Skip to content

Commit

Permalink
feat: add example for custom-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
cehali committed Feb 24, 2023
1 parent b104e46 commit 1007e9d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 7 deletions.
12 changes: 12 additions & 0 deletions contracts/CustomUrlsExample.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

contract CustomUrlsExample is CustomUrlsConsumerBase {
function getValue() public view returns (uint256) {
bytes32 dataFeedId = bytes32("0x60cbe6b18347697f");
return getOracleNumericValueFromTxMsg(dataFeedId);
}
}
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.18",
"@redstone-finance/evm-connector": "^0.0.21",
"redstone-protocol": "^1.0.5",
"redstone-sdk": "^1.0.7"
}
Expand Down
24 changes: 24 additions & 0 deletions test/CustomUrlsExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { WrapperBuilder } = require("@redstone-finance/evm-connector");

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

beforeEach(async () => {
// Deploy contract
const CustomUrlsExample = await ethers.getContractFactory("CustomUrlsExample");
contract = await CustomUrlsExample.deploy();
});

it("Get Custom Url (Bored Ape Yacht Club floor price) price securely", async function () {
// Wrapping the contract
const wrappedContract = WrapperBuilder.wrap(contract).usingDataService({
dataServiceId: "redstone-custom-urls-demo",
uniqueSignersCount: 2,
dataFeeds: ["0x60cbe6b18347697f"],
}, ["https://d1zm8lxy9v2ddd.cloudfront.net"]);

// Interact with the contract (getting oracle value securely)
const value = await wrappedContract.getValue();
console.log({ value });
});
});
94 changes: 88 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,47 @@
# yarn lockfile v1


"@chainlink/contracts@^0.6.0":
version "0.6.1"
resolved "https://registry.yarnpkg.com/@chainlink/contracts/-/contracts-0.6.1.tgz#8842b57e755793cbdbcbc45277fb5d179c993e19"
integrity sha512-EuwijGexttw0UjfrW+HygwhQIrGAbqpf1ue28R55HhWMHBzphEH0PhWm8DQmFfj5OZNy8Io66N4L0nStkZ3QKQ==
dependencies:
"@eth-optimism/contracts" "^0.5.21"
"@openzeppelin/contracts" "~4.3.3"
"@openzeppelin/contracts-upgradeable" "^4.7.3"
"@openzeppelin/contracts-v0.7" "npm:@openzeppelin/[email protected]"

"@eth-optimism/contracts@^0.5.21":
version "0.5.40"
resolved "https://registry.yarnpkg.com/@eth-optimism/contracts/-/contracts-0.5.40.tgz#d13a04a15ea947a69055e6fc74d87e215d4c936a"
integrity sha512-MrzV0nvsymfO/fursTB7m/KunkPsCndltVgfdHaT1Aj5Vi6R/doKIGGkOofHX+8B6VMZpuZosKCMQ5lQuqjt8w==
dependencies:
"@eth-optimism/core-utils" "0.12.0"
"@ethersproject/abstract-provider" "^5.7.0"
"@ethersproject/abstract-signer" "^5.7.0"

"@eth-optimism/[email protected]":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@eth-optimism/core-utils/-/core-utils-0.12.0.tgz#6337e4599a34de23f8eceb20378de2a2de82b0ea"
integrity sha512-qW+7LZYCz7i8dRa7SRlUKIo1VBU8lvN0HeXCxJR+z+xtMzMQpPds20XJNCMclszxYQHkXY00fOT6GvFw9ZL6nw==
dependencies:
"@ethersproject/abi" "^5.7.0"
"@ethersproject/abstract-provider" "^5.7.0"
"@ethersproject/address" "^5.7.0"
"@ethersproject/bignumber" "^5.7.0"
"@ethersproject/bytes" "^5.7.0"
"@ethersproject/constants" "^5.7.0"
"@ethersproject/contracts" "^5.7.0"
"@ethersproject/hash" "^5.7.0"
"@ethersproject/keccak256" "^5.7.0"
"@ethersproject/properties" "^5.7.0"
"@ethersproject/providers" "^5.7.0"
"@ethersproject/rlp" "^5.7.0"
"@ethersproject/transactions" "^5.7.0"
"@ethersproject/web" "^5.7.0"
bufio "^1.0.7"
chai "^4.3.4"

"@ethersproject/[email protected]", "@ethersproject/abi@^5.0.0-beta.146", "@ethersproject/abi@^5.0.9", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.4.7", "@ethersproject/abi@^5.7.0":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.7.0.tgz#b3f3e045bbbeed1af3947335c247ad625a44e449"
Expand Down Expand Up @@ -90,7 +131,7 @@
dependencies:
"@ethersproject/bignumber" "^5.7.0"

