Do message payment within same instruction
Change-Id: Id1e3ac10bcdc7e91c649f5e75caf8a98e27be0c6
This commit is contained in:
parent
cdcf6f5d14
commit
62f5cb1986
|
@ -64,9 +64,10 @@ impl<'b> InstructionContext<'b> for PostMessage<'b> {
|
|||
|
||||
#[derive(BorshDeserialize, BorshSerialize, Default)]
|
||||
pub struct PostMessageData {
|
||||
/// unique nonce for this message
|
||||
/// Unique nonce for this message
|
||||
pub nonce: u32,
|
||||
/// message payload
|
||||
|
||||
/// Message payload
|
||||
pub payload: Vec<u8>,
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ pub fn post_message(
|
|||
payload: data.payload.clone(),
|
||||
};
|
||||
|
||||
trace!("Verifying Message: {}, {}", accs.emitter.key, data.nonce,);
|
||||
trace!("Verifying Message: {}, {}", accs.emitter.key, data.nonce);
|
||||
|
||||
accs.message
|
||||
.verify_derivation(ctx.program_id, &msg_derivation)?;
|
||||
|
|
|
@ -152,14 +152,21 @@ mod helpers {
|
|||
) -> Pubkey {
|
||||
// Transfer money into the fee collector as it needs a balance/must exist.
|
||||
let fee_collector = FeeCollector::<'_>::key(None, program);
|
||||
transfer(client, payer, &fee_collector, 10_000);
|
||||
|
||||
// Capture the resulting message, later functions will need this.
|
||||
let (message_key, instruction) =
|
||||
instructions::post_message(*program, payer.pubkey(), emitter.pubkey(), nonce, data)
|
||||
.unwrap();
|
||||
|
||||
execute(client, payer, &[payer, emitter], &[instruction]);
|
||||
execute(
|
||||
client,
|
||||
payer,
|
||||
&[payer, emitter],
|
||||
&[
|
||||
system_instruction::transfer(&payer.pubkey(), &fee_collector, 10_000),
|
||||
instruction,
|
||||
],
|
||||
);
|
||||
|
||||
message_key
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue