Revert "fix: AccountAddress wrapped into struct"

This reverts commit 6bced517644b1ab3879aa35d5c4695edb5f3bcb2.
This commit is contained in:
Oleksandr Pravdyvyi 2025-08-13 13:44:41 +03:00
parent 6bced51764
commit fed2d50a9a
No known key found for this signature in database
GPG Key ID: 9F8955C63C443871
12 changed files with 89 additions and 171 deletions

View File

@ -1,44 +1,17 @@
use common::transaction::{SignaturePublicKey, Tag}; use common::transaction::SignaturePublicKey;
use serde::{Deserialize, Serialize};
use tiny_keccak::{Hasher, Keccak}; use tiny_keccak::{Hasher, Keccak};
#[derive( // TODO: Consider wrapping `AccountAddress` in a struct.
Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Default,
)]
pub struct AccountAddress(pub(crate) [u8; 32]);
impl AccountAddress { pub type AccountAddress = [u8; 32];
pub fn new(value: [u8; 32]) -> Self {
Self(value)
}
pub fn tag(&self) -> Tag { /// Returns the address associated with a public key
self.0[0] pub fn from_public_key(public_key: &SignaturePublicKey) -> AccountAddress {
}
pub fn raw_addr(&self) -> [u8; 32] {
self.0
}
}
impl TryFrom<Vec<u8>> for AccountAddress {
type Error = Vec<u8>;
fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
let addr_val: [u8; 32] = value.try_into()?;
Ok(AccountAddress::new(addr_val))
}
}
impl From<&SignaturePublicKey> for AccountAddress {
fn from(value: &SignaturePublicKey) -> Self {
let mut address = [0; 32]; let mut address = [0; 32];
let mut keccak_hasher = Keccak::v256(); let mut keccak_hasher = Keccak::v256();
keccak_hasher.update(&value.to_sec1_bytes()); keccak_hasher.update(&public_key.to_sec1_bytes());
keccak_hasher.finalize(&mut address); keccak_hasher.finalize(&mut address);
AccountAddress::new(address) address
}
} }
#[cfg(test)] #[cfg(test)]
@ -46,6 +19,7 @@ mod tests {
use common::transaction::SignaturePrivateKey; use common::transaction::SignaturePrivateKey;
use super::*; use super::*;
use crate::account_core::address;
#[test] #[test]
fn test_address_key_equal_keccak_pub_sign_key() { fn test_address_key_equal_keccak_pub_sign_key() {
@ -57,9 +31,6 @@ mod tests {
keccak_hasher.update(&public_key.to_sec1_bytes()); keccak_hasher.update(&public_key.to_sec1_bytes());
keccak_hasher.finalize(&mut expected_address); keccak_hasher.finalize(&mut expected_address);
assert_eq!( assert_eq!(expected_address, address::from_public_key(public_key));
AccountAddress::new(expected_address),
AccountAddress::from(public_key)
);
} }
} }

View File

