fix: final fixes & polishing

This commit is contained in:
Daniil Polyakov 2026-03-14 03:20:37 +03:00
parent 9d87e3b046
commit b631ef02c6
21 changed files with 120 additions and 639 deletions

12
Cargo.lock generated
View File

@ -1498,22 +1498,16 @@ name = "common"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1",
"borsh", "borsh",
"bytesize",
"hex", "hex",
"log", "log",
"logos-blockchain-common-http-client", "logos-blockchain-common-http-client",
"nssa", "nssa",
"nssa_core", "nssa_core",
"reqwest",
"serde", "serde",
"serde_json",
"serde_with", "serde_with",
"sha2", "sha2",
"thiserror 2.0.18", "thiserror 2.0.18",
"tokio-retry",
"url",
] ]
[[package]] [[package]]
@ -3556,8 +3550,6 @@ name = "integration_tests"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1",
"borsh",
"bytesize", "bytesize",
"common", "common",
"env_logger", "env_logger",
@ -7200,7 +7192,6 @@ dependencies = [
"jsonrpsee", "jsonrpsee",
"nssa", "nssa",
"nssa_core", "nssa_core",
"serde_json",
] ]
[[package]] [[package]]
@ -8652,8 +8643,6 @@ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
"base58", "base58",
"base64 0.22.1",
"borsh",
"clap", "clap",
"common", "common",
"env_logger", "env_logger",
@ -8684,7 +8673,6 @@ name = "wallet-ffi"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cbindgen", "cbindgen",
"common",
"nssa", "nssa",
"nssa_core", "nssa_core",
"sequencer_service_rpc", "sequencer_service_rpc",

View File

@ -33,7 +33,7 @@ run-bedrock:
[working-directory: 'sequencer/service'] [working-directory: 'sequencer/service']
run-sequencer: run-sequencer:
@echo "🧠 Running sequencer" @echo "🧠 Running sequencer"
RUST_LOG=info RISC0_DEV_MODE=1 cargo run --release -p sequencer_service configs/debug RUST_LOG=info RISC0_DEV_MODE=1 cargo run --release -p sequencer_service configs/debug/sequencer_config.json
# Run Indexer # Run Indexer
[working-directory: 'indexer/service'] [working-directory: 'indexer/service']

View File

@ -13,16 +13,10 @@ nssa_core.workspace = true
anyhow.workspace = true anyhow.workspace = true
thiserror.workspace = true thiserror.workspace = true
serde_json.workspace = true
serde.workspace = true serde.workspace = true
serde_with.workspace = true serde_with.workspace = true
reqwest.workspace = true
sha2.workspace = true sha2.workspace = true
log.workspace = true log.workspace = true
hex.workspace = true hex.workspace = true
borsh.workspace = true borsh.workspace = true
bytesize.workspace = true
base64.workspace = true
url.workspace = true
logos-blockchain-common-http-client.workspace = true logos-blockchain-common-http-client.workspace = true
tokio-retry.workspace = true

View File

@ -27,11 +27,9 @@ url.workspace = true
anyhow.workspace = true anyhow.workspace = true
env_logger.workspace = true env_logger.workspace = true
log.workspace = true log.workspace = true
base64.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
hex.workspace = true hex.workspace = true
tempfile.workspace = true tempfile.workspace = true
borsh.workspace = true
bytesize.workspace = true bytesize.workspace = true
futures.workspace = true futures.workspace = true
testcontainers = { version = "0.27.0", features = ["docker-compose"] } testcontainers = { version = "0.27.0", features = ["docker-compose"] }

View File

@ -480,5 +480,7 @@ pub async fn verify_commitment_is_in_state(
seq_client seq_client
.get_proof_for_commitment(commitment) .get_proof_for_commitment(commitment)
.await .await
.is_ok() .ok()
.flatten()
.is_some()
} }

View File

