Skip to content

Commit

Permalink
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Browse files Browse the repository at this point in the history
  • Loading branch information
Brord van Wierst committed Nov 10, 2023
2 parents a225a03 + b1762a3 commit 72a5c32
Show file tree
Hide file tree
Showing 165 changed files with 6,819 additions and 5,674 deletions.
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
resolver = "2"
members = [
"bindings/core",
# TODO: issue #1424
#"bindings/nodejs",
"bindings/nodejs",
# TODO: issue #1423
#"bindings/python",
# TODO: issue #1425
Expand Down
35 changes: 26 additions & 9 deletions bindings/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use fern_logger::{logger_init, LoggerConfig, LoggerOutputConfigBuilder};
pub use iota_sdk;
use iota_sdk::{
client::secret::{SecretManager, SecretManagerDto},
types::block::address::Bech32Address,
utils::serde::bip44::option_bip44,
wallet::{ClientOptions, Wallet},
};
use serde::Deserialize;
Expand All @@ -27,7 +29,7 @@ pub use self::method_handler::listen_mqtt;
pub use self::method_handler::CallMethod;
pub use self::{
error::{Error, Result},
method::{ClientMethod, SecretManagerMethod, UtilsMethod, WalletCommandMethod, WalletMethod},
method::{ClientMethod, SecretManagerMethod, UtilsMethod, WalletMethod},
method_handler::{call_client_method, call_secret_manager_method, call_utils_method, call_wallet_method},
response::Response,
};
Expand All @@ -42,21 +44,24 @@ pub fn init_logger(config: String) -> std::result::Result<(), fern_logger::Error
#[derivative(Debug)]
#[serde(rename_all = "camelCase")]
pub struct WalletOptions {
pub storage_path: Option<String>,
pub client_options: Option<ClientOptions>,
pub address: Option<Bech32Address>,
pub alias: Option<String>,
#[serde(with = "option_bip44", default)]
pub bip_path: Option<Bip44>,
pub client_options: Option<ClientOptions>,
#[derivative(Debug(format_with = "OmittedDebug::omitted_fmt"))]
pub secret_manager: Option<SecretManagerDto>,
pub storage_path: Option<String>,
}

impl WalletOptions {
pub fn with_storage_path(mut self, storage_path: impl Into<Option<String>>) -> Self {
self.storage_path = storage_path.into();
pub fn with_address(mut self, address: impl Into<Option<Bech32Address>>) -> Self {
self.address = address.into();
self
}

pub fn with_client_options(mut self, client_options: impl Into<Option<ClientOptions>>) -> Self {
self.client_options = client_options.into();
pub fn with_alias(mut self, alias: impl Into<Option<String>>) -> Self {
self.alias = alias.into();
self
}

Expand All @@ -65,16 +70,28 @@ impl WalletOptions {
self
}

pub fn with_client_options(mut self, client_options: impl Into<Option<ClientOptions>>) -> Self {
self.client_options = client_options.into();
self
}

pub fn with_secret_manager(mut self, secret_manager: impl Into<Option<SecretManagerDto>>) -> Self {
self.secret_manager = secret_manager.into();
self
}

pub fn with_storage_path(mut self, storage_path: impl Into<Option<String>>) -> Self {
self.storage_path = storage_path.into();
self
}

pub async fn build(self) -> iota_sdk::wallet::Result<Wallet> {
log::debug!("wallet options: {self:?}");
let mut builder = Wallet::builder()
.with_client_options(self.client_options)
.with_bip_path(self.bip_path);
.with_address(self.address)
.with_alias(self.alias)
.with_bip_path(self.bip_path)
.with_client_options(self.client_options);

#[cfg(feature = "storage")]
if let Some(storage_path) = &self.storage_path {
Expand Down
6 changes: 1 addition & 5 deletions bindings/core/src/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ mod client;
mod secret_manager;
mod utils;
mod wallet;
mod wallet_command;

pub use self::{
client::ClientMethod, secret_manager::SecretManagerMethod, utils::UtilsMethod, wallet::WalletMethod,
wallet_command::WalletCommandMethod,
};
pub use self::{client::ClientMethod, secret_manager::SecretManagerMethod, utils::UtilsMethod, wallet::WalletMethod};
8 changes: 4 additions & 4 deletions bindings/core/src/method/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ pub enum SecretManagerMethod {
SignatureUnlock {
/// Transaction signing hash
transaction_signing_hash: String,
/// Chain to sign the hash with
/// Chain used to sign the hash
#[serde(with = "Bip44Def")]
chain: Bip44,
},
/// Signs a message with an Ed25519 private key.
SignEd25519 {
/// The message to sign, hex encoded String
message: String,
/// Chain to sign the message with
/// Chain used to sign the message
#[serde(with = "Bip44Def")]
chain: Bip44,
},
/// Signs a message with an Secp256k1Ecdsa private key.
SignSecp256k1Ecdsa {
/// The message to sign, hex encoded String
message: String,
/// Chain to sign the message with
/// Chain used to sign the message
#[serde(with = "Bip44Def")]
chain: Bip44,
},
Expand All @@ -66,7 +66,7 @@ pub enum SecretManagerMethod {
#[serde(rename_all = "camelCase")]
SignBlock {
unsigned_block: UnsignedBlockDto,
/// Chain to sign the essence hash with
/// Chain used to sign the block
#[serde(with = "Bip44Def")]
chain: Bip44,
},
Expand Down
Loading

0 comments on commit 72a5c32

Please sign in to comment.