mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-02 13:23:08 +00:00
fetch accounts with zero balance when not seen before
This commit is contained in:
parent
98e63a3008
commit
b3e53bc32a
@ -13,6 +13,14 @@ fn main() {
|
||||
println!("📝 Initial balances");
|
||||
print_accounts(&sequencer, &[]);
|
||||
|
||||
// A public execution of the Transfer Program
|
||||
// User1 sends 3 tokens to another account
|
||||
USER_CLIENTS[1]
|
||||
.transfer_public(&[0xdeadbeef; 8], 3, &mut sequencer)
|
||||
.unwrap();
|
||||
println!("📝 Balances after transfer");
|
||||
print_accounts(&sequencer, &[]);
|
||||
|
||||
// A public execution of the Transfer Program
|
||||
// User1 sends 51 tokens to the piñata account
|
||||
USER_CLIENTS[1]
|
||||
@ -58,7 +66,7 @@ fn main() {
|
||||
// User1 claims the prize of the Piñata program to a new self-owned private account
|
||||
let another_private_account_user_1 = {
|
||||
// All of this is executed locally by the User1
|
||||
let pinata_account = sequencer.get_account(&PINATA_ADDRESS).unwrap();
|
||||
let pinata_account = sequencer.get_account(&PINATA_ADDRESS);
|
||||
let receiver_account = MockedClient::fresh_account_for_mint(USER_CLIENTS[1].user_address());
|
||||
let visibilities = [AccountVisibility::Public, AccountVisibility::Private(None)];
|
||||
let preimage = bytes_to_words(b"NSSA Selective privacy is great!").to_vec();
|
||||
|
||||
@ -21,7 +21,7 @@ impl MockedClient {
|
||||
let sender_commitment_auth_path = sequencer.get_authentication_path_for(&from_account.commitment());
|
||||
|
||||
// Fetch public account to deshield to
|
||||
let to_account = sequencer.get_account(to_address).unwrap();
|
||||
let to_account = sequencer.get_account(to_address);
|
||||
|
||||
// Set account visibilities
|
||||
// First entry is the private sender. Second entry is the public receiver
|
||||
|
||||
@ -18,7 +18,7 @@ impl MockedClient {
|
||||
let commitment_tree_root = sequencer.get_commitment_tree_root();
|
||||
|
||||
// Fetch sender account from the sequencer
|
||||
let from_account = sequencer.get_account(&self.user_address()).ok_or(Error::NotFound)?;
|
||||
let from_account = sequencer.get_account(&self.user_address());
|
||||
|
||||
// Create a new default private account for the receiver
|
||||
let to_account = Self::fresh_account_for_mint(*to_address);
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
NotFound,
|
||||
BadInput,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::NotFound => write!(f, "Not found"),
|
||||
Error::BadInput => write!(f, "Bad input"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@ impl MockedSequencer {
|
||||
}
|
||||
|
||||
/// Returns the current state of the account for the given address
|
||||
pub fn get_account(&self, address: &Address) -> Option<Account> {
|
||||
self.accounts.get(address).cloned()
|
||||
pub fn get_account(&self, address: &Address) -> Account {
|
||||
self.accounts.get(address).cloned().unwrap_or(Account::new(*address, 0))
|
||||
}
|
||||
|
||||
/// Returns the root of the commitment tree
|
||||
|
||||
@ -15,7 +15,7 @@ impl MockedSequencer {
|
||||
// Reject if the states of the public input accounts used in the inner execution do not
|
||||
// coincide with the on-chain state.
|
||||
for account in output.public_accounts_pre.iter() {
|
||||
let current_account = self.get_account(&account.address).ok_or(Error::NotFound)?;
|
||||
let current_account = self.get_account(&account.address);
|
||||
if ¤t_account != account {
|
||||
return Err(Error::BadInput);
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ impl MockedSequencer {
|
||||
// Fetch the current state of the input accounts.
|
||||
let input_accounts: Vec<Account> = input_account_addresses
|
||||
.iter()
|
||||
.map(|address| self.get_account(address).ok_or(Error::NotFound))
|
||||
.collect::<Result<_, _>>()?;
|
||||
.map(|address| self.get_account(address))
|
||||
.collect();
|
||||
|
||||
// Execute the program
|
||||
let program_output =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user