solana/bridge: re-organize account data

Change-Id: Ia215c584e5d00145d8ad0250c303ca9503d8432a
This commit is contained in:
Reisen 2021-09-10 12:00:24 +00:00
parent 75ac0c9153
commit ca509f2d73
21 changed files with 539 additions and 409 deletions

View File

@ -11,9 +11,9 @@ use borsh::BorshDeserialize;
use bridge::{
accounts::{
Bridge,
BridgeData,
FeeCollector,
},
types::BridgeData,
};
use clap::{
crate_description,

View File

@ -1,86 +1,17 @@
use crate::{
types,
types::{
BridgeData,
PostedMessageData,
PostedVAAData,
SequenceTracker,
},
};
use solana_program::pubkey::Pubkey;
use solitaire::{
processors::seeded::Seeded,
AccountState,
Data,
Derive,
Info,
};
pub mod bridge;
pub mod claim;
pub mod fee_collector;
pub mod guardian_set;
pub mod posted_message;
pub mod posted_vaa;
pub mod sequence;
pub mod signature_set;
pub type FeeCollector<'a> = Derive<Info<'a>, "fee_collector">;
pub type Bridge<'a, const State: AccountState> = Derive<Data<'a, BridgeData, { State }>, "Bridge">;
pub type GuardianSet<'b, const State: AccountState> = Data<'b, types::GuardianSetData, { State }>;
pub struct GuardianSetDerivationData {
pub index: u32,
}
impl<'b, const State: AccountState> Seeded<&GuardianSetDerivationData>
for GuardianSet<'b, { State }>
{
fn seeds(data: &GuardianSetDerivationData) -> Vec<Vec<u8>> {
vec![
"GuardianSet".as_bytes().to_vec(),
data.index.to_be_bytes().to_vec(),
]
}
}
pub type Claim<'b, const State: AccountState> = Data<'b, types::ClaimData, { State }>;
pub struct ClaimDerivationData {
pub emitter_address: [u8; 32],
pub emitter_chain: u16,
pub sequence: u64,
}
impl<'b, const State: AccountState> Seeded<&ClaimDerivationData> for Claim<'b, { State }> {
fn seeds(data: &ClaimDerivationData) -> Vec<Vec<u8>> {
return vec![
data.emitter_address.to_vec(),
data.emitter_chain.to_be_bytes().to_vec(),
data.sequence.to_be_bytes().to_vec(),
];
}
}
pub type SignatureSet<'b, const State: AccountState> = Data<'b, types::SignatureSet, { State }>;
pub type PostedMessage<'b, const State: AccountState> = Data<'b, PostedMessageData, { State }>;
pub type PostedVAA<'b, const State: AccountState> = Data<'b, PostedVAAData, { State }>;
pub struct PostedVAADerivationData {
pub payload_hash: Vec<u8>,
}
impl<'b, const State: AccountState> Seeded<&PostedVAADerivationData> for PostedVAA<'b, { State }> {
fn seeds(data: &PostedVAADerivationData) -> Vec<Vec<u8>> {
vec!["PostedVAA".as_bytes().to_vec(), data.payload_hash.to_vec()]
}
}
pub type Sequence<'b> = Data<'b, SequenceTracker, { AccountState::MaybeInitialized }>;
pub struct SequenceDerivationData<'a> {
pub emitter_key: &'a Pubkey,
}
impl<'b> Seeded<&SequenceDerivationData<'b>> for Sequence<'b> {
fn seeds(data: &SequenceDerivationData) -> Vec<Vec<u8>> {
vec![
"Sequence".as_bytes().to_vec(),
data.emitter_key.to_bytes().to_vec(),
]
}
}
pub use bridge::*;
pub use claim::*;
pub use fee_collector::*;
pub use guardian_set::*;
pub use posted_message::*;
pub use posted_vaa::*;
pub use sequence::*;
pub use signature_set::*;

View File