"@ethersproject/[email protected]":
"@ethersproject/[email protected]", "@ethersproject/contracts@^5.7.0":
version "5.7.0"
resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.7.0.tgz#c305e775abd07e48aa590e1a877ed5c316f8bd1e"
integrity sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==
Expand Down Expand Up @@ -219,7 +260,7 @@
bech32 "1.1.4"
ws "7.4.6"

"@ethersproject/[email protected]":
"@ethersproject/[email protected]", "@ethersproject/providers@^5.7.0":
version "5.7.2"
resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb"
integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==
Expand Down Expand Up @@ -660,16 +701,32 @@
table "^6.8.0"
undici "^5.4.0"

"@openzeppelin/contracts-upgradeable@^4.7.3":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.1.tgz#363f7dd08f25f8f77e16d374350c3d6b43340a7a"
integrity sha512-1wTv+20lNiC0R07jyIAbHU7TNHKRwGiTGRfiNnA8jOWjKT98g5OgLpYWOi40Vgpk8SPLA9EvfJAbAeIyVn+7Bw==

"@openzeppelin/contracts-v0.7@npm:@openzeppelin/[email protected]":
version "3.4.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2.tgz#d81f786fda2871d1eb8a8c5a73e455753ba53527"
integrity sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA==

"@openzeppelin/contracts@^4.7.3":
version "4.7.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.7.3.tgz#939534757a81f8d69cc854c7692805684ff3111e"
integrity sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==

"@redstone-finance/evm-connector@^0.0.18":
version "0.0.18"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.0.18.tgz#f66b086929e7be7a455c5bc6e3866eef5b88b5f5"
integrity sha512-i0q0atO/LjbyBKI3+vXSBdvcthXuqhCWxbnYqeceS7s3JKtO8iEfZ36eWJ5s3Y6osrpNC4nzxhvam1Ac3CX1UA==
"@openzeppelin/contracts@~4.3.3":
version "4.3.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.3.3.tgz#ff6ee919fc2a1abaf72b22814bfb72ed129ec137"
integrity sha512-tDBopO1c98Yk7Cv/PZlHqrvtVjlgK5R4J6jxLwoO7qxK4xqOiZG+zSkIvGFpPZ0ikc3QOED3plgdqjgNTnBc7g==

"@redstone-finance/evm-connector@^0.0.21":
version "0.0.21"
resolved "https://registry.yarnpkg.com/@redstone-finance/evm-connector/-/evm-connector-0.0.21.tgz#63628318ea56ba635b8af49e91ee4fe7608bb883"
integrity sha512-I61eKTVB4PnrpbCWm3QhxZlIzqLOAlYaBhjTfy/E6ON0zX20PtGdXI+nbHm8917xYlObNQT1mfHr3Yp/z9xEOw==
dependencies:
"@chainlink/contracts" "^0.6.0"
"@openzeppelin/contracts" "^4.7.3"
axios "^1.1.3"
ethers "^5.6.8"
Expand Down Expand Up @@ -1324,6 +1381,11 @@ buffer@^6.0.3:
base64-js "^1.3.1"
ieee754 "^1.2.1"

bufio@^1.0.7:
version "1.2.0"
resolved "https://registry.yarnpkg.com/bufio/-/bufio-1.2.0.tgz#b9ad1c06b0d9010363c387c39d2810a7086d143f"
integrity sha512-UlFk8z/PwdhYQTXSQQagwGAdtRI83gib2n4uy4rQnenxUM2yQi8lBDzF230BNk+3wAoZDxYRoBwVVUPgHa9MCA==

busboy@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893"
Expand Down Expand Up @@ -1392,6 +1454,19 @@ chai@^4.2.0:
pathval "^1.1.1"
type-detect "^4.0.5"

chai@^4.3.4:
version "4.3.7"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51"
integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==
dependencies:
assertion-error "^1.1.0"
check-error "^1.0.2"
deep-eql "^4.1.2"
get-func-name "^2.0.0"
loupe "^2.3.1"
pathval "^1.1.1"
type-detect "^4.0.5"

chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
Expand Down Expand Up @@ -1685,6 +1760,13 @@ deep-eql@^4.0.1:
dependencies:
type-detect "^4.0.0"

deep-eql@^4.1.2:
version "4.1.3"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d"
integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==
dependencies:
type-detect "^4.0.0"

deep-extend@~0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
Expand Down

0 comments on commit 1007e9d

Please sign in to comment.