Skip to content

Commit

Permalink
Fix rustfmt issues for bindings/wasm/iota_interaction_ts and identity…
Browse files Browse the repository at this point in the history
…_iota_core
  • Loading branch information
chrisgitiota committed Jan 8, 2025
1 parent 1cc7e25 commit 59f02b9
Show file tree
Hide file tree
Showing 37 changed files with 666 additions and 513 deletions.
126 changes: 64 additions & 62 deletions bindings/wasm/iota_interaction_ts/src/asset_move_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Serialize + MoveType>(
inner: T,
mutable: bool,
transferable: bool,
deletable: bool,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
fn new_asset<T: Serialize + MoveType>(
inner: T,
mutable: bool,
transferable: bool,
deletable: bool,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn delete<T: MoveType>(asset: ObjectRef, package: ObjectID) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
fn delete<T: MoveType>(asset: ObjectRef, package: ObjectID) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn transfer<T: MoveType>(
asset: ObjectRef,
recipient: IotaAddress,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
fn transfer<T: MoveType>(
asset: ObjectRef,
recipient: IotaAddress,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn make_tx(
proposal: (ObjectID, SequenceNumber),
cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
function_name: &'static str,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
fn make_tx(
proposal: (ObjectID, SequenceNumber),
cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
function_name: &'static str,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn accept_proposal(
proposal: (ObjectID, SequenceNumber),
recipient_cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
fn accept_proposal(
proposal: (ObjectID, SequenceNumber),
recipient_cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn conclude_or_cancel(
proposal: (ObjectID, SequenceNumber),
sender_cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error>{
unimplemented!();
}
fn conclude_or_cancel(
proposal: (ObjectID, SequenceNumber),
sender_cap: ObjectRef,
asset: ObjectRef,
asset_type_param: TypeTag,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}

fn update<T: MoveType + Serialize>(asset: ObjectRef, new_content: T, package: ObjectID)
-> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
}
fn update<T: MoveType + Serialize>(
asset: ObjectRef,
new_content: T,
package: ObjectID,
) -> Result<ProgrammableTransactionBcs, Self::Error> {
unimplemented!();
}
}
4 changes: 2 additions & 2 deletions bindings/wasm/iota_interaction_ts/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
2 changes: 1 addition & 1 deletion bindings/wasm/iota_interaction_ts/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pub mod types;
pub mod utils;

pub use types::*;
pub use utils::*;
pub use utils::*;
11 changes: 7 additions & 4 deletions bindings/wasm/iota_interaction_ts/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsValue>>(wasm_type_instance: W) -> core::result::Result<T, WasmError<'a>> {
pub fn into_sdk_type<'a, T: DeserializeOwned, W: Into<JsValue>>(
wasm_type_instance: W,
) -> core::result::Result<T, WasmError<'a>> {
let js_value: JsValue = wasm_type_instance.into();
match serde_wasm_bindgen::from_value::<T>(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: {:?}",
Expand All @@ -21,4 +24,4 @@ pub fn into_sdk_type<'a, T: DeserializeOwned, W: Into<JsValue>>(wasm_type_instan
Err(e.into())
}
}
}
}
11 changes: 7 additions & 4 deletions bindings/wasm/iota_interaction_ts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, JsValue>`.
///
Expand Down Expand Up @@ -206,4 +209,4 @@ pub fn into_ts_sdk_result<T: DeserializeOwned>(result: Result<JsValue>) -> TsSdk
let js_value = result_str.map_err(|e| TsSdkError::JsSysError(e))?;
let ret_val: T = into_sdk_type(js_value)?;
Ok(ret_val)
}
}
Loading

0 comments on commit 59f02b9

Please sign in to comment.