From adcf8fd3035103fa7bde6c6913e7b4afbaa66bff Mon Sep 17 00:00:00 2001 From: David Craven Date: Tue, 11 Apr 2023 22:25:56 +0200 Subject: [PATCH] Some fixes. --- rosetta-cli/src/identifiers.rs | 9 +++------ rosetta-cli/src/main.rs | 7 ++----- rosetta-client/src/signer.rs | 3 ++- rosetta-server/Cargo.toml | 4 ++++ rosetta-server/build.rs | 7 +++++++ rosetta-server/src/lib.rs | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 rosetta-server/build.rs diff --git a/rosetta-cli/src/identifiers.rs b/rosetta-cli/src/identifiers.rs index 16eaf890..dd372c39 100644 --- a/rosetta-cli/src/identifiers.rs +++ b/rosetta-cli/src/identifiers.rs @@ -40,14 +40,11 @@ pub struct BlockIdentifierOpts { } impl BlockIdentifierOpts { - pub fn partial_block_identifier(&self) -> Option { - if self.index.is_none() && self.hash.is_none() { - return None; - } - Some(PartialBlockIdentifier { + pub fn partial_block_identifier(&self) -> PartialBlockIdentifier { + PartialBlockIdentifier { index: self.index, hash: self.hash.clone(), - }) + } } pub fn block_identifier(&self) -> Option { diff --git a/rosetta-cli/src/main.rs b/rosetta-cli/src/main.rs index 305267d2..5e19cd2f 100644 --- a/rosetta-cli/src/main.rs +++ b/rosetta-cli/src/main.rs @@ -50,7 +50,7 @@ async fn main() -> Result<()> { let req = AccountBalanceRequest { network_identifier: config.network(), account_identifier, - block_identifier: opts.block.partial_block_identifier(), + block_identifier: Some(opts.block.partial_block_identifier()), currencies: None, }; let balance = client.account_balance(&req).await?; @@ -104,10 +104,7 @@ async fn main() -> Result<()> { let res = client.block_transaction(&req).await?; println!("{res:#?}"); } else { - let block_identifier = opts - .block - .partial_block_identifier() - .ok_or_else(|| anyhow::anyhow!("missing partial block identifier"))?; + let block_identifier = opts.block.partial_block_identifier(); let req = BlockRequest { network_identifier, block_identifier, diff --git a/rosetta-client/src/signer.rs b/rosetta-client/src/signer.rs index b37caf13..fee0ac50 100644 --- a/rosetta-client/src/signer.rs +++ b/rosetta-client/src/signer.rs @@ -62,7 +62,8 @@ impl Signer { self.master_key(algorithm)? .derive(ChildNumber::hardened_from_u32(44))? .derive(ChildNumber::hardened_from_u32(coin))? - .derive(ChildNumber::hardened_from_u32(account)) + .derive(ChildNumber::hardened_from_u32(account))? + .derive(ChildNumber::non_hardened_from_u32(0)) } } diff --git a/rosetta-server/Cargo.toml b/rosetta-server/Cargo.toml index f0c4ed4b..2302d970 100644 --- a/rosetta-server/Cargo.toml +++ b/rosetta-server/Cargo.toml @@ -24,3 +24,7 @@ serde_json = "1.0.94" sled = "0.34.7" tide = { version = "0.16.0", default-features = false, features = ["h1-server", "logger"] } tokio = { version = "1.26.0", features = ["full"] } + +[build-dependencies] +anyhow = "1.0.69" +vergen = { version = "8.1.1", features = ["build", "git", "gitcl"] } diff --git a/rosetta-server/build.rs b/rosetta-server/build.rs new file mode 100644 index 00000000..88e78920 --- /dev/null +++ b/rosetta-server/build.rs @@ -0,0 +1,7 @@ +use anyhow::Result; +use vergen::EmitBuilder; + +fn main() -> Result<()> { + EmitBuilder::builder().all_git().emit()?; + Ok(()) +} diff --git a/rosetta-server/src/lib.rs b/rosetta-server/src/lib.rs index 6ed6dcf8..f604cd9a 100644 --- a/rosetta-server/src/lib.rs +++ b/rosetta-server/src/lib.rs @@ -157,7 +157,7 @@ async fn network_options(mut req: Request>) -> tid version: Version { rosetta_version: "1.4.13".into(), node_version, - middleware_version: None, + middleware_version: Some(env!("VERGEN_GIT_DESCRIBE").into()), metadata: None, }, allow: None,