mirror of
https://github.com/logos-blockchain/lssa-zkvm-testing.git
synced 2026-01-03 22:03:10 +00:00
improve comments in happy path example
This commit is contained in:
parent
fe7727a93c
commit
af7d3675a1
@ -1,12 +1,8 @@
|
||||
use core::{
|
||||
bytes_to_words,
|
||||
types::Address,
|
||||
visibility::InputVisibiility,
|
||||
};
|
||||
use core::{bytes_to_words, types::Address, visibility::InputVisibiility};
|
||||
|
||||
use nssa::program::PinataProgram;
|
||||
|
||||
use crate::mocked_components::sequencer::{print_accounts, MockedSequencer};
|
||||
use crate::mocked_components::sequencer::{print_accounts, MockedSequencer, PINATA_ADDRESS};
|
||||
use crate::mocked_components::{client::MockedClient, USER_CLIENTS};
|
||||
|
||||
mod mocked_components;
|
||||
@ -18,13 +14,15 @@ fn main() {
|
||||
print_accounts(&sequencer, &[]);
|
||||
|
||||
// A public execution of the Transfer Program
|
||||
// User1 sends 51 tokens to the piñata account
|
||||
USER_CLIENTS[1]
|
||||
.transfer_public(&[0xcafe; 8], 51, &mut sequencer)
|
||||
.transfer_public(&PINATA_ADDRESS, 51, &mut sequencer)
|
||||
.unwrap();
|
||||
println!("📝 Balances after transfer");
|
||||
print_accounts(&sequencer, &[]);
|
||||
|
||||
// A shielded execution of the Transfer Program
|
||||
// User0 shields 15 tokens to a new private account of User1
|
||||
let private_account_user_1 = USER_CLIENTS[0]
|
||||
.transfer_shielded(&addresses[1], 15, &mut sequencer)
|
||||
.unwrap();
|
||||
@ -32,6 +30,7 @@ fn main() {
|
||||
print_accounts(&sequencer, &[&private_account_user_1]);
|
||||
|
||||
// A private execution of the Transfer Program
|
||||
// User1 uses it's private account to send 8 tokens to a new private account of User2
|
||||
let [private_account_user_1, private_account_user_2] = USER_CLIENTS[1]
|
||||
.transfer_private(private_account_user_1, &addresses[2], 8, &mut sequencer)
|
||||
.unwrap();
|
||||
@ -39,26 +38,28 @@ fn main() {
|
||||
print_accounts(&sequencer, &[&private_account_user_1, &private_account_user_2]);
|
||||
|
||||
// A deshielded execution of the Transfer Program
|
||||
let private_acount_user_2 = USER_CLIENTS[2]
|
||||
// User2 deshields 1 token to the public account of User0
|
||||
let private_account_user_2 = USER_CLIENTS[2]
|
||||
.transfer_deshielded(private_account_user_2, &addresses[0], 1, &mut sequencer)
|
||||
.unwrap();
|
||||
println!("📝 Balances after deshielded execution");
|
||||
print_accounts(&sequencer, &[&private_account_user_1, &private_acount_user_2]);
|
||||
print_accounts(&sequencer, &[&private_account_user_1, &private_account_user_2]);
|
||||
|
||||
// A public execution of the Piñata program
|
||||
// User2 claims the prize of the Piñata program to its public account
|
||||
let preimage = bytes_to_words(b"NSSA Selective privacy is great!").to_vec();
|
||||
sequencer
|
||||
.process_public_execution::<PinataProgram>(&[[0xcafe; 8], addresses[2]], preimage)
|
||||
.process_public_execution::<PinataProgram>(&[PINATA_ADDRESS, addresses[2]], preimage)
|
||||
.unwrap();
|
||||
println!("📝 Balances after public piñata execution");
|
||||
print_accounts(&sequencer, &[&private_account_user_1, &private_acount_user_2]);
|
||||
print_accounts(&sequencer, &[&private_account_user_1, &private_account_user_2]);
|
||||
|
||||
// A deshielded execution of the Piñata program
|
||||
// User1 claims the prize of the Piñata program to a new self-owned private account
|
||||
let private_account_user_0 = {
|
||||
// All of this is executed locally by the sender
|
||||
let receiver_addr = USER_CLIENTS[1].user_address();
|
||||
let pinata_account = sequencer.get_account(&[0xcafe; 8]).unwrap();
|
||||
let receiver_account = MockedClient::fresh_account_for_mint(receiver_addr);
|
||||
// All of this is executed locally by the User1
|
||||
let pinata_account = sequencer.get_account(&PINATA_ADDRESS).unwrap();
|
||||
let receiver_account = MockedClient::fresh_account_for_mint(USER_CLIENTS[1].user_address());
|
||||
let visibilities = [InputVisibiility::Public, InputVisibiility::Private(None)];
|
||||
let preimage = bytes_to_words(b"NSSA Selective privacy is great!").to_vec();
|
||||
|
||||
@ -76,7 +77,7 @@ fn main() {
|
||||
println!("📝 Balances after private piñata execution");
|
||||
print_accounts(
|
||||
&sequencer,
|
||||
&[&private_account_user_1, &private_acount_user_2, &private_account_user_0],
|
||||
&[&private_account_user_1, &private_account_user_2, &private_account_user_0],
|
||||
);
|
||||
|
||||
println!("Ok!");
|
||||
|
||||
@ -25,7 +25,7 @@ const DEPLOYED_PROGRAM_IDS: [ProgramId; 3] = [TRANSFER_ID, TRANSFER_MULTIPLE_ID,
|
||||
/// The initial balance of the genesis accounts
|
||||
const INITIAL_BALANCE: u128 = 150;
|
||||
/// The address of the piñata program account
|
||||
const PINATA_ADDRESS: Address = [0xcafe; 8];
|
||||
pub const PINATA_ADDRESS: Address = [0xcafe; 8];
|
||||
|
||||
impl MockedSequencer {
|
||||
pub fn new() -> Self {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user