mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-25 03:11:21 +00:00
Merge remote-tracking branch 'origin/dev' into moudy/cross-zone-target-auth
# Conflicts: # Cargo.lock # artifacts/lez/programs/amm.bin # artifacts/lez/programs/associated_token_account.bin # artifacts/lez/programs/authenticated_transfer.bin # artifacts/lez/programs/bridge.bin # artifacts/lez/programs/bridge_lock.bin # artifacts/lez/programs/clock.bin # artifacts/lez/programs/cross_zone_inbox.bin # artifacts/lez/programs/cross_zone_outbox.bin # artifacts/lez/programs/faucet.bin # artifacts/lez/programs/pinata.bin # artifacts/lez/programs/pinata_token.bin # artifacts/lez/programs/ping_receiver.bin # artifacts/lez/programs/ping_sender.bin # artifacts/lez/programs/token.bin # artifacts/lez/programs/vault.bin # artifacts/lez/programs/wrapped_token.bin # test_fixtures/fixtures/prebuilt_sequencer_db.dump
This commit is contained in:
@@ -5,7 +5,7 @@ use risc0_zkvm::serde::to_vec;
|
||||
|
||||
/// Proxy for spending from a private PDA via `auth_transfer`.
|
||||
///
|
||||
/// `pre_states = [pda (authorized), recipient]`. Debits the PDA and credits the recipient.
|
||||
/// `pre_states = [pda, recipient]`. Debits the PDA and credits the recipient.
|
||||
/// The PDA-to-npk binding is established via `pda_seeds` in the chained call to `auth_transfer`.
|
||||
type Instruction = (PdaSeed, u128, ProgramId);
|
||||
|
||||
@@ -24,16 +24,17 @@ fn main() {
|
||||
return;
|
||||
};
|
||||
|
||||
assert!(first.is_authorized, "first pre_state must be authorized");
|
||||
|
||||
let first_post = AccountPostState::new(first.account.clone());
|
||||
let second_post = AccountPostState::new(second.account.clone());
|
||||
|
||||
let mut first_for_callee = first.clone();
|
||||
first_for_callee.is_authorized = true;
|
||||
|
||||
let chained_call = ChainedCall {
|
||||
program_id: auth_transfer_id,
|
||||
instruction_data: to_vec(&authenticated_transfer_core::Instruction::Transfer { amount })
|
||||
.unwrap(),
|
||||
pre_states: vec![first.clone(), second.clone()],
|
||||
pre_states: vec![first_for_callee, second.clone()],
|
||||
pda_seeds: vec![seed],
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
|
||||
|
||||
type Instruction = u128;
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
ProgramInput {
|
||||
self_program_id,
|
||||
caller_program_id,
|
||||
pre_states,
|
||||
instruction: balance,
|
||||
},
|
||||
instruction_words,
|
||||
) = read_lee_inputs::<Instruction>();
|
||||
|
||||
if let Ok([account_pre]) = <[_; 1]>::try_from(pre_states.clone()) {
|
||||
let account_post =
|
||||
AccountPostState::new_claimed_if_default(account_pre.account, Claim::Authorized);
|
||||
|
||||
ProgramOutput::new(
|
||||
self_program_id,
|
||||
caller_program_id,
|
||||
instruction_words,
|
||||
pre_states,
|
||||
vec![account_post],
|
||||
)
|
||||
.write();
|
||||
return;
|
||||
}
|
||||
|
||||
let Ok([sender_pre, receiver_pre]) = <[_; 2]>::try_from(pre_states) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut sender_post = sender_pre.account.clone();
|
||||
let mut receiver_post = receiver_pre.account.clone();
|
||||
sender_post.balance = sender_post
|
||||
.balance
|
||||
.checked_sub(balance)
|
||||
.expect("Not enough balance to transfer");
|
||||
receiver_post.balance = receiver_post
|
||||
.balance
|
||||
.checked_add(balance)
|
||||
.expect("Overflow when adding balance");
|
||||
|
||||
ProgramOutput::new(
|
||||
self_program_id,
|
||||
caller_program_id,
|
||||
instruction_words,
|
||||
vec![sender_pre, receiver_pre],
|
||||
vec![
|
||||
AccountPostState::new_claimed_if_default(sender_post, Claim::Authorized),
|
||||
AccountPostState::new_claimed_if_default(receiver_post, Claim::Authorized),
|
||||
],
|
||||
)
|
||||
.write();
|
||||
}
|
||||
@@ -11,6 +11,21 @@ mod guests {
|
||||
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn simple_balance_transfer() -> Program {
|
||||
use guests::{
|
||||
SIMPLE_BALANCE_TRANSFER_ELF, SIMPLE_BALANCE_TRANSFER_ID, SIMPLE_BALANCE_TRANSFER_PATH,
|
||||
};
|
||||
|
||||
let _unused = SIMPLE_BALANCE_TRANSFER_PATH;
|
||||
|
||||
Program::new_unchecked(
|
||||
SIMPLE_BALANCE_TRANSFER_ID,
|
||||
Cow::Borrowed(SIMPLE_BALANCE_TRANSFER_ELF),
|
||||
)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn chain_caller() -> Program {
|
||||
|
||||
Reference in New Issue
Block a user