@ -0,0 +1,59 @@
//! The Bridge account contains the main state for the wormhole bridge, as well as tracking
//! configuration options for how the bridge should behave.
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use serde::{
Deserialize,
Serialize,
};
use solitaire::{
AccountOwner,
AccountState,
Data,
Derive,
Owned,
};
pub type Bridge<'a, const State: AccountState> = Derive<Data<'a, BridgeData, { State }>, "Bridge">;
#[derive(Clone, Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct BridgeData {
/// The current guardian set index, used to decide which signature sets to accept.
pub guardian_set_index: u32,
/// Lamports in the collection account
pub last_lamports: u64,
/// Bridge configuration, which is set once upon initialization.
pub config: BridgeConfig,
}
#[cfg(not(feature = "cpi"))]
impl Owned for BridgeData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for BridgeData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
use solana_program::pubkey::Pubkey;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}
#[derive(Clone, Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct BridgeConfig {
/// Period for how long a guardian set is valid after it has been replaced by a new one. This
/// guarantees that VAAs issued by that set can still be submitted for a certain period. In
/// this period we still trust the old guardian set.
pub guardian_set_expiration_time: u32,
/// Amount of lamports that needs to be paid to the protocol to post a message
pub fee: u64,
}

View File

@ -0,0 +1,47 @@
//! ClaimData accounts are one off markers that can be combined with other accounts to represent
//! data that can only be used once.
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use serde::{
Deserialize,
Serialize,
};
use solitaire::{
processors::seeded::Seeded,
AccountOwner,
AccountState,
Data,
Owned,
};
pub type Claim<'a, const State: AccountState> = Data<'a, ClaimData, { State }>;
#[derive(Default, Clone, Copy, BorshDeserialize, BorshSerialize, Serialize, Deserialize)]
pub struct ClaimData {
pub claimed: bool,
}
impl Owned for ClaimData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
pub struct ClaimDerivationData {
pub emitter_address: [u8; 32],
pub emitter_chain: u16,
pub sequence: u64,
}
impl<'b, const State: AccountState> Seeded<&ClaimDerivationData> for Claim<'b, { State }> {
fn seeds(data: &ClaimDerivationData) -> Vec<Vec<u8>> {
return vec![
data.emitter_address.to_vec(),
data.emitter_chain.to_be_bytes().to_vec(),
data.sequence.to_be_bytes().to_vec(),
];
}
}

View File

@ -0,0 +1,8 @@
//! The FeeCollector is a simple account that collects SOL fees.
use solitaire::{
Derive,
Info,
};
pub type FeeCollector<'a> = Derive<Info<'a>, "fee_collector">;

View File

@ -0,0 +1,65 @@
//! GuardianSet represents an account containing information about the current active guardians
//! responsible for signing wormhole VAAs.
use crate::types::GuardianPublicKey;
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use serde::{
Deserialize,
Serialize,
};
use solitaire::{
processors::seeded::Seeded,
AccountOwner,
AccountState,
Data,
Owned,
};
pub type GuardianSet<'b, const State: AccountState> = Data<'b, GuardianSetData, { State }>;
#[derive(Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct GuardianSetData {
/// Index representing an incrementing version number for this guardian set.
pub index: u32,
/// ETH style public keys
pub keys: Vec<GuardianPublicKey>,
/// Timestamp representing the time this guardian became active.
pub creation_time: u32,
/// Expiration time when VAAs issued by this set are no longer valid.
pub expiration_time: u32,
}
/// GuardianSet account PDAs are indexed by their version number.
pub struct GuardianSetDerivationData {
pub index: u32,
}
impl<'a, const State: AccountState> Seeded<&GuardianSetDerivationData>
for GuardianSet<'a, { State }>
{
fn seeds(data: &GuardianSetDerivationData) -> Vec<Vec<u8>> {
vec![
"GuardianSet".as_bytes().to_vec(),
data.index.to_be_bytes().to_vec(),
]
}
}
impl GuardianSetData {
/// Number of guardians in the set
pub fn num_guardians(&self) -> u8 {
self.keys.iter().filter(|v| **v != [0u8; 20]).count() as u8
}
}
impl Owned for GuardianSetData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}

View File

