Selaa lähdekoodia

feat(target_chains/fuel): bump fuel-toolchain and refactor (#1794)

* bump fuel-toolchain and refactor

* remove troubleshooting log

* redeploy

* precommit
Daniel Chew 1 vuosi sitten
vanhempi
sitoutus
2c4bc07bef
24 muutettua tiedostoa jossa 356 lisäystä ja 337 poistoa
  1. 190 219
      target_chains/fuel/contracts/Cargo.lock
  2. 1 1
      target_chains/fuel/contracts/Cargo.toml
  3. 2 2
      target_chains/fuel/contracts/Forc.lock
  4. 5 7
      target_chains/fuel/contracts/README.md
  5. 2 2
      target_chains/fuel/contracts/fuel-toolchain.toml
  6. 1 1
      target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract-abi.json
  7. 12 12
      target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract-storage_slots.json
  8. BIN
      target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract.bin
  9. 1 1
      target_chains/fuel/contracts/pyth-interface/src/data_structures/price.sw
  10. 0 1
      target_chains/fuel/contracts/pyth-interface/src/pyth_merkle_proof.sw
  11. 33 7
      target_chains/fuel/contracts/src/pyth_utils.rs
  12. 2 4
      target_chains/fuel/contracts/tests/functions/pyth_core/ema_price.rs
  13. 2 4
      target_chains/fuel/contracts/tests/functions/pyth_core/ema_price_no_older_than.rs
  14. 2 4
      target_chains/fuel/contracts/tests/functions/pyth_core/ema_price_unsafe.rs
  15. 2 2
      target_chains/fuel/contracts/tests/functions/pyth_core/price.rs
  16. 2 4
      target_chains/fuel/contracts/tests/functions/pyth_core/price_no_older_than.rs
  17. 2 2
      target_chains/fuel/contracts/tests/functions/pyth_core/price_unsafe.rs
  18. 17 14
      target_chains/fuel/contracts/tests/functions/pyth_core/update_price_feeds.rs
  19. 2 2
      target_chains/fuel/contracts/tests/functions/pyth_info/price_feed_unsafe.rs
  20. 31 15
      target_chains/fuel/contracts/tests/utils/interface/pyth_core.rs
  21. 6 6
      target_chains/fuel/contracts/tests/utils/interface/pyth_governance.rs
  22. 19 13
      target_chains/fuel/contracts/tests/utils/interface/pyth_info.rs
  23. 4 6
      target_chains/fuel/contracts/tests/utils/interface/pyth_init.rs
  24. 18 8
      target_chains/fuel/contracts/tests/utils/interface/wormhole_guardians.rs

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 190 - 219
target_chains/fuel/contracts/Cargo.lock


+ 1 - 1
target_chains/fuel/contracts/Cargo.toml

@@ -9,7 +9,7 @@ license = "Apache-2.0"
 [dependencies]
 rand = "0.8.5"
 base64 = "0.22"
-fuels = { version = "0.62.0", features = ["fuel-core-lib"] }
+fuels = { version = "0.65.1", features = ["fuel-core-lib"] }
 tokio = { version = "1.12", features = ["rt", "macros"] }
 hex = "0.4.3"
 reqwest = "0.11.27"

+ 2 - 2
target_chains/fuel/contracts/Forc.lock

@@ -1,6 +1,6 @@
 [[package]]
 name = "core"
-source = "path+from-root-E19CE48B3E858B72"
+source = "path+from-root-2AB5BCE55EAAEFF4"
 
 [[package]]
 name = "pyth-contract"
@@ -32,7 +32,7 @@ dependencies = ["std"]
 
 [[package]]
 name = "std"
-source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6"
+source = "git+https://github.com/fuellabs/sway?tag=v0.62.0#efda0397c7bee77de73bd726ec0b732d57614973"
 dependencies = ["core"]
 
 [[package]]

+ 5 - 7
target_chains/fuel/contracts/README.md

@@ -1,17 +1,15 @@
 # Pyth-integration
 
-> **_NOTE:_** The project is a WIP.
-
 An implementation of a [Pyth Network](https://pyth.network/) oracle contract in Sway. Utilising minimal, internal [Wormhole](https://docs.wormhole.com/wormhole/) functionality and state.
 
 ## Interfaces
 
 The project provides four interfaces for interaction with the oracle contract:
 
-- [PythCore](./pyth-interface/src/interface.sw#L20) - provides the core functionality to required to utilise the oracle; getting fees, updating prices and fetching prices.
-- [PythInit](./pyth-interface/src/interface.sw#L250) - provides the functionality to setup the oracle's state.
-- [PythInfo](./pyth-interface/src/interface.sw#L255) - provides additional information about the oracle's state.
-- [WormholeGuardians](./pyth-interface/src/interface.sw#L283) - provides functionality to maintain and query the wormhole-state-elements used by the oracle.
+- [PythCore](./pyth-interface/src/interface.sw#L24) - provides the core functionality to required to utilise the oracle; getting fees, updating prices and fetching prices.
+- [PythInit](./pyth-interface/src/interface.sw#L263) - provides the functionality to setup the oracle's state.
+- [PythInfo](./pyth-interface/src/interface.sw#L277) - provides additional information about the oracle's state.
+- [WormholeGuardians](./pyth-interface/src/interface.sw#L308) - provides functionality to maintain and query the wormhole-state-elements used by the oracle.
 
 ## Running the project
 
@@ -37,7 +35,7 @@ cargo test
 
 Before deploying the oracle contract; the `deployer` must be set to the address of the deploying wallet in the storage block, so that the deployer can setup the contract with the `constructor()` method.
 
-Parameters for the `constructor()` method can be seen in the [tests of the method](./pyth-contract/tests/functions/pyth_init/constuctor.rs#L28), which at the time of writing uses the real up-to-date values as per Pyth's documentation and EVM integrations. Care should be taken to ensure that the most up-to-date values are used for the `constructor()` method's parameters.
+Parameters for the `constructor()` method can be seen in the [tests of the method](./tests/utils/interface/pyth_init.rs#L7), which at the time of writing uses the real up-to-date values as per Pyth's documentation and EVM integrations. Care should be taken to ensure that the most up-to-date values are used for the `constructor()` method's parameters.
 
 #### Fuel Beta-5 network deployment:
 

+ 2 - 2
target_chains/fuel/contracts/fuel-toolchain.toml

@@ -2,5 +2,5 @@
 channel = "latest-aarch64-apple-darwin"
 
 [components]
-forc = "0.60.0"
-fuel-core = "0.26.0"
+forc = "0.62.0"
+fuel-core = "0.31.0"

+ 1 - 1
target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract-abi.json

@@ -1838,7 +1838,7 @@
         "type": 6,
         "typeArguments": []
       },
-      "offset": 129616
+      "offset": 117008
     }
   ]
 }

+ 12 - 12
target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract-storage_slots.json

@@ -1,50 +1,50 @@
 [
   {
-    "key": "6294951dcb0a9111a517be5cf4785670ff4e166fb5ab9c33b17e6881b48e964f",
+    "key": "11672498f6e54d64f7c94ceafab63ce9c33b957b083d82f9301e18c4bbcdd43e",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "71217a24656901c411894bb65eb78a828dafa5a6844488ef5024eb5ac0cff79c",
+    "key": "1fea2a1870fafe58b3f658d2a10d75f7d4b599036bb925958e3650097753f03f",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "71217a24656901c411894bb65eb78a828dafa5a6844488ef5024eb5ac0cff79d",
+    "key": "1fea2a1870fafe58b3f658d2a10d75f7d4b599036bb925958e3650097753f040",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "7f91d1a929dce734e7f930bbb279ccfccdb5474227502ea8845815c74bd930a7",
+    "key": "1feab27058c4ed60cb36c15c123efafc983fdbc10f4cfac4f1b23fdb8c36fb7d",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "8a89a0cce819e0426e565819a9a98711329087da5a802fb16edd223c47fa44ef",
+    "key": "1feab27058c4ed60cb36c15c123efafc983fdbc10f4cfac4f1b23fdb8c36fb7e",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "94b2b70d20da552763c7614981b2a4d984380d7ed4e54c01b28c914e79e44bd5",
+    "key": "2978ac0e4bdc20e0a96c04e8adb0639e5efdff01601aa4f7887421e795e4b96a",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "94b2b70d20da552763c7614981b2a4d984380d7ed4e54c01b28c914e79e44bd6",
+    "key": "357565afd3b58fa5509545cd95377655dcb331b733af6f4439699d27dcf450eb",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "a9203bbb8366ca9d708705dce980acbb54d44fb753370ffe4c7d351b46b2abbc",
+    "key": "358560d9e39bf0d62ad9ffeba18c167b0e4e6722c6eb24f55cbc64054c51b905",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "b48b753af346966d0d169c0b2e3234611f65d5cfdb57c7b6e7cd6ca93707bee0",
+    "key": "358560d9e39bf0d62ad9ffeba18c167b0e4e6722c6eb24f55cbc64054c51b906",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "c7e08cdde76020f08f4ce5c3257422ae67f9676992689b64b85f35aa58752d9e",
+    "key": "480744474aef380dda93aae5f17de10f991ca301c7ae8a925ab40229da966cf8",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "c7e08cdde76020f08f4ce5c3257422ae67f9676992689b64b85f35aa58752d9f",
+    "key": "d16fb5609ac0a5d5c45145524cbd88ae218f3be85b76bb42239b7eb916305d6d",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   },
   {
-    "key": "d02e07f5a716bd3b6670aaf9a73352164e6b946c24db14f72005b7029e67d96a",
+    "key": "f9e12c6c1c57daf9e6a5ff000b582628bec999880e26917559121db757ba5653",
     "value": "0000000000000000000000000000000000000000000000000000000000000000"
   }
 ]

BIN
target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract.bin


+ 1 - 1
target_chains/fuel/contracts/pyth-interface/src/data_structures/price.sw

@@ -333,7 +333,7 @@ impl PriceFeed {
         let (_, slice) = encoded_proof.split_at(current_offset);
         let (encoded_message, _) = slice.split_at(message_size);
         current_offset += message_size;
-        let end_offset = validate_proof(encoded_proof, current_offset, digest, encoded_message);
+        let end_offset = validate_proof(encoded_proof, current_offset, digest, encoded_message.clone());
         // Message type of 0 is a Price Feed
         require(
             encoded_message

+ 0 - 1
target_chains/fuel/contracts/pyth-interface/src/pyth_merkle_proof.sw

@@ -42,7 +42,6 @@ pub fn validate_proof(
     leaf_data: Bytes,
 ) -> u64 {
     let mut current_digest = leaf_hash(leaf_data);
-
     let proof_size = encoded_proof.get(proof_offset).unwrap().as_u64();
     proof_offset += 1;
 

+ 33 - 7
target_chains/fuel/contracts/src/pyth_utils.rs

@@ -7,8 +7,12 @@ use crate::constants::{
 use base64::{engine::general_purpose, prelude::Engine};
 use fuels::{
     prelude::{abigen, CallParameters, Contract, LoadConfiguration, TxPolicies, WalletUnlocked},
-    programs::call_response::FuelCallResponse,
-    types::{errors::Error, Address, Bits256, Bytes, Identity},
+    programs::responses::CallResponse,
+    tx::Receipt,
+    types::{
+        errors::{transaction::Reason, Error},
+        Address, Bits256, Bytes, Identity,
+    },
 };
 use rand::Rng;
 use reqwest;
@@ -163,7 +167,7 @@ pub fn create_governance_instruction_payload(
 }
 
 impl Pyth {
-    pub async fn price(&self, price_feed_id: Bits256) -> Result<FuelCallResponse<Price>, Error> {
+    pub async fn price(&self, price_feed_id: Bits256) -> Result<CallResponse<Price>, Error> {
         self.instance
             .methods()
             .price(price_feed_id)
@@ -175,7 +179,7 @@ impl Pyth {
         &self,
         fee: u64,
         update_data: &[Bytes],
-    ) -> Result<FuelCallResponse<()>, Error> {
+    ) -> Result<CallResponse<()>, Error> {
         self.instance
             .methods()
             .update_price_feeds(update_data.to_vec())
@@ -184,7 +188,7 @@ impl Pyth {
             .await
     }
 
-    pub async fn update_fee(&self, update_data: &[Bytes]) -> Result<FuelCallResponse<u64>, Error> {
+    pub async fn update_fee(&self, update_data: &[Bytes]) -> Result<CallResponse<u64>, Error> {
         self.instance
             .methods()
             .update_fee(update_data.to_vec())
@@ -200,7 +204,7 @@ impl Pyth {
         wormhole_guardian_set_addresses: Vec<Bits256>,
         wormhole_guardian_set_index: u32,
         chain_id: u16,
-    ) -> Result<FuelCallResponse<()>, Error> {
+    ) -> Result<CallResponse<()>, Error> {
         self.instance
             .methods()
             .constructor(
@@ -240,7 +244,7 @@ impl Pyth {
         })
     }
 
-    pub async fn current_guardian_set_index(&self) -> Result<FuelCallResponse<u32>, Error> {
+    pub async fn current_guardian_set_index(&self) -> Result<CallResponse<u32>, Error> {
         self.instance
             .methods()
             .current_guardian_set_index()
@@ -376,3 +380,25 @@ pub fn default_data_sources() -> Vec<DataSource> {
         },
     ]
 }
+
+pub fn handle_error(e: Error) -> Error {
+    if let Error::Transaction(Reason::Reverted {
+        reason: _,
+        revert_id: _,
+        receipts,
+    }) = &e
+    {
+        for r in receipts {
+            match r {
+                Receipt::Log { ra, .. } => {
+                    println!("{:?}", ra);
+                }
+                Receipt::LogData { data, .. } => {
+                    println!("{:?}", hex::encode(data.clone().unwrap()));
+                }
+                _ => {}
+            }
+        }
+    }
+    e
+}

+ 2 - 4
target_chains/fuel/contracts/tests/functions/pyth_core/ema_price.rs

@@ -42,8 +42,7 @@ mod success {
             .value;
 
         update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes())
-            .await
-            .unwrap();
+            .await;
 
         let eth_usd_ema_price = ema_price(&deployer.instance, default_price_feed_ids()[0])
             .await
@@ -90,8 +89,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await
-        .unwrap();
+        .await;
 
         let eth_usd_ema_price = ema_price(&deployer.instance, default_price_feed_ids()[0])
             .await

+ 2 - 4
target_chains/fuel/contracts/tests/functions/pyth_core/ema_price_no_older_than.rs

@@ -42,8 +42,7 @@ mod success {
             .value;
 
         update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes())
-            .await
-            .unwrap();
+            .await;
 
         let eth_usd_ema_price = ema_price_no_older_than(
             &deployer.instance,
@@ -98,8 +97,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await
-        .unwrap();
+        .await;
 
         let eth_usd_ema_price = ema_price_no_older_than(
             &deployer.instance,

+ 2 - 4
target_chains/fuel/contracts/tests/functions/pyth_core/ema_price_unsafe.rs

@@ -42,8 +42,7 @@ mod success {
             .value;
 
         update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes())
-            .await
-            .unwrap();
+            .await;
 
         let eth_usd_ema_price = ema_price_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await
@@ -90,8 +89,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await
-        .unwrap();
+        .await;
 
         let eth_usd_ema_price = ema_price_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await

+ 2 - 2
target_chains/fuel/contracts/tests/functions/pyth_core/price.rs

@@ -40,7 +40,7 @@ mod success {
             .await
             .value;
 
-        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await.unwrap();
+        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await;
 
         let eth_usd_price = price(&deployer.instance, default_price_feed_ids()[0])
             .await
@@ -87,7 +87,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await.unwrap();
+        .await;
 
         let eth_usd_price = price(&deployer.instance, default_price_feed_ids()[0])
             .await

+ 2 - 4
target_chains/fuel/contracts/tests/functions/pyth_core/price_no_older_than.rs

@@ -43,8 +43,7 @@ mod success {
             .value;
 
         update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes())
-            .await
-            .unwrap();
+            .await;
 
         let eth_usd_price = price_no_older_than(
             &deployer.instance,
@@ -99,8 +98,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await
-        .unwrap();
+        .await;
 
         let eth_usd_price = price_no_older_than(
             &deployer.instance,

+ 2 - 2
target_chains/fuel/contracts/tests/functions/pyth_core/price_unsafe.rs

@@ -40,7 +40,7 @@ mod success {
             .await
             .value;
 
-        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await.unwrap();
+        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await;
 
         let eth_usd_price = price_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await
@@ -87,7 +87,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await.unwrap();
+        .await;
 
         let eth_usd_price = price_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await

+ 17 - 14
target_chains/fuel/contracts/tests/functions/pyth_core/update_price_feeds.rs

@@ -5,7 +5,6 @@ use crate::utils::interface::{
 };
 use crate::utils::setup::setup_environment;
 
-use fuels::types::errors::{transaction::Reason, Error};
 use pyth_sdk::{
     constants::{
         DEFAULT_SINGLE_UPDATE_FEE, DEFAULT_VALID_TIME_PERIOD, DUMMY_CHAIN_ID,
@@ -56,9 +55,7 @@ mod success {
             (false, false)
         );
 
-        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes())
-            .await
-            .unwrap();
+        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await;
 
         // Final values
         assert_eq!(
@@ -113,8 +110,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await
-        .unwrap();
+        .await;
 
         // Final values
         assert_eq!(
@@ -132,6 +128,10 @@ mod success {
 }
 
 mod failure {
+    use fuels::{
+        programs::calls::CallParameters,
+        types::errors::{transaction::Reason, Error},
+    };
 
     use super::*;
 
@@ -169,18 +169,21 @@ mod failure {
             (false, false)
         );
 
-        let response = update_price_feeds(
-            &deployer.instance,
-            fee,
-            test_corrupted_proof_accumulator_update_data_bytes(),
-        )
-        .await;
+        // Manually call the function to test the panic
+        let result = deployer
+            .instance
+            .methods()
+            .update_price_feeds(test_corrupted_proof_accumulator_update_data_bytes())
+            .call_params(CallParameters::default().with_amount(fee))
+            .unwrap()
+            .call()
+            .await;
 
-        let is_error = response.is_err();
+        let is_error = result.is_err();
 
         assert!(is_error);
 
-        let error = response.unwrap_err();
+        let error = result.unwrap_err();
 
         if let Error::Transaction(Reason::Reverted {
             reason,

+ 2 - 2
target_chains/fuel/contracts/tests/functions/pyth_info/price_feed_unsafe.rs

@@ -41,7 +41,7 @@ mod success {
             .await
             .value;
 
-        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await.unwrap();
+        update_price_feeds(&deployer.instance, fee, test_batch_update_data_bytes()).await;
 
         let eth_usd_price_feed = price_feed_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await
@@ -81,7 +81,7 @@ mod success {
             fee,
             test_accumulator_update_data_bytes(),
         )
-        .await.unwrap();
+        .await;
 
         let eth_usd_price_feed = price_feed_unsafe(&deployer.instance, default_price_feed_ids()[0])
             .await

+ 31 - 15
target_chains/fuel/contracts/tests/utils/interface/pyth_core.rs

@@ -1,22 +1,22 @@
 use fuels::{
     accounts::wallet::WalletUnlocked,
     prelude::{Bytes, CallParameters, TxPolicies},
-    programs::call_response::FuelCallResponse,
-    types::errors::Error,
+    programs::responses::CallResponse,
     types::Bits256,
 };
 
-use pyth_sdk::pyth_utils::{Price, PriceFeed, PythOracleContract};
+use pyth_sdk::pyth_utils::{handle_error, Price, PriceFeed, PythOracleContract};
 
 pub(crate) async fn ema_price(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .ema_price(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
@@ -24,24 +24,26 @@ pub(crate) async fn ema_price_no_older_than(
     contract: &PythOracleContract<WalletUnlocked>,
     time_period: u64,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .ema_price_no_older_than(time_period, price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn ema_price_unsafe(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .ema_price_unsafe(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
@@ -52,7 +54,7 @@ pub(crate) async fn parse_price_feed_updates(
     min_publish_time: u64,
     price_feed_ids: Vec<Bits256>,
     update_data: Vec<Bytes>,
-) -> FuelCallResponse<Vec<PriceFeed>> {
+) -> CallResponse<Vec<PriceFeed>> {
     contract
         .methods()
         .parse_price_feed_updates(
@@ -66,18 +68,20 @@ pub(crate) async fn parse_price_feed_updates(
         .unwrap()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn price(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .price(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
@@ -85,36 +89,39 @@ pub(crate) async fn price_no_older_than(
     contract: &PythOracleContract<WalletUnlocked>,
     time_period: u64,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .price_no_older_than(time_period, price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn price_unsafe(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<Price> {
+) -> CallResponse<Price> {
     contract
         .methods()
         .price_unsafe(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn update_fee(
     contract: &PythOracleContract<WalletUnlocked>,
     update_data: Vec<Bytes>,
-) -> FuelCallResponse<u64> {
+) -> CallResponse<u64> {
     contract
         .methods()
         .update_fee(update_data)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
@@ -122,7 +129,7 @@ pub(crate) async fn update_price_feeds(
     contract: &PythOracleContract<WalletUnlocked>,
     fee: u64,
     update_data: Vec<Bytes>,
-) -> Result<FuelCallResponse<()>, Error> {
+) -> CallResponse<()> {
     contract
         .methods()
         .update_price_feeds(update_data)
@@ -130,6 +137,8 @@ pub(crate) async fn update_price_feeds(
         .unwrap()
         .call()
         .await
+        .map_err(handle_error)
+        .unwrap()
 }
 
 pub(crate) async fn update_price_feeds_if_necessary(
@@ -138,7 +147,7 @@ pub(crate) async fn update_price_feeds_if_necessary(
     price_feed_ids: Vec<Bits256>,
     publish_times: Vec<u64>,
     update_data: Vec<Bytes>,
-) -> FuelCallResponse<()> {
+) -> CallResponse<()> {
     contract
         .methods()
         .update_price_feeds_if_necessary(price_feed_ids, publish_times, update_data)
@@ -146,11 +155,18 @@ pub(crate) async fn update_price_feeds_if_necessary(
         .unwrap()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn valid_time_period(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<u64> {
-    contract.methods().valid_time_period().call().await.unwrap()
+) -> CallResponse<u64> {
+    contract
+        .methods()
+        .valid_time_period()
+        .call()
+        .await
+        .map_err(handle_error)
+        .unwrap()
 }

+ 6 - 6
target_chains/fuel/contracts/tests/utils/interface/pyth_governance.rs

@@ -1,27 +1,27 @@
-use fuels::{
-    accounts::wallet::WalletUnlocked, programs::call_response::FuelCallResponse, types::Bytes,
-};
-use pyth_sdk::pyth_utils::{DataSource, PythOracleContract};
+use fuels::{accounts::wallet::WalletUnlocked, programs::responses::CallResponse, types::Bytes};
+use pyth_sdk::pyth_utils::{handle_error, DataSource, PythOracleContract};
 
 pub(crate) async fn execute_governance_instruction(
     contract: &PythOracleContract<WalletUnlocked>,
     encoded_vm: Bytes,
-) -> FuelCallResponse<()> {
+) -> CallResponse<()> {
     contract
         .methods()
         .execute_governance_instruction(encoded_vm)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn governance_data_source(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<DataSource> {
+) -> CallResponse<DataSource> {
     contract
         .methods()
         .governance_data_source()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }

+ 19 - 13
target_chains/fuel/contracts/tests/utils/interface/pyth_info.rs

@@ -1,64 +1,70 @@
-use fuels::{
-    accounts::wallet::WalletUnlocked, programs::call_response::FuelCallResponse, types::Bits256,
-};
+use fuels::{accounts::wallet::WalletUnlocked, programs::responses::CallResponse, types::Bits256};
 
-use pyth_sdk::pyth_utils::{DataSource, PriceFeed, PythOracleContract, State};
+use pyth_sdk::pyth_utils::{handle_error, DataSource, PriceFeed, PythOracleContract, State};
 
-pub(crate) async fn owner(
-    contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<State> {
+pub(crate) async fn owner(contract: &PythOracleContract<WalletUnlocked>) -> CallResponse<State> {
     contract.methods().owner().call().await.unwrap()
 }
 
 pub(crate) async fn price_feed_exists(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<bool> {
+) -> CallResponse<bool> {
     contract
         .methods()
         .price_feed_exists(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn price_feed_unsafe(
     contract: &PythOracleContract<WalletUnlocked>,
     price_feed_id: Bits256,
-) -> FuelCallResponse<PriceFeed> {
+) -> CallResponse<PriceFeed> {
     contract
         .methods()
         .price_feed_unsafe(price_feed_id)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn single_update_fee(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<u64> {
-    contract.methods().single_update_fee().call().await.unwrap()
+) -> CallResponse<u64> {
+    contract
+        .methods()
+        .single_update_fee()
+        .call()
+        .await
+        .map_err(handle_error)
+        .unwrap()
 }
 
 pub(crate) async fn is_valid_data_source(
     contract: &PythOracleContract<WalletUnlocked>,
     data_source: &DataSource,
-) -> FuelCallResponse<bool> {
+) -> CallResponse<bool> {
     contract
         .methods()
         .is_valid_data_source(data_source.clone())
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn valid_data_sources(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<Vec<DataSource>> {
+) -> CallResponse<Vec<DataSource>> {
     contract
         .methods()
         .valid_data_sources()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }

+ 4 - 6
target_chains/fuel/contracts/tests/utils/interface/pyth_init.rs

@@ -1,9 +1,6 @@
-use fuels::{
-    accounts::wallet::WalletUnlocked, programs::call_response::FuelCallResponse,
-    types::Bits256,
-};
+use fuels::{accounts::wallet::WalletUnlocked, programs::responses::CallResponse, types::Bits256};
 
-use pyth_sdk::pyth_utils::{DataSource, PythOracleContract};
+use pyth_sdk::pyth_utils::{handle_error, DataSource, PythOracleContract};
 
 pub(crate) async fn constructor(
     contract: &PythOracleContract<WalletUnlocked>,
@@ -15,7 +12,7 @@ pub(crate) async fn constructor(
     wormhole_guardian_set_addresses: Vec<Bits256>,
     wormhole_guardian_set_index: u32,
     chain_id: u16,
-) -> FuelCallResponse<()> {
+) -> CallResponse<()> {
     contract
         .methods()
         .constructor(
@@ -30,5 +27,6 @@ pub(crate) async fn constructor(
         )
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }

+ 18 - 8
target_chains/fuel/contracts/tests/utils/interface/wormhole_guardians.rs

@@ -1,59 +1,69 @@
 use fuels::{
     accounts::wallet::WalletUnlocked,
-    programs::call_response::FuelCallResponse,
+    programs::responses::CallResponse,
     types::{Bits256, Bytes},
 };
-use pyth_sdk::pyth_utils::{DataSource, GuardianSet, PythOracleContract};
+use pyth_sdk::pyth_utils::{handle_error, DataSource, GuardianSet, PythOracleContract};
 
 pub(crate) async fn current_guardian_set_index(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<u32> {
+) -> CallResponse<u32> {
     contract
         .methods()
         .current_guardian_set_index()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn current_wormhole_provider(
     contract: &PythOracleContract<WalletUnlocked>,
-) -> FuelCallResponse<DataSource> {
+) -> CallResponse<DataSource> {
     contract
         .methods()
         .current_wormhole_provider()
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn governance_action_is_consumed(
     contract: &PythOracleContract<WalletUnlocked>,
     governance_action_hash: Bits256,
-) -> FuelCallResponse<bool> {
+) -> CallResponse<bool> {
     contract
         .methods()
         .governance_action_is_consumed(governance_action_hash)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }
 
 pub(crate) async fn guardian_set(
     contract: &PythOracleContract<WalletUnlocked>,
     index: u32,
-) -> FuelCallResponse<GuardianSet> {
-    contract.methods().guardian_set(index).call().await.unwrap()
+) -> CallResponse<GuardianSet> {
+    contract
+        .methods()
+        .guardian_set(index)
+        .call()
+        .await
+        .map_err(handle_error)
+        .unwrap()
 }
 
 pub(crate) async fn submit_new_guardian_set(
     contract: &PythOracleContract<WalletUnlocked>,
     encoded_vm: Bytes,
-) -> FuelCallResponse<()> {
+) -> CallResponse<()> {
     contract
         .methods()
         .submit_new_guardian_set(encoded_vm)
         .call()
         .await
+        .map_err(handle_error)
         .unwrap()
 }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä