Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
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)
}
}
4 changes: 2 additions & 2 deletions test/MyContract_test.js
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
11 changes: 8 additions & 3 deletions truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
}