Implement Initialize using correct anchor decorators.
Change-Id: I5d7120f927cc0e4a9dc2882b245058fde0a65637
This commit is contained in:
parent
1c9facbb75
commit
bcf7be93d6
|
@ -1,7 +1,20 @@
|
|||
use anchor_lang::{prelude::*, solana_program};
|
||||
|
||||
use crate::{types::Version, MAX_LEN_GUARDIAN_KEYS};
|
||||
|
||||
#[account]
|
||||
pub struct BridgeInfo {}
|
||||
|
||||
#[account]
|
||||
pub struct GuardianSetInfo {}
|
||||
pub struct GuardianSetInfo {
|
||||
/// Version number of this guardian set.
|
||||
pub version: Version,
|
||||
/// Number of keys stored
|
||||
pub len_keys: u8,
|
||||
/// public key hashes of the guardian set
|
||||
pub keys: [[u8; 20]; MAX_LEN_GUARDIAN_KEYS],
|
||||
/// creation time
|
||||
pub creation_time: u32,
|
||||
/// expiration time when VAAs issued by this set are no longer valid
|
||||
pub expiration_time: u32,
|
||||
}
|
||||
|
|
|
@ -13,8 +13,17 @@ pub fn initialize(
|
|||
initial_guardian_key: [[u8; 20]; MAX_LEN_GUARDIAN_KEYS],
|
||||
config: BridgeConfig,
|
||||
) -> Result<Bridge, ProgramError> {
|
||||
let version = Version(0);
|
||||
|
||||
// Initialize the Guardian Set for the first time.
|
||||
ctx.accounts.guardian_set.version = version;
|
||||
ctx.accounts.guardian_set.creation_time = ctx.accounts.clock.unix_timestamp as u32;
|
||||
ctx.accounts.guardian_set.keys = initial_guardian_key;
|
||||
ctx.accounts.guardian_set.len_keys = len_guardians;
|
||||
|
||||
// Generate a Version 0 state for the bridges genesis.
|
||||
Ok(Bridge {
|
||||
guardian_set_version: Version(0),
|
||||
guardian_set_version: version,
|
||||
config,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@ pub struct Initialize<'info> {
|
|||
pub clock: Sysvar<'info, Clock>,
|
||||
|
||||
/// Information about the current guardian set.
|
||||
pub guardian_set: ProgramState<'info, GuardianSetInfo>,
|
||||
#[account(init)]
|
||||
pub guardian_set: ProgramAccount<'info, GuardianSetInfo>,
|
||||
|
||||
/// Required by Anchor for associated accounts.
|
||||
pub rent: Sysvar<'info, Rent>,
|
||||
|
|
Loading…
Reference in New Issue