Skip to content

Commit

Permalink
feat: added examples with duplicated data feed ids
Browse files Browse the repository at this point in the history
  • Loading branch information
hatskier committed Nov 9, 2022
1 parent 1c3730f commit 3032210
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions contracts/AvalancheProdExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ contract AvalancheProdExample is AvalancheDataServiceConsumerBase {
{
return getOracleNumericValuesFromTxMsg(dataFeedIds);
}

function getLatestPricesForManyAssetsWithDuplicates(bytes32[] memory dataFeedIdsWithDuplicates)
public
view
returns (uint256[] memory)
{
return getOracleNumericValuesWithDuplicatesFromTxMsg(dataFeedIdsWithDuplicates);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"typechain": "^8.1.0"
},
"dependencies": {
"@redstone-finance/evm-connector": "^0.0.9",
"@redstone-finance/evm-connector": "^0.0.11",
"redstone-protocol": "^1.0.2",
"redstone-sdk": "^1.0.3"
}
Expand Down
11 changes: 11 additions & 0 deletions test/AvalancheProdExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ describe("AvalancheProdExample", function () {
const prices = await wrappedContract.getLatestPricesForManyAssets(ids);
console.log(prices);
});

it("Get price for AVAX, ETH, and PNG in the same call (with dupliates)", async () => {
// Wrapping the contract
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({
dataServiceId: "redstone-avalanche-prod",
uniqueSignersCount: 10,
}, redstoneCacheLayerUrls);
const ids = ["AVAX", "ETH", "PNG", "ETH", "ETH", "PNG"].map(dataFeedId => formatBytes32String(dataFeedId));
const prices = await wrappedContract.getLatestPricesForManyAssetsWithDuplicates(ids);
console.log(prices);
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,10 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.7.3.tgz#939534757a81f8d69cc854c7692805684ff3111e"
integrity sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==

"@redstone-finance/evm-connector@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.0.9.tgz#a94dad677c645e41689537da1bf56ec584b50c0d"
integrity sha512-TkW4tr986e4pCh2SKXaOhI1yzzhX3MsAZyHMOEPt6TD2WdOuyzTpGwnDBVt5np8uKSVbnAs/CnP6/bXqXoe4UA==
"@redstone-finance/evm-connector@^0.0.11":
version "0.0.11"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.0.11.tgz#531f649e6b00d0d0d55b75003ac718e946983a55"
integrity sha512-nN+nFN9oUxC6uqphMNe2iz8DUZ0bAhv4bLsFssn2Z+LErZbkNitGSpxYAJ43F1E0v3PswJmoeQWPLxALFrgkwA==
dependencies:
"@openzeppelin/contracts" "^4.7.3"
axios "^1.1.3"
Expand Down

0 comments on commit 3032210

Please sign in to comment.