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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use anchor_lang::prelude::*;
use anchor_lang::solana_program;
#[account]
#[derive(Default, Debug, PartialEq)]
pub struct SmartWallet {
    
    pub base: Pubkey,
    
    pub bump: u8,
    
    pub threshold: u64,
    
    pub minimum_delay: i64,
    
    pub grace_period: i64,
    
    pub owner_set_seqno: u32,
    
    pub num_transactions: u64,
    
    pub owners: Vec<Pubkey>,
    
    pub reserved: [u64; 16],
}
#[account]
#[derive(Debug, Default, PartialEq)]
pub struct Transaction {
    
    pub smart_wallet: Pubkey,
    
    
    
    pub index: u64,
    
    pub bump: u8,
    
    pub proposer: Pubkey,
    
    pub instructions: Vec<TXInstruction>,
    
    pub signers: Vec<bool>,
    
    pub owner_set_seqno: u32,
    
    pub eta: i64,
    
    pub executor: Pubkey,
    
    pub executed_at: i64,
}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Default, PartialEq)]
pub struct TXInstruction {
    
    pub program_id: Pubkey,
    
    pub keys: Vec<TXAccountMeta>,
    
    pub data: Vec<u8>,
}
impl TXInstruction {
    
    pub fn space(&self) -> usize {
        std::mem::size_of::<Pubkey>()
            + (self.keys.len() as usize) * std::mem::size_of::<TXAccountMeta>()
            + (self.data.len() as usize)
    }
}
#[derive(AnchorSerialize, AnchorDeserialize, Debug, PartialEq, Copy, Clone)]
pub struct TXAccountMeta {
    
    pub pubkey: Pubkey,
    
    pub is_signer: bool,
    
    pub is_writable: bool,
}
impl From<&TXInstruction> for solana_program::instruction::Instruction {
    fn from(tx: &TXInstruction) -> solana_program::instruction::Instruction {
        solana_program::instruction::Instruction {
            program_id: tx.program_id,
            accounts: tx.keys.clone().into_iter().map(Into::into).collect(),
            data: tx.data.clone(),
        }
    }
}
impl From<TXAccountMeta> for solana_program::instruction::AccountMeta {
    fn from(
        TXAccountMeta {
            pubkey,
            is_signer,
            is_writable,
        }: TXAccountMeta,
    ) -> solana_program::instruction::AccountMeta {
        solana_program::instruction::AccountMeta {
            pubkey,
            is_signer,
            is_writable,
        }
    }
}