Use clock time for bridge initialization timestamp

Change-Id: I6121e7546f4c0590dff830572a843384a0470972
This commit is contained in:
Reisen 2021-07-07 08:48:37 +00:00 committed by Hendrik Hofstadt
parent 7ab5a93b21
commit 768f768001
2 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,7 @@ use crate::{
Error::TooManyGuardians,
MAX_LEN_GUARDIAN_KEYS,
};
use solana_program::sysvar::clock::Clock;
use solitaire::{
CreationLamports::Exempt,
*,
@ -29,6 +30,9 @@ pub struct Initialize<'b> {
/// Payer for account creation.
pub payer: Mut<Payer<'b>>,
/// Clock used for recording the initialization time.
pub clock: Sysvar<'b, Clock>,
}
impl<'b> InstructionContext<'b> for Initialize<'b> {
@ -62,9 +66,9 @@ pub fn initialize(
return Err(TooManyGuardians.into());
}
// Allocate a default guardian set, with zeroed keys.
// Allocate initial guardian set with the provided keys.
accs.guardian_set.index = index;
accs.guardian_set.creation_time = 0;
accs.guardian_set.creation_time = accs.clock.unix_timestamp as u32;
accs.guardian_set.keys.extend(&data.initial_guardians);
// Initialize Guardian Set

View File

@ -62,6 +62,7 @@ pub fn initialize(
AccountMeta::new(guardian_set, false),
AccountMeta::new(fee_collector, false),
AccountMeta::new(payer, true),
AccountMeta::new_readonly(sysvar::clock::id(), false),
AccountMeta::new_readonly(sysvar::rent::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
],