forked from MetaMask/utils
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransaction-types.ts
134 lines (115 loc) · 2.45 KB
/
transaction-types.ts
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { Bytes } from './bytes';
import { Hex } from './hex';
export type Transaction =
| LegacyTransaction
| EIP2930Transaction
| EIP1559Transaction;
export type SignedTransaction = Transaction & Signature;
export type Signature = {
/**
* EC signature parameter
* 32 bytes long sequence.
*/
r: Bytes;
/**
* EC signature parameter
* Signature proof.
* 32 bytes long sequence
*/
s: Bytes;
/**
* Recovery identifier. It can be either 0x1b or 0x1c
* 1 byte long sequence
*/
yParity: Bytes;
};
/**
* Base Ethereum Transaction
*/
export type BaseTransaction = {
/**
* Sequentially incrementing counter which indicates the transaction
* number from the account
*/
nonce: Bytes;
/**
* The address of the sender, that will be signing the transaction
*/
from: Hex | Uint8Array;
/**
* The receiving address.
* If an externally-owned account, the transaction will transfer value.
* If a contract account, the transaction will execute the contract code.
*/
to: Hex | Uint8Array;
/**
* The amount of Ether sent.
*/
value: Bytes;
/**
* Maximum amount of gas units that this transaction can consume.
*/
gasLimit: Bytes;
/**
* Arbitrary data.
*/
data?: Bytes;
};
/**
* Typed Ethereum Transaction
*/
export type TypedTransaction = BaseTransaction & {
/**
* Transaction type.
*/
type: number;
};
/**
* Ethereum Legacy Transaction
* Reference: https://ethereum.org/en/developers/docs/transactions/
*/
export type LegacyTransaction = BaseTransaction & {
/**
* Transaction's gas price.
*/
gasPrice: Bytes | null;
};
/**
* EIP-2930 Transaction: Optional Access Lists
* Reference: https://eips.ethereum.org/EIPS/eip-2930
*/
export type EIP2930Transaction = TypedTransaction & {
/**
* Transaction type.
*/
type: 1;
/**
* Transaction chain ID
*/
chainId: Bytes;
/**
* List of addresses and storage keys that the transaction plans to access
*/
accessList:
| { address: Hex; storageKeys: Hex[] }[]
| { address: Uint8Array; storageKeys: Uint8Array[] }[];
};
/**
* EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)
*
* Reference: https://eips.ethereum.org/EIPS/eip-1559
*/
export type EIP1559Transaction = TypedTransaction & {
/**
* Transaction type.
*/
type: 2;
/**
* Maximum fee to give to the miner
*/
maxPriorityFeePerGas: Bytes;
/**
* Maximum total fee
*/
maxFeePerGas: Bytes;
};