From 0677426c91cba56bd61b1e69669e2c8339dd07cf Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 4 Dec 2023 18:46:58 +0100 Subject: [PATCH 1/7] Set issuer of sent blocks --- bindings/core/src/method_handler/wallet.rs | 3 ++- .../wallet/offline_signing/3_send_transaction.rs | 2 +- sdk/src/wallet/operations/block.rs | 12 +++++++++--- sdk/src/wallet/operations/output_claiming.rs | 4 +++- sdk/src/wallet/operations/output_consolidation.rs | 4 +++- sdk/src/wallet/operations/participation/voting.rs | 4 ++-- .../wallet/operations/participation/voting_power.rs | 4 ++-- sdk/src/wallet/operations/syncing/transactions.rs | 4 +++- sdk/src/wallet/operations/transaction/account.rs | 10 ++++++++-- .../high_level/burning_melting/melt_native_token.rs | 3 ++- .../transaction/high_level/burning_melting/mod.rs | 2 +- .../transaction/high_level/create_account.rs | 3 ++- .../high_level/minting/create_native_token.rs | 2 +- .../high_level/minting/mint_native_token.rs | 2 +- .../transaction/high_level/minting/mint_nfts.rs | 3 ++- .../operations/transaction/high_level/send.rs | 3 ++- .../transaction/high_level/send_native_tokens.rs | 3 ++- .../operations/transaction/high_level/send_nft.rs | 3 ++- sdk/src/wallet/operations/transaction/mod.rs | 13 +++++++++---- .../operations/transaction/submit_transaction.rs | 5 +++-- 20 files changed, 60 insertions(+), 29 deletions(-) diff --git a/bindings/core/src/method_handler/wallet.rs b/bindings/core/src/method_handler/wallet.rs index 8c30d7bf11..a0b59f8088 100644 --- a/bindings/core/src/method_handler/wallet.rs +++ b/bindings/core/src/method_handler/wallet.rs @@ -368,6 +368,7 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM &wallet.client().get_protocol_parameters().await?, )?, None, + None, ) .await?; Response::SentTransaction(TransactionWithMetadataDto::from(&transaction)) @@ -388,7 +389,7 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM &wallet.client().get_protocol_parameters().await?, )?; let transaction = wallet - .submit_and_store_transaction(signed_transaction_data, None) + .submit_and_store_transaction(signed_transaction_data, None, None) .await?; Response::SentTransaction(TransactionWithMetadataDto::from(&transaction)) } diff --git a/sdk/examples/wallet/offline_signing/3_send_transaction.rs b/sdk/examples/wallet/offline_signing/3_send_transaction.rs index 5a108b9fbc..9763aec488 100644 --- a/sdk/examples/wallet/offline_signing/3_send_transaction.rs +++ b/sdk/examples/wallet/offline_signing/3_send_transaction.rs @@ -43,7 +43,7 @@ async fn main() -> Result<()> { // Sends offline signed transaction online. let transaction = wallet - .submit_and_store_transaction(signed_transaction_data, None) + .submit_and_store_transaction(signed_transaction_data, None, None) .await?; wait_for_inclusion(&transaction.transaction_id, &wallet).await?; diff --git a/sdk/src/wallet/operations/block.rs b/sdk/src/wallet/operations/block.rs index 93f1a63914..38c467d515 100644 --- a/sdk/src/wallet/operations/block.rs +++ b/sdk/src/wallet/operations/block.rs @@ -12,13 +12,19 @@ where crate::wallet::Error: From, crate::client::Error: From, { - pub(crate) async fn submit_basic_block(&self, payload: Option) -> Result { + pub(crate) async fn submit_basic_block( + &self, + payload: Option, + issuer_id: impl Into> + Send, + ) -> Result { log::debug!("submit_basic_block"); + // TODO + let issuer_id = issuer_id.into().unwrap_or(AccountId::null()); + let block = self .client() - // TODO https://github.com/iotaledger/iota-sdk/issues/1665 to set AccountId - .build_basic_block(AccountId::null(), payload) + .build_basic_block(issuer_id, payload) .await? .sign_ed25519( &*self.get_secret_manager().read().await, diff --git a/sdk/src/wallet/operations/output_claiming.rs b/sdk/src/wallet/operations/output_claiming.rs index f966eee27e..fa64145091 100644 --- a/sdk/src/wallet/operations/output_claiming.rs +++ b/sdk/src/wallet/operations/output_claiming.rs @@ -203,7 +203,9 @@ where } })?; - let claim_tx = self.sign_and_submit_transaction(prepared_transaction, None).await?; + let claim_tx = self + .sign_and_submit_transaction(prepared_transaction, None, None) + .await?; log::debug!( "[OUTPUT_CLAIMING] Claiming transaction created: block_id: {:?} tx_id: {:?}", diff --git a/sdk/src/wallet/operations/output_consolidation.rs b/sdk/src/wallet/operations/output_consolidation.rs index c07c70195f..fdb29b815b 100644 --- a/sdk/src/wallet/operations/output_consolidation.rs +++ b/sdk/src/wallet/operations/output_consolidation.rs @@ -105,7 +105,9 @@ where /// transaction. pub async fn consolidate_outputs(&self, params: ConsolidationParams) -> Result { let prepared_transaction = self.prepare_consolidate_outputs(params).await?; - let consolidation_tx = self.sign_and_submit_transaction(prepared_transaction, None).await?; + let consolidation_tx = self + .sign_and_submit_transaction(prepared_transaction, None, None) + .await?; log::debug!( "[OUTPUT_CONSOLIDATION] consolidation transaction created: block_id: {:?} tx_id: {:?}", diff --git a/sdk/src/wallet/operations/participation/voting.rs b/sdk/src/wallet/operations/participation/voting.rs index 5da86d003a..b8642af3c6 100644 --- a/sdk/src/wallet/operations/participation/voting.rs +++ b/sdk/src/wallet/operations/participation/voting.rs @@ -41,7 +41,7 @@ where ) -> Result { let prepared = self.prepare_vote(event_id, answers).await?; - self.sign_and_submit_transaction(prepared, None).await + self.sign_and_submit_transaction(prepared, None, None).await } /// Prepares the transaction for [Wallet::vote()]. @@ -131,7 +131,7 @@ where pub async fn stop_participating(&self, event_id: ParticipationEventId) -> Result { let prepared = self.prepare_stop_participating(event_id).await?; - self.sign_and_submit_transaction(prepared, None).await + self.sign_and_submit_transaction(prepared, None, None).await } /// Prepares the transaction for [Wallet::stop_participating()]. diff --git a/sdk/src/wallet/operations/participation/voting_power.rs b/sdk/src/wallet/operations/participation/voting_power.rs index 4bf3a8c88b..550ffe64d9 100644 --- a/sdk/src/wallet/operations/participation/voting_power.rs +++ b/sdk/src/wallet/operations/participation/voting_power.rs @@ -44,7 +44,7 @@ where pub async fn increase_voting_power(&self, amount: u64) -> Result { let prepared = self.prepare_increase_voting_power(amount).await?; - self.sign_and_submit_transaction(prepared, None).await + self.sign_and_submit_transaction(prepared, None, None).await } /// Prepares the transaction for [Wallet::increase_voting_power()]. @@ -92,7 +92,7 @@ where pub async fn decrease_voting_power(&self, amount: u64) -> Result { let prepared = self.prepare_decrease_voting_power(amount).await?; - self.sign_and_submit_transaction(prepared, None).await + self.sign_and_submit_transaction(prepared, None, None).await } /// Prepares the transaction for [Wallet::decrease_voting_power()]. diff --git a/sdk/src/wallet/operations/syncing/transactions.rs b/sdk/src/wallet/operations/syncing/transactions.rs index 890e78e041..609dff8c62 100644 --- a/sdk/src/wallet/operations/syncing/transactions.rs +++ b/sdk/src/wallet/operations/syncing/transactions.rs @@ -202,7 +202,9 @@ where for mut transaction in transactions_to_reissue { log::debug!("[SYNC] reissue transaction"); - let reissued_block = self.submit_signed_transaction(transaction.payload.clone()).await?; + let reissued_block = self + .submit_signed_transaction(transaction.payload.clone(), None) + .await?; transaction.block_id.replace(reissued_block); updated_transactions.push(transaction); } diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 099f9f1fcf..1dea13e4c9 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -24,8 +24,14 @@ where { /// Transitions an implicit account to an account. pub async fn implicit_account_transition(&self, output_id: &OutputId) -> Result { - self.sign_and_submit_transaction(self.prepare_implicit_account_transition(output_id).await?, None) - .await + let issuer_id = AccountId::from(output_id); + + self.sign_and_submit_transaction( + self.prepare_implicit_account_transition(output_id).await?, + issuer_id, + None, + ) + .await } /// Prepares to transition an implicit account to an account. diff --git a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs index 9aafc1c92c..70cde54392 100644 --- a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs @@ -37,7 +37,8 @@ where .prepare_melt_native_token(token_id, melt_amount, options.clone()) .await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::melt_native_token()]. diff --git a/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs b/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs index 809a4ee45e..3909c7c7f7 100644 --- a/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs +++ b/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs @@ -22,7 +22,7 @@ impl Wallet { let options = options.into(); let prepared = self.prepare_burn(burn, options.clone()).await?; - self.sign_and_submit_transaction(prepared, options).await + self.sign_and_submit_transaction(prepared, None, options).await } /// A generic `prepare_burn()` function that can be used to prepare the burn of native tokens, nfts, foundries and diff --git a/sdk/src/wallet/operations/transaction/high_level/create_account.rs b/sdk/src/wallet/operations/transaction/high_level/create_account.rs index 944e0dd351..9ae930a68f 100644 --- a/sdk/src/wallet/operations/transaction/high_level/create_account.rs +++ b/sdk/src/wallet/operations/transaction/high_level/create_account.rs @@ -62,7 +62,8 @@ where let options = options.into(); let prepared_transaction = self.prepare_create_account_output(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::create_account_output()]. diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs index 554ecb6ac3..e74dbc10f4 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs @@ -117,7 +117,7 @@ where let options = options.into(); let prepared = self.prepare_create_native_token(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared.transaction, options) + self.sign_and_submit_transaction(prepared.transaction, None, options) .await .map(|transaction| CreateNativeTokenTransaction { token_id: prepared.token_id, diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs index 6288c1837b..4342e48b97 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs @@ -41,7 +41,7 @@ where let prepared = self .prepare_mint_native_token(token_id, mint_amount, options.clone()) .await?; - let transaction = self.sign_and_submit_transaction(prepared, options).await?; + let transaction = self.sign_and_submit_transaction(prepared, None, options).await?; Ok(transaction) } diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs index 28542e2503..613fd48d19 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs @@ -147,7 +147,8 @@ where let options = options.into(); let prepared_transaction = self.prepare_mint_nfts(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::mint_nfts()]. diff --git a/sdk/src/wallet/operations/transaction/high_level/send.rs b/sdk/src/wallet/operations/transaction/high_level/send.rs index 4f03b7a35b..f51d01afaf 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send.rs @@ -121,7 +121,8 @@ where let options = options.into(); let prepared_transaction = self.prepare_send(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::send()]. diff --git a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs index 56a89ef771..255931a5f3 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs @@ -111,7 +111,8 @@ where let options = options.into(); let prepared_transaction = self.prepare_send_native_tokens(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::send_native_tokens()]. diff --git a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs index b62a24b139..995de07b89 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs @@ -79,7 +79,8 @@ where let options = options.into(); let prepared_transaction = self.prepare_send_nft(params, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction, options).await + self.sign_and_submit_transaction(prepared_transaction, None, options) + .await } /// Prepares the transaction for [Wallet::send_nft()]. diff --git a/sdk/src/wallet/operations/transaction/mod.rs b/sdk/src/wallet/operations/transaction/mod.rs index 82221ec46d..84fb9a78b2 100644 --- a/sdk/src/wallet/operations/transaction/mod.rs +++ b/sdk/src/wallet/operations/transaction/mod.rs @@ -20,7 +20,10 @@ use crate::{ }, types::{ api::core::OutputWithMetadataResponse, - block::{output::Output, payload::signed_transaction::SignedTransactionPayload}, + block::{ + output::{AccountId, Output}, + payload::signed_transaction::SignedTransactionPayload, + }, }, wallet::{ types::{InclusionState, TransactionWithMetadata}, @@ -89,7 +92,7 @@ where let prepared_transaction_data = self.prepare_transaction(outputs, options.clone()).await?; - self.sign_and_submit_transaction(prepared_transaction_data, options) + self.sign_and_submit_transaction(prepared_transaction_data, None, options) .await } @@ -97,6 +100,7 @@ where pub async fn sign_and_submit_transaction( &self, prepared_transaction_data: PreparedTransactionData, + issuer_id: impl Into> + Send, options: impl Into> + Send, ) -> crate::wallet::Result { log::debug!("[TRANSACTION] sign_and_submit_transaction"); @@ -110,7 +114,7 @@ where } }; - self.submit_and_store_transaction(signed_transaction_data, options) + self.submit_and_store_transaction(signed_transaction_data, issuer_id, options) .await } @@ -118,6 +122,7 @@ where pub async fn submit_and_store_transaction( &self, signed_transaction_data: SignedTransactionData, + issuer_id: impl Into> + Send, options: impl Into> + Send, ) -> crate::wallet::Result { log::debug!( @@ -141,7 +146,7 @@ where // Ignore errors from sending, we will try to send it again during [`sync_pending_transactions`] let block_id = match self - .submit_signed_transaction(signed_transaction_data.payload.clone()) + .submit_signed_transaction(signed_transaction_data.payload.clone(), issuer_id) .await { Ok(block_id) => Some(block_id), diff --git a/sdk/src/wallet/operations/transaction/submit_transaction.rs b/sdk/src/wallet/operations/transaction/submit_transaction.rs index bf202b44f8..3fffb31b7e 100644 --- a/sdk/src/wallet/operations/transaction/submit_transaction.rs +++ b/sdk/src/wallet/operations/transaction/submit_transaction.rs @@ -5,7 +5,7 @@ use crate::wallet::events::types::{TransactionProgressEvent, WalletEvent}; use crate::{ client::secret::SecretManage, - types::block::{payload::Payload, BlockId}, + types::block::{output::AccountId, payload::Payload, BlockId}, wallet::{operations::transaction::SignedTransactionPayload, Wallet}, }; @@ -18,6 +18,7 @@ where pub(crate) async fn submit_signed_transaction( &self, payload: SignedTransactionPayload, + issuer_id: impl Into> + Send, ) -> crate::wallet::Result { log::debug!("[TRANSACTION] submit_signed_transaction"); @@ -25,6 +26,6 @@ where self.emit(WalletEvent::TransactionProgress(TransactionProgressEvent::Broadcasting)) .await; - self.submit_basic_block(Some(Payload::from(payload))).await + self.submit_basic_block(Some(Payload::from(payload)), issuer_id).await } } From 9486270bdb0b5e875051c5fab48511bae606a7e6 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 4 Dec 2023 20:40:45 +0100 Subject: [PATCH 2/7] Set implicit account transition context inputs --- .../types/block/context_input/block_issuance_credit.rs | 2 +- sdk/src/types/block/context_input/commitment.rs | 2 +- sdk/src/types/block/context_input/reward.rs | 2 +- sdk/src/wallet/operations/transaction/account.rs | 10 +++++++++- .../wallet/operations/transaction/build_transaction.rs | 4 ++++ sdk/src/wallet/operations/transaction/options.rs | 6 +++++- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/sdk/src/types/block/context_input/block_issuance_credit.rs b/sdk/src/types/block/context_input/block_issuance_credit.rs index fececf43f9..b4855e0c55 100644 --- a/sdk/src/types/block/context_input/block_issuance_credit.rs +++ b/sdk/src/types/block/context_input/block_issuance_credit.rs @@ -15,7 +15,7 @@ pub struct BlockIssuanceCreditContextInput(AccountId); impl BlockIssuanceCreditContextInput { /// The context input kind of a [`BlockIssuanceCreditContextInput`]. - pub const KIND: u8 = 1; + pub const KIND: u8 = 2; /// Creates a new [`BlockIssuanceCreditContextInput`]. pub fn new(account_id: AccountId) -> Self { diff --git a/sdk/src/types/block/context_input/commitment.rs b/sdk/src/types/block/context_input/commitment.rs index c799e7dc3b..30aa10699f 100644 --- a/sdk/src/types/block/context_input/commitment.rs +++ b/sdk/src/types/block/context_input/commitment.rs @@ -14,7 +14,7 @@ pub struct CommitmentContextInput(SlotCommitmentId); impl CommitmentContextInput { /// The context input kind of a [`CommitmentContextInput`]. - pub const KIND: u8 = 0; + pub const KIND: u8 = 1; /// Creates a new [`CommitmentContextInput`]. pub fn new(commitment_id: SlotCommitmentId) -> Self { diff --git a/sdk/src/types/block/context_input/reward.rs b/sdk/src/types/block/context_input/reward.rs index 347cdaa350..a8f3ea7d76 100644 --- a/sdk/src/types/block/context_input/reward.rs +++ b/sdk/src/types/block/context_input/reward.rs @@ -19,7 +19,7 @@ pub struct RewardContextInput(#[packable(unpack_error_with = Error::InvalidRewar impl RewardContextInput { /// The context input kind of a [`RewardContextInput`]. - pub const KIND: u8 = 2; + pub const KIND: u8 = 3; /// Creates a new [`RewardContextInput`]. pub fn new(index: u16) -> Result { diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 4e4800b4fa..5c66b1fe0f 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -8,6 +8,7 @@ use crate::{ client::{api::PreparedTransactionData, secret::SecretManage}, types::block::{ address::Address, + context_input::{BlockIssuanceCreditContextInput, CommitmentContextInput}, output::{ feature::{BlockIssuerFeature, BlockIssuerKey, BlockIssuerKeys, Ed25519BlockIssuerKey}, unlock_condition::AddressUnlockCondition, @@ -83,7 +84,8 @@ where } }; - let account = AccountOutput::build_with_amount(implicit_account.amount(), AccountId::from(output_id)) + let account_id = AccountId::from(output_id); + let account = AccountOutput::build_with_amount(implicit_account.amount(), account_id) .with_mana(implicit_account.mana()) .with_unlock_conditions([AddressUnlockCondition::from(Address::from( *implicit_account @@ -97,7 +99,13 @@ where )?]) .finish_output()?; + let issuance = self.client().get_issuance().await?; + let transaction_options = TransactionOptions { + context_inputs: Some(vec![ + CommitmentContextInput::new(*issuance.latest_commitment.previous_commitment_id()).into(), + BlockIssuanceCreditContextInput::new(account_id).into(), + ]), custom_inputs: Some(vec![*output_id]), ..Default::default() }; diff --git a/sdk/src/wallet/operations/transaction/build_transaction.rs b/sdk/src/wallet/operations/transaction/build_transaction.rs index b5d9ce6dc7..c1cdf59dae 100644 --- a/sdk/src/wallet/operations/transaction/build_transaction.rs +++ b/sdk/src/wallet/operations/transaction/build_transaction.rs @@ -49,6 +49,10 @@ where // Optional add a tagged payload if let Some(options) = options.into() { builder = builder.with_payload(options.tagged_data_payload); + + if let Some(context_inputs) = options.context_inputs { + builder = builder.with_context_inputs(context_inputs); + } } let transaction = builder.finish_with_params(&protocol_parameters)?; diff --git a/sdk/src/wallet/operations/transaction/options.rs b/sdk/src/wallet/operations/transaction/options.rs index 7be4a75b9e..2e98c2e0d2 100644 --- a/sdk/src/wallet/operations/transaction/options.rs +++ b/sdk/src/wallet/operations/transaction/options.rs @@ -5,7 +5,9 @@ use serde::{Deserialize, Serialize}; use crate::{ client::api::input_selection::Burn, - types::block::{address::Address, output::OutputId, payload::tagged_data::TaggedDataPayload}, + types::block::{ + address::Address, context_input::ContextInput, output::OutputId, payload::tagged_data::TaggedDataPayload, + }, }; /// Options for transactions @@ -16,6 +18,8 @@ pub struct TransactionOptions { pub remainder_value_strategy: RemainderValueStrategy, #[serde(default)] pub tagged_data_payload: Option, + #[serde(default)] + pub context_inputs: Option>, // If custom inputs are provided only they are used. If also other additional inputs should be used, // `mandatory_inputs` should be used instead. #[serde(default)] From 4c19b044f3d25bf668a0eea6721fe4a270d751f1 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 09:45:35 +0100 Subject: [PATCH 3/7] Move comment --- sdk/src/wallet/operations/transaction/build_transaction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/operations/transaction/build_transaction.rs b/sdk/src/wallet/operations/transaction/build_transaction.rs index c1cdf59dae..2f126b6fff 100644 --- a/sdk/src/wallet/operations/transaction/build_transaction.rs +++ b/sdk/src/wallet/operations/transaction/build_transaction.rs @@ -46,8 +46,8 @@ where .with_inputs(inputs) .with_outputs(selected_transaction_data.outputs); - // Optional add a tagged payload if let Some(options) = options.into() { + // Optional add a tagged payload builder = builder.with_payload(options.tagged_data_payload); if let Some(context_inputs) = options.context_inputs { From 5810bd999d7e9308aaa77ac9873396314e71501a Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 09:59:57 +0100 Subject: [PATCH 4/7] Use ID of latest_commitment --- sdk/src/wallet/operations/transaction/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 5c66b1fe0f..86d1ebc411 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -103,7 +103,7 @@ where let transaction_options = TransactionOptions { context_inputs: Some(vec![ - CommitmentContextInput::new(*issuance.latest_commitment.previous_commitment_id()).into(), + CommitmentContextInput::new(issuance.latest_commitment.id()).into(), BlockIssuanceCreditContextInput::new(account_id).into(), ]), custom_inputs: Some(vec![*output_id]), From 844eb80d34d3fff2edf71291cd9f8a759a9e2ef7 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 10:10:14 +0100 Subject: [PATCH 5/7] Temporarily change context input IDs --- sdk/src/types/block/context_input/mod.rs | 34 ++++++++++-------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/sdk/src/types/block/context_input/mod.rs b/sdk/src/types/block/context_input/mod.rs index c7972d6bea..4d8ee73af6 100644 --- a/sdk/src/types/block/context_input/mod.rs +++ b/sdk/src/types/block/context_input/mod.rs @@ -82,10 +82,10 @@ mod tests { use super::ContextInput; #[test] - fn test_commitment() { + fn commitment() { let commitment: ContextInput = serde_json::from_value(serde_json::json!( { - "type": 0, + "type": 1, "commitmentId": "0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d8" } )) @@ -107,15 +107,13 @@ mod tests { } #[test] - fn test_block_issuance_credit() { - let bic: ContextInput = serde_json::from_str( - r#" + fn block_issuance_credit() { + let bic: ContextInput = serde_json::from_value(serde_json::json!( { - "type": 1, + "type": 2, "accountId": "0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c649" } - "#, - ) + )) .unwrap(); assert!(bic.is_block_issuance_credit()); assert_eq!( @@ -124,27 +122,23 @@ mod tests { ); // Test wrong type returns error. - let bic_deserialization_result: Result = serde_json::from_str( - r#" + let bic_deserialization_result: Result = serde_json::from_value(serde_json::json!( { - "type": 2, + "type": 3, "accountId": "0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c649" } - "#, - ); + )); assert!(bic_deserialization_result.is_err()); } #[test] - fn test_reward() { - let reward: ContextInput = serde_json::from_str( - r#" + fn reward() { + let reward: ContextInput = serde_json::from_value(serde_json::json!( { - "type": 2, - "index": 10 + "type": 3, + "index": 10 } - "#, - ) + )) .unwrap(); assert!(reward.is_reward()); assert_eq!(reward.as_reward().index(), 10); From b3834a86595292970f6da7579c6f5ca18ff3e9f3 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 10:12:12 +0100 Subject: [PATCH 6/7] Add TODO --- sdk/src/wallet/operations/transaction/account.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 86d1ebc411..49abc800ea 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -99,6 +99,7 @@ where )?]) .finish_output()?; + // TODO https://github.com/iotaledger/iota-sdk/issues/1740 let issuance = self.client().get_issuance().await?; let transaction_options = TransactionOptions { From 6b4419e3a12fe59fca2786dcb0130b0441cdf79f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 10:18:42 +0100 Subject: [PATCH 7/7] Clippy --- sdk/src/wallet/operations/transaction/account.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 49abc800ea..81d64777a3 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -30,7 +30,7 @@ where pub async fn implicit_account_transition( &self, output_id: &OutputId, - key_source: Option>, + key_source: Option + Send>, ) -> Result { let issuer_id = AccountId::from(output_id); @@ -46,7 +46,7 @@ where pub async fn prepare_implicit_account_transition( &self, output_id: &OutputId, - key_source: Option>, + key_source: Option + Send>, ) -> Result where crate::wallet::Error: From,