added flare flare oracle code

This commit is contained in:
ayomaska18
2024-10-25 13:17:01 +01:00
parent 49534d8789
commit ea446e978f
3 changed files with 47 additions and 2 deletions

View File

@@ -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;

44
contracts/FlareOracle.sol Normal file
View File

@@ -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);
}
}

4
package-lock.json generated
View File

@@ -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",