Add a fixed size message type, hacky for now
Change-Id: I62f3bbe6bb760c7dd3c21f6bd98de54dfb0bb00b
This commit is contained in:
parent
aab8efec63
commit
8effae6cb5
|
@ -3,15 +3,18 @@ use anchor_lang::{prelude::*, solana_program};
|
||||||
use crate::{
|
use crate::{
|
||||||
accounts,
|
accounts,
|
||||||
anchor_bridge::Bridge,
|
anchor_bridge::Bridge,
|
||||||
types::{BridgeConfig, Index},
|
types::{BridgeConfig, Index, Chain},
|
||||||
PublishMessage,
|
PublishMessage,
|
||||||
Result,
|
Result,
|
||||||
MAX_LEN_GUARDIAN_KEYS,
|
MAX_LEN_GUARDIAN_KEYS,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constant fee for VAA transactions, measured in lamports.
|
/// Constant fee for VAA transactions, measured in lamports.
|
||||||
const VAA_TX_FEE: u64 = 18 * 10000;
|
const VAA_TX_FEE: u64 = 18 * 10000;
|
||||||
|
|
||||||
|
/// Maximum size of a posted VAA
|
||||||
|
pub const MAX_PAYLOAD_SIZE: usize = 400;
|
||||||
|
|
||||||
pub fn publish_message(bridge: &mut Bridge, ctx: Context<PublishMessage>) -> Result<()> {
|
pub fn publish_message(bridge: &mut Bridge, ctx: Context<PublishMessage>) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -50,6 +53,36 @@ pub struct SignatureState {
|
||||||
pub struct ClaimedVAA {
|
pub struct ClaimedVAA {
|
||||||
/// hash of the vaa
|
/// hash of the vaa
|
||||||
pub hash: [u8; 32],
|
pub hash: [u8; 32],
|
||||||
|
|
||||||
/// time the vaa was submitted
|
/// time the vaa was submitted
|
||||||
pub vaa_time: u32,
|
pub vaa_time: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Record of a posted wormhole message.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
||||||
|
pub struct PostedMessage {
|
||||||
|
/// header of the posted VAA
|
||||||
|
pub vaa_version: u8,
|
||||||
|
|
||||||
|
/// time the vaa was submitted
|
||||||
|
pub vaa_time: u32,
|
||||||
|
|
||||||
|
/// Account where signatures are stored
|
||||||
|
pub vaa_signature_account: Pubkey,
|
||||||
|
|
||||||
|
/// time the posted message was created
|
||||||
|
pub submission_time: u32,
|
||||||
|
|
||||||
|
/// unique nonce for this message
|
||||||
|
pub nonce: u32,
|
||||||
|
|
||||||
|
/// emitter of the message
|
||||||
|
pub emitter_chain: Chain,
|
||||||
|
|
||||||
|
/// emitter of the message
|
||||||
|
pub emitter_address: [u8; 32],
|
||||||
|
|
||||||
|
/// message payload
|
||||||
|
pub payload: [[u8; 32]; 13],
|
||||||
|
}
|
||||||
|
|
|
@ -3,19 +3,13 @@ use anchor_lang::{prelude::*, solana_program};
|
||||||
mod api;
|
mod api;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
use types::{Index, BridgeConfig};
|
use api::PostedMessage;
|
||||||
|
use types::{Index, BridgeConfig, Chain};
|
||||||
|
|
||||||
// Without this, Anchor's derivation macros break. It requires names with no path components at all
|
// Without this, Anchor's derivation macros break. It requires names with no path components at all
|
||||||
// otherwise it errors.
|
// otherwise it errors.
|
||||||
use anchor_bridge::Bridge;
|
use anchor_bridge::Bridge;
|
||||||
|
|
||||||
/// An enum with labeled network identifiers. These must be consistent accross all wormhole
|
|
||||||
/// contracts deployed on each chain.
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum Chain {
|
|
||||||
Solana = 1u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// chain id of this chain
|
/// chain id of this chain
|
||||||
pub const CHAIN_ID_SOLANA: u8 = Chain::Solana as u8;
|
pub const CHAIN_ID_SOLANA: u8 = Chain::Solana as u8;
|
||||||
/// maximum number of guardians
|
/// maximum number of guardians
|
||||||
|
@ -90,6 +84,9 @@ pub struct PublishMessage<'info> {
|
||||||
#[account(signer)]
|
#[account(signer)]
|
||||||
pub emitter: AccountInfo<'info>,
|
pub emitter: AccountInfo<'info>,
|
||||||
|
|
||||||
|
/// State struct, derived by #[state], used for associated accounts.
|
||||||
|
pub state: ProgramState<'info, Bridge>,
|
||||||
|
|
||||||
/// Instructions used for transaction reflection.
|
/// Instructions used for transaction reflection.
|
||||||
pub instructions: AccountInfo<'info>,
|
pub instructions: AccountInfo<'info>,
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,11 @@ pub struct BridgeConfig {
|
||||||
/// this period we still trust the old guardian set.
|
/// this period we still trust the old guardian set.
|
||||||
pub guardian_set_expiration_time: u32,
|
pub guardian_set_expiration_time: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An enum with labeled network identifiers. These must be consistent accross all wormhole
|
||||||
|
/// contracts deployed on each chain.
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
||||||
|
pub enum Chain {
|
||||||
|
Solana = 1u8,
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue