Skip to content

Commit

Permalink
Updates based on v0.2 (#11)
Browse files Browse the repository at this point in the history
* fix: updates based on v0.2

* feat: update based on feedback

* fix: update nvm version for github action

* fix: update trigger

* fix: remove comments
  • Loading branch information
nick-bisonai authored Jun 14, 2024
1 parent e737587 commit eb8209d
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 397 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/misc.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ on:
- "contracts/**"
- "deploy/**"
- "scripts/**"
- ".github/workflows/misc.test.yaml"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.12"
node-version: "20.10.0"
- run: yarn
working-directory: ./contracts
- run: yarn solhint
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.12
20.10.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ yarn compile
## Deploy

```shell
# aggregator example
# feed example
npx hardhat deploy --network baobab --deploy-scripts deploy/DataFeedConsumer
```

Expand Down
17 changes: 7 additions & 10 deletions contracts/DataFeedConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;

import {IAggregator} from "@bisonai/orakl-contracts/src/v0.1/interfaces/IAggregator.sol";
pragma solidity ^0.8.20;

import {IFeedProxy} from "@bisonai/orakl-contracts/v0.2/src/interfaces/IFeedProxy.sol";

contract DataFeedConsumer {
IAggregator internal dataFeed;
IFeedProxy internal feedProxy;
int256 public answer;
uint80 public roundId;

constructor(address aggregatorProxy) {
dataFeed = IAggregator(aggregatorProxy);
constructor(address _feedProxy) {
feedProxy = IFeedProxy(_feedProxy);
}

function getLatestData() public {
(
uint80 roundId_,
int256 answer_
, /* uint startedAt */
, /* uint updatedAt */
, /* uint80 answeredInRound */
) = dataFeed.latestRoundData();
) = feedProxy.latestRoundData();

answer = answer_;
roundId = roundId_;
}

function decimals() public view returns (uint8) {
return dataFeed.decimals();
return feedProxy.decimals();
}
}
11 changes: 5 additions & 6 deletions contracts/DataFeedRouterConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma solidity ^0.8.20;

import {IAggregatorRouter} from "@bisonai/orakl-contracts/src/v0.1/interfaces/IAggregatorRouter.sol";
import {IFeedRouter} from "@bisonai/orakl-contracts/v0.2/src/interfaces/IFeedRouter.sol";

contract DataFeedRouterConsumer {
IAggregatorRouter internal router;
IFeedRouter internal router;
int256 public answer;
uint80 public roundId;

constructor(address aggregatorRouter) {
router = IAggregatorRouter(aggregatorRouter);
router = IFeedRouter(aggregatorRouter);
}


function getLatestData(string calldata pair) public {
(
uint80 roundId_,
int256 answer_
, /* uint startedAt */
, /* uint updatedAt */
, /* uint80 answeredInRound */

) = router.latestRoundData(pair);

answer = answer_;
Expand Down
4 changes: 2 additions & 2 deletions deploy/DataFeedConsumer/DataFeedConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DeployFunction } from 'hardhat-deploy/types'
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, network } = hre
const { deploy } = deployments
const { deployer, aggregatorProxy: aggregatorProxyAddress } = await getNamedAccounts()
const { deployer, feedProxy: feedProxyAddress } = await getNamedAccounts()

console.log('0-DataFeedConsumer.ts')

Expand All @@ -14,7 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

await deploy('DataFeedConsumer', {
args: [aggregatorProxyAddress],
args: [feedProxyAddress],
from: deployer,
log: true
})
Expand Down
4 changes: 2 additions & 2 deletions deploy/DataFeedRouterConsumer/DataFeedRouterConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DeployFunction } from 'hardhat-deploy/types'
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, network } = hre
const { deploy } = deployments
const { deployer, aggregatorRouter: aggregatorRouterAddress } = await getNamedAccounts()
const { deployer, feedRouter: feedRouterAddress } = await getNamedAccounts()

console.log('1-DataFeedRouterConsumer.ts')

Expand All @@ -14,7 +14,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

await deploy('DataFeedRouterConsumer', {
args: [aggregatorRouterAddress],
args: [feedRouterAddress],
from: deployer,
log: true
})
Expand Down
12 changes: 5 additions & 7 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (process.env.PRIV_KEY) {

const config: HardhatUserConfig = {
solidity: {
version: '0.8.16',
version: '0.8.20',
settings: {
optimizer: {
enabled: true,
Expand Down Expand Up @@ -58,13 +58,11 @@ const config: HardhatUserConfig = {
### Contract Addresses
https://raw.githubusercontent.com/Bisonai/orakl/master/contracts/v0.1/deployments/datafeeds-addresses.json
*/
aggregatorProxy: {
baobab: '0x4b0687ce6eC3Fe6c019467c744D0C563643BdFa4' // BTC-USDT
// cypress: '0xc0516486DD0837a8Dd6E502F9134Ff3c421377AC', // BTC-USDT
feedProxy: {
baobab: '0x23c95f4842ac01a6eca3381005c5749f575ea801' // BTC-USDT
},
aggregatorRouter: {
baobab: '0xAF821aaaEdeF65b3bC1668c0b910c5b763dF6354'
//cypress: '0x16937CFc59A8Cd126Dc70A75A4bd3b78f690C861'
feedRouter: {
baobab: '0xd9dbbb92a6ecb8b8d3e386b8d0ad8284bd816ef1'
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"solhint": "./node_modules/.bin/solhint -f table contracts/*.sol"
},
"devDependencies": {
"@bisonai/orakl-contracts": "^1.4.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomicfoundation/hardhat-toolbox": "^2.0.1",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"@nomiclabs/hardhat-etherscan": "^3.1.5",
"@bisonai/orakl-contracts": "^2.0.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^1.0.1",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@typechain/ethers-v5": "^10.2.0",
"@typechain/hardhat": "^6.1.5",
Expand All @@ -27,9 +28,9 @@
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"ethers": "^5.7.2",
"hardhat": "^2.12.6",
"hardhat-deploy": "^0.11.22",
"hardhat-gas-reporter": "^1.0.9",
"hardhat": "^2.20.1",
"hardhat-deploy": "^0.11.45",
"hardhat-gas-reporter": "^1.0.8",
"prettier": "^2.8.4",
"solhint": "^3.3.8",
"solhint-plugin-prettier": "^0.0.5",
Expand Down
Loading

0 comments on commit eb8209d

Please sign in to comment.