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::{
|
||||
accounts,
|
||||
anchor_bridge::Bridge,
|
||||
types::{BridgeConfig, Index},
|
||||
types::{BridgeConfig, Index, Chain},
|
||||
PublishMessage,
|
||||
Result,
|
||||
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;
|
||||
|
||||
/// Maximum size of a posted VAA
|
||||
pub const MAX_PAYLOAD_SIZE: usize = 400;
|
||||
|
||||
pub fn publish_message(bridge: &mut Bridge, ctx: Context<PublishMessage>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -50,6 +53,36 @@ pub struct SignatureState {
|
|||
pub struct ClaimedVAA {
|
||||
/// hash of the vaa
|
||||
pub hash: [u8; 32],
|
||||
|
||||
/// time the vaa was submitted
|
||||
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 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
|
||||
// otherwise it errors.
|
||||
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
|
||||
pub const CHAIN_ID_SOLANA: u8 = Chain::Solana as u8;
|
||||
/// maximum number of guardians
|
||||
|
@ -90,6 +84,9 @@ pub struct PublishMessage<'info> {
|
|||
#[account(signer)]
|
||||
pub emitter: AccountInfo<'info>,
|
||||
|
||||
/// State struct, derived by #[state], used for associated accounts.
|
||||
pub state: ProgramState<'info, Bridge>,
|
||||
|
||||
/// Instructions used for transaction reflection.
|
||||
pub instructions: AccountInfo<'info>,
|
||||
|
||||
|
|
|
@ -12,3 +12,11 @@ pub struct BridgeConfig {
|
|||
/// this period we still trust the old guardian set.
|
||||
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