@metamask-previews/keyring-api 21.1.0-8202c83 → 21.3.0-2d9d5c0
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/CHANGELOG.md +35 -1
- package/README.md +11 -0
- package/dist/api/account-options.cjs +44 -7
- package/dist/api/account-options.cjs.map +1 -1
- package/dist/api/account-options.d.cts +41 -3
- package/dist/api/account-options.d.cts.map +1 -1
- package/dist/api/account-options.d.mts +41 -3
- package/dist/api/account-options.d.mts.map +1 -1
- package/dist/api/account-options.mjs +43 -6
- package/dist/api/account-options.mjs.map +1 -1
- package/dist/api/account.cjs +15 -1
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.d.cts +18 -0
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +18 -0
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/account.mjs +14 -0
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/index.cjs +1 -0
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -0
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -0
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/keyring.cjs +0 -2
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs +0 -2
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/v2/create-account/bip44.cjs +57 -0
- package/dist/api/v2/create-account/bip44.cjs.map +1 -0
- package/dist/api/v2/create-account/bip44.d.cts +83 -0
- package/dist/api/v2/create-account/bip44.d.cts.map +1 -0
- package/dist/api/v2/create-account/bip44.d.mts +83 -0
- package/dist/api/v2/create-account/bip44.d.mts.map +1 -0
- package/dist/api/v2/create-account/bip44.mjs +54 -0
- package/dist/api/v2/create-account/bip44.mjs.map +1 -0
- package/dist/api/v2/create-account/custom.cjs +14 -0
- package/dist/api/v2/create-account/custom.cjs.map +1 -0
- package/dist/api/v2/create-account/custom.d.cts +25 -0
- package/dist/api/v2/create-account/custom.d.cts.map +1 -0
- package/dist/api/v2/create-account/custom.d.mts +25 -0
- package/dist/api/v2/create-account/custom.d.mts.map +1 -0
- package/dist/api/v2/create-account/custom.mjs +11 -0
- package/dist/api/v2/create-account/custom.mjs.map +1 -0
- package/dist/api/v2/create-account/index.cjs +83 -0
- package/dist/api/v2/create-account/index.cjs.map +1 -0
- package/dist/api/v2/create-account/index.d.cts +68 -0
- package/dist/api/v2/create-account/index.d.cts.map +1 -0
- package/dist/api/v2/create-account/index.d.mts +68 -0
- package/dist/api/v2/create-account/index.d.mts.map +1 -0
- package/dist/api/v2/create-account/index.mjs +66 -0
- package/dist/api/v2/create-account/index.mjs.map +1 -0
- package/dist/api/v2/create-account/private-key.cjs +28 -0
- package/dist/api/v2/create-account/private-key.cjs.map +1 -0
- package/dist/api/v2/create-account/private-key.d.cts +45 -0
- package/dist/api/v2/create-account/private-key.d.cts.map +1 -0
- package/dist/api/v2/create-account/private-key.d.mts +45 -0
- package/dist/api/v2/create-account/private-key.d.mts.map +1 -0
- package/dist/api/v2/create-account/private-key.mjs +25 -0
- package/dist/api/v2/create-account/private-key.mjs.map +1 -0
- package/dist/api/v2/export-account/index.cjs +38 -0
- package/dist/api/v2/export-account/index.cjs.map +1 -0
- package/dist/api/v2/export-account/index.d.cts +48 -0
- package/dist/api/v2/export-account/index.d.cts.map +1 -0
- package/dist/api/v2/export-account/index.d.mts +48 -0
- package/dist/api/v2/export-account/index.d.mts.map +1 -0
- package/dist/api/v2/export-account/index.mjs +21 -0
- package/dist/api/v2/export-account/index.mjs.map +1 -0
- package/dist/api/v2/export-account/private-key.cjs +36 -0
- package/dist/api/v2/export-account/private-key.cjs.map +1 -0
- package/dist/api/v2/export-account/private-key.d.cts +53 -0
- package/dist/api/v2/export-account/private-key.d.cts.map +1 -0
- package/dist/api/v2/export-account/private-key.d.mts +53 -0
- package/dist/api/v2/export-account/private-key.d.mts.map +1 -0
- package/dist/api/v2/export-account/private-key.mjs +33 -0
- package/dist/api/v2/export-account/private-key.mjs.map +1 -0
- package/dist/api/v2/index.cjs +23 -0
- package/dist/api/v2/index.cjs.map +1 -0
- package/dist/api/v2/index.d.cts +8 -0
- package/dist/api/v2/index.d.cts.map +1 -0
- package/dist/api/v2/index.d.mts +8 -0
- package/dist/api/v2/index.d.mts.map +1 -0
- package/dist/api/v2/index.mjs +7 -0
- package/dist/api/v2/index.mjs.map +1 -0
- package/dist/api/v2/keyring-capabilities.cjs +56 -0
- package/dist/api/v2/keyring-capabilities.cjs.map +1 -0
- package/dist/api/v2/keyring-capabilities.d.cts +143 -0
- package/dist/api/v2/keyring-capabilities.d.cts.map +1 -0
- package/dist/api/v2/keyring-capabilities.d.mts +143 -0
- package/dist/api/v2/keyring-capabilities.d.mts.map +1 -0
- package/dist/api/v2/keyring-capabilities.mjs +53 -0
- package/dist/api/v2/keyring-capabilities.mjs.map +1 -0
- package/dist/api/v2/keyring-type.cjs +44 -0
- package/dist/api/v2/keyring-type.cjs.map +1 -0
- package/dist/api/v2/keyring-type.d.cts +40 -0
- package/dist/api/v2/keyring-type.d.cts.map +1 -0
- package/dist/api/v2/keyring-type.d.mts +40 -0
- package/dist/api/v2/keyring-type.d.mts.map +1 -0
- package/dist/api/v2/keyring-type.mjs +41 -0
- package/dist/api/v2/keyring-type.mjs.map +1 -0
- package/dist/api/v2/keyring.cjs +3 -0
- package/dist/api/v2/keyring.cjs.map +1 -0
- package/dist/api/v2/keyring.d.cts +107 -0
- package/dist/api/v2/keyring.d.cts.map +1 -0
- package/dist/api/v2/keyring.d.mts +107 -0
- package/dist/api/v2/keyring.d.mts.map +1 -0
- package/dist/api/v2/keyring.mjs +2 -0
- package/dist/api/v2/keyring.mjs.map +1 -0
- package/dist/api/v2/private-key.cjs +53 -0
- package/dist/api/v2/private-key.cjs.map +1 -0
- package/dist/api/v2/private-key.d.cts +77 -0
- package/dist/api/v2/private-key.d.cts.map +1 -0
- package/dist/api/v2/private-key.d.mts +77 -0
- package/dist/api/v2/private-key.d.mts.map +1 -0
- package/dist/api/v2/private-key.mjs +50 -0
- package/dist/api/v2/private-key.mjs.map +1 -0
- package/dist/api/v2/wrapper/index.cjs +19 -0
- package/dist/api/v2/wrapper/index.cjs.map +1 -0
- package/dist/api/v2/wrapper/index.d.cts +3 -0
- package/dist/api/v2/wrapper/index.d.cts.map +1 -0
- package/dist/api/v2/wrapper/index.d.mts +3 -0
- package/dist/api/v2/wrapper/index.d.mts.map +1 -0
- package/dist/api/v2/wrapper/index.mjs +3 -0
- package/dist/api/v2/wrapper/index.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs +116 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts +146 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts +146 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs +112 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
- package/dist/btc/types.d.cts +16 -0
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +16 -0
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/eth/erc4337/types.d.cts +4 -4
- package/dist/eth/erc4337/types.d.mts +4 -4
- package/dist/eth/index.cjs +2 -0
- package/dist/eth/index.cjs.map +1 -1
- package/dist/eth/index.d.cts +2 -0
- package/dist/eth/index.d.cts.map +1 -1
- package/dist/eth/index.d.mts +2 -0
- package/dist/eth/index.d.mts.map +1 -1
- package/dist/eth/index.mjs +2 -0
- package/dist/eth/index.mjs.map +1 -1
- package/dist/eth/rpc/index.cjs +18 -0
- package/dist/eth/rpc/index.cjs.map +1 -0
- package/dist/eth/rpc/index.d.cts +2 -0
- package/dist/eth/rpc/index.d.cts.map +1 -0
- package/dist/eth/rpc/index.d.mts +2 -0
- package/dist/eth/rpc/index.d.mts.map +1 -0
- package/dist/eth/rpc/index.mjs +2 -0
- package/dist/eth/rpc/index.mjs.map +1 -0
- package/dist/eth/rpc/params.cjs +151 -0
- package/dist/eth/rpc/params.cjs.map +1 -0
- package/dist/eth/rpc/params.d.cts +215 -0
- package/dist/eth/rpc/params.d.cts.map +1 -0
- package/dist/eth/rpc/params.d.mts +215 -0
- package/dist/eth/rpc/params.d.mts.map +1 -0
- package/dist/eth/rpc/params.mjs +148 -0
- package/dist/eth/rpc/params.mjs.map +1 -0
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +13 -5
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +13 -5
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs.map +1 -1
- package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
- package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
- package/dist/eth/v2/index.cjs +18 -0
- package/dist/eth/v2/index.cjs.map +1 -0
- package/dist/eth/v2/index.d.cts +2 -0
- package/dist/eth/v2/index.d.cts.map +1 -0
- package/dist/eth/v2/index.d.mts +2 -0
- package/dist/eth/v2/index.d.mts.map +1 -0
- package/dist/eth/v2/index.mjs +2 -0
- package/dist/eth/v2/index.mjs.map +1 -0
- package/dist/events.cjs +0 -2
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +16 -0
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +16 -0
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +0 -2
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +15 -11
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +34 -12
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +34 -12
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +15 -11
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/types.d.cts +4 -0
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +4 -0
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/trx/types.cjs +4 -0
- package/dist/trx/types.cjs.map +1 -1
- package/dist/trx/types.d.cts +8 -0
- package/dist/trx/types.d.cts.map +1 -1
- package/dist/trx/types.d.mts +8 -0
- package/dist/trx/types.d.mts.map +1 -1
- package/dist/trx/types.mjs +4 -0
- package/dist/trx/types.mjs.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Superstruct validation schemas for Ethereum JSON-RPC method parameters.
|
|
3
|
+
*
|
|
4
|
+
* These structs provide runtime validation for the parameters passed to various
|
|
5
|
+
* Ethereum RPC methods. They can be used by keyring implementations to validate
|
|
6
|
+
* incoming requests before processing.
|
|
7
|
+
*/
|
|
8
|
+
import { object } from "@metamask/keyring-utils";
|
|
9
|
+
import { any, array, literal, nullable, number, optional, record, string, tuple, type, union, unknown } from "@metamask/superstruct";
|
|
10
|
+
import { EthAddressStruct, EthBytesStruct } from "../types.mjs";
|
|
11
|
+
/**
|
|
12
|
+
* A struct for validating Ethereum transaction data.
|
|
13
|
+
*
|
|
14
|
+
* This uses `type()` instead of `object()` to allow extra properties,
|
|
15
|
+
* since transaction formats can vary and include additional fields.
|
|
16
|
+
* The actual transaction validation is performed by the transaction library.
|
|
17
|
+
*/
|
|
18
|
+
export const EthTransactionDataStruct = type({
|
|
19
|
+
to: optional(nullable(EthAddressStruct)),
|
|
20
|
+
from: optional(EthAddressStruct),
|
|
21
|
+
nonce: optional(union([string(), number()])),
|
|
22
|
+
value: optional(union([string(), number()])),
|
|
23
|
+
data: optional(EthBytesStruct),
|
|
24
|
+
gas: optional(union([string(), number()])),
|
|
25
|
+
gasLimit: optional(union([string(), number()])),
|
|
26
|
+
gasPrice: optional(union([string(), number()])),
|
|
27
|
+
maxFeePerGas: optional(union([string(), number()])),
|
|
28
|
+
maxPriorityFeePerGas: optional(union([string(), number()])),
|
|
29
|
+
accessList: optional(array(type({
|
|
30
|
+
address: EthAddressStruct,
|
|
31
|
+
storageKeys: array(string()),
|
|
32
|
+
}))),
|
|
33
|
+
type: optional(union([string(), number()])),
|
|
34
|
+
chainId: optional(union([string(), number()])),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* A struct for TypedDataV1 format (legacy typed data).
|
|
38
|
+
* This is an array of { type, name, value } objects.
|
|
39
|
+
*/
|
|
40
|
+
export const EthTypedDataV1Struct = array(object({
|
|
41
|
+
type: string(),
|
|
42
|
+
name: string(),
|
|
43
|
+
value: unknown(),
|
|
44
|
+
}));
|
|
45
|
+
/**
|
|
46
|
+
* A struct for TypedData types definition.
|
|
47
|
+
* Maps type names to arrays of { name, type } definitions.
|
|
48
|
+
*/
|
|
49
|
+
export const EthTypedDataTypesStruct = record(string(), array(object({
|
|
50
|
+
name: string(),
|
|
51
|
+
type: string(),
|
|
52
|
+
})));
|
|
53
|
+
/**
|
|
54
|
+
* A struct for TypedMessage format (EIP-712 V3/V4).
|
|
55
|
+
* Contains types, domain, primaryType, and message.
|
|
56
|
+
*/
|
|
57
|
+
export const EthTypedMessageStruct = object({
|
|
58
|
+
types: EthTypedDataTypesStruct,
|
|
59
|
+
primaryType: string(),
|
|
60
|
+
domain: record(string(), any()),
|
|
61
|
+
message: record(string(), any()),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).
|
|
65
|
+
*/
|
|
66
|
+
export const EthEncryptedDataStruct = object({
|
|
67
|
+
version: literal('x25519-xsalsa20-poly1305'),
|
|
68
|
+
nonce: string(),
|
|
69
|
+
ephemPublicKey: string(),
|
|
70
|
+
ciphertext: string(),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* A struct for EIP-7702 authorization tuple.
|
|
74
|
+
* Format: [chainId, address, nonce]
|
|
75
|
+
*/
|
|
76
|
+
export const EthEip7702AuthorizationStruct = tuple([
|
|
77
|
+
number(), // chainId
|
|
78
|
+
EthAddressStruct, // address (contract to delegate to)
|
|
79
|
+
number(), // nonce
|
|
80
|
+
]);
|
|
81
|
+
/**
|
|
82
|
+
* A struct for getEncryptionPublicKey options.
|
|
83
|
+
*/
|
|
84
|
+
export const EthGetEncryptionPublicKeyOptionsStruct = record(string(), unknown());
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// RPC Method Parameter Structs
|
|
87
|
+
// ============================================================================
|
|
88
|
+
/**
|
|
89
|
+
* Parameters for `eth_signTransaction`.
|
|
90
|
+
*/
|
|
91
|
+
export const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);
|
|
92
|
+
/**
|
|
93
|
+
* Parameters for `eth_sign`.
|
|
94
|
+
*/
|
|
95
|
+
export const EthSignParamsStruct = tuple([
|
|
96
|
+
EthAddressStruct, // address
|
|
97
|
+
EthBytesStruct, // data (hex-encoded message hash)
|
|
98
|
+
]);
|
|
99
|
+
/**
|
|
100
|
+
* Parameters for `personal_sign`.
|
|
101
|
+
*/
|
|
102
|
+
export const EthPersonalSignParamsStruct = union([
|
|
103
|
+
tuple([EthBytesStruct]), // [data]
|
|
104
|
+
tuple([EthBytesStruct, EthAddressStruct]), // [data, address]
|
|
105
|
+
]);
|
|
106
|
+
/**
|
|
107
|
+
* Parameters for `eth_signTypedData_v1`.
|
|
108
|
+
*/
|
|
109
|
+
export const EthSignTypedDataV1ParamsStruct = tuple([
|
|
110
|
+
EthAddressStruct, // address
|
|
111
|
+
EthTypedDataV1Struct, // typed data array
|
|
112
|
+
]);
|
|
113
|
+
/**
|
|
114
|
+
* Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.
|
|
115
|
+
*/
|
|
116
|
+
export const EthSignTypedDataParamsStruct = tuple([
|
|
117
|
+
EthAddressStruct, // address
|
|
118
|
+
EthTypedMessageStruct, // typed data object
|
|
119
|
+
]);
|
|
120
|
+
/**
|
|
121
|
+
* Parameters for `eth_decrypt`.
|
|
122
|
+
*/
|
|
123
|
+
export const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);
|
|
124
|
+
/**
|
|
125
|
+
* Parameters for `eth_getAppKeyAddress`.
|
|
126
|
+
*/
|
|
127
|
+
export const EthGetAppKeyAddressParamsStruct = tuple([
|
|
128
|
+
string(), // origin URL
|
|
129
|
+
]);
|
|
130
|
+
/**
|
|
131
|
+
* Parameters for `eth_signEip7702Authorization`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const params = [[1, '0xContractAddress', 0]];
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export const EthSignEip7702AuthorizationParamsStruct = tuple([
|
|
139
|
+
EthEip7702AuthorizationStruct,
|
|
140
|
+
]);
|
|
141
|
+
/**
|
|
142
|
+
* Parameters for `eth_getEncryptionPublicKey`.
|
|
143
|
+
*/
|
|
144
|
+
export const EthGetEncryptionPublicKeyParamsStruct = tuple([
|
|
145
|
+
EthAddressStruct, // address
|
|
146
|
+
optional(EthGetEncryptionPublicKeyOptionsStruct), // options
|
|
147
|
+
]);
|
|
148
|
+
//# sourceMappingURL=params.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.mjs","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EACL,GAAG,EACH,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACR,8BAA8B;AAE/B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,qBAAiB;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;IAC3C,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACxC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAChC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5C,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5C,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC;IAC9B,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1C,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/C,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MA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AE,oBAAoB;CAC5C,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAItE;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;IACnD,MAAM,EAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,CAAC;IAC3D,6BAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;IACzD,gBAAgB,EAAE,UAAU;IAC5B,QAAQ,CAAC,sCAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n array,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n tuple,\n type,\n union,\n unknown,\n} from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct } from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n to: optional(nullable(EthAddressStruct)),\n from: optional(EthAddressStruct),\n nonce: optional(union([string(), number()])),\n value: optional(union([string(), number()])),\n data: optional(EthBytesStruct),\n gas: optional(union([string(), number()])),\n gasLimit: optional(union([string(), number()])),\n gasPrice: optional(union([string(), number()])),\n maxFeePerGas: optional(union([string(), number()])),\n maxPriorityFeePerGas: optional(union([string(), number()])),\n accessList: optional(\n array(\n type({\n address: EthAddressStruct,\n storageKeys: array(string()),\n }),\n ),\n ),\n type: optional(union([string(), number()])),\n chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n object({\n type: string(),\n name: string(),\n value: unknown(),\n }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n string(),\n array(\n object({\n name: string(),\n type: string(),\n }),\n ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n types: EthTypedDataTypesStruct,\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n version: literal('x25519-xsalsa20-poly1305'),\n nonce: string(),\n ephemPublicKey: string(),\n ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n number(), // chainId\n EthAddressStruct, // address (contract to delegate to)\n number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n string(),\n unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n EthAddressStruct, // address\n EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n tuple([EthBytesStruct]), // [data]\n tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n EthAddressStruct, // address\n optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]}
|
package/dist/eth/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAAwE;AACxE,2CAA0D;AAE1D,kCAA6B;AAC7B,0CAIgB;AAEH,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oDAAuC,CAAA;IACvC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,mBAAmB;IACnB,8DAAiD,CAAA;IACjD,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;AAC7C,CAAC,EAZW,SAAS,yBAAT,SAAS,QAYpB;AAEY,QAAA,mBAAmB,GAAG,IAAA,sBAAM,EAAC;IACxC,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC;IAEtC;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,IAAA,qBAAO,EAAC,WAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;KAC/B,CAAC,CACH;CACF,CAAC,CAAC;AAIU,QAAA,uBAAuB,GAAG,IAAA,sBAAM,EAAC;IAC5C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,uBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern<Hex>(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|
package/dist/eth/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Infer } from "@metamask/superstruct";
|
|
2
2
|
import { EthScope } from "./index.cjs";
|
|
3
3
|
export declare const EthBytesStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
4
|
-
export declare const EthAddressStruct: import("@metamask/superstruct").Struct
|
|
4
|
+
export declare const EthAddressStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
5
5
|
export declare const EthUint256Struct: import("@metamask/superstruct").Struct<string, null>;
|
|
6
6
|
/**
|
|
7
7
|
* Supported Ethereum methods.
|
|
@@ -28,17 +28,19 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
|
|
|
28
28
|
groupIndex: number;
|
|
29
29
|
} | {
|
|
30
30
|
type: "private-key";
|
|
31
|
+
} | {
|
|
32
|
+
type: "custom";
|
|
31
33
|
};
|
|
32
34
|
exportable?: boolean;
|
|
33
35
|
};
|
|
34
|
-
address: string
|
|
36
|
+
address: `0x${string}`;
|
|
35
37
|
scopes: EthScope.Eoa[];
|
|
36
38
|
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
|
|
37
39
|
}, {
|
|
38
40
|
/**
|
|
39
41
|
* Account address.
|
|
40
42
|
*/
|
|
41
|
-
address: import("@metamask/superstruct").Struct
|
|
43
|
+
address: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
42
44
|
/**
|
|
43
45
|
* Account type.
|
|
44
46
|
*/
|
|
@@ -67,6 +69,8 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
|
|
|
67
69
|
groupIndex: number;
|
|
68
70
|
} | {
|
|
69
71
|
type: "private-key";
|
|
72
|
+
} | {
|
|
73
|
+
type: "custom";
|
|
70
74
|
};
|
|
71
75
|
exportable?: boolean;
|
|
72
76
|
}, null>;
|
|
@@ -83,17 +87,19 @@ export declare const EthErc4337AccountStruct: import("@metamask/superstruct").St
|
|
|
83
87
|
groupIndex: number;
|
|
84
88
|
} | {
|
|
85
89
|
type: "private-key";
|
|
90
|
+
} | {
|
|
91
|
+
type: "custom";
|
|
86
92
|
};
|
|
87
93
|
exportable?: boolean;
|
|
88
94
|
};
|
|
89
|
-
address: string
|
|
95
|
+
address: `0x${string}`;
|
|
90
96
|
scopes: `${string}:${string}`[];
|
|
91
97
|
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
|
|
92
98
|
}, {
|
|
93
99
|
/**
|
|
94
100
|
* Account address.
|
|
95
101
|
*/
|
|
96
|
-
address: import("@metamask/superstruct").Struct
|
|
102
|
+
address: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
97
103
|
/**
|
|
98
104
|
* Account type.
|
|
99
105
|
*/
|
|
@@ -124,6 +130,8 @@ export declare const EthErc4337AccountStruct: import("@metamask/superstruct").St
|
|
|
124
130
|
groupIndex: number;
|
|
125
131
|
} | {
|
|
126
132
|
type: "private-key";
|
|
133
|
+
} | {
|
|
134
|
+
type: "custom";
|
|
127
135
|
};
|
|
128
136
|
exportable?: boolean;
|
|
129
137
|
}, null>;
|
package/dist/eth/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,6DAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,YAAY,kBAAkB;IAC9B,IAAI,aAAa;IACjB,eAAe,wBAAwB;IACvC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IAExC,oBAAoB,6BAA6B;IACjD,kBAAkB,2BAA2B;IAC7C,iBAAiB,0BAA0B;CAC5C;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;IAG9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
package/dist/eth/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Infer } from "@metamask/superstruct";
|
|
2
2
|
import { EthScope } from "./index.mjs";
|
|
3
3
|
export declare const EthBytesStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
4
|
-
export declare const EthAddressStruct: import("@metamask/superstruct").Struct
|
|
4
|
+
export declare const EthAddressStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
5
5
|
export declare const EthUint256Struct: import("@metamask/superstruct").Struct<string, null>;
|
|
6
6
|
/**
|
|
7
7
|
* Supported Ethereum methods.
|
|
@@ -28,17 +28,19 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
|
|
|
28
28
|
groupIndex: number;
|
|
29
29
|
} | {
|
|
30
30
|
type: "private-key";
|
|
31
|
+
} | {
|
|
32
|
+
type: "custom";
|
|
31
33
|
};
|
|
32
34
|
exportable?: boolean;
|
|
33
35
|
};
|
|
34
|
-
address: string
|
|
36
|
+
address: `0x${string}`;
|
|
35
37
|
scopes: EthScope.Eoa[];
|
|
36
38
|
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
|
|
37
39
|
}, {
|
|
38
40
|
/**
|
|
39
41
|
* Account address.
|
|
40
42
|
*/
|
|
41
|
-
address: import("@metamask/superstruct").Struct
|
|
43
|
+
address: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
42
44
|
/**
|
|
43
45
|
* Account type.
|
|
44
46
|
*/
|
|
@@ -67,6 +69,8 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
|
|
|
67
69
|
groupIndex: number;
|
|
68
70
|
} | {
|
|
69
71
|
type: "private-key";
|
|
72
|
+
} | {
|
|
73
|
+
type: "custom";
|
|
70
74
|
};
|
|
71
75
|
exportable?: boolean;
|
|
72
76
|
}, null>;
|
|
@@ -83,17 +87,19 @@ export declare const EthErc4337AccountStruct: import("@metamask/superstruct").St
|
|
|
83
87
|
groupIndex: number;
|
|
84
88
|
} | {
|
|
85
89
|
type: "private-key";
|
|
90
|
+
} | {
|
|
91
|
+
type: "custom";
|
|
86
92
|
};
|
|
87
93
|
exportable?: boolean;
|
|
88
94
|
};
|
|
89
|
-
address: string
|
|
95
|
+
address: `0x${string}`;
|
|
90
96
|
scopes: `${string}:${string}`[];
|
|
91
97
|
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
|
|
92
98
|
}, {
|
|
93
99
|
/**
|
|
94
100
|
* Account address.
|
|
95
101
|
*/
|
|
96
|
-
address: import("@metamask/superstruct").Struct
|
|
102
|
+
address: import("@metamask/superstruct").Struct<`0x${string}`, null>;
|
|
97
103
|
/**
|
|
98
104
|
* Account type.
|
|
99
105
|
*/
|
|
@@ -124,6 +130,8 @@ export declare const EthErc4337AccountStruct: import("@metamask/superstruct").St
|
|
|
124
130
|
groupIndex: number;
|
|
125
131
|
} | {
|
|
126
132
|
type: "private-key";
|
|
133
|
+
} | {
|
|
134
|
+
type: "custom";
|
|
127
135
|
};
|
|
128
136
|
exportable?: boolean;
|
|
129
137
|
}, null>;
|
package/dist/eth/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,6DAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,YAAY,kBAAkB;IAC9B,IAAI,aAAa;IACjB,eAAe,wBAAwB;IACvC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IAExC,oBAAoB,6BAA6B;IACjD,kBAAkB,2BAA2B;IAC7C,iBAAiB,0BAA0B;CAC5C;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;IAG9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
package/dist/eth/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B;AACxE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B;AACxE,OAAO,EAAE,aAAa,EAAY,wBAAwB;AAE1D,OAAO,EAAE,QAAQ,EAAE,o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/B,CAAC,CACH;CACF,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;IAC5C,GAAG,oBAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,gBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,KAAK,CACZ,KAAK,CAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern<Hex>(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EthKeyringWrapper = exports.EthKeyringMethod = void 0;
|
|
4
|
+
const tx_1 = require("@ethereumjs/tx");
|
|
5
|
+
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
6
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
7
|
+
const utils_1 = require("@metamask/utils");
|
|
8
|
+
const keyring_wrapper_1 = require("../../api/v2/wrapper/keyring-wrapper.cjs");
|
|
9
|
+
const rpc_1 = require("../rpc/index.cjs");
|
|
10
|
+
const types_1 = require("../types.cjs");
|
|
11
|
+
/**
|
|
12
|
+
* Additional Ethereum methods supported by Eth keyrings that are not in the standard EthMethod enum.
|
|
13
|
+
* These are primarily encryption and utility methods.
|
|
14
|
+
*/
|
|
15
|
+
var EthKeyringMethod;
|
|
16
|
+
(function (EthKeyringMethod) {
|
|
17
|
+
EthKeyringMethod["Decrypt"] = "eth_decrypt";
|
|
18
|
+
EthKeyringMethod["GetEncryptionPublicKey"] = "eth_getEncryptionPublicKey";
|
|
19
|
+
EthKeyringMethod["GetAppKeyAddress"] = "eth_getAppKeyAddress";
|
|
20
|
+
EthKeyringMethod["SignEip7702Authorization"] = "eth_signEip7702Authorization";
|
|
21
|
+
})(EthKeyringMethod || (exports.EthKeyringMethod = EthKeyringMethod = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements KeyringV2.
|
|
24
|
+
*
|
|
25
|
+
* This class provides common functionality for all Ethereum keyrings including:
|
|
26
|
+
* - Request handling for standard Ethereum signing methods
|
|
27
|
+
* - Helper methods for Hex address conversion
|
|
28
|
+
*
|
|
29
|
+
* Subclasses must implement:
|
|
30
|
+
* - `getAccounts()`: Return all managed accounts
|
|
31
|
+
* - `createAccounts()`: Create new accounts based on options
|
|
32
|
+
* - `deleteAccount()`: Remove an account from the keyring
|
|
33
|
+
* - `exportAccount()` (optional): Export private key in specified format
|
|
34
|
+
*/
|
|
35
|
+
class EthKeyringWrapper extends keyring_wrapper_1.KeyringWrapper {
|
|
36
|
+
/**
|
|
37
|
+
* Helper method to safely cast a KeyringAccount address to Hex type.
|
|
38
|
+
* The KeyringAccount.address is typed as string, but for Ethereum accounts
|
|
39
|
+
* it should always be a valid Hex address.
|
|
40
|
+
*
|
|
41
|
+
* @param address - The address from a KeyringAccount.
|
|
42
|
+
* @returns The address as Hex type.
|
|
43
|
+
*/
|
|
44
|
+
toHexAddress(address) {
|
|
45
|
+
return (0, utils_1.add0x)(address);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handle an Ethereum signing request.
|
|
49
|
+
*
|
|
50
|
+
* Routes the request to the appropriate legacy keyring method based on
|
|
51
|
+
* the RPC method name.
|
|
52
|
+
*
|
|
53
|
+
* @param request - The keyring request containing method and params.
|
|
54
|
+
* @returns The result of the signing operation.
|
|
55
|
+
*/
|
|
56
|
+
async submitRequest(request) {
|
|
57
|
+
const { method, params } = request.request;
|
|
58
|
+
const { address, methods } = await this.getAccount(request.account);
|
|
59
|
+
const hexAddress = this.toHexAddress(address);
|
|
60
|
+
// Validate account can handle the method
|
|
61
|
+
if (!methods.includes(method)) {
|
|
62
|
+
throw new Error(`Account ${request.account} cannot handle method: ${method}`);
|
|
63
|
+
}
|
|
64
|
+
switch (method) {
|
|
65
|
+
case `${types_1.EthMethod.SignTransaction}`: {
|
|
66
|
+
if (!this.inner.signTransaction) {
|
|
67
|
+
throw new Error('Keyring does not support signTransaction');
|
|
68
|
+
}
|
|
69
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignTransactionParamsStruct);
|
|
70
|
+
const [txData] = params;
|
|
71
|
+
// Convert validated transaction data to TypedTransaction
|
|
72
|
+
// TODO: Improve typing to ensure txData matches TypedTxData
|
|
73
|
+
const tx = tx_1.TransactionFactory.fromTxData(txData);
|
|
74
|
+
// Note: Bigints are not directly representable in JSON
|
|
75
|
+
return (await this.inner.signTransaction(hexAddress, tx)); // FIXME: Should return type be unknown?
|
|
76
|
+
}
|
|
77
|
+
case `${types_1.EthMethod.Sign}`: {
|
|
78
|
+
if (!this.inner.signMessage) {
|
|
79
|
+
throw new Error('Keyring does not support signMessage');
|
|
80
|
+
}
|
|
81
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignParamsStruct);
|
|
82
|
+
const [, data] = params;
|
|
83
|
+
return this.inner.signMessage(hexAddress, data);
|
|
84
|
+
}
|
|
85
|
+
case `${types_1.EthMethod.PersonalSign}`: {
|
|
86
|
+
if (!this.inner.signPersonalMessage) {
|
|
87
|
+
throw new Error('Keyring does not support signPersonalMessage');
|
|
88
|
+
}
|
|
89
|
+
(0, superstruct_1.assert)(params, rpc_1.EthPersonalSignParamsStruct);
|
|
90
|
+
const [data] = params;
|
|
91
|
+
return this.inner.signPersonalMessage(hexAddress, data);
|
|
92
|
+
}
|
|
93
|
+
case `${types_1.EthMethod.SignTypedDataV1}`: {
|
|
94
|
+
if (!this.inner.signTypedData) {
|
|
95
|
+
throw new Error('Keyring does not support signTypedData');
|
|
96
|
+
}
|
|
97
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignTypedDataV1ParamsStruct);
|
|
98
|
+
const [, data] = params;
|
|
99
|
+
return this.inner.signTypedData(hexAddress, data, {
|
|
100
|
+
version: eth_sig_util_1.SignTypedDataVersion.V1,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
case `${types_1.EthMethod.SignTypedDataV3}`: {
|
|
104
|
+
if (!this.inner.signTypedData) {
|
|
105
|
+
throw new Error('Keyring does not support signTypedData');
|
|
106
|
+
}
|
|
107
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignTypedDataParamsStruct);
|
|
108
|
+
const [, data] = params;
|
|
109
|
+
return this.inner.signTypedData(hexAddress,
|
|
110
|
+
// TODO: Improve typing to ensure data matches MessageTypes
|
|
111
|
+
data, {
|
|
112
|
+
version: eth_sig_util_1.SignTypedDataVersion.V3,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
case `${types_1.EthMethod.SignTypedDataV4}`: {
|
|
116
|
+
if (!this.inner.signTypedData) {
|
|
117
|
+
throw new Error('Keyring does not support signTypedData');
|
|
118
|
+
}
|
|
119
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignTypedDataParamsStruct);
|
|
120
|
+
const [, data] = params;
|
|
121
|
+
return this.inner.signTypedData(hexAddress,
|
|
122
|
+
// TODO: Improve typing to ensure data matches MessageTypes
|
|
123
|
+
data, {
|
|
124
|
+
version: eth_sig_util_1.SignTypedDataVersion.V4,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
case `${EthKeyringMethod.Decrypt}`: {
|
|
128
|
+
if (!this.inner.decryptMessage) {
|
|
129
|
+
throw new Error('Keyring does not support decryptMessage');
|
|
130
|
+
}
|
|
131
|
+
(0, superstruct_1.assert)(params, rpc_1.EthDecryptParamsStruct);
|
|
132
|
+
const [encryptedData] = params;
|
|
133
|
+
return this.inner.decryptMessage(hexAddress, encryptedData);
|
|
134
|
+
}
|
|
135
|
+
case `${EthKeyringMethod.GetEncryptionPublicKey}`: {
|
|
136
|
+
if (!this.inner.getEncryptionPublicKey) {
|
|
137
|
+
throw new Error('Keyring does not support getEncryptionPublicKey');
|
|
138
|
+
}
|
|
139
|
+
(0, superstruct_1.assert)(params, rpc_1.EthGetEncryptionPublicKeyParamsStruct);
|
|
140
|
+
const [, options] = params;
|
|
141
|
+
return this.inner.getEncryptionPublicKey(hexAddress, options);
|
|
142
|
+
}
|
|
143
|
+
case `${EthKeyringMethod.GetAppKeyAddress}`: {
|
|
144
|
+
if (!this.inner.getAppKeyAddress) {
|
|
145
|
+
throw new Error('Keyring does not support getAppKeyAddress');
|
|
146
|
+
}
|
|
147
|
+
(0, superstruct_1.assert)(params, rpc_1.EthGetAppKeyAddressParamsStruct);
|
|
148
|
+
const [origin] = params;
|
|
149
|
+
return this.inner.getAppKeyAddress(hexAddress, origin);
|
|
150
|
+
}
|
|
151
|
+
case `${EthKeyringMethod.SignEip7702Authorization}`: {
|
|
152
|
+
if (!this.inner.signEip7702Authorization) {
|
|
153
|
+
throw new Error('Keyring does not support signEip7702Authorization');
|
|
154
|
+
}
|
|
155
|
+
(0, superstruct_1.assert)(params, rpc_1.EthSignEip7702AuthorizationParamsStruct);
|
|
156
|
+
const [authorization] = params;
|
|
157
|
+
return this.inner.signEip7702Authorization(hexAddress, authorization);
|
|
158
|
+
}
|
|
159
|
+
default:
|
|
160
|
+
throw new Error(`Unsupported method for EthKeyringWrapper: ${method}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.EthKeyringWrapper = EthKeyringWrapper;
|
|
165
|
+
//# sourceMappingURL=eth-keyring-wrapper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.cjs","sourceRoot":"","sources":["../../../src/eth/v2/eth-keyring-wrapper.ts"],"names":[],"mappings":";;;AAAA,uCAAsE;AAEtE,yDAA8D;AAE9D,uDAA+C;AAC/C,2CAA6D;AAI7D,8EAG8C;AAC9C,0CAUgB;AAChB,wCAAqC;AAErC;;;GAGG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,yEAAqD,CAAA;IACrD,6DAAyC,CAAA;IACzC,6EAAyD,CAAA;AAC3D,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAQD;;;;;;;;;;;;GAYG;AACH,MAAsB,iBAGpB,SAAQ,gCAAgD;IACxD;;;;;;;OAOG;IACO,YAAY,CAAC,OAAe;QACpC,OAAO,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,OAAuB;QACzC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;QAE3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,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AO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAChE,CAAC;YAED,KAAK,GAAG,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;oBACjC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;gBAC/D,CAAC;gBACD,IAAA,oBAAM,EAAC,MAAM,EAAE,qCAA+B,CAAC,CAAC;gBAChD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;gBACxB,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACzD,CAAC;YAED,KAAK,GAAG,gBAAgB,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;gBACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;oBACzC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAA,oBAAM,EAAC,MAAM,EAAE,6CAAuC,CAAC,CAAC;gBACxD,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC;gBAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;YACxE,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;CACF;AA5JD,8CA4JC","sourcesContent":["import { TransactionFactory, type TypedTxData } from '@ethereumjs/tx';\nimport type { MessageTypes, TypedMessage } from '@metamask/eth-sig-util';\nimport { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport type { EthKeyring } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport { add0x, type Hex, type Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from '../../api/account';\nimport type { KeyringRequest } from '../../api/request';\nimport {\n KeyringWrapper,\n type KeyringWrapperOptions,\n} from '../../api/v2/wrapper/keyring-wrapper';\nimport {\n EthDecryptParamsStruct,\n EthGetAppKeyAddressParamsStruct,\n EthGetEncryptionPublicKeyParamsStruct,\n EthPersonalSignParamsStruct,\n EthSignEip7702AuthorizationParamsStruct,\n EthSignParamsStruct,\n EthSignTransactionParamsStruct,\n EthSignTypedDataParamsStruct,\n EthSignTypedDataV1ParamsStruct,\n} from '../rpc';\nimport { EthMethod } from '../types';\n\n/**\n * Additional Ethereum methods supported by Eth keyrings that are not in the standard EthMethod enum.\n * These are primarily encryption and utility methods.\n */\nexport enum EthKeyringMethod {\n Decrypt = 'eth_decrypt',\n GetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n GetAppKeyAddress = 'eth_getAppKeyAddress',\n SignEip7702Authorization = 'eth_signEip7702Authorization',\n}\n\n/**\n * Options for constructing an EthKeyringWrapper.\n */\nexport type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> =\n KeyringWrapperOptions<InnerKeyring>;\n\n/**\n * Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements KeyringV2.\n *\n * This class provides common functionality for all Ethereum keyrings including:\n * - Request handling for standard Ethereum signing methods\n * - Helper methods for Hex address conversion\n *\n * Subclasses must implement:\n * - `getAccounts()`: Return all managed accounts\n * - `createAccounts()`: Create new accounts based on options\n * - `deleteAccount()`: Remove an account from the keyring\n * - `exportAccount()` (optional): Export private key in specified format\n */\nexport abstract class EthKeyringWrapper<\n InnerKeyring extends EthKeyring,\n KeyringAccountType extends KeyringAccount = KeyringAccount,\n> extends KeyringWrapper<InnerKeyring, KeyringAccountType> {\n /**\n * Helper method to safely cast a KeyringAccount address to Hex type.\n * The KeyringAccount.address is typed as string, but for Ethereum accounts\n * it should always be a valid Hex address.\n *\n * @param address - The address from a KeyringAccount.\n * @returns The address as Hex type.\n */\n protected toHexAddress(address: string): Hex {\n return add0x(address);\n }\n\n /**\n * Handle an Ethereum signing request.\n *\n * Routes the request to the appropriate legacy keyring method based on\n * the RPC method name.\n *\n * @param request - The keyring request containing method and params.\n * @returns The result of the signing operation.\n */\n async submitRequest(request: KeyringRequest): Promise<Json> {\n const { method, params } = request.request;\n\n const { address, methods } = await this.getAccount(request.account);\n const hexAddress = this.toHexAddress(address);\n\n // Validate account can handle the method\n if (!methods.includes(method)) {\n throw new Error(\n `Account ${request.account} cannot handle method: ${method}`,\n );\n }\n\n switch (method) {\n case `${EthMethod.SignTransaction}`: {\n if (!this.inner.signTransaction) {\n throw new Error('Keyring does not support signTransaction');\n }\n assert(params, EthSignTransactionParamsStruct);\n const [txData] = params;\n // Convert validated transaction data to TypedTransaction\n // TODO: Improve typing to ensure txData matches TypedTxData\n const tx = TransactionFactory.fromTxData(txData as TypedTxData);\n // Note: Bigints are not directly representable in JSON\n return (await this.inner.signTransaction(\n hexAddress,\n tx,\n )) as unknown as Json; // FIXME: Should return type be unknown?\n }\n\n case `${EthMethod.Sign}`: {\n if (!this.inner.signMessage) {\n throw new Error('Keyring does not support signMessage');\n }\n assert(params, EthSignParamsStruct);\n const [, data] = params;\n return this.inner.signMessage(hexAddress, data);\n }\n\n case `${EthMethod.PersonalSign}`: {\n if (!this.inner.signPersonalMessage) {\n throw new Error('Keyring does not support signPersonalMessage');\n }\n assert(params, EthPersonalSignParamsStruct);\n const [data] = params;\n return this.inner.signPersonalMessage(hexAddress, data as Hex);\n }\n\n case `${EthMethod.SignTypedDataV1}`: {\n if (!this.inner.signTypedData) {\n throw new Error('Keyring does not support signTypedData');\n }\n assert(params, EthSignTypedDataV1ParamsStruct);\n const [, data] = params;\n return this.inner.signTypedData(hexAddress, data, {\n version: SignTypedDataVersion.V1,\n });\n }\n\n case `${EthMethod.SignTypedDataV3}`: {\n if (!this.inner.signTypedData) {\n throw new Error('Keyring does not support signTypedData');\n }\n assert(params, EthSignTypedDataParamsStruct);\n const [, data] = params;\n return this.inner.signTypedData(\n hexAddress,\n // TODO: Improve typing to ensure data matches MessageTypes\n data as TypedMessage<MessageTypes>,\n {\n version: SignTypedDataVersion.V3,\n },\n );\n }\n\n case `${EthMethod.SignTypedDataV4}`: {\n if (!this.inner.signTypedData) {\n throw new Error('Keyring does not support signTypedData');\n }\n assert(params, EthSignTypedDataParamsStruct);\n const [, data] = params;\n return this.inner.signTypedData(\n hexAddress,\n // TODO: Improve typing to ensure data matches MessageTypes\n data as TypedMessage<MessageTypes>,\n {\n version: SignTypedDataVersion.V4,\n },\n );\n }\n\n case `${EthKeyringMethod.Decrypt}`: {\n if (!this.inner.decryptMessage) {\n throw new Error('Keyring does not support decryptMessage');\n }\n assert(params, EthDecryptParamsStruct);\n const [encryptedData] = params;\n return this.inner.decryptMessage(hexAddress, encryptedData);\n }\n\n case `${EthKeyringMethod.GetEncryptionPublicKey}`: {\n if (!this.inner.getEncryptionPublicKey) {\n throw new Error('Keyring does not support getEncryptionPublicKey');\n }\n assert(params, EthGetEncryptionPublicKeyParamsStruct);\n const [, options] = params;\n return this.inner.getEncryptionPublicKey(hexAddress, options);\n }\n\n case `${EthKeyringMethod.GetAppKeyAddress}`: {\n if (!this.inner.getAppKeyAddress) {\n throw new Error('Keyring does not support getAppKeyAddress');\n }\n assert(params, EthGetAppKeyAddressParamsStruct);\n const [origin] = params;\n return this.inner.getAppKeyAddress(hexAddress, origin);\n }\n\n case `${EthKeyringMethod.SignEip7702Authorization}`: {\n if (!this.inner.signEip7702Authorization) {\n throw new Error('Keyring does not support signEip7702Authorization');\n }\n assert(params, EthSignEip7702AuthorizationParamsStruct);\n const [authorization] = params;\n return this.inner.signEip7702Authorization(hexAddress, authorization);\n }\n\n default:\n throw new Error(`Unsupported method for EthKeyringWrapper: ${method}`);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EthKeyring } from "@metamask/keyring-utils";
|
|
2
|
+
import { type Hex, type Json } from "@metamask/utils";
|
|
3
|
+
import type { KeyringAccount } from "../../api/account.cjs";
|
|
4
|
+
import type { KeyringRequest } from "../../api/request.cjs";
|
|
5
|
+
import { KeyringWrapper, type KeyringWrapperOptions } from "../../api/v2/wrapper/keyring-wrapper.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Additional Ethereum methods supported by Eth keyrings that are not in the standard EthMethod enum.
|
|
8
|
+
* These are primarily encryption and utility methods.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum EthKeyringMethod {
|
|
11
|
+
Decrypt = "eth_decrypt",
|
|
12
|
+
GetEncryptionPublicKey = "eth_getEncryptionPublicKey",
|
|
13
|
+
GetAppKeyAddress = "eth_getAppKeyAddress",
|
|
14
|
+
SignEip7702Authorization = "eth_signEip7702Authorization"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for constructing an EthKeyringWrapper.
|
|
18
|
+
*/
|
|
19
|
+
export type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> = KeyringWrapperOptions<InnerKeyring>;
|
|
20
|
+
/**
|
|
21
|
+
* Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements KeyringV2.
|
|
22
|
+
*
|
|
23
|
+
* This class provides common functionality for all Ethereum keyrings including:
|
|
24
|
+
* - Request handling for standard Ethereum signing methods
|
|
25
|
+
* - Helper methods for Hex address conversion
|
|
26
|
+
*
|
|
27
|
+
* Subclasses must implement:
|
|
28
|
+
* - `getAccounts()`: Return all managed accounts
|
|
29
|
+
* - `createAccounts()`: Create new accounts based on options
|
|
30
|
+
* - `deleteAccount()`: Remove an account from the keyring
|
|
31
|
+
* - `exportAccount()` (optional): Export private key in specified format
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class EthKeyringWrapper<InnerKeyring extends EthKeyring, KeyringAccountType extends KeyringAccount = KeyringAccount> extends KeyringWrapper<InnerKeyring, KeyringAccountType> {
|
|
34
|
+
/**
|
|
35
|
+
* Helper method to safely cast a KeyringAccount address to Hex type.
|
|
36
|
+
* The KeyringAccount.address is typed as string, but for Ethereum accounts
|
|
37
|
+
* it should always be a valid Hex address.
|
|
38
|
+
*
|
|
39
|
+
* @param address - The address from a KeyringAccount.
|
|
40
|
+
* @returns The address as Hex type.
|
|
41
|
+
*/
|
|
42
|
+
protected toHexAddress(address: string): Hex;
|
|
43
|
+
/**
|
|
44
|
+
* Handle an Ethereum signing request.
|
|
45
|
+
*
|
|
46
|
+
* Routes the request to the appropriate legacy keyring method based on
|
|
47
|
+
* the RPC method name.
|
|
48
|
+
*
|
|
49
|
+
* @param request - The keyring request containing method and params.
|
|
50
|
+
* @returns The result of the signing operation.
|
|
51
|
+
*/
|
|
52
|
+
submitRequest(request: KeyringRequest): Promise<Json>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=eth-keyring-wrapper.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.d.cts","sourceRoot":"","sources":["../../../src/eth/v2/eth-keyring-wrapper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAE1D,OAAO,EAAS,KAAK,GAAG,EAAE,KAAK,IAAI,EAAE,wBAAwB;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AACxD,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC3B,iDAA6C;AAc9C;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,gBAAgB;IACvB,sBAAsB,+BAA+B;IACrD,gBAAgB,yBAAyB;IACzC,wBAAwB,iCAAiC;CAC1D;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,SAAS,UAAU,IAClE,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,8BAAsB,iBAAiB,CACrC,YAAY,SAAS,UAAU,EAC/B,kBAAkB,SAAS,cAAc,GAAG,cAAc,CAC1D,SAAQ,cAAc,CAAC,YAAY,EAAE,kBAAkB,CAAC;IACxD;;;;;;;OAOG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG;IAI5C;;;;;;;;OAQG;IACG,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAmI5D"}
|