mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-26 11:51:13 +00:00
feat(cross-zone): add ping_sender and thread target_accounts through outbox emission
This commit is contained in:
@@ -20,13 +20,20 @@ fn main() {
|
||||
"Outbox is only callable through a chain call from a user program"
|
||||
);
|
||||
|
||||
let (target_zone, target_program_id, payload, ordinal) = match instruction {
|
||||
let (target_zone, target_program_id, target_accounts, payload, ordinal) = match instruction {
|
||||
Instruction::Emit {
|
||||
target_zone,
|
||||
target_program_id,
|
||||
target_accounts,
|
||||
payload,
|
||||
ordinal,
|
||||
} => (target_zone, target_program_id, payload, ordinal),
|
||||
} => (
|
||||
target_zone,
|
||||
target_program_id,
|
||||
target_accounts,
|
||||
payload,
|
||||
ordinal,
|
||||
),
|
||||
};
|
||||
|
||||
let [outbox] =
|
||||
@@ -42,6 +49,7 @@ fn main() {
|
||||
post_account.data = OutboxRecord {
|
||||
target_zone,
|
||||
target_program_id,
|
||||
target_accounts,
|
||||
payload,
|
||||
}
|
||||
.to_bytes()
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
use cross_zone_outbox_core::Instruction as OutboxInstruction;
|
||||
use lee_core::{
|
||||
account::AccountWithMetadata,
|
||||
program::{AccountPostState, ChainedCall, ProgramInput, ProgramOutput, read_lee_inputs},
|
||||
};
|
||||
use ping_core::SenderInstruction;
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
ProgramInput {
|
||||
self_program_id,
|
||||
caller_program_id,
|
||||
pre_states,
|
||||
instruction,
|
||||
},
|
||||
instruction_words,
|
||||
) = read_lee_inputs::<SenderInstruction>();
|
||||
|
||||
assert!(
|
||||
caller_program_id.is_none(),
|
||||
"ping_sender is only invoked as a top-level user transaction"
|
||||
);
|
||||
|
||||
let SenderInstruction::Send {
|
||||
outbox_program_id,
|
||||
target_zone,
|
||||
target_program_id,
|
||||
target_accounts,
|
||||
payload,
|
||||
ordinal,
|
||||
} = instruction;
|
||||
|
||||
// The single account is the outbox PDA the chained call writes into; the
|
||||
// outbox claims it, so ping_sender forwards it unchanged.
|
||||
let [outbox] =
|
||||
<[AccountWithMetadata; 1]>::try_from(pre_states).expect("Send requires exactly 1 account");
|
||||
|
||||
let call = ChainedCall::new(
|
||||
outbox_program_id,
|
||||
vec![outbox.clone()],
|
||||
&OutboxInstruction::Emit {
|
||||
target_zone,
|
||||
target_program_id,
|
||||
target_accounts,
|
||||
payload,
|
||||
ordinal,
|
||||
},
|
||||
);
|
||||
|
||||
ProgramOutput::new(
|
||||
self_program_id,
|
||||
caller_program_id,
|
||||
instruction_words,
|
||||
vec![outbox.clone()],
|
||||
vec![AccountPostState::new(outbox.account)],
|
||||
)
|
||||
.with_chained_calls(vec![call])
|
||||
.write();
|
||||
}
|
||||
Reference in New Issue
Block a user