diff --git a/Cargo.lock b/Cargo.lock index c1f2a11221..0e1bd2ff89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,30 +101,30 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -235,12 +235,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "bech32" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" - [[package]] name = "bech32" version = "0.10.0-beta" @@ -462,9 +456,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.10" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fffed7514f420abec6d183b1d3acfd9099c79c3a10a06ade4f8203f1411272" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -472,9 +466,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.9" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63361bae7eef3771745f02d8d892bec2fee5f6e34af316ba556e7f97a7069ff1" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -613,9 +607,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -623,9 +617,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" @@ -787,9 +781,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", "serde", @@ -909,12 +903,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "dotenvy" version = "0.15.7" @@ -1004,26 +992,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" -[[package]] -name = "enum-iterator" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79a6321a1197d7730510c7e3f6cb80432dfefecb32426de8cea0aa19b4bb8d7" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e94aa31f7c0dc764f57896dc615ddd76fc13b0d5dca7eb6cc5e018a5a09ec06" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1403,9 +1371,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "1.5.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "798154e4b6570af74899d71155fb0072d5b17e6aa12f39c8ef22c60fb8ec99e7" +checksum = "723777263b0dcc5730aec947496bd8c3940ba63c15f5633b288cc615f4f6af79" dependencies = [ "cc", "libc", @@ -1625,23 +1593,17 @@ dependencies = [ [[package]] name = "iota-ledger-nano" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82990c4050a18fcd5d78af7069ab3cd33e7a44c961526910171529bd5a4f6bb1" +checksum = "9fef85d9f5e9cf947d8a4f6aabb74f38ef970aade7d60112c8b8637596f07f93" dependencies = [ - "bech32 0.7.3", - "enum-iterator", - "futures", + "arrayref", + "byteorder", + "hex", "hidapi", "lazy_static", - "ledger-apdu", - "ledger-transport", - "ledger-transport-hid", "log", - "once_cell", - "serde", "thiserror", - "trait-async", ] [[package]] @@ -1650,7 +1612,7 @@ version = "1.1.2" dependencies = [ "anymap", "async-trait", - "bech32 0.10.0-beta", + "bech32", "bitflags 2.4.1", "bs58", "derive_more", @@ -1841,43 +1803,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "ledger-apdu" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe435806c197dfeaa5efcded5e623c4b8230fd28fdf1e91e7a86e40ef2acbf90" -dependencies = [ - "arrayref", - "no-std-compat", - "snafu", -] - -[[package]] -name = "ledger-transport" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1117f2143d92c157197785bf57711d7b02f2cfa101e162f8ca7900fb7f976321" -dependencies = [ - "async-trait", - "ledger-apdu", -] - -[[package]] -name = "ledger-transport-hid" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ba81a1f5f24396b37211478aff7fbcd605dd4544df8dbed07b9da3c2057aee" -dependencies = [ - "byteorder", - "cfg-if", - "hex", - "hidapi", - "ledger-transport", - "libc", - "log", - "thiserror", -] - [[package]] name = "libc" version = "0.2.150" @@ -1955,9 +1880,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -2131,12 +2056,6 @@ dependencies = [ "libc", ] -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - [[package]] name = "nom" version = "7.1.3" @@ -2626,9 +2545,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom", @@ -2710,15 +2629,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.25" +version = "0.38.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3026,28 +2945,6 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" -[[package]] -name = "snafu" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" -dependencies = [ - "doc-comment", - "snafu-derive", -] - -[[package]] -name = "snafu-derive" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "socket2" version = "0.4.10" @@ -3419,17 +3316,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "trait-async" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe8c654712ee594c93b7222d98b4e61c7e003aec49e73877edac607a213699d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "try-lock" version = "0.2.4" @@ -3971,9 +3857,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.19" +version = "0.5.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "b7e87b8dfbe3baffbe687eef2e164e32286eff31a5ee16463ce03d991643ec94" dependencies = [ "memchr", ] @@ -4036,18 +3922,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.27" +version = "0.7.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43de342578a3a14a9314a2dab1942cbfcbe5686e1f91acdc513058063eafe18" +checksum = "5d075cf85bbb114e933343e087b92f2146bac0d55b534cbb8188becf0039948e" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.27" +version = "0.7.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1012d89e3acb79fad7a799ce96866cfb8098b74638465ea1b1533d35900ca90" +checksum = "86cd5ca076997b97ef09d3ad65efe811fa68c9e874cb636ccb211223a813b0c2" dependencies = [ "proc-macro2", "quote", diff --git a/bindings/python/tests/test_protocol_parameters.py b/bindings/python/tests/test_protocol_parameters.py index 3aecfa5056..2450b86cf5 100644 --- a/bindings/python/tests/test_protocol_parameters.py +++ b/bindings/python/tests/test_protocol_parameters.py @@ -9,6 +9,7 @@ with open('../../sdk/tests/types/fixtures/protocol_parameters.json', "r", encoding="utf-8") as json_file: protocol_params_json = json.load(json_file) + def test_protocol_parameters(): protocol_params_dict = protocol_params_json['params'] protocol_params = ProtocolParameters.from_dict(protocol_params_dict) diff --git a/sdk/src/client/api/block_builder/input_selection/mod.rs b/sdk/src/client/api/block_builder/input_selection/mod.rs index 04fb56e061..d4e1ad58b1 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -19,7 +19,7 @@ pub use self::{burn::Burn, error::Error, requirement::Requirement}; use crate::{ client::{api::types::RemainderData, secret::types::InputSigningData}, types::block::{ - address::{AccountAddress, Address, AnchorAddress, NftAddress}, + address::{AccountAddress, Address, NftAddress}, input::INPUT_COUNT_RANGE, output::{ AccountOutput, ChainId, FoundryOutput, NativeTokensBuilder, NftOutput, Output, OutputId, OUTPUT_COUNT_RANGE, @@ -31,6 +31,7 @@ use crate::{ }; /// Working state for the input selection algorithm. +#[derive(Debug)] pub struct InputSelection { available_inputs: Vec>, required_inputs: HashSet, @@ -63,15 +64,16 @@ impl InputSelection { .output .required_and_unlocked_address(self.slot_index, input.output_id())? .0; + let required_address = if let Address::Restricted(restricted) = &required_address { + restricted.address() + } else { + &required_address + }; match required_address { - Address::Ed25519(_) => Ok(None), Address::Account(account_address) => Ok(Some(Requirement::Account(*account_address.account_id()))), Address::Nft(nft_address) => Ok(Some(Requirement::Nft(*nft_address.nft_id()))), - Address::Anchor(_) => Err(Error::UnsupportedAddressType(AnchorAddress::KIND)), - Address::ImplicitAccountCreation(_) => Ok(None), - Address::Restricted(_) => Ok(None), - _ => todo!("What do we do here?"), + _ => Ok(None), } } @@ -236,12 +238,20 @@ impl InputSelection { // PANIC: safe to unwrap as non basic/account/foundry/nft outputs are already filtered out. .unwrap() .0; + let required_address = if let Address::Restricted(restricted) = &required_address { + restricted.address() + } else { + &required_address + }; match required_address { - Address::ImplicitAccountCreation(implicit_account_creation) => self - .addresses - .contains(&Address::from(*implicit_account_creation.ed25519_address())), - Address::Restricted(restricted) => self.addresses.contains(restricted.address()), + Address::Anchor(_) => false, + Address::ImplicitAccountCreation(implicit_account_creation) => { + self.required_inputs.contains(input.output_id()) + && self + .addresses + .contains(&Address::from(*implicit_account_creation.ed25519_address())) + } _ => self.addresses.contains(&required_address), } }) diff --git a/sdk/src/client/api/block_builder/mod.rs b/sdk/src/client/api/block_builder/mod.rs index 9222463327..45bb293a2d 100644 --- a/sdk/src/client/api/block_builder/mod.rs +++ b/sdk/src/client/api/block_builder/mod.rs @@ -19,6 +19,7 @@ impl ClientInner { pub async fn build_basic_block(&self, issuer_id: AccountId, payload: Option) -> Result { let issuance = self.get_issuance().await?; + // TODO https://github.com/iotaledger/iota-sdk/issues/1753 let issuing_time = { #[cfg(feature = "std")] let issuing_time = std::time::SystemTime::now() diff --git a/sdk/src/types/api/core.rs b/sdk/src/types/api/core.rs index 48e89e3451..34b6472ad8 100644 --- a/sdk/src/types/api/core.rs +++ b/sdk/src/types/api/core.rs @@ -277,6 +277,9 @@ pub struct IssuanceBlockHeaderResponse { /// Blocks that are directly referenced to adjust opinion. #[serde(default, skip_serializing_if = "BTreeSet::is_empty")] pub shallow_like_parents: BTreeSet, + // Latest issuing time of the returned parents. + #[serde(with = "string")] + pub latest_parent_block_issuing_time: u64, /// The slot index of the latest finalized slot. pub latest_finalized_slot: SlotIndex, /// The latest slot commitment. @@ -521,7 +524,7 @@ pub struct RoutesResponse { #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct UtxoChangesResponse { - pub index: u32, + pub commitment_id: SlotCommitmentId, pub created_outputs: Vec, pub consumed_outputs: Vec, } diff --git a/sdk/src/types/block/mana/parameters.rs b/sdk/src/types/block/mana/parameters.rs index fd5ffd44c8..65e8ca8d04 100644 --- a/sdk/src/types/block/mana/parameters.rs +++ b/sdk/src/types/block/mana/parameters.rs @@ -21,11 +21,13 @@ use crate::types::block::{ pub struct ManaParameters { /// The number of bits used to represent Mana. pub(crate) bits_count: u8, - /// The amount of potential Mana generated by 1 IOTA in 1 slot. + /// The amount of potential Mana generated by 1 microIOTA in 1 slot multiplied by 2^generation_rate_exponent. pub(crate) generation_rate: u8, - /// The scaling of `mana_generation_rate` expressed as an exponent of 2. + /// The scaling of `generation_rate` expressed as an exponent of 2. + /// The actual generation rate of Mana is given by generation_rate * 2^(-generation_rate_exponent). pub(crate) generation_rate_exponent: u8, /// A lookup table of epoch index diff to mana decay factor. + /// The actual decay factor is given by decay_factors[epoch_diff] * 2^(-decay_factors_exponent). #[packable(unpack_error_with = |_| Error::InvalidManaDecayFactors)] #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::boxed_slice_prefix"))] #[getset(skip)] @@ -34,8 +36,10 @@ pub struct ManaParameters { pub(crate) decay_factors_exponent: u8, /// An integer approximation of the sum of decay over epochs. pub(crate) decay_factor_epochs_sum: u32, - /// The scaling of `mana_decay_factor_epochs_sum` expressed as an exponent of 2. + /// The scaling of `decay_factor_epochs_sum` expressed as an exponent of 2. pub(crate) decay_factor_epochs_sum_exponent: u8, + // Decay factor for 1 year. + pub(crate) annual_decay_factor_percentage: u8, } impl ManaParameters { @@ -99,6 +103,7 @@ impl Default for ManaParameters { decay_factors_exponent: Default::default(), decay_factor_epochs_sum: Default::default(), decay_factor_epochs_sum_exponent: Default::default(), + annual_decay_factor_percentage: Default::default(), } } } diff --git a/sdk/src/types/block/payload/signed_transaction/transaction.rs b/sdk/src/types/block/payload/signed_transaction/transaction.rs index 50260c10d9..8f8669419d 100644 --- a/sdk/src/types/block/payload/signed_transaction/transaction.rs +++ b/sdk/src/types/block/payload/signed_transaction/transaction.rs @@ -101,6 +101,11 @@ impl TransactionBuilder { self } + pub fn add_capabilities(mut self, capabilities: impl IntoIterator) -> Self { + self.capabilities.add_capabilities(capabilities); + self + } + /// Sets the payload of a [`TransactionBuilder`]. pub fn with_payload(mut self, payload: impl Into) -> Self { self.payload = payload.into(); diff --git a/sdk/src/types/block/protocol/mod.rs b/sdk/src/types/block/protocol/mod.rs index e4e2adaeb0..43a6ebd316 100644 --- a/sdk/src/types/block/protocol/mod.rs +++ b/sdk/src/types/block/protocol/mod.rs @@ -91,6 +91,9 @@ pub struct ProtocolParameters { /// Defines the target size of the committee. If there's fewer candidates the actual committee size could be /// smaller in a given epoch. pub(crate) target_committee_size: u8, + /// Defines the number of heavier slots that a chain needs to be ahead of the current chain to be considered for + /// switching. + pub(crate) chain_switching_threshold: u8, } // This implementation is required to make [`ProtocolParameters`] a [`Packable`] visitor. @@ -128,6 +131,7 @@ impl Default for ProtocolParameters { version_signaling_parameters: Default::default(), rewards_parameters: Default::default(), target_committee_size: 32, + chain_switching_threshold: 3, } } } diff --git a/sdk/src/wallet/error.rs b/sdk/src/wallet/error.rs index a1ae55356a..1bc7bfabe3 100644 --- a/sdk/src/wallet/error.rs +++ b/sdk/src/wallet/error.rs @@ -126,6 +126,9 @@ pub enum Error { /// Implicit account not found. #[error("implicit account not found")] ImplicitAccountNotFound, + /// No account was provided or found to issue the block. + #[error("no account was provided or found to issue the block")] + NoAccountToIssueBlock, } impl Error { diff --git a/sdk/src/wallet/operations/block.rs b/sdk/src/wallet/operations/block.rs index 3327508d39..d0962b9e50 100644 --- a/sdk/src/wallet/operations/block.rs +++ b/sdk/src/wallet/operations/block.rs @@ -15,8 +15,16 @@ impl Wallet { ) -> Result { log::debug!("submit_basic_block"); - // TODO https://github.com/iotaledger/iota-sdk/issues/1741 - let issuer_id = issuer_id.into().unwrap_or(AccountId::null()); + let issuer_id = match issuer_id.into() { + Some(issuer_id) => Some(issuer_id), + None => self + .data() + .await + .accounts() + .next() + .map(|o| o.output.as_account().account_id_non_null(&o.output_id)), + } + .ok_or(crate::wallet::Error::NoAccountToIssueBlock)?; let block = self .client() diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 2301e96848..3b284b8580 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -13,6 +13,7 @@ use crate::{ unlock_condition::AddressUnlockCondition, AccountId, AccountOutput, OutputId, }, + payload::signed_transaction::{TransactionCapabilities, TransactionCapabilityFlag}, }, wallet::{ operations::transaction::{TransactionOptions, TransactionWithMetadata}, @@ -83,12 +84,17 @@ impl Wallet { // TODO https://github.com/iotaledger/iota-sdk/issues/1740 let issuance = self.client().get_issuance().await?; + // TODO remove when https://github.com/iotaledger/iota-sdk/issues/1744 is done + let mut capabilities = TransactionCapabilities::default(); + capabilities.add_capability(TransactionCapabilityFlag::BurnMana); + let transaction_options = TransactionOptions { context_inputs: Some(vec![ CommitmentContextInput::new(issuance.latest_commitment.id()).into(), BlockIssuanceCreditContextInput::new(account_id).into(), ]), custom_inputs: Some(vec![*output_id]), + capabilities: Some(capabilities), ..Default::default() }; diff --git a/sdk/src/wallet/operations/transaction/build_transaction.rs b/sdk/src/wallet/operations/transaction/build_transaction.rs index 34fb960422..362d910ce2 100644 --- a/sdk/src/wallet/operations/transaction/build_transaction.rs +++ b/sdk/src/wallet/operations/transaction/build_transaction.rs @@ -50,6 +50,10 @@ impl Wallet { if let Some(context_inputs) = options.context_inputs { builder = builder.with_context_inputs(context_inputs); } + + if let Some(capabilities) = options.capabilities { + builder = builder.add_capabilities(capabilities.capabilities_iter()); + } } 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 2e98c2e0d2..c19d15739f 100644 --- a/sdk/src/wallet/operations/transaction/options.rs +++ b/sdk/src/wallet/operations/transaction/options.rs @@ -6,7 +6,10 @@ use serde::{Deserialize, Serialize}; use crate::{ client::api::input_selection::Burn, types::block::{ - address::Address, context_input::ContextInput, output::OutputId, payload::tagged_data::TaggedDataPayload, + address::Address, + context_input::ContextInput, + output::OutputId, + payload::{signed_transaction::TransactionCapabilities, tagged_data::TaggedDataPayload}, }, }; @@ -30,6 +33,8 @@ pub struct TransactionOptions { pub note: Option, #[serde(default)] pub allow_micro_amount: bool, + #[serde(default)] + pub capabilities: Option, } #[allow(clippy::enum_variant_names)] diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 10af45e799..4fac367de0 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -1853,7 +1853,7 @@ fn restricted_account() { let restricted = Address::from(RestrictedAddress::new(account_address.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, restricted, None, None, None, None, None, None), + Basic(3_000_000, restricted, None, None, None, None, None, None), Account( 2_000_000, account_id_1,