Skip to content

Commit

Permalink
update token endpoint, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Dec 4, 2024
1 parent 4b8e7d0 commit e8dfee4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,18 @@ where
.argument(&token_id)
.original_result()
}

/// Updates a specific token to the newest version.
pub fn update_token<Arg0: ProxyArg<TokenIdentifier<Env::Api>>>(
self,
token_id: Arg0,
) -> TxTypedCall<Env, From, To, NotPayable, Gas, ()> {
self.wrapped_tx
.payment(NotPayable)
.raw_call("updateTokenID")
.argument(&token_id)
.original_result()
}
}

const TRUE_STR: &str = "true";
Expand Down
14 changes: 14 additions & 0 deletions tools/interactor-system-func-calls/src/system_sc_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit e8dfee4

Please sign in to comment.