From 7efe26de3bec75661ebb067f5b0081108cf88e3d Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 21 Nov 2024 12:15:38 +0900 Subject: [PATCH 1/2] update fuel example --- pages/price-feeds/use-real-time-data/fuel.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/price-feeds/use-real-time-data/fuel.mdx b/pages/price-feeds/use-real-time-data/fuel.mdx index a2c6f9b2..55196c11 100644 --- a/pages/price-feeds/use-real-time-data/fuel.mdx +++ b/pages/price-feeds/use-real-time-data/fuel.mdx @@ -44,7 +44,8 @@ abi UpdatePrice { fn update_price_feeds(update_fee: u64, update_data: Vec); } -const PYTH_CONTRACT_ID = 0x1ab91bc1402a187055d3e827017ace566a103ce2a4126517da5d656d6a436aea; // Testnet Contract +const PYTH_MAINNET_CONTRACT_ID = 0x1c86fdd9e0e7bc0d2ae1bf6817ef4834ffa7247655701ee1b031b52a24c523da; // Mainnet Contract +const PYTH_CONTRACT_ID = 0x25146735b29d4216639f7f8b1d7b921ff87a1d3051de62d6cceaacabeb33b8e7; // Testnet Contract const FUEL_ETH_BASE_ASSET_ID = 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07; impl UpdatePrice for Contract { From b084bf4b605108098010b741593829a91c44f1d7 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 21 Nov 2024 12:16:37 +0900 Subject: [PATCH 2/2] fix --- pages/price-feeds/use-real-time-data/fuel.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pages/price-feeds/use-real-time-data/fuel.mdx b/pages/price-feeds/use-real-time-data/fuel.mdx index 55196c11..7a41e0e7 100644 --- a/pages/price-feeds/use-real-time-data/fuel.mdx +++ b/pages/price-feeds/use-real-time-data/fuel.mdx @@ -45,33 +45,33 @@ abi UpdatePrice { } const PYTH_MAINNET_CONTRACT_ID = 0x1c86fdd9e0e7bc0d2ae1bf6817ef4834ffa7247655701ee1b031b52a24c523da; // Mainnet Contract -const PYTH_CONTRACT_ID = 0x25146735b29d4216639f7f8b1d7b921ff87a1d3051de62d6cceaacabeb33b8e7; // Testnet Contract +const PYTH_TESTNET_CONTRACT_ID = 0x25146735b29d4216639f7f8b1d7b921ff87a1d3051de62d6cceaacabeb33b8e7; // Testnet Contract const FUEL_ETH_BASE_ASSET_ID = 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07; impl UpdatePrice for Contract { fn valid_time_period() -> u64 { - let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID); + let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID); let period = pyth_contract.valid_time_period(); period } fn get_price(price_feed_id: PriceFeedId) -> Price { - let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID); + let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID); let price = pyth_contract.price(price_feed_id); price } fn get_price_unsafe(price_feed_id: PriceFeedId) -> Price { - let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID); + let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID); let price = pyth_contract.price_unsafe(price_feed_id); price } fn update_fee(update_data: Vec) -> u64 { - let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID); + let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID); let fee = pyth_contract.update_fee(update_data); fee } #[payable] fn update_price_feeds(update_fee: u64, update_data: Vec) { - let pyth_contract = abi(PythCore, PYTH_CONTRACT_ID); + let pyth_contract = abi(PythCore, PYTH_MAINNET_CONTRACT_ID); pyth_contract .update_price_feeds { asset_id: FUEL_ETH_BASE_ASSET_ID, @@ -102,7 +102,7 @@ The code snippet above does the following things: - `update_fee(update_data)`: Calculates the fee required to update the price feeds. - `update_price_feeds(update_fee, update_data)`: Updates the price feeds with the provided data and fee. -3. Uses the `PYTH_CONTRACT_ID` constant to interact with the Pyth contract on testnet. +3. Uses the `PYTH_MAINNET_CONTRACT_ID` constant to interact with the Pyth contract on testnet. 4. Uses the `FUEL_ETH_BASE_ASSET_ID` constant as the asset ID for paying update fees. To use this contract, you would typically: