@metamask/utils 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/encryption-types.d.ts +6 -0
- package/dist/encryption-types.js +3 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/keyring.d.ts +210 -0
- package/dist/keyring.js +3 -0
- package/dist/keyring.js.map +1 -0
- package/dist/transaction-types.d.ts +116 -0
- package/dist/transaction-types.js +3 -0
- package/dist/transaction-types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption-types.js","sourceRoot":"","sources":["../src/encryption-types.ts"],"names":[],"mappings":"","sourcesContent":["export type Eip1024EncryptedData = {\n version: string;\n nonce: string;\n ephemPublicKey: string;\n ciphertext: string;\n};\n"]}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { Eip1024EncryptedData } from './encryption-types';
|
|
2
|
+
import { Hex } from './hex';
|
|
3
|
+
import { Json } from './json';
|
|
4
|
+
import type { Transaction, SignedTransaction } from './transaction-types';
|
|
5
|
+
/**
|
|
6
|
+
* A Keyring class.
|
|
7
|
+
*
|
|
8
|
+
* This type is used to validate the constructor signature and the `type`
|
|
9
|
+
* static property on Keyring classes. See the {@link Keyring} type for more
|
|
10
|
+
* information.
|
|
11
|
+
*/
|
|
12
|
+
export declare type KeyringClass<State extends Json> = {
|
|
13
|
+
/**
|
|
14
|
+
* The Keyring constructor. Takes a single parameter, an "options" object.
|
|
15
|
+
* See the documentation for the specific keyring for more information about
|
|
16
|
+
* what these options are.
|
|
17
|
+
*
|
|
18
|
+
* @param options - The constructor options. Differs between keyring
|
|
19
|
+
* implementations.
|
|
20
|
+
*/
|
|
21
|
+
new (options?: Record<string, unknown>): Keyring<State>;
|
|
22
|
+
/**
|
|
23
|
+
* The name of this type of keyring. This must uniquely identify the
|
|
24
|
+
* keyring type.
|
|
25
|
+
*/
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A keyring is something that can sign messages. Keyrings are used to add new
|
|
30
|
+
* signing strategies; each strategy is a new keyring.
|
|
31
|
+
*
|
|
32
|
+
* Each keyring manages a collection of key pairs, which we call "accounts".
|
|
33
|
+
* Each account is referred to by its "address", which is a unique identifier
|
|
34
|
+
* derived from the public key. The address is always a "0x"-prefixed
|
|
35
|
+
* hexidecimal string.
|
|
36
|
+
*
|
|
37
|
+
* The keyring might store the private key for each account as well, but it's
|
|
38
|
+
* not guaranteed. Some keyrings delegate signing, so they don't need the
|
|
39
|
+
* private key directly. The keyring (and in particular the keyring state)
|
|
40
|
+
* should be treated with care though, just in case it does contain sensitive
|
|
41
|
+
* material such as a private key.
|
|
42
|
+
*/
|
|
43
|
+
export declare type Keyring<State extends Json> = {
|
|
44
|
+
/**
|
|
45
|
+
* The name of this type of keyring. This must match the `type` property of
|
|
46
|
+
* the keyring class.
|
|
47
|
+
*/
|
|
48
|
+
type: string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the addresses for all accounts in this keyring.
|
|
51
|
+
*
|
|
52
|
+
* @returns A list of the account addresses for this keyring
|
|
53
|
+
*/
|
|
54
|
+
getAccounts(): Promise<Hex[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Add an account to the keyring.
|
|
57
|
+
*
|
|
58
|
+
* @param number - The number of accounts to add. Usually defaults to 1.
|
|
59
|
+
* @returns A list of the newly added account addresses.
|
|
60
|
+
*/
|
|
61
|
+
addAccounts(number: number): Promise<Hex[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Serialize the keyring state as a JSON-serializable object.
|
|
64
|
+
*
|
|
65
|
+
* @returns A JSON-serializable representation of the keyring state.
|
|
66
|
+
*/
|
|
67
|
+
serialize(): Promise<State>;
|
|
68
|
+
/**
|
|
69
|
+
* Deserialize the given keyring state, overwriting any existing state with
|
|
70
|
+
* the serialized state provided.
|
|
71
|
+
*
|
|
72
|
+
* @param state - A JSON-serializable representation of the keyring state.
|
|
73
|
+
*/
|
|
74
|
+
deserialize(state: State): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Remove an account from the keyring.
|
|
77
|
+
*
|
|
78
|
+
* @param address - The address of the account to remove.
|
|
79
|
+
*/
|
|
80
|
+
removeAccount?(address: Hex): void;
|
|
81
|
+
/**
|
|
82
|
+
* Export the private key for one of the keyring accounts.
|
|
83
|
+
*
|
|
84
|
+
* Some keyrings accept an "options" parameter as well. See the documentation
|
|
85
|
+
* for the specific keyring for more information about what these options
|
|
86
|
+
* are. For some keyrings, the options parameter is used to allow exporting a
|
|
87
|
+
* private key that is derived from the given account, rather than exporting
|
|
88
|
+
* that account's private key directly.
|
|
89
|
+
*
|
|
90
|
+
* @param address - The address of the account to export.
|
|
91
|
+
* @param options - Export options; differs between keyrings.
|
|
92
|
+
* @returns The non-prefixed, hex-encoded private key that was requested.
|
|
93
|
+
*/
|
|
94
|
+
exportAccount?(address: Hex, options?: Record<string, unknown>): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Get the "app key" address for the given account and origin. An app key is
|
|
97
|
+
* an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}
|
|
98
|
+
* for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}
|
|
99
|
+
* is used as the unique identifier for the application, and it's used as
|
|
100
|
+
* part of the key derivation process.
|
|
101
|
+
*
|
|
102
|
+
* @param address - The address of the account the app key is derived from.
|
|
103
|
+
* @param origin - The origin of the application.
|
|
104
|
+
* @returns The address of the app key for the given account and origin.
|
|
105
|
+
*/
|
|
106
|
+
getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;
|
|
107
|
+
/**
|
|
108
|
+
* Sign a transaction. This is equivalent to the `eth_signTransaction`
|
|
109
|
+
* Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for
|
|
110
|
+
* more details.
|
|
111
|
+
*
|
|
112
|
+
* Some keyrings accept an "options" parameter as well. See the documentation
|
|
113
|
+
* for the specific keyring for more information about what these options
|
|
114
|
+
* are. For some keyrings, the options parameter can even change which key is
|
|
115
|
+
* used for signing (e.g. signing with app keys).
|
|
116
|
+
*
|
|
117
|
+
* @param address - The address of the account to use for signing.
|
|
118
|
+
* @param transaction - The transaction to sign.
|
|
119
|
+
* @param options - Signing options; differs between keyrings.
|
|
120
|
+
* @returns The signed transaction.
|
|
121
|
+
*/
|
|
122
|
+
signTransaction?(address: Hex, transaction: Transaction, options?: Record<string, unknown>): Promise<SignedTransaction>;
|
|
123
|
+
/**
|
|
124
|
+
* Sign a message. This is equivalent to an older version of the the
|
|
125
|
+
* `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,
|
|
126
|
+
* using the curve secp256k1 the Keccak-256 hash function.
|
|
127
|
+
*
|
|
128
|
+
* For more information about this method and why we still support it, see
|
|
129
|
+
* the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
|
|
130
|
+
*
|
|
131
|
+
* Some keyrings accept an "options" parameter as well. See the documentation
|
|
132
|
+
* for the specific keyring for more information about what these options
|
|
133
|
+
* are. For some keyrings, the options parameter can even change which key is
|
|
134
|
+
* used for signing (e.g. signing with app keys).
|
|
135
|
+
*
|
|
136
|
+
* @param address - The address of the account to use for signing.
|
|
137
|
+
* @param message - The message to sign.
|
|
138
|
+
* @param options - Signing options; differs between keyrings.
|
|
139
|
+
* @returns The signed message.
|
|
140
|
+
*/
|
|
141
|
+
signMessage?(address: Hex, message: string, options?: Record<string, unknown>): Promise<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC
|
|
144
|
+
* method, which is exposed by MetaMask as the method `personal_sign`. See
|
|
145
|
+
* the Ethereum JSON-RPC API documentation for more details.
|
|
146
|
+
*
|
|
147
|
+
* For more information about this method and why we call it `personal_sign`,
|
|
148
|
+
* see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
|
|
149
|
+
*
|
|
150
|
+
* Some keyrings accept an "options" parameter as well. See the documentation
|
|
151
|
+
* for the specific keyring for more information about what these options
|
|
152
|
+
* are. For some keyrings, the options parameter can even change which key is
|
|
153
|
+
* used for signing (e.g. signing with app keys).
|
|
154
|
+
*
|
|
155
|
+
* @param address - The address of the account to use for signing.
|
|
156
|
+
* @param message - The message to sign.
|
|
157
|
+
* @param options - Signing options; differs between keyrings.
|
|
158
|
+
* @returns The signed message.
|
|
159
|
+
*/
|
|
160
|
+
signPersonalMessage?(address: Hex, message: Hex, options?: {
|
|
161
|
+
version?: string;
|
|
162
|
+
} & Record<string, unknown>): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Sign a message. This is equivalent to the `eth_signTypedData` Ethereum
|
|
165
|
+
* JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}
|
|
166
|
+
* for more details.
|
|
167
|
+
*
|
|
168
|
+
* The "version" option dictates which version of `eth_signTypedData` is
|
|
169
|
+
* used. The latest version reflects the specification most closely, whereas
|
|
170
|
+
* earlier versions reflect earlier drafts of the specification that are
|
|
171
|
+
* still supported for backwards-compatibility reasons. For more information
|
|
172
|
+
* about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
|
|
173
|
+
*
|
|
174
|
+
* Some keyrings accept additional options as well. See the documentation for
|
|
175
|
+
* the specific keyring for more information about what these options are.
|
|
176
|
+
* For some keyrings, the options parameter can even change which key is used
|
|
177
|
+
* for signing (e.g. signing with app keys).
|
|
178
|
+
*
|
|
179
|
+
* @param address - The address of the account to use for signing.
|
|
180
|
+
* @param typedData - The data to sign.
|
|
181
|
+
* @param options - Signing options; differs between keyrings.
|
|
182
|
+
* @returns The signed message.
|
|
183
|
+
*/
|
|
184
|
+
signTypedData?(address: Hex, typedData: Record<string, unknown>, options?: Record<string, unknown>): Promise<string>;
|
|
185
|
+
/**
|
|
186
|
+
* Get a public key to use for encryption. This is equivalent to the
|
|
187
|
+
* ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}
|
|
188
|
+
* for more information.
|
|
189
|
+
*
|
|
190
|
+
* Some keyrings accept an "options" parameter as well. See the documentation
|
|
191
|
+
* for the specific keyring for more information about what these options
|
|
192
|
+
* are. For some keyrings, the options parameter can even change which key is
|
|
193
|
+
* used (e.g. encrypting with app keys).
|
|
194
|
+
*
|
|
195
|
+
* @param account - The address of the account you want the encryption key for.
|
|
196
|
+
* @param options - Options; differs between keyrings.
|
|
197
|
+
*/
|
|
198
|
+
getEncryptionPublicKey?(account: Hex, options?: Record<string, unknown>): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`
|
|
201
|
+
* JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}
|
|
202
|
+
* for more information.
|
|
203
|
+
*
|
|
204
|
+
* @param account - The address of the account you want to use to decrypt
|
|
205
|
+
* the message.
|
|
206
|
+
* @param encryptedData - The encrypted data that you want to decrypt.
|
|
207
|
+
* @returns The decrypted data.
|
|
208
|
+
*/
|
|
209
|
+
decryptMessage?(account: Hex, encryptedData: Eip1024EncryptedData): Promise<string>;
|
|
210
|
+
};
|
package/dist/keyring.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Eip1024EncryptedData } from './encryption-types';\nimport { Hex } from './hex';\nimport { Json } from './json';\nimport type { Transaction, SignedTransaction } from './transaction-types';\n\n/**\n * A Keyring class.\n *\n * This type is used to validate the constructor signature and the `type`\n * static property on Keyring classes. See the {@link Keyring} type for more\n * information.\n */\nexport type KeyringClass<State extends Json> = {\n /**\n * The Keyring constructor. Takes a single parameter, an \"options\" object.\n * See the documentation for the specific keyring for more information about\n * what these options are.\n *\n * @param options - The constructor options. Differs between keyring\n * implementations.\n */\n new (options?: Record<string, unknown>): Keyring<State>;\n\n /**\n * The name of this type of keyring. This must uniquely identify the\n * keyring type.\n */\n type: string;\n};\n\n/**\n * A keyring is something that can sign messages. Keyrings are used to add new\n * signing strategies; each strategy is a new keyring.\n *\n * Each keyring manages a collection of key pairs, which we call \"accounts\".\n * Each account is referred to by its \"address\", which is a unique identifier\n * derived from the public key. The address is always a \"0x\"-prefixed\n * hexidecimal string.\n *\n * The keyring might store the private key for each account as well, but it's\n * not guaranteed. Some keyrings delegate signing, so they don't need the\n * private key directly. The keyring (and in particular the keyring state)\n * should be treated with care though, just in case it does contain sensitive\n * material such as a private key.\n */\nexport type Keyring<State extends Json> = {\n /**\n * The name of this type of keyring. This must match the `type` property of\n * the keyring class.\n */\n type: string;\n\n /**\n * Get the addresses for all accounts in this keyring.\n *\n * @returns A list of the account addresses for this keyring\n */\n getAccounts(): Promise<Hex[]>;\n\n /**\n * Add an account to the keyring.\n *\n * @param number - The number of accounts to add. Usually defaults to 1.\n * @returns A list of the newly added account addresses.\n */\n addAccounts(number: number): Promise<Hex[]>;\n\n /**\n * Serialize the keyring state as a JSON-serializable object.\n *\n * @returns A JSON-serializable representation of the keyring state.\n */\n serialize(): Promise<State>;\n\n /**\n * Deserialize the given keyring state, overwriting any existing state with\n * the serialized state provided.\n *\n * @param state - A JSON-serializable representation of the keyring state.\n */\n deserialize(state: State): Promise<void>;\n\n /**\n * Remove an account from the keyring.\n *\n * @param address - The address of the account to remove.\n */\n removeAccount?(address: Hex): void;\n\n /**\n * Export the private key for one of the keyring accounts.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter is used to allow exporting a\n * private key that is derived from the given account, rather than exporting\n * that account's private key directly.\n *\n * @param address - The address of the account to export.\n * @param options - Export options; differs between keyrings.\n * @returns The non-prefixed, hex-encoded private key that was requested.\n */\n exportAccount?(\n address: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get the \"app key\" address for the given account and origin. An app key is\n * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}\n * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}\n * is used as the unique identifier for the application, and it's used as\n * part of the key derivation process.\n *\n * @param address - The address of the account the app key is derived from.\n * @param origin - The origin of the application.\n * @returns The address of the app key for the given account and origin.\n */\n getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;\n\n /**\n * Sign a transaction. This is equivalent to the `eth_signTransaction`\n * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for\n * more details.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param transaction - The transaction to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed transaction.\n */\n signTransaction?(\n address: Hex,\n transaction: Transaction,\n options?: Record<string, unknown>,\n ): Promise<SignedTransaction>;\n\n /**\n * Sign a message. This is equivalent to an older version of the the\n * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,\n * using the curve secp256k1 the Keccak-256 hash function.\n *\n * For more information about this method and why we still support it, see\n * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signMessage?(\n address: Hex,\n message: string,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC\n * method, which is exposed by MetaMask as the method `personal_sign`. See\n * the Ethereum JSON-RPC API documentation for more details.\n *\n * For more information about this method and why we call it `personal_sign`,\n * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signPersonalMessage?(\n address: Hex,\n message: Hex,\n options?: { version?: string } & Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum\n * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}\n * for more details.\n *\n * The \"version\" option dictates which version of `eth_signTypedData` is\n * used. The latest version reflects the specification most closely, whereas\n * earlier versions reflect earlier drafts of the specification that are\n * still supported for backwards-compatibility reasons. For more information\n * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept additional options as well. See the documentation for\n * the specific keyring for more information about what these options are.\n * For some keyrings, the options parameter can even change which key is used\n * for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param typedData - The data to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signTypedData?(\n address: Hex,\n typedData: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get a public key to use for encryption. This is equivalent to the\n * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}\n * for more information.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used (e.g. encrypting with app keys).\n *\n * @param account - The address of the account you want the encryption key for.\n * @param options - Options; differs between keyrings.\n */\n getEncryptionPublicKey?(\n account: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`\n * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}\n * for more information.\n *\n * @param account - The address of the account you want to use to decrypt\n * the message.\n * @param encryptedData - The encrypted data that you want to decrypt.\n * @returns The decrypted data.\n */\n decryptMessage?(\n account: Hex,\n encryptedData: Eip1024EncryptedData,\n ): Promise<string>;\n};\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Bytes } from './bytes';
|
|
2
|
+
import { Hex } from './hex';
|
|
3
|
+
export declare type Transaction = LegacyTransaction | EIP2930Transaction | EIP1559Transaction;
|
|
4
|
+
export declare type SignedTransaction = Transaction & Signature;
|
|
5
|
+
export declare type Signature = {
|
|
6
|
+
/**
|
|
7
|
+
* EC signature parameter
|
|
8
|
+
* 32 bytes long sequence.
|
|
9
|
+
*/
|
|
10
|
+
r: Bytes;
|
|
11
|
+
/**
|
|
12
|
+
* EC signature parameter
|
|
13
|
+
* Signature proof.
|
|
14
|
+
* 32 bytes long sequence
|
|
15
|
+
*/
|
|
16
|
+
s: Bytes;
|
|
17
|
+
/**
|
|
18
|
+
* Recovery identifier. It can be either 0x1b or 0x1c
|
|
19
|
+
* 1 byte long sequence
|
|
20
|
+
*/
|
|
21
|
+
yParity: Bytes;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Base Ethereum Transaction
|
|
25
|
+
*/
|
|
26
|
+
export declare type BaseTransaction = {
|
|
27
|
+
/**
|
|
28
|
+
* Sequentially incrementing counter which indicates the transaction
|
|
29
|
+
* number from the account
|
|
30
|
+
*/
|
|
31
|
+
nonce: Bytes;
|
|
32
|
+
/**
|
|
33
|
+
* The address of the sender, that will be signing the transaction
|
|
34
|
+
*/
|
|
35
|
+
from: Hex | Uint8Array;
|
|
36
|
+
/**
|
|
37
|
+
* The receiving address.
|
|
38
|
+
* If an externally-owned account, the transaction will transfer value.
|
|
39
|
+
* If a contract account, the transaction will execute the contract code.
|
|
40
|
+
*/
|
|
41
|
+
to: Hex | Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* The amount of Ether sent.
|
|
44
|
+
*/
|
|
45
|
+
value: Bytes;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum amount of gas units that this transaction can consume.
|
|
48
|
+
*/
|
|
49
|
+
gasLimit: Bytes;
|
|
50
|
+
/**
|
|
51
|
+
* Arbitrary data.
|
|
52
|
+
*/
|
|
53
|
+
data?: Bytes;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Typed Ethereum Transaction
|
|
57
|
+
*/
|
|
58
|
+
export declare type TypedTransaction = BaseTransaction & {
|
|
59
|
+
/**
|
|
60
|
+
* Transaction type.
|
|
61
|
+
*/
|
|
62
|
+
type: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Ethereum Legacy Transaction
|
|
66
|
+
* Reference: https://ethereum.org/en/developers/docs/transactions/
|
|
67
|
+
*/
|
|
68
|
+
export declare type LegacyTransaction = BaseTransaction & {
|
|
69
|
+
/**
|
|
70
|
+
* Transaction's gas price.
|
|
71
|
+
*/
|
|
72
|
+
gasPrice: Bytes | null;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* EIP-2930 Transaction: Optional Access Lists
|
|
76
|
+
* Reference: https://eips.ethereum.org/EIPS/eip-2930
|
|
77
|
+
*/
|
|
78
|
+
export declare type EIP2930Transaction = TypedTransaction & {
|
|
79
|
+
/**
|
|
80
|
+
* Transaction type.
|
|
81
|
+
*/
|
|
82
|
+
type: 1;
|
|
83
|
+
/**
|
|
84
|
+
* Transaction chain ID
|
|
85
|
+
*/
|
|
86
|
+
chainId: Bytes;
|
|
87
|
+
/**
|
|
88
|
+
* List of addresses and storage keys that the transaction plans to access
|
|
89
|
+
*/
|
|
90
|
+
accessList: {
|
|
91
|
+
address: Hex;
|
|
92
|
+
storageKeys: Hex[];
|
|
93
|
+
}[] | {
|
|
94
|
+
address: Uint8Array;
|
|
95
|
+
storageKeys: Uint8Array[];
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)
|
|
100
|
+
*
|
|
101
|
+
* Reference: https://eips.ethereum.org/EIPS/eip-1559
|
|
102
|
+
*/
|
|
103
|
+
export declare type EIP1559Transaction = TypedTransaction & {
|
|
104
|
+
/**
|
|
105
|
+
* Transaction type.
|
|
106
|
+
*/
|
|
107
|
+
type: 2;
|
|
108
|
+
/**
|
|
109
|
+
* Maximum fee to give to the miner
|
|
110
|
+
*/
|
|
111
|
+
maxPriorityFeePerGas: Bytes;
|
|
112
|
+
/**
|
|
113
|
+
* Maximum total fee
|
|
114
|
+
*/
|
|
115
|
+
maxFeePerGas: Bytes;
|
|
116
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-types.js","sourceRoot":"","sources":["../src/transaction-types.ts"],"names":[],"mappings":"","sourcesContent":["import { Bytes } from './bytes';\nimport { Hex } from './hex';\n\nexport type Transaction =\n | LegacyTransaction\n | EIP2930Transaction\n | EIP1559Transaction;\n\nexport type SignedTransaction = Transaction & Signature;\n\nexport type Signature = {\n /**\n * EC signature parameter\n * 32 bytes long sequence.\n */\n r: Bytes;\n\n /**\n * EC signature parameter\n * Signature proof.\n * 32 bytes long sequence\n */\n s: Bytes;\n\n /**\n * Recovery identifier. It can be either 0x1b or 0x1c\n * 1 byte long sequence\n */\n yParity: Bytes;\n};\n\n/**\n * Base Ethereum Transaction\n */\nexport type BaseTransaction = {\n /**\n * Sequentially incrementing counter which indicates the transaction\n * number from the account\n */\n nonce: Bytes;\n\n /**\n * The address of the sender, that will be signing the transaction\n */\n from: Hex | Uint8Array;\n\n /**\n * The receiving address.\n * If an externally-owned account, the transaction will transfer value.\n * If a contract account, the transaction will execute the contract code.\n */\n to: Hex | Uint8Array;\n\n /**\n * The amount of Ether sent.\n */\n value: Bytes;\n\n /**\n * Maximum amount of gas units that this transaction can consume.\n */\n gasLimit: Bytes;\n\n /**\n * Arbitrary data.\n */\n data?: Bytes;\n};\n\n/**\n * Typed Ethereum Transaction\n */\nexport type TypedTransaction = BaseTransaction & {\n /**\n * Transaction type.\n */\n type: number;\n};\n\n/**\n * Ethereum Legacy Transaction\n * Reference: https://ethereum.org/en/developers/docs/transactions/\n */\nexport type LegacyTransaction = BaseTransaction & {\n /**\n * Transaction's gas price.\n */\n gasPrice: Bytes | null;\n};\n\n/**\n * EIP-2930 Transaction: Optional Access Lists\n * Reference: https://eips.ethereum.org/EIPS/eip-2930\n */\nexport type EIP2930Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 1;\n\n /**\n * Transaction chain ID\n */\n chainId: Bytes;\n\n /**\n * List of addresses and storage keys that the transaction plans to access\n */\n accessList:\n | { address: Hex; storageKeys: Hex[] }[]\n | { address: Uint8Array; storageKeys: Uint8Array[] }[];\n};\n\n/**\n * EIP-1559 Transaction: Fee market change for ETH 1.0 chain (Type-2)\n *\n * Reference: https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = TypedTransaction & {\n /**\n * Transaction type.\n */\n type: 2;\n\n /**\n * Maximum fee to give to the miner\n */\n maxPriorityFeePerGas: Bytes;\n\n /**\n * Maximum total fee\n */\n maxFeePerGas: Bytes;\n};\n"]}
|