forked from neonevm/neon-evm
-
Notifications
You must be signed in to change notification settings - Fork 9
/
mod.rs
116 lines (97 loc) · 4.28 KB
/
mod.rs
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
#![allow(deprecated)]
//! `EvmInstruction` serialization/deserialization
use solana_program::{ program_error::ProgramError };
/// `EvmInstruction` serialized in instruction data
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum EvmInstruction {
/// Deposits NEON tokens to an Ether account (V3).
/// Requires previously executed SPL-Token.Approve which
/// delegates the deposit amount to the NEON destination account.
///
/// Accounts expected by this instruction:
///
/// 0. `[writable]` NEON token source account.
/// 1. `[writable]` NEON token pool (destination) account.
/// 2. `[writable]` Ether account to store balance of NEONs.
/// 3. `[]` SPL Token program id.
/// 4. `[writeable,signer]` Funding account (must be a system account).
/// 5. `[]` System program.
DepositV03,
/// Create Ethereum account V3
/// # Account references
/// 0. [WRITE, SIGNER] Funding account
/// 1. [] System Program
/// 2. [WRITE] New account (program_address(version, ether, bump_seed))
CreateAccountV03,
/// Collect lamports from treasury pool accounts to main pool balance
/// 0. `[WRITE]` Main treasury balance: PDA["treasury_pool"]
/// 1. `[WRITE]` Auxiliary treasury balance: PDA["treasury_pool", index.to_le_bytes()]
/// 2. `[]` System program
CollectTreasure,
/// Create Holder Account
HolderCreate,
/// Delete Holder Account
HolderDelete,
/// Write Transaction into Holder Account
HolderWrite,
/// Execute Transaction from Instruction in single iteration
TransactionExecuteFromInstruction,
/// Execute Transaction from Account in single iteration
TransactionExecuteFromAccount,
/// Execute Iterative Transaction from Instruction
TransactionStepFromInstruction,
/// Execute Iterative Transaction from Account
TransactionStepFromAccount,
/// Execute Iterative Transaction without ChainId from Account
TransactionStepFromAccountNoChainId,
/// Cancel Transaction
Cancel,
/// CreateMainTreasury
/// 0. `[WRITE]` Main treasury balance: PDA["treasury_pool"]
/// 1. `[]` Program data (to get program upgrade-authority)
/// 2. `[SIGNER]` Owner for account (upgrade program authority)
/// 3. `[]` SPL token program id
/// 4. `[]` System program
/// 5. `[]` wSOL mint
/// 6. `[WRITE,SIGNER]` Payer
CreateMainTreasury,
}
impl EvmInstruction {
/// Parse `EvmInstruction`
///
/// # Errors
/// Will return `ProgramError::InvalidInstructionData` if can't parse `tag`
pub const fn parse(tag: &u8) -> Result<Self, ProgramError> {
Ok(match tag {
0x1e => Self::CollectTreasure, // 30
0x1f => Self::TransactionExecuteFromInstruction, // 31
0x20 => Self::TransactionStepFromInstruction, // 32
0x21 => Self::TransactionStepFromAccount, // 33
0x22 => Self::TransactionStepFromAccountNoChainId, // 34
0x23 => Self::Cancel, // 35
0x24 => Self::HolderCreate, // 36
0x25 => Self::HolderDelete, // 37
0x26 => Self::HolderWrite, // 38
0x27 => Self::DepositV03, // 39
0x28 => Self::CreateAccountV03, // 40
0x29 => Self::CreateMainTreasury, // 41
0x2A => Self::TransactionExecuteFromAccount, // 42
_ => return Err(ProgramError::InvalidInstructionData),
})
}
}
pub mod account_create;
pub mod account_holder_create;
pub mod account_holder_delete;
pub mod account_holder_write;
pub mod neon_tokens_deposit;
pub mod transaction_cancel;
pub mod transaction_execute_from_instruction;
pub mod transaction_execute_from_account;
pub mod transaction_execute;
pub mod transaction_step_from_instruction;
pub mod transaction_step_from_account;
pub mod transaction_step_from_account_no_chainid;
pub mod transaction_step;
pub mod collect_treasury;
pub mod create_main_treasury;