Skip to content

Commit 934c1d8

Browse files
authored
fix(docs): acquire fresh lts contract each time (#482)
2 parents 55ae060 + fc93cab commit 934c1d8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

examples/developer-hub-solidity/FtsoV2MigrationExample.sol

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/
55
import {FtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/FtsoV2Interface.sol";
66

77
contract FtsoV2FeedConsumer {
8-
FtsoV2Interface internal ftsoV2;
9-
10-
/**
11-
* @dev Constructor initializes the FTSOv2 contract by fetching the FtsoV2Interface address from the ContractRegistry.
12-
*/
13-
constructor() {
14-
ftsoV2 = ContractRegistry.getFtsoV2();
15-
}
16-
178
/**
189
* @dev Converts a feed name to a bytes21 ID with a fixed category (1) and USD quote.
1910
* @param _name The name of the feed, e.g. FLR.
@@ -49,6 +40,9 @@ contract FtsoV2FeedConsumer {
4940
uint64 _timestamp
5041
)
5142
{
43+
// Get the current FTSOv2 contract from the ContractRegistry
44+
FtsoV2Interface ftsoV2 = ContractRegistry.getFtsoV2();
45+
5246
bytes21[] memory feedIds = new bytes21[](_feedNames.length);
5347

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

6660
return (feedValues, decimals, timestamp);
6761
}
@@ -79,6 +73,9 @@ contract FtsoV2FeedConsumer {
7973
payable
8074
returns (uint256[] memory _feedValues, uint64 _timestamp)
8175
{
76+
// Get the current FTSOv2 contract from the ContractRegistry
77+
FtsoV2Interface ftsoV2 = ContractRegistry.getFtsoV2();
78+
8279
bytes21[] memory feedIds = new bytes21[](_feedNames.length);
8380

8481
// Preprocess feed names to feed IDs

0 commit comments

Comments
 (0)