forked from ERFIFTEEN/redstone-evm-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update redstone-sdk and evm-connector
- Loading branch information
Showing
6 changed files
with
64 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.4; | ||
|
||
import "@redstone-finance/evm-connector/contracts/data-services/PrimaryDemoDataServiceConsumerBase.sol"; | ||
|
||
contract PrimaryDemoExample is PrimaryDemoDataServiceConsumerBase { | ||
function getLatestPrice(bytes32 dataFeedId) public view returns (uint256) { | ||
return getOracleNumericValueFromTxMsg(dataFeedId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { formatBytes32String } = require("ethers/lib/utils"); | ||
const { WrapperBuilder } = require("@redstone-finance/evm-connector"); | ||
|
||
const redstoneCacheLayerUrls = [ | ||
|
||
]; | ||
|
||
// TODO: update after dev cache service for primary node will be deployed | ||
describe.skip("PrimaryDemoExample", function () { | ||
let contract; | ||
|
||
beforeEach(async () => { | ||
// Deploy contract | ||
const PrimaryProdExample = await ethers.getContractFactory("PrimaryDemoExample"); | ||
contract = await PrimaryProdExample.deploy(); | ||
}); | ||
|
||
it("Get VST price securely", async function () { | ||
// Wrapping the contract | ||
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({ | ||
dataFeeds: ["VST"], | ||
urls: redstoneCacheLayerUrls, | ||
}); | ||
|
||
// Interact with the contract (getting oracle value securely) | ||
const vstPriceFromContract = await wrappedContract.getLatestPrice(formatBytes32String("VST")); | ||
console.log({ vstPriceFromContract }); | ||
}); | ||
|
||
it("Get SWETH price securely", async function () { | ||
// Wrapping the contract | ||
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({ | ||
dataFeeds: ["SWETH"], | ||
urls: redstoneCacheLayerUrls, | ||
}); | ||
|
||
// Interact with the contract (getting oracle value securely) | ||
const swethPriceFromContract = await wrappedContract.getLatestPrice(formatBytes32String("SWETH")); | ||
console.log({ swethPriceFromContract }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters