Skip to content

Commit

Permalink
feat: update redstone-sdk and evm-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
koonopek committed Jun 6, 2023
1 parent 3c765f3 commit 820a90b
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 43 deletions.
11 changes: 11 additions & 0 deletions contracts/PrimaryDemoExample.sol
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);
}
}
26 changes: 2 additions & 24 deletions contracts/PrimaryProdExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,9 @@

pragma solidity ^0.8.4;

import "@redstone-finance/evm-connector/contracts/data-services/AvalancheDataServiceConsumerBase.sol";

contract PrimaryProdExample is AvalancheDataServiceConsumerBase {
function getUniqueSignersThreshold() public view virtual override returns (uint8) {
return 3;
}

function getAuthorisedSignerIndex(
address signerAddress
) public view virtual override returns (uint8) {
if (signerAddress == 0x8BB8F32Df04c8b654987DAaeD53D6B6091e3B774) {
return 0;
} else if (signerAddress == 0xdEB22f54738d54976C4c0fe5ce6d408E40d88499) {
return 1;
} else if (signerAddress == 0x51Ce04Be4b3E32572C4Ec9135221d0691Ba7d202) {
return 2;
} else if (signerAddress == 0xDD682daEC5A90dD295d14DA4b0bec9281017b5bE) {
return 3;
} else if (signerAddress == 0x9c5AE89C4Af6aA32cE58588DBaF90d18a855B6de) {
return 4;
} else {
revert SignerNotAuthorised(signerAddress);
}
}
import "@redstone-finance/evm-connector/contracts/data-services/PrimaryProdDataServiceConsumerBase.sol";

contract PrimaryProdExample is PrimaryProdDataServiceConsumerBase {
function getLatestPrice(bytes32 dataFeedId) public view returns (uint256) {
return getOracleNumericValueFromTxMsg(dataFeedId);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"typechain": "^8.1.0"
},
"dependencies": {
"@redstone-finance/evm-connector": "0.1.0",
"@redstone-finance/evm-connector": "^0.2.0",
"redstone-protocol": "^1.0.5",
"redstone-sdk": "1.1.0"
"redstone-sdk": "^1.3.0"
}
}
41 changes: 41 additions & 0 deletions test/PrimaryDemoExample.js
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 });
});
});
9 changes: 0 additions & 9 deletions test/PrimaryProdExample.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const { formatBytes32String } = require("ethers/lib/utils");
const { WrapperBuilder } = require("@redstone-finance/evm-connector");

const redstoneCacheLayerUrls = [
"https://oracle-gateway-1.a.redstone.finance",
"https://oracle-gateway-2.a.redstone.finance",
];

describe("PrimaryProdExample", function () {
let contract;

Expand All @@ -19,8 +14,6 @@ describe("PrimaryProdExample", function () {
// Wrapping the contract
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({
dataFeeds: ["VST"],
dataServiceId: "redstone-primary-prod",
urls: redstoneCacheLayerUrls,
});

// Interact with the contract (getting oracle value securely)
Expand All @@ -32,8 +25,6 @@ describe("PrimaryProdExample", function () {
// Wrapping the contract
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({
dataFeeds: ["SWETH"],
dataServiceId: "redstone-primary-prod",
urls: redstoneCacheLayerUrls,
});

// Interact with the contract (getting oracle value securely)
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,10 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.3.tgz#ff6ee919fc2a1abaf72b22814bfb72ed129ec137"
integrity sha512-tDBopO1c98Yk7Cv/PZlHqrvtVjlgK5R4J6jxLwoO7qxK4xqOiZG+zSkIvGFpPZ0ikc3QOED3plgdqjgNTnBc7g==

"@redstone-finance/evm-connector@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.1.0.tgz#4fef3312bac98ce72d685cec71e955a7e6dc1522"
integrity sha512-1JmHagppQAiAomlw85Nk9Qmdyw+pkoiz0uPpZ498a/jFZf5OGZ8L1uzfcV79vY3qJFcwrmKjYW9J2o0QFfDmSA==
"@redstone-finance/evm-connector@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.2.0.tgz#0e22324883fecba83dbcef7dc73bcf0f62c9e1c5"
integrity sha512-GGZUYYrK2iSLjlgKBfp0Jf0drlj3oTP5XwyZJzhbEm/oPOcytj/aUCutQNmgX+AE3/zWCNc0tQE3DOlzyzL18Q==
dependencies:
"@chainlink/contracts" "^0.6.1"
"@openzeppelin/contracts" "^4.7.3"
Expand Down Expand Up @@ -3871,10 +3871,10 @@ redstone-protocol@^1.0.5:
dependencies:
ethers "^5.6.8"

redstone-sdk@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/redstone-sdk/-/redstone-sdk-1.1.0.tgz#9ba48bb41e12e0d4a305506aef280e632e88e437"
integrity sha512-4dYgaIAb+iJ2RK2d/r/hqa2S1VC1JpZGqCtNqYoV3wjKITP9Nl1UKh9Ho7YBXY+/q6Hwx8/NQo/1kxcilxIfrg==
redstone-sdk@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/redstone-sdk/-/redstone-sdk-1.3.0.tgz#4e46ad0e770e3e5e8b64d94145d8cf5e0041520a"
integrity sha512-e/kn5xZPL58/0i/ZEnrBylBnfnVztnlvGeeWaU47zYbAjpSc8P3mbj69h3P1OH84Ob9u3LOfB33vBlgRxYKQng==
dependencies:
axios "^0.27.2"
redstone-oracles-smartweave-contracts "*"
Expand Down

0 comments on commit 820a90b

Please sign in to comment.