Skip to content

Commit

Permalink
build: solc 0.4.24 to 0.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GMSteuart committed Aug 1, 2020
1 parent 5ec2a6e commit ff5fd9a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
6 changes: 3 additions & 3 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity 0.4.24;
pragma solidity >=0.4.24 <0.7.0;

contract Migrations {
address public owner;
uint public last_completed_migration;
uint256 public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _;
Expand All @@ -12,7 +12,7 @@ contract Migrations {
owner = msg.sender;
}

function setCompleted(uint completed) public restricted {
function setCompleted(uint256 completed) public restricted {
last_completed_migration = completed;
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/MyContract.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity 0.4.24;
pragma solidity 0.6.6;

import "@chainlink/contracts/src/v0.4/ChainlinkClient.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
import "openzeppelin-solidity/contracts/access/Ownable.sol";

/**
* @title MyContract is an example contract which requests data from
Expand Down Expand Up @@ -105,4 +105,4 @@ contract MyContract is ChainlinkClient, Ownable {
{
cancelChainlinkRequest(_requestId, _payment, _callbackFunctionId, _expiration);
}
}
}
19 changes: 9 additions & 10 deletions migrations/2_mycontract_migration.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
const MyContract = artifacts.require('MyContract')
const { LinkToken } = require('@chainlink/contracts/truffle/v0.4/LinkToken')
const { Oracle } = require('@chainlink/contracts/truffle/v0.4/Oracle')
const { Oracle } = require('@chainlink/contracts/truffle/v0.6/Oracle')

module.exports = (deployer, network, [defaultAccount]) => {
module.exports = async (deployer, network, [defaultAccount]) => {
// Local (development) networks need their own deployment of the LINK
// token and the Oracle contract
if (!network.startsWith('live')) {
LinkToken.setProvider(deployer.provider)
Oracle.setProvider(deployer.provider)

deployer.deploy(LinkToken, { from: defaultAccount }).then(link => {
return deployer
.deploy(Oracle, link.address, { from: defaultAccount })
.then(() => {
return deployer.deploy(MyContract, link.address)
})
})
try {
await deployer.deploy(LinkToken, { from: defaultAccount })
await deployer.deploy(Oracle, LinkToken.address, { from: defaultAccount })
await deployer.deploy(MyContract, LinkToken.address)
} catch (err) {
console.error(err)
}
} else {
// For live networks, use the 0 address to allow the ChainlinkRegistry
// contract automatically retrieve the correct address for you
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"license": "MIT",
"dependencies": {
"@chainlink/contracts": "^0.0.3",
"@chainlink/test-helpers": "0.0.2",
"openzeppelin-solidity": "1.12.0"
"@chainlink/contracts": "^0.0.8",
"@chainlink/test-helpers": "0.0.5",
"openzeppelin-solidity": "^3.0.0"
},
"devDependencies": {
"@chainlink/belt": "^0.0.1",
Expand Down
18 changes: 11 additions & 7 deletions scripts/fund-contract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const MyContract = artifacts.require('MyContract')
const { LinkToken } = require('@chainlink/contracts/truffle/v0.4/LinkToken')
const LinkTokenInterface = artifacts.require('LinkTokenInterface')

/*
This script is meant to assist with funding the requesting
Expand All @@ -11,10 +11,14 @@ const { LinkToken } = require('@chainlink/contracts/truffle/v0.4/LinkToken')
const payment = process.env.TRUFFLE_CL_BOX_PAYMENT || '1000000000000000000'

module.exports = async callback => {
const mc = await MyContract.deployed()
const tokenAddress = await mc.getChainlinkToken()
const token = await LinkToken.at(tokenAddress)
console.log('Funding contract:', mc.address)
const tx = await token.transfer(mc.address, payment)
callback(tx.tx)
try {
const mc = await MyContract.deployed()
const tokenAddress = await mc.getChainlinkToken()
const token = await LinkTokenInterface.at(tokenAddress)
console.log('Funding contract:', mc.address)
const tx = await token.transfer(mc.address, payment)
callback(tx.tx)
} catch (err) {
callback(err)
}
}
2 changes: 1 addition & 1 deletion test/MyContract_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { expectRevert, time } = require('openzeppelin-test-helpers')

contract('MyContract', accounts => {
const { LinkToken } = require('@chainlink/contracts/truffle/v0.4/LinkToken')
const { Oracle } = require('@chainlink/contracts/truffle/v0.4/Oracle')
const { Oracle } = require('@chainlink/contracts/truffle/v0.6/Oracle')
const MyContract = artifacts.require('MyContract.sol')

const defaultAccount = accounts[0]
Expand Down
7 changes: 6 additions & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module.exports = {
port: 8545,
network_id: '*',
},
ganache: {
host: '127.0.0.1',
port: 7545,
network_id: '*',
},
live: {
provider: () => {
return new HDWalletProvider(process.env.MNEMONIC, process.env.RPC_URL)
Expand All @@ -19,7 +24,7 @@ module.exports = {
},
compilers: {
solc: {
version: '0.4.24',
version: '0.6.6',
},
},
}

0 comments on commit ff5fd9a

Please sign in to comment.