Skip to content

Instantly share code, notes, and snippets.

@0xZRA
Created July 1, 2024 00:15
Show Gist options
  • Save 0xZRA/18d8f25e6b3a97025de946868a230765 to your computer and use it in GitHub Desktop.
Save 0xZRA/18d8f25e6b3a97025de946868a230765 to your computer and use it in GitHub Desktop.
Updated version of test/src/sdk-harness/test_projects/run_external_proxy/mod.rs
use fuels::{
prelude::*
};
abigen!(Contract(
name = "RunExternalProxyContract",
abi = "test_projects/run_external_proxy/out/debug/run_external_proxy-abi.json",
));
#[tokio::test]
async fn run_external_can_proxy_call() {
let wallet = launch_provider_and_get_wallet().await.unwrap();
let target_id = Contract::load_from(
"test_projects/run_external_target/out/debug/run_external_target.bin",
LoadConfiguration::default()
.with_storage_configuration(StorageConfiguration::default().with_autoload(false)),
)
.unwrap()
.deploy(&wallet, TxPolicies::default())
.await
.unwrap();
let configurables = RunExternalProxyContractConfigurables::default()
.with_TARGET(target_id.clone().into())
.unwrap();
let id = Contract::load_from(
"test_projects/run_external_proxy/out/debug/run_external_proxy.bin",
LoadConfiguration::default().with_configurables(configurables),
)
.unwrap()
.deploy(&wallet, TxPolicies::default())
.await
.unwrap();
let instance = RunExternalProxyContract::new(id.clone(), wallet);
// Call "does_not_exist_in_the_target"
// Will call run_external_proxy::does_not_exist_in_the_target
// it will proxy the call to run_external_target,
// and endup in the fallback, fn that will simply return supplied value
let result = instance
.methods()
.does_not_exist_in_the_target(22)
.with_contract_ids(&[target_id.into()])
.call()
.await
.unwrap();
assert_eq!(result.value, 22); // checking this value is irrelevant for this PoC though
println!("Result from fallback {:?}", result.value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment