From e8dfee4c76c06c30f02182c64f1ec0e3d069bdb9 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Wed, 4 Dec 2024 14:41:23 +0100 Subject: [PATCH] update token endpoint, tests --- .../system_proxy/esdt_system_sc_proxy.rs | 12 +++++++++++ .../src/system_sc_interact.rs | 14 +++++++++++++ .../tests/chain_simulator_token_tests.rs | 20 +++++++++++++++++++ 3 files changed, 46 insertions(+) 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 468243d024..7e4e0fb4ed 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 @@ -652,6 +652,18 @@ where .argument(&token_id) .original_result() } + + /// Updates a specific token to the newest version. + pub fn update_token>>( + self, + token_id: Arg0, + ) -> TxTypedCall { + self.wrapped_tx + .payment(NotPayable) + .raw_call("updateTokenID") + .argument(&token_id) + .original_result() + } } const TRUE_STR: &str = "true"; 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 f98acaea98..28ecc05034 100644 --- a/tools/interactor-system-func-calls/src/system_sc_interact.rs +++ b/tools/interactor-system-func-calls/src/system_sc_interact.rs @@ -459,6 +459,20 @@ impl SysFuncCallsInteract { .await; } + pub async fn update_token(&mut self, token_id: &[u8]) { + println!("Updating the following token {token_id:?} to the newest version..."); + + self.interactor + .tx() + .from(&self.wallet_address) + .to(ESDTSystemSCAddress) + .gas(100_000_000u64) + .typed(ESDTSystemSCProxy) + .update_token(TokenIdentifier::from(token_id)) + .run() + .await; + } + pub async fn mint_sft( &mut self, token_id: &[u8], diff --git a/tools/interactor-system-func-calls/tests/chain_simulator_token_tests.rs b/tools/interactor-system-func-calls/tests/chain_simulator_token_tests.rs index 57cb67dccd..ba0f83c9f7 100644 --- a/tools/interactor-system-func-calls/tests/chain_simulator_token_tests.rs +++ b/tools/interactor-system-func-calls/tests/chain_simulator_token_tests.rs @@ -193,3 +193,23 @@ async fn change_to_dynamic_test() { // change SFT to dynamic interact.change_to_dynamic(sft_token_id.as_bytes()).await; } + +#[tokio::test] +#[ignore = "run on demand"] +async fn update_token_test() { + let mut interact = SysFuncCallsInteract::init(Config::load_config()).await; + + // issue NFT with all roles + let nft_token_id = interact + .issue_token_all_roles( + RustBigUint::from(ISSUE_COST), + b"TESTNFT", + b"TEST", + 0usize, + EsdtTokenType::NonFungible, + ) + .await; + + // update NFT + interact.update_token(nft_token_id.as_bytes()).await; +}