Skip to content

Commit

Permalink
new issued token identifier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Apr 5, 2024
1 parent f4a3205 commit 8fcf604
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
4 changes: 2 additions & 2 deletions contracts/examples/multisig/interact/src/multisig_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl MultisigInteract {
.await
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
let wallet_address = interactor.register_wallet(test_wallets::mike());
let wallet_address = interactor.register_wallet(test_wallets::dan());
let multisig_code = BytesValue::interpret_from(
"mxsc:../output/multisig.mxsc.json",
&InterpreterContext::default(),
Expand Down Expand Up @@ -195,7 +195,7 @@ impl MultisigInteract {
.typed(multisig_proxy::MultisigProxy)
.init(quorum, board.clone())
.code(&self.multisig_code)
.gas(NumExpr("70,000,000"))
.gas(NumExpr("100,000,000"))
.returns(ReturnsNewAddress)
});
}
Expand Down
50 changes: 13 additions & 37 deletions framework/scenario/src/scenario/model/transaction/tx_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use super::{
const SC_DEPLOY_PROCESSING_TYPE: &str = "SCDeployment";
const LOG_IDENTIFIER_SIGNAL_ERROR: &str = "signalError";

const SYSTEM_SC_BECH32: &str = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u";

#[derive(Debug, Default, Clone)]
/// The response of a transaction.
pub struct TxResponse {
Expand Down Expand Up @@ -195,48 +193,26 @@ impl TxResponse {
}

fn process_new_issued_token_identifier(mut self) -> Self {
for scr in self.api_scrs.iter() {
if scr.sender.to_string() != SYSTEM_SC_BECH32 {
continue;
}

let Some(prev_tx) = self.api_scrs.iter().find(|e| e.hash == scr.prev_tx_hash) else {
continue;
};

let is_issue_fungible = prev_tx.data.starts_with("issue@");
let is_issue_semi_fungible = prev_tx.data.starts_with("issueSemiFungible@");
let is_issue_non_fungible = prev_tx.data.starts_with("issueNonFungible@");
let is_register_meta_esdt = prev_tx.data.starts_with("registerMetaESDT@");

if !is_issue_fungible
&& !is_issue_semi_fungible
&& !is_issue_non_fungible
&& !is_register_meta_esdt
{
continue;
}
if let Some(logs) = &self.api_logs {
for event in logs.events.iter().cloned() {
if event.identifier != "performAction" {
continue;
}

if scr.data.starts_with("ESDTTransfer@") {
let encoded_tid = scr.data.split('@').nth(1);
if encoded_tid.is_none() {
return self;
if event.topics.is_none() {
continue;
}

self.new_issued_token_identifier =
Some(String::from_utf8(hex::decode(encoded_tid.unwrap()).unwrap()).unwrap());
let topics = event.topics.unwrap();

break;
} else if scr.data.starts_with("@00@") {
let encoded_tid = scr.data.split('@').nth(2);
if encoded_tid.is_none() {
return self;
if topics.get(7).is_none() {
continue;
}

self.new_issued_token_identifier =
Some(String::from_utf8(hex::decode(encoded_tid.unwrap()).unwrap()).unwrap());
let new_token_id = topics.get(7).unwrap();

break;
self.new_issued_token_identifier =
Some(String::from_utf8(base64_decode(new_token_id)).unwrap());
}
}

Expand Down

0 comments on commit 8fcf604

Please sign in to comment.