From 7b28bb11d2dbd6c534e3533bb5545ed5d92ba1e3 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 14:03:20 +0200 Subject: [PATCH 1/7] fix: Remove unimplemented publish type --- .../src/transaction_builder/mod.rs | 16 +-- crates/iota-sdk-types/src/lib.rs | 2 + crates/iota-sdk-types/src/package_data.rs | 131 ++++++++++++++++++ .../src/builder/mod.rs | 85 ++++++------ crates/iota-transaction-builder/src/lib.rs | 14 +- .../src/publish_type.rs | 83 ----------- 6 files changed, 182 insertions(+), 149 deletions(-) create mode 100644 crates/iota-sdk-types/src/package_data.rs delete mode 100644 crates/iota-transaction-builder/src/publish_type.rs diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index c77500526..0c64fb6d4 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -7,8 +7,7 @@ use std::{ time::Duration, }; -use iota_transaction_builder::MovePackageData; -use iota_types::Input; +use iota_types::{Input, MovePackageData}; use crate::{ crypto::simple::SimpleKeypair, @@ -266,11 +265,10 @@ impl TransactionBuilder { ) -> Arc { self.write(|builder| { builder - .publish(MovePackageData { + .publish(MovePackageData::new( modules, - dependencies: dependencies.into_iter().map(|o| **o).collect(), - digest: None, - }) + dependencies.into_iter().map(|o| **o).collect(), + )) .upgrade_cap(upgrade_cap_name); }); self @@ -301,11 +299,7 @@ impl TransactionBuilder { .upgrade( **package, ticket, - MovePackageData { - modules, - dependencies: dependencies.into_iter().map(|o| **o).collect(), - digest: None, - }, + MovePackageData::new(modules, dependencies.into_iter().map(|o| **o).collect()), ) .name(name); }); diff --git a/crates/iota-sdk-types/src/lib.rs b/crates/iota-sdk-types/src/lib.rs index 9387e6479..7a6fcd33a 100644 --- a/crates/iota-sdk-types/src/lib.rs +++ b/crates/iota-sdk-types/src/lib.rs @@ -122,6 +122,7 @@ mod gas; pub mod iota_names; mod object; mod object_id; +mod package_data; mod transaction; mod type_tag; mod u256; @@ -159,6 +160,7 @@ pub use object::{ TypeOrigin, UpgradeInfo, Version, }; pub use object_id::ObjectId; +pub use package_data::MovePackageData; #[cfg(feature = "serde")] #[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))] pub(crate) use transaction::SignedTransactionWithIntentMessage; diff --git a/crates/iota-sdk-types/src/package_data.rs b/crates/iota-sdk-types/src/package_data.rs new file mode 100644 index 000000000..86852fe40 --- /dev/null +++ b/crates/iota-sdk-types/src/package_data.rs @@ -0,0 +1,131 @@ +// Copyright 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::{Digest, ObjectId}; + +/// Type corresponding to the output of `iota move build +/// --dump-bytecode-as-base64` +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct MovePackageData { + /// The package modules as a series of bytes + #[cfg_attr(feature = "serde", serde(with = "serialization::modules"))] + pub modules: Vec>, + /// The package dependencies, specified by their object IDs. + pub dependencies: Vec, + /// The package digest. + #[cfg_attr(feature = "serde", serde(with = "serialization::digest"))] + pub digest: Digest, +} + +impl MovePackageData { + #[cfg(feature = "hash")] + pub fn new(modules: Vec>, dependencies: Vec) -> Self { + use crate::hash::Hasher; + let mut components = dependencies + .iter() + .map(|o| o.into_inner()) + .chain(modules.iter().map(|module| { + let mut hasher = Hasher::new(); + hasher.update(module); + hasher.finalize().into_inner() + })) + .collect::>(); + + // Sort so the order of the modules and the order of the dependencies + // does not matter. + components.sort(); + + let mut hasher = Hasher::new(); + for c in components { + hasher.update(c); + } + + Self { + modules, + dependencies, + digest: Digest::from(hasher.finalize().into_inner()), + } + } +} + +#[cfg(feature = "serde")] +mod serialization { + use base64ct::Encoding; + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + use super::*; + + impl MovePackageData { + pub fn to_base64(&self) -> String { + base64ct::Base64::encode_string(&bcs::to_bytes(self).expect("bcs encoding failed")) + } + + pub fn from_base64(base64: &str) -> Result { + use serde::de::Error; + bcs::from_bytes(&base64ct::Base64::decode_vec(base64).map_err(bcs::Error::custom)?) + } + } + + pub mod modules { + use super::*; + + pub fn serialize( + value: &Vec>, + serializer: S, + ) -> Result { + value + .iter() + .map(|v| base64ct::Base64::encode_string(v)) + .collect::>() + .serialize(serializer) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result>, D::Error> + where + D: Deserializer<'de>, + { + let bcs = Vec::::deserialize(deserializer)?; + bcs.into_iter() + .map(|s| base64ct::Base64::decode_vec(&s).map_err(serde::de::Error::custom)) + .collect() + } + } + + pub mod digest { + use super::*; + + pub fn serialize(value: &Digest, serializer: S) -> Result { + value.as_bytes().serialize(serializer) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let bytes = Vec::::deserialize(deserializer)?; + Digest::from_bytes(bytes).map_err(|e| serde::de::Error::custom(format!("{e}"))) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + const PACKAGE: &str = r#"{"modules":["oRzrCwYAAAAKAQAIAggUAxw+BFoGBWBBB6EBwQEI4gJACqIDGgy8A5cBDdMEBgAKAQ0BEwEUAAIMAAABCAAAAAgAAQQEAAMDAgAACAABAAAJAgMAABACAwAAEgQDAAAMBQYAAAYHAQAAEQgBAAAFCQoAAQsACwACDg8BAQwCEw8BAQgDDwwNAAoOCgYJBgEHCAQAAQYIAAEDAQYIAQQHCAEDAwcIBAEIAAQDAwUHCAQDCAAFBwgEAgMHCAQBCAIBCAMBBggEAQUBCAECCQAFBkNvbmZpZwVGb3JnZQVTd29yZAlUeENvbnRleHQDVUlEDWNyZWF0ZV9jb25maWcMY3JlYXRlX3N3b3JkAmlkBGluaXQFbWFnaWMJbXlfbW9kdWxlA25ldwluZXdfc3dvcmQGb2JqZWN0D3B1YmxpY190cmFuc2ZlcgZzZW5kZXIIc3RyZW5ndGgOc3dvcmRfdHJhbnNmZXIOc3dvcmRzX2NyZWF0ZWQIdHJhbnNmZXIKdHhfY29udGV4dAV2YWx1ZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAgMHCAMJAxADAQICBwgDEgMCAgIHCAMVAwAAAAABCQoAEQgGAAAAAAAAAAASAQsALhELOAACAQEAAAEECwAQABQCAgEAAAEECwAQARQCAwEAAAEECwAQAhQCBAEAAAEOCgAQAhQGAQAAAAAAAAAWCwAPAhULAxEICwELAhIAAgUBAAABCAsDEQgLAAsBEgALAjgBAgYBAAABBAsACwE4AgIHAQAAAQULAREICwASAgIAAQACAQEA"],"dependencies":["0x0000000000000000000000000000000000000000000000000000000000000002","0x0000000000000000000000000000000000000000000000000000000000000001"],"digest":[246,127,102,77,186,19,68,12,161,181,56,248,210,0,91,211,245,251,165,152,0,197,250,135,171,37,177,240,133,76,122,124]}"#; + + #[test] + fn test_serialization() { + let package: MovePackageData = serde_json::from_str(PACKAGE).unwrap(); + let new_json = serde_json::to_string(&package).unwrap(); + assert_eq!(new_json, PACKAGE); + } + + #[test] + fn test_digest() { + let json_package: MovePackageData = serde_json::from_str(PACKAGE).unwrap(); + let package = MovePackageData::new(json_package.modules, json_package.dependencies); + assert_eq!(json_package.digest, package.digest); + } +} diff --git a/crates/iota-transaction-builder/src/builder/mod.rs b/crates/iota-transaction-builder/src/builder/mod.rs index 192cef8e6..ae1e2b226 100644 --- a/crates/iota-transaction-builder/src/builder/mod.rs +++ b/crates/iota-transaction-builder/src/builder/mod.rs @@ -15,8 +15,9 @@ use iota_graphql_client::{ query_types::{ObjectFilter, ObjectRef, TransactionMetadata}, }; use iota_types::{ - Address, GasPayment, Identifier, ObjectId, ObjectReference, Owner, ProgrammableTransaction, - StructTag, Transaction, TransactionEffects, TransactionExpiration, TransactionV1, TypeTag, + Address, GasPayment, Identifier, MovePackageData, ObjectId, ObjectReference, Owner, + ProgrammableTransaction, StructTag, Transaction, TransactionEffects, TransactionExpiration, + TransactionV1, TypeTag, }; use reqwest::Url; use serde::Serialize; @@ -29,7 +30,6 @@ use crate::{ ptb_arguments::PTBArgumentList, }, error::Error, - publish_type::PublishType, types::{MoveType, MoveTypes}, unresolved::{ Argument, Command, Input, InputId, InputKind, MakeMoveVector, MergeCoins, MoveCall, @@ -309,29 +309,6 @@ impl TransactionBuilder { self.data.get_named_result(name) } - /// Send IOTA to a recipient address. - pub fn send_iota( - &mut self, - recipient: Address, - amount: impl Into>, - ) -> &mut TransactionBuilder { - let rec_arg = self.pure(recipient); - let coin_arg = if let Some(amount) = amount.into() { - let amt_arg = self.apply_argument(amount); - self.command(Command::SplitCoins(SplitCoins { - coin: Argument::Gas, - amounts: vec![amt_arg], - })) - } else { - Argument::Gas - }; - self.command(Command::TransferObjects(TransferObjects { - objects: vec![coin_arg], - address: rec_arg, - })); - self.reset() - } - /// Begin building a move call. pub fn move_call( &mut self, @@ -350,18 +327,6 @@ impl TransactionBuilder { }) } - /// Publish a move package. - pub fn publish(&mut self, kind: impl Into) -> &mut TransactionBuilder { - let module = match kind.into() { - PublishType::Path(_path) => todo!("load the package from the path"), - PublishType::Compiled(m) => m, - }; - self.cmd_state_change(Publish { - modules: module.modules, - dependencies: module.dependencies, - }) - } - /// Transfer objects to a recipient address. pub fn transfer_objects( &mut self, @@ -377,6 +342,29 @@ impl TransactionBuilder { self.reset() } + /// Send IOTA to a recipient address. + pub fn send_iota( + &mut self, + recipient: Address, + amount: impl Into>, + ) -> &mut TransactionBuilder { + let rec_arg = self.pure(recipient); + let coin_arg = if let Some(amount) = amount.into() { + let amt_arg = self.apply_argument(amount); + self.command(Command::SplitCoins(SplitCoins { + coin: Argument::Gas, + amounts: vec![amt_arg], + })) + } else { + Argument::Gas + }; + self.command(Command::TransferObjects(TransferObjects { + objects: vec![coin_arg], + address: rec_arg, + })); + self.reset() + } + /// Transfer some coins to a recipient address. If multiple coins are /// provided then they will be merged. pub fn send_coins( @@ -448,21 +436,28 @@ impl TransactionBuilder { self.cmd_state_change(SplitCoins { coin, amounts }) } + /// Publish a move package. + pub fn publish( + &mut self, + package_data: MovePackageData, + ) -> &mut TransactionBuilder { + self.cmd_state_change(Publish { + modules: package_data.modules, + dependencies: package_data.dependencies, + }) + } + /// Upgrade a move package. pub fn upgrade( &mut self, package_id: ObjectId, upgrade_cap: U, - kind: impl Into, + package_data: MovePackageData, ) -> &mut TransactionBuilder { - let module = match kind.into() { - PublishType::Path(_path) => todo!("load the package from the path"), - PublishType::Compiled(m) => m, - }; let ticket = self.apply_argument(upgrade_cap); self.cmd_state_change(Upgrade { - modules: module.modules, - dependencies: module.dependencies, + modules: package_data.modules, + dependencies: package_data.dependencies, package: package_id, ticket, }) diff --git a/crates/iota-transaction-builder/src/lib.rs b/crates/iota-transaction-builder/src/lib.rs index ee8c385a5..98d3debd5 100644 --- a/crates/iota-transaction-builder/src/lib.rs +++ b/crates/iota-transaction-builder/src/lib.rs @@ -8,7 +8,6 @@ pub mod builder; pub mod error; -pub(crate) mod publish_type; pub mod types; #[allow(missing_docs)] pub mod unresolved; @@ -18,7 +17,6 @@ pub use self::{ TransactionBuilder, ptb_arguments::{PTBArgument, PTBArgumentList, Receiving, Shared, SharedMut, res}, }, - publish_type::MovePackageData, types::PureBytes, }; @@ -32,11 +30,11 @@ mod tests { pagination::PaginationFilter, }; use iota_types::{ - Address, Digest, ExecutionStatus, IdOperation, ObjectId, ObjectReference, ObjectType, - TransactionEffects, + Address, Digest, ExecutionStatus, IdOperation, MovePackageData, ObjectId, ObjectReference, + ObjectType, TransactionEffects, }; - use crate::{TransactionBuilder, error::Error, publish_type::MovePackageData, res}; + use crate::{TransactionBuilder, error::Error, res}; /// This is used to read the json file that contains the modules/deps/digest /// generated with iota move build --dump-bytecode-as-base64 on the @@ -331,11 +329,7 @@ mod tests { // we need this ticket to authorize the upgrade tx.move_call(Address::FRAMEWORK, "package", "authorize_upgrade") - .arguments(( - upgrade_cap.unwrap(), - 0u8, - updated_package.digest.as_ref().unwrap(), - )) + .arguments((upgrade_cap.unwrap(), 0u8, updated_package.digest)) .name("ticket"); // now we can upgrade the package let receipt = tx diff --git a/crates/iota-transaction-builder/src/publish_type.rs b/crates/iota-transaction-builder/src/publish_type.rs deleted file mode 100644 index 75638a4bf..000000000 --- a/crates/iota-transaction-builder/src/publish_type.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2025 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use std::{path::PathBuf, str::FromStr}; - -use base64ct::Encoding; -use iota_types::{Digest, ObjectId}; -use serde::{Deserialize, Deserializer}; - -#[derive(Debug)] -pub enum PublishType { - Path(PathBuf), - Compiled(MovePackageData), -} - -impl From<&str> for PublishType { - fn from(value: &str) -> Self { - Self::from(PathBuf::from(value)) - } -} - -impl From for PublishType { - fn from(value: String) -> Self { - Self::from(PathBuf::from(value)) - } -} - -impl From for PublishType { - fn from(value: PathBuf) -> Self { - Self::Path(value) - } -} - -impl From for PublishType { - fn from(value: MovePackageData) -> Self { - Self::Compiled(value) - } -} - -/// Type corresponding to the output of `iota move build -/// --dump-bytecode-as-base64` -#[derive(serde::Deserialize, Debug)] -pub struct MovePackageData { - /// The package modules as a series of bytes - #[serde(deserialize_with = "bcs_from_str")] - pub modules: Vec>, - /// The package dependencies, specified by their object IDs. - #[serde(deserialize_with = "deps_from_str")] - pub dependencies: Vec, - /// The package digest. - #[serde(deserialize_with = "deser_digest")] - pub digest: Option, -} - -fn bcs_from_str<'de, D>(deserializer: D) -> Result>, D::Error> -where - D: Deserializer<'de>, -{ - let bcs = Vec::::deserialize(deserializer)?; - bcs.into_iter() - .map(|s| base64ct::Base64::decode_vec(&s).map_err(serde::de::Error::custom)) - .collect() -} - -fn deps_from_str<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - let deps = Vec::::deserialize(deserializer)?; - deps.into_iter() - .map(|s| ObjectId::from_str(&s).map_err(serde::de::Error::custom)) - .collect() -} - -fn deser_digest<'de, D>(deserializer: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - let bytes = Vec::::deserialize(deserializer)?; - Digest::from_bytes(bytes) - .map(Some) - .map_err(|e| serde::de::Error::custom(format!("{e}"))) -} From 47d52a318ba8ffe6e36790825ef49f59ba3766d8 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 14:13:53 +0200 Subject: [PATCH 2/7] impl FFI type --- .../src/transaction_builder/mod.rs | 19 +++------- crates/iota-sdk-ffi/src/types/mod.rs | 1 + crates/iota-sdk-ffi/src/types/package_data.rs | 38 +++++++++++++++++++ 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 crates/iota-sdk-ffi/src/types/package_data.rs diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index 0c64fb6d4..2cddda2be 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -7,7 +7,7 @@ use std::{ time::Duration, }; -use iota_types::{Input, MovePackageData}; +use iota_types::Input; use crate::{ crypto::simple::SimpleKeypair, @@ -18,6 +18,7 @@ use crate::{ address::Address, graphql::DryRunResult, object::ObjectId, + package_data::MovePackageData, struct_tag::Identifier, transaction::{Argument, Transaction, TransactionEffects}, type_tag::TypeTag, @@ -259,16 +260,13 @@ impl TransactionBuilder { /// the package pub fn publish( self: Arc, - modules: Vec>, + package_data: &MovePackageData, dependencies: Vec>, upgrade_cap_name: String, ) -> Arc { self.write(|builder| { builder - .publish(MovePackageData::new( - modules, - dependencies.into_iter().map(|o| **o).collect(), - )) + .publish(package_data.0.clone()) .upgrade_cap(upgrade_cap_name); }); self @@ -288,19 +286,14 @@ impl TransactionBuilder { #[uniffi::method(default(name = None))] pub fn upgrade( self: Arc, - modules: Vec>, - dependencies: Vec>, + package_data: &MovePackageData, package: &ObjectId, ticket: &PTBArgument, name: Option, ) -> Arc { self.write(|builder| { builder - .upgrade( - **package, - ticket, - MovePackageData::new(modules, dependencies.into_iter().map(|o| **o).collect()), - ) + .upgrade(**package, ticket, package_data.0.clone()) .name(name); }); self diff --git a/crates/iota-sdk-ffi/src/types/mod.rs b/crates/iota-sdk-ffi/src/types/mod.rs index 5e7f31874..144515c62 100644 --- a/crates/iota-sdk-ffi/src/types/mod.rs +++ b/crates/iota-sdk-ffi/src/types/mod.rs @@ -14,6 +14,7 @@ pub mod gas; pub mod graphql; pub mod iota_names; pub mod object; +pub mod package_data; pub mod signature; pub mod struct_tag; pub mod transaction; diff --git a/crates/iota-sdk-ffi/src/types/package_data.rs b/crates/iota-sdk-ffi/src/types/package_data.rs new file mode 100644 index 000000000..ec5ea827e --- /dev/null +++ b/crates/iota-sdk-ffi/src/types/package_data.rs @@ -0,0 +1,38 @@ +// Copyright (c) 2025 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::sync::Arc; + +use crate::{error::Result, types::object::ObjectId}; + +#[derive(derive_more::From, uniffi::Object)] +pub struct MovePackageData(pub iota_types::MovePackageData); + +#[uniffi::export] +impl MovePackageData { + #[uniffi::constructor] + pub fn new(modules: Vec>, dependencies: Vec>) -> Self { + Self(iota_types::MovePackageData::new( + modules, + dependencies.into_iter().map(|o| **o).collect(), + )) + } + + pub fn to_base64(&self) -> String { + self.0.to_base64() + } + + #[uniffi::constructor] + pub fn from_base64(base64: &str) -> Result { + Ok(Self(iota_types::MovePackageData::from_base64(base64)?)) + } + + pub fn to_json(&self) -> String { + serde_json::to_string(&self.0).expect("failed to serialize move package data") + } + + #[uniffi::constructor] + pub fn from_json(json: &str) -> Result { + Ok(Self(serde_json::from_str(json)?)) + } +} From 9181f5bf8d19a56c872fa837665c50b55c9ed4e8 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 14:32:11 +0200 Subject: [PATCH 3/7] add upgrade policy --- bindings/go/iota_sdk_ffi/iota_sdk_ffi.go | 298 +++++- bindings/go/iota_sdk_ffi/iota_sdk_ffi.h | 126 ++- bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt | 894 +++++++++++++++--- bindings/python/lib/iota_sdk_ffi.py | 326 ++++++- .../src/transaction_builder/mod.rs | 2 +- crates/iota-sdk-ffi/src/types/mod.rs | 2 +- .../{package_data.rs => move_package.rs} | 25 + crates/iota-sdk-types/Cargo.toml | 1 + crates/iota-sdk-types/src/lib.rs | 4 +- .../src/{package_data.rs => move_package.rs} | 34 + crates/iota-transaction-builder/src/lib.rs | 8 +- 11 files changed, 1561 insertions(+), 159 deletions(-) rename crates/iota-sdk-ffi/src/types/{package_data.rs => move_package.rs} (65%) rename crates/iota-sdk-types/src/{package_data.rs => move_package.rs} (84%) diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index deede89aa..ef4963bc2 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -1898,6 +1898,24 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64() + }) + if checksum != 1835 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json() + }) + if checksum != 3153 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap() }) @@ -3728,7 +3746,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() }) - if checksum != 46833 { + if checksum != 30595 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish: UniFFI API checksum mismatch") } @@ -3782,7 +3800,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() }) - if checksum != 34068 { + if checksum != 3616 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade: UniFFI API checksum mismatch") } @@ -4085,6 +4103,15 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8() + }) + if checksum != 30703 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig() }) @@ -5633,6 +5660,33 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64() + }) + if checksum != 61420 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json() + }) + if checksum != 13174 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new() + }) + if checksum != 65225 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new() }) @@ -6848,6 +6902,33 @@ func uniffiCheckChecksums() { } } { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive() + }) + if checksum != 4357 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible() + }) + if checksum != 62706 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only() + }) + if checksum != 53392 { + // If this happens try cleaning and rebuilding your project + panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only: UniFFI API checksum mismatch") + } + } + { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64() }) @@ -15293,6 +15374,119 @@ func (_ FfiDestroyerMovePackage) Destroy(value *MovePackage) { +type MovePackageDataInterface interface { + ToBase64() string + ToJson() string +} +type MovePackageData struct { + ffiObject FfiObject +} +func NewMovePackageData(modules [][]byte, dependencies []*ObjectId) *MovePackageData { + return FfiConverterMovePackageDataINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new(FfiConverterSequenceBytesINSTANCE.Lower(modules), FfiConverterSequenceObjectIdINSTANCE.Lower(dependencies),_uniffiStatus) + })) +} + + +func MovePackageDataFromBase64(base64 string) (*MovePackageData, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64(FfiConverterStringINSTANCE.Lower(base64),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MovePackageData + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMovePackageDataINSTANCE.Lift(_uniffiRV), nil + } +} + +func MovePackageDataFromJson(json string) (*MovePackageData, error) { + _uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json(FfiConverterStringINSTANCE.Lower(json),_uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MovePackageData + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMovePackageDataINSTANCE.Lift(_uniffiRV), nil + } +} + + + +func (_self *MovePackageData) ToBase64() string { + _pointer := _self.ffiObject.incrementPointer("*MovePackageData") + defer _self.ffiObject.decrementPointer() + return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64( + _pointer,_uniffiStatus), + } + })) +} + +func (_self *MovePackageData) ToJson() string { + _pointer := _self.ffiObject.incrementPointer("*MovePackageData") + defer _self.ffiObject.decrementPointer() + return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer { + inner: C.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json( + _pointer,_uniffiStatus), + } + })) +} +func (object *MovePackageData) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterMovePackageData struct {} + +var FfiConverterMovePackageDataINSTANCE = FfiConverterMovePackageData{} + + +func (c FfiConverterMovePackageData) Lift(pointer unsafe.Pointer) *MovePackageData { + result := &MovePackageData { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_movepackagedata(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_movepackagedata(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*MovePackageData).Destroy) + return result +} + +func (c FfiConverterMovePackageData) Read(reader io.Reader) *MovePackageData { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterMovePackageData) Lower(value *MovePackageData) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*MovePackageData") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterMovePackageData) Write(writer io.Writer, value *MovePackageData) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerMovePackageData struct {} + +func (_ FfiDestroyerMovePackageData) Destroy(value *MovePackageData) { + value.Destroy() +} + + + // Aggregated signature from members of a multisig committee. // // # BCS @@ -21855,7 +22049,7 @@ type TransactionBuilderInterface interface { // - `modules`: is the modules' bytecode to be published // - `dependencies`: is the list of IDs of the transitive dependencies of // the package - Publish(modules [][]byte, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder + Publish(packageData *MovePackageData, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder // Transfer some coins to a recipient address. If multiple coins are // provided then they will be merged. SendCoins(coins []*PtbArgument, recipient *Address, amount **PtbArgument) *TransactionBuilder @@ -21879,7 +22073,7 @@ type TransactionBuilderInterface interface { // To get the ticket, you have to call the // `0x2::package::authorize_upgrade` function, and pass the package // ID, the upgrade policy, and package digest. - Upgrade(modules [][]byte, dependencies []*ObjectId, varPackage *ObjectId, ticket *PtbArgument, name *string) *TransactionBuilder + Upgrade(packageData *MovePackageData, varPackage *ObjectId, ticket *PtbArgument, name *string) *TransactionBuilder } // A builder for creating transactions. Use [`finish`](Self::finish) to // finalize the transaction data. @@ -22137,12 +22331,12 @@ func (_self *TransactionBuilder) MoveCall(varPackage *Address, module *Identifie // - `modules`: is the modules' bytecode to be published // - `dependencies`: is the list of IDs of the transitive dependencies of // the package -func (_self *TransactionBuilder) Publish(modules [][]byte, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder { +func (_self *TransactionBuilder) Publish(packageData *MovePackageData, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() return FfiConverterTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish( - _pointer,FfiConverterSequenceBytesINSTANCE.Lower(modules), FfiConverterSequenceObjectIdINSTANCE.Lower(dependencies), FfiConverterStringINSTANCE.Lower(upgradeCapName),_uniffiStatus) + _pointer,FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterSequenceObjectIdINSTANCE.Lower(dependencies), FfiConverterStringINSTANCE.Lower(upgradeCapName),_uniffiStatus) })) } @@ -22209,12 +22403,12 @@ func (_self *TransactionBuilder) TransferObjects(recipient *Address, objects []* // To get the ticket, you have to call the // `0x2::package::authorize_upgrade` function, and pass the package // ID, the upgrade policy, and package digest. -func (_self *TransactionBuilder) Upgrade(modules [][]byte, dependencies []*ObjectId, varPackage *ObjectId, ticket *PtbArgument, name *string) *TransactionBuilder { +func (_self *TransactionBuilder) Upgrade(packageData *MovePackageData, varPackage *ObjectId, ticket *PtbArgument, name *string) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() return FfiConverterTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade( - _pointer,FfiConverterSequenceBytesINSTANCE.Lower(modules), FfiConverterSequenceObjectIdINSTANCE.Lower(dependencies), FfiConverterObjectIdINSTANCE.Lower(varPackage), FfiConverterPtbArgumentINSTANCE.Lower(ticket), FfiConverterOptionalStringINSTANCE.Lower(name),_uniffiStatus) + _pointer,FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterObjectIdINSTANCE.Lower(varPackage), FfiConverterPtbArgumentINSTANCE.Lower(ticket), FfiConverterOptionalStringINSTANCE.Lower(name),_uniffiStatus) })) } func (object *TransactionBuilder) Destroy() { @@ -23398,6 +23592,94 @@ func (_ FfiDestroyerUpgrade) Destroy(value *Upgrade) { +type UpgradePolicyInterface interface { + AsU8() uint8 +} +type UpgradePolicy struct { + ffiObject FfiObject +} + + +func UpgradePolicyAdditive() *UpgradePolicy { + return FfiConverterUpgradePolicyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive(_uniffiStatus) + })) +} + +func UpgradePolicyCompatible() *UpgradePolicy { + return FfiConverterUpgradePolicyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible(_uniffiStatus) + })) +} + +func UpgradePolicyDepOnly() *UpgradePolicy { + return FfiConverterUpgradePolicyINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only(_uniffiStatus) + })) +} + + + +func (_self *UpgradePolicy) AsU8() uint8 { + _pointer := _self.ffiObject.incrementPointer("*UpgradePolicy") + defer _self.ffiObject.decrementPointer() + return FfiConverterUint8INSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint8_t { + return C.uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8( + _pointer,_uniffiStatus) + })) +} +func (object *UpgradePolicy) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterUpgradePolicy struct {} + +var FfiConverterUpgradePolicyINSTANCE = FfiConverterUpgradePolicy{} + + +func (c FfiConverterUpgradePolicy) Lift(pointer unsafe.Pointer) *UpgradePolicy { + result := &UpgradePolicy { + newFfiObject( + pointer, + func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { + return C.uniffi_iota_sdk_ffi_fn_clone_upgradepolicy(pointer, status) + }, + func(pointer unsafe.Pointer, status *C.RustCallStatus) { + C.uniffi_iota_sdk_ffi_fn_free_upgradepolicy(pointer, status) + }, + ), + } + runtime.SetFinalizer(result, (*UpgradePolicy).Destroy) + return result +} + +func (c FfiConverterUpgradePolicy) Read(reader io.Reader) *UpgradePolicy { + return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) +} + +func (c FfiConverterUpgradePolicy) Lower(value *UpgradePolicy) unsafe.Pointer { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the pointer will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked pointer. + pointer := value.ffiObject.incrementPointer("*UpgradePolicy") + defer value.ffiObject.decrementPointer() + return pointer + +} + +func (c FfiConverterUpgradePolicy) Write(writer io.Writer, value *UpgradePolicy) { + writeUint64(writer, uint64(uintptr(c.Lower(value)))) +} + +type FfiDestroyerUpgradePolicy struct {} + +func (_ FfiDestroyerUpgradePolicy) Destroy(value *UpgradePolicy) { + value.Destroy() +} + + + // A signature from a user // // A `UserSignature` is most commonly used to authorize the execution and diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index c3a4c7792..c8771d10f 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -2250,6 +2250,41 @@ RustBuffer uniffi_iota_sdk_ffi_fn_method_movepackage_type_origin_table(void* ptr uint64_t uniffi_iota_sdk_ffi_fn_method_movepackage_version(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_MOVEPACKAGEDATA +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_MOVEPACKAGEDATA +void* uniffi_iota_sdk_ffi_fn_clone_movepackagedata(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_MOVEPACKAGEDATA +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_MOVEPACKAGEDATA +void uniffi_iota_sdk_ffi_fn_free_movepackagedata(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_BASE64 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_BASE64 +void* uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64(RustBuffer base64, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_JSON +void* uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json(RustBuffer json, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_MOVEPACKAGEDATA_NEW +void* uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new(RustBuffer modules, RustBuffer dependencies, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_MOVEPACKAGEDATA_TO_BASE64 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_MOVEPACKAGEDATA_TO_BASE64 +RustBuffer uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_MOVEPACKAGEDATA_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_MOVEPACKAGEDATA_TO_JSON +RustBuffer uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json(void* ptr, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_MULTISIGAGGREGATEDSIGNATURE #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_MULTISIGAGGREGATEDSIGNATURE void* uniffi_iota_sdk_ffi_fn_clone_multisigaggregatedsignature(void* ptr, RustCallStatus *out_status @@ -4271,7 +4306,7 @@ void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_move_call(void* ptr, void #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_PUBLISH #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_PUBLISH -void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(void* ptr, RustBuffer modules, RustBuffer dependencies, RustBuffer upgrade_cap_name, RustCallStatus *out_status +void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(void* ptr, void* package_data, RustBuffer dependencies, RustBuffer upgrade_cap_name, RustCallStatus *out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_SEND_COINS @@ -4301,7 +4336,7 @@ void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_transfer_objects(void* pt #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_UPGRADE #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_UPGRADE -void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(void* ptr, RustBuffer modules, RustBuffer dependencies, void* package, void* ticket, RustBuffer name, RustCallStatus *out_status +void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(void* ptr, void* package_data, void* package, void* ticket, RustBuffer name, RustCallStatus *out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_TRANSACTIONEFFECTS @@ -4663,6 +4698,39 @@ void* uniffi_iota_sdk_ffi_fn_method_upgrade_package(void* ptr, RustCallStatus *o void* uniffi_iota_sdk_ffi_fn_method_upgrade_ticket(void* ptr, RustCallStatus *out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_UPGRADEPOLICY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_UPGRADEPOLICY +void* uniffi_iota_sdk_ffi_fn_clone_upgradepolicy(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_UPGRADEPOLICY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_FREE_UPGRADEPOLICY +void uniffi_iota_sdk_ffi_fn_free_upgradepolicy(void* ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_ADDITIVE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_ADDITIVE +void* uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_COMPATIBLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_COMPATIBLE +void* uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_DEP_ONLY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_UPGRADEPOLICY_DEP_ONLY +void* uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_UPGRADEPOLICY_AS_U8 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_UPGRADEPOLICY_AS_U8 +uint8_t uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8(void* ptr, RustCallStatus *out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_USERSIGNATURE #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_USERSIGNATURE void* uniffi_iota_sdk_ffi_fn_clone_usersignature(void* ptr, RustCallStatus *out_status @@ -6495,6 +6563,18 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_movepackage_type_origin_table(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MOVEPACKAGE_VERSION uint16_t uniffi_iota_sdk_ffi_checksum_method_movepackage_version(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MOVEPACKAGEDATA_TO_BASE64 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MOVEPACKAGEDATA_TO_BASE64 +uint16_t uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MOVEPACKAGEDATA_TO_JSON +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MOVEPACKAGEDATA_TO_JSON +uint16_t uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_MULTISIGAGGREGATEDSIGNATURE_BITMAP @@ -7953,6 +8033,12 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_upgrade_package(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_UPGRADE_TICKET uint16_t uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_UPGRADEPOLICY_AS_U8 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_UPGRADEPOLICY_AS_U8 +uint16_t uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_USERSIGNATURE_AS_MULTISIG @@ -8985,6 +9071,24 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_movecall_new(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGE_NEW uint16_t uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_BASE64 +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_BASE64 +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_JSON +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_FROM_JSON +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_NEW +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MOVEPACKAGEDATA_NEW +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_MULTISIGAGGREGATEDSIGNATURE_NEW @@ -9795,6 +9899,24 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_typetag_new_vector(void #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADE_NEW uint16_t uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_ADDITIVE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_ADDITIVE +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_COMPATIBLE +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_COMPATIBLE +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_DEP_ONLY +#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_UPGRADEPOLICY_DEP_ONLY +uint16_t uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_USERSIGNATURE_FROM_BASE64 diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 064d7a15c..4128adc9a 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -2389,6 +2389,28 @@ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback { + + + + + + + + + + + + + + + + + + + + + + @@ -2767,6 +2789,10 @@ fun uniffi_iota_sdk_ffi_checksum_method_movepackage_type_origin_table( ): Short fun uniffi_iota_sdk_ffi_checksum_method_movepackage_version( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64( +): Short +fun uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json( +): Short fun uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap( ): Short fun uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_committee( @@ -3253,6 +3279,8 @@ fun uniffi_iota_sdk_ffi_checksum_method_upgrade_package( ): Short fun uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket( ): Short +fun uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8( +): Short fun uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig( ): Short fun uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig_opt( @@ -3597,6 +3625,12 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_movecall_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregator_new_with_message( @@ -3867,6 +3901,12 @@ fun uniffi_iota_sdk_ffi_checksum_constructor_typetag_new_vector( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new( ): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible( +): Short +fun uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only( +): Short fun uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64( ): Short fun uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_bytes( @@ -4692,6 +4732,20 @@ fun uniffi_iota_sdk_ffi_fn_method_movepackage_type_origin_table(`ptr`: Pointer,u ): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_method_movepackage_version(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Long +fun uniffi_iota_sdk_ffi_fn_clone_movepackagedata(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_movepackagedata(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64(`base64`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json(`json`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new(`modules`: RustBuffer.ByValue,`dependencies`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue +fun uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): RustBuffer.ByValue fun uniffi_iota_sdk_ffi_fn_clone_multisigaggregatedsignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_multisigaggregatedsignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -5492,7 +5546,7 @@ fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_merge_coins(`ptr`: Pointer, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_move_call(`ptr`: Pointer,`package`: Pointer,`module`: Pointer,`function`: Pointer,`arguments`: RustBuffer.ByValue,`typeArgs`: RustBuffer.ByValue,`names`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(`ptr`: Pointer,`modules`: RustBuffer.ByValue,`dependencies`: RustBuffer.ByValue,`upgradeCapName`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(`ptr`: Pointer,`packageData`: Pointer,`dependencies`: RustBuffer.ByValue,`upgradeCapName`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_send_coins(`ptr`: Pointer,`coins`: RustBuffer.ByValue,`recipient`: Pointer,`amount`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -5504,7 +5558,7 @@ fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_sponsor(`ptr`: Pointer,`spo ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_transfer_objects(`ptr`: Pointer,`recipient`: Pointer,`objects`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(`ptr`: Pointer,`modules`: RustBuffer.ByValue,`dependencies`: RustBuffer.ByValue,`package`: Pointer,`ticket`: Pointer,`name`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade(`ptr`: Pointer,`packageData`: Pointer,`package`: Pointer,`ticket`: Pointer,`name`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_clone_transactioneffects(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -5646,6 +5700,18 @@ fun uniffi_iota_sdk_ffi_fn_method_upgrade_package(`ptr`: Pointer,uniffi_out_err: ): Pointer fun uniffi_iota_sdk_ffi_fn_method_upgrade_ticket(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_iota_sdk_ffi_fn_clone_upgradepolicy(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_free_upgradepolicy(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Unit +fun uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only(uniffi_out_err: UniffiRustCallStatus, +): Pointer +fun uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, +): Byte fun uniffi_iota_sdk_ffi_fn_clone_usersignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_free_usersignature(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus, @@ -6495,6 +6561,12 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_movepackage_version() != 22970.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64() != 1835.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json() != 3153.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap() != 41489.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -7104,7 +7176,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_move_call() != 22281.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 46833.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 30595.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_coins() != 434.toShort()) { @@ -7122,7 +7194,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_transfer_objects() != 16313.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 34068.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 3616.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1() != 48710.toShort()) { @@ -7224,6 +7296,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket() != 11416.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8() != 30703.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig() != 36332.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -7740,6 +7815,15 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new() != 17506.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64() != 61420.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json() != 13174.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new() != 65225.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new() != 3396.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -8145,6 +8229,15 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new() != 61663.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive() != 4357.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible() != 62706.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only() != 53392.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64() != 8029.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -24154,79 +24247,16 @@ public object FfiConverterTypeMovePackage: FfiConverter { // -/** - * Aggregated signature from members of a multisig committee. - * - * # BCS - * - * The BCS serialized form for this type is defined by the following ABNF: - * - * ```text - * multisig-aggregated-signature = (vector multisig-member-signature) - * u16 ; bitmap - * multisig-committee - * ``` - * - * There is also a legacy encoding for this type defined as: - * - * ```text - * legacy-multisig-aggregated-signature = (vector multisig-member-signature) - * roaring-bitmap ; bitmap - * legacy-multisig-committee - * roaring-bitmap = bytes ; where the contents of the bytes are valid - * ; according to the serialized spec for - * ; roaring bitmaps - * ``` - * - * See [here](https://github.com/RoaringBitmap/RoaringFormatSpec) for the specification for the - * serialized format of RoaringBitmaps. - */ -public interface MultisigAggregatedSignatureInterface { +public interface MovePackageDataInterface { - /** - * The bitmap that indicates which committee members provided their - * signature. - */ - fun `bitmap`(): kotlin.UShort - - fun `committee`(): MultisigCommittee + fun `toBase64`(): kotlin.String - /** - * The list of signatures from committee members - */ - fun `signatures`(): List + fun `toJson`(): kotlin.String companion object } -/** - * Aggregated signature from members of a multisig committee. - * - * # BCS - * - * The BCS serialized form for this type is defined by the following ABNF: - * - * ```text - * multisig-aggregated-signature = (vector multisig-member-signature) - * u16 ; bitmap - * multisig-committee - * ``` - * - * There is also a legacy encoding for this type defined as: - * - * ```text - * legacy-multisig-aggregated-signature = (vector multisig-member-signature) - * roaring-bitmap ; bitmap - * legacy-multisig-committee - * roaring-bitmap = bytes ; where the contents of the bytes are valid - * ; according to the serialized spec for - * ; roaring bitmaps - * ``` - * - * See [here](https://github.com/RoaringBitmap/RoaringFormatSpec) for the specification for the - * serialized format of RoaringBitmaps. - */ -open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggregatedSignatureInterface +open class MovePackageData: Disposable, AutoCloseable, MovePackageDataInterface { constructor(pointer: Pointer) { @@ -24244,20 +24274,11 @@ open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggre this.pointer = null this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) } - /** - * Construct a new aggregated multisig signature. - * - * Since the list of signatures doesn't contain sufficient information to - * identify which committee member provided the signature, it is up to - * the caller to ensure that the provided signature list is in the same - * order as it's corresponding member in the provided committee - * and that it's position in the provided bitmap is set. - */ - constructor(`committee`: MultisigCommittee, `signatures`: List, `bitmap`: kotlin.UShort) : + constructor(`modules`: List, `dependencies`: List) : this( uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_multisigaggregatedsignature_new( - FfiConverterTypeMultisigCommittee.lower(`committee`),FfiConverterSequenceTypeMultisigMemberSignature.lower(`signatures`),FfiConverterUShort.lower(`bitmap`),_status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new( + FfiConverterSequenceByteArray.lower(`modules`),FfiConverterSequenceTypeObjectId.lower(`dependencies`),_status) } ) @@ -24312,7 +24333,7 @@ open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggre override fun run() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_multisigaggregatedsignature(ptr, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_movepackagedata(ptr, status) } } } @@ -24320,19 +24341,15 @@ open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggre fun uniffiClonePointer(): Pointer { return uniffiRustCall() { status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigaggregatedsignature(pointer!!, status) + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_movepackagedata(pointer!!, status) } } - - /** - * The bitmap that indicates which committee members provided their - * signature. - */override fun `bitmap`(): kotlin.UShort { - return FfiConverterUShort.lift( + override fun `toBase64`(): kotlin.String { + return FfiConverterString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_bitmap( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64( it, _status) } } @@ -24340,11 +24357,11 @@ open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggre } - override fun `committee`(): MultisigCommittee { - return FfiConverterTypeMultisigCommittee.lift( + override fun `toJson`(): kotlin.String { + return FfiConverterString.lift( callWithPointer { uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_committee( + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json( it, _status) } } @@ -24353,50 +24370,58 @@ open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggre - /** - * The list of signatures from committee members - */override fun `signatures`(): List { - return FfiConverterSequenceTypeMultisigMemberSignature.lift( - callWithPointer { - uniffiRustCall() { _status -> - UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_signatures( - it, _status) + + + companion object { + + @Throws(SdkFfiException::class) fun `fromBase64`(`base64`: kotlin.String): MovePackageData { + return FfiConverterTypeMovePackageData.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64( + FfiConverterString.lower(`base64`),_status) } - } ) } + + @Throws(SdkFfiException::class) fun `fromJson`(`json`: kotlin.String): MovePackageData { + return FfiConverterTypeMovePackageData.lift( + uniffiRustCallWithError(SdkFfiException) { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json( + FfiConverterString.lower(`json`),_status) +} + ) + } - - - companion object + + } } /** * @suppress */ -public object FfiConverterTypeMultisigAggregatedSignature: FfiConverter { +public object FfiConverterTypeMovePackageData: FfiConverter { - override fun lower(value: MultisigAggregatedSignature): Pointer { + override fun lower(value: MovePackageData): Pointer { return value.uniffiClonePointer() } - override fun lift(value: Pointer): MultisigAggregatedSignature { - return MultisigAggregatedSignature(value) + override fun lift(value: Pointer): MovePackageData { + return MovePackageData(value) } - override fun read(buf: ByteBuffer): MultisigAggregatedSignature { + override fun read(buf: ByteBuffer): MovePackageData { // The Rust code always writes pointers as 8 bytes, and will // fail to compile if they don't fit. return lift(Pointer(buf.getLong())) } - override fun allocationSize(value: MultisigAggregatedSignature) = 8UL + override fun allocationSize(value: MovePackageData) = 8UL - override fun write(value: MultisigAggregatedSignature, buf: ByteBuffer) { + override fun write(value: MovePackageData, buf: ByteBuffer) { // The Rust code always expects pointers written as 8 bytes, // and will fail to compile if they don't fit. buf.putLong(Pointer.nativeValue(lower(value))) @@ -24502,20 +24527,368 @@ public object FfiConverterTypeMultisigAggregatedSignature: FfiConverter companion object } -open class MultisigAggregator: Disposable, AutoCloseable, MultisigAggregatorInterface +/** + * Aggregated signature from members of a multisig committee. + * + * # BCS + * + * The BCS serialized form for this type is defined by the following ABNF: + * + * ```text + * multisig-aggregated-signature = (vector multisig-member-signature) + * u16 ; bitmap + * multisig-committee + * ``` + * + * There is also a legacy encoding for this type defined as: + * + * ```text + * legacy-multisig-aggregated-signature = (vector multisig-member-signature) + * roaring-bitmap ; bitmap + * legacy-multisig-committee + * roaring-bitmap = bytes ; where the contents of the bytes are valid + * ; according to the serialized spec for + * ; roaring bitmaps + * ``` + * + * See [here](https://github.com/RoaringBitmap/RoaringFormatSpec) for the specification for the + * serialized format of RoaringBitmaps. + */ +open class MultisigAggregatedSignature: Disposable, AutoCloseable, MultisigAggregatedSignatureInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + /** + * Construct a new aggregated multisig signature. + * + * Since the list of signatures doesn't contain sufficient information to + * identify which committee member provided the signature, it is up to + * the caller to ensure that the provided signature list is in the same + * order as it's corresponding member in the provided committee + * and that it's position in the provided bitmap is set. + */ + constructor(`committee`: MultisigCommittee, `signatures`: List, `bitmap`: kotlin.UShort) : + this( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_multisigaggregatedsignature_new( + FfiConverterTypeMultisigCommittee.lower(`committee`),FfiConverterSequenceTypeMultisigMemberSignature.lower(`signatures`),FfiConverterUShort.lower(`bitmap`),_status) +} + ) + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_multisigaggregatedsignature(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_multisigaggregatedsignature(pointer!!, status) + } + } + + + /** + * The bitmap that indicates which committee members provided their + * signature. + */override fun `bitmap`(): kotlin.UShort { + return FfiConverterUShort.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_bitmap( + it, _status) +} + } + ) + } + + + override fun `committee`(): MultisigCommittee { + return FfiConverterTypeMultisigCommittee.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_committee( + it, _status) +} + } + ) + } + + + + /** + * The list of signatures from committee members + */override fun `signatures`(): List { + return FfiConverterSequenceTypeMultisigMemberSignature.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_multisigaggregatedsignature_signatures( + it, _status) +} + } + ) + } + + + + + + + companion object + +} + +/** + * @suppress + */ +public object FfiConverterTypeMultisigAggregatedSignature: FfiConverter { + + override fun lower(value: MultisigAggregatedSignature): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): MultisigAggregatedSignature { + return MultisigAggregatedSignature(value) + } + + override fun read(buf: ByteBuffer): MultisigAggregatedSignature { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: MultisigAggregatedSignature) = 8UL + + override fun write(value: MultisigAggregatedSignature, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + +public interface MultisigAggregatorInterface { + + fun `finish`(): MultisigAggregatedSignature + + fun `verifier`(): MultisigVerifier + + fun `withSignature`(`signature`: UserSignature): MultisigAggregator + + fun `withVerifier`(`verifier`: MultisigVerifier): MultisigAggregator + + companion object +} + +open class MultisigAggregator: Disposable, AutoCloseable, MultisigAggregatorInterface { constructor(pointer: Pointer) { @@ -38157,7 +38530,7 @@ public interface TransactionBuilderInterface { * - `dependencies`: is the list of IDs of the transitive dependencies of * the package */ - fun `publish`(`modules`: List, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder + fun `publish`(`packageData`: MovePackageData, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder /** * Transfer some coins to a recipient address. If multiple coins are @@ -38199,7 +38572,7 @@ public interface TransactionBuilderInterface { * `0x2::package::authorize_upgrade` function, and pass the package * ID, the upgrade policy, and package digest. */ - fun `upgrade`(`modules`: List, `dependencies`: List, `package`: ObjectId, `ticket`: PtbArgument, `name`: kotlin.String? = null): TransactionBuilder + fun `upgrade`(`packageData`: MovePackageData, `package`: ObjectId, `ticket`: PtbArgument, `name`: kotlin.String? = null): TransactionBuilder companion object } @@ -38522,12 +38895,12 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte * - `modules`: is the modules' bytecode to be published * - `dependencies`: is the list of IDs of the transitive dependencies of * the package - */override fun `publish`(`modules`: List, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder { + */override fun `publish`(`packageData`: MovePackageData, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder { return FfiConverterTypeTransactionBuilder.lift( callWithPointer { uniffiRustCall() { _status -> UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish( - it, FfiConverterSequenceByteArray.lower(`modules`),FfiConverterSequenceTypeObjectId.lower(`dependencies`),FfiConverterString.lower(`upgradeCapName`),_status) + it, FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterSequenceTypeObjectId.lower(`dependencies`),FfiConverterString.lower(`upgradeCapName`),_status) } } ) @@ -38624,12 +38997,12 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte * To get the ticket, you have to call the * `0x2::package::authorize_upgrade` function, and pass the package * ID, the upgrade policy, and package digest. - */override fun `upgrade`(`modules`: List, `dependencies`: List, `package`: ObjectId, `ticket`: PtbArgument, `name`: kotlin.String?): TransactionBuilder { + */override fun `upgrade`(`packageData`: MovePackageData, `package`: ObjectId, `ticket`: PtbArgument, `name`: kotlin.String?): TransactionBuilder { return FfiConverterTypeTransactionBuilder.lift( callWithPointer { uniffiRustCall() { _status -> UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade( - it, FfiConverterSequenceByteArray.lower(`modules`),FfiConverterSequenceTypeObjectId.lower(`dependencies`),FfiConverterTypeObjectId.lower(`package`),FfiConverterTypePTBArgument.lower(`ticket`),FfiConverterOptionalString.lower(`name`),_status) + it, FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterTypeObjectId.lower(`package`),FfiConverterTypePTBArgument.lower(`ticket`),FfiConverterOptionalString.lower(`name`),_status) } } ) @@ -41291,6 +41664,273 @@ public object FfiConverterTypeUpgrade: FfiConverter { // +public interface UpgradePolicyInterface { + + fun `asU8`(): kotlin.UByte + + companion object +} + +open class UpgradePolicy: Disposable, AutoCloseable, UpgradePolicyInterface +{ + + constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + @Suppress("UNUSED_PARAMETER") + constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(pointer)) + } + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed = AtomicBoolean(false) + private val callCounter = AtomicLong(1) + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + @Synchronized + override fun close() { + this.destroy() + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.get() + if (c == 0L) { + throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiCleanAction(private val pointer: Pointer?) : Runnable { + override fun run() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_free_upgradepolicy(ptr, status) + } + } + } + } + + fun uniffiClonePointer(): Pointer { + return uniffiRustCall() { status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_clone_upgradepolicy(pointer!!, status) + } + } + + override fun `asU8`(): kotlin.UByte { + return FfiConverterUByte.lift( + callWithPointer { + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8( + it, _status) +} + } + ) + } + + + + + + companion object { + fun `additive`(): UpgradePolicy { + return FfiConverterTypeUpgradePolicy.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive( + _status) +} + ) + } + + + fun `compatible`(): UpgradePolicy { + return FfiConverterTypeUpgradePolicy.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible( + _status) +} + ) + } + + + fun `depOnly`(): UpgradePolicy { + return FfiConverterTypeUpgradePolicy.lift( + uniffiRustCall() { _status -> + UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only( + _status) +} + ) + } + + + + } + +} + +/** + * @suppress + */ +public object FfiConverterTypeUpgradePolicy: FfiConverter { + + override fun lower(value: UpgradePolicy): Pointer { + return value.uniffiClonePointer() + } + + override fun lift(value: Pointer): UpgradePolicy { + return UpgradePolicy(value) + } + + override fun read(buf: ByteBuffer): UpgradePolicy { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(Pointer(buf.getLong())) + } + + override fun allocationSize(value: UpgradePolicy) = 8UL + + override fun write(value: UpgradePolicy, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(Pointer.nativeValue(lower(value))) + } +} + + +// This template implements a class for working with a Rust struct via a Pointer/Arc +// to the live Rust struct on the other side of the FFI. +// +// Each instance implements core operations for working with the Rust `Arc` and the +// Kotlin Pointer to work with the live Rust struct on the other side of the FFI. +// +// There's some subtlety here, because we have to be careful not to operate on a Rust +// struct after it has been dropped, and because we must expose a public API for freeing +// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are: +// +// * Each instance holds an opaque pointer to the underlying Rust struct. +// Method calls need to read this pointer from the object's state and pass it in to +// the Rust FFI. +// +// * When an instance is no longer needed, its pointer should be passed to a +// special destructor function provided by the Rust FFI, which will drop the +// underlying Rust struct. +// +// * Given an instance, calling code is expected to call the special +// `destroy` method in order to free it after use, either by calling it explicitly +// or by using a higher-level helper like the `use` method. Failing to do so risks +// leaking the underlying Rust struct. +// +// * We can't assume that calling code will do the right thing, and must be prepared +// to handle Kotlin method calls executing concurrently with or even after a call to +// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`. +// +// * We must never allow Rust code to operate on the underlying Rust struct after +// the destructor has been called, and must never call the destructor more than once. +// Doing so may trigger memory unsafety. +// +// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner` +// is implemented to call the destructor when the Kotlin object becomes unreachable. +// This is done in a background thread. This is not a panacea, and client code should be aware that +// 1. the thread may starve if some there are objects that have poorly performing +// `drop` methods or do significant work in their `drop` methods. +// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`, +// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html). +// +// If we try to implement this with mutual exclusion on access to the pointer, there is the +// possibility of a race between a method call and a concurrent call to `destroy`: +// +// * Thread A starts a method call, reads the value of the pointer, but is interrupted +// before it can pass the pointer over the FFI to Rust. +// * Thread B calls `destroy` and frees the underlying Rust struct. +// * Thread A resumes, passing the already-read pointer value to Rust and triggering +// a use-after-free. +// +// One possible solution would be to use a `ReadWriteLock`, with each method call taking +// a read lock (and thus allowed to run concurrently) and the special `destroy` method +// taking a write lock (and thus blocking on live method calls). However, we aim not to +// generate methods with any hidden blocking semantics, and a `destroy` method that might +// block if called incorrectly seems to meet that bar. +// +// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track +// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy` +// has been called. These are updated according to the following rules: +// +// * The initial value of the counter is 1, indicating a live object with no in-flight calls. +// The initial value for the flag is false. +// +// * At the start of each method call, we atomically check the counter. +// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted. +// If it is nonzero them we atomically increment it by 1 and proceed with the method call. +// +// * At the end of each method call, we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// * When `destroy` is called, we atomically flip the flag from false to true. +// If the flag was already true we silently fail. +// Otherwise we atomically decrement and check the counter. +// If it has reached zero then we destroy the underlying Rust struct. +// +// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc` works, +// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`. +// +// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been +// called *and* all in-flight method calls have completed, avoiding violating any of the expectations +// of the underlying Rust code. +// +// This makes a cleaner a better alternative to _not_ calling `destroy()` as +// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop` +// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner +// thread may be starved, and the app will leak memory. +// +// In this case, `destroy`ing manually may be a better solution. +// +// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects +// with Rust peers are reclaimed: +// +// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen: +// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then: +// 3. The memory is reclaimed when the process terminates. +// +// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219 +// + + /** * A signature from a user * diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 20764659c..70e52b51c 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -803,6 +803,10 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_movepackage_version() != 22970: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64() != 1835: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json() != 3153: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap() != 41489: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_committee() != 17432: @@ -1209,7 +1213,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_move_call() != 22281: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 46833: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 30595: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_coins() != 434: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1221,7 +1225,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_transfer_objects() != 16313: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 34068: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_upgrade() != 3616: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactioneffects_as_v1() != 48710: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -1289,6 +1293,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket() != 11416: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8() != 30703: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig() != 36332: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig_opt() != 21895: @@ -1633,6 +1639,12 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new() != 17506: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64() != 61420: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json() != 13174: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new() != 65225: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new() != 3396: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregator_new_with_message() != 41388: @@ -1903,6 +1915,12 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new() != 61663: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive() != 4357: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible() != 62706: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only() != 53392: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64() != 8029: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_bytes() != 37499: @@ -3972,6 +3990,42 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackage_version.restype = ctypes.c_uint64 +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_movepackagedata.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_movepackagedata.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_movepackagedata.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_movepackagedata.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64.restype = _UniffiRustBuffer +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json.restype = _UniffiRustBuffer _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_multisigaggregatedsignature.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -6041,7 +6095,7 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_move_call.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, + ctypes.c_void_p, _UniffiRustBuffer, _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), @@ -6085,8 +6139,7 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_transfer_objects.restype = ctypes.c_void_p _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, + ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, _UniffiRustBuffer, @@ -6441,6 +6494,33 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_upgrade_ticket.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_upgradepolicy.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_upgradepolicy.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_upgradepolicy.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_free_upgradepolicy.restype = None +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only.restype = ctypes.c_void_p +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8.restype = ctypes.c_uint8 _UniffiLib.uniffi_iota_sdk_ffi_fn_clone_usersignature.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -7772,6 +7852,12 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackage_version.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackage_version.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_base64.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_movepackagedata_to_json.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_multisigaggregatedsignature_bitmap.restype = ctypes.c_uint16 @@ -8501,6 +8587,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_upgrade_ticket.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_method_upgradepolicy_as_u8.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_method_usersignature_as_multisig.restype = ctypes.c_uint16 @@ -9017,6 +9106,15 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackage_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_base64.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_from_json.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_movepackagedata_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_multisigaggregatedsignature_new.restype = ctypes.c_uint16 @@ -9422,6 +9520,15 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgrade_new.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_additive.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_compatible.restype = ctypes.c_uint16 +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only.argtypes = ( +) +_UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_upgradepolicy_dep_only.restype = ctypes.c_uint16 _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64.argtypes = ( ) _UniffiLib.uniffi_iota_sdk_ffi_checksum_constructor_usersignature_from_base64.restype = ctypes.c_uint16 @@ -9866,6 +9973,10 @@ def write(value, buf): + + + + @@ -31074,6 +31185,106 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: MovePackageProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) +class MovePackageDataProtocol(typing.Protocol): + def to_base64(self, ): + raise NotImplementedError + def to_json(self, ): + raise NotImplementedError +# MovePackageData is a Rust-only trait - it's a wrapper around a Rust implementation. +class MovePackageData(): + _pointer: ctypes.c_void_p + def __init__(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]"): + _UniffiConverterSequenceBytes.check_lower(modules) + + _UniffiConverterSequenceTypeObjectId.check_lower(dependencies) + + self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_new, + _UniffiConverterSequenceBytes.lower(modules), + _UniffiConverterSequenceTypeObjectId.lower(dependencies)) + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_movepackagedata, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_movepackagedata, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def from_base64(cls, base64: "str"): + _UniffiConverterString.check_lower(base64) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_base64, + _UniffiConverterString.lower(base64)) + return cls._make_instance_(pointer) + + @classmethod + def from_json(cls, json: "str"): + _UniffiConverterString.check_lower(json) + + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeSdkFfiError,_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_movepackagedata_from_json, + _UniffiConverterString.lower(json)) + return cls._make_instance_(pointer) + + + + def to_base64(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_base64,self._uniffi_clone_pointer(),) + ) + + + + + + def to_json(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_movepackagedata_to_json,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeMovePackageData: + + @staticmethod + def lift(value: int): + return MovePackageData._make_instance_(value) + + @staticmethod + def check_lower(value: MovePackageData): + if not isinstance(value, MovePackageData): + raise TypeError("Expected MovePackageData instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: MovePackageDataProtocol): + if not isinstance(value, MovePackageData): + raise TypeError("Expected MovePackageData instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: MovePackageDataProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) class MultisigAggregatedSignatureProtocol(typing.Protocol): """ Aggregated signature from members of a multisig committee. @@ -38049,7 +38260,7 @@ def move_call(self, package: "Address",module: "Identifier",function: "Identifie """ raise NotImplementedError - def publish(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str"): + def publish(self, package_data: "MovePackageData",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str"): """ Publish a list of modules with the given dependencies. The result assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` @@ -38099,7 +38310,7 @@ def transfer_objects(self, recipient: "Address",objects: "typing.List[PtbArgumen """ raise NotImplementedError - def upgrade(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]",package: "ObjectId",ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT): + def upgrade(self, package_data: "MovePackageData",package: "ObjectId",ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT): """ Upgrade a Move package. @@ -38453,7 +38664,7 @@ def move_call(self, package: "Address",module: "Identifier",function: "Identifie - def publish(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str") -> "TransactionBuilder": + def publish(self, package_data: "MovePackageData",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str") -> "TransactionBuilder": """ Publish a list of modules with the given dependencies. The result assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` @@ -38470,7 +38681,7 @@ def publish(self, modules: "typing.List[bytes]",dependencies: "typing.List[Objec the package """ - _UniffiConverterSequenceBytes.check_lower(modules) + _UniffiConverterTypeMovePackageData.check_lower(package_data) _UniffiConverterSequenceTypeObjectId.check_lower(dependencies) @@ -38478,7 +38689,7 @@ def publish(self, modules: "typing.List[bytes]",dependencies: "typing.List[Objec return _UniffiConverterTypeTransactionBuilder.lift( _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish,self._uniffi_clone_pointer(), - _UniffiConverterSequenceBytes.lower(modules), + _UniffiConverterTypeMovePackageData.lower(package_data), _UniffiConverterSequenceTypeObjectId.lower(dependencies), _UniffiConverterString.lower(upgrade_cap_name)) ) @@ -38593,7 +38804,7 @@ def transfer_objects(self, recipient: "Address",objects: "typing.List[PtbArgumen - def upgrade(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]",package: "ObjectId",ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT) -> "TransactionBuilder": + def upgrade(self, package_data: "MovePackageData",package: "ObjectId",ticket: "PtbArgument",name: "typing.Union[object, typing.Optional[str]]" = _DEFAULT) -> "TransactionBuilder": """ Upgrade a Move package. @@ -38608,9 +38819,7 @@ def upgrade(self, modules: "typing.List[bytes]",dependencies: "typing.List[Objec ID, the upgrade policy, and package digest. """ - _UniffiConverterSequenceBytes.check_lower(modules) - - _UniffiConverterSequenceTypeObjectId.check_lower(dependencies) + _UniffiConverterTypeMovePackageData.check_lower(package_data) _UniffiConverterTypeObjectId.check_lower(package) @@ -38622,8 +38831,7 @@ def upgrade(self, modules: "typing.List[bytes]",dependencies: "typing.List[Objec return _UniffiConverterTypeTransactionBuilder.lift( _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_upgrade,self._uniffi_clone_pointer(), - _UniffiConverterSequenceBytes.lower(modules), - _UniffiConverterSequenceTypeObjectId.lower(dependencies), + _UniffiConverterTypeMovePackageData.lower(package_data), _UniffiConverterTypeObjectId.lower(package), _UniffiConverterTypePtbArgument.lower(ticket), _UniffiConverterOptionalString.lower(name)) @@ -39871,6 +40079,90 @@ def read(cls, buf: _UniffiRustBuffer): @classmethod def write(cls, value: UpgradeProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) +class UpgradePolicyProtocol(typing.Protocol): + def as_u8(self, ): + raise NotImplementedError +# UpgradePolicy is a Rust-only trait - it's a wrapper around a Rust implementation. +class UpgradePolicy(): + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_free_upgradepolicy, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_clone_upgradepolicy, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + @classmethod + def additive(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_additive,) + return cls._make_instance_(pointer) + + @classmethod + def compatible(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_compatible,) + return cls._make_instance_(pointer) + + @classmethod + def dep_only(cls, ): + # Call the (fallible) function before creating any half-baked object instances. + pointer = _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_constructor_upgradepolicy_dep_only,) + return cls._make_instance_(pointer) + + + + def as_u8(self, ) -> "int": + return _UniffiConverterUInt8.lift( + _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_upgradepolicy_as_u8,self._uniffi_clone_pointer(),) + ) + + + + + + +class _UniffiConverterTypeUpgradePolicy: + + @staticmethod + def lift(value: int): + return UpgradePolicy._make_instance_(value) + + @staticmethod + def check_lower(value: UpgradePolicy): + if not isinstance(value, UpgradePolicy): + raise TypeError("Expected UpgradePolicy instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: UpgradePolicyProtocol): + if not isinstance(value, UpgradePolicy): + raise TypeError("Expected UpgradePolicy instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: UpgradePolicyProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) class UserSignatureProtocol(typing.Protocol): """ A signature from a user @@ -42068,6 +42360,7 @@ def hex_encode(input: "bytes") -> "str": "MoveCall", "MoveFunction", "MovePackage", + "MovePackageData", "MultisigAggregatedSignature", "MultisigAggregator", "MultisigCommittee", @@ -42115,6 +42408,7 @@ def hex_encode(input: "bytes") -> "str": "TransferObjects", "TypeTag", "Upgrade", + "UpgradePolicy", "UserSignature", "UserSignatureVerifier", "ValidatorAggregatedSignature", diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index 2cddda2be..c5efa485f 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -17,8 +17,8 @@ use crate::{ types::{ address::Address, graphql::DryRunResult, + move_package::MovePackageData, object::ObjectId, - package_data::MovePackageData, struct_tag::Identifier, transaction::{Argument, Transaction, TransactionEffects}, type_tag::TypeTag, diff --git a/crates/iota-sdk-ffi/src/types/mod.rs b/crates/iota-sdk-ffi/src/types/mod.rs index 144515c62..56c905ff1 100644 --- a/crates/iota-sdk-ffi/src/types/mod.rs +++ b/crates/iota-sdk-ffi/src/types/mod.rs @@ -13,8 +13,8 @@ pub mod execution_status; pub mod gas; pub mod graphql; pub mod iota_names; +pub mod move_package; pub mod object; -pub mod package_data; pub mod signature; pub mod struct_tag; pub mod transaction; diff --git a/crates/iota-sdk-ffi/src/types/package_data.rs b/crates/iota-sdk-ffi/src/types/move_package.rs similarity index 65% rename from crates/iota-sdk-ffi/src/types/package_data.rs rename to crates/iota-sdk-ffi/src/types/move_package.rs index ec5ea827e..c2d3c1bf9 100644 --- a/crates/iota-sdk-ffi/src/types/package_data.rs +++ b/crates/iota-sdk-ffi/src/types/move_package.rs @@ -5,6 +5,31 @@ use std::sync::Arc; use crate::{error::Result, types::object::ObjectId}; +#[derive(derive_more::From, uniffi::Object)] +pub struct UpgradePolicy(pub iota_types::UpgradePolicy); + +#[uniffi::export] +impl UpgradePolicy { + #[uniffi::constructor] + pub fn compatible() -> Self { + Self(iota_types::UpgradePolicy::Compatible) + } + + #[uniffi::constructor] + pub fn additive() -> Self { + Self(iota_types::UpgradePolicy::Additive) + } + + #[uniffi::constructor] + pub fn dep_only() -> Self { + Self(iota_types::UpgradePolicy::DepOnly) + } + + pub fn as_u8(&self) -> u8 { + self.0 as u8 + } +} + #[derive(derive_more::From, uniffi::Object)] pub struct MovePackageData(pub iota_types::MovePackageData); diff --git a/crates/iota-sdk-types/Cargo.toml b/crates/iota-sdk-types/Cargo.toml index 7e74e1149..a4a9a07e7 100644 --- a/crates/iota-sdk-types/Cargo.toml +++ b/crates/iota-sdk-types/Cargo.toml @@ -44,6 +44,7 @@ anyhow = "1.0" base64ct = { version = "1.6.0", features = ["alloc"] } bnum = "0.12.0" bs58 = "0.5.1" +derive_more = { version = "2.0", features = ["display"] } hex = "0.4.3" paste = "1.0" roaring = { version = "0.11.2", default-features = false } diff --git a/crates/iota-sdk-types/src/lib.rs b/crates/iota-sdk-types/src/lib.rs index 7a6fcd33a..ff0e632f7 100644 --- a/crates/iota-sdk-types/src/lib.rs +++ b/crates/iota-sdk-types/src/lib.rs @@ -120,9 +120,9 @@ mod execution_status; pub mod framework; mod gas; pub mod iota_names; +mod move_package; mod object; mod object_id; -mod package_data; mod transaction; mod type_tag; mod u256; @@ -155,12 +155,12 @@ pub use execution_status::{ }; pub use framework::Coin; pub use gas::GasCostSummary; +pub use move_package::{MovePackageData, UpgradePolicy}; pub use object::{ GenesisObject, MovePackage, MoveStruct, Object, ObjectData, ObjectReference, ObjectType, Owner, TypeOrigin, UpgradeInfo, Version, }; pub use object_id::ObjectId; -pub use package_data::MovePackageData; #[cfg(feature = "serde")] #[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))] pub(crate) use transaction::SignedTransactionWithIntentMessage; diff --git a/crates/iota-sdk-types/src/package_data.rs b/crates/iota-sdk-types/src/move_package.rs similarity index 84% rename from crates/iota-sdk-types/src/package_data.rs rename to crates/iota-sdk-types/src/move_package.rs index 86852fe40..88c72db80 100644 --- a/crates/iota-sdk-types/src/package_data.rs +++ b/crates/iota-sdk-types/src/move_package.rs @@ -3,6 +3,40 @@ use crate::{Digest, ObjectId}; +/// Rust representation of upgrade policy constants in `iota::package`. +#[repr(u8)] +#[derive(derive_more::Display, Debug, Clone, Copy)] +pub enum UpgradePolicy { + #[display("COMPATIBLE")] + Compatible = 0, + #[display("ADDITIVE")] + Additive = 128, + #[display("DEP_ONLY")] + DepOnly = 192, +} + +impl UpgradePolicy { + pub const COMPATIBLE: u8 = Self::Compatible as u8; + pub const ADDITIVE: u8 = Self::Additive as u8; + pub const DEP_ONLY: u8 = Self::DepOnly as u8; + + pub fn is_valid_policy(policy: &u8) -> bool { + Self::try_from(*policy).is_ok() + } +} + +impl TryFrom for UpgradePolicy { + type Error = (); + fn try_from(value: u8) -> Result { + match value { + x if x == Self::Compatible as u8 => Ok(Self::Compatible), + x if x == Self::Additive as u8 => Ok(Self::Additive), + x if x == Self::DepOnly as u8 => Ok(Self::DepOnly), + _ => Err(()), + } + } +} + /// Type corresponding to the output of `iota move build /// --dump-bytecode-as-base64` #[derive(Clone, Debug)] diff --git a/crates/iota-transaction-builder/src/lib.rs b/crates/iota-transaction-builder/src/lib.rs index 98d3debd5..d8ac1e3e0 100644 --- a/crates/iota-transaction-builder/src/lib.rs +++ b/crates/iota-transaction-builder/src/lib.rs @@ -31,7 +31,7 @@ mod tests { }; use iota_types::{ Address, Digest, ExecutionStatus, IdOperation, MovePackageData, ObjectId, ObjectReference, - ObjectType, TransactionEffects, + ObjectType, TransactionEffects, UpgradePolicy, }; use crate::{TransactionBuilder, error::Error, res}; @@ -329,7 +329,11 @@ mod tests { // we need this ticket to authorize the upgrade tx.move_call(Address::FRAMEWORK, "package", "authorize_upgrade") - .arguments((upgrade_cap.unwrap(), 0u8, updated_package.digest)) + .arguments(( + upgrade_cap.unwrap(), + UpgradePolicy::Additive as u8, + updated_package.digest, + )) .name("ticket"); // now we can upgrade the package let receipt = tx From edf67388892680e64ec86daf6001e4fbb0bd5530 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 14:32:58 +0200 Subject: [PATCH 4/7] clippy --- crates/iota-sdk-types/src/move_package.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/iota-sdk-types/src/move_package.rs b/crates/iota-sdk-types/src/move_package.rs index 88c72db80..7068f10c5 100644 --- a/crates/iota-sdk-types/src/move_package.rs +++ b/crates/iota-sdk-types/src/move_package.rs @@ -105,7 +105,7 @@ mod serialization { use super::*; pub fn serialize( - value: &Vec>, + value: &[Vec], serializer: S, ) -> Result { value From 599f1126b02a2f81abff3c8ad708b8c5c337ebe3 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 14:56:09 +0200 Subject: [PATCH 5/7] compatible --- crates/iota-transaction-builder/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/iota-transaction-builder/src/lib.rs b/crates/iota-transaction-builder/src/lib.rs index d8ac1e3e0..ef9538569 100644 --- a/crates/iota-transaction-builder/src/lib.rs +++ b/crates/iota-transaction-builder/src/lib.rs @@ -331,7 +331,7 @@ mod tests { tx.move_call(Address::FRAMEWORK, "package", "authorize_upgrade") .arguments(( upgrade_cap.unwrap(), - UpgradePolicy::Additive as u8, + UpgradePolicy::Compatible as u8, updated_package.digest, )) .name("ticket"); From ebaa1249c08d3595586ad57b252c6e3a81b6daae Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 15:33:51 +0200 Subject: [PATCH 6/7] missed extra param --- bindings/go/iota_sdk_ffi/iota_sdk_ffi.go | 8 ++++---- bindings/go/iota_sdk_ffi/iota_sdk_ffi.h | 2 +- bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt | 10 +++++----- bindings/python/lib/iota_sdk_ffi.py | 10 +++------- crates/iota-sdk-ffi/src/transaction_builder/mod.rs | 1 - 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 8ac49b0d3..50b5e3e1f 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -3755,7 +3755,7 @@ func uniffiCheckChecksums() { checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() }) - if checksum != 30595 { + if checksum != 22805 { // If this happens try cleaning and rebuilding your project panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish: UniFFI API checksum mismatch") } @@ -22166,7 +22166,7 @@ type TransactionBuilderInterface interface { // - `modules`: is the modules' bytecode to be published // - `dependencies`: is the list of IDs of the transitive dependencies of // the package - Publish(packageData *MovePackageData, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder + Publish(packageData *MovePackageData, upgradeCapName string) *TransactionBuilder // Transfer some coins to a recipient address. If multiple coins are // provided then they will be merged. SendCoins(coins []*PtbArgument, recipient *Address, amount **PtbArgument) *TransactionBuilder @@ -22448,12 +22448,12 @@ func (_self *TransactionBuilder) MoveCall(varPackage *Address, module *Identifie // - `modules`: is the modules' bytecode to be published // - `dependencies`: is the list of IDs of the transitive dependencies of // the package -func (_self *TransactionBuilder) Publish(packageData *MovePackageData, dependencies []*ObjectId, upgradeCapName string) *TransactionBuilder { +func (_self *TransactionBuilder) Publish(packageData *MovePackageData, upgradeCapName string) *TransactionBuilder { _pointer := _self.ffiObject.incrementPointer("*TransactionBuilder") defer _self.ffiObject.decrementPointer() return FfiConverterTransactionBuilderINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { return C.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish( - _pointer,FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterSequenceObjectIdINSTANCE.Lower(dependencies), FfiConverterStringINSTANCE.Lower(upgradeCapName),_uniffiStatus) + _pointer,FfiConverterMovePackageDataINSTANCE.Lower(packageData), FfiConverterStringINSTANCE.Lower(upgradeCapName),_uniffiStatus) })) } diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h index 3e69924dd..a76033af2 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.h @@ -4326,7 +4326,7 @@ void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_move_call(void* ptr, void #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_PUBLISH #define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_PUBLISH -void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(void* ptr, void* package_data, RustBuffer dependencies, RustBuffer upgrade_cap_name, RustCallStatus *out_status +void* uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(void* ptr, void* package_data, RustBuffer upgrade_cap_name, RustCallStatus *out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTIONBUILDER_SEND_COINS diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 251338c91..0c8f02fbf 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -5582,7 +5582,7 @@ fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_merge_coins(`ptr`: Pointer, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_move_call(`ptr`: Pointer,`package`: Pointer,`module`: Pointer,`function`: Pointer,`arguments`: RustBuffer.ByValue,`typeArgs`: RustBuffer.ByValue,`names`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer -fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(`ptr`: Pointer,`packageData`: Pointer,`dependencies`: RustBuffer.ByValue,`upgradeCapName`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish(`ptr`: Pointer,`packageData`: Pointer,`upgradeCapName`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_iota_sdk_ffi_fn_method_transactionbuilder_send_coins(`ptr`: Pointer,`coins`: RustBuffer.ByValue,`recipient`: Pointer,`amount`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -7221,7 +7221,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_move_call() != 22281.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 30595.toShort()) { + if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 22805.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_coins() != 434.toShort()) { @@ -38659,7 +38659,7 @@ public interface TransactionBuilderInterface { * - `dependencies`: is the list of IDs of the transitive dependencies of * the package */ - fun `publish`(`packageData`: MovePackageData, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder + fun `publish`(`packageData`: MovePackageData, `upgradeCapName`: kotlin.String): TransactionBuilder /** * Transfer some coins to a recipient address. If multiple coins are @@ -39024,12 +39024,12 @@ open class TransactionBuilder: Disposable, AutoCloseable, TransactionBuilderInte * - `modules`: is the modules' bytecode to be published * - `dependencies`: is the list of IDs of the transitive dependencies of * the package - */override fun `publish`(`packageData`: MovePackageData, `dependencies`: List, `upgradeCapName`: kotlin.String): TransactionBuilder { + */override fun `publish`(`packageData`: MovePackageData, `upgradeCapName`: kotlin.String): TransactionBuilder { return FfiConverterTypeTransactionBuilder.lift( callWithPointer { uniffiRustCall() { _status -> UniffiLib.INSTANCE.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish( - it, FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterSequenceTypeObjectId.lower(`dependencies`),FfiConverterString.lower(`upgradeCapName`),_status) + it, FfiConverterTypeMovePackageData.lower(`packageData`),FfiConverterString.lower(`upgradeCapName`),_status) } } ) diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index b3be4c621..15b9e399a 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -1215,7 +1215,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_move_call() != 22281: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 30595: + if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_publish() != 22805: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_send_coins() != 434: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -6131,7 +6131,6 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): ctypes.c_void_p, ctypes.c_void_p, _UniffiRustBuffer, - _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish.restype = ctypes.c_void_p @@ -38392,7 +38391,7 @@ def move_call(self, package: "Address",module: "Identifier",function: "Identifie """ raise NotImplementedError - def publish(self, package_data: "MovePackageData",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str"): + def publish(self, package_data: "MovePackageData",upgrade_cap_name: "str"): """ Publish a list of modules with the given dependencies. The result assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` @@ -38796,7 +38795,7 @@ def move_call(self, package: "Address",module: "Identifier",function: "Identifie - def publish(self, package_data: "MovePackageData",dependencies: "typing.List[ObjectId]",upgrade_cap_name: "str") -> "TransactionBuilder": + def publish(self, package_data: "MovePackageData",upgrade_cap_name: "str") -> "TransactionBuilder": """ Publish a list of modules with the given dependencies. The result assigned to `upgrade_cap_name` is the `0x2::package::UpgradeCap` @@ -38815,14 +38814,11 @@ def publish(self, package_data: "MovePackageData",dependencies: "typing.List[Obj _UniffiConverterTypeMovePackageData.check_lower(package_data) - _UniffiConverterSequenceTypeObjectId.check_lower(dependencies) - _UniffiConverterString.check_lower(upgrade_cap_name) return _UniffiConverterTypeTransactionBuilder.lift( _uniffi_rust_call(_UniffiLib.uniffi_iota_sdk_ffi_fn_method_transactionbuilder_publish,self._uniffi_clone_pointer(), _UniffiConverterTypeMovePackageData.lower(package_data), - _UniffiConverterSequenceTypeObjectId.lower(dependencies), _UniffiConverterString.lower(upgrade_cap_name)) ) diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index c5efa485f..c8dbfa406 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -261,7 +261,6 @@ impl TransactionBuilder { pub fn publish( self: Arc, package_data: &MovePackageData, - dependencies: Vec>, upgrade_cap_name: String, ) -> Arc { self.write(|builder| { From 225b76aed530c964866a65ab6ec114c5e61b866b Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 16 Oct 2025 15:51:43 +0200 Subject: [PATCH 7/7] docs --- bindings/go/iota_sdk_ffi/iota_sdk_ffi.go | 6 ++++++ bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt | 14 ++++++++++++++ bindings/python/lib/iota_sdk_ffi.py | 18 ++++++++++++++++++ crates/iota-sdk-ffi/src/types/move_package.rs | 3 +++ 4 files changed, 41 insertions(+) diff --git a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go index 50b5e3e1f..1fe43fc17 100644 --- a/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go +++ b/bindings/go/iota_sdk_ffi/iota_sdk_ffi.go @@ -15437,10 +15437,14 @@ func (_ FfiDestroyerMovePackage) Destroy(value *MovePackage) { +// Type corresponding to the output of `iota move build +// --dump-bytecode-as-base64` type MovePackageDataInterface interface { ToBase64() string ToJson() string } +// Type corresponding to the output of `iota move build +// --dump-bytecode-as-base64` type MovePackageData struct { ffiObject FfiObject } @@ -23757,9 +23761,11 @@ func (_ FfiDestroyerUpgrade) Destroy(value *Upgrade) { +// Representation of upgrade policy constants in `iota::package`. type UpgradePolicyInterface interface { AsU8() uint8 } +// Representation of upgrade policy constants in `iota::package`. type UpgradePolicy struct { ffiObject FfiObject } diff --git a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt index 0c8f02fbf..b82e713cd 100644 --- a/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt +++ b/bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt @@ -24310,6 +24310,10 @@ public object FfiConverterTypeMovePackage: FfiConverter { // +/** + * Type corresponding to the output of `iota move build + * --dump-bytecode-as-base64` + */ public interface MovePackageDataInterface { fun `toBase64`(): kotlin.String @@ -24319,6 +24323,10 @@ public interface MovePackageDataInterface { companion object } +/** + * Type corresponding to the output of `iota move build + * --dump-bytecode-as-base64` + */ open class MovePackageData: Disposable, AutoCloseable, MovePackageDataInterface { @@ -41849,6 +41857,9 @@ public object FfiConverterTypeUpgrade: FfiConverter { // +/** + * Representation of upgrade policy constants in `iota::package`. + */ public interface UpgradePolicyInterface { fun `asU8`(): kotlin.UByte @@ -41856,6 +41867,9 @@ public interface UpgradePolicyInterface { companion object } +/** + * Representation of upgrade policy constants in `iota::package`. + */ open class UpgradePolicy: Disposable, AutoCloseable, UpgradePolicyInterface { diff --git a/bindings/python/lib/iota_sdk_ffi.py b/bindings/python/lib/iota_sdk_ffi.py index 15b9e399a..d8b840b4f 100644 --- a/bindings/python/lib/iota_sdk_ffi.py +++ b/bindings/python/lib/iota_sdk_ffi.py @@ -31255,12 +31255,22 @@ def read(cls, buf: _UniffiRustBuffer): def write(cls, value: MovePackageProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) class MovePackageDataProtocol(typing.Protocol): + """ + Type corresponding to the output of `iota move build + --dump-bytecode-as-base64` + """ + def to_base64(self, ): raise NotImplementedError def to_json(self, ): raise NotImplementedError # MovePackageData is a Rust-only trait - it's a wrapper around a Rust implementation. class MovePackageData(): + """ + Type corresponding to the output of `iota move build + --dump-bytecode-as-base64` + """ + _pointer: ctypes.c_void_p def __init__(self, modules: "typing.List[bytes]",dependencies: "typing.List[ObjectId]"): _UniffiConverterSequenceBytes.check_lower(modules) @@ -40261,10 +40271,18 @@ def read(cls, buf: _UniffiRustBuffer): def write(cls, value: UpgradeProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) class UpgradePolicyProtocol(typing.Protocol): + """ + Representation of upgrade policy constants in `iota::package`. + """ + def as_u8(self, ): raise NotImplementedError # UpgradePolicy is a Rust-only trait - it's a wrapper around a Rust implementation. class UpgradePolicy(): + """ + Representation of upgrade policy constants in `iota::package`. + """ + _pointer: ctypes.c_void_p def __init__(self, *args, **kwargs): diff --git a/crates/iota-sdk-ffi/src/types/move_package.rs b/crates/iota-sdk-ffi/src/types/move_package.rs index c2d3c1bf9..03b1f4d7f 100644 --- a/crates/iota-sdk-ffi/src/types/move_package.rs +++ b/crates/iota-sdk-ffi/src/types/move_package.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use crate::{error::Result, types::object::ObjectId}; +/// Representation of upgrade policy constants in `iota::package`. #[derive(derive_more::From, uniffi::Object)] pub struct UpgradePolicy(pub iota_types::UpgradePolicy); @@ -30,6 +31,8 @@ impl UpgradePolicy { } } +/// Type corresponding to the output of `iota move build +/// --dump-bytecode-as-base64` #[derive(derive_more::From, uniffi::Object)] pub struct MovePackageData(pub iota_types::MovePackageData);