diff --git a/bindings/wasm/iota_interaction_ts/src/asset_move_calls.rs b/bindings/wasm/iota_interaction_ts/src/asset_move_calls.rs index 5f1e0b2fb..f09e1c530 100644 --- a/bindings/wasm/iota_interaction_ts/src/asset_move_calls.rs +++ b/bindings/wasm/iota_interaction_ts/src/asset_move_calls.rs @@ -3,77 +3,79 @@ use serde::Serialize; -use identity_iota_interaction::{ - AssetMoveCalls, - ProgrammableTransactionBcs, - types::{ - TypeTag, - base_types::{SequenceNumber, ObjectID, ObjectRef, IotaAddress}, - } -}; -use identity_iota_interaction::MoveType; use crate::error::TsSdkError; +use identity_iota_interaction::types::base_types::IotaAddress; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; +use identity_iota_interaction::types::base_types::SequenceNumber; +use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::AssetMoveCalls; +use identity_iota_interaction::MoveType; +use identity_iota_interaction::ProgrammableTransactionBcs; pub struct AssetMoveCallsTsSdk {} impl AssetMoveCalls for AssetMoveCallsTsSdk { - type Error = TsSdkError; + type Error = TsSdkError; - fn new_asset( - inner: T, - mutable: bool, - transferable: bool, - deletable: bool, - package: ObjectID, - ) -> Result { - unimplemented!(); - } + fn new_asset( + inner: T, + mutable: bool, + transferable: bool, + deletable: bool, + package: ObjectID, + ) -> Result { + unimplemented!(); + } - fn delete(asset: ObjectRef, package: ObjectID) -> Result { - unimplemented!(); - } + fn delete(asset: ObjectRef, package: ObjectID) -> Result { + unimplemented!(); + } - fn transfer( - asset: ObjectRef, - recipient: IotaAddress, - package: ObjectID, - ) -> Result { - unimplemented!(); - } + fn transfer( + asset: ObjectRef, + recipient: IotaAddress, + package: ObjectID, + ) -> Result { + unimplemented!(); + } - fn make_tx( - proposal: (ObjectID, SequenceNumber), - cap: ObjectRef, - asset: ObjectRef, - asset_type_param: TypeTag, - package: ObjectID, - function_name: &'static str, - ) -> Result { - unimplemented!(); - } + fn make_tx( + proposal: (ObjectID, SequenceNumber), + cap: ObjectRef, + asset: ObjectRef, + asset_type_param: TypeTag, + package: ObjectID, + function_name: &'static str, + ) -> Result { + unimplemented!(); + } - fn accept_proposal( - proposal: (ObjectID, SequenceNumber), - recipient_cap: ObjectRef, - asset: ObjectRef, - asset_type_param: TypeTag, - package: ObjectID, - ) -> Result { - unimplemented!(); - } + fn accept_proposal( + proposal: (ObjectID, SequenceNumber), + recipient_cap: ObjectRef, + asset: ObjectRef, + asset_type_param: TypeTag, + package: ObjectID, + ) -> Result { + unimplemented!(); + } - fn conclude_or_cancel( - proposal: (ObjectID, SequenceNumber), - sender_cap: ObjectRef, - asset: ObjectRef, - asset_type_param: TypeTag, - package: ObjectID, - ) -> Result{ - unimplemented!(); - } + fn conclude_or_cancel( + proposal: (ObjectID, SequenceNumber), + sender_cap: ObjectRef, + asset: ObjectRef, + asset_type_param: TypeTag, + package: ObjectID, + ) -> Result { + unimplemented!(); + } - fn update(asset: ObjectRef, new_content: T, package: ObjectID) - -> Result { - unimplemented!(); - } -} \ No newline at end of file + fn update( + asset: ObjectRef, + new_content: T, + package: ObjectID, + ) -> Result { + unimplemented!(); + } +} diff --git a/bindings/wasm/iota_interaction_ts/src/bindings/mod.rs b/bindings/wasm/iota_interaction_ts/src/bindings/mod.rs index 8973635fb..c04f57355 100644 --- a/bindings/wasm/iota_interaction_ts/src/bindings/mod.rs +++ b/bindings/wasm/iota_interaction_ts/src/bindings/mod.rs @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 mod types; -mod wasm_types; mod wasm_iota_client; +mod wasm_types; pub use types::*; -pub use wasm_types::*; pub use wasm_iota_client::*; +pub use wasm_types::*; diff --git a/bindings/wasm/iota_interaction_ts/src/common/mod.rs b/bindings/wasm/iota_interaction_ts/src/common/mod.rs index 41cfe587f..e23da706a 100644 --- a/bindings/wasm/iota_interaction_ts/src/common/mod.rs +++ b/bindings/wasm/iota_interaction_ts/src/common/mod.rs @@ -5,4 +5,4 @@ pub mod types; pub mod utils; pub use types::*; -pub use utils::*; \ No newline at end of file +pub use utils::*; diff --git a/bindings/wasm/iota_interaction_ts/src/common/utils.rs b/bindings/wasm/iota_interaction_ts/src/common/utils.rs index 6de392001..5b2d698be 100644 --- a/bindings/wasm/iota_interaction_ts/src/common/utils.rs +++ b/bindings/wasm/iota_interaction_ts/src/common/utils.rs @@ -4,14 +4,17 @@ use serde::de::DeserializeOwned; use wasm_bindgen::prelude::*; -use crate::error::{wasm_error, WasmError}; +use crate::error::wasm_error; +use crate::error::WasmError; -pub fn into_sdk_type<'a, T: DeserializeOwned, W: Into>(wasm_type_instance: W) -> core::result::Result> { +pub fn into_sdk_type<'a, T: DeserializeOwned, W: Into>( + wasm_type_instance: W, +) -> core::result::Result> { let js_value: JsValue = wasm_type_instance.into(); match serde_wasm_bindgen::from_value::(js_value.clone()) { Ok(ret_val) => Ok(ret_val), Err(e) => { - // TODO: Replace all console_log! usages by proper Error management and Result types. + // TODO: Replace all console_log! usages by proper Error management and Result types. // Use console_log! only for debug purposes console_log!( "[iota_interaction_ts::common::utils - fn into_sdk_type]\n js_value: {:?}\n Error: {:?}", @@ -21,4 +24,4 @@ pub fn into_sdk_type<'a, T: DeserializeOwned, W: Into>(wasm_type_instan Err(e.into()) } } -} \ No newline at end of file +} diff --git a/bindings/wasm/iota_interaction_ts/src/error.rs b/bindings/wasm/iota_interaction_ts/src/error.rs index a0195a023..2a0996914 100644 --- a/bindings/wasm/iota_interaction_ts/src/error.rs +++ b/bindings/wasm/iota_interaction_ts/src/error.rs @@ -3,15 +3,18 @@ use std::result::Result as StdResult; +use serde::de::DeserializeOwned; use std::borrow::Cow; use std::fmt::Debug; use std::fmt::Display; -use serde::de::DeserializeOwned; use wasm_bindgen::JsValue; -use thiserror::Error as ThisError; -use identity_iota_interaction::types::execution_status::{CommandArgumentError, ExecutionFailureStatus, PackageUpgradeError, TypeArgumentError}; use crate::common::into_sdk_type; +use identity_iota_interaction::types::execution_status::CommandArgumentError; +use identity_iota_interaction::types::execution_status::ExecutionFailureStatus; +use identity_iota_interaction::types::execution_status::PackageUpgradeError; +use identity_iota_interaction::types::execution_status::TypeArgumentError; +use thiserror::Error as ThisError; /// Convenience wrapper for `Result`. /// @@ -206,4 +209,4 @@ pub fn into_ts_sdk_result(result: Result) -> TsSdk let js_value = result_str.map_err(|e| TsSdkError::JsSysError(e))?; let ret_val: T = into_sdk_type(js_value)?; Ok(ret_val) -} \ No newline at end of file +} diff --git a/bindings/wasm/iota_interaction_ts/src/identity_move_calls.rs b/bindings/wasm/iota_interaction_ts/src/identity_move_calls.rs index eebaf4711..4c3a6e712 100644 --- a/bindings/wasm/iota_interaction_ts/src/identity_move_calls.rs +++ b/bindings/wasm/iota_interaction_ts/src/identity_move_calls.rs @@ -5,183 +5,189 @@ use serde::Serialize; use std::collections::HashSet; use super::TransactionBuilderAdapter; -use identity_iota_interaction::{IdentityMoveCalls, ProgrammableTransactionBcs, types::{ - TypeTag, - base_types::{SequenceNumber, ObjectID, ObjectRef, IotaAddress}, - transaction::Argument, -}, BorrowIntentFnT, ControllerIntentFnT}; -use identity_iota_interaction::rpc_types::{IotaObjectData, OwnedObjectRef}; -use identity_iota_interaction::MoveType; use crate::error::TsSdkError; +use identity_iota_interaction::rpc_types::IotaObjectData; +use identity_iota_interaction::rpc_types::OwnedObjectRef; +use identity_iota_interaction::types::base_types::IotaAddress; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; +use identity_iota_interaction::types::base_types::SequenceNumber; +use identity_iota_interaction::types::transaction::Argument; +use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::BorrowIntentFnT; +use identity_iota_interaction::ControllerIntentFnT; +use identity_iota_interaction::IdentityMoveCalls; +use identity_iota_interaction::MoveType; +use identity_iota_interaction::ProgrammableTransactionBcs; pub struct IdentityMoveCallsTsSdk {} impl IdentityMoveCalls for IdentityMoveCallsTsSdk { - type Error = TsSdkError; - type NativeTxBuilder = (); // TODO: Set this to the wasm32... type that is wrapped by IdentityMoveCallsTsSdk - - fn propose_borrow( - identity: OwnedObjectRef, - capability: ObjectRef, - objects: Vec, - expiration: Option, - package_id: ObjectID - ) -> Result { - todo!() - } - - fn execute_borrow>( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - objects: Vec, - intent_fn: F, - package: ObjectID - ) -> Result { - todo!() - } - - fn propose_config_change( - identity: OwnedObjectRef, - controller_cap: ObjectRef, - expiration: Option, - threshold: Option, - controllers_to_add: I1, - controllers_to_remove: HashSet, - controllers_to_update: I2, - package: ObjectID, - ) -> Result - where - I1: IntoIterator, - I2: IntoIterator, - { - unimplemented!(); - } - - fn execute_config_change( - identity: OwnedObjectRef, - controller_cap: ObjectRef, - proposal_id: ObjectID, - package: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn propose_controller_execution( - identity: OwnedObjectRef, - capability: ObjectRef, - controller_cap_id: ObjectID, - expiration: Option, - package_id: ObjectID - ) -> Result { - todo!() - } - - fn execute_controller_execution>( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - borrowing_controller_cap_ref: ObjectRef, - intent_fn: F, - package: ObjectID - ) -> Result { - todo!() - } - - fn new_identity(did_doc: &[u8], package_id: ObjectID) -> Result { - unimplemented!(); - } - - fn new_with_controllers( - did_doc: &[u8], - controllers: C, - threshold: u64, - package_id: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn propose_deactivation( - identity: OwnedObjectRef, - capability: ObjectRef, - expiration: Option, - package_id: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn execute_deactivation( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - package_id: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn approve_proposal( - identity: OwnedObjectRef, - controller_cap: ObjectRef, - proposal_id: ObjectID, - package: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn propose_send( - identity: OwnedObjectRef, - capability: ObjectRef, - transfer_map: Vec<(ObjectID, IotaAddress)>, - expiration: Option, - package_id: ObjectID - ) -> Result { - todo!() - } - - fn execute_send( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - objects: Vec<(ObjectRef, TypeTag)>, - package: ObjectID - ) -> Result { - todo!() - } - - fn propose_update( - identity: OwnedObjectRef, - capability: ObjectRef, - did_doc: impl AsRef<[u8]>, - expiration: Option, - package_id: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn execute_update( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - package_id: ObjectID, - ) -> Result { - unimplemented!(); - } - - fn propose_upgrade( - identity: OwnedObjectRef, - capability: ObjectRef, - expiration: Option, - package_id: ObjectID - ) -> Result { - todo!() - } - - fn execute_upgrade( - identity: OwnedObjectRef, - capability: ObjectRef, - proposal_id: ObjectID, - package_id: ObjectID - ) -> Result { - todo!() - } + type Error = TsSdkError; + type NativeTxBuilder = (); // TODO: Set this to the wasm32... type that is wrapped by IdentityMoveCallsTsSdk + + fn propose_borrow( + identity: OwnedObjectRef, + capability: ObjectRef, + objects: Vec, + expiration: Option, + package_id: ObjectID, + ) -> Result { + todo!() + } + + fn execute_borrow>( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + objects: Vec, + intent_fn: F, + package: ObjectID, + ) -> Result { + todo!() + } + + fn propose_config_change( + identity: OwnedObjectRef, + controller_cap: ObjectRef, + expiration: Option, + threshold: Option, + controllers_to_add: I1, + controllers_to_remove: HashSet, + controllers_to_update: I2, + package: ObjectID, + ) -> Result + where + I1: IntoIterator, + I2: IntoIterator, + { + unimplemented!(); + } + + fn execute_config_change( + identity: OwnedObjectRef, + controller_cap: ObjectRef, + proposal_id: ObjectID, + package: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn propose_controller_execution( + identity: OwnedObjectRef, + capability: ObjectRef, + controller_cap_id: ObjectID, + expiration: Option, + package_id: ObjectID, + ) -> Result { + todo!() + } + + fn execute_controller_execution>( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + borrowing_controller_cap_ref: ObjectRef, + intent_fn: F, + package: ObjectID, + ) -> Result { + todo!() + } + + fn new_identity(did_doc: &[u8], package_id: ObjectID) -> Result { + unimplemented!(); + } + + fn new_with_controllers( + did_doc: &[u8], + controllers: C, + threshold: u64, + package_id: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn propose_deactivation( + identity: OwnedObjectRef, + capability: ObjectRef, + expiration: Option, + package_id: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn execute_deactivation( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + package_id: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn approve_proposal( + identity: OwnedObjectRef, + controller_cap: ObjectRef, + proposal_id: ObjectID, + package: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn propose_send( + identity: OwnedObjectRef, + capability: ObjectRef, + transfer_map: Vec<(ObjectID, IotaAddress)>, + expiration: Option, + package_id: ObjectID, + ) -> Result { + todo!() + } + + fn execute_send( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + objects: Vec<(ObjectRef, TypeTag)>, + package: ObjectID, + ) -> Result { + todo!() + } + + fn propose_update( + identity: OwnedObjectRef, + capability: ObjectRef, + did_doc: impl AsRef<[u8]>, + expiration: Option, + package_id: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn execute_update( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + package_id: ObjectID, + ) -> Result { + unimplemented!(); + } + + fn propose_upgrade( + identity: OwnedObjectRef, + capability: ObjectRef, + expiration: Option, + package_id: ObjectID, + ) -> Result { + todo!() + } + + fn execute_upgrade( + identity: OwnedObjectRef, + capability: ObjectRef, + proposal_id: ObjectID, + package_id: ObjectID, + ) -> Result { + todo!() + } } diff --git a/bindings/wasm/iota_interaction_ts/src/lib.rs b/bindings/wasm/iota_interaction_ts/src/lib.rs index 47500f6f8..adbebe688 100644 --- a/bindings/wasm/iota_interaction_ts/src/lib.rs +++ b/bindings/wasm/iota_interaction_ts/src/lib.rs @@ -1,34 +1,33 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0pub mod iota_client_ts_sdk; - #[cfg(target_arch = "wasm32")] pub(crate) mod bindings; -#[cfg(target_arch = "wasm32")] -pub mod iota_client_ts_sdk; #[cfg(target_arch = "wasm32")] pub mod asset_move_calls; #[cfg(target_arch = "wasm32")] -pub mod identity_move_calls; -#[cfg(target_arch = "wasm32")] -pub mod transaction_builder; +pub mod common; #[cfg(target_arch = "wasm32")] pub mod error; #[cfg(target_arch = "wasm32")] -pub mod common; +pub mod identity_move_calls; #[cfg(target_arch = "wasm32")] -mod migration_move_calls; - +pub mod iota_client_ts_sdk; #[cfg(target_arch = "wasm32")] -pub use iota_client_ts_sdk::IotaClientTsSdk as IotaClientAdapter; +mod migration_move_calls; #[cfg(target_arch = "wasm32")] -pub use iota_client_ts_sdk::IotaTransactionBlockResponseProvider as IotaTransactionBlockResponseAdapter; +pub mod transaction_builder; + #[cfg(target_arch = "wasm32")] pub use asset_move_calls::AssetMoveCallsTsSdk as AssetMoveCallsAdapter; #[cfg(target_arch = "wasm32")] pub use identity_move_calls::IdentityMoveCallsTsSdk as IdentityMoveCallsAdapter; #[cfg(target_arch = "wasm32")] +pub use iota_client_ts_sdk::IotaClientTsSdk as IotaClientAdapter; +#[cfg(target_arch = "wasm32")] +pub use iota_client_ts_sdk::IotaTransactionBlockResponseProvider as IotaTransactionBlockResponseAdapter; +#[cfg(target_arch = "wasm32")] pub use migration_move_calls::MigrationMoveCallsTsSdk as MigrationMoveCallsAdapter; #[cfg(target_arch = "wasm32")] pub use transaction_builder::TransactionBuilderTsSdk as TransactionBuilderAdapter; @@ -55,4 +54,4 @@ cfg_if::cfg_if! { #[allow(unused_imports)] pub use bindings::ProgrammableTransaction; } -} \ No newline at end of file +} diff --git a/bindings/wasm/iota_interaction_ts/src/migration_move_calls.rs b/bindings/wasm/iota_interaction_ts/src/migration_move_calls.rs index 6bb73bd27..a80b07d57 100644 --- a/bindings/wasm/iota_interaction_ts/src/migration_move_calls.rs +++ b/bindings/wasm/iota_interaction_ts/src/migration_move_calls.rs @@ -1,8 +1,11 @@ +use identity_iota_interaction::ident_str; use identity_iota_interaction::rpc_types::OwnedObjectRef; -use identity_iota_interaction::types::base_types::{ObjectID, ObjectRef}; -use identity_iota_interaction::{ident_str, MigrationMoveCalls, ProgrammableTransactionBcs}; -use identity_iota_interaction::types::IOTA_FRAMEWORK_PACKAGE_ID; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; use identity_iota_interaction::types::transaction::ObjectArg; +use identity_iota_interaction::types::IOTA_FRAMEWORK_PACKAGE_ID; +use identity_iota_interaction::MigrationMoveCalls; +use identity_iota_interaction::ProgrammableTransactionBcs; use crate::error::TsSdkError; diff --git a/bindings/wasm/iota_interaction_ts/src/transaction_builder.rs b/bindings/wasm/iota_interaction_ts/src/transaction_builder.rs index 1e05e13bf..eeda9bf8e 100644 --- a/bindings/wasm/iota_interaction_ts/src/transaction_builder.rs +++ b/bindings/wasm/iota_interaction_ts/src/transaction_builder.rs @@ -1,57 +1,58 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::ops::{Deref, DerefMut}; +use std::ops::Deref; +use std::ops::DerefMut; +use crate::error::TsSdkError; use identity_iota_interaction::ProgrammableTransactionBcs; use identity_iota_interaction::TransactionBuilderT; -use crate::error::TsSdkError; pub type NativeTsCodeBindingWrapper = (); pub struct TransactionBuilderTsSdk { - pub(crate) builder: NativeTsCodeBindingWrapper + pub(crate) builder: NativeTsCodeBindingWrapper, } impl TransactionBuilderTsSdk { - pub fn new(builder: NativeTsCodeBindingWrapper) -> Self { - TransactionBuilderTsSdk {builder} - } + pub fn new(builder: NativeTsCodeBindingWrapper) -> Self { + TransactionBuilderTsSdk { builder } + } } impl TransactionBuilderT for TransactionBuilderTsSdk { - type Error = TsSdkError; - type NativeTxBuilder = NativeTsCodeBindingWrapper; + type Error = TsSdkError; + type NativeTxBuilder = NativeTsCodeBindingWrapper; - fn finish(self) -> Result { - unimplemented!(); - } + fn finish(self) -> Result { + unimplemented!(); + } - fn as_native_tx_builder(&mut self) -> &mut Self::NativeTxBuilder { - todo!() - } + fn as_native_tx_builder(&mut self) -> &mut Self::NativeTxBuilder { + todo!() + } - fn into_native_tx_builder(self) -> Self::NativeTxBuilder { - todo!() - } + fn into_native_tx_builder(self) -> Self::NativeTxBuilder { + todo!() + } } impl Default for TransactionBuilderTsSdk { - fn default() -> Self { - unimplemented!(); - } + fn default() -> Self { + unimplemented!(); + } } impl Deref for TransactionBuilderTsSdk { - type Target = NativeTsCodeBindingWrapper; + type Target = NativeTsCodeBindingWrapper; - fn deref(&self) -> &Self::Target { - &self.builder - } + fn deref(&self) -> &Self::Target { + &self.builder + } } impl DerefMut for TransactionBuilderTsSdk { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.builder - } -} \ No newline at end of file + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.builder + } +} diff --git a/identity_iota_core/src/iota_interaction_adapter.rs b/identity_iota_core/src/iota_interaction_adapter.rs index 93a075cea..5f22eacae 100644 --- a/identity_iota_core/src/iota_interaction_adapter.rs +++ b/identity_iota_core/src/iota_interaction_adapter.rs @@ -9,4 +9,4 @@ cfg_if::cfg_if! { } else { pub(crate) use crate::iota_interaction_rust::*; } -} \ No newline at end of file +} diff --git a/identity_iota_core/src/iota_interaction_rust/asset_move_calls.rs b/identity_iota_core/src/iota_interaction_rust/asset_move_calls.rs index d2b858def..bf134d16a 100644 --- a/identity_iota_core/src/iota_interaction_rust/asset_move_calls.rs +++ b/identity_iota_core/src/iota_interaction_rust/asset_move_calls.rs @@ -5,17 +5,18 @@ use serde::Serialize; use crate::rebased::Error; use identity_iota_interaction::ident_str; +use identity_iota_interaction::types::base_types::IotaAddress; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; +use identity_iota_interaction::types::base_types::SequenceNumber; use identity_iota_interaction::types::programmable_transaction_builder::ProgrammableTransactionBuilder; +use identity_iota_interaction::types::transaction::Command; +use identity_iota_interaction::types::transaction::ObjectArg; +use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::AssetMoveCalls; use identity_iota_interaction::MoveType; +use identity_iota_interaction::ProgrammableTransactionBcs; use identity_iota_interaction::TypedValue; -use identity_iota_interaction::{ - types::{ - base_types::{IotaAddress, ObjectID, ObjectRef, SequenceNumber}, - transaction::{Command, ObjectArg}, - TypeTag, - }, - AssetMoveCalls, ProgrammableTransactionBcs, -}; use iota_sdk::types::transaction::Argument; use iota_sdk::types::transaction::ProgrammableMoveCall; diff --git a/identity_iota_core/src/iota_interaction_rust/identity_move_calls.rs b/identity_iota_core/src/iota_interaction_rust/identity_move_calls.rs index 2e7e391d3..6c3632183 100644 --- a/identity_iota_core/src/iota_interaction_rust/identity_move_calls.rs +++ b/identity_iota_core/src/iota_interaction_rust/identity_move_calls.rs @@ -4,24 +4,32 @@ use std::collections::HashSet; use std::str::FromStr; -use identity_iota_interaction::{ - BorrowIntentFnT, ControllerIntentFnT, IdentityMoveCalls, ProgrammableTransactionBcs, TransactionBuilderT, -}; +use identity_iota_interaction::BorrowIntentFnT; +use identity_iota_interaction::ControllerIntentFnT; +use identity_iota_interaction::IdentityMoveCalls; +use identity_iota_interaction::ProgrammableTransactionBcs; +use identity_iota_interaction::TransactionBuilderT; // ProgrammableTransactionBuilder can only be used here cause this is a platform specific file use identity_iota_interaction::types::programmable_transaction_builder::ProgrammableTransactionBuilder as Ptb; -use super::{utils, TransactionBuilderAdapter}; -use crate::rebased::proposals::{BorrowAction, ControllerExecution, SendAction}; -use crate::rebased::{rebased_err, Error}; +use super::utils; +use super::TransactionBuilderAdapter; +use crate::rebased::proposals::BorrowAction; +use crate::rebased::proposals::ControllerExecution; +use crate::rebased::proposals::SendAction; +use crate::rebased::rebased_err; +use crate::rebased::Error; use identity_iota_interaction::ident_str; -use identity_iota_interaction::rpc_types::{IotaObjectData, OwnedObjectRef}; +use identity_iota_interaction::rpc_types::IotaObjectData; +use identity_iota_interaction::rpc_types::OwnedObjectRef; +use identity_iota_interaction::types::base_types::IotaAddress; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; use identity_iota_interaction::types::base_types::ObjectType; -use identity_iota_interaction::types::{ - base_types::{IotaAddress, ObjectID, ObjectRef}, - transaction::ObjectArg, -}; -use identity_iota_interaction::types::{TypeTag, IOTA_FRAMEWORK_PACKAGE_ID}; +use identity_iota_interaction::types::transaction::ObjectArg; +use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::types::IOTA_FRAMEWORK_PACKAGE_ID; use identity_iota_interaction::MoveType; #[derive(Clone)] diff --git a/identity_iota_core/src/iota_interaction_rust/iota_client_rust_sdk.rs b/identity_iota_core/src/iota_interaction_rust/iota_client_rust_sdk.rs index caade0cf6..95c766eaa 100644 --- a/identity_iota_core/src/iota_interaction_rust/iota_client_rust_sdk.rs +++ b/identity_iota_core/src/iota_interaction_rust/iota_client_rust_sdk.rs @@ -12,30 +12,54 @@ use fastcrypto::traits::ToFromBytes; use secret_storage::Signer; use crate::rebased::Error; -use identity_iota_interaction::apis::{CoinReadApi, EventApi, QuorumDriverApi, ReadApi}; +use identity_iota_interaction::apis::CoinReadApi; +use identity_iota_interaction::apis::EventApi; +use identity_iota_interaction::apis::QuorumDriverApi; +use identity_iota_interaction::apis::ReadApi; use identity_iota_interaction::error::IotaRpcResult; -use identity_iota_interaction::rpc_types::{ - Coin, CoinPage, EventFilter, EventPage, IotaExecutionStatus, IotaObjectData, IotaObjectDataOptions, - IotaObjectResponse, IotaObjectResponseQuery, IotaPastObjectResponse, IotaTransactionBlockEffects, - IotaTransactionBlockEffectsAPI, IotaTransactionBlockEffectsV1, IotaTransactionBlockResponse, - IotaTransactionBlockResponseOptions, ObjectChange, ObjectsPage, OwnedObjectRef, -}; -use identity_iota_interaction::shared_crypto::intent::{Intent, IntentMessage}; -use identity_iota_interaction::types::{ - base_types::{IotaAddress, ObjectID, SequenceNumber}, - crypto::{Signature, SignatureScheme}, - digests::TransactionDigest, - dynamic_field::DynamicFieldName, - event::EventID, - quorum_driver_types::ExecuteTransactionRequestType, - transaction::{ProgrammableTransaction, Transaction, TransactionData}, -}; +use identity_iota_interaction::rpc_types::Coin; +use identity_iota_interaction::rpc_types::CoinPage; +use identity_iota_interaction::rpc_types::EventFilter; +use identity_iota_interaction::rpc_types::EventPage; +use identity_iota_interaction::rpc_types::IotaExecutionStatus; +use identity_iota_interaction::rpc_types::IotaObjectData; +use identity_iota_interaction::rpc_types::IotaObjectDataOptions; +use identity_iota_interaction::rpc_types::IotaObjectResponse; +use identity_iota_interaction::rpc_types::IotaObjectResponseQuery; +use identity_iota_interaction::rpc_types::IotaPastObjectResponse; +use identity_iota_interaction::rpc_types::IotaTransactionBlockEffects; +use identity_iota_interaction::rpc_types::IotaTransactionBlockEffectsAPI; +use identity_iota_interaction::rpc_types::IotaTransactionBlockEffectsV1; +use identity_iota_interaction::rpc_types::IotaTransactionBlockResponse; +use identity_iota_interaction::rpc_types::IotaTransactionBlockResponseOptions; +use identity_iota_interaction::rpc_types::ObjectChange; +use identity_iota_interaction::rpc_types::ObjectsPage; +use identity_iota_interaction::rpc_types::OwnedObjectRef; +use identity_iota_interaction::shared_crypto::intent::Intent; +use identity_iota_interaction::shared_crypto::intent::IntentMessage; +use identity_iota_interaction::types::base_types::IotaAddress; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::SequenceNumber; +use identity_iota_interaction::types::crypto::Signature; +use identity_iota_interaction::types::crypto::SignatureScheme; +use identity_iota_interaction::types::digests::TransactionDigest; +use identity_iota_interaction::types::dynamic_field::DynamicFieldName; +use identity_iota_interaction::types::event::EventID; +use identity_iota_interaction::types::quorum_driver_types::ExecuteTransactionRequestType; +use identity_iota_interaction::types::transaction::ProgrammableTransaction; +use identity_iota_interaction::types::transaction::Transaction; +use identity_iota_interaction::types::transaction::TransactionData; +use identity_iota_interaction::CoinReadTrait; +use identity_iota_interaction::EventTrait; +use identity_iota_interaction::IotaClient; +use identity_iota_interaction::IotaClientTrait; use identity_iota_interaction::IotaKeySignature; -use identity_iota_interaction::{ - CoinReadTrait, EventTrait, IotaClientTrait, IotaTransactionBlockResponseT, ProgrammableTransactionBcs, - QuorumDriverTrait, ReadTrait, -}; -use identity_iota_interaction::{IotaClient, SignatureBcs, TransactionDataBcs}; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::ProgrammableTransactionBcs; +use identity_iota_interaction::QuorumDriverTrait; +use identity_iota_interaction::ReadTrait; +use identity_iota_interaction::SignatureBcs; +use identity_iota_interaction::TransactionDataBcs; /// The minimum balance required to execute a transaction. pub(crate) const MINIMUM_BALANCE: u64 = 1_000_000_000; diff --git a/identity_iota_core/src/iota_interaction_rust/migration_move_calls.rs b/identity_iota_core/src/iota_interaction_rust/migration_move_calls.rs index fe96f4c71..ff27e79ab 100644 --- a/identity_iota_core/src/iota_interaction_rust/migration_move_calls.rs +++ b/identity_iota_core/src/iota_interaction_rust/migration_move_calls.rs @@ -1,10 +1,13 @@ use identity_iota_interaction::types::programmable_transaction_builder::ProgrammableTransactionBuilder as Ptb; +use identity_iota_interaction::ident_str; use identity_iota_interaction::rpc_types::OwnedObjectRef; -use identity_iota_interaction::types::base_types::{ObjectID, ObjectRef}; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::types::base_types::ObjectRef; use identity_iota_interaction::types::transaction::ObjectArg; use identity_iota_interaction::types::IOTA_FRAMEWORK_PACKAGE_ID; -use identity_iota_interaction::{ident_str, MigrationMoveCalls, ProgrammableTransactionBcs}; +use identity_iota_interaction::MigrationMoveCalls; +use identity_iota_interaction::ProgrammableTransactionBcs; use crate::rebased::Error; diff --git a/identity_iota_core/src/iota_interaction_rust/transaction_builder.rs b/identity_iota_core/src/iota_interaction_rust/transaction_builder.rs index fb0f10b90..9854e1893 100644 --- a/identity_iota_core/src/iota_interaction_rust/transaction_builder.rs +++ b/identity_iota_core/src/iota_interaction_rust/transaction_builder.rs @@ -1,7 +1,8 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::ops::{Deref, DerefMut}; +use std::ops::Deref; +use std::ops::DerefMut; use crate::rebased::Error; use identity_iota_interaction::types::programmable_transaction_builder::ProgrammableTransactionBuilder; diff --git a/identity_iota_core/src/lib.rs b/identity_iota_core/src/lib.rs index 209b95bb8..5793d5cb8 100644 --- a/identity_iota_core/src/lib.rs +++ b/identity_iota_core/src/lib.rs @@ -29,12 +29,12 @@ mod did; mod did_resolution; mod document; mod error; +mod iota_interaction_adapter; mod network; #[cfg(feature = "iota-client")] /// Contains the rebased Identity and the interaction with the IOTA Client. pub mod rebased; mod state_metadata; -mod iota_interaction_adapter; #[cfg(not(target_arch = "wasm32"))] -mod iota_interaction_rust; \ No newline at end of file +mod iota_interaction_rust; diff --git a/identity_iota_core/src/rebased/assets/asset.rs b/identity_iota_core/src/rebased/assets/asset.rs index 7d6a2885a..83901fa4b 100644 --- a/identity_iota_core/src/rebased/assets/asset.rs +++ b/identity_iota_core/src/rebased/assets/asset.rs @@ -4,14 +4,15 @@ use std::str::FromStr as _; use crate::iota_interaction_adapter::AssetMoveCallsAdapter; -use identity_iota_interaction::IotaKeySignature; use crate::rebased::client::IdentityClient; -use crate::rebased::transaction::{TransactionInternal, TransactionOutputInternal}; -use identity_iota_interaction::{AssetMoveCalls, IotaClientTrait, MoveType}; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; use crate::rebased::Error; use anyhow::anyhow; use anyhow::Context; use async_trait::async_trait; +use identity_iota_interaction::ident_str; +use identity_iota_interaction::move_types::language_storage::StructTag; use identity_iota_interaction::rpc_types::IotaData as _; use identity_iota_interaction::rpc_types::IotaExecutionStatus; use identity_iota_interaction::rpc_types::IotaObjectDataOptions; @@ -22,8 +23,10 @@ use identity_iota_interaction::types::base_types::SequenceNumber; use identity_iota_interaction::types::id::UID; use identity_iota_interaction::types::object::Owner; use identity_iota_interaction::types::TypeTag; -use identity_iota_interaction::ident_str; -use identity_iota_interaction::move_types::language_storage::StructTag; +use identity_iota_interaction::AssetMoveCalls; +use identity_iota_interaction::IotaClientTrait; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::MoveType; use secret_storage::Signer; use serde::de::DeserializeOwned; use serde::Deserialize; @@ -63,7 +66,7 @@ where impl AuthenticatedAsset where - T: for<'a> Deserialize<'a>, + T: for<'a> Deserialize<'a>, { /// Resolves an [`AuthenticatedAsset`] by its ID `id`. pub async fn get_by_id(id: ObjectID, client: &IdentityClient) -> Result { @@ -509,12 +512,10 @@ where )?; let tx_result = client.execute_transaction(tx, gas_budget).await?; - let effects_created = tx_result - .effects_created() - .ok_or_else(|| Error::TransactionUnexpectedResponse("could not find effects in transaction response".to_owned()))?; - let created_obj_ids = effects_created - .iter() - .map(|obj| obj.reference.object_id); + let effects_created = tx_result.effects_created().ok_or_else(|| { + Error::TransactionUnexpectedResponse("could not find effects in transaction response".to_owned()) + })?; + let created_obj_ids = effects_created.iter().map(|obj| obj.reference.object_id); for id in created_obj_ids { let object_type = client .read_api() diff --git a/identity_iota_core/src/rebased/assets/public_available_vc.rs b/identity_iota_core/src/rebased/assets/public_available_vc.rs index 5cf6c4631..e110b592c 100644 --- a/identity_iota_core/src/rebased/assets/public_available_vc.rs +++ b/identity_iota_core/src/rebased/assets/public_available_vc.rs @@ -7,10 +7,11 @@ use anyhow::Context as _; use identity_credential::credential::Credential; use identity_credential::credential::Jwt; use identity_credential::credential::JwtCredential; +use identity_iota_interaction::types::base_types::ObjectID; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaVerifiableCredential; use identity_jose::jwt::JwtHeader; use identity_jose::jwu; -use identity_iota_interaction::types::base_types::ObjectID; -use identity_iota_interaction::{IotaKeySignature, IotaVerifiableCredential}; use itertools::Itertools; use secret_storage::Signer; diff --git a/identity_iota_core/src/rebased/client/full_client.rs b/identity_iota_core/src/rebased/client/full_client.rs index 7de74768a..910f0e99f 100644 --- a/identity_iota_core/src/rebased/client/full_client.rs +++ b/identity_iota_core/src/rebased/client/full_client.rs @@ -8,23 +8,27 @@ use crate::IotaDocument; use async_trait::async_trait; use fastcrypto::ed25519::Ed25519PublicKey; use fastcrypto::traits::ToFromBytes; -use identity_verification::jwk::Jwk; +use identity_iota_interaction::move_types::language_storage::StructTag; use identity_iota_interaction::rpc_types::IotaObjectData; use identity_iota_interaction::rpc_types::IotaObjectDataFilter; use identity_iota_interaction::rpc_types::IotaObjectResponseQuery; use identity_iota_interaction::types::base_types::IotaAddress; use identity_iota_interaction::types::base_types::ObjectRef; -use identity_iota_interaction::move_types::language_storage::StructTag; +use identity_verification::jwk::Jwk; use secret_storage::Signer; use serde::de::DeserializeOwned; use serde::Serialize; -use crate::rebased::{rebased_err, Error}; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdaptedTraitObj; use crate::rebased::assets::AuthenticatedAssetBuilder; use crate::rebased::migration::Identity; use crate::rebased::migration::IdentityBuilder; -use identity_iota_interaction::{IotaClientTrait, IotaKeySignature, MoveType, ProgrammableTransactionBcs}; -use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdaptedTraitObj; +use crate::rebased::rebased_err; +use crate::rebased::Error; +use identity_iota_interaction::IotaClientTrait; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::MoveType; +use identity_iota_interaction::ProgrammableTransactionBcs; use crate::rebased::transaction::TransactionOutputInternal; cfg_if::cfg_if! { @@ -91,14 +95,14 @@ impl Deref for IdentityClient { impl IdentityClient where - S: Signer + Sync, + S: Signer + Sync, { /// Create a new [`IdentityClient`]. pub async fn new(client: IdentityClientReadOnly, signer: S) -> Result { let public_key = signer - .public_key() - .await - .map_err(|e| Error::InvalidKey(e.to_string()))?; + .public_key() + .await + .map_err(|e| Error::InvalidKey(e.to_string()))?; let address = convert_to_address(&public_key)?; Ok(Self { @@ -120,13 +124,17 @@ where // which is an IotaClientAdapter instance now, provided via the Deref trait. // TODO: Find a more transparent way to reference the // IotaClientAdapter for readonly. - self.read_client.execute_transaction( - self.sender_address(), - self.sender_public_key(), - tx_bcs, - gas_budget, - self.signer() - ).await.map_err(rebased_err) + self + .read_client + .execute_transaction( + self.sender_address(), + self.sender_public_key(), + tx_bcs, + gas_budget, + self.signer(), + ) + .await + .map_err(rebased_err) } } @@ -154,7 +162,7 @@ impl IdentityClient { /// Returns a new [`IdentityBuilder`] in order to build a new [`crate::rebased::migration::OnChainIdentity`]. pub fn create_authenticated_asset(&self, content: T) -> AuthenticatedAssetBuilder where - T: MoveType + Serialize + DeserializeOwned, + T: MoveType + Serialize + DeserializeOwned, { AuthenticatedAssetBuilder::new(content) } @@ -163,21 +171,21 @@ impl IdentityClient { /// and that satisfies `predicate`. pub async fn find_owned_ref

(&self, tag: StructTag, predicate: P) -> Result, Error> where - P: Fn(&IotaObjectData) -> bool, + P: Fn(&IotaObjectData) -> bool, { let filter = IotaObjectResponseQuery::new_with_filter(IotaObjectDataFilter::StructType(tag)); let mut cursor = None; loop { let mut page = self - .read_api() - .get_owned_objects(self.sender_address(), Some(filter.clone()), cursor, None) - .await?; + .read_api() + .get_owned_objects(self.sender_address(), Some(filter.clone()), cursor, None) + .await?; let obj_ref = std::mem::take(&mut page.data) - .into_iter() - .filter_map(|res| res.data) - .find(|obj| predicate(obj)) - .map(|obj_data| obj_data.object_ref()); + .into_iter() + .filter_map(|res| res.data) + .find(|obj| predicate(obj)) + .map(|obj_data| obj_data.object_ref()); cursor = page.next_cursor; if obj_ref.is_some() { @@ -194,7 +202,7 @@ impl IdentityClient { impl IdentityClient where - S: Signer + Sync, + S: Signer + Sync, { /// Returns [`Transaction`] [`PublishDidTx`] that - when executed - will publish a new DID Document on chain. pub fn publish_did_document(&self, document: IotaDocument) -> PublishDidTx { @@ -209,18 +217,18 @@ where gas_budget: u64, ) -> Result { let mut oci = - if let Identity::FullFledged(value) = self.get_identity(get_object_id_from_did(document.id())?).await? { - value - } else { - return Err(Error::Identity("only new identities can be updated".to_string())); - }; + if let Identity::FullFledged(value) = self.get_identity(get_object_id_from_did(document.id())?).await? { + value + } else { + return Err(Error::Identity("only new identities can be updated".to_string())); + }; oci - .update_did_document(document.clone()) - .finish(self) - .await? - .execute_with_gas(gas_budget, self) - .await?; + .update_did_document(document.clone()) + .finish(self) + .await? + .execute_with_gas(gas_budget, self) + .await?; Ok(document) } @@ -234,11 +242,11 @@ where }; oci - .deactivate_did() - .finish(self) - .await? - .execute_with_gas(gas_budget, self) - .await?; + .deactivate_did() + .finish(self) + .await? + .execute_with_gas(gas_budget, self) + .await?; Ok(()) } @@ -247,18 +255,18 @@ where /// Utility function that returns the key's bytes of a JWK encoded public ed25519 key. pub fn get_sender_public_key(sender_public_jwk: &Jwk) -> Result, Error> { let public_key_base_64 = &sender_public_jwk - .try_okp_params() - .map_err(|err| Error::InvalidKey(format!("key not of type `Okp`; {err}")))? - .x; + .try_okp_params() + .map_err(|err| Error::InvalidKey(format!("key not of type `Okp`; {err}")))? + .x; identity_jose::jwu::decode_b64(public_key_base_64) - .map_err(|err| Error::InvalidKey(format!("could not decode base64 public key; {err}"))) + .map_err(|err| Error::InvalidKey(format!("could not decode base64 public key; {err}"))) } /// Utility function to convert a public key's bytes into an [`IotaAddress`]. pub fn convert_to_address(sender_public_key: &[u8]) -> Result { let public_key = Ed25519PublicKey::from_bytes(sender_public_key) - .map_err(|err| Error::InvalidKey(format!("could not parse public key to Ed25519 public key; {err}")))?; + .map_err(|err| Error::InvalidKey(format!("could not parse public key to Ed25519 public key; {err}")))?; Ok(IotaAddress::from(&public_key)) } @@ -275,16 +283,16 @@ impl PublishDidTx { client: &IdentityClient, ) -> Result, Error> where - S: Signer + Sync, + S: Signer + Sync, { let TransactionOutputInternal { output: identity, response, } = client - .create_identity(self.0) - .finish() - .execute_with_opt_gas_internal(gas_budget, client) - .await?; + .create_identity(self.0) + .finish() + .execute_with_opt_gas_internal(gas_budget, client) + .await?; Ok(TransactionOutputInternal { output: identity.did_doc, @@ -306,12 +314,13 @@ impl TransactionT for PublishDidTx { client: &IdentityClient, ) -> Result, Error> where - S: Signer + Sync, + S: Signer + Sync, { Ok( - self.execute_publish_did_tx_with_opt_gas(gas_budget, client) - .await? - .into() + self + .execute_publish_did_tx_with_opt_gas(gas_budget, client) + .await? + .into(), ) } @@ -322,8 +331,8 @@ impl TransactionT for PublishDidTx { client: &IdentityClient, ) -> Result, Error> where - S: Signer + Sync, + S: Signer + Sync, { self.execute_publish_did_tx_with_opt_gas(gas_budget, client).await } -} \ No newline at end of file +} diff --git a/identity_iota_core/src/rebased/client/mod.rs b/identity_iota_core/src/rebased/client/mod.rs index 95d0f4e70..d5b4f76b5 100644 --- a/identity_iota_core/src/rebased/client/mod.rs +++ b/identity_iota_core/src/rebased/client/mod.rs @@ -7,4 +7,4 @@ mod read_only; pub use full_client::*; pub use read_only::*; -pub use identity_iota_interaction::IotaKeySignature; \ No newline at end of file +pub use identity_iota_interaction::IotaKeySignature; diff --git a/identity_iota_core/src/rebased/client/read_only.rs b/identity_iota_core/src/rebased/client/read_only.rs index 3930b2e2d..df2ee8308 100644 --- a/identity_iota_core/src/rebased/client/read_only.rs +++ b/identity_iota_core/src/rebased/client/read_only.rs @@ -14,9 +14,16 @@ use anyhow::anyhow; use anyhow::Context as _; use futures::stream::FuturesUnordered; +use crate::iota_interaction_adapter::IotaClientAdapter; +use crate::rebased::migration::get_alias; +use crate::rebased::migration::get_identity; +use crate::rebased::migration::lookup; +use crate::rebased::migration::Identity; +use crate::rebased::Error; use futures::StreamExt as _; use identity_core::common::Url; use identity_did::DID; +use identity_iota_interaction::move_types::language_storage::StructTag; use identity_iota_interaction::rpc_types::EventFilter; use identity_iota_interaction::rpc_types::IotaData as _; use identity_iota_interaction::rpc_types::IotaObjectData; @@ -28,15 +35,8 @@ use identity_iota_interaction::types::base_types::IotaAddress; use identity_iota_interaction::types::base_types::ObjectID; use identity_iota_interaction::types::base_types::ObjectRef; use identity_iota_interaction::IotaClientTrait; -use crate::iota_interaction_adapter::IotaClientAdapter; -use identity_iota_interaction::move_types::language_storage::StructTag; use serde::de::DeserializeOwned; use serde::Deserialize; -use crate::rebased::migration::get_alias; -use crate::rebased::migration::get_identity; -use crate::rebased::migration::lookup; -use crate::rebased::migration::Identity; -use crate::rebased::Error; #[cfg(not(target_arch = "wasm32"))] use identity_iota_interaction::IotaClient; @@ -131,7 +131,10 @@ impl IdentityClientReadOnly { } } - async fn new_with_pkg_id_internal(iota_client: IotaClientAdapter, iota_identity_pkg_id: ObjectID) -> Result { + async fn new_with_pkg_id_internal( + iota_client: IotaClientAdapter, + iota_identity_pkg_id: ObjectID, + ) -> Result { let IdentityPkgMetadata { migration_registry_id, .. } = identity_pkg_metadata(&iota_client, iota_identity_pkg_id).await?; @@ -271,7 +274,10 @@ struct MigrationRegistryCreatedEvent { // TODO: remove argument `package_id` and use `EventFilter::MoveEventField` to find the beacon event and thus the // package id. // TODO: authenticate the beacon event with though sender's ID. -async fn identity_pkg_metadata(iota_client: &IotaClientAdapter, package_id: ObjectID) -> Result { +async fn identity_pkg_metadata( + iota_client: &IotaClientAdapter, + package_id: ObjectID, +) -> Result { // const EVENT_BEACON_PATH: &str = "/beacon"; // const EVENT_BEACON_VALUE: &[u8] = b"identity.rs_pkg"; diff --git a/identity_iota_core/src/rebased/error.rs b/identity_iota_core/src/rebased/error.rs index f784eaeba..9e4ea6a74 100644 --- a/identity_iota_core/src/rebased/error.rs +++ b/identity_iota_core/src/rebased/error.rs @@ -82,6 +82,9 @@ pub enum Error { /// Can be used for example like `map_err(rebased_err)` to convert other error /// types to identity_iota_core::rebased::Error. -pub fn rebased_err(error: T) -> Error where Error: From { +pub fn rebased_err(error: T) -> Error +where + Error: From, +{ error.into() } diff --git a/identity_iota_core/src/rebased/migration/alias.rs b/identity_iota_core/src/rebased/migration/alias.rs index 4de10020b..463286ab7 100644 --- a/identity_iota_core/src/rebased/migration/alias.rs +++ b/identity_iota_core/src/rebased/migration/alias.rs @@ -14,14 +14,17 @@ use serde; use serde::Deserialize; use serde::Serialize; -use identity_iota_interaction::{MigrationMoveCalls, ProgrammableTransactionBcs}; -use identity_iota_interaction::IotaKeySignature; use crate::iota_interaction_adapter::MigrationMoveCallsAdapter; use crate::rebased::client::IdentityClient; use crate::rebased::client::IdentityClientReadOnly; -use crate::rebased::transaction::{TransactionInternal, TransactionOutputInternal}; -use identity_iota_interaction::{IotaClientTrait, MoveType}; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; use crate::rebased::Error; +use identity_iota_interaction::IotaClientTrait; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::MigrationMoveCalls; +use identity_iota_interaction::MoveType; +use identity_iota_interaction::ProgrammableTransactionBcs; use super::get_identity; use super::Identity; @@ -67,8 +70,6 @@ pub async fn get_alias(client: &IdentityClientReadOnly, object_id: ObjectID) -> } } - - cfg_if::cfg_if! { if #[cfg(target_arch = "wasm32")] { // Add wasm32 compatible migrate() function wrapper here @@ -139,9 +140,13 @@ impl UnmigratedAlias { .map(|timestamp| timestamp.to_unix() as u64 * 1000); // Build migration tx. - let tx = - MigrationMoveCallsAdapter::migrate_did_output(alias_output_ref, created, migration_registry_ref, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = MigrationMoveCallsAdapter::migrate_did_output( + alias_output_ref, + created, + migration_registry_ref, + client.package_id(), + ) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(MigrateLegacyAliasTx(tx)) } diff --git a/identity_iota_core/src/rebased/migration/identity.rs b/identity_iota_core/src/rebased/migration/identity.rs index b3d77cdd1..7935413c8 100644 --- a/identity_iota_core/src/rebased/migration/identity.rs +++ b/identity_iota_core/src/rebased/migration/identity.rs @@ -18,6 +18,8 @@ use crate::StateMetadataDocument; use crate::StateMetadataEncoding; use async_trait::async_trait; use identity_core::common::Timestamp; +use identity_iota_interaction::ident_str; +use identity_iota_interaction::move_types::language_storage::StructTag; use identity_iota_interaction::rpc_types::IotaObjectData; use identity_iota_interaction::rpc_types::IotaObjectDataOptions; use identity_iota_interaction::rpc_types::IotaParsedData; @@ -27,12 +29,10 @@ use identity_iota_interaction::rpc_types::OwnedObjectRef; use identity_iota_interaction::types::base_types::IotaAddress; use identity_iota_interaction::types::base_types::ObjectID; use identity_iota_interaction::types::base_types::ObjectRef; -use identity_iota_interaction::IotaKeySignature; use identity_iota_interaction::types::id::UID; use identity_iota_interaction::types::object::Owner; use identity_iota_interaction::types::TypeTag; -use identity_iota_interaction::ident_str; -use identity_iota_interaction::move_types::language_storage::StructTag; +use identity_iota_interaction::IotaKeySignature; use secret_storage::Signer; use serde; use serde::Deserialize; @@ -47,9 +47,12 @@ use crate::rebased::proposals::DeactivateDid; use crate::rebased::proposals::ProposalBuilder; use crate::rebased::proposals::SendAction; use crate::rebased::proposals::UpdateDidDocument; -use crate::rebased::transaction::{TransactionInternal, TransactionOutputInternal}; -use identity_iota_interaction::{IotaClientTrait, MoveType}; -use crate::rebased::{rebased_err, Error}; +use crate::rebased::rebased_err; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; +use crate::rebased::Error; +use identity_iota_interaction::IotaClientTrait; +use identity_iota_interaction::MoveType; use super::Multicontroller; use super::UnmigratedAlias; @@ -479,8 +482,9 @@ impl TransactionInternal for CreateIdentityTx { let response = client.execute_transaction(programmable_transaction, gas_budget).await?; - let created = response.effects_created() - .ok_or_else(|| Error::TransactionUnexpectedResponse("could not find effects_created in transaction".to_string()))?; + let created = response.effects_created().ok_or_else(|| { + Error::TransactionUnexpectedResponse("could not find effects_created in transaction".to_string()) + })?; let new_identities: Vec = created .into_iter() .filter(|elem| { @@ -496,7 +500,8 @@ impl TransactionInternal for CreateIdentityTx { [value] => value.object_id(), _ => { return Err(Error::TransactionUnexpectedResponse(format!( - "could not find new identity in response: {}", response.to_string() + "could not find new identity in response: {}", + response.to_string() ))); } }; diff --git a/identity_iota_core/src/rebased/migration/registry.rs b/identity_iota_core/src/rebased/migration/registry.rs index ada3425d4..196cf15e1 100644 --- a/identity_iota_core/src/rebased/migration/registry.rs +++ b/identity_iota_core/src/rebased/migration/registry.rs @@ -1,10 +1,10 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use identity_iota_interaction::IotaClientTrait; use identity_iota_interaction::rpc_types::IotaData; use identity_iota_interaction::types::base_types::ObjectID; use identity_iota_interaction::types::id::ID; +use identity_iota_interaction::IotaClientTrait; use crate::rebased::client::IdentityClientReadOnly; @@ -27,10 +27,7 @@ pub enum Error { /// Lookup a legacy `alias_id` into the migration registry /// to get the UID of the corresponding migrated DID document if any. -pub async fn lookup( - id_client: &IdentityClientReadOnly, - alias_id: ObjectID, -) -> Result, Error> { +pub async fn lookup(id_client: &IdentityClientReadOnly, alias_id: ObjectID) -> Result, Error> { let dynamic_field_name = serde_json::from_value(serde_json::json!({ "type": "0x2::object::ID", "value": alias_id.to_string() diff --git a/identity_iota_core/src/rebased/proposals/borrow.rs b/identity_iota_core/src/rebased/proposals/borrow.rs index cf79cf7dc..8523bd8ba 100644 --- a/identity_iota_core/src/rebased/proposals/borrow.rs +++ b/identity_iota_core/src/rebased/proposals/borrow.rs @@ -4,19 +4,27 @@ use std::collections::HashMap; use std::marker::PhantomData; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaKeySignature, IotaTransactionBlockResponseT, TransactionBuilderT}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::TransactionBuilderT; use crate::rebased::client::IdentityClient; use crate::rebased::migration::Proposal; -use crate::rebased::transaction::{ProtoTransaction, TransactionInternal, TransactionOutputInternal}; -use identity_iota_interaction::MoveType; +use crate::rebased::transaction::ProtoTransaction; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; use crate::rebased::Error; use async_trait::async_trait; use identity_iota_interaction::rpc_types::IotaObjectData; use identity_iota_interaction::types::base_types::ObjectID; use identity_iota_interaction::types::transaction::Argument; use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::MoveType; use secret_storage::Signer; use serde::Deserialize; use serde::Serialize; @@ -162,7 +170,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } @@ -233,7 +243,8 @@ where object_data_list }; - let intent_adapter = move |ptb: &mut dyn TransactionBuilderT, args: &HashMap| { + let intent_adapter = move |ptb: &mut dyn TransactionBuilderT, + args: &HashMap| { (borrow_action.intent_fn)(ptb.as_native_tx_builder(), args) }; diff --git a/identity_iota_core/src/rebased/proposals/config_change.rs b/identity_iota_core/src/rebased/proposals/config_change.rs index 0126ca0a5..57f76ab5f 100644 --- a/identity_iota_core/src/rebased/proposals/config_change.rs +++ b/identity_iota_core/src/rebased/proposals/config_change.rs @@ -7,9 +7,14 @@ use std::marker::PhantomData; use std::ops::DerefMut as _; use std::str::FromStr as _; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, OptionalSync}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSync; use crate::rebased::client::IdentityClient; use crate::rebased::migration::Proposal; @@ -25,8 +30,8 @@ use serde::Serialize; use crate::rebased::iota::types::Number; use crate::rebased::migration::OnChainIdentity; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; use super::CreateProposalTx; use super::ExecuteProposalTx; @@ -238,9 +243,13 @@ impl ProposalT for Proposal { .expect("identity exists on-chain"); let controller_cap_ref = identity.get_controller_cap(client).await?; - let tx = - IdentityMoveCallsAdapter::execute_config_change(identity_ref, controller_cap_ref, proposal_id, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = IdentityMoveCallsAdapter::execute_config_change( + identity_ref, + controller_cap_ref, + proposal_id, + client.package_id(), + ) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(ExecuteProposalTx { identity, @@ -249,7 +258,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } diff --git a/identity_iota_core/src/rebased/proposals/controller.rs b/identity_iota_core/src/rebased/proposals/controller.rs index 787365039..0d4e5b1ab 100644 --- a/identity_iota_core/src/rebased/proposals/controller.rs +++ b/identity_iota_core/src/rebased/proposals/controller.rs @@ -3,14 +3,20 @@ use std::marker::PhantomData; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, TransactionBuilderT}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::TransactionBuilderT; use crate::rebased::client::IdentityClient; use crate::rebased::migration::Proposal; -use crate::rebased::transaction::{ProtoTransaction, TransactionInternal, TransactionOutputInternal}; -use identity_iota_interaction::MoveType; +use crate::rebased::transaction::ProtoTransaction; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; use crate::rebased::Error; use async_trait::async_trait; use identity_iota_interaction::rpc_types::IotaObjectRef; @@ -19,6 +25,7 @@ use identity_iota_interaction::types::base_types::IotaAddress; use identity_iota_interaction::types::base_types::ObjectID; use identity_iota_interaction::types::transaction::Argument; use identity_iota_interaction::types::TypeTag; +use identity_iota_interaction::MoveType; use secret_storage::Signer; use serde::Deserialize; use serde::Serialize; @@ -146,7 +153,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } @@ -219,7 +228,8 @@ where }) .ok_or_else(|| Error::ObjectLookup(format!("object {borrowing_cap_id} doesn't exist")))?; - let intent_adapter = move |ptb: &mut dyn TransactionBuilderT, arg: &Argument| { + let intent_adapter = move |ptb: &mut dyn TransactionBuilderT, + arg: &Argument| { (action.intent_fn)(ptb.as_native_tx_builder(), arg) }; diff --git a/identity_iota_core/src/rebased/proposals/deactivate_did.rs b/identity_iota_core/src/rebased/proposals/deactivate_did.rs index 956bc8f9a..f72ddd043 100644 --- a/identity_iota_core/src/rebased/proposals/deactivate_did.rs +++ b/identity_iota_core/src/rebased/proposals/deactivate_did.rs @@ -3,9 +3,14 @@ use std::marker::PhantomData; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, OptionalSync}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSync; use crate::rebased::client::IdentityClient; use async_trait::async_trait; @@ -17,8 +22,8 @@ use serde::Serialize; use crate::rebased::migration::OnChainIdentity; use crate::rebased::migration::Proposal; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; use super::CreateProposalTx; use super::ExecuteProposalTx; @@ -69,7 +74,7 @@ impl ProposalT for Proposal { .expect("controller exists"); let chained_execution = sender_vp >= identity.threshold(); let tx = - IdentityMoveCallsAdapter::propose_deactivation(identity_ref, controller_cap_ref, expiration, client.package_id()) + IdentityMoveCallsAdapter::propose_deactivation(identity_ref, controller_cap_ref, expiration, client.package_id()) .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(CreateProposalTx { @@ -95,9 +100,13 @@ impl ProposalT for Proposal { .expect("identity exists on-chain"); let controller_cap_ref = identity.get_controller_cap(client).await?; - let tx = - IdentityMoveCallsAdapter::execute_deactivation(identity_ref, controller_cap_ref, proposal_id, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = IdentityMoveCallsAdapter::execute_deactivation( + identity_ref, + controller_cap_ref, + proposal_id, + client.package_id(), + ) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(ExecuteProposalTx { identity, @@ -106,7 +115,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } diff --git a/identity_iota_core/src/rebased/proposals/mod.rs b/identity_iota_core/src/rebased/proposals/mod.rs index 471793491..c35c295d2 100644 --- a/identity_iota_core/src/rebased/proposals/mod.rs +++ b/identity_iota_core/src/rebased/proposals/mod.rs @@ -18,16 +18,23 @@ cfg_if::cfg_if! { use identity_iota_interaction::rpc_types::IotaTransactionBlockResponse; } } +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; -use crate::iota_interaction_adapter::{IdentityMoveCallsAdapter}; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse}; -use identity_iota_interaction::{IdentityMoveCalls, IotaClientTrait, IotaTransactionBlockResponseT, OptionalSend, ProgrammableTransactionBcs}; +use identity_iota_interaction::IdentityMoveCalls; +use identity_iota_interaction::IotaClientTrait; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSend; +use identity_iota_interaction::ProgrammableTransactionBcs; use crate::rebased::client::IdentityClientReadOnly; use crate::rebased::migration::get_identity; -use crate::rebased::transaction::{ProtoTransaction, TransactionInternal, TransactionOutputInternal}; +use crate::rebased::transaction::ProtoTransaction; +use crate::rebased::transaction::TransactionInternal; +use crate::rebased::transaction::TransactionOutputInternal; use async_trait::async_trait; pub use borrow::*; pub use config_change::*; @@ -49,8 +56,8 @@ pub use upgrade::*; use crate::rebased::client::IdentityClient; use crate::rebased::migration::OnChainIdentity; use crate::rebased::migration::Proposal; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; /// Interface that allows the creation and execution of an [`OnChainIdentity`]'s [`Proposal`]s. #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] @@ -61,7 +68,7 @@ pub trait ProposalT { /// The output of the [`Proposal`] type Output; /// Platform-agnostic type of the IotaTransactionBlockResponse - type Response: IotaTransactionBlockResponseT; + type Response: IotaTransactionBlockResponseT; /// Creates a new [`Proposal`] with the provided action and expiration. async fn create<'i, S>( @@ -90,7 +97,9 @@ pub trait ProposalT { } /// For internal platform-agnostic usage only. - fn parse_tx_effects_internal(tx_response: &dyn IotaTransactionBlockResponseT) -> Result; + fn parse_tx_effects_internal( + tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result; } impl Proposal { diff --git a/identity_iota_core/src/rebased/proposals/send.rs b/identity_iota_core/src/rebased/proposals/send.rs index 69627708f..0f321a89b 100644 --- a/identity_iota_core/src/rebased/proposals/send.rs +++ b/identity_iota_core/src/rebased/proposals/send.rs @@ -12,14 +12,19 @@ use secret_storage::Signer; use serde::Deserialize; use serde::Serialize; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, OptionalSync}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSync; use crate::rebased::client::IdentityClient; use crate::rebased::migration::OnChainIdentity; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; use super::CreateProposalTx; use super::ExecuteProposalTx; @@ -164,7 +169,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } diff --git a/identity_iota_core/src/rebased/proposals/update_did_doc.rs b/identity_iota_core/src/rebased/proposals/update_did_doc.rs index c85b3e3a2..3e6ed7fd9 100644 --- a/identity_iota_core/src/rebased/proposals/update_did_doc.rs +++ b/identity_iota_core/src/rebased/proposals/update_did_doc.rs @@ -3,9 +3,14 @@ use std::marker::PhantomData; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, OptionalSync}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSync; use crate::rebased::client::IdentityClient; use crate::IotaDocument; @@ -18,8 +23,8 @@ use serde::Serialize; use crate::rebased::migration::OnChainIdentity; use crate::rebased::migration::Proposal; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; use super::CreateProposalTx; use super::ExecuteProposalTx; @@ -102,8 +107,9 @@ impl ProposalT for Proposal { .expect("identity exists on-chain"); let controller_cap_ref = identity.get_controller_cap(client).await?; - let tx = IdentityMoveCallsAdapter::execute_update(identity_ref, controller_cap_ref, proposal_id, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = + IdentityMoveCallsAdapter::execute_update(identity_ref, controller_cap_ref, proposal_id, client.package_id()) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(ExecuteProposalTx { identity, @@ -112,7 +118,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } diff --git a/identity_iota_core/src/rebased/proposals/upgrade.rs b/identity_iota_core/src/rebased/proposals/upgrade.rs index 0a8b06259..db796853d 100644 --- a/identity_iota_core/src/rebased/proposals/upgrade.rs +++ b/identity_iota_core/src/rebased/proposals/upgrade.rs @@ -3,9 +3,14 @@ use std::marker::PhantomData; -use crate::iota_interaction_adapter::{AdapterError, AdapterNativeResponse, IdentityMoveCallsAdapter, IotaTransactionBlockResponseAdapter}; -use identity_iota_interaction::{IdentityMoveCalls, IotaTransactionBlockResponseT, OptionalSync}; +use crate::iota_interaction_adapter::AdapterError; +use crate::iota_interaction_adapter::AdapterNativeResponse; +use crate::iota_interaction_adapter::IdentityMoveCallsAdapter; +use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdapter; +use identity_iota_interaction::IdentityMoveCalls; use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::IotaTransactionBlockResponseT; +use identity_iota_interaction::OptionalSync; use crate::rebased::client::IdentityClient; use async_trait::async_trait; @@ -17,8 +22,8 @@ use serde::Serialize; use crate::rebased::migration::OnChainIdentity; use crate::rebased::migration::Proposal; -use identity_iota_interaction::MoveType; use crate::rebased::Error; +use identity_iota_interaction::MoveType; use super::CreateProposalTx; use super::ExecuteProposalTx; @@ -70,8 +75,9 @@ impl ProposalT for Proposal { .controller_voting_power(controller_cap_ref.0) .expect("controller exists"); let chained_execution = sender_vp >= identity.threshold(); - let tx = IdentityMoveCallsAdapter::propose_upgrade(identity_ref, controller_cap_ref, expiration, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = + IdentityMoveCallsAdapter::propose_upgrade(identity_ref, controller_cap_ref, expiration, client.package_id()) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(CreateProposalTx { identity, @@ -96,8 +102,9 @@ impl ProposalT for Proposal { .expect("identity exists on-chain"); let controller_cap_ref = identity.get_controller_cap(client).await?; - let tx = IdentityMoveCallsAdapter::execute_upgrade(identity_ref, controller_cap_ref, proposal_id, client.package_id()) - .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; + let tx = + IdentityMoveCallsAdapter::execute_upgrade(identity_ref, controller_cap_ref, proposal_id, client.package_id()) + .map_err(|e| Error::TransactionBuildingFailed(e.to_string()))?; Ok(ExecuteProposalTx { identity, @@ -106,7 +113,9 @@ impl ProposalT for Proposal { }) } - fn parse_tx_effects_internal(_tx_response: &dyn IotaTransactionBlockResponseT) -> Result { + fn parse_tx_effects_internal( + _tx_response: &dyn IotaTransactionBlockResponseT, + ) -> Result { Ok(()) } } diff --git a/identity_iota_core/src/rebased/transaction.rs b/identity_iota_core/src/rebased/transaction.rs index 95c98989d..2b59b5288 100644 --- a/identity_iota_core/src/rebased/transaction.rs +++ b/identity_iota_core/src/rebased/transaction.rs @@ -6,16 +6,17 @@ use std::ops::Deref; #[cfg(not(target_arch = "wasm32"))] use identity_iota_interaction::rpc_types::IotaTransactionBlockResponse; #[cfg(not(target_arch = "wasm32"))] -use identity_iota_interaction::types::transaction::{ProgrammableTransaction}; +use identity_iota_interaction::types::transaction::ProgrammableTransaction; #[cfg(target_arch = "wasm32")] use iota_interaction_ts::ProgrammableTransaction; -use async_trait::async_trait; -use identity_iota_interaction::{IotaKeySignature, ProgrammableTransactionBcs}; use crate::iota_interaction_adapter::IotaTransactionBlockResponseAdaptedTraitObj; -use secret_storage::Signer; use crate::rebased::client::IdentityClient; use crate::rebased::Error; +use async_trait::async_trait; +use identity_iota_interaction::IotaKeySignature; +use identity_iota_interaction::ProgrammableTransactionBcs; +use secret_storage::Signer; /// The output type of a [`Transaction`]. #[cfg(not(target_arch = "wasm32"))] @@ -86,13 +87,10 @@ impl From> for TransactionOutput { fn from(value: TransactionOutputInternal) -> Self { let TransactionOutputInternal:: { output: out, - response: internal_response + response: internal_response, } = value; let response = internal_response.clone_native_response(); - TransactionOutput { - output: out, - response, - } + TransactionOutput { output: out, response } } } @@ -128,7 +126,7 @@ pub(crate) trait TransactionInternal: Sized { #[cfg(not(target_arch = "wasm32"))] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] -impl + Send, O> Transaction for T { +impl + Send, O> Transaction for T { type Output = O; async fn execute_with_opt_gas + Sync>( @@ -185,15 +183,13 @@ impl TransactionInternal for ProgrammableTransactionBcs { async fn execute_with_opt_gas_internal + Sync>( self, gas_budget: Option, - client: &IdentityClient + client: &IdentityClient, ) -> Result, Error> { // For wasm32 targets, the following line will result in a compiler error[E0412] // TODO: Implement wasm-bindings for the ProgrammableTransaction TS equivalent // and use them to do the BCS serialization let self_tx = bcs::from_bytes::(&self)?; - self_tx - .execute_with_opt_gas_internal(gas_budget, client) - .await + self_tx.execute_with_opt_gas_internal(gas_budget, client).await } } diff --git a/identity_iota_core/src/rebased/utils.rs b/identity_iota_core/src/rebased/utils.rs index d1dcdad87..f48eb9144 100644 --- a/identity_iota_core/src/rebased/utils.rs +++ b/identity_iota_core/src/rebased/utils.rs @@ -9,8 +9,8 @@ use serde::Deserialize; #[cfg(not(target_arch = "wasm32"))] use tokio::process::Command; -use identity_iota_interaction::types::base_types::IotaAddress; use crate::rebased::Error; +use identity_iota_interaction::types::base_types::IotaAddress; const FUND_WITH_ACTIVE_ADDRESS_FUNDING_TX_BUDGET: u64 = 5_000_000; const FUND_WITH_ACTIVE_ADDRESS_FUNDING_VALUE: u64 = 500_000_000; @@ -108,4 +108,4 @@ pub async fn request_funds(address: &IotaAddress) -> anyhow::Result<()> { } Ok(()) -} \ No newline at end of file +} diff --git a/identity_iota_core/tests/e2e/asset.rs b/identity_iota_core/tests/e2e/asset.rs index 10ad77df0..ddab27ba2 100644 --- a/identity_iota_core/tests/e2e/asset.rs +++ b/identity_iota_core/tests/e2e/asset.rs @@ -15,13 +15,13 @@ use identity_credential::validator::JwtCredentialValidator; use identity_document::document::CoreDocument; use identity_eddsa_verifier::EdDSAJwsVerifier; use identity_iota_core::rebased::transaction::Transaction; -use identity_iota_interaction::MoveType as _; use identity_iota_core::rebased::AuthenticatedAsset; use identity_iota_core::rebased::PublicAvailableVC; use identity_iota_core::rebased::TransferProposal; use identity_iota_core::IotaDID; use identity_iota_core::IotaDocument; use identity_iota_interaction::IotaClientTrait; +use identity_iota_interaction::MoveType as _; use identity_storage::JwkDocumentExt; use identity_storage::JwsSignatureOptions; use identity_verification::VerificationMethod; diff --git a/identity_iota_core/tests/e2e/common.rs b/identity_iota_core/tests/e2e/common.rs index b773bda46..0edb20502 100644 --- a/identity_iota_core/tests/e2e/common.rs +++ b/identity_iota_core/tests/e2e/common.rs @@ -6,10 +6,10 @@ use anyhow::anyhow; use anyhow::Context; use identity_iota_core::rebased::client::IdentityClient; use identity_iota_core::rebased::client::IdentityClientReadOnly; -use identity_iota_interaction::IotaKeySignature; use identity_iota_core::rebased::transaction::Transaction; use identity_iota_core::rebased::utils::request_funds; use identity_iota_core::IotaDID; +use identity_iota_interaction::IotaKeySignature; use identity_jose::jwk::Jwk; use identity_jose::jws::JwsAlgorithm; use identity_storage::JwkMemStore;