Skip to content

Commit

Permalink
Merge branch '2.0' into syntactic-address-caps
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Jan 9, 2024
2 parents fe64b50 + a70e508 commit 85f2a07
Show file tree
Hide file tree
Showing 34 changed files with 13,607 additions and 11,882 deletions.
273 changes: 130 additions & 143 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions bindings/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ iota-sdk = { path = "../../sdk", default-features = false, features = [
backtrace = { version = "0.3.69", default-features = false, features = ["std"] }
derivative = { version = "2.2.0", default-features = false }
fern-logger = { version = "0.5.0", default-features = false }
futures = { version = "0.3.29", default-features = false }
futures = { version = "0.3.30", default-features = false }
iota-crypto = { version = "0.23.0", default-features = false, features = [
"slip10",
"bip44",
Expand All @@ -26,10 +26,10 @@ log = { version = "0.4.20", default-features = false }
packable = { version = "0.10.0", default-features = false }
prefix-hex = { version = "0.7.1", default-features = false }
primitive-types = { version = "0.12.2", default-features = false }
serde = { version = "1.0.193", default-features = false }
serde_json = { version = "1.0.108", default-features = false }
thiserror = { version = "1.0.51", default-features = false }
tokio = { version = "1.35.0", default-features = false }
serde = { version = "1.0.195", default-features = false }
serde_json = { version = "1.0.111", default-features = false }
thiserror = { version = "1.0.56", default-features = false }
tokio = { version = "1.35.1", default-features = false }
url = { version = "2.4.1", default-features = false, features = ["serde"] }
zeroize = { version = "1.7.0", default-features = false }

Expand Down
114 changes: 62 additions & 52 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use iota_sdk::{
api::core::OutputWithMetadataResponse,
block::{
output::{
AccountOutput, BasicOutput, FoundryOutput, MinimumOutputAmount, NftOutput, Output, OutputBuilderAmount,
AccountOutputBuilder, BasicOutputBuilder, FoundryOutputBuilder, MinimumOutputAmount, NftOutputBuilder,
},
payload::Payload,
Block, BlockDto, UnsignedBlockDto,
Expand Down Expand Up @@ -64,40 +64,43 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
features,
immutable_features,
} => {
let output = Output::from(AccountOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmount::Amount(amount)
} else {
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
&account_id,
foundry_counter,
unlock_conditions,
features,
immutable_features,
)?);
let mut output_builder = if let Some(amount) = amount {
AccountOutputBuilder::new_with_amount(amount, account_id)
} else {
AccountOutputBuilder::new_with_minimum_amount(client.get_storage_score_parameters().await?, account_id)
}
.with_mana(mana)
.with_foundry_counter(foundry_counter)
.with_unlock_conditions(unlock_conditions);

if let Some(features) = features {
output_builder = output_builder.with_features(features);
}
if let Some(immutable_features) = immutable_features {
output_builder = output_builder.with_immutable_features(immutable_features)
}

Response::Output(output)
Response::Output(output_builder.finish_output()?)
}
ClientMethod::BuildBasicOutput {
amount,
mana,
unlock_conditions,
features,
} => {
let output = Output::from(BasicOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmount::Amount(amount)
} else {
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
unlock_conditions,
features,
)?);
let mut output_builder = if let Some(amount) = amount {
BasicOutputBuilder::new_with_amount(amount)
} else {
BasicOutputBuilder::new_with_minimum_amount(client.get_storage_score_parameters().await?)
}
.with_mana(mana)
.with_unlock_conditions(unlock_conditions);

Response::Output(output)
if let Some(features) = features {
output_builder = output_builder.with_features(features);
}

Response::Output(output_builder.finish_output()?)
}
ClientMethod::BuildFoundryOutput {
amount,
Expand All @@ -107,20 +110,25 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
features,
immutable_features,
} => {
let output = Output::from(FoundryOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmount::Amount(amount)
} else {
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
serial_number,
token_scheme,
unlock_conditions,
features,
immutable_features,
)?);
let mut output_builder = if let Some(amount) = amount {
FoundryOutputBuilder::new_with_amount(amount, serial_number, token_scheme)
} else {
FoundryOutputBuilder::new_with_minimum_amount(
client.get_storage_score_parameters().await?,
serial_number,
token_scheme,
)
}
.with_unlock_conditions(unlock_conditions);

Response::Output(output)
if let Some(features) = features {
output_builder = output_builder.with_features(features);
}
if let Some(immutable_features) = immutable_features {
output_builder = output_builder.with_immutable_features(immutable_features)
}

Response::Output(output_builder.finish_output()?)
}
ClientMethod::BuildNftOutput {
amount,
Expand All @@ -130,20 +138,22 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
features,
immutable_features,
} => {
let output = Output::from(NftOutput::try_from_dtos(
if let Some(amount) = amount {
OutputBuilderAmount::Amount(amount)
} else {
OutputBuilderAmount::MinimumAmount(client.get_storage_score_parameters().await?)
},
mana,
&nft_id,
unlock_conditions,
features,
immutable_features,
)?);
let mut output_builder = if let Some(amount) = amount {
NftOutputBuilder::new_with_amount(amount, nft_id)
} else {
NftOutputBuilder::new_with_minimum_amount(client.get_storage_score_parameters().await?, nft_id)
}
.with_mana(mana)
.with_unlock_conditions(unlock_conditions);

if let Some(features) = features {
output_builder = output_builder.with_features(features);
}
if let Some(immutable_features) = immutable_features {
output_builder = output_builder.with_immutable_features(immutable_features)
}

Response::Output(output)
Response::Output(output_builder.finish_output()?)
}
ClientMethod::BuildBasicBlock { issuer_id, payload } => {
let payload = if let Some(payload) = payload {
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ log = { version = "0.4.20", default-features = false }
napi = { version = "2.13.3", default-features = false, features = ["async"] }
napi-derive = { version = "2.13.0", default-features = false }
once_cell = { version = "1.19.0", default-features = false }
serde_json = { version = "1.0.108", default-features = false }
serde_json = { version = "1.0.111", default-features = false }
thiserror = { version = "1.0.49", default-features = false }
tokio = { version = "1.35.0", default-features = false }
tokio = { version = "1.35.1", default-features = false }

[build-dependencies]
napi-build = { version = "2.0.1", default-features = false }
Expand Down
Loading

0 comments on commit 85f2a07

Please sign in to comment.