Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions examples/developer-hub-solidity/FtsoV2MigrationExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/
import {FtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/FtsoV2Interface.sol";

contract FtsoV2FeedConsumer {
FtsoV2Interface internal ftsoV2;

/**
* @dev Constructor initializes the FTSOv2 contract by fetching the FtsoV2Interface address from the ContractRegistry.
*/
constructor() {
ftsoV2 = ContractRegistry.getFtsoV2();
}

/**
* @dev Converts a feed name to a bytes21 ID with a fixed category (1) and USD quote.
* @param _name The name of the feed, e.g. FLR.
Expand Down Expand Up @@ -49,6 +40,9 @@ contract FtsoV2FeedConsumer {
uint64 _timestamp
)
{
// Get the current FTSOv2 contract from the ContractRegistry
FtsoV2Interface ftsoV2 = ContractRegistry.getFtsoV2();

bytes21[] memory feedIds = new bytes21[](_feedNames.length);

// Preprocess feed names to feed IDs
Expand All @@ -61,7 +55,7 @@ contract FtsoV2FeedConsumer {
uint256[] memory feedValues,
int8[] memory decimals,
uint64 timestamp
) = ftsoV2.getFeedsById(feedIds);
) = ftsoV2.getFeedsById{value: msg.value}(feedIds);

return (feedValues, decimals, timestamp);
}
Expand All @@ -79,6 +73,9 @@ contract FtsoV2FeedConsumer {
payable
returns (uint256[] memory _feedValues, uint64 _timestamp)
{
// Get the current FTSOv2 contract from the ContractRegistry
FtsoV2Interface ftsoV2 = ContractRegistry.getFtsoV2();

bytes21[] memory feedIds = new bytes21[](_feedNames.length);

// Preprocess feed names to feed IDs
Expand Down
Loading