Defined `Vec` alias in Sway breaks SDK harness

#1603

Issue Details

5 months ago
tritao
tritao
bugblocked
bitzoicbitzoic
opened 5 months ago
Author

If an alias is defined in Sway that is a Vec, then the Rust SDK will fail to compile.

Minimal Repro Sway Contract:

contract; pub type MyAlias = Vec<b256>; abi MyContract { fn test_function() -> MyAlias; } impl MyContract for Contract { fn test_function() -> MyAlias { MyAlias::new() } }

Minimal Repro SDK harness:

use fuels::{prelude::*, types::ContractId}; // Load abi from json abigen!(Contract( name = "MyContract", abi = "out/debug/test_sdk_vec_alias-abi.json" )); async fn get_contract_instance() -> (MyContract<WalletUnlocked>, ContractId) { // Launch a local network and deploy the contract let mut wallets = launch_custom_provider_and_get_wallets( WalletsConfig::new( Some(1), /* Single wallet */ Some(1), /* Single coin (UTXO) */ Some(1_000_000_000), /* Amount per coin */ ), None, None, ) .await .unwrap(); let wallet = wallets.pop().unwrap(); let id = Contract::load_from( "./out/debug/test_sdk_vec_alias.bin", LoadConfiguration::default(), ) .unwrap() .deploy(&wallet, TxPolicies::default()) .await .unwrap(); let instance = MyContract::new(id.clone(), wallet); (instance, id.into()) } #[tokio::test] async fn can_get_contract_id() { let (instance, _id) = get_contract_instance().await; // Now you have an instance of your contract you can use to test each function let result = instance.methods().test_function().await.unwrap().value; }
Image