Skip to content

Commit

Permalink
Merge branch 'upstream/2.0' into cleanup-wallet-syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Apr 15, 2024
2 parents e91b2af + 950b332 commit ea08631
Show file tree
Hide file tree
Showing 62 changed files with 889 additions and 487 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bindings-nodejs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
shell: sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn publish --access public
run: yarn publish --access public --tag alpha

nodejs-binding-prebuild:
runs-on: ${{ matrix.os }}
Expand Down
120 changes: 61 additions & 59 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bindings/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ iota-sdk = { path = "../../sdk", default-features = false, features = [
"tls",
] }

backtrace = { version = "0.3.70", default-features = false, features = ["std"] }
backtrace = { version = "0.3.71", 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.30", default-features = false }
Expand All @@ -30,7 +30,7 @@ packable = { version = "0.11.0", default-features = false, features = [
prefix-hex = { version = "0.7.1", default-features = false }
primitive-types = { version = "0.12.2", default-features = false }
serde = { version = "1.0.197", default-features = false }
serde_json = { version = "1.0.114", default-features = false }
serde_json = { version = "1.0.115", default-features = false }
strum = { version = "0.26.2", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.58", default-features = false }
tokio = { version = "1.36.0", default-features = false }
Expand Down
11 changes: 10 additions & 1 deletion bindings/core/src/method/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use iota_sdk::{
dto::{SignedTransactionPayloadDto, TransactionDto},
TransactionId,
},
protocol::ProtocolParameters,
protocol::{ProtocolParameters, WorkScoreParameters},
signature::Ed25519Signature,
slot::{SlotCommitment, SlotIndex},
unlock::Unlock,
Expand Down Expand Up @@ -187,4 +187,13 @@ pub enum UtilsMethod {
},
IotaMainnetProtocolParameters,
ShimmerMainnetProtocolParameters,
/// Returns the work score of a block.
/// Expected response: [`WorkScore`](crate::Response::WorkScore)
#[serde(rename_all = "camelCase")]
BlockWorkScore {
/// Block
block: BlockDto,
/// Work score parameters
work_score_parameters: WorkScoreParameters,
},
}
15 changes: 14 additions & 1 deletion bindings/core/src/method_handler/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ use iota_sdk::{
input::UtxoInput,
output::{FoundryId, MinimumOutputAmount, Output, OutputId, TokenId},
payload::{signed_transaction::Transaction, SignedTransactionPayload},
protocol::WorkScore,
semantic::SemanticValidationContext,
signature::SignatureError,
Block,
Block, BlockBody,
},
TryFromDto,
},
Expand Down Expand Up @@ -169,6 +170,18 @@ pub(crate) fn call_utils_method_internal(method: UtilsMethod) -> Result<Response
UtilsMethod::ShimmerMainnetProtocolParameters => Response::ProtocolParameters(
iota_sdk::types::block::protocol::shimmer_mainnet_protocol_parameters().clone(),
),
UtilsMethod::BlockWorkScore {
block,
work_score_parameters,
} => {
let block = Block::try_from_dto(block)?;
let work_score = match block.body() {
BlockBody::Basic(basic) => basic.work_score(work_score_parameters),
// Validation blocks have a work score of 0.
BlockBody::Validation(_validation) => 0,
};
Response::WorkScore(work_score)
}
};

Ok(response)
Expand Down
Loading

0 comments on commit ea08631

Please sign in to comment.