diff --git a/contracts/EventManager.sol b/contracts/EventManager.sol index 9becbbc..bfc80d3 100644 --- a/contracts/EventManager.sol +++ b/contracts/EventManager.sol @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 +import {TestFtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/TestFtsoV2Interface.sol"; pragma solidity >=0.8.2 <0.9.0; diff --git a/contracts/FlareOracle.sol b/contracts/FlareOracle.sol new file mode 100644 index 0000000..373ca79 --- /dev/null +++ b/contracts/FlareOracle.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0 <0.9.0; + +import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol"; +/* THIS IS A TEST IMPORT, in production use: import {FtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/FtsoV2Interface.sol"; */ +import {TestFtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/TestFtsoV2Interface.sol"; + +/** + * THIS IS AN EXAMPLE CONTRACT. + * DO NOT USE THIS CODE IN PRODUCTION. + */ +contract FtsoV2FeedConsumer { + TestFtsoV2Interface internal ftsoV2; + // Feed IDs, see https://dev.flare.network/ftso/feeds for full list + bytes21[] public feedIds = [ + bytes21(0x01464c522f55534400000000000000000000000000) // FLR/USD + // bytes21(0x014254432f55534400000000000000000000000000), // BTC/USD + // bytes21(0x014554482f55534400000000000000000000000000) // ETH/USD + ]; + + /** + * Constructor initializes the FTSOv2 contract. + * The contract registry is used to fetch the FtsoV2 contract address. + */ + constructor() { + /* THIS IS A TEST METHOD, in production use: ftsoV2 = ContractRegistry.getFtsoV2(); */ + ftsoV2 = ContractRegistry.getTestFtsoV2(); + } + + /** + * Get the current value of the feeds. + */ + function getFtsoV2CurrentFeedValues() + external + view + returns ( + uint256[] memory _feedValues, + int8[] memory _decimals, + uint64 _timestamp + ) + { + return ftsoV2.getFeedsById(feedIds); + } +} diff --git a/package-lock.json b/package-lock.json index 267eba4..ac9b546 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "encode", + "name": "event-chain", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "encode", + "name": "event-chain", "version": "0.1.0", "dependencies": { "@radix-ui/react-icons": "^1.3.0",