Make message a signer in CPI, improve attest ix signature
Change-Id: I5136a62d5b0b7617b4dc3e3e2a17614a68908f3f
This commit is contained in:
parent
eb457f9e1e
commit
fae219e427
|
@ -79,7 +79,7 @@ pub struct AttestToken<'b> {
|
||||||
pub bridge: Mut<Info<'b>>,
|
pub bridge: Mut<Info<'b>>,
|
||||||
|
|
||||||
/// Account to store the posted message
|
/// Account to store the posted message
|
||||||
pub message: Mut<Info<'b>>,
|
pub message: Signer<Mut<Info<'b>>>,
|
||||||
|
|
||||||
/// Emitter of the VAA
|
/// Emitter of the VAA
|
||||||
pub emitter: EmitterAccount<'b>,
|
pub emitter: EmitterAccount<'b>,
|
||||||
|
@ -172,7 +172,7 @@ pub fn attest_token(
|
||||||
params.try_to_vec()?.as_slice(),
|
params.try_to_vec()?.as_slice(),
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(*accs.bridge.key, false),
|
AccountMeta::new(*accs.bridge.key, false),
|
||||||
AccountMeta::new(*accs.message.key, false),
|
AccountMeta::new(*accs.message.key, true),
|
||||||
AccountMeta::new_readonly(*accs.emitter.key, true),
|
AccountMeta::new_readonly(*accs.emitter.key, true),
|
||||||
AccountMeta::new(*accs.sequence.key, false),
|
AccountMeta::new(*accs.sequence.key, false),
|
||||||
AccountMeta::new(*accs.payer.key, true),
|
AccountMeta::new(*accs.payer.key, true),
|
||||||
|
|
|
@ -83,7 +83,7 @@ pub struct TransferNative<'b> {
|
||||||
pub bridge: Mut<Info<'b>>,
|
pub bridge: Mut<Info<'b>>,
|
||||||
|
|
||||||
/// Account to store the posted message
|
/// Account to store the posted message
|
||||||
pub message: Mut<Info<'b>>,
|
pub message: Signer<Mut<Info<'b>>>,
|
||||||
|
|
||||||
/// Emitter of the VAA
|
/// Emitter of the VAA
|
||||||
pub emitter: EmitterAccount<'b>,
|
pub emitter: EmitterAccount<'b>,
|
||||||
|
@ -191,7 +191,7 @@ pub fn transfer_native(
|
||||||
params.try_to_vec()?.as_slice(),
|
params.try_to_vec()?.as_slice(),
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(*accs.bridge.key, false),
|
AccountMeta::new(*accs.bridge.key, false),
|
||||||
AccountMeta::new(*accs.message.key, false),
|
AccountMeta::new(*accs.message.key, true),
|
||||||
AccountMeta::new_readonly(*accs.emitter.key, true),
|
AccountMeta::new_readonly(*accs.emitter.key, true),
|
||||||
AccountMeta::new(*accs.sequence.key, false),
|
AccountMeta::new(*accs.sequence.key, false),
|
||||||
AccountMeta::new(*accs.payer.key, true),
|
AccountMeta::new(*accs.payer.key, true),
|
||||||
|
@ -222,7 +222,7 @@ pub struct TransferWrapped<'b> {
|
||||||
pub bridge: Mut<Info<'b>>,
|
pub bridge: Mut<Info<'b>>,
|
||||||
|
|
||||||
/// Account to store the posted message
|
/// Account to store the posted message
|
||||||
pub message: Mut<Info<'b>>,
|
pub message: Signer<Mut<Info<'b>>>,
|
||||||
|
|
||||||
/// Emitter of the VAA
|
/// Emitter of the VAA
|
||||||
pub emitter: EmitterAccount<'b>,
|
pub emitter: EmitterAccount<'b>,
|
||||||
|
@ -324,7 +324,7 @@ pub fn transfer_wrapped(
|
||||||
params.try_to_vec()?.as_slice(),
|
params.try_to_vec()?.as_slice(),
|
||||||
vec![
|
vec![
|
||||||
AccountMeta::new(*accs.bridge.key, false),
|
AccountMeta::new(*accs.bridge.key, false),
|
||||||
AccountMeta::new(*accs.message.key, false),
|
AccountMeta::new(*accs.message.key, true),
|
||||||
AccountMeta::new_readonly(*accs.emitter.key, true),
|
AccountMeta::new_readonly(*accs.emitter.key, true),
|
||||||
AccountMeta::new(*accs.sequence.key, false),
|
AccountMeta::new(*accs.sequence.key, false),
|
||||||
AccountMeta::new(*accs.payer.key, true),
|
AccountMeta::new(*accs.payer.key, true),
|
||||||
|
|
|
@ -448,7 +448,6 @@ pub fn attest(
|
||||||
payer: Pubkey,
|
payer: Pubkey,
|
||||||
message_key: Pubkey,
|
message_key: Pubkey,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
decimals: u8,
|
|
||||||
nonce: u32,
|
nonce: u32,
|
||||||
) -> solitaire::Result<Instruction> {
|
) -> solitaire::Result<Instruction> {
|
||||||
let config_key = ConfigAccount::<'_, { AccountState::Uninitialized }>::key(None, &program_id);
|
let config_key = ConfigAccount::<'_, { AccountState::Uninitialized }>::key(None, &program_id);
|
||||||
|
@ -462,9 +461,7 @@ pub fn attest(
|
||||||
|
|
||||||
// Mint Metadata
|
// Mint Metadata
|
||||||
let mint_meta = WrappedTokenMeta::<'_, { AccountState::Uninitialized }>::key(
|
let mint_meta = WrappedTokenMeta::<'_, { AccountState::Uninitialized }>::key(
|
||||||
&WrappedMetaDerivationData {
|
&WrappedMetaDerivationData { mint_key: mint },
|
||||||
mint_key: mint,
|
|
||||||
},
|
|
||||||
&bridge_id,
|
&bridge_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ pub fn attest_ix(
|
||||||
payer: String,
|
payer: String,
|
||||||
message: String,
|
message: String,
|
||||||
mint: String,
|
mint: String,
|
||||||
decimals: u8,
|
|
||||||
nonce: u32,
|
nonce: u32,
|
||||||
) -> JsValue {
|
) -> JsValue {
|
||||||
let program_id = Pubkey::from_str(program_id.as_str()).unwrap();
|
let program_id = Pubkey::from_str(program_id.as_str()).unwrap();
|
||||||
|
@ -66,16 +65,7 @@ pub fn attest_ix(
|
||||||
let message = Pubkey::from_str(message.as_str()).unwrap();
|
let message = Pubkey::from_str(message.as_str()).unwrap();
|
||||||
let mint = Pubkey::from_str(mint.as_str()).unwrap();
|
let mint = Pubkey::from_str(mint.as_str()).unwrap();
|
||||||
|
|
||||||
let ix = attest(
|
let ix = attest(program_id, bridge_id, payer, message, mint, nonce).unwrap();
|
||||||
program_id,
|
|
||||||
bridge_id,
|
|
||||||
payer,
|
|
||||||
message,
|
|
||||||
mint,
|
|
||||||
decimals,
|
|
||||||
nonce,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
JsValue::from_serde(&ix).unwrap()
|
JsValue::from_serde(&ix).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,10 @@ mod helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch account data, the loop is there to re-attempt until data is available.
|
/// Fetch account data, the loop is there to re-attempt until data is available.
|
||||||
pub fn get_account_data<T: BorshDeserialize>(client: &RpcClient, account: &Pubkey) -> Option<T> {
|
pub fn get_account_data<T: BorshDeserialize>(
|
||||||
|
client: &RpcClient,
|
||||||
|
account: &Pubkey,
|
||||||
|
) -> Option<T> {
|
||||||
let account = client
|
let account = client
|
||||||
.get_account_with_commitment(account, CommitmentConfig::processed())
|
.get_account_with_commitment(account, CommitmentConfig::processed())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -516,8 +519,7 @@ mod helpers {
|
||||||
client,
|
client,
|
||||||
payer,
|
payer,
|
||||||
&[payer, mint_authority],
|
&[payer, mint_authority],
|
||||||
&[
|
&[spl_token_metadata::instruction::create_metadata_accounts(
|
||||||
spl_token_metadata::instruction::create_metadata_accounts(
|
|
||||||
spl_token_metadata::id(),
|
spl_token_metadata::id(),
|
||||||
*metadata_account,
|
*metadata_account,
|
||||||
mint.pubkey(),
|
mint.pubkey(),
|
||||||
|
@ -531,8 +533,7 @@ mod helpers {
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
)
|
)],
|
||||||
],
|
|
||||||
CommitmentConfig::processed(),
|
CommitmentConfig::processed(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
use {
|
use crate::state::{
|
||||||
crate::{
|
Creator,
|
||||||
state::{Creator, Data, EDITION, EDITION_MARKER_BIT_SIZE, PREFIX},
|
Data,
|
||||||
|
EDITION,
|
||||||
|
EDITION_MARKER_BIT_SIZE,
|
||||||
|
PREFIX,
|
||||||
|
};
|
||||||
|
use borsh::{
|
||||||
|
BorshDeserialize,
|
||||||
|
BorshSerialize,
|
||||||
|
};
|
||||||
|
use solana_program::{
|
||||||
|
instruction::{
|
||||||
|
AccountMeta,
|
||||||
|
Instruction,
|
||||||
},
|
},
|
||||||
borsh::{BorshDeserialize, BorshSerialize},
|
|
||||||
solana_program::{
|
|
||||||
instruction::{AccountMeta, Instruction},
|
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
sysvar,
|
sysvar,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use crate::{
|
use crate::utils::try_from_slice_checked;
|
||||||
utils::try_from_slice_checked,
|
|
||||||
};
|
|
||||||
use borsh::{
|
use borsh::{
|
||||||
BorshDeserialize,
|
BorshDeserialize,
|
||||||
BorshSerialize,
|
BorshSerialize,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{
|
use crate::state::{
|
||||||
state::{
|
|
||||||
Data,
|
Data,
|
||||||
Key,
|
Key,
|
||||||
Metadata,
|
Metadata,
|
||||||
|
@ -14,7 +13,6 @@ use crate::{
|
||||||
MAX_SYMBOL_LENGTH,
|
MAX_SYMBOL_LENGTH,
|
||||||
MAX_URI_LENGTH,
|
MAX_URI_LENGTH,
|
||||||
PREFIX,
|
PREFIX,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use borsh::{
|
use borsh::{
|
||||||
BorshDeserialize,
|
BorshDeserialize,
|
||||||
|
|
Loading…
Reference in New Issue