Skip to content

Commit

Permalink
refactored for 0.8 and new oracle and jobids
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAlphaC committed Oct 12, 2021
1 parent 2ec1182 commit e6b1d94
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ autoflake --in-place --remove-unused-variables --remove-all-unused-imports -r .
black .
```

If you're using [vscode](https://code.visualstudio.com/) and the [solidity extension](https://github.com/juanfranblanco/vscode-solidity), you can create a folder called `.vscode` at the root folder of this project, and create a file called `settings.json`, and add the following content:

```json
{
"solidity.remappings": [
"@chainlink/=[YOUR_HOME_DIR]/.brownie/packages/smartcontractkit/[email protected]",
"@openzeppelin/=[YOUR_HOME_DIR]/.brownie/packages/OpenZeppelin/[email protected]"
]
}
```
This will quiet the linting errors it gives you.

## Resources

To get started with Brownie:
Expand Down
16 changes: 8 additions & 8 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ reports:
exclude_contracts:
- SafeMath
dependencies:
- smartcontractkit/[email protected].1
- OpenZeppelin/openzeppelin-contracts@3.4.0
- smartcontractkit/[email protected].2
- OpenZeppelin/openzeppelin-contracts@4.3.2
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected].1'
- '@openzeppelin=OpenZeppelin/openzeppelin-contracts@3.4.0'
- '@chainlink=smartcontractkit/[email protected].2'
- '@openzeppelin=OpenZeppelin/openzeppelin-contracts@4.3.2'
# automatically fetch contract sources from Etherscan
autofetch_sources: True
# Uncomment to use the .env file
Expand All @@ -29,8 +29,8 @@ networks:
link_token: '0xa36085F69e2889c224210F603D836748e7dC0088'
keyhash: '0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4'
fee: 100000000000000000
oracle: '0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e'
jobId: '29fa9aa13bf1468788b7cc4a500a45b8'
oracle: '0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8'
jobId: 'd5270d1c311941d0b08bead21fea7747'
eth_usd_price_feed: '0x9326BFA02ADD2366b30bacB125260Af641031331'
# Change to True if you have an Etherscan API key and want to verify
verify: False
Expand All @@ -46,8 +46,8 @@ networks:
link_token: '0x01be23585060835e02b77ef475b0cc51aa1e0709'
keyhash: '0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311'
fee: 100000000000000000
oracle: '0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e'
jobId: '6d1bfe27e7034b1d87b5270556b17277'
oracle: '0xc57b33452b4f7bb189bb5afae9cc4aba1f7a4fd8'
jobId: '6b88e0402e5d415eb946e528b8e0c7ba'
eth_usd_price_feed: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'
# Change to True if you have an Etherscan API key and want to verify
verify: False
Expand Down
8 changes: 4 additions & 4 deletions contracts/APIConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

contract APIConsumer is ChainlinkClient {

using Chainlink for Chainlink.Request;
uint256 public volume;

address private oracle;
Expand All @@ -17,7 +17,7 @@ contract APIConsumer is ChainlinkClient {
* Job ID: 29fa9aa13bf1468788b7cc4a500a45b8
* Fee: 0.1 LINK
*/
constructor(address _oracle, string memory _jobId, uint256 _fee, address _link) public {
constructor(address _oracle, string memory _jobId, uint256 _fee, address _link) {
if (_link == address(0)) {
setPublicChainlinkToken();
} else {
Expand Down
11 changes: 4 additions & 7 deletions contracts/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pragma solidity ^0.6.7;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;


interface KeeperCompatibleInterface {
function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
function performUpkeep(bytes calldata performData) external;
}
import "@chainlink/contracts/src/v0.8/interfaces/KeeperCompatibleInterface.sol";

contract Counter is KeeperCompatibleInterface {
/**
Expand All @@ -20,7 +17,7 @@ contract Counter is KeeperCompatibleInterface {
uint public lastTimeStamp;


constructor(uint updateInterval) public {
constructor(uint updateInterval) {
interval = updateInterval;
lastTimeStamp = block.timestamp;

Expand Down
6 changes: 3 additions & 3 deletions contracts/PriceFeedConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract PriceFeedConsumer {

Expand All @@ -18,7 +18,7 @@ contract PriceFeedConsumer {
* Aggregator: ETH/USD
* Address: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
*/
constructor(address AggregatorAddress) public {
constructor(address AggregatorAddress) {
priceFeed = AggregatorV3Interface(AggregatorAddress);
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/VRFConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.6.6;
pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";

contract VRFConsumer is VRFConsumerBase {

Expand All @@ -22,7 +22,7 @@ contract VRFConsumer is VRFConsumerBase {
VRFConsumerBase(
_vrfCoordinator, // VRF Coordinator
_linkToken // LINK Token
) public
)
{
keyHash = _keyhash;
// fee = 0.1 * 10 ** 18; // 0.1 LINK
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_returns_random_number_testnet(
transaction_receipt = vrf_consumer.getRandomNumber({"from": get_account()})
assert isinstance(transaction_receipt.txid, str)
transaction_receipt.wait(1)
time.sleep(35)
time.sleep(90)
# Assert
assert vrf_consumer.randomResult() > 0
assert isinstance(vrf_consumer.randomResult(), int)

0 comments on commit e6b1d94

Please sign in to comment.