diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol index cffe8b9..94daaea 100644 --- a/contracts/Migrations.sol +++ b/contracts/Migrations.sol @@ -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) _; @@ -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; } diff --git a/contracts/MyContract.sol b/contracts/MyContract.sol index efc9294..f1a6a09 100644 --- a/contracts/MyContract.sol +++ b/contracts/MyContract.sol @@ -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/contracts/access/Ownable.sol"; /** * @title MyContract is an example contract which requests data from @@ -105,4 +105,4 @@ contract MyContract is ChainlinkClient, Ownable { { cancelChainlinkRequest(_requestId, _payment, _callbackFunctionId, _expiration); } -} \ No newline at end of file +} diff --git a/migrations/2_mycontract_migration.js b/migrations/2_mycontract_migration.js index 19c1ab7..8030f60 100644 --- a/migrations/2_mycontract_migration.js +++ b/migrations/2_mycontract_migration.js @@ -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 diff --git a/package.json b/package.json index 9c260c5..62a251e 100644 --- a/package.json +++ b/package.json @@ -15,16 +15,16 @@ }, "license": "MIT", "dependencies": { - "@chainlink/contracts": "^0.0.3", - "@chainlink/test-helpers": "0.0.2", - "openzeppelin-solidity": "1.12.0" + "@chainlink/contracts": "^0.0.8", + "@openzeppelin/contracts": "^3.1.0", + "@truffle/hdwallet-provider": "^1.0.40" }, "devDependencies": { "@chainlink/belt": "^0.0.1", - "@truffle/hdwallet-provider": "^1.0.30", + "@chainlink/test-helpers": "0.0.5", + "@openzeppelin/test-helpers": "^0.5.6", "chai": "^4.2.0", "depcheck": "^0.9.1", - "openzeppelin-test-helpers": "^0.4.3", "solhint": "^2.1.0", "truffle": "^5.1.5" } diff --git a/scripts/fund-contract.js b/scripts/fund-contract.js index 549e567..45fe8b1 100644 --- a/scripts/fund-contract.js +++ b/scripts/fund-contract.js @@ -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 @@ -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) + } } diff --git a/test/MyContract_test.js b/test/MyContract_test.js index dd9c076..ac0c8a5 100644 --- a/test/MyContract_test.js +++ b/test/MyContract_test.js @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const { oracle } = require('@chainlink/test-helpers') -const { expectRevert, time } = require('openzeppelin-test-helpers') +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] diff --git a/truffle-config.js b/truffle-config.js index 75b1185..c612ec0 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -7,19 +7,24 @@ 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) }, network_id: '*', - // Necessary due to https://github.com/trufflesuite/truffle/issues/1971 - // Should be fixed in Truffle 5.0.17 + // ~~Necessary due to https://github.com/trufflesuite/truffle/issues/1971~~ + // Necessary due to https://github.com/trufflesuite/truffle/issues/3008 skipDryRun: true, }, }, compilers: { solc: { - version: '0.4.24', + version: '0.6.6', }, }, }