@metamask/keyring-sdk 2.1.1 → 2.3.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/dist/eth/eth-4337-keyring.cjs +3 -0
  3. package/dist/eth/eth-4337-keyring.cjs.map +1 -0
  4. package/dist/eth/eth-4337-keyring.d.cts +35 -0
  5. package/dist/eth/eth-4337-keyring.d.cts.map +1 -0
  6. package/dist/eth/eth-4337-keyring.d.mts +35 -0
  7. package/dist/eth/eth-4337-keyring.d.mts.map +1 -0
  8. package/dist/eth/eth-4337-keyring.mjs +2 -0
  9. package/dist/eth/eth-4337-keyring.mjs.map +1 -0
  10. package/dist/eth/index.cjs.map +1 -1
  11. package/dist/eth/index.d.cts +1 -0
  12. package/dist/eth/index.d.cts.map +1 -1
  13. package/dist/eth/index.d.mts +1 -0
  14. package/dist/eth/index.d.mts.map +1 -1
  15. package/dist/eth/index.mjs.map +1 -1
  16. package/dist/index.cjs +1 -0
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +1 -0
  19. package/dist/index.d.cts.map +1 -1
  20. package/dist/index.d.mts +1 -0
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +1 -0
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/migration.cjs +95 -0
  25. package/dist/migration.cjs.map +1 -0
  26. package/dist/migration.d.cts +124 -0
  27. package/dist/migration.d.cts.map +1 -0
  28. package/dist/migration.d.mts +124 -0
  29. package/dist/migration.d.mts.map +1 -0
  30. package/dist/migration.mjs +90 -0
  31. package/dist/migration.mjs.map +1 -0
  32. package/dist/v2/eth/eth-keyring-v1-adapter.cjs +320 -0
  33. package/dist/v2/eth/eth-keyring-v1-adapter.cjs.map +1 -0
  34. package/dist/v2/eth/eth-keyring-v1-adapter.d.cts +156 -0
  35. package/dist/v2/eth/eth-keyring-v1-adapter.d.cts.map +1 -0
  36. package/dist/v2/eth/eth-keyring-v1-adapter.d.mts +156 -0
  37. package/dist/v2/eth/eth-keyring-v1-adapter.d.mts.map +1 -0
  38. package/dist/v2/eth/eth-keyring-v1-adapter.mjs +314 -0
  39. package/dist/v2/eth/eth-keyring-v1-adapter.mjs.map +1 -0
  40. package/dist/v2/eth/index.cjs +1 -0
  41. package/dist/v2/eth/index.cjs.map +1 -1
  42. package/dist/v2/eth/index.d.cts +1 -0
  43. package/dist/v2/eth/index.d.cts.map +1 -1
  44. package/dist/v2/eth/index.d.mts +1 -0
  45. package/dist/v2/eth/index.d.mts.map +1 -1
  46. package/dist/v2/eth/index.mjs +1 -0
  47. package/dist/v2/eth/index.mjs.map +1 -1
  48. package/dist/v2/keyring-v1-adapter.cjs +5 -19
  49. package/dist/v2/keyring-v1-adapter.cjs.map +1 -1
  50. package/dist/v2/keyring-v1-adapter.d.cts +1 -1
  51. package/dist/v2/keyring-v1-adapter.d.cts.map +1 -1
  52. package/dist/v2/keyring-v1-adapter.d.mts +1 -1
  53. package/dist/v2/keyring-v1-adapter.d.mts.map +1 -1
  54. package/dist/v2/keyring-v1-adapter.mjs +5 -19
  55. package/dist/v2/keyring-v1-adapter.mjs.map +1 -1
  56. package/package.json +4 -4
