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)]