From 89128ccb2578f939aa92131bf71f96d8d3730205 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 6 Sep 2024 20:18:14 +0300 Subject: [PATCH] system SC proxy - arg reference fix --- .../examples/nft-minter/src/nft_module.rs | 4 +- .../system_proxy/builtin_func_proxy.rs | 58 +++---- .../system_proxy/esdt_system_sc_proxy.rs | 146 +++++++++--------- .../src/system_sc_interact.rs | 72 ++++----- 4 files changed, 140 insertions(+), 140 deletions(-) diff --git a/contracts/examples/nft-minter/src/nft_module.rs b/contracts/examples/nft-minter/src/nft_module.rs index 66f50ea958..12f2c3b868 100644 --- a/contracts/examples/nft-minter/src/nft_module.rs +++ b/contracts/examples/nft-minter/src/nft_module.rs @@ -49,8 +49,8 @@ pub trait NftModule { self.send() .esdt_system_sc_proxy() .set_special_roles( - &self.blockchain().get_sc_address(), - &self.nft_token_id().get(), + self.blockchain().get_sc_address(), + self.nft_token_id().get(), [EsdtLocalRole::NftCreate][..].iter().cloned(), ) .async_call_and_exit() diff --git a/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs b/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs index 6e4978980a..6755dbbd03 100644 --- a/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs +++ b/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs @@ -78,7 +78,7 @@ where self.wrapped_tx .payment(NotPayable) .raw_call(CHANGE_OWNER_BUILTIN_FUNC_NAME) - .argument(new_owner) + .argument(&new_owner) .original_result() } @@ -87,26 +87,26 @@ where Arg1: ProxyArg>, >( self, - token: &Arg0, + token: Arg0, nonce: u64, - amount: &Arg1, + amount: Arg1, ) -> TxTypedCall { if nonce == 0 { return self .wrapped_tx .payment(NotPayable) .raw_call(ESDT_LOCAL_BURN_FUNC_NAME) - .argument(token) - .argument(amount) + .argument(&token) + .argument(&amount) .original_result(); } self.wrapped_tx .payment(NotPayable) .raw_call(ESDT_NFT_BURN_FUNC_NAME) - .argument(token) + .argument(&token) .argument(&nonce) - .argument(amount) + .argument(&amount) .original_result() } @@ -115,31 +115,31 @@ where Arg1: ProxyArg>, >( self, - token: &Arg0, + token: Arg0, nonce: u64, - amount: &Arg1, + amount: Arg1, ) -> TxTypedCall { if nonce == 0 { return self .wrapped_tx .payment(NotPayable) .raw_call(ESDT_LOCAL_MINT_FUNC_NAME) - .argument(token) - .argument(amount) + .argument(&token) + .argument(&amount) .original_result(); } self.wrapped_tx .payment(NotPayable) .raw_call(ESDT_NFT_ADD_QUANTITY_FUNC_NAME) - .argument(token) + .argument(&token) .argument(&nonce) - .argument(amount) + .argument(&amount) .original_result() } pub fn nft_add_multiple_uri>>( self, - token_id: &Arg0, + token_id: Arg0, nft_nonce: u64, new_uris: &ManagedVec>, ) -> TxTypedCall { @@ -147,7 +147,7 @@ where .wrapped_tx .payment(NotPayable) .raw_call(ESDT_NFT_ADD_URI_FUNC_NAME) - .argument(token_id) + .argument(&token_id) .argument(&nft_nonce); for uri in new_uris { @@ -159,16 +159,16 @@ where pub fn nft_update_attributes>>( self, - token_id: &Arg0, + token_id: Arg0, nft_nonce: u64, new_attributes: &T, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call(ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME) - .argument(token_id) + .argument(&token_id) .argument(&nft_nonce) - .argument(new_attributes) + .argument(&new_attributes) .original_result() } @@ -182,11 +182,11 @@ where Arg4: ProxyArg>, >( self, - token: &Arg0, - amount: &Arg1, - name: &Arg2, - royalties: &Arg3, - hash: &Arg4, + token: Arg0, + amount: Arg1, + name: Arg2, + royalties: Arg3, + hash: Arg4, attributes: &T, uris: &ManagedVec>, ) -> TxTypedCall { @@ -194,12 +194,12 @@ where .wrapped_tx .payment(NotPayable) .raw_call(ESDT_NFT_CREATE_FUNC_NAME) - .argument(token) - .argument(amount) - .argument(name) - .argument(royalties) - .argument(hash) - .argument(attributes); + .argument(&token) + .argument(&amount) + .argument(&name) + .argument(&royalties) + .argument(&hash) + .argument(&attributes); if uris.is_empty() { // at least one URI is required, so we push an empty one diff --git a/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs b/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs index 10730ff0fc..979f9d1d60 100644 --- a/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs +++ b/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs @@ -70,9 +70,9 @@ where >( self, issue_cost: BigUint, - token_display_name: &Arg0, - token_ticker: &Arg1, - initial_supply: &Arg2, + token_display_name: Arg0, + token_ticker: Arg1, + initial_supply: Arg2, properties: FungibleTokenProperties, ) -> IssueCall { self.issue( @@ -104,8 +104,8 @@ where >( self, issue_cost: BigUint, - token_display_name: &Arg0, - token_ticker: &Arg1, + token_display_name: Arg0, + token_ticker: Arg1, properties: NonFungibleTokenProperties, ) -> IssueCall { let zero = &BigUint::zero(); @@ -138,8 +138,8 @@ where >( self, issue_cost: BigUint, - token_display_name: &Arg0, - token_ticker: &Arg1, + token_display_name: Arg0, + token_ticker: Arg1, properties: SemiFungibleTokenProperties, ) -> IssueCall { let zero = BigUint::zero(); @@ -172,8 +172,8 @@ where >( self, issue_cost: BigUint, - token_display_name: &Arg0, - token_ticker: &Arg1, + token_display_name: Arg0, + token_ticker: Arg1, properties: MetaTokenProperties, ) -> IssueCall { let zero = &BigUint::zero(); @@ -236,9 +236,9 @@ where self, issue_cost: BigUint, token_type: EsdtTokenType, - token_display_name: &Arg0, - token_ticker: &Arg1, - initial_supply: &Arg2, + token_display_name: Arg0, + token_ticker: Arg1, + initial_supply: Arg2, properties: TokenProperties, ) -> IssueCall { let endpoint_name = match token_type { @@ -253,11 +253,11 @@ where .wrapped_tx .raw_call(endpoint_name) .egld(issue_cost) - .argument(token_display_name) - .argument(token_ticker); + .argument(&token_display_name) + .argument(&token_ticker); if token_type == EsdtTokenType::Fungible { - tx = tx.argument(initial_supply); + tx = tx.argument(&initial_supply); tx = tx.argument(&properties.num_decimals); } else if token_type == EsdtTokenType::Meta { tx = tx.argument(&properties.num_decimals); @@ -290,14 +290,14 @@ where /// It will fail if the SC is not the owner of the token. pub fn mint>, Arg1: ProxyArg>>( self, - token_identifier: &Arg0, - amount: &Arg1, + token_identifier: Arg0, + amount: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("mint") - .argument(token_identifier) - .argument(amount) + .argument(&token_identifier) + .argument(&amount) .original_result() } @@ -305,14 +305,14 @@ where /// which causes it to burn fungible ESDT tokens owned by the SC. pub fn burn>, Arg1: ProxyArg>>( self, - token_identifier: &Arg0, - amount: &Arg1, + token_identifier: Arg0, + amount: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("ESDTBurn") - .argument(token_identifier) - .argument(amount) + .argument(&token_identifier) + .argument(&amount) .original_result() } @@ -320,24 +320,24 @@ where /// except minting, freezing/unfreezing and wiping. pub fn pause>>( self, - token_identifier: &Arg0, + token_identifier: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("pause") - .argument(token_identifier) + .argument(&token_identifier) .original_result() } /// The reverse operation of `pause`. pub fn unpause>>( self, - token_identifier: &Arg0, + token_identifier: Arg0, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("unPause") - .argument(token_identifier) + .argument(&token_identifier) .original_result() } @@ -349,14 +349,14 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, - address: &Arg1, + token_identifier: Arg0, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("freeze") - .argument(token_identifier) - .argument(address) + .argument(&token_identifier) + .argument(&address) .original_result() } @@ -366,14 +366,14 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, - address: &Arg1, + token_identifier: Arg0, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("unFreeze") - .argument(token_identifier) - .argument(address) + .argument(&token_identifier) + .argument(&address) .original_result() } @@ -386,14 +386,14 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, - address: &Arg1, + token_identifier: Arg0, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("wipe") - .argument(token_identifier) - .argument(address) + .argument(&token_identifier) + .argument(&address) .original_result() } @@ -405,16 +405,16 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, + token_identifier: Arg0, nft_nonce: u64, - address: &Arg1, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("freezeSingleNFT") - .argument(token_identifier) + .argument(&token_identifier) .argument(&nft_nonce) - .argument(address) + .argument(&address) .original_result() } @@ -424,16 +424,16 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, + token_identifier: Arg0, nft_nonce: u64, - address: &Arg1, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("unFreezeSingleNFT") - .argument(token_identifier) + .argument(&token_identifier) .argument(&nft_nonce) - .argument(address) + .argument(&address) .original_result() } @@ -446,16 +446,16 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, + token_identifier: Arg0, nft_nonce: u64, - address: &Arg1, + address: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("wipeSingleNFT") - .argument(token_identifier) + .argument(&token_identifier) .argument(&nft_nonce) - .argument(address) + .argument(&address) .original_result() } @@ -463,13 +463,13 @@ where /// This function as almost all in case of ESDT can be called only by the owner. pub fn change_sft_to_meta_esdt>>( self, - token_identifier: &Arg0, + token_identifier: Arg0, num_decimals: usize, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("changeSFTToMetaESDT") - .argument(token_identifier) + .argument(&token_identifier) .argument(&num_decimals) .original_result() } @@ -484,16 +484,16 @@ where Arg1: ProxyArg>, >( self, - address: &Arg0, - token_identifier: &Arg1, + address: Arg0, + token_identifier: Arg1, roles_iter: RoleIter, ) -> TxTypedCall { let mut tx = self .wrapped_tx .payment(NotPayable) .raw_call("setSpecialRole") - .argument(token_identifier) - .argument(address); + .argument(&token_identifier) + .argument(&address); for role in roles_iter { if role != EsdtLocalRole::None { tx = tx.argument(&role.as_role_name()); @@ -513,16 +513,16 @@ where Arg1: ProxyArg>, >( self, - address: &Arg0, - token_identifier: &Arg1, + address: Arg0, + token_identifier: Arg1, roles_iter: RoleIter, ) -> TxTypedCall { let mut tx = self .wrapped_tx .payment(NotPayable) .raw_call("unSetSpecialRole") - .argument(token_identifier) - .argument(address); + .argument(&token_identifier) + .argument(&address); for role in roles_iter { if role != EsdtLocalRole::None { tx = tx.argument(&role.as_role_name()); @@ -537,14 +537,14 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, - new_owner: &Arg1, + token_identifier: Arg0, + new_owner: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("transferOwnership") - .argument(token_identifier) - .argument(new_owner) + .argument(&token_identifier) + .argument(&new_owner) .original_result() } @@ -553,29 +553,29 @@ where Arg1: ProxyArg>, >( self, - token_identifier: &Arg0, - old_creator: &Arg1, - new_creator: &Arg1, + token_identifier: Arg0, + old_creator: Arg1, + new_creator: Arg1, ) -> TxTypedCall { self.wrapped_tx .payment(NotPayable) .raw_call("transferNFTCreateRole") - .argument(token_identifier) - .argument(old_creator) - .argument(new_creator) + .argument(&token_identifier) + .argument(&old_creator) + .argument(&new_creator) .original_result() } pub fn control_changes>>( self, - token_identifier: &Arg0, + token_identifier: Arg0, property_arguments: &TokenPropertyArguments, ) -> TxTypedCall { let mut tx = self .wrapped_tx .payment(NotPayable) .raw_call("controlChanges") - .argument(token_identifier); + .argument(&token_identifier); append_token_property_arguments(&mut tx.data, property_arguments); tx.original_result() } diff --git a/tools/interactor-system-func-calls/src/system_sc_interact.rs b/tools/interactor-system-func-calls/src/system_sc_interact.rs index 0558eba3c1..df47733d47 100644 --- a/tools/interactor-system-func-calls/src/system_sc_interact.rs +++ b/tools/interactor-system-func-calls/src/system_sc_interact.rs @@ -257,9 +257,9 @@ impl SysFuncCallsInteract { .typed(ESDTSystemSCProxy) .issue_fungible( issue_cost.into(), - &token_display_name, - &token_ticker, - &initial_supply, + token_display_name, + token_ticker, + initial_supply, FungibleTokenProperties { num_decimals, can_freeze: true, @@ -297,8 +297,8 @@ impl SysFuncCallsInteract { .typed(ESDTSystemSCProxy) .issue_non_fungible( issue_cost.into(), - &token_display_name, - &token_ticker, + token_display_name, + token_ticker, NonFungibleTokenProperties { can_freeze: true, can_wipe: true, @@ -334,8 +334,8 @@ impl SysFuncCallsInteract { .typed(ESDTSystemSCProxy) .issue_semi_fungible( issue_cost.into(), - &token_display_name, - &token_ticker, + token_display_name, + token_ticker, SemiFungibleTokenProperties { can_freeze: true, can_wipe: true, @@ -397,8 +397,8 @@ impl SysFuncCallsInteract { .gas(100_000_000u64) .typed(ESDTSystemSCProxy) .set_special_roles( - &ManagedAddress::from_address(wallet_address), - &TokenIdentifier::from(token_id), + ManagedAddress::from_address(wallet_address), + TokenIdentifier::from(token_id), roles.into_iter(), ) .prepare_async() @@ -423,11 +423,11 @@ impl SysFuncCallsInteract { .gas(100_000_000u64) .typed(UserBuiltinProxy) .esdt_nft_create( - &token_id, - &amount, - &name, - &royalties, - &hash, + token_id, + amount, + name, + royalties, + hash, &NftDummyAttributes { creation_epoch: 2104, cool_factor: 5, @@ -457,8 +457,8 @@ impl SysFuncCallsInteract { .typed(ESDTSystemSCProxy) .register_meta_esdt( issue_cost.into(), - &token_display_name, - &token_ticker, + token_display_name, + token_ticker, MetaTokenProperties { num_decimals, can_freeze: true, @@ -487,7 +487,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .change_sft_to_meta_esdt(&token_id, num_decimals) + .change_sft_to_meta_esdt(token_id, num_decimals) .prepare_async() .run() .await; @@ -502,7 +502,7 @@ impl SysFuncCallsInteract { .to(&self.wallet_address) .gas(100_000_000u64) .typed(UserBuiltinProxy) - .esdt_local_mint(&token_id, nonce, &amount) + .esdt_local_mint(token_id, nonce, amount) .prepare_async() .run() .await; @@ -517,7 +517,7 @@ impl SysFuncCallsInteract { .to(&self.wallet_address) .gas(100_000_000u64) .typed(UserBuiltinProxy) - .esdt_local_burn(&token_id, nonce, &amount) + .esdt_local_burn(token_id, nonce, amount) .prepare_async() .run() .await; @@ -532,7 +532,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .pause(&token_id) + .pause(token_id) .prepare_async() .run() .await; @@ -547,7 +547,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .unpause(&token_id) + .unpause(token_id) .prepare_async() .run() .await; @@ -562,7 +562,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .freeze(&token_id, &address) + .freeze(token_id, address) .prepare_async() .run() .await; @@ -577,7 +577,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .unfreeze(&token_id, &address) + .unfreeze(token_id, address) .prepare_async() .run() .await; @@ -592,7 +592,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .freeze_nft(&token_id, nonce, &address) + .freeze_nft(token_id, nonce, address) .prepare_async() .run() .await; @@ -607,7 +607,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .unfreeze_nft(&token_id, nonce, &address) + .unfreeze_nft(token_id, nonce, address) .prepare_async() .run() .await; @@ -622,7 +622,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .wipe(&token_id, &address) + .wipe(token_id, address) .prepare_async() .run() .await; @@ -637,7 +637,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .wipe_nft(&token_id, nonce, &address) + .wipe_nft(token_id, nonce, address) .prepare_async() .run() .await; @@ -660,11 +660,11 @@ impl SysFuncCallsInteract { .gas(100_000_000u64) .typed(UserBuiltinProxy) .esdt_nft_create( - &token_id, - &amount, - &name, - &royalties, - &hash, + token_id, + amount, + name, + royalties, + hash, &NftDummyAttributes { creation_epoch: 2104, cool_factor: 5, @@ -690,7 +690,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .unset_special_roles(&address, &token_id, roles.into_iter()) + .unset_special_roles(address, token_id, roles.into_iter()) .prepare_async() .run() .await; @@ -705,7 +705,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .transfer_ownership(&token_id, &new_owner) + .transfer_ownership(token_id, new_owner) .prepare_async() .run() .await; @@ -725,7 +725,7 @@ impl SysFuncCallsInteract { .to(ESDTSystemSCAddress) .gas(100_000_000u64) .typed(ESDTSystemSCProxy) - .transfer_nft_create_role(&token_id, &old_owner, &new_owner) + .transfer_nft_create_role(token_id, old_owner, new_owner) .prepare_async() .run() .await; @@ -741,7 +741,7 @@ impl SysFuncCallsInteract { .gas(100_000_000u64) .typed(ESDTSystemSCProxy) .control_changes( - &token_id, + token_id, &TokenPropertyArguments { can_freeze: Some(true), can_wipe: Some(true),