Implement optional persistence in Solana wormhole

Also reformatted the token_bridge

Change-Id: I195d7e2e13295c8b28e2a0b63620e3d306dc07e6
This commit is contained in:
Hendrik Hofstadt 2021-07-02 19:59:59 +02:00
parent 3fd60e822a
commit d9fde6d7cc
19 changed files with 246 additions and 360 deletions

View File

@ -10,6 +10,8 @@ WORKDIR /usr/src/solana
ADD solana /usr/src/solana
ADD proto /usr/src/proto
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
RUN --mount=type=cache,target=/usr/local/cargo,from=rust,source=/usr/local/cargo \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \

View File

@ -120,7 +120,13 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
},
{
Memcmp: &rpc.RPCFilterMemcmp{
Offset: 4, // Offset of VaaTime
Offset: 4, // Start of the Persist flag
Bytes: solana.Base58{0x01}, // Only grab messages that need to be persisted
},
},
{
Memcmp: &rpc.RPCFilterMemcmp{
Offset: 5, // Offset of VaaTime
Bytes: solana.Base58{0, 0, 0, 0}, // This means this VAA hasn't been signed yet
},
},
@ -188,7 +194,9 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
type (
MessagePublicationAccount struct {
VaaVersion uint8
VaaVersion uint8
// Borsh does not seem to support booleans, so 0=false / 1=true
Persist uint8
VaaTime uint32
VaaSignatureAccount vaa.Address
SubmissionTime uint32

View File

@ -10,6 +10,7 @@ RUN sh -c "$(curl -sSfL https://release.solana.com/edge/install)"
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV EMITTER_ADDRESS="11111111111111111111111111111115"
COPY bridge bridge
COPY modules modules

View File

@ -111,6 +111,7 @@ fn command_post_message(
bridge: &Pubkey,
nonce: u32,
payload: Vec<u8>,
persist: bool,
) -> CommmandResult {
println!("Posting a message to the wormhole");
@ -134,6 +135,7 @@ fn command_post_message(
config.fee_payer.pubkey(),
nonce,
payload,
persist,
)
.unwrap();
let mut transaction =
@ -267,6 +269,13 @@ fn main() {
.index(3)
.required(true)
.help("Payload of the message"),
)
.arg(
Arg::with_name("persist")
.short("p")
.long("persist")
.takes_value(false)
.help("Indicates that the VAA should be persisted on-chain"),
),
)
.get_matches();
@ -322,8 +331,9 @@ fn main() {
let data_str: String = value_of(arg_matches, "data").unwrap();
let data = hex::decode(data_str).unwrap();
let nonce: u32 = value_of(arg_matches, "nonce").unwrap();
let persist = arg_matches.is_present("persist");
command_post_message(&config, &bridge, nonce, data)
command_post_message(&config, &bridge, nonce, data, persist)
}
_ => unreachable!(),

View File

@ -71,6 +71,9 @@ pub struct PostMessageData {
/// Message payload
pub payload: Vec<u8>,
/// Should the VAA for this message be persisted on-chain
pub persist: bool,
}
pub fn post_message(
@ -127,6 +130,7 @@ pub fn post_message(
accs.message.nonce = data.nonce;
accs.message.payload = data.payload;
accs.message.sequence = accs.sequence.sequence;
accs.message.persist = data.persist;
// Create message account
accs.message

View File

@ -79,6 +79,7 @@ pub fn post_message(
emitter: Pubkey,
nonce: u32,
payload: Vec<u8>,
persist: bool,
) -> solitaire::Result<(Pubkey, Instruction)> {
let bridge = Bridge::<'_, { AccountState::Uninitialized }>::key(None, &program_id);
let fee_collector = FeeCollector::<'_>::key(None, &program_id);
@ -99,27 +100,31 @@ pub fn post_message(
&program_id,
);
Ok((message, Instruction {
program_id,
Ok((
message,
Instruction {
program_id,
accounts: vec![
AccountMeta::new(bridge, false),
AccountMeta::new(message, false),
AccountMeta::new(emitter, true),
AccountMeta::new(sequence, false),
AccountMeta::new(payer, true),
AccountMeta::new(fee_collector, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
AccountMeta::new_readonly(sysvar::rent::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
],
accounts: vec![
AccountMeta::new(bridge, false),
AccountMeta::new(message, false),
AccountMeta::new(emitter, true),
AccountMeta::new(sequence, false),
AccountMeta::new(payer, true),
AccountMeta::new(fee_collector, false),
AccountMeta::new_readonly(sysvar::clock::id(), false),
AccountMeta::new_readonly(sysvar::rent::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
],
data: crate::instruction::Instruction::PostMessage(PostMessageData {
nonce,
payload: payload.clone(),
})
.try_to_vec()?,
}))
data: crate::instruction::Instruction::PostMessage(PostMessageData {
nonce,
payload: payload.clone(),
persist,
})
.try_to_vec()?,
},
))
}
pub fn verify_signatures(

View File

@ -162,6 +162,9 @@ pub struct PostedMessageData {
/// Header of the posted VAA
pub vaa_version: u8,
/// Whether the VAA for this message should be persisted
pub persist: bool,
/// Time the vaa was submitted
pub vaa_time: u32,

View File

@ -1,48 +1,29 @@
use borsh::BorshSerialize;
use bridge::{
api,
types,
};
use bridge::{api, types};
use clap::Clap;
use solana_client::{
rpc_client::RpcClient,
rpc_config::RpcSendTransactionConfig,
};
use solana_client::{rpc_client::RpcClient, rpc_config::RpcSendTransactionConfig};
use solana_program::pubkey::Pubkey;
use solana_sdk::{
commitment_config::CommitmentConfig,
signature::{
read_keypair_file,
Signer as SolSigner,
},
signature::{read_keypair_file, Signer as SolSigner},
transaction::Transaction,
};
use solitaire_client::{
AccEntry,
ToInstruction,
};
use solitaire_client::{AccEntry, ToInstruction};
use bridge::accounts::{
GuardianSet,
GuardianSetDerivationData,
};
use solitaire::{
processors::seeded::Seeded,
AccountState,
};
use std::error;
use solana_sdk::instruction::Instruction;
use solana_sdk::signature::Keypair;
use solana_sdk::client::Client;
use solana_client::rpc_request::RpcError;
use bridge::accounts::{GuardianSet, GuardianSetDerivationData};
use solana_client::client_error::{ClientError, ClientErrorKind};
use solana_client::rpc_request::RpcError;
use solana_sdk::client::Client;
use solana_sdk::instruction::Instruction;
use solana_sdk::program_pack::Pack;
use solana_sdk::rent::Rent;
use token_bridge::api::{AttestTokenData, TransferNativeData};
use solana_sdk::signature::Keypair;
use solitaire::{processors::seeded::Seeded, AccountState};
use solitaire_client::solana_sdk::account::ReadableAccount;
use spl_token::instruction::TokenInstruction::Transfer;
use spl_token::state::Mint;
use solitaire_client::solana_sdk::account::ReadableAccount;
use std::error;
use token_bridge::api::{AttestTokenData, TransferNativeData};
#[derive(Clap)]
pub struct Opts {
@ -95,62 +76,137 @@ fn main() -> Result<(), ErrBox> {
let payer = read_keypair_file(&*shellexpand::tilde("~/.config/solana/id.json"))
.expect("Example requires a keypair file");
let token_program_id = opts.token_address;
let init_token = token_bridge::instructions::initialize(token_program_id, payer.pubkey(), program_id).unwrap();
let init_token =
token_bridge::instructions::initialize(token_program_id, payer.pubkey(), program_id)
.unwrap();
send_ix_in_tx(&client, init_token, &payer, vec![&payer])?;
// Create a token
let mint_authority = Keypair::new();
let mint = Keypair::new();
let init_mint_account = solana_sdk::system_instruction::create_account(&payer.pubkey(), &mint.pubkey(), Rent::default().minimum_balance(spl_token::state::Mint::LEN), spl_token::state::Mint::LEN as u64, &spl_token::id());
let init_mint = spl_token::instruction::initialize_mint(&spl_token::id(), &mint.pubkey(), &mint_authority.pubkey(), None, 8)?;
let init_mint_account = solana_sdk::system_instruction::create_account(
&payer.pubkey(),
&mint.pubkey(),
Rent::default().minimum_balance(spl_token::state::Mint::LEN),
spl_token::state::Mint::LEN as u64,
&spl_token::id(),
);
let init_mint = spl_token::instruction::initialize_mint(
&spl_token::id(),
&mint.pubkey(),
&mint_authority.pubkey(),
None,
8,
)?;
send_ix_in_tx(&client, init_mint_account, &payer, vec![&payer, &mint])?;
send_ix_in_tx(&client, init_mint, &payer, vec![&payer])?;
// Attest a token
let rando = Keypair::new();
let mint_data = get_mint(&client, &mint.pubkey())?;
let attest_token = token_bridge::instructions::attest(token_program_id, program_id, payer.pubkey(), mint.pubkey(), mint_data, rando.pubkey(), 0).unwrap();
let attest_token = token_bridge::instructions::attest(
token_program_id,
program_id,
payer.pubkey(),
mint.pubkey(),
mint_data,
rando.pubkey(),
0,
)
.unwrap();
send_ix_in_tx(&client, attest_token, &payer, vec![&payer])?;
// Create a token account
let token_authority = Keypair::new();
let token_acc = Keypair::new();
let init_token_sys = solana_sdk::system_instruction::create_account(&payer.pubkey(), &token_acc.pubkey(), Rent::default().minimum_balance(spl_token::state::Account::LEN), spl_token::state::Account::LEN as u64, &spl_token::id());
let init_token_account = spl_token::instruction::initialize_account(&spl_token::id(), &token_acc.pubkey(), &mint.pubkey(), &token_authority.pubkey())?;
let init_token_sys = solana_sdk::system_instruction::create_account(
&payer.pubkey(),
&token_acc.pubkey(),
Rent::default().minimum_balance(spl_token::state::Account::LEN),
spl_token::state::Account::LEN as u64,
&spl_token::id(),
);
let init_token_account = spl_token::instruction::initialize_account(
&spl_token::id(),
&token_acc.pubkey(),
&mint.pubkey(),
&token_authority.pubkey(),
)?;
send_ix_in_tx(&client, init_token_sys, &payer, vec![&payer, &token_acc])?;
send_ix_in_tx(&client, init_token_account, &payer, vec![&payer])?;
// Mint tokens
let mint_ix = spl_token::instruction::mint_to(&spl_token::id(), &mint.pubkey(), &token_acc.pubkey(), &mint_authority.pubkey(), &[], 1000)?;
let mint_ix = spl_token::instruction::mint_to(
&spl_token::id(),
&mint.pubkey(),
&token_acc.pubkey(),
&mint_authority.pubkey(),
&[],
1000,
)?;
send_ix_in_tx(&client, mint_ix, &payer, vec![&payer, &mint_authority])?;
// Give allowance
let bridge_token_authority = token_bridge::accounts::AuthoritySigner::key(None, &token_program_id);
let allowance_ix = spl_token::instruction::approve(&spl_token::id(), &token_acc.pubkey(), &bridge_token_authority, &token_authority.pubkey(), &[], 1000)?;
send_ix_in_tx(&client, allowance_ix, &payer, vec![&payer, &token_authority])?;
let bridge_token_authority =
token_bridge::accounts::AuthoritySigner::key(None, &token_program_id);
let allowance_ix = spl_token::instruction::approve(
&spl_token::id(),
&token_acc.pubkey(),
&bridge_token_authority,
&token_authority.pubkey(),
&[],
1000,
)?;
send_ix_in_tx(
&client,
allowance_ix,
&payer,
vec![&payer, &token_authority],
)?;
// Transfer to ETH
let transfer_eth = token_bridge::instructions::transfer_native(token_program_id, program_id, payer.pubkey(), token_acc.pubkey(), mint.pubkey(), TransferNativeData {
nonce: 1,
amount: 500,
fee: 0,
target_address: [2; 32],
target_chain: 2,
}).unwrap();
let transfer_eth = token_bridge::instructions::transfer_native(
token_program_id,
program_id,
payer.pubkey(),
token_acc.pubkey(),
mint.pubkey(),
TransferNativeData {
nonce: 1,
amount: 500,
fee: 0,
target_address: [2; 32],
target_chain: 2,
},
)
.unwrap();
send_ix_in_tx(&client, transfer_eth, &payer, vec![&payer])?;
let transfer_eth = token_bridge::instructions::transfer_native(token_program_id, program_id, payer.pubkey(), token_acc.pubkey(), mint.pubkey(), TransferNativeData {
nonce: 2,
amount: 500,
fee: 0,
target_address: [2; 32],
target_chain: 2,
}).unwrap();
let transfer_eth = token_bridge::instructions::transfer_native(
token_program_id,
program_id,
payer.pubkey(),
token_acc.pubkey(),
mint.pubkey(),
TransferNativeData {
nonce: 2,
amount: 500,
fee: 0,
target_address: [2; 32],
target_chain: 2,
},
)
.unwrap();
send_ix_in_tx(&client, transfer_eth, &payer, vec![&payer])?;
Ok(())
}
fn send_ix_in_tx(client: &RpcClient, ix: Instruction, payer: &Keypair, signers: Vec<&Keypair>) -> Result<(), ClientError> {
fn send_ix_in_tx(
client: &RpcClient,
ix: Instruction,
payer: &Keypair,
signers: Vec<&Keypair>,
) -> Result<(), ClientError> {
let mut tx = Transaction::new_with_payer(&[ix], Some(&payer.pubkey()));
let (recent_blockhash, _) = client.get_recent_blockhash()?;
@ -173,5 +229,8 @@ fn send_ix_in_tx(client: &RpcClient, ix: Instruction, payer: &Keypair, signers:
fn get_mint(client: &RpcClient, mint: &Pubkey) -> Result<Mint, ClientError> {
let acc = client.get_account(mint)?;
Mint::unpack(acc.data()).map_err(|e| ClientError { request: None, kind: ClientErrorKind::Custom(String::from("Could not deserialize mint")) })
}
Mint::unpack(acc.data()).map_err(|e| ClientError {
request: None,
kind: ClientErrorKind::Custom(String::from("Could not deserialize mint")),
})
}

View File

@ -1,16 +1,10 @@
use crate::types::*;
use bridge::{
api::ForeignAddress,
vaa::{
DeserializePayload,
PayloadMessage,
},
vaa::{DeserializePayload, PayloadMessage},
};
use solana_program::pubkey::Pubkey;
use solitaire::{
processors::seeded::Seeded,
*,
};
use solitaire::{processors::seeded::Seeded, *};
pub type AuthoritySigner<'b> = Derive<Info<'b>, "authority_signer">;
pub type CustodySigner<'b> = Derive<Info<'b>, "custody_signer">;

View File

@ -1,52 +1,28 @@
use crate::{
accounts::{
ConfigAccount,
EmitterAccount,
},
messages::{
PayloadAssetMeta,
PayloadTransfer,
},
accounts::{ConfigAccount, EmitterAccount},
messages::{PayloadAssetMeta, PayloadTransfer},
types::*,
};
use bridge::{
api::{
PostMessage,
PostMessageData,
},
api::{PostMessage, PostMessageData},
vaa::SerializePayload,
};
use primitive_types::U256;
use solana_program::{
account_info::AccountInfo,
instruction::{
AccountMeta,
Instruction,
},
program::{
invoke,
invoke_signed,
},
instruction::{AccountMeta, Instruction},
program::{invoke, invoke_signed},
program_error::ProgramError,
pubkey::Pubkey,
sysvar::clock::Clock,
};
use solitaire::{
CreationLamports::Exempt,
*,
};
use solitaire::processors::seeded::invoke_seeded;
use solitaire::{CreationLamports::Exempt, *};
use spl_token::{
error::TokenError::OwnerMismatch,
state::{
Account,
Mint,
},
state::{Account, Mint},
};
use std::ops::{
Deref,
DerefMut,
};
use solitaire::processors::seeded::invoke_seeded;
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct AttestToken<'b> {
@ -111,6 +87,7 @@ pub fn attest_token(
let params = bridge::instruction::Instruction::PostMessage(PostMessageData {
nonce: data.nonce,
payload: payload.try_to_vec()?,
persist: true,
});
let ix = Instruction::new_with_bytes(

View File

@ -1,14 +1,7 @@
use crate::{
accounts::{
ConfigAccount,
CustodyAccount,
CustodyAccountDerivationData,
CustodySigner,
Endpoint,
EndpointDerivationData,
MintSigner,
WrappedDerivationData,
WrappedMint,
ConfigAccount, CustodyAccount, CustodyAccountDerivationData, CustodySigner, Endpoint,
EndpointDerivationData, MintSigner, WrappedDerivationData, WrappedMint,
},
messages::PayloadTransfer,
types::*,
@ -16,27 +9,15 @@ use crate::{
};
use bridge::vaa::ClaimableVAA;
use solana_program::{
account_info::AccountInfo,
program::invoke_signed,
program_error::ProgramError,
pubkey::Pubkey,
account_info::AccountInfo, program::invoke_signed, program_error::ProgramError, pubkey::Pubkey,
};
use solitaire::{
processors::seeded::{
invoke_seeded,
Seeded,
},
processors::seeded::{invoke_seeded, Seeded},
CreationLamports::Exempt,
*,
};
use spl_token::state::{
Account,
Mint,
};
use std::ops::{
Deref,
DerefMut,
};
use spl_token::state::{Account, Mint};
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct CompleteNative<'b> {

View File

@ -1,39 +1,21 @@
use crate::{
accounts::{
ConfigAccount,
Endpoint,
EndpointDerivationData,
MintSigner,
WrappedDerivationData,
WrappedMint,
WrappedTokenMeta,
ConfigAccount, Endpoint, EndpointDerivationData, MintSigner, WrappedDerivationData,
WrappedMint, WrappedTokenMeta,
},
messages::PayloadAssetMeta,
types::*,
};
use bridge::vaa::ClaimableVAA;
use solana_program::{
account_info::AccountInfo,
program::invoke_signed,
program_error::ProgramError,
pubkey::Pubkey,
};
use solitaire::{
processors::seeded::Seeded,
CreationLamports::Exempt,
*,
account_info::AccountInfo, program::invoke_signed, program_error::ProgramError, pubkey::Pubkey,
};
use solitaire::{processors::seeded::Seeded, CreationLamports::Exempt, *};
use spl_token::{
error::TokenError::OwnerMismatch,
state::{
Account,
Mint,
},
};
use std::ops::{
Deref,
DerefMut,
state::{Account, Mint},
};
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct CreateWrapped<'b> {

View File

@ -1,20 +1,7 @@
use crate::{
accounts::ConfigAccount,
types::*,
};
use solana_program::{
account_info::AccountInfo,
program_error::ProgramError,
pubkey::Pubkey,
};
use solitaire::{
CreationLamports::Exempt,
*,
};
use std::ops::{
Deref,
DerefMut,
};
use crate::{accounts::ConfigAccount, types::*};
use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
use solitaire::{CreationLamports::Exempt, *};
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct Initialize<'b> {
@ -22,8 +9,7 @@ pub struct Initialize<'b> {
pub config: ConfigAccount<'b, { AccountState::Uninitialized }>,
}
impl<'b> InstructionContext<'b> for Initialize<'b> {
}
impl<'b> InstructionContext<'b> for Initialize<'b> {}
pub fn initialize(
ctx: &ExecutionContext,

View File

@ -1,31 +1,12 @@
use crate::{
accounts::{
ConfigAccount,
Endpoint,
EndpointDerivationData,
},
accounts::{ConfigAccount, Endpoint, EndpointDerivationData},
messages::PayloadGovernanceRegisterChain,
types::*,
};
use bridge::vaa::{
ClaimableVAA,
DeserializePayload,
PayloadMessage,
};
use solana_program::{
account_info::AccountInfo,
program_error::ProgramError,
pubkey::Pubkey,
};
use solitaire::{
processors::seeded::Seeded,
CreationLamports::Exempt,
*,
};
use std::ops::{
Deref,
DerefMut,
};
use bridge::vaa::{ClaimableVAA, DeserializePayload, PayloadMessage};
use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
use solitaire::{processors::seeded::Seeded, CreationLamports::Exempt, *};
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct RegisterChain<'b> {

View File

@ -1,14 +1,7 @@
use crate::{
accounts::{
AuthoritySigner,
ConfigAccount,
CustodyAccount,
CustodyAccountDerivationData,
CustodySigner,
EmitterAccount,
MintSigner,
WrappedDerivationData,
WrappedMint,
AuthoritySigner, ConfigAccount, CustodyAccount, CustodyAccountDerivationData,
CustodySigner, EmitterAccount, MintSigner, WrappedDerivationData, WrappedMint,
WrappedTokenMeta,
},
messages::PayloadTransfer,
@ -17,47 +10,29 @@ use crate::{
TokenBridgeError::WrongAccountOwner,
};
use bridge::{
api::{
PostMessage,
PostMessageData,
},
api::{PostMessage, PostMessageData},
vaa::SerializePayload,
};
use primitive_types::U256;
use solana_program::{
account_info::AccountInfo,
instruction::{
AccountMeta,
Instruction,
},
program::{
invoke,
invoke_signed,
},
instruction::{AccountMeta, Instruction},
program::{invoke, invoke_signed},
program_error::ProgramError,
program_option::COption,
pubkey::Pubkey,
sysvar::clock::Clock,
};
use solitaire::{
processors::seeded::{
invoke_seeded,
Seeded,
},
processors::seeded::{invoke_seeded, Seeded},
CreationLamports::Exempt,
*,
};
use spl_token::{
error::TokenError::OwnerMismatch,
state::{
Account,
Mint,
},
};
use std::ops::{
Deref,
DerefMut,
state::{Account, Mint},
};
use std::ops::{Deref, DerefMut};
#[derive(FromAccounts)]
pub struct TransferNative<'b> {
@ -176,6 +151,7 @@ pub fn transfer_native(
let params = bridge::instruction::Instruction::PostMessage(PostMessageData {
nonce: data.nonce,
payload: payload.try_to_vec()?,
persist: true,
});
let ix = Instruction::new_with_bytes(
@ -299,6 +275,7 @@ pub fn transfer_wrapped(
let params = bridge::instruction::Instruction::PostMessage(PostMessageData {
nonce: data.nonce,
payload: payload.try_to_vec()?,
persist: true,
});
let ix = Instruction::new_with_bytes(

View File

@ -1,69 +1,31 @@
use crate::{
accounts::{
AuthoritySigner,
ConfigAccount,
CustodyAccount,
CustodyAccountDerivationData,
CustodySigner,
EmitterAccount,
Endpoint,
EndpointDerivationData,
MintSigner,
WrappedDerivationData,
WrappedMint,
WrappedTokenMeta,
AuthoritySigner, ConfigAccount, CustodyAccount, CustodyAccountDerivationData,
CustodySigner, EmitterAccount, Endpoint, EndpointDerivationData, MintSigner,
WrappedDerivationData, WrappedMint, WrappedTokenMeta,
},
api::{
complete_transfer::{
CompleteNativeData,
CompleteWrappedData,
},
AttestTokenData,
CreateWrappedData,
RegisterChainData,
TransferNativeData,
complete_transfer::{CompleteNativeData, CompleteWrappedData},
AttestTokenData, CreateWrappedData, RegisterChainData, TransferNativeData,
TransferWrappedData,
},
messages::{
PayloadAssetMeta,
PayloadGovernanceRegisterChain,
PayloadTransfer,
},
messages::{PayloadAssetMeta, PayloadGovernanceRegisterChain, PayloadTransfer},
};
use borsh::BorshSerialize;
use bridge::vaa::SerializePayload;
use bridge::{
accounts::{
Bridge,
Claim,
ClaimDerivationData,
FeeCollector,
Message,
MessageDerivationData,
Sequence,
Bridge, Claim, ClaimDerivationData, FeeCollector, Message, MessageDerivationData, Sequence,
SequenceDerivationData,
},
api::ForeignAddress,
types::{
BridgeConfig,
PostedMessage,
},
vaa::{
ClaimableVAA,
PayloadMessage,
},
types::{BridgeConfig, PostedMessage},
vaa::{ClaimableVAA, PayloadMessage},
};
use solana_program::instruction::Instruction;
use solitaire::{
processors::seeded::Seeded,
AccountState,
};
use solitaire_client::{
AccountMeta,
Keypair,
Pubkey,
};
use bridge::vaa::SerializePayload;
use primitive_types::U256;
use solana_program::instruction::Instruction;
use solitaire::{processors::seeded::Seeded, AccountState};
use solitaire_client::{AccountMeta, Keypair, Pubkey};
use spl_token::state::Mint;
pub fn initialize(
@ -511,6 +473,7 @@ pub fn attest(
// Program
AccountMeta::new_readonly(bridge_id, false),
],
data: crate::instruction::Instruction::AttestToken(AttestTokenData { nonce }).try_to_vec()?,
data: crate::instruction::Instruction::AttestToken(AttestTokenData { nonce })
.try_to_vec()?,
})
}

View File

@ -13,29 +13,11 @@ pub mod messages;
pub mod types;
use api::{
attest_token,
complete_native,
complete_wrapped,
create_wrapped,
initialize,
register_chain,
transfer_native,
transfer_wrapped,
AttestToken,
AttestTokenData,
CompleteNative,
CompleteNativeData,
CompleteWrapped,
CompleteWrappedData,
CreateWrapped,
CreateWrappedData,
Initialize,
RegisterChain,
RegisterChainData,
TransferNative,
TransferNativeData,
TransferWrapped,
TransferWrappedData,
attest_token, complete_native, complete_wrapped, create_wrapped, initialize, register_chain,
transfer_native, transfer_wrapped, AttestToken, AttestTokenData, CompleteNative,
CompleteNativeData, CompleteWrapped, CompleteWrappedData, CreateWrapped, CreateWrappedData,
Initialize, RegisterChain, RegisterChainData, TransferNative, TransferNativeData,
TransferWrapped, TransferWrappedData,
};
use solitaire::*;

View File

@ -1,36 +1,16 @@
use crate::{
types::{
Address,
ChainID,
},
types::{Address, ChainID},
TokenBridgeError,
};
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use bridge::vaa::{
DeserializePayload,
SerializePayload,
};
use byteorder::{
BigEndian,
ReadBytesExt,
WriteBytesExt,
};
use borsh::{BorshDeserialize, BorshSerialize};
use bridge::vaa::{DeserializePayload, SerializePayload};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use primitive_types::U256;
use solana_program::{
native_token::Sol,
program_error::ProgramError,
};
use solana_program::{native_token::Sol, program_error::ProgramError};
use solitaire::SolitaireError;
use std::{
error::Error,
io::{
Cursor,
Read,
Write,
},
io::{Cursor, Read, Write},
str::Utf8Error,
string::FromUtf8Error,
};

View File

@ -1,19 +1,10 @@
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::pubkey::Pubkey;
use solitaire::{
pack_type,
processors::seeded::{
AccountOwner,
Owned,
},
};
use spl_token::state::{
Account,
Mint,
processors::seeded::{AccountOwner, Owned},
};
use spl_token::state::{Account, Mint};
pub type Address = [u8; 32];
pub type ChainID = u16;