fix: nonces fix

This commit is contained in:
Oleksandr Pravdyvyi 2025-08-13 16:23:00 +03:00
parent f32d7a7daf
commit 6cada5bd09
No known key found for this signature in database
GPG Key ID: 9F8955C63C443871
2 changed files with 1 additions and 19 deletions

View File

@ -25,7 +25,6 @@ pub struct Account {
pub key_holder: AddressKeyHolder,
pub address: AccountAddress,
pub balance: u64,
pub nonce: u64,
pub utxos: HashMap<TreeHashType, UTXO>,
}
@ -34,7 +33,6 @@ pub struct AccountForSerialization {
pub key_holder: AddressKeyHolder,
pub address: AccountAddress,
pub balance: u64,
pub nonce: u64,
pub utxos: HashMap<String, UTXO>,
}
@ -44,7 +42,6 @@ impl From<Account> for AccountForSerialization {
key_holder: value.key_holder,
address: value.address,
balance: value.balance,
nonce: value.nonce,
utxos: value
.utxos
.into_iter()
@ -60,7 +57,6 @@ impl From<AccountForSerialization> for Account {
key_holder: value.key_holder,
address: value.address,
balance: value.balance,
nonce: value.nonce,
utxos: value
.utxos
.into_iter()
@ -124,14 +120,12 @@ impl Account {
let public_key = *key_holder.get_pub_account_signing_key().verifying_key();
let address = address::from_public_key(&public_key);
let balance = 0;
let nonce = 0;
let utxos = HashMap::new();
Self {
key_holder,
address,
balance,
nonce,
utxos,
}
}
@ -140,14 +134,12 @@ impl Account {
let key_holder = AddressKeyHolder::new_os_random();
let public_key = *key_holder.get_pub_account_signing_key().verifying_key();
let address = address::from_public_key(&public_key);
let nonce = 0;
let utxos = HashMap::new();
Self {
key_holder,
address,
balance,
nonce,
utxos,
}
}

View File

@ -112,15 +112,6 @@ impl WalletCore {
}
}
///Helperfunction to increment nonces for all given accounts
fn increment_nonces(&mut self, accounts_to_increment_nonces: &[AccountAddress]) {
for acc_addr in accounts_to_increment_nonces {
if let Some(acc) = self.storage.acc_map.get_mut(acc_addr) {
acc.nonce += 1;
}
}
}
///Dumps all accounts from acc_map at `path`
///
///Currently storing everything in one file
@ -198,7 +189,7 @@ pub async fn execute_subcommand(command: Command) -> Result<()> {
let from = produce_account_addr_from_hex(from)?;
let to = produce_account_addr_from_hex(to)?;
let mut wallet_core = WalletCore::start_from_config_update_chain(wallet_config).await?;
let wallet_core = WalletCore::start_from_config_update_chain(wallet_config).await?;
let res = wallet_core
.send_public_native_token_transfer(from, nonce, to, amount)
@ -207,7 +198,6 @@ pub async fn execute_subcommand(command: Command) -> Result<()> {
info!("Results of tx send is {res:#?}");
//ToDo: Insert transaction polling logic here
wallet_core.increment_nonces(&[from, to]);
let acc_storage_path = wallet_core.store_present_accounts_at_home()?;