@ -19,10 +19,12 @@ serde.workspace = true
k256.workspace = true k256.workspace = true
sha2.workspace = true sha2.workspace = true
rand.workspace = true rand.workspace = true
base58.workspace = true
hex.workspace = true hex.workspace = true
aes-gcm.workspace = true aes-gcm.workspace = true
bip39.workspace = true bip39.workspace = true
hmac-sha512.workspace = true hmac-sha512.workspace = true
thiserror.workspace = true thiserror.workspace = true
itertools.workspace = true itertools.workspace = true
[dev-dependencies]
base58.workspace = true

View File

@ -10,16 +10,16 @@ use sha2::{Digest as _, digest::FixedOutput as _};
const NSSA_ENTROPY_BYTES: [u8; 32] = [0; 32]; const NSSA_ENTROPY_BYTES: [u8; 32] = [0; 32];
#[derive(Debug)]
/// Seed holder. Non-clonable to ensure that different holders use different seeds. /// Seed holder. Non-clonable to ensure that different holders use different seeds.
/// Produces `TopSecretKeyHolder` objects. /// Produces `TopSecretKeyHolder` objects.
#[derive(Debug)]
pub struct SeedHolder { pub struct SeedHolder {
// ToDo: Needs to be vec as serde derives is not implemented for [u8; 64] // ToDo: Needs to be vec as serde derives is not implemented for [u8; 64]
pub(crate) seed: Vec<u8>, pub(crate) seed: Vec<u8>,
} }
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
/// Secret spending key object. Can produce `PrivateKeyHolder` objects. /// Secret spending key object. Can produce `PrivateKeyHolder` objects.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct SecretSpendingKey(pub(crate) [u8; 32]); pub struct SecretSpendingKey(pub(crate) [u8; 32]);
pub type ViewingSecretKey = Scalar; pub type ViewingSecretKey = Scalar;

View File

