Skip to content

Commit

Permalink
Merge pull request #1146 from multiversx/interactor-nft-all-roles-trace
Browse files Browse the repository at this point in the history
Interactor issue nft with all roles
  • Loading branch information
andrei-marinica committed Jul 10, 2023
2 parents 46bf06b + 1b786f7 commit 2daacf8
Show file tree
Hide file tree
Showing 10 changed files with 737 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ async fn main() {
Some(multisig_interact_cli::InteractCliCommand::MultiDeploy(args)) => {
multisig_interact.multi_deploy(&args.count).await;
},
Some(multisig_interact_cli::InteractCliCommand::NftFullAllRoles) => {
multisig_interact
.issue_multisig_and_collection_with_all_roles_full()
.await;
},
Some(multisig_interact_cli::InteractCliCommand::NftFull) => {
multisig_interact.issue_multisig_and_collection_full().await;
},
Some(multisig_interact_cli::InteractCliCommand::NftIssueAllRoles) => {
multisig_interact.issue_collection_with_all_roles().await;
},
Some(multisig_interact_cli::InteractCliCommand::NftIssue) => {
multisig_interact.issue_collection().await;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ pub enum InteractCliCommand {
Feed,
#[command(name = "multi-deploy", about = "Multiple deploy contracts")]
MultiDeploy(MultiDeployArgs),
#[command(
name = "nft-full-all-roles",
about = "Issue multisig and collection with all roles"
)]
NftFullAllRoles,
#[command(name = "nft-full", about = "Issue multisig and collection")]
NftFull,
#[command(
name = "nft-issue-all-roles",
about = "Issue collection with all roles"
)]
NftIssueAllRoles,
#[command(name = "nft-issue", about = "Issue collection")]
NftIssue,
#[command(name = "nft-items", about = "Create items")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ISSUE_COST: u64 = 50000000000000000; // 0.05 EGLD

const COLLECTION_NAME: &str = "TestCollection1";
const COLLECTION_TICKER: &str = "TESTCOLL1";
const TOKEN_TYPE: &str = "NFT";

const NUM_ITEMS: usize = 3;
const ROYALTIES: usize = 3000;
Expand All @@ -23,6 +24,94 @@ impl MultisigInteract {
self.create_items().await;
}

pub async fn issue_multisig_and_collection_with_all_roles_full(&mut self) {
self.deploy().await;
self.feed_contract_egld().await;
self.issue_collection_with_all_roles().await;
self.interactor.sleep(Duration::from_secs(15)).await;
self.create_items().await;
}

pub async fn propose_issue_collection_with_all_roles(&mut self) -> Option<usize> {
let system_sc_address = bech32::decode(SYSTEM_SC_BECH32);
let mut typed_sc_call = self
.state
.multisig()
.propose_async_call(
system_sc_address,
ISSUE_COST,
"registerAndSetAllRoles".to_string(),
MultiValueVec::from([
COLLECTION_NAME.as_bytes(),
COLLECTION_TICKER.as_bytes(),
TOKEN_TYPE.as_bytes(),
top_encode_to_vec_u8_or_panic(&0u32).as_slice(),
]),
)
.into_blockchain_call()
.from(&self.wallet_address)
.gas_limit("10,000,000")
.expect(TxExpect::ok());

self.interactor.sc_call(&mut typed_sc_call).await;

let result = typed_sc_call.result();
if result.is_err() {
println!(
"propose issue collection with roles failed with: {}",
result.err().unwrap()
);
return None;
}

let action_id = result.unwrap();
println!("successfully proposed issue colllection with roles action `{action_id}`");
Some(action_id)
}

pub async fn issue_collection_with_all_roles(&mut self) {
println!("proposing issue collection with all roles...");
let action_id = self.propose_issue_collection_with_all_roles().await;
if action_id.is_none() {
return;
}

let action_id = action_id.unwrap();
println!("perfoming issue collection with all roles action `{action_id}`...");

if !self.quorum_reached(action_id).await && !self.sign(action_id).await {
return;
}
println!("quorum reached for action `{action_id}`");

let mut typed_sc_call = self
.state
.multisig()
.perform_action_endpoint(action_id)
.into_blockchain_call()
.from(&self.wallet_address)
.gas_limit("80,000,000");

self.interactor.sc_call(&mut typed_sc_call).await;

let result = typed_sc_call
.response()
.issue_non_fungible_new_token_identifier();
if result.is_err() {
println!(
"perform issue collection with all roles failed with: {}",
result.err().unwrap()
);
return;
}

self.collection_token_identifier = result.unwrap();
println!(
"collection token identifier: {}",
self.collection_token_identifier
);
}

pub async fn propose_issue_collection(&mut self) -> Option<usize> {
let system_sc_address = bech32::decode(SYSTEM_SC_BECH32);
let mut typed_sc_call = self
Expand Down
Loading

0 comments on commit 2daacf8

Please sign in to comment.