From 3eb16f2a1e077111c1b009a8bc5e8be475a0582d Mon Sep 17 00:00:00 2001 From: Mirko Zichichi Date: Tue, 13 Aug 2024 12:47:35 +0200 Subject: [PATCH] fix(docs/content): make self sponsor example for Shimmer --- docs/examples/rust/Cargo.toml | 4 +-- ...elf-sponsor.rs => shimmer-self-sponsor.rs} | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) rename docs/examples/rust/stardust/{self-sponsor.rs => shimmer-self-sponsor.rs} (88%) diff --git a/docs/examples/rust/Cargo.toml b/docs/examples/rust/Cargo.toml index e7258ad69ea..c968318d7ac 100644 --- a/docs/examples/rust/Cargo.toml +++ b/docs/examples/rust/Cargo.toml @@ -52,5 +52,5 @@ name = "foundry-output-claim" path = "stardust/foundry-output-claim.rs" [[example]] -name = "self-sponsor" -path = "stardust/self-sponsor.rs" \ No newline at end of file +name = "shimmer-self-sponsor" +path = "stardust/shimmer-self-sponsor.rs" \ No newline at end of file diff --git a/docs/examples/rust/stardust/self-sponsor.rs b/docs/examples/rust/stardust/shimmer-self-sponsor.rs similarity index 88% rename from docs/examples/rust/stardust/self-sponsor.rs rename to docs/examples/rust/stardust/shimmer-self-sponsor.rs index da6c92dccb3..458b618d815 100644 --- a/docs/examples/rust/stardust/self-sponsor.rs +++ b/docs/examples/rust/stardust/shimmer-self-sponsor.rs @@ -1,8 +1,8 @@ // Copyright (c) 2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//! Example demonstrating the self-sponsor scenario for claiming a basic output. -//! In order to work, it requires a network with test objects +//! Example demonstrating the self-sponsor scenario for claiming a Shimmer basic +//! output. In order to work, it requires a network with test objects //! generated from iota-genesis-builder/src/stardust/test_outputs. use std::{fs, path::PathBuf, str::FromStr}; @@ -15,9 +15,9 @@ use iota_sdk::{ types::{ base_types::ObjectID, crypto::SignatureScheme::ED25519, - gas_coin::GAS, programmable_transaction_builder::ProgrammableTransactionBuilder, quorum_driver_types::ExecuteTransactionRequestType, + smr_coin::SMR, transaction::{Argument, ObjectArg, Transaction, TransactionData}, IOTA_FRAMEWORK_ADDRESS, STARDUST_ADDRESS, }, @@ -26,6 +26,9 @@ use iota_sdk::{ use move_core_types::ident_str; use shared_crypto::intent::Intent; +pub const IOTA_COIN_TYPE: u32 = 4218; +pub const SHIMMER_COIN_TYPE: u32 = 4219; + /// Got from iota-genesis-builder/src/stardust/test_outputs/stardust_mix.rs const MAIN_ADDRESS_MNEMONIC: &str = "crazy drum raw dirt tooth where fee base warm beach trim rule sign silk fee fee dad large creek venue coin steel hub scale"; @@ -57,9 +60,12 @@ async fn main() -> Result<(), anyhow::Error> { let mut keystore = setup_keystore()?; // For this example we need to derive addresses that are not at different - // indexes, one for sponsoring and one for claiming the Basic Output. - let sponsor_derivation_path = DerivationPath::from_str("m/44'/4218'/0'/0'/5'")?; - let sender_derivation_path = DerivationPath::from_str("m/44'/4218'/0'/0'/10'")?; + // indexes and coin_types, one for sponsoring with IOTA coin type and one for + // claiming the Basic Output with Shimmer coin type. + let sponsor_derivation_path = + DerivationPath::from_str(format!("m/44'/{IOTA_COIN_TYPE}'/0'/0'/5'").as_str())?; + let sender_derivation_path = + DerivationPath::from_str(format!("m/44'/{SHIMMER_COIN_TYPE}'/0'/0'/50'").as_str())?; // Derive the address of the sponsor let sponsor = keystore.import_from_mnemonic( @@ -80,7 +86,7 @@ async fn main() -> Result<(), anyhow::Error> { // This object id was fetched manually. It refers to a Basic Output object that // contains some Native Tokens. let basic_output_object_id = ObjectID::from_hex_literal( - "0xb9c75a53a39e82bafcb454e68b3bd265a6083f32be832632df9ade976b47c37f", + "0xbdc4dec75098700e8e82349d9f3a9f28dcd22d2b39f5fbdf8436b05430bc3690", )?; // Get Basic Output object let basic_output_object = iota_client @@ -100,9 +106,9 @@ async fn main() -> Result<(), anyhow::Error> { let mut builder = ProgrammableTransactionBuilder::new(); ////// Command #1: extract the base token and native tokens bag. - // Type argument for a Basic Output coming from the IOTA network, i.e., the IOTA - // token or Gas type tag - let type_arguments = vec![GAS::type_tag()]; + // Type argument for a Basic Output coming from the Shimmer network, i.e., the + // SMR coin + let type_arguments = vec![SMR::type_tag()]; // Then pass the basic output object as input let arguments = vec![builder.obj(ObjectArg::ImmOrOwnedObject(basic_output_object_ref))?]; // Finally call the basic_output::extract_assets function @@ -128,9 +134,9 @@ async fn main() -> Result<(), anyhow::Error> { arguments, ); - ////// Command #3: create a coin from the extracted IOTA balance - // Type argument for the IOTA coin - let type_arguments = vec![GAS::type_tag()]; + ////// Command #3: create a coin from the extracted SMR balance + // Type argument for the SMR coin + let type_arguments = vec![SMR::type_tag()]; let arguments = vec![extracted_base_token]; let new_iota_coin = builder.programmable_move_call( IOTA_FRAMEWORK_ADDRESS.into(),