@ -114,7 +114,7 @@ impl AccountPublicMask {
} }
pub fn make_tag(&self) -> Tag { pub fn make_tag(&self) -> Tag {
self.address.tag() self.address[0]
} }
} }
@ -122,7 +122,7 @@ impl Account {
pub fn new() -> Self { pub fn new() -> Self {
let key_holder = AddressKeyHolder::new_os_random(); let key_holder = AddressKeyHolder::new_os_random();
let public_key = *key_holder.get_pub_account_signing_key().verifying_key(); let public_key = *key_holder.get_pub_account_signing_key().verifying_key();
let address = AccountAddress::from(&public_key); let address = address::from_public_key(&public_key);
let balance = 0; let balance = 0;
let nonce = 0; let nonce = 0;
let utxos = HashMap::new(); let utxos = HashMap::new();
@ -139,7 +139,7 @@ impl Account {
pub fn new_with_balance(balance: u64) -> Self { pub fn new_with_balance(balance: u64) -> Self {
let key_holder = AddressKeyHolder::new_os_random(); let key_holder = AddressKeyHolder::new_os_random();
let public_key = *key_holder.get_pub_account_signing_key().verifying_key(); let public_key = *key_holder.get_pub_account_signing_key().verifying_key();
let address = AccountAddress::from(&public_key); let address = address::from_public_key(&public_key);
let nonce = 0; let nonce = 0;
let utxos = HashMap::new(); let utxos = HashMap::new();
@ -191,7 +191,7 @@ impl Account {
privacy_flag: bool, privacy_flag: bool,
) -> Result<()> { ) -> Result<()> {
let asset_utxo = UTXO::new( let asset_utxo = UTXO::new(
self.address.raw_addr(), self.address,
serde_json::to_vec(&asset)?, serde_json::to_vec(&asset)?,
amount, amount,
privacy_flag, privacy_flag,
@ -204,16 +204,12 @@ impl Account {
pub fn log(&self) { pub fn log(&self) {
info!("Keys generated"); info!("Keys generated");
//use HexString info!("Account address is {:?}", hex::encode(self.address));
info!(
"Account address is {:?}",
hex::encode(self.address.raw_addr())
);
info!("Account balance is {:?}", self.balance); info!("Account balance is {:?}", self.balance);
} }
pub fn make_tag(&self) -> Tag { pub fn make_tag(&self) -> Tag {
self.address.tag() self.address[0]
} }
///Produce account public mask ///Produce account public mask
@ -251,8 +247,8 @@ mod tests {
#[test] #[test]
fn test_add_new_utxo_outputs() { fn test_add_new_utxo_outputs() {
let mut account = Account::new(); let mut account = Account::new();
let utxo1 = generate_dummy_utxo(account.address.raw_addr(), 100); let utxo1 = generate_dummy_utxo(account.address, 100);
let utxo2 = generate_dummy_utxo(account.address.raw_addr(), 200); let utxo2 = generate_dummy_utxo(account.address, 200);
let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]); let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]);

View File

@ -120,10 +120,7 @@ mod tests {
use elliptic_curve::point::AffineCoordinates; use elliptic_curve::point::AffineCoordinates;
use k256::{AffinePoint, ProjectivePoint, Scalar}; use k256::{AffinePoint, ProjectivePoint, Scalar};
use crate::{ use crate::{account_core::address, key_management::ephemeral_key_holder::EphemeralKeyHolder};
account_core::address::AccountAddress,
key_management::ephemeral_key_holder::EphemeralKeyHolder,
};
use super::*; use super::*;
@ -350,7 +347,7 @@ mod tests {
let verifying_key = signing_key.verifying_key(); let verifying_key = signing_key.verifying_key();
let address = AccountAddress::from(verifying_key); let address = address::from_public_key(verifying_key);
println!("======Prerequisites======"); println!("======Prerequisites======");
println!(); println!();
@ -376,8 +373,7 @@ mod tests {
println!("======Public data======"); println!("======Public data======");
println!(); println!();
//Use HexString println!("Address{:?}", hex::encode(address));
println!("Address{:?}", hex::encode(address.raw_addr()));
println!( println!(
"Nulifier public key {:?}", "Nulifier public key {:?}",
hex::encode(serde_json::to_vec(&nullifer_public_key).unwrap()) hex::encode(serde_json::to_vec(&nullifer_public_key).unwrap())

View File

@ -1,4 +1,3 @@
use accounts::account_core::address::AccountAddress;
use bincode; use bincode;
use common::merkle_tree_public::merkle_tree::UTXOCommitmentsMerkleTree; use common::merkle_tree_public::merkle_tree::UTXOCommitmentsMerkleTree;
use rand::{thread_rng, RngCore}; use rand::{thread_rng, RngCore};
@ -83,7 +82,7 @@ pub fn private_circuit(
for in_utxo in input_utxos { for in_utxo in input_utxos {
let nullifier_public_key = public_context let nullifier_public_key = public_context
.account_masks .account_masks
.get(&AccountAddress::new(in_utxo.owner)) .get(&in_utxo.owner)
.unwrap() .unwrap()
.nullifier_public_key; .nullifier_public_key;
@ -126,7 +125,7 @@ pub fn deshielded_circuit(
for in_utxo in input_utxos { for in_utxo in input_utxos {
let nullifier_public_key = public_context let nullifier_public_key = public_context
.account_masks .account_masks
.get(&AccountAddress::new(in_utxo.owner)) .get(&in_utxo.owner)
.unwrap() .unwrap()
.nullifier_public_key; .nullifier_public_key;

View File

@ -28,12 +28,7 @@ impl Serialize for PublicSCContext {
where where
S: serde::Serializer, S: serde::Serializer,
{ {
let mut account_masks_keys: Vec<[u8; 32]> = self let mut account_masks_keys: Vec<[u8; 32]> = self.account_masks.keys().cloned().collect();
.account_masks
.keys()
.cloned()
.map(|addr| addr.raw_addr())
.collect();
account_masks_keys.sort(); account_masks_keys.sort();
let mut account_mask_values: Vec<AccountPublicMask> = let mut account_mask_values: Vec<AccountPublicMask> =
@ -116,7 +111,7 @@ mod tests {
account_masks.insert(acc_3.address, acc_3.make_account_public_mask()); account_masks.insert(acc_3.address, acc_3.make_account_public_mask());
PublicSCContext { PublicSCContext {
caller_address: AccountAddress::new(caller_address), caller_address,
caller_balance: 100, caller_balance: 100,
account_masks, account_masks,
comitment_store_root, comitment_store_root,

View File

@ -1,6 +1,6 @@
use std::fmt::Display; use std::fmt::Display;
use accounts::account_core::address::AccountAddress; use accounts::account_core::address::{self, AccountAddress};
use anyhow::Result; use anyhow::Result;
use common::{ use common::{
block::HashableBlockData, block::HashableBlockData,
@ -135,10 +135,10 @@ impl SequencerCore {
if let Ok(native_transfer_action) = if let Ok(native_transfer_action) =
serde_json::from_slice::<PublicNativeTokenSend>(execution_input) serde_json::from_slice::<PublicNativeTokenSend>(execution_input)
{ {
let signer_address = AccountAddress::from(&tx.transaction().public_key); let signer_address = address::from_public_key(&tx.transaction().public_key);
//Correct sender check //Correct sender check
if AccountAddress::new(native_transfer_action.from) != signer_address { if native_transfer_action.from != signer_address {
return Err(TransactionMalformationErrorKind::IncorrectSender); return Err(TransactionMalformationErrorKind::IncorrectSender);
} }
} }
@ -219,7 +219,8 @@ impl SequencerCore {
serde_json::from_slice::<PublicNativeTokenSend>(execution_input) serde_json::from_slice::<PublicNativeTokenSend>(execution_input)
{ {
// Nonce check // Nonce check
let signer_addres = AccountAddress::from(&mempool_tx.auth_tx.transaction().public_key); let signer_addres =
address::from_public_key(&mempool_tx.auth_tx.transaction().public_key);
if self.store.acc_store.get_account_nonce(&signer_addres) if self.store.acc_store.get_account_nonce(&signer_addres)
!= native_transfer_action.nonce != native_transfer_action.nonce
{ {
@ -229,11 +230,11 @@ impl SequencerCore {
let from_balance = self let from_balance = self
.store .store
.acc_store .acc_store
.get_account_balance(&AccountAddress::new(native_transfer_action.from)); .get_account_balance(&native_transfer_action.from);
let to_balance = self let to_balance = self
.store .store
.acc_store .acc_store
.get_account_balance(&AccountAddress::new(native_transfer_action.to)); .get_account_balance(&native_transfer_action.to);
//Balance check //Balance check
if from_balance < native_transfer_action.balance_to_move { if from_balance < native_transfer_action.balance_to_move {
@ -241,11 +242,11 @@ impl SequencerCore {
} }
self.store.acc_store.set_account_balance( self.store.acc_store.set_account_balance(
&AccountAddress::new(native_transfer_action.from), &native_transfer_action.from,
from_balance - native_transfer_action.balance_to_move, from_balance - native_transfer_action.balance_to_move,
); );
self.store.acc_store.set_account_balance( self.store.acc_store.set_account_balance(
&AccountAddress::new(native_transfer_action.to), &native_transfer_action.to,
to_balance + native_transfer_action.balance_to_move, to_balance + native_transfer_action.balance_to_move,
); );
@ -619,13 +620,11 @@ mod tests {
common_setup(&mut sequencer); common_setup(&mut sequencer);
let acc1: AccountAddress = let acc1 = hex::decode(sequencer.sequencer_config.initial_accounts[0].addr.clone())
hex::decode(sequencer.sequencer_config.initial_accounts[0].addr.clone())
.unwrap() .unwrap()
.try_into() .try_into()
.unwrap(); .unwrap();
let acc2: AccountAddress = let acc2 = hex::decode(sequencer.sequencer_config.initial_accounts[1].addr.clone())
hex::decode(sequencer.sequencer_config.initial_accounts[1].addr.clone())
.unwrap() .unwrap()
.try_into() .try_into()
.unwrap(); .unwrap();
@ -633,11 +632,7 @@ mod tests {
let sign_key1 = create_signing_key_for_account1(); let sign_key1 = create_signing_key_for_account1();
let tx = common::test_utils::create_dummy_transaction_native_token_transfer( let tx = common::test_utils::create_dummy_transaction_native_token_transfer(
acc1.raw_addr(), acc1, 0, acc2, 100, sign_key1,
0,
acc2.raw_addr(),
100,
sign_key1,
); );
sequencer sequencer

View File

@ -155,38 +155,30 @@ mod tests {
#[test] #[test]
fn test_zero_balance_account_data_creation() { fn test_zero_balance_account_data_creation() {
let address = AccountAddress::new([1; 32]); let new_acc = AccountPublicData::new([1; 32]);
let new_acc = AccountPublicData::new(address);
assert_eq!(new_acc.balance, 0); assert_eq!(new_acc.balance, 0);
assert_eq!(new_acc.address, address); assert_eq!(new_acc.address, [1; 32]);
} }
#[test] #[test]
fn test_zero_nonce_account_data_creation() { fn test_zero_nonce_account_data_creation() {
let address = AccountAddress::new([1; 32]); let new_acc = AccountPublicData::new([1; 32]);
let new_acc = AccountPublicData::new(address);
assert_eq!(new_acc.nonce, 0); assert_eq!(new_acc.nonce, 0);
} }
#[test] #[test]
fn test_non_zero_balance_account_data_creation() { fn test_non_zero_balance_account_data_creation() {
let address = AccountAddress::new([1; 32]); let new_acc = AccountPublicData::new_with_balance([1; 32], 10);
let new_acc = AccountPublicData::new_with_balance(address, 10);
assert_eq!(new_acc.balance, 10); assert_eq!(new_acc.balance, 10);
assert_eq!(new_acc.address, address); assert_eq!(new_acc.address, [1; 32]);
} }
#[test] #[test]
fn test_zero_nonce_account_data_creation_with_balance() { fn test_zero_nonce_account_data_creation_with_balance() {
let address = AccountAddress::new([1; 32]); let new_acc = AccountPublicData::new_with_balance([1; 32], 10);
let new_acc = AccountPublicData::new_with_balance(address, 10);
assert_eq!(new_acc.nonce, 0); assert_eq!(new_acc.nonce, 0);
} }
@ -200,117 +192,94 @@ mod tests {
#[test] #[test]
fn account_sequencer_store_register_acc() { fn account_sequencer_store_register_acc() {
let address = AccountAddress::new([1; 32]);
let mut seq_acc_store = SequencerAccountsStore::default(); let mut seq_acc_store = SequencerAccountsStore::default();
seq_acc_store.register_account(address); seq_acc_store.register_account([1; 32]);
assert!(seq_acc_store.contains_account(&address)); assert!(seq_acc_store.contains_account(&[1; 32]));
let acc_balance = seq_acc_store.get_account_balance(&address); let acc_balance = seq_acc_store.get_account_balance(&[1; 32]);
assert_eq!(acc_balance, 0); assert_eq!(acc_balance, 0);
} }
#[test] #[test]
fn account_sequencer_store_unregister_acc_not_present() { fn account_sequencer_store_unregister_acc_not_present() {
let address1 = AccountAddress::new([1; 32]);
let address2 = AccountAddress::new([2; 32]);
let mut seq_acc_store = SequencerAccountsStore::default(); let mut seq_acc_store = SequencerAccountsStore::default();
seq_acc_store.register_account(address1); seq_acc_store.register_account([1; 32]);
let rem_res = seq_acc_store.unregister_account(address2).unwrap(); let rem_res = seq_acc_store.unregister_account([2; 32]).unwrap();
assert!(rem_res.is_none()); assert!(rem_res.is_none());
} }
#[test] #[test]
fn account_sequencer_store_unregister_acc_not_zero_balance() { fn account_sequencer_store_unregister_acc_not_zero_balance() {
let address1 = AccountAddress::new([1; 32]); let mut seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]);
let address2 = AccountAddress::new([2; 32]);
let mut seq_acc_store = SequencerAccountsStore::new(&[(address1, 12), (address2, 100)]); let rem_res = seq_acc_store.unregister_account([1; 32]);
let rem_res = seq_acc_store.unregister_account(address1);
assert!(rem_res.is_err()); assert!(rem_res.is_err());
} }
#[test] #[test]
fn account_sequencer_store_unregister_acc() { fn account_sequencer_store_unregister_acc() {
let address = AccountAddress::new([1; 32]);
let mut seq_acc_store = SequencerAccountsStore::default(); let mut seq_acc_store = SequencerAccountsStore::default();
seq_acc_store.register_account(address); seq_acc_store.register_account([1; 32]);
assert!(seq_acc_store.contains_account(&address)); assert!(seq_acc_store.contains_account(&[1; 32]));
seq_acc_store.unregister_account(address).unwrap().unwrap(); seq_acc_store.unregister_account([1; 32]).unwrap().unwrap();
assert!(!seq_acc_store.contains_account(&address)); assert!(!seq_acc_store.contains_account(&[1; 32]));
} }
#[test] #[test]
fn account_sequencer_store_with_preset_accounts_1() { fn account_sequencer_store_with_preset_accounts_1() {
let address1 = AccountAddress::new([1; 32]); let seq_acc_store = SequencerAccountsStore::new(&[([1; 32], 12), ([2; 32], 100)]);
let address2 = AccountAddress::new([2; 32]);
let seq_acc_store = SequencerAccountsStore::new(&[(address1, 12), (address2, 100)]); assert!(seq_acc_store.contains_account(&[1; 32]));
assert!(seq_acc_store.contains_account(&[2; 32]));
assert!(seq_acc_store.contains_account(&address1)); let acc_balance = seq_acc_store.get_account_balance(&[1; 32]);
assert!(seq_acc_store.contains_account(&address2));
let acc_balance = seq_acc_store.get_account_balance(&address1);
assert_eq!(acc_balance, 12); assert_eq!(acc_balance, 12);
let acc_balance = seq_acc_store.get_account_balance(&address2); let acc_balance = seq_acc_store.get_account_balance(&[2; 32]);
assert_eq!(acc_balance, 100); assert_eq!(acc_balance, 100);
} }
#[test] #[test]
fn account_sequencer_store_with_preset_accounts_2() { fn account_sequencer_store_with_preset_accounts_2() {
let address1 = AccountAddress::new([6; 32]);
let address2 = AccountAddress::new([7; 32]);
let address3 = AccountAddress::new([8; 32]);
let seq_acc_store = let seq_acc_store =
SequencerAccountsStore::new(&[(address1, 120), (address2, 15), (address3, 10)]); SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]);
assert!(seq_acc_store.contains_account(&address1)); assert!(seq_acc_store.contains_account(&[6; 32]));
assert!(seq_acc_store.contains_account(&address2)); assert!(seq_acc_store.contains_account(&[7; 32]));
assert!(seq_acc_store.contains_account(&address3)); assert!(seq_acc_store.contains_account(&[8; 32]));
let acc_balance = seq_acc_store.get_account_balance(&address1); let acc_balance = seq_acc_store.get_account_balance(&[6; 32]);
assert_eq!(acc_balance, 120); assert_eq!(acc_balance, 120);
let acc_balance = seq_acc_store.get_account_balance(&address2); let acc_balance = seq_acc_store.get_account_balance(&[7; 32]);
assert_eq!(acc_balance, 15); assert_eq!(acc_balance, 15);
let acc_balance = seq_acc_store.get_account_balance(&address3); let acc_balance = seq_acc_store.get_account_balance(&[8; 32]);
assert_eq!(acc_balance, 10); assert_eq!(acc_balance, 10);
} }
#[test] #[test]
fn account_sequencer_store_fetch_unknown_account() { fn account_sequencer_store_fetch_unknown_account() {
let address1 = AccountAddress::new([6; 32]);
let address2 = AccountAddress::new([7; 32]);
let address3 = AccountAddress::new([8; 32]);
let address4 = AccountAddress::new([9; 32]);
let seq_acc_store = let seq_acc_store =
SequencerAccountsStore::new(&[(address1, 120), (address2, 15), (address3, 10)]); SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]);
let acc_balance = seq_acc_store.get_account_balance(&address4); let acc_balance = seq_acc_store.get_account_balance(&[9; 32]);
assert_eq!(acc_balance, 0); assert_eq!(acc_balance, 0);
} }
@ -324,21 +293,19 @@ mod tests {
#[test] #[test]
fn account_sequencer_store_set_balance_to_unknown_account() { fn account_sequencer_store_set_balance_to_unknown_account() {
let address = AccountAddress::new([1; 32]);
let mut seq_acc_store = SequencerAccountsStore::default(); let mut seq_acc_store = SequencerAccountsStore::default();
let ret = seq_acc_store.set_account_balance(&address, 100); let ret = seq_acc_store.set_account_balance(&[1; 32], 100);
assert_eq!(ret, 0); assert_eq!(ret, 0);
assert!(seq_acc_store.contains_account(&address)); assert!(seq_acc_store.contains_account(&[1; 32]));
assert_eq!(seq_acc_store.get_account_balance(&address), 100); assert_eq!(seq_acc_store.get_account_balance(&[1; 32]), 100);
} }
#[test] #[test]
fn test_increase_nonce() { fn test_increase_nonce() {
let mut account_store = SequencerAccountsStore::default(); let mut account_store = SequencerAccountsStore::default();
let address = AccountAddress::new([1; 32]); let address = [1; 32];
let first_nonce = account_store.increase_nonce(&address); let first_nonce = account_store.increase_nonce(&address);
assert_eq!(first_nonce, 0); assert_eq!(first_nonce, 0);
let second_nonce = account_store.increase_nonce(&address); let second_nonce = account_store.increase_nonce(&address);

View File

@ -1,4 +1,3 @@
use accounts::account_core::address::AccountAddress;
use actix_web::Error as HttpError; use actix_web::Error as HttpError;
use sequencer_core::config::AccountInitialData; use sequencer_core::config::AccountInitialData;
use serde_json::Value; use serde_json::Value;
@ -73,7 +72,7 @@ impl JsonHandler {
{ {
let mut acc_store = self.sequencer_state.lock().await; let mut acc_store = self.sequencer_state.lock().await;
acc_store.register_account(AccountAddress::new(acc_req.address)); acc_store.register_account(acc_req.address);
} }
let helperstruct = RegisterAccountResponse { let helperstruct = RegisterAccountResponse {

View File

@ -82,7 +82,7 @@ mod tests {
let mut store = WalletAccountsStore::new(); let mut store = WalletAccountsStore::new();
let account_addr: [u8; 32] = pad_to_32("nonexistent".to_string().as_bytes()); let account_addr: [u8; 32] = pad_to_32("nonexistent".to_string().as_bytes());
store.unregister_account(AccountAddress::new(account_addr)); store.unregister_account(account_addr);
assert!(store.accounts.is_empty()); assert!(store.accounts.is_empty());
} }

View File

@ -1,6 +1,6 @@
use std::{fs::File, io::BufReader, path::PathBuf, str::FromStr}; use std::{fs::File, io::BufReader, path::PathBuf, str::FromStr};
use accounts::account_core::{address::AccountAddress, Account}; use accounts::account_core::Account;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use crate::{config::WalletConfig, HOME_DIR_ENV_VAR}; use crate::{config::WalletConfig, HOME_DIR_ENV_VAR};
@ -20,7 +20,7 @@ pub fn fetch_config() -> Result<WalletConfig> {
} }
//ToDo: Replace with structures conversion in future //ToDo: Replace with structures conversion in future
pub fn produce_account_addr_from_hex(hex_str: String) -> Result<AccountAddress> { pub fn produce_account_addr_from_hex(hex_str: String) -> Result<[u8; 32]> {
hex::decode(hex_str)? hex::decode(hex_str)?
.try_into() .try_into()
.map_err(|_| anyhow!("Failed conversion to 32 bytes")) .map_err(|_| anyhow!("Failed conversion to 32 bytes"))

View File

@ -86,9 +86,9 @@ impl WalletCore {
let tx: TransactionBody = let tx: TransactionBody =
sc_core::transaction_payloads_tools::create_public_transaction_payload( sc_core::transaction_payloads_tools::create_public_transaction_payload(
serde_json::to_vec(&PublicNativeTokenSend { serde_json::to_vec(&PublicNativeTokenSend {
from: from.raw_addr(), from,
nonce, nonce,
to: to.raw_addr(), to,
balance_to_move, balance_to_move,
}) })
.unwrap(), .unwrap(),

View File

@ -187,7 +187,7 @@ pub fn prove_send_utxo_shielded(
return Err(ExecutionFailureKind::AmountMismatchError); return Err(ExecutionFailureKind::AmountMismatchError);
} }
let temp_utxo_to_spend = UTXO::new(owner.raw_addr(), vec![], amount, true); let temp_utxo_to_spend = UTXO::new(owner, vec![], amount, true);
let utxo_payload = temp_utxo_to_spend.into_payload(); let utxo_payload = temp_utxo_to_spend.into_payload();
let mut builder = ExecutorEnv::builder(); let mut builder = ExecutorEnv::builder();
@ -561,7 +561,7 @@ mod tests {
let utxo_exec = execute_mint_utxo(amount, owner, randomness).expect("execution failed"); let utxo_exec = execute_mint_utxo(amount, owner, randomness).expect("execution failed");
assert_eq!(utxo_exec.amount, amount); assert_eq!(utxo_exec.amount, amount);
assert_eq!(utxo_exec.owner, owner.raw_addr()); assert_eq!(utxo_exec.owner, owner);
} }
#[test] #[test]
@ -571,7 +571,7 @@ mod tests {
let (utxo, _) = prove_mint_utxo(amount, owner).expect("proof failed"); let (utxo, _) = prove_mint_utxo(amount, owner).expect("proof failed");
assert_eq!(utxo.amount, amount); assert_eq!(utxo.amount, amount);
assert_eq!(utxo.owner, owner.raw_addr()); assert_eq!(utxo.owner, owner);
} }
#[test] #[test]