2021-12-02 07:28:12 -08:00
|
|
|
use crate::error::*;
|
2021-12-03 00:52:48 -08:00
|
|
|
use crate::state::*;
|
2021-12-02 07:28:12 -08:00
|
|
|
use anchor_lang::prelude::*;
|
|
|
|
use std::str::FromStr;
|
|
|
|
|
|
|
|
#[derive(Accounts)]
|
|
|
|
#[instruction(time_offset: i64)]
|
|
|
|
pub struct SetTimeOffset<'info> {
|
|
|
|
#[account(mut, has_one = realm_authority)]
|
2021-12-08 23:22:22 -08:00
|
|
|
pub registrar: AccountLoader<'info, Registrar>,
|
2021-12-02 07:28:12 -08:00
|
|
|
pub realm_authority: Signer<'info>,
|
|
|
|
}
|
|
|
|
|
2021-12-03 00:19:13 -08:00
|
|
|
/// A debug-only instruction that advances the time.
|
2021-12-02 07:28:12 -08:00
|
|
|
pub fn set_time_offset(ctx: Context<SetTimeOffset>, time_offset: i64) -> Result<()> {
|
2021-12-14 03:47:12 -08:00
|
|
|
let allowed_program = Pubkey::from_str("GovernanceProgramTest1111111111111111111111").unwrap();
|
2021-12-08 23:22:22 -08:00
|
|
|
let registrar = &mut ctx.accounts.registrar.load_mut()?;
|
2022-04-25 11:50:02 -07:00
|
|
|
require_keys_eq!(
|
|
|
|
registrar.governance_program_id,
|
|
|
|
allowed_program,
|
2022-04-25 07:23:10 -07:00
|
|
|
VsrError::DebugInstruction
|
2021-12-02 07:28:12 -08:00
|
|
|
);
|
|
|
|
registrar.time_offset = time_offset;
|
|
|
|
Ok(())
|
|
|
|
}
|