lssa/wallet/src/config.rs

128 lines
3.9 KiB
Rust
Raw Normal View History

2025-09-11 18:32:46 +03:00
use key_protocol::key_management::KeyChain;
2025-08-19 14:14:09 +03:00
use serde::{Deserialize, Serialize};
2024-12-03 09:32:35 +02:00
use std::path::PathBuf;
2025-08-19 14:14:09 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2025-09-11 18:32:46 +03:00
pub struct InitialAccountDataPublic {
2025-08-19 14:14:09 +03:00
pub address: nssa::Address,
pub pub_sign_key: nssa::PrivateKey,
}
2025-02-28 12:32:54 +02:00
2025-09-02 09:01:33 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2025-09-11 18:32:46 +03:00
pub struct PersistentAccountDataPublic {
2025-09-02 09:01:33 +03:00
pub address: nssa::Address,
pub pub_sign_key: nssa::PrivateKey,
}
2025-09-11 18:32:46 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InitialAccountDataPrivate {
pub address: nssa::Address,
pub account: nssa_core::account::Account,
pub key_chain: KeyChain,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PersistentAccountDataPrivate {
pub address: nssa::Address,
pub account: nssa_core::account::Account,
pub key_chain: KeyChain,
}
2025-09-18 15:59:17 +03:00
//Big difference in enum variants sizes
//however it is improbable, that we will have that much accounts, that it will substantialy affect memory
#[allow(clippy::large_enum_variant)]
2025-09-11 18:32:46 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum InitialAccountData {
Public(InitialAccountDataPublic),
Private(InitialAccountDataPrivate),
}
2025-09-18 15:59:17 +03:00
//Big difference in enum variants sizes
//however it is improbable, that we will have that much accounts, that it will substantialy affect memory
#[allow(clippy::large_enum_variant)]
2025-09-11 18:32:46 +03:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PersistentAccountData {
Public(PersistentAccountDataPublic),
Private(PersistentAccountDataPrivate),
}
impl InitialAccountData {
pub fn address(&self) -> nssa::Address {
match &self {
Self::Public(acc) => acc.address,
Self::Private(acc) => acc.address,
}
}
}
impl PersistentAccountData {
pub fn address(&self) -> nssa::Address {
match &self {
Self::Public(acc) => acc.address,
Self::Private(acc) => acc.address,
}
}
}
impl From<InitialAccountDataPublic> for InitialAccountData {
fn from(value: InitialAccountDataPublic) -> Self {
Self::Public(value)
}
}
impl From<InitialAccountDataPrivate> for InitialAccountData {
fn from(value: InitialAccountDataPrivate) -> Self {
Self::Private(value)
}
}
impl From<PersistentAccountDataPublic> for PersistentAccountData {
fn from(value: PersistentAccountDataPublic) -> Self {
Self::Public(value)
}
}
impl From<PersistentAccountDataPrivate> for PersistentAccountData {
fn from(value: PersistentAccountDataPrivate) -> Self {
Self::Private(value)
}
}
2025-02-28 12:32:54 +02:00
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GasConfig {
/// Gas spent per deploying one byte of data
pub gas_fee_per_byte_deploy: u64,
/// Gas spent per reading one byte of data in VM
pub gas_fee_per_input_buffer_runtime: u64,
/// Gas spent per one byte of contract data in runtime
pub gas_fee_per_byte_runtime: u64,
/// Cost of one gas of runtime in public balance
pub gas_cost_runtime: u64,
/// Cost of one gas of deployment in public balance
pub gas_cost_deploy: u64,
/// Gas limit for deployment
pub gas_limit_deploy: u64,
/// Gas limit for runtime
pub gas_limit_runtime: u64,
}
2024-12-03 09:32:35 +02:00
#[derive(Debug, Clone, Serialize, Deserialize)]
2025-08-11 08:55:08 +03:00
pub struct WalletConfig {
2024-12-03 09:32:35 +02:00
///Home dir of sequencer storage
pub home: PathBuf,
///Override rust log (env var logging level)
pub override_rust_log: Option<String>,
2024-12-05 13:05:58 +02:00
///Sequencer URL
pub sequencer_addr: String,
2025-08-21 15:58:31 +03:00
///Sequencer polling duration for new blocks in milliseconds
pub seq_poll_timeout_millis: u64,
///Sequencer polling max number of blocks
pub seq_poll_max_blocks: usize,
///Sequencer polling max number error retries
pub seq_poll_max_retries: u64,
///Sequencer polling error retry delay in milliseconds
pub seq_poll_retry_delay_millis: u64,
2025-07-29 14:20:03 +03:00
///Initial accounts for wallet
2025-08-19 14:14:09 +03:00
pub initial_accounts: Vec<InitialAccountData>,
2024-12-03 09:32:35 +02:00
}