@ -66,13 +66,13 @@ impl NSSAUserData {
) -> Result<Self> { ) -> Result<Self> {
if !Self::valid_public_key_transaction_pairing_check(&default_accounts_keys) { if !Self::valid_public_key_transaction_pairing_check(&default_accounts_keys) {
anyhow::bail!( anyhow::bail!(
"Key transaction pairing check not satisfied, there is account_ids, which is not derived from keys" "Key transaction pairing check not satisfied, there are public account_ids, which is not derived from keys"
); );
} }
if !Self::valid_private_key_transaction_pairing_check(&default_accounts_key_chains) { if !Self::valid_private_key_transaction_pairing_check(&default_accounts_key_chains) {
anyhow::bail!( anyhow::bail!(
"Key transaction pairing check not satisfied, there is account_ids, which is not derived from keys" "Key transaction pairing check not satisfied, there are private account_ids, which is not derived from keys"
); );
} }

View File

@ -97,7 +97,7 @@ COPY --from=builder --chown=sequencer_user:sequencer_user /usr/local/bin/r0vm /u
COPY --from=builder --chown=sequencer_user:sequencer_user /root/.logos-blockchain-circuits /home/sequencer_user/.logos-blockchain-circuits COPY --from=builder --chown=sequencer_user:sequencer_user /root/.logos-blockchain-circuits /home/sequencer_user/.logos-blockchain-circuits
# Copy entrypoint script # Copy entrypoint script
COPY sequencer_service/docker-entrypoint.sh /docker-entrypoint.sh COPY sequencer/service/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh
# Expose default port # Expose default port
@ -125,4 +125,4 @@ USER root
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
WORKDIR /sequencer_service WORKDIR /sequencer_service
CMD ["sequencer_service", "/etc/sequencer_service"] CMD ["sequencer_service", "/etc/sequencer_service/sequencer_config.json"]

View File

@ -2,13 +2,13 @@ services:
sequencer_service: sequencer_service:
image: lssa/sequencer_service image: lssa/sequencer_service
build: build:
context: .. context: ../..
dockerfile: sequencer/service/Dockerfile dockerfile: sequencer/service/Dockerfile
container_name: sequencer_service container_name: sequencer_service
ports: ports:
- "3040:3040" - "3040:3040"
volumes: volumes:
# Mount configuration folder # Mount configuration file
- ./configs/docker:/etc/sequencer_service - ./configs/docker/sequencer_config.json:/etc/sequencer_service/sequencer_config.json
# Mount data folder # Mount data folder
- ./data:/var/lib/sequencer_service - ./data:/var/lib/sequencer_service

View File

@ -13,7 +13,6 @@ nssa.workspace = true
nssa_core.workspace = true nssa_core.workspace = true
jsonrpsee = { workspace = true, features = ["macros"] } jsonrpsee = { workspace = true, features = ["macros"] }
serde_json.workspace = true
[features] [features]
client = ["jsonrpsee/client"] client = ["jsonrpsee/client"]

View File

@ -79,7 +79,7 @@ pub trait Rpc {
async fn get_proof_for_commitment( async fn get_proof_for_commitment(
&self, &self,
commitment: Commitment, commitment: Commitment,
) -> Result<MembershipProof, ErrorObjectOwned>; ) -> Result<Option<MembershipProof>, ErrorObjectOwned>;
#[method(name = "getAccount")] #[method(name = "getAccount")]
async fn get_account(&self, account_id: AccountId) -> Result<Account, ErrorObjectOwned>; async fn get_account(&self, account_id: AccountId) -> Result<Account, ErrorObjectOwned>;

View File

@ -160,18 +160,9 @@ impl<BC: BlockSettlementClientTrait + Send + 'static, IC: IndexerClientTrait + S
async fn get_proof_for_commitment( async fn get_proof_for_commitment(
&self, &self,
commitment: Commitment, commitment: Commitment,
) -> Result<MembershipProof, ErrorObjectOwned> { ) -> Result<Option<MembershipProof>, ErrorObjectOwned> {
let sequencer = self.sequencer.lock().await; let sequencer = self.sequencer.lock().await;
sequencer Ok(sequencer.state().get_proof_for_commitment(&commitment))
.state()
.get_proof_for_commitment(&commitment)
.ok_or_else(|| {
ErrorObjectOwned::owned(
NOT_FOUND_ERROR_CODE,
"Proof for commitment not found",
None::<()>,
)
})
} }
async fn get_account(&self, account_id: AccountId) -> Result<Account, ErrorObjectOwned> { async fn get_account(&self, account_id: AccountId) -> Result<Account, ErrorObjectOwned> {

View File

@ -13,7 +13,6 @@ crate-type = ["rlib", "cdylib", "staticlib"]
[dependencies] [dependencies]
wallet.workspace = true wallet.workspace = true
nssa.workspace = true nssa.workspace = true
common.workspace = true
nssa_core.workspace = true nssa_core.workspace = true
sequencer_service_rpc = { workspace = true, features = ["client"] } sequencer_service_rpc = { workspace = true, features = ["client"] }
tokio.workspace = true tokio.workspace = true

View File

@ -27,8 +27,6 @@ humantime.workspace = true
tokio = { workspace = true, features = ["macros"] } tokio = { workspace = true, features = ["macros"] }
clap.workspace = true clap.workspace = true
base58.workspace = true base58.workspace = true
base64.workspace = true
borsh.workspace = true
hex.workspace = true hex.workspace = true
rand.workspace = true rand.workspace = true
itertools.workspace = true itertools.workspace = true

View File

@ -161,105 +161,44 @@ impl WalletChainStore {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::str::FromStr as _;
use key_protocol::key_management::key_tree::{ use key_protocol::key_management::key_tree::{
keys_private::ChildKeysPrivate, keys_public::ChildKeysPublic, traits::KeyNode as _, keys_private::ChildKeysPrivate, keys_public::ChildKeysPublic, traits::KeyNode as _,
}; };
use nssa::PrivateKey;
use super::*; use super::*;
use crate::config::{ use crate::config::{
InitialAccountData, PersistentAccountDataPrivate, PersistentAccountDataPublic, InitialAccountData, InitialAccountDataPublic, PersistentAccountDataPrivate,
PersistentAccountDataPublic,
}; };
fn create_initial_accounts() -> Vec<InitialAccountData> { fn create_initial_accounts() -> Vec<InitialAccountData> {
let initial_acc1 = serde_json::from_str( vec![
r#"{ InitialAccountData::Public(InitialAccountDataPublic {
"Public": { account_id: nssa::AccountId::from_str(
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r", "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"pub_sign_key": [ )
127, .unwrap(),
39, pub_sign_key: PrivateKey::try_new([
48, 127, 39, 48, 152, 242, 91, 113, 230, 192, 5, 169, 81, 159, 38, 120, 218, 141,
152, 28, 127, 1, 246, 162, 119, 120, 226, 217, 148, 138, 189, 249, 1, 251,
242, ])
91, .unwrap(),
113, }),
230, InitialAccountData::Public(InitialAccountDataPublic {
192, account_id: nssa::AccountId::from_str(
5, "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
169, )
81, .unwrap(),
159, pub_sign_key: PrivateKey::try_new([
38, 244, 52, 248, 116, 23, 32, 1, 69, 134, 174, 67, 53, 109, 42, 236, 98, 87, 218,
120, 8, 98, 34, 246, 4, 221, 183, 93, 105, 115, 59, 134, 252, 76,
218, ])
141, .unwrap(),
28, }),
127, ]
1,
246,
162,
119,
120,
226,
217,
148,
138,
189,
249,
1,
251
]
}
}"#,
)
.unwrap();
let initial_acc2 = serde_json::from_str(
r#"{
"Public": {
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"pub_sign_key": [
244,
52,
248,
116,
23,
32,
1,
69,
134,
174,
67,
53,
109,
42,
236,
98,
87,
218,
8,
98,
34,
246,
4,
221,
183,
93,
105,
115,
59,
134,
252,
76
]
}
}"#,
)
.unwrap();
let initial_accounts = vec![initial_acc1, initial_acc2];
initial_accounts
} }
fn create_sample_wallet_config() -> WalletConfig { fn create_sample_wallet_config() -> WalletConfig {

View File

@ -62,7 +62,7 @@ impl WalletSubcommand for AuthTransferSubcommand {
.register_account(account_id) .register_account(account_id)
.await?; .await?;
println!("Results of tx send are {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -77,7 +77,7 @@ impl WalletSubcommand for AuthTransferSubcommand {
.register_account_private(account_id) .register_account_private(account_id)
.await?; .await?;
println!("Results of tx send are {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -313,7 +313,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandPrivate {
.send_private_transfer_to_owned_account(from, to, amount) .send_private_transfer_to_owned_account(from, to, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -352,7 +352,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandPrivate {
.send_private_transfer_to_outer_account(from, to_npk, to_vpk, amount) .send_private_transfer_to_outer_account(from, to_npk, to_vpk, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -387,7 +387,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandShielded {
.send_shielded_transfer(from, to, amount) .send_shielded_transfer(from, to, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -427,7 +427,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandShielded {
.send_shielded_transfer_to_outer_account(from, to_npk, to_vpk, amount) .send_shielded_transfer_to_outer_account(from, to_npk, to_vpk, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
wallet_core.store_persistent_data().await?; wallet_core.store_persistent_data().await?;
@ -457,7 +457,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommand {
.send_deshielded_transfer(from, to, amount) .send_deshielded_transfer(from, to, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -482,7 +482,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommand {
.send_public_transfer(from, to, amount) .send_public_transfer(from, to, amount)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;

View File

@ -116,7 +116,7 @@ impl WalletSubcommand for PinataProgramSubcommandPublic {
.claim(pinata_account_id, winner_account_id, solution) .claim(pinata_account_id, winner_account_id, solution)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -151,7 +151,7 @@ impl WalletSubcommand for PinataProgramSubcommandPrivate {
.claim_private_owned_account(pinata_account_id, winner_account_id, solution) .claim_private_owned_account(pinata_account_id, winner_account_id, solution)
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;

View File

@ -721,7 +721,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -769,7 +769,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -802,7 +802,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -838,7 +838,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -887,7 +887,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -930,7 +930,7 @@ impl WalletSubcommand for TokenProgramSubcommandDeshielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -963,7 +963,7 @@ impl WalletSubcommand for TokenProgramSubcommandDeshielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -996,7 +996,7 @@ impl WalletSubcommand for TokenProgramSubcommandDeshielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1051,7 +1051,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1079,7 +1079,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1112,7 +1112,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1145,7 +1145,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1191,7 +1191,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1231,7 +1231,7 @@ impl WalletSubcommand for CreateNewTokenProgramSubcommand {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1269,7 +1269,7 @@ impl WalletSubcommand for CreateNewTokenProgramSubcommand {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;
@ -1304,7 +1304,7 @@ impl WalletSubcommand for CreateNewTokenProgramSubcommand {
) )
.await?; .await?;
println!("Transaction hash is {tx_hash:#?}"); println!("Transaction hash is {tx_hash}");
let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?; let transfer_tx = wallet_core.poll_native_token_transfer(tx_hash).await?;

View File

@ -2,6 +2,7 @@ use std::{
collections::HashMap, collections::HashMap,
io::{BufReader, Write as _}, io::{BufReader, Write as _},
path::Path, path::Path,
str::FromStr as _,
time::Duration, time::Duration,
}; };
@ -217,481 +218,52 @@ impl Default for WalletConfig {
seq_poll_max_retries: 5, seq_poll_max_retries: 5,
seq_block_poll_max_amount: 100, seq_block_poll_max_amount: 100,
basic_auth: None, basic_auth: None,
initial_accounts: { initial_accounts: vec![
let init_acc_json = r#" InitialAccountData::Public(InitialAccountDataPublic {
[ account_id: nssa::AccountId::from_str(
{ "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r",
"Public": { )
"account_id": "CbgR6tj5kWx5oziiFptM7jMvrQeYY3Mzaao6ciuhSr2r", .unwrap(),
"pub_sign_key": [ pub_sign_key: nssa::PrivateKey::try_new([
127, 127, 39, 48, 152, 242, 91, 113, 230, 192, 5, 169, 81, 159, 38, 120, 218,
39, 141, 28, 127, 1, 246, 162, 119, 120, 226, 217, 148, 138, 189, 249, 1, 251,
48, ])
152, .unwrap(),
242, }),
91, InitialAccountData::Public(InitialAccountDataPublic {
113, account_id: nssa::AccountId::from_str(
230, "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo",
192, )
5, .unwrap(),
169, pub_sign_key: nssa::PrivateKey::try_new([
81, 244, 52, 248, 116, 23, 32, 1, 69, 134, 174, 67, 53, 109, 42, 236, 98, 87,
159, 218, 8, 98, 34, 246, 4, 221, 183, 93, 105, 115, 59, 134, 252, 76,
38, ])
120, .unwrap(),
218, }),
141, InitialAccountData::Private(Box::new(InitialAccountDataPrivate {
28, account_id: nssa::AccountId::from_str(
127, "HWkW5qd4XK3me6sCAb4bfPj462k33DjtKtEcYpuzNwB",
1, )
246, .unwrap(),
162, account: nssa::Account {
119, balance: 10_000,
120, ..Default::default()
226,
217,
148,
138,
189,
249,
1,
251
]
}
},
{
"Public": {
"account_id": "2RHZhw9h534Zr3eq2RGhQete2Hh667foECzXPmSkGni2",
"pub_sign_key": [
244,
52,
248,
116,
23,
32,
1,
69,
134,
174,
67,
53,
109,
42,
236,
98,
87,
218,
8,
98,
34,
246,
4,
221,
183,
93,
105,
115,
59,
134,
252,
76
]
}
},
{
"Private": {
"account_id": "HWkW5qd4XK3me6sCAb4bfPj462k33DjtKtEcYpuzNwB",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 10000,
"data": [],
"nonce": 0
},
"key_chain": {
"secret_spending_key": [
14,
202,
241,
109,
32,
181,
152,
140,
76,
153,
108,
57,
77,
192,
181,
97,
108,
144,
122,
45,
219,
5,
203,
193,
82,
123,
83,
34,
250,
214,
137,
63
],
"private_key_holder": {
"nullifier_secret_key": [
174,
56,
101,
30,
248,
249,
100,
0,
122,
199,
209,
246,
58,
163,
223,
146,
59,
143,
78,
95,
41,
186,
106,
187,
53,
63,
75,
244,
233,
185,
110,
199
],
"viewing_secret_key": [
251,
85,
223,
73,
142,
127,
134,
132,
185,
210,
100,
103,
198,
108,
229,
80,
176,
211,
249,
114,
110,
7,
225,
17,
7,
69,
204,
32,
47,
242,
103,
247
]
}, },
"nullifier_public_key": [ key_chain: KeyChain::new_mnemonic("default_private_account_1".to_owned()),
139, })),
19, InitialAccountData::Private(Box::new(InitialAccountDataPrivate {
158, account_id: nssa::AccountId::from_str(
11, "HUpbRQ1vEcZv5y6TDYv9tpt1VA64ji2v4RDLJfK2rpZn",
155, )
231, .unwrap(),
85, account: nssa::Account {
206, balance: 20_000,
132, ..Default::default()
228,
220,
114,
145,
89,
113,
156,
238,
142,
242,
74,
182,
91,
43,
100,
6,
190,
31,
15,
31,
88,
96,
204
],
"viewing_public_key": [
3,
136,
153,
50,
191,
184,
135,
36,
29,
107,
57,
9,
218,
135,
249,
213,
118,
215,
118,
173,
30,
137,
116,
77,
17,
86,
62,
154,
31,
173,
19,
167,
211
]
}
}
},
{
"Private": {
"account_id": "HUpbRQ1vEcZv5y6TDYv9tpt1VA64ji2v4RDLJfK2rpZn",
"account": {
"program_owner": [
0,
0,
0,
0,
0,
0,
0,
0
],
"balance": 20000,
"data": [],
"nonce": 0
},
"key_chain": {
"secret_spending_key": [
32,
162,
244,
221,
2,
133,
168,
250,
240,
52,
92,
187,
157,
116,
249,
203,
143,
194,
214,
112,
115,
142,
153,
78,
241,
173,
103,
242,
192,
196,
29,
133
],
"private_key_holder": {
"nullifier_secret_key": [
188,
235,
121,
54,
131,
206,
7,
215,
94,
231,
102,
22,
12,
27,
253,
161,
248,
206,
41,
160,
206,
149,
5,
217,
127,
235,
154,
230,
198,
232,
102,
31
],
"viewing_secret_key": [
89,
116,
140,
122,
211,
179,
190,
229,
18,
94,
56,
235,
48,
99,
104,
228,
111,
72,
231,
18,
247,
97,
110,
60,
238,
138,
0,
25,
92,
44,
30,
145
]
}, },
"nullifier_public_key": [ key_chain: KeyChain::new_mnemonic("default_private_account_2".to_owned()),
173, })),
134, ],
33,
223,
54,
226,
10,
71,
215,
254,
143,
172,
24,
244,
243,
208,
65,
112,
118,
70,
217,
240,
69,
100,
129,
3,
121,
25,
213,
132,
42,
45
],
"viewing_public_key": [
2,
43,
42,
253,
112,
83,
195,
164,
26,
141,
92,
28,
224,
120,
155,
119,
225,
1,
45,
42,
245,
172,
134,
136,
52,
183,
170,
96,
115,
212,
114,
120,
37
]
}
}
}
]
"#;
serde_json::from_str(init_acc_json).unwrap()
},
} }
} }
} }

View File

@ -299,8 +299,7 @@ impl WalletCore {
self.sequencer_client self.sequencer_client
.get_proof_for_commitment(acc_comm) .get_proof_for_commitment(acc_comm)
.await .await
.map(Some) .map_err(Into::into)
.map_err(anyhow::Error::from)
} else { } else {
Ok(None) Ok(None)
} }