1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use anchor_client::anchor_lang::{
solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
system_program, sysvar,
},
InstructionData,
};
use cronos_program::pda::PDA;
use cronos_program::state::InstructionData as CronosInstructionData;
pub fn task_create(
task_pda: PDA,
daemon: Pubkey,
owner: Pubkey,
instruction: Instruction,
exec_at: i64,
stop_at: i64,
recurr: i64,
) -> Instruction {
Instruction {
program_id: cronos_program::ID,
accounts: vec![
AccountMeta::new_readonly(sysvar::clock::ID, false),
AccountMeta::new(daemon, false),
AccountMeta::new(owner, true),
AccountMeta::new(task_pda.0, false),
AccountMeta::new_readonly(system_program::ID, false),
],
data: cronos_program::instruction::TaskCreate {
instruction_data: CronosInstructionData::from(instruction),
exec_at,
stop_at,
recurr,
bump: task_pda.1,
}
.data(),
}
}