Skip to content

Commit

Permalink
fix(docs): acquire fresh lts contract each time (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
dineshpinto authored Jan 10, 2025
2 parents 55ae060 + fc93cab commit 934c1d8
Showing 1 changed file with 7 additions and 10 deletions.
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

0 comments on commit 934c1d8

Please sign in to comment.