@@ -0,0 +1,156 @@
1
+ import type { TypedTransaction } from "@ethereumjs/tx";
2
+ import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch, KeyringExecutionContext } from "@metamask/keyring-api";
3
+ import type { Keyring as KeyringV2 } from "@metamask/keyring-api/v2";
4
+ import type { BaseKeyring, EthKeyring } from "@metamask/keyring-utils";
5
+ import type { Hex } from "@metamask/utils";
6
+ import type { Eth4337Keyring } from "../../eth/index.mjs";
7
+ import { KeyringV1Adapter } from "../keyring-v1-adapter.mjs";
8
+ /**
9
+ * Legacy ETH keyring API surface exposed by {@link EthKeyringV1Adapter}.
10
+ */
11
+ export type BaseEthKeyring = BaseKeyring & Pick<EthKeyring, 'exportAccount' | 'signMessage' | 'signEip7702Authorization' | 'signPersonalMessage' | 'signTypedData' | 'signTransaction'> & Eth4337Keyring;
12
+ /**
13
+ * Error thrown when an account cannot be resolved from the requested address.
14
+ */
15
+ export declare class EthKeyringV1AccountNotFoundError extends Error {
16
+ readonly address: string;
17
+ constructor(address: string);
18
+ }
19
+ /**
20
+ * Error thrown when a resolved account does not support a requested method.
21
+ */
22
+ export declare class EthKeyringV1MethodNotSupportedError extends Error {
23
+ readonly address: string;
24
+ readonly method: string;
25
+ constructor(method: string, address: string);
26
+ }
27
+ /**
28
+ * Adapts a `KeyringV2` instance to the subset of the legacy ETH keyring API
29
+ * used by existing ETH export and signing flows.
30
+ *
31
+ * The adapter is account-agnostic: each method resolves the requested address
32
+ * against the wrapped v2 keyring's accounts, verifies that the resolved account
33
+ * supports the requested method, then forwards the request through the v2
34
+ * `submitRequest` or `exportAccount` APIs.
35
+ */
36
+ export declare class EthKeyringV1Adapter<InnerKeyring extends KeyringV2 = KeyringV2> extends KeyringV1Adapter<InnerKeyring> implements BaseEthKeyring {
37
+ #private;
38
+ /**
39
+ * Gets the private data associated with the given address so
40
+ * that it may be exported.
41
+ *
42
+ * Used by the UI to export an account.
43
+ *
44
+ * @param address - Address of the account to export.
45
+ * @returns A promise that resolves to the exported private key.
46
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
47
+ * address.
48
+ */
49
+ exportAccount(address: Hex): Promise<string>;
50
+ /**
51
+ * Sign a transaction.
52
+ *
53
+ * @param address - Sender's address.
54
+ * @param transaction - Transaction.
55
+ * @returns A promise that resolves to the signed transaction.
56
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
57
+ * address.
58
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
59
+ * not support transaction signing.
60
+ */
61
+ signTransaction(address: Hex, transaction: TypedTransaction): Promise<TypedTransaction>;
62
+ /**
63
+ * Sign a message.
64
+ *
65
+ * @param address - Signer's address.
66
+ * @param data - Data to sign.
67
+ * @returns A promise that resolves to the signature.
68
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
69
+ * address.
70
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
71
+ * not support message signing.
72
+ */
73
+ signMessage(address: Hex, data: string): Promise<string>;
74
+ /**
75
+ * Sign an EIP-7702 authorization.
76
+ *
77
+ * @param address - Signer's address.
78
+ * @param authorization - Authorization tuple to sign.
79
+ * @returns A promise that resolves to the signature.
80
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
81
+ * address.
82
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
83
+ * not support EIP-7702 authorization signing.
84
+ */
85
+ signEip7702Authorization(address: Hex, authorization: [chainId: number, contractAddress: Hex, nonce: number]): Promise<string>;
86
+ /**
87
+ * Sign a personal message.
88
+ *
89
+ * Note: KeyringController says this should return a Buffer but it actually
90
+ * expects a string.
91
+ *
92
+ * @param address - Signer's address.
93
+ * @param message - Data to sign.
94
+ * @returns A promise that resolves to the signature.
95
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
96
+ * address.
97
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
98
+ * not support personal message signing.
99
+ */
100
+ signPersonalMessage(address: Hex, message: Hex): Promise<string>;
101
+ /**
102
+ * Sign a typed data message.
103
+ *
104
+ * @param address - Signer's address.
105
+ * @param typedData - Typed data to sign.
106
+ * @param options - Signing options.
107
+ * @param options.version - The typed data version to use.
108
+ * @returns A promise that resolves to the signature.
109
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
110
+ * address.
111
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
112
+ * not support the requested typed data signing method.
113
+ */
114
+ signTypedData(address: Hex, typedData: unknown[] | Record<string, unknown>, options?: Record<string, unknown>): Promise<string>;
115
+ /**
116
+ * Convert base transactions to a base UserOperation.
117
+ *
118
+ * @param address - Address of the sender.
119
+ * @param transactions - Base transactions to include in the UserOperation.
120
+ * @param context - Keyring execution context.
121
+ * @returns A pseudo-UserOperation that can be used to construct a real one.
122
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
123
+ * address.
124
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
125
+ * not support UserOperation preparation.
126
+ */
127
+ prepareUserOperation(address: string, transactions: EthBaseTransaction[], context: KeyringExecutionContext): Promise<EthBaseUserOperation>;
128
+ /**
129
+ * Patches properties of a UserOperation. Currently, only the
130
+ * `paymasterAndData` can be patched.
131
+ *
132
+ * @param address - Address of the sender.
133
+ * @param userOperation - UserOperation to patch.
134
+ * @param context - Keyring execution context.
135
+ * @returns A patch to apply to the UserOperation.
136
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
137
+ * address.
138
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
139
+ * not support UserOperation patching.
140
+ */
141
+ patchUserOperation(address: string, userOperation: EthUserOperation, context: KeyringExecutionContext): Promise<EthUserOperationPatch>;
142
+ /**
143
+ * Signs a UserOperation.
144
+ *
145
+ * @param address - Address of the sender.
146
+ * @param userOperation - UserOperation to sign.
147
+ * @param context - Keyring execution context.
148
+ * @returns The signature of the UserOperation.
149
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
150
+ * address.
151
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
152
+ * not support UserOperation signing.
153
+ */
154
+ signUserOperation(address: string, userOperation: EthUserOperation, context: KeyringExecutionContext): Promise<string>;
155
+ }
156
+ //# sourceMappingURL=eth-keyring-v1-adapter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eth-keyring-v1-adapter.d.mts","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-v1-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB;AAWvD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EAErB,uBAAuB,EAExB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,O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AAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GACpE,OAAO,CAAC,MAAM,CAAC;IAmBlB;;;;;;;;;;;;;OAaG;IACG,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBtE;;;;;;;;;;;;OAYG;IACG,aAAa,CACjB,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC;IAuBlB;;;;;;;;;;;OAWG;IACG,oBAAoB,CACxB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,oBAAoB,CAAC;IAuBhC;;;;;;;;;;;;OAYG;IACG,kBAAkB,CACtB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,gBAAgB,EAC/B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IAiBjC;;;;;;;;;;;OAWG;IACG,iBAAiB,CACrB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,gBAAgB,EAC/B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC;CAuFnB"}
@@ -0,0 +1,314 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _EthKeyringV1Adapter_instances, _EthKeyringV1Adapter_getAccount, _EthKeyringV1Adapter_getAccountForMethod, _EthKeyringV1Adapter_getSignTypedDataMethod, _EthKeyringV1Adapter_submitRequest;
7
+ import { TransactionFactory } from "@ethereumjs/tx";
8
+ import { normalize as ethNormalize } from "@metamask/eth-sig-util";
9
+ import { EthBaseUserOperationStruct, EthBytesStrictStruct, EthBytesStruct, EthMethod, EthUserOperationPatchStruct } from "@metamask/keyring-api";
10
+ import { AccountExportType, PrivateKeyEncoding } from "@metamask/keyring-api/v2";
11
+ import { strictMask } from "@metamask/keyring-utils";
12
+ import { mask, object } from "@metamask/superstruct";
13
+ import { bigIntToHex, KnownCaipNamespace, remove0x, toCaipChainId } from "@metamask/utils";
14
+ import { v4 as uuid } from "uuid";
15
+ import { KeyringV1Adapter } from "../keyring-v1-adapter.mjs";
16
+ import { EthKeyringMethod } from "./eth-keyring-wrapper.mjs";
17
+ const METAMASK_ORIGIN = 'metamask';
18
+ /**
19
+ * Convert a value to a valid JSON object.
20
+ *
21
+ * The function chains JSON.stringify and JSON.parse to ensure that the result
22
+ * is a valid JSON object.
23
+ *
24
+ * We assume that the input value is JSON-serializable.
25
+ *
26
+ * However, some transformations can occur like: in objects, undefined values
27
+ * are removed, and in arrays, they are replaced with null.
28
+ *
29
+ * @param value - Value to convert to JSON - Assumed to be JSON-serializable.
30
+ * @returns JSON representation of the value.
31
+ */
32
+ function toJson(value) {
33
+ return JSON.parse(JSON.stringify(value));
34
+ }
35
+ /**
36
+ * Convert a chain ID (number or hex) to an EIP-155 CAIP chain ID string for keyring request scoping.
37
+ *
38
+ * @param chainId - The chain ID to convert.
39
+ * @returns The EIP-155 CAIP chain ID string.
40
+ */
41
+ function toEip155Scope(chainId) {
42
+ return toCaipChainId(KnownCaipNamespace.Eip155, BigInt(chainId).toString());
43
+ }
44
+ /**
45
+ * Error thrown when an account cannot be resolved from the requested address.
46
+ */
47
+ export class EthKeyringV1AccountNotFoundError extends Error {
48
+ constructor(address) {
49
+ super(`Account not found for address: ${address}`);
50
+ this.name = 'EthKeyringV1AccountNotFoundError';
51
+ this.address = address;
52
+ Object.setPrototypeOf(this, EthKeyringV1AccountNotFoundError.prototype);
53
+ }
54
+ }
55
+ /**
56
+ * Error thrown when a resolved account does not support a requested method.
57
+ */
58
+ export class EthKeyringV1MethodNotSupportedError extends Error {
59
+ constructor(method, address) {
60
+ super(`Account ${address} does not support method: ${method}`);
61
+ this.name = 'EthKeyringV1MethodNotSupportedError';
62
+ this.address = address;
63
+ this.method = method;
64
+ Object.setPrototypeOf(this, EthKeyringV1MethodNotSupportedError.prototype);
65
+ }
66
+ }
67
+ /**
68
+ * Adapts a `KeyringV2` instance to the subset of the legacy ETH keyring API
69
+ * used by existing ETH export and signing flows.
70
+ *
71
+ * The adapter is account-agnostic: each method resolves the requested address
72
+ * against the wrapped v2 keyring's accounts, verifies that the resolved account
73
+ * supports the requested method, then forwards the request through the v2
74
+ * `submitRequest` or `exportAccount` APIs.
75
+ */
76
+ export class EthKeyringV1Adapter extends KeyringV1Adapter {
77
+ constructor() {
78
+ super(...arguments);
79
+ _EthKeyringV1Adapter_instances.add(this);
80
+ }
81
+ /**
82
+ * Gets the private data associated with the given address so
83
+ * that it may be exported.
84
+ *
85
+ * Used by the UI to export an account.
86
+ *
87
+ * @param address - Address of the account to export.
88
+ * @returns A promise that resolves to the exported private key.
89
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
90
+ * address.
91
+ */
92
+ async exportAccount(address) {
93
+ const { account } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccount).call(this, address);
94
+ if (!this.inner.exportAccount) {
95
+ throw new Error('Keyring does not support exportAccount');
96
+ }
97
+ const exportedAccount = await this.inner.exportAccount(account.id, {
98
+ type: AccountExportType.PrivateKey,
99
+ encoding: PrivateKeyEncoding.Hexadecimal,
100
+ });
101
+ return remove0x(exportedAccount.privateKey);
102
+ }
103
+ /**
104
+ * Sign a transaction.
105
+ *
106
+ * @param address - Sender's address.
107
+ * @param transaction - Transaction.
108
+ * @returns A promise that resolves to the signed transaction.
109
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
110
+ * address.
111
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
112
+ * not support transaction signing.
113
+ */
114
+ async signTransaction(address, transaction) {
115
+ const { account, normalizedAddress } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.SignTransaction);
116
+ const chainId = transaction.common.chainId();
117
+ const tx = toJson({
118
+ ...transaction.toJSON(),
119
+ from: normalizedAddress,
120
+ type: `0x${transaction.type.toString(16)}`,
121
+ chainId: bigIntToHex(chainId),
122
+ });
123
+ const signedTx = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.SignTransaction, toJson([tx]), toEip155Scope(chainId));
124
+ // Only take the signature fields from the keyring response. This prevents
125
+ // the keyring from overwriting the transaction payload we submitted.
126
+ const signature = mask(signedTx, object({
127
+ r: EthBytesStrictStruct,
128
+ s: EthBytesStrictStruct,
129
+ v: EthBytesStrictStruct,
130
+ }));
131
+ return TransactionFactory.fromTxData({
132
+ ...tx,
133
+ r: signature.r,
134
+ s: signature.s,
135
+ v: signature.v,
136
+ });
137
+ }
138
+ /**
139
+ * Sign a message.
140
+ *
141
+ * @param address - Signer's address.
142
+ * @param data - Data to sign.
143
+ * @returns A promise that resolves to the signature.
144
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
145
+ * address.
146
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
147
+ * not support message signing.
148
+ */
149
+ async signMessage(address, data) {
150
+ const { account, normalizedAddress } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.Sign);
151
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.Sign, toJson([normalizedAddress, data]), ''), EthBytesStruct);
152
+ }
153
+ /**
154
+ * Sign an EIP-7702 authorization.
155
+ *
156
+ * @param address - Signer's address.
157
+ * @param authorization - Authorization tuple to sign.
158
+ * @returns A promise that resolves to the signature.
159
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
160
+ * address.
161
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
162
+ * not support EIP-7702 authorization signing.
163
+ */
164
+ async signEip7702Authorization(address, authorization) {
165
+ const { account } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthKeyringMethod.SignEip7702Authorization);
166
+ const [chainId] = authorization;
167
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthKeyringMethod.SignEip7702Authorization, [authorization], toEip155Scope(chainId)), EthBytesStruct);
168
+ }
169
+ /**
170
+ * Sign a personal message.
171
+ *
172
+ * Note: KeyringController says this should return a Buffer but it actually
173
+ * expects a string.
174
+ *
175
+ * @param address - Signer's address.
176
+ * @param message - Data to sign.
177
+ * @returns A promise that resolves to the signature.
178
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
179
+ * address.
180
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
181
+ * not support personal message signing.
182
+ */
183
+ async signPersonalMessage(address, message) {
184
+ const { account, normalizedAddress } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.PersonalSign);
185
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.PersonalSign, toJson([message, normalizedAddress]), ''), EthBytesStruct);
186
+ }
187
+ /**
188
+ * Sign a typed data message.
189
+ *
190
+ * @param address - Signer's address.
191
+ * @param typedData - Typed data to sign.
192
+ * @param options - Signing options.
193
+ * @param options.version - The typed data version to use.
194
+ * @returns A promise that resolves to the signature.
195
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
196
+ * address.
197
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
198
+ * not support the requested typed data signing method.
199
+ */
200
+ async signTypedData(address, typedData, options) {
201
+ const version = options?.version;
202
+ const method = __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getSignTypedDataMethod).call(this, version);
203
+ const { account, normalizedAddress } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, method);
204
+ // Extract chain ID as if it was a typed message (as defined by EIP-712), if
205
+ // input is not a typed message, then chain ID will be undefined!
206
+ const chainId = typedData.domain?.chainId;
207
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, method, toJson([normalizedAddress, typedData]), chainId === undefined ? '' : toEip155Scope(chainId)), EthBytesStruct);
208
+ }
209
+ /**
210
+ * Convert base transactions to a base UserOperation.
211
+ *
212
+ * @param address - Address of the sender.
213
+ * @param transactions - Base transactions to include in the UserOperation.
214
+ * @param context - Keyring execution context.
215
+ * @returns A pseudo-UserOperation that can be used to construct a real one.
216
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
217
+ * address.
218
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
219
+ * not support UserOperation preparation.
220
+ */
221
+ async prepareUserOperation(address, transactions, context) {
222
+ const { account } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.PrepareUserOperation);
223
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.PrepareUserOperation,
224
+ // NOTE: This is inconsistent with the other methods. We are not wrapping `transactions` in an array.
225
+ // Which means the receiver of the `submitRequest` call would see individual transactions spread as
226
+ // separate params rather than a single transactions array as the first param, which doesn't match
227
+ // the method signature of `prepareUserOperation(address, transactions, context)`.
228
+ // This was already implemented like this in the legacy Snap keyring, so we keep the same logic here
229
+ // too!
230
+ toJson(transactions), toEip155Scope(context.chainId)), EthBaseUserOperationStruct);
231
+ }
232
+ /**
233
+ * Patches properties of a UserOperation. Currently, only the
234
+ * `paymasterAndData` can be patched.
235
+ *
236
+ * @param address - Address of the sender.
237
+ * @param userOperation - UserOperation to patch.
238
+ * @param context - Keyring execution context.
239
+ * @returns A patch to apply to the UserOperation.
240
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
241
+ * address.
242
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
243
+ * not support UserOperation patching.
244
+ */
245
+ async patchUserOperation(address, userOperation, context) {
246
+ const { account } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.PatchUserOperation);
247
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.PatchUserOperation, toJson([userOperation]), toEip155Scope(context.chainId)), EthUserOperationPatchStruct);
248
+ }
249
+ /**
250
+ * Signs a UserOperation.
251
+ *
252
+ * @param address - Address of the sender.
253
+ * @param userOperation - UserOperation to sign.
254
+ * @param context - Keyring execution context.
255
+ * @returns The signature of the UserOperation.
256
+ * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the
257
+ * address.
258
+ * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does
259
+ * not support UserOperation signing.
260
+ */
261
+ async signUserOperation(address, userOperation, context) {
262
+ const { account } = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccountForMethod).call(this, address, EthMethod.SignUserOperation);
263
+ return strictMask(await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_submitRequest).call(this, account, EthMethod.SignUserOperation, toJson([userOperation]), toEip155Scope(context.chainId)), EthBytesStruct);
264
+ }
265
+ }
266
+ _EthKeyringV1Adapter_instances = new WeakSet(), _EthKeyringV1Adapter_getAccount = async function _EthKeyringV1Adapter_getAccount(address) {
267
+ const normalizedAddress = ethNormalize(address);
268
+ const normalizedAddressLowerCase = normalizedAddress?.toLowerCase();
269
+ if (!normalizedAddress || !normalizedAddressLowerCase) {
270
+ throw new EthKeyringV1AccountNotFoundError(address);
271
+ }
272
+ const accounts = await this.inner.getAccounts();
273
+ const account = accounts.find((keyringAccount) => {
274
+ const accountAddress = ethNormalize(keyringAccount.address);
275
+ return accountAddress?.toLowerCase() === normalizedAddressLowerCase;
276
+ });
277
+ if (!account) {
278
+ throw new EthKeyringV1AccountNotFoundError(address);
279
+ }
280
+ return {
281
+ account,
282
+ normalizedAddress: normalizedAddress,
283
+ };
284
+ }, _EthKeyringV1Adapter_getAccountForMethod = async function _EthKeyringV1Adapter_getAccountForMethod(address, method) {
285
+ const resolvedAccount = await __classPrivateFieldGet(this, _EthKeyringV1Adapter_instances, "m", _EthKeyringV1Adapter_getAccount).call(this, address);
286
+ if (!resolvedAccount.account.methods.includes(method)) {
287
+ throw new EthKeyringV1MethodNotSupportedError(method, address);
288
+ }
289
+ return resolvedAccount;
290
+ }, _EthKeyringV1Adapter_getSignTypedDataMethod = function _EthKeyringV1Adapter_getSignTypedDataMethod(version) {
291
+ switch (version) {
292
+ case 'V3':
293
+ return EthMethod.SignTypedDataV3;
294
+ case 'V4':
295
+ return EthMethod.SignTypedDataV4;
296
+ case 'V1':
297
+ default:
298
+ // Use 'V1' by default to match other keyring implementations. V1 will be
299
+ // used if the version is not specified or not supported.
300
+ return EthMethod.SignTypedDataV1;
301
+ }
302
+ }, _EthKeyringV1Adapter_submitRequest = async function _EthKeyringV1Adapter_submitRequest(account, method, params, scope) {
303
+ return (await this.inner.submitRequest({
304
+ id: uuid(),
305
+ origin: METAMASK_ORIGIN,
306
+ scope,
307
+ account: account.id,
308
+ request: {
309
+ method,
310
+ params,
311
+ },
312
+ }));
313
+ };
314
+ //# sourceMappingURL=eth-keyring-v1-adapter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eth-keyring-v1-adapter.mjs","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-v1-adapter.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB;AAEpD,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,+BAA+B;AACnE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,2BAA2B,EAC5B,8BAA8B;AAW/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EACnB,iCAAiC;AAElC,OAAO,EAAE,UAAU,EAAE,gCAAgC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,8BAA8B;AAErD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACd,wBAAwB;AACzB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAGlC,OAAO,EAAE,gBAAgB,EAAE,kCAA8B;AACzD,OAAO,EAAE,gBAAgB,EAAE,kCAA8B;AAEzD,MAAM,eAAe,GAAG,UAAU,CAAC;AAenC;;;;;;;;;;;;;GAaG;AACH,SAAS,MAAM,CAA2B,KAAc;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAS,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,OAAiC;IACtD,OAAO,aAAa,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9E,CAAC;AAkBD;;GAEG;AACH,MAAM,OAAO,gCA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ction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport { normalize as ethNormalize } from '@metamask/eth-sig-util';\nimport {\n EthBaseUserOperationStruct,\n EthBytesStrictStruct,\n EthBytesStruct,\n EthMethod,\n EthUserOperationPatchStruct,\n} from '@metamask/keyring-api';\nimport type {\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n KeyringAccount,\n KeyringExecutionContext,\n KeyringRequest,\n} from '@metamask/keyring-api';\nimport type { Keyring as KeyringV2 } from '@metamask/keyring-api/v2';\nimport {\n AccountExportType,\n PrivateKeyEncoding,\n} from '@metamask/keyring-api/v2';\nimport type { BaseKeyring, EthKeyring } from '@metamask/keyring-utils';\nimport { strictMask } from '@metamask/keyring-utils';\nimport { mask, object } from '@metamask/superstruct';\nimport type { Hex, Json } from '@metamask/utils';\nimport {\n bigIntToHex,\n KnownCaipNamespace,\n remove0x,\n toCaipChainId,\n} from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type { Eth4337Keyring } from '../../eth';\nimport { KeyringV1Adapter } from '../keyring-v1-adapter';\nimport { EthKeyringMethod } from './eth-keyring-wrapper';\n\nconst METAMASK_ORIGIN = 'metamask';\n\ntype RequestParams = NonNullable<KeyringRequest['request']['params']>;\n\ntype ResolvedAccount = {\n account: KeyringAccount;\n normalizedAddress: Hex;\n};\n\ntype TypedDataWithDomain = {\n domain?: {\n chainId?: string | number;\n };\n};\n\n/**\n * Convert a value to a valid JSON object.\n *\n * The function chains JSON.stringify and JSON.parse to ensure that the result\n * is a valid JSON object.\n *\n * We assume that the input value is JSON-serializable.\n *\n * However, some transformations can occur like: in objects, undefined values\n * are removed, and in arrays, they are replaced with null.\n *\n * @param value - Value to convert to JSON - Assumed to be JSON-serializable.\n * @returns JSON representation of the value.\n */\nfunction toJson<Type extends Json = Json>(value: unknown): Type {\n return JSON.parse(JSON.stringify(value)) as Type;\n}\n\n/**\n * Convert a chain ID (number or hex) to an EIP-155 CAIP chain ID string for keyring request scoping.\n *\n * @param chainId - The chain ID to convert.\n * @returns The EIP-155 CAIP chain ID string.\n */\nfunction toEip155Scope(chainId: string | number | bigint): string {\n return toCaipChainId(KnownCaipNamespace.Eip155, BigInt(chainId).toString());\n}\n\n/**\n * Legacy ETH keyring API surface exposed by {@link EthKeyringV1Adapter}.\n */\nexport type BaseEthKeyring = BaseKeyring &\n // Only pick account-related methods (signing and exporting).\n Pick<\n EthKeyring,\n | 'exportAccount'\n | 'signMessage'\n | 'signEip7702Authorization'\n | 'signPersonalMessage'\n | 'signTypedData'\n | 'signTransaction'\n > &\n Eth4337Keyring;\n\n/**\n * Error thrown when an account cannot be resolved from the requested address.\n */\nexport class EthKeyringV1AccountNotFoundError extends Error {\n readonly address: string;\n\n constructor(address: string) {\n super(`Account not found for address: ${address}`);\n this.name = 'EthKeyringV1AccountNotFoundError';\n this.address = address;\n Object.setPrototypeOf(this, EthKeyringV1AccountNotFoundError.prototype);\n }\n}\n\n/**\n * Error thrown when a resolved account does not support a requested method.\n */\nexport class EthKeyringV1MethodNotSupportedError extends Error {\n readonly address: string;\n\n readonly method: string;\n\n constructor(method: string, address: string) {\n super(`Account ${address} does not support method: ${method}`);\n this.name = 'EthKeyringV1MethodNotSupportedError';\n this.address = address;\n this.method = method;\n Object.setPrototypeOf(this, EthKeyringV1MethodNotSupportedError.prototype);\n }\n}\n\n/**\n * Adapts a `KeyringV2` instance to the subset of the legacy ETH keyring API\n * used by existing ETH export and signing flows.\n *\n * The adapter is account-agnostic: each method resolves the requested address\n * against the wrapped v2 keyring's accounts, verifies that the resolved account\n * supports the requested method, then forwards the request through the v2\n * `submitRequest` or `exportAccount` APIs.\n */\nexport class EthKeyringV1Adapter<InnerKeyring extends KeyringV2 = KeyringV2>\n extends KeyringV1Adapter<InnerKeyring>\n implements BaseEthKeyring\n{\n /**\n * Gets the private data associated with the given address so\n * that it may be exported.\n *\n * Used by the UI to export an account.\n *\n * @param address - Address of the account to export.\n * @returns A promise that resolves to the exported private key.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n */\n async exportAccount(address: Hex): Promise<string> {\n const { account } = await this.#getAccount(address);\n\n if (!this.inner.exportAccount) {\n throw new Error('Keyring does not support exportAccount');\n }\n\n const exportedAccount = await this.inner.exportAccount(account.id, {\n type: AccountExportType.PrivateKey,\n encoding: PrivateKeyEncoding.Hexadecimal,\n });\n\n return remove0x(exportedAccount.privateKey);\n }\n\n /**\n * Sign a transaction.\n *\n * @param address - Sender's address.\n * @param transaction - Transaction.\n * @returns A promise that resolves to the signed transaction.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support transaction signing.\n */\n async signTransaction(\n address: Hex,\n transaction: TypedTransaction,\n ): Promise<TypedTransaction> {\n const { account, normalizedAddress } = await this.#getAccountForMethod(\n address,\n EthMethod.SignTransaction,\n );\n\n const chainId = transaction.common.chainId();\n const tx = toJson({\n ...transaction.toJSON(),\n from: normalizedAddress,\n type: `0x${transaction.type.toString(16)}`,\n chainId: bigIntToHex(chainId),\n });\n\n const signedTx = await this.#submitRequest(\n account,\n EthMethod.SignTransaction,\n toJson<Json[]>([tx]),\n toEip155Scope(chainId),\n );\n\n // Only take the signature fields from the keyring response. This prevents\n // the keyring from overwriting the transaction payload we submitted.\n const signature = mask(\n signedTx,\n object({\n r: EthBytesStrictStruct,\n s: EthBytesStrictStruct,\n v: EthBytesStrictStruct,\n }),\n );\n\n return TransactionFactory.fromTxData({\n ...(tx as Record<string, Json>),\n r: signature.r,\n s: signature.s,\n v: signature.v,\n });\n }\n\n /**\n * Sign a message.\n *\n * @param address - Signer's address.\n * @param data - Data to sign.\n * @returns A promise that resolves to the signature.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support message signing.\n */\n async signMessage(address: Hex, data: string): Promise<string> {\n const { account, normalizedAddress } = await this.#getAccountForMethod(\n address,\n EthMethod.Sign,\n );\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthMethod.Sign,\n toJson<Json[]>([normalizedAddress, data]),\n '',\n ),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign an EIP-7702 authorization.\n *\n * @param address - Signer's address.\n * @param authorization - Authorization tuple to sign.\n * @returns A promise that resolves to the signature.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support EIP-7702 authorization signing.\n */\n async signEip7702Authorization(\n address: Hex,\n authorization: [chainId: number, contractAddress: Hex, nonce: number],\n ): Promise<string> {\n const { account } = await this.#getAccountForMethod(\n address,\n EthKeyringMethod.SignEip7702Authorization,\n );\n\n const [chainId] = authorization;\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthKeyringMethod.SignEip7702Authorization,\n [authorization],\n toEip155Scope(chainId),\n ),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a personal message.\n *\n * Note: KeyringController says this should return a Buffer but it actually\n * expects a string.\n *\n * @param address - Signer's address.\n * @param message - Data to sign.\n * @returns A promise that resolves to the signature.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support personal message signing.\n */\n async signPersonalMessage(address: Hex, message: Hex): Promise<string> {\n const { account, normalizedAddress } = await this.#getAccountForMethod(\n address,\n EthMethod.PersonalSign,\n );\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthMethod.PersonalSign,\n toJson<Json[]>([message, normalizedAddress]),\n '',\n ),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a typed data message.\n *\n * @param address - Signer's address.\n * @param typedData - Typed data to sign.\n * @param options - Signing options.\n * @param options.version - The typed data version to use.\n * @returns A promise that resolves to the signature.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support the requested typed data signing method.\n */\n async signTypedData(\n address: Hex,\n typedData: unknown[] | Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<string> {\n const version = options?.version as SignTypedDataVersion | undefined;\n const method = this.#getSignTypedDataMethod(version);\n const { account, normalizedAddress } = await this.#getAccountForMethod(\n address,\n method,\n );\n\n // Extract chain ID as if it was a typed message (as defined by EIP-712), if\n // input is not a typed message, then chain ID will be undefined!\n const chainId = (typedData as TypedDataWithDomain).domain?.chainId;\n\n return strictMask(\n await this.#submitRequest(\n account,\n method,\n toJson<Json[]>([normalizedAddress, typedData]),\n chainId === undefined ? '' : toEip155Scope(chainId),\n ),\n EthBytesStruct,\n );\n }\n\n /**\n * Convert base transactions to a base UserOperation.\n *\n * @param address - Address of the sender.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real one.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support UserOperation preparation.\n */\n async prepareUserOperation(\n address: string,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation> {\n const { account } = await this.#getAccountForMethod(\n address,\n EthMethod.PrepareUserOperation,\n );\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthMethod.PrepareUserOperation,\n // NOTE: This is inconsistent with the other methods. We are not wrapping `transactions` in an array.\n // Which means the receiver of the `submitRequest` call would see individual transactions spread as\n // separate params rather than a single transactions array as the first param, which doesn't match\n // the method signature of `prepareUserOperation(address, transactions, context)`.\n // This was already implemented like this in the legacy Snap keyring, so we keep the same logic here\n // too!\n toJson<Json[]>(transactions),\n toEip155Scope(context.chainId),\n ),\n EthBaseUserOperationStruct,\n );\n }\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param address - Address of the sender.\n * @param userOperation - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support UserOperation patching.\n */\n async patchUserOperation(\n address: string,\n userOperation: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch> {\n const { account } = await this.#getAccountForMethod(\n address,\n EthMethod.PatchUserOperation,\n );\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthMethod.PatchUserOperation,\n toJson<Json[]>([userOperation]),\n toEip155Scope(context.chainId),\n ),\n EthUserOperationPatchStruct,\n );\n }\n\n /**\n * Signs a UserOperation.\n *\n * @param address - Address of the sender.\n * @param userOperation - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns The signature of the UserOperation.\n * @throws {@link EthKeyringV1AccountNotFoundError} if no account matches the\n * address.\n * @throws {@link EthKeyringV1MethodNotSupportedError} if the account does\n * not support UserOperation signing.\n */\n async signUserOperation(\n address: string,\n userOperation: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string> {\n const { account } = await this.#getAccountForMethod(\n address,\n EthMethod.SignUserOperation,\n );\n\n return strictMask(\n await this.#submitRequest(\n account,\n EthMethod.SignUserOperation,\n toJson<Json[]>([userOperation]),\n toEip155Scope(context.chainId),\n ),\n EthBytesStruct,\n );\n }\n\n async #getAccount(address: string): Promise<ResolvedAccount> {\n const normalizedAddress = ethNormalize(address);\n const normalizedAddressLowerCase = normalizedAddress?.toLowerCase();\n\n if (!normalizedAddress || !normalizedAddressLowerCase) {\n throw new EthKeyringV1AccountNotFoundError(address);\n }\n\n const accounts = await this.inner.getAccounts();\n const account = accounts.find((keyringAccount) => {\n const accountAddress = ethNormalize(keyringAccount.address);\n return accountAddress?.toLowerCase() === normalizedAddressLowerCase;\n });\n\n if (!account) {\n throw new EthKeyringV1AccountNotFoundError(address);\n }\n\n return {\n account,\n normalizedAddress: normalizedAddress as Hex,\n };\n }\n\n async #getAccountForMethod(\n address: string,\n method: string,\n ): Promise<ResolvedAccount> {\n const resolvedAccount = await this.#getAccount(address);\n\n if (!resolvedAccount.account.methods.includes(method)) {\n throw new EthKeyringV1MethodNotSupportedError(method, address);\n }\n\n return resolvedAccount;\n }\n\n #getSignTypedDataMethod(\n version: SignTypedDataVersion | undefined,\n ): EthMethod {\n switch (version) {\n case 'V3':\n return EthMethod.SignTypedDataV3;\n case 'V4':\n return EthMethod.SignTypedDataV4;\n case 'V1':\n default:\n // Use 'V1' by default to match other keyring implementations. V1 will be\n // used if the version is not specified or not supported.\n return EthMethod.SignTypedDataV1;\n }\n }\n\n async #submitRequest<Result extends Json = Json>(\n account: KeyringAccount,\n method: string,\n params: RequestParams,\n scope: string,\n ): Promise<Result> {\n return (await this.inner.submitRequest({\n id: uuid(),\n origin: METAMASK_ORIGIN,\n scope,\n account: account.id,\n request: {\n method,\n params,\n },\n })) as Result;\n }\n}\n"]}
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./eth-keyring-v1-adapter.cjs"), exports);
17
18
  __exportStar(require("./eth-keyring-wrapper.cjs"), exports);