@ -0,0 +1,119 @@
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use serde::{
Deserialize,
Serialize,
};
use solana_program::pubkey::Pubkey;
use solitaire::{
AccountOwner,
AccountState,
Data,
Owned,
};
use std::{
io::Write,
ops::{
Deref,
DerefMut,
},
};
pub type PostedMessage<'a, const State: AccountState> = Data<'a, PostedMessageData, { State }>;
// This is using the same payload as the PostedVAA for backwards compatibility.
// This will be deprecated in a future release.
#[repr(transparent)]
pub struct PostedMessageData(pub MessageData);
#[derive(Default, BorshSerialize, BorshDeserialize, Clone, Serialize, Deserialize)]
pub struct MessageData {
/// Header of the posted VAA
pub vaa_version: u8,
/// Level of consistency requested by the emitter
pub consistency_level: 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,
/// Sequence number of this message
pub sequence: u64,
/// Emitter of the message
pub emitter_chain: u16,
/// Emitter of the message
pub emitter_address: [u8; 32],
/// Message payload
pub payload: Vec<u8>,
}
impl BorshSerialize for PostedMessageData {
fn serialize<W: Write>(&self, writer: &mut W) -> std::io::Result<()> {
writer.write(b"msg")?;
BorshSerialize::serialize(&self.0, writer)
}
}
impl BorshDeserialize for PostedMessageData {
fn deserialize(buf: &mut &[u8]) -> std::io::Result<Self> {
*buf = &buf[3..];
Ok(PostedMessageData(
<MessageData as BorshDeserialize>::deserialize(buf)?,
))
}
}
impl Deref for PostedMessageData {
type Target = MessageData;
fn deref(&self) -> &Self::Target {
unsafe { std::mem::transmute(&self.0) }
}
}
impl DerefMut for PostedMessageData {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { std::mem::transmute(&mut self.0) }
}
}
impl Default for PostedMessageData {
fn default() -> Self {
PostedMessageData(MessageData::default())
}
}
impl Clone for PostedMessageData {
fn clone(&self) -> Self {
PostedMessageData(self.0.clone())
}
}
#[cfg(not(feature = "cpi"))]
impl Owned for PostedMessageData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for PostedMessageData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}

View File

@ -0,0 +1,91 @@
use crate::MessageData;
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use solitaire::{
processors::seeded::Seeded,
AccountOwner,
AccountState,
Data,
Owned,
};
use std::{
io::Write,
ops::{
Deref,
DerefMut,
},
};
pub type PostedVAA<'b, const State: AccountState> = Data<'b, PostedVAAData, { State }>;
pub struct PostedVAADerivationData {
pub payload_hash: Vec<u8>,
}
impl<'a, const State: AccountState> Seeded<&PostedVAADerivationData> for PostedVAA<'a, { State }> {
fn seeds(data: &PostedVAADerivationData) -> Vec<Vec<u8>> {
vec!["PostedVAA".as_bytes().to_vec(), data.payload_hash.to_vec()]
}
}
#[repr(transparent)]
pub struct PostedVAAData(pub MessageData);
impl BorshSerialize for PostedVAAData {
fn serialize<W: Write>(&self, writer: &mut W) -> std::io::Result<()> {
writer.write(b"vaa")?;
BorshSerialize::serialize(&self.0, writer)
}
}
impl BorshDeserialize for PostedVAAData {
fn deserialize(buf: &mut &[u8]) -> std::io::Result<Self> {
*buf = &buf[3..];
Ok(PostedVAAData(
<MessageData as BorshDeserialize>::deserialize(buf)?,
))
}
}
impl Deref for PostedVAAData {
type Target = MessageData;
fn deref(&self) -> &Self::Target {
unsafe { std::mem::transmute(&self.0) }
}
}
impl DerefMut for PostedVAAData {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { std::mem::transmute(&mut self.0) }
}
}
impl Default for PostedVAAData {
fn default() -> Self {
PostedVAAData(MessageData::default())
}
}
impl Clone for PostedVAAData {
fn clone(&self) -> Self {
PostedVAAData(self.0.clone())
}
}
#[cfg(not(feature = "cpi"))]
impl Owned for PostedVAAData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for PostedVAAData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
use solana_program::pubkey::Pubkey;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}

View File

@ -0,0 +1,38 @@
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use solana_program::pubkey::Pubkey;
use solitaire::{
processors::seeded::Seeded,
AccountState,
AccountOwner,
Data,
Owned,
};
pub type Sequence<'b> = Data<'b, SequenceTracker, { AccountState::MaybeInitialized }>;
#[derive(Default, Clone, Copy, BorshDeserialize, BorshSerialize)]
pub struct SequenceTracker {
pub sequence: u64,
}
pub struct SequenceDerivationData<'a> {
pub emitter_key: &'a Pubkey,
}
impl<'b> Seeded<&SequenceDerivationData<'b>> for Sequence<'b> {
fn seeds(data: &SequenceDerivationData) -> Vec<Vec<u8>> {
vec![
"Sequence".as_bytes().to_vec(),
data.emitter_key.to_bytes().to_vec(),
]
}
}
impl Owned for SequenceTracker {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}

View File

@ -0,0 +1,32 @@
//! PostedMessage
use borsh::{
BorshDeserialize,
BorshSerialize,
};
use solitaire::{
AccountOwner,
AccountState,
Data,
Owned,
};
pub type SignatureSet<'b, const State: AccountState> = Data<'b, SignatureSetData, { State }>;
#[derive(Default, BorshSerialize, BorshDeserialize)]
pub struct SignatureSetData {
/// Signatures of validators
pub signatures: Vec<bool>,
/// Hash of the data
pub hash: [u8; 32],
/// Index of the guardian set
pub guardian_set_index: u32,
}
impl Owned for SignatureSetData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}

View File

@ -1,12 +1,12 @@
use crate::{
accounts::{
Bridge,
BridgeConfig,
FeeCollector,
GuardianSet,
GuardianSetDerivationData,
},
error::Error::TooManyGuardians,
types::*,
MAX_LEN_GUARDIAN_KEYS,
};
use solana_program::sysvar::clock::Clock;

View File

@ -1,11 +1,9 @@
use solitaire::*;
use crate::{
accounts::{
GuardianSet,
GuardianSetDerivationData,
SignatureSet,
},
GuardianSet,
GuardianSetDerivationData,
SignatureSet,
error::Error::{
GuardianSetMismatch,
InstructionAtWrongIndex,

View File

@ -2,11 +2,10 @@
#![allow(non_upper_case_globals)]
#![allow(incomplete_features)]
pub mod accounts;
pub mod api;
pub mod error;
pub mod types;
pub mod vaa;
use solitaire::*;
pub const MAX_LEN_GUARDIAN_KEYS: usize = 19;
pub const CHAIN_ID_SOLANA: u16 = 1;
#[cfg(feature = "no-entrypoint")]
pub mod instructions;
@ -19,8 +18,30 @@ extern crate wasm_bindgen;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
pub mod wasm;
use solitaire::*;
pub mod accounts;
pub use accounts::{
BridgeConfig,
BridgeData,
Claim,
ClaimData,
ClaimDerivationData,
FeeCollector,
GuardianSet,
GuardianSetData,
GuardianSetDerivationData,
PostedMessage,
PostedMessageData,
MessageData,
PostedVAA,
PostedVAAData,
Sequence,
SequenceTracker,
SequenceDerivationData,
SignatureSet,
SignatureSetData,
};
pub mod api;
pub use api::{
initialize,
post_message,
@ -50,6 +71,10 @@ pub use api::{
VerifySignaturesData,
};
pub mod error;
pub mod types;
pub mod vaa;
pub use vaa::{
DeserializeGovernancePayload,
DeserializePayload,
@ -58,9 +83,6 @@ pub use vaa::{
SerializePayload,
};
pub const MAX_LEN_GUARDIAN_KEYS: usize = 19;
pub const CHAIN_ID_SOLANA: u16 = 1;
solitaire! {
Initialize(InitializeData) => initialize,
PostMessage(PostMessageData) => post_message,

View File

@ -24,284 +24,24 @@ use solana_program::{
program_error::ProgramError::InvalidAccountData,
pubkey::Pubkey,
};
use solitaire::{
processors::seeded::{
AccountOwner,
Owned,
},
SolitaireError,
};
use solitaire::SolitaireError;
use std::{
self,
io::{
Cursor,
Read,
Write,
},
ops::{
Deref,
DerefMut,
},
};
#[derive(Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct GuardianSetData {
/// Version number of this guardian set.
pub index: u32,
/// Type representing an Ethereum style public key for Guardians.
pub type GuardianPublicKey = [u8; 20];
/// public key hashes of the guardian set
pub keys: Vec<[u8; 20]>,
/// creation time
pub creation_time: u32,
/// expiration time when VAAs issued by this set are no longer valid
pub expiration_time: u32,
}
impl GuardianSetData {
/// Number of guardians in the set
pub fn num_guardians(&self) -> u8 {
self.keys.iter().filter(|v| **v != [0u8; 20]).count() as u8
}
}
impl Owned for GuardianSetData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[derive(Clone, Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct BridgeConfig {
/// Period for how long a guardian set is valid after it has been replaced by a new one. This
/// guarantees that VAAs issued by that set can still be submitted for a certain period. In
/// this period we still trust the old guardian set.
pub guardian_set_expiration_time: u32,
/// Amount of lamports that needs to be paid to the protocol to post a message
pub fee: u64,
}
#[derive(Clone, Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
pub struct BridgeData {
/// The current guardian set index, used to decide which signature sets to accept.
pub guardian_set_index: u32,
/// Lamports in the collection account
pub last_lamports: u64,
/// Bridge configuration, which is set once upon initialization.
pub config: BridgeConfig,
}
#[cfg(not(feature = "cpi"))]
impl Owned for BridgeData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for BridgeData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}
#[derive(Default, BorshSerialize, BorshDeserialize)]
pub struct SignatureSet {
/// Signatures of validators
pub signatures: Vec<bool>,
/// Hash of the data
pub hash: [u8; 32],
/// Index of the guardian set
pub guardian_set_index: u32,
}
impl Owned for SignatureSet {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
// This is using the same payload as the PostedVAA for backwards compatibility.
// This will be deprecated in a future release.
#[repr(transparent)]
pub struct PostedMessageData(pub MessageData);
impl BorshSerialize for PostedMessageData {
fn serialize<W: Write>(&self, writer: &mut W) -> std::io::Result<()> {
writer.write(b"msg")?;
BorshSerialize::serialize(&self.0, writer)
}
}
impl BorshDeserialize for PostedMessageData {
fn deserialize(buf: &mut &[u8]) -> std::io::Result<Self> {
*buf = &buf[3..];
Ok(PostedMessageData(
<MessageData as BorshDeserialize>::deserialize(buf)?,
))
}
}
impl Deref for PostedMessageData {
type Target = MessageData;
fn deref(&self) -> &Self::Target {
unsafe { std::mem::transmute(&self.0) }
}
}
impl DerefMut for PostedMessageData {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { std::mem::transmute(&mut self.0) }
}
}
impl Default for PostedMessageData {
fn default() -> Self {
PostedMessageData(MessageData::default())
}
}
impl Clone for PostedMessageData {
fn clone(&self) -> Self {
PostedMessageData(self.0.clone())
}
}
#[cfg(not(feature = "cpi"))]
impl Owned for PostedMessageData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for PostedMessageData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}
#[repr(transparent)]
pub struct PostedVAAData(pub MessageData);
impl BorshSerialize for PostedVAAData {
fn serialize<W: Write>(&self, writer: &mut W) -> std::io::Result<()> {
writer.write(b"vaa")?;
BorshSerialize::serialize(&self.0, writer)
}
}
impl BorshDeserialize for PostedVAAData {
fn deserialize(buf: &mut &[u8]) -> std::io::Result<Self> {
*buf = &buf[3..];
Ok(PostedVAAData(
<MessageData as BorshDeserialize>::deserialize(buf)?,
))
}
}
impl Deref for PostedVAAData {
type Target = MessageData;
fn deref(&self) -> &Self::Target {
unsafe { std::mem::transmute(&self.0) }
}
}
impl DerefMut for PostedVAAData {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { std::mem::transmute(&mut self.0) }
}
}
impl Default for PostedVAAData {
fn default() -> Self {
PostedVAAData(MessageData::default())
}
}
impl Clone for PostedVAAData {
fn clone(&self) -> Self {
PostedVAAData(self.0.clone())
}
}
#[derive(Default, BorshSerialize, BorshDeserialize, Clone, Serialize, Deserialize)]
pub struct MessageData {
/// Header of the posted VAA
pub vaa_version: u8,
/// Level of consistency requested by the emitter
pub consistency_level: 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,
/// Sequence number of this message
pub sequence: u64,
/// Emitter of the message
pub emitter_chain: u16,
/// Emitter of the message
pub emitter_address: [u8; 32],
/// Message payload
pub payload: Vec<u8>,
}
#[cfg(not(feature = "cpi"))]
impl Owned for PostedVAAData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[cfg(feature = "cpi")]
impl Owned for PostedVAAData {
fn owner(&self) -> AccountOwner {
use std::str::FromStr;
AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap())
}
}
#[derive(Default, Clone, Copy, BorshDeserialize, BorshSerialize)]
pub struct SequenceTracker {
pub sequence: u64,
}
impl Owned for SequenceTracker {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
}
#[derive(Default, Clone, Copy, BorshDeserialize, BorshSerialize, Serialize, Deserialize)]
pub struct ClaimData {
pub claimed: bool,
}
impl Owned for ClaimData {
fn owner(&self) -> AccountOwner {
AccountOwner::This
}
#[repr(u8)]
#[derive(BorshSerialize, BorshDeserialize, Clone, Serialize, Deserialize)]
pub enum ConsistencyLevel {
Confirmed,
Finalized,
}
pub struct GovernancePayloadUpgrade {
@ -493,10 +233,3 @@ impl SerializeGovernancePayload for GovernancePayloadTransferFees {
impl DeserializeGovernancePayload for GovernancePayloadTransferFees {
}
#[repr(u8)]
#[derive(BorshSerialize, BorshDeserialize, Clone, Serialize, Deserialize)]
pub enum ConsistencyLevel {
Confirmed,
Finalized,
}

View File

@ -1,8 +1,4 @@
use crate::{
accounts::{
Claim,
ClaimDerivationData,
},
api::{
post_vaa::PostVAAData,
ForeignAddress,
@ -13,7 +9,9 @@ use crate::{
InvalidGovernanceModule,
VAAAlreadyExecuted,
},
types::PostedVAAData,
Claim,
ClaimDerivationData,
PostedVAAData,
Result,
CHAIN_ID_SOLANA,
};

View File

@ -20,21 +20,16 @@ use std::io::Write;
use crate::{
accounts::{
Bridge,
BridgeData,
FeeCollector,
GuardianSet,
GuardianSetData,
GuardianSetDerivationData,
PostedVAA,
PostedVAAData,
PostedVAADerivationData,
},
types::ConsistencyLevel,
PostVAAData,
VerifySignaturesData,
};
use crate::{
accounts::{
Bridge,
FeeCollector,
},
instructions::{
hash_vaa,
post_message,
@ -46,13 +41,13 @@ use crate::{
verify_signatures,
},
types::{
BridgeData,
ConsistencyLevel,
GovernancePayloadGuardianSetChange,
GovernancePayloadTransferFees,
GovernancePayloadUpgrade,
GuardianSetData,
PostedVAAData,
},
PostVAAData,
VerifySignaturesData,
};
use byteorder::LittleEndian;
use wasm_bindgen::prelude::*;

View File

@ -1,7 +1,7 @@
use crate::types::*;
use bridge::{
accounts::BridgeData,
api::ForeignAddress,
types::BridgeData,
vaa::{
DeserializePayload,
PayloadMessage,

View File

@ -35,20 +35,18 @@ use borsh::BorshSerialize;
use bridge::{
accounts::{
Bridge,
BridgeConfig,
Claim,
ClaimDerivationData,
FeeCollector,
PostedVAA,
PostedVAAData,
PostedVAADerivationData,
Sequence,
SequenceDerivationData,
},
api::ForeignAddress,
instructions::hash_vaa,
types::{
BridgeConfig,
PostedVAAData,
},
vaa::{
ClaimableVAA,
PayloadMessage,

View File

@ -1,7 +1,7 @@
use crate::types::*;
use bridge::{
accounts::BridgeData,
api::ForeignAddress,
types::BridgeData,
vaa::{
DeserializePayload,
PayloadMessage,

View File

@ -38,20 +38,18 @@ use borsh::BorshSerialize;
use bridge::{
accounts::{
Bridge,
BridgeConfig,
Claim,
ClaimDerivationData,
FeeCollector,
PostedVAA,
PostedVAAData,
PostedVAADerivationData,
Sequence,
SequenceDerivationData,
},
api::ForeignAddress,
instructions::hash_vaa,
types::{
BridgeConfig,
PostedVAAData,
},
vaa::{
ClaimableVAA,
PayloadMessage,

View File

@ -22,10 +22,8 @@ use solana_program::{
};
use bridge::{
types::{
BridgeData,
ConsistencyLevel,
},
accounts::BridgeData,
types::ConsistencyLevel,
PostMessageData,
};