18
19
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAsC","sourcesContent":["export * from './eth-keyring-wrapper';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAAyC;AACzC,4DAAsC","sourcesContent":["export * from './eth-keyring-v1-adapter';\nexport * from './eth-keyring-wrapper';\n"]}
@@ -1,2 +1,3 @@
1
+ export * from "./eth-keyring-v1-adapter.cjs";
1
2
  export * from "./eth-keyring-wrapper.cjs";
2
3
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,0CAAsC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,6CAAyC;AACzC,0CAAsC"}
@@ -1,2 +1,3 @@
1
+ export * from "./eth-keyring-v1-adapter.mjs";
1
2
  export * from "./eth-keyring-wrapper.mjs";
2
3
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,0CAAsC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,6CAAyC;AACzC,0CAAsC"}
@@ -1,2 +1,3 @@
1
+ export * from "./eth-keyring-v1-adapter.mjs";
1
2
  export * from "./eth-keyring-wrapper.mjs";
2
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,0CAAsC","sourcesContent":["export * from './eth-keyring-wrapper';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/v2/eth/index.ts"],"names":[],"mappings":"AAAA,6CAAyC;AACzC,0CAAsC","sourcesContent":["export * from './eth-keyring-v1-adapter';\nexport * from './eth-keyring-wrapper';\n"]}
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _KeyringV1Adapter_inner;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.KeyringV1Adapter = void 0;
16
4
  /**
@@ -44,8 +32,7 @@ exports.KeyringV1Adapter = void 0;
44
32
  */
45
33
  class KeyringV1Adapter {
46
34
  constructor(inner) {
47
- _KeyringV1Adapter_inner.set(this, void 0);
48
- __classPrivateFieldSet(this, _KeyringV1Adapter_inner, inner, "f");
35
+ this.inner = inner;
49
36
  this.type = inner.type;
50
37
  }
51
38
  /**
@@ -57,7 +44,7 @@ class KeyringV1Adapter {
57
44
  * @returns The inner v2 keyring instance.
58
45
  */
59
46
  unwrap() {
60
- return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f");
47
+ return this.inner;
61
48
  }
62
49
  /**
63
50
  * Returns the addresses of all accounts in this keyring.
@@ -68,7 +55,7 @@ class KeyringV1Adapter {
68
55
  * @returns A promise resolving to the list of account addresses.
69
56
  */
70
57
  async getAccounts() {
71
- const accounts = await __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").getAccounts();
58
+ const accounts = await this.inner.getAccounts();
72
59
  return accounts.map((account) => account.address);
73
60
  }
74
61
  /**
@@ -79,7 +66,7 @@ class KeyringV1Adapter {
79
66
  * @returns A promise resolving to the serialized state.
80
67
  */
81
68
  async serialize() {
82
- return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").serialize();
69
+ return this.inner.serialize();
83
70
  }
84
71
  /**
85
72
  * Restores keyring state from a serialized snapshot.
@@ -90,9 +77,8 @@ class KeyringV1Adapter {
90
77
  * @returns A promise that resolves when deserialization is complete.
91
78
  */
92
79
  async deserialize(state) {
93
- return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").deserialize(state);
80
+ return this.inner.deserialize(state);
94
81
  }
95
82
  }
96
83
  exports.KeyringV1Adapter = KeyringV1Adapter;
97
- _KeyringV1Adapter_inner = new WeakMap();
98
84
  //# sourceMappingURL=keyring-v1-adapter.cjs.map