@metamask/keyring-sdk 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -1
- package/dist/eth/account-id.cjs +2 -1
- package/dist/eth/account-id.cjs.map +1 -1
- package/dist/mnemonic.cjs +2 -1
- package/dist/mnemonic.cjs.map +1 -1
- package/dist/v2/eth/eth-keyring-wrapper.cjs.map +1 -1
- package/dist/v2/eth/eth-keyring-wrapper.d.cts +3 -2
- package/dist/v2/eth/eth-keyring-wrapper.d.cts.map +1 -1
- package/dist/v2/eth/eth-keyring-wrapper.d.mts +3 -2
- package/dist/v2/eth/eth-keyring-wrapper.d.mts.map +1 -1
- package/dist/v2/eth/eth-keyring-wrapper.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -0
- package/dist/v2/index.cjs.map +1 -1
- package/dist/v2/index.d.cts +1 -0
- package/dist/v2/index.d.cts.map +1 -1
- package/dist/v2/index.d.mts +1 -0
- package/dist/v2/index.d.mts.map +1 -1
- package/dist/v2/index.mjs +1 -0
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/keyring-v1-adapter.cjs +98 -0
- package/dist/v2/keyring-v1-adapter.cjs.map +1 -0
- package/dist/v2/keyring-v1-adapter.d.cts +76 -0
- package/dist/v2/keyring-v1-adapter.d.cts.map +1 -0
- package/dist/v2/keyring-v1-adapter.d.mts +76 -0
- package/dist/v2/keyring-v1-adapter.d.mts.map +1 -0
- package/dist/v2/keyring-v1-adapter.mjs +94 -0
- package/dist/v2/keyring-v1-adapter.mjs.map +1 -0
- package/dist/v2/keyring-wrapper.cjs.map +1 -1
- package/dist/v2/keyring-wrapper.d.cts +2 -1
- package/dist/v2/keyring-wrapper.d.cts.map +1 -1
- package/dist/v2/keyring-wrapper.d.mts +2 -1
- package/dist/v2/keyring-wrapper.d.mts.map +1 -1
- package/dist/v2/keyring-wrapper.mjs.map +1 -1
- package/package.json +24 -24
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `KeyringV1Adapter` ([#543](https://github.com/MetaMask/accounts/pull/543))
|
|
15
|
+
- This adapter can be used when a keyring v2 instance has no v1 equivalent (`KeyringController` still rely on v1 logic for its vault/state management).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Bump `@metamask/keyring-utils` from `^3.2.0` to `^3.3.0` ([#544](https://github.com/MetaMask/accounts/pull/544))
|
|
20
|
+
|
|
21
|
+
## [2.0.2]
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Bump `@metamask/keyring-api` from `^23.0.1` to `^23.1.0` ([#538](https://github.com/MetaMask/accounts/pull/538))
|
|
26
|
+
|
|
10
27
|
## [2.0.1]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -55,7 +72,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
55
72
|
|
|
56
73
|
- Initial release, extracted from `@metamask/keyring-api` ([#478](https://github.com/MetaMask/accounts/pull/478)), ([#482](https://github.com/MetaMask/accounts/pull/482))
|
|
57
74
|
|
|
58
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@2.0
|
|
75
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@2.1.0...HEAD
|
|
76
|
+
[2.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@2.0.2...@metamask/keyring-sdk@2.1.0
|
|
77
|
+
[2.0.2]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@2.0.1...@metamask/keyring-sdk@2.0.2
|
|
59
78
|
[2.0.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@2.0.0...@metamask/keyring-sdk@2.0.1
|
|
60
79
|
[2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@1.2.0...@metamask/keyring-sdk@2.0.0
|
|
61
80
|
[1.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@1.1.0...@metamask/keyring-sdk@1.2.0
|
package/dist/eth/account-id.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateEthAccountId =
|
|
3
|
+
exports.generateEthAccountId = void 0;
|
|
4
4
|
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
6
|
const sha256_1 = require("ethereum-cryptography/sha256");
|
|
@@ -24,4 +24,5 @@ function generateEthAccountId(address) {
|
|
|
24
24
|
random: (0, sha256_1.sha256)((0, utils_1.hexToBytes)(normalized)).slice(0, 16),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
exports.generateEthAccountId = generateEthAccountId;
|
|
27
28
|
//# sourceMappingURL=account-id.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-id.cjs","sourceRoot":"","sources":["../../src/eth/account-id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account-id.cjs","sourceRoot":"","sources":["../../src/eth/account-id.ts"],"names":[],"mappings":";;;AAAA,yDAAmD;AAEnD,2CAA6C;AAC7C,yDAAsD;AACtD,+BAAoC;AAEpC;;;;;;;;;;;;GAYG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,MAAM,UAAU,GAAG,IAAA,wBAAS,EAAC,OAAO,CAAW,CAAC;IAChD,OAAO,IAAA,SAAM,EAAC;QACZ,MAAM,EAAE,IAAA,eAAM,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;KACpD,CAAC,CAAC;AACL,CAAC;AALD,oDAKC","sourcesContent":["import { normalize } from '@metamask/eth-sig-util';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport { hexToBytes } from '@metamask/utils';\nimport { sha256 } from 'ethereum-cryptography/sha256';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * Generates a deterministic account ID for a given Ethereum address.\n *\n * The address is first normalized (lowercased, `0x`-prefixed) so that\n * checksum-cased and lowercase variants of the same address produce the\n * same ID. The ID is then a UUID v4 derived by seeding the UUID generator\n * with the first 16 bytes of the SHA-256 hash of the normalized address\n * bytes.\n *\n * @param address - The Ethereum address (hex string) to generate the account\n * ID from.\n * @returns A deterministic UUID v4 string to use as the account ID.\n */\nexport function generateEthAccountId(address: string): AccountId {\n const normalized = normalize(address) as string;\n return uuidv4({\n random: sha256(hexToBytes(normalized)).slice(0, 16),\n });\n}\n"]}
|
package/dist/mnemonic.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeMnemonic =
|
|
3
|
+
exports.encodeMnemonic = void 0;
|
|
4
4
|
const english_1 = require("@metamask/scure-bip39/dist/wordlists/english.js");
|
|
5
5
|
/**
|
|
6
6
|
* Encodes a mnemonic as an array of bytes (UTF-8).
|
|
@@ -17,4 +17,5 @@ function encodeMnemonic(mnemonicIndicesBytes) {
|
|
|
17
17
|
const mnemonic = mnemonicIndices.map((i) => english_1.wordlist[i]).join(' ');
|
|
18
18
|
return Array.from(new TextEncoder().encode(mnemonic));
|
|
19
19
|
}
|
|
20
|
+
exports.encodeMnemonic = encodeMnemonic;
|
|
20
21
|
//# sourceMappingURL=mnemonic.cjs.map
|
package/dist/mnemonic.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonic.cjs","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mnemonic.cjs","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AAExE;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,oBAAgC;IAC7D,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI;IAChC,0EAA0E;IAC1E,iEAAiE;IACjE,oBAAoB;IACpB,IAAI,WAAW,CAAC,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAC7D,CAAC;IACF,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC;AATD,wCASC","sourcesContent":["import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';\n\n/**\n * Encodes a mnemonic as an array of bytes (UTF-8).\n *\n * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.\n * @returns An array of bytes (UTF-8) representing the mnemonic.\n */\nexport function encodeMnemonic(mnemonicIndicesBytes: Uint8Array): number[] {\n const mnemonicIndices = Array.from(\n // Create a new `Uint8Array` to ensure we have a proper view on the buffer\n // without having to worry about `byteOffset` and `byteLength` of\n // the inner buffer.\n new Uint16Array(new Uint8Array(mnemonicIndicesBytes).buffer),\n );\n const mnemonic = mnemonicIndices.map((i) => wordlist[i]).join(' ');\n return Array.from(new TextEncoder().encode(mnemonic));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth-keyring-wrapper.cjs","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":";;;AAAA,uCAAsE;AAEtE,yDAA8D;AAE9D,uDA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gB,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,qDAAuC,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;AArKD,8CAqKC","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 { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport {\n EthDecryptParamsStruct,\n EthGetAppKeyAddressParamsStruct,\n EthGetEncryptionPublicKeyParamsStruct,\n EthPersonalSignParamsStruct,\n EthSignEip7702AuthorizationParamsStruct,\n EthSignParamsStruct,\n EthSignTransactionParamsStruct,\n EthSignTypedDataParamsStruct,\n EthSignTypedDataV1ParamsStruct,\n EthMethod,\n} from '@metamask/keyring-api';\nimport type { EthKeyring } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport { add0x, type Hex, type Json } from '@metamask/utils';\n\nimport { generateEthAccountId } from '../../eth/account-id';\nimport { KeyringWrapper, type KeyringWrapperOptions } from '../keyring-wrapper';\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 {@link EthKeyringWrapper}.\n *\n * `registryOptions` is intentionally omitted: the registry is always\n * configured with {@link generateEthAccountId} to produce deterministic\n * account IDs for Ethereum addresses.\n */\nexport type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> = Omit<\n KeyringWrapperOptions<InnerKeyring>,\n 'registryOptions'\n>;\n\n/**\n * Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements Keyring.\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 constructor(options: EthKeyringWrapperOptions<InnerKeyring>) {\n super({\n ...options,\n // We use a custom ID generator to ensure that account IDs are deterministic based on\n // the Ethereum address.\n registryOptions: { generateId: generateEthAccountId },\n });\n }\n\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"]}
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.cjs","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AAGpD,yDAA8D;AAE9D,uDAW+B;AAE/B,uDAA+C;AAC/C,2CAAwC;AAGxC,yDAA4D;AAC5D,4DAAoD;AAGpD;;;GAGG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,yEAAqD,CAAA;IACrD,6DAAyC,CAAA;IAC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,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACvE,CAAC;gBACD,IAAA,oBAAM,EAAC,MAAM,EAAE,qDAAuC,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;AArKD,8CAqKC","sourcesContent":["import { TransactionFactory } from '@ethereumjs/tx';\nimport type { TypedTxData } from '@ethereumjs/tx';\nimport type { MessageTypes, TypedMessage } from '@metamask/eth-sig-util';\nimport { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport type { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport {\n EthDecryptParamsStruct,\n EthGetAppKeyAddressParamsStruct,\n EthGetEncryptionPublicKeyParamsStruct,\n EthPersonalSignParamsStruct,\n EthSignEip7702AuthorizationParamsStruct,\n EthSignParamsStruct,\n EthSignTransactionParamsStruct,\n EthSignTypedDataParamsStruct,\n EthSignTypedDataV1ParamsStruct,\n EthMethod,\n} from '@metamask/keyring-api';\nimport type { EthKeyring } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport { add0x } from '@metamask/utils';\nimport type { Hex, Json } from '@metamask/utils';\n\nimport { generateEthAccountId } from '../../eth/account-id';\nimport { KeyringWrapper } from '../keyring-wrapper';\nimport type { KeyringWrapperOptions } from '../keyring-wrapper';\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 {@link EthKeyringWrapper}.\n *\n * `registryOptions` is intentionally omitted: the registry is always\n * configured with {@link generateEthAccountId} to produce deterministic\n * account IDs for Ethereum addresses.\n */\nexport type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> = Omit<\n KeyringWrapperOptions<InnerKeyring>,\n 'registryOptions'\n>;\n\n/**\n * Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements Keyring.\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 constructor(options: EthKeyringWrapperOptions<InnerKeyring>) {\n super({\n ...options,\n // We use a custom ID generator to ensure that account IDs are deterministic based on\n // the Ethereum address.\n registryOptions: { generateId: generateEthAccountId },\n });\n }\n\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"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { KeyringAccount, KeyringRequest } from "@metamask/keyring-api";
|
|
2
2
|
import type { EthKeyring } from "@metamask/keyring-utils";
|
|
3
|
-
import {
|
|
4
|
-
import { KeyringWrapper
|
|
3
|
+
import type { Hex, Json } from "@metamask/utils";
|
|
4
|
+
import { KeyringWrapper } from "../keyring-wrapper.cjs";
|
|
5
|
+
import type { KeyringWrapperOptions } from "../keyring-wrapper.cjs";
|
|
5
6
|
/**
|
|
6
7
|
* Additional Ethereum methods supported by Eth keyrings that are not in the standard EthMethod enum.
|
|
7
8
|
* These are primarily encryption and utility methods.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth-keyring-wrapper.d.cts","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.d.cts","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8BAA8B;AAa5E,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAG1D,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAGjD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,+BAA2B;AAEhE;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,gBAAgB;IACvB,sBAAsB,+BAA+B;IACrD,gBAAgB,yBAAyB;IACzC,wBAAwB,iCAAiC;CAC1D;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,SAAS,UAAU,IAAI,IAAI,CAC1E,qBAAqB,CAAC,YAAY,CAAC,EACnC,iBAAiB,CAClB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,8BAAsB,iBAAiB,CACrC,YAAY,SAAS,UAAU,EAC/B,kBAAkB,SAAS,cAAc,GAAG,cAAc,CAC1D,SAAQ,cAAc,CAAC,YAAY,EAAE,kBAAkB,CAAC;gBAC5C,OAAO,EAAE,wBAAwB,CAAC,YAAY,CAAC;IAS3D;;;;;;;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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { KeyringAccount, KeyringRequest } from "@metamask/keyring-api";
|
|
2
2
|
import type { EthKeyring } from "@metamask/keyring-utils";
|
|
3
|
-
import {
|
|
4
|
-
import { KeyringWrapper
|
|
3
|
+
import type { Hex, Json } from "@metamask/utils";
|
|
4
|
+
import { KeyringWrapper } from "../keyring-wrapper.mjs";
|
|
5
|
+
import type { KeyringWrapperOptions } from "../keyring-wrapper.mjs";
|
|
5
6
|
/**
|
|
6
7
|
* Additional Ethereum methods supported by Eth keyrings that are not in the standard EthMethod enum.
|
|
7
8
|
* These are primarily encryption and utility methods.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth-keyring-wrapper.d.mts","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.d.mts","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8BAA8B;AAa5E,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAG1D,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAGjD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,+BAA2B;AAEhE;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,gBAAgB;IACvB,sBAAsB,+BAA+B;IACrD,gBAAgB,yBAAyB;IACzC,wBAAwB,iCAAiC;CAC1D;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,CAAC,YAAY,SAAS,UAAU,IAAI,IAAI,CAC1E,qBAAqB,CAAC,YAAY,CAAC,EACnC,iBAAiB,CAClB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,8BAAsB,iBAAiB,CACrC,YAAY,SAAS,UAAU,EAC/B,kBAAkB,SAAS,cAAc,GAAG,cAAc,CAC1D,SAAQ,cAAc,CAAC,YAAY,EAAE,kBAAkB,CAAC;gBAC5C,OAAO,EAAE,wBAAwB,CAAC,YAAY,CAAC;IAS3D;;;;;;;OAOG;IAC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iDAAiD,CAAC,CAAC;gBACrE,CAAC;gBACD,MAAM,CAAC,MAAM,EAAE,qCAAqC,CAAC,CAAC;gBACtD,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;gBAC3B,OAAO,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,MAAM,CAAC,MAAM,EAAE,+BAA+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,MAAM,CAAC,MAAM,EAAE,uCAAuC,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","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 { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport {\n EthDecryptParamsStruct,\n EthGetAppKeyAddressParamsStruct,\n EthGetEncryptionPublicKeyParamsStruct,\n EthPersonalSignParamsStruct,\n EthSignEip7702AuthorizationParamsStruct,\n EthSignParamsStruct,\n EthSignTransactionParamsStruct,\n EthSignTypedDataParamsStruct,\n EthSignTypedDataV1ParamsStruct,\n EthMethod,\n} from '@metamask/keyring-api';\nimport type { EthKeyring } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport { add0x, type Hex, type Json } from '@metamask/utils';\n\nimport { generateEthAccountId } from '../../eth/account-id';\nimport { KeyringWrapper, type KeyringWrapperOptions } from '../keyring-wrapper';\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 {@link EthKeyringWrapper}.\n *\n * `registryOptions` is intentionally omitted: the registry is always\n * configured with {@link generateEthAccountId} to produce deterministic\n * account IDs for Ethereum addresses.\n */\nexport type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> = Omit<\n KeyringWrapperOptions<InnerKeyring>,\n 'registryOptions'\n>;\n\n/**\n * Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements Keyring.\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 constructor(options: EthKeyringWrapperOptions<InnerKeyring>) {\n super({\n ...options,\n // We use a custom ID generator to ensure that account IDs are deterministic based on\n // the Ethereum address.\n registryOptions: { generateId: generateEthAccountId },\n });\n }\n\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"]}
|
|
1
|
+
{"version":3,"file":"eth-keyring-wrapper.mjs","sourceRoot":"","sources":["../../../src/v2/eth/eth-keyring-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB;AAGpD,OAAO,EAAE,oBAAoB,EAAE,+BAA+B;AAE9D,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,qCAAqC,EACrC,2BAA2B,EAC3B,uCAAuC,EACvC,mBAAmB,EACnB,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,EAC9B,SAAS,EACV,8BAA8B;AAE/B,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAC/C,OAAO,EAAE,KAAK,EAAE,wBAAwB;AAGxC,OAAO,EAAE,oBAAoB,EAAE,iCAA6B;AAC5D,OAAO,EAAE,cAAc,EAAE,+BAA2B;AAGpD;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,yEAAqD,CAAA;IACrD,6DAAyC,CAAA;IACzC,6EAAyD,CAAA;AAC3D,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAcD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAgB,iBAGpB,SAAQ,cAAgD;IACxD,YAAY,OAA+C;QACzD,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,qFAAqF;YACrF,wBAAwB;YACxB,eAAe,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE;SACtD,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACO,YAAY,CAAC,OAAe;QACpC,OAAO,KAAK,CAAC,OA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CAAC;oBACvC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;gBACrE,CAAC;gBACD,MAAM,CAAC,MAAM,EAAE,qCAAqC,CAAC,CAAC;gBACtD,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;gBAC3B,OAAO,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,MAAM,CAAC,MAAM,EAAE,+BAA+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,MAAM,CAAC,MAAM,EAAE,uCAAuC,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","sourcesContent":["import { TransactionFactory } from '@ethereumjs/tx';\nimport type { TypedTxData } from '@ethereumjs/tx';\nimport type { MessageTypes, TypedMessage } from '@metamask/eth-sig-util';\nimport { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport type { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport {\n EthDecryptParamsStruct,\n EthGetAppKeyAddressParamsStruct,\n EthGetEncryptionPublicKeyParamsStruct,\n EthPersonalSignParamsStruct,\n EthSignEip7702AuthorizationParamsStruct,\n EthSignParamsStruct,\n EthSignTransactionParamsStruct,\n EthSignTypedDataParamsStruct,\n EthSignTypedDataV1ParamsStruct,\n EthMethod,\n} from '@metamask/keyring-api';\nimport type { EthKeyring } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport { add0x } from '@metamask/utils';\nimport type { Hex, Json } from '@metamask/utils';\n\nimport { generateEthAccountId } from '../../eth/account-id';\nimport { KeyringWrapper } from '../keyring-wrapper';\nimport type { KeyringWrapperOptions } from '../keyring-wrapper';\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 {@link EthKeyringWrapper}.\n *\n * `registryOptions` is intentionally omitted: the registry is always\n * configured with {@link generateEthAccountId} to produce deterministic\n * account IDs for Ethereum addresses.\n */\nexport type EthKeyringWrapperOptions<InnerKeyring extends EthKeyring> = Omit<\n KeyringWrapperOptions<InnerKeyring>,\n 'registryOptions'\n>;\n\n/**\n * Abstract wrapper for Ethereum-based keyrings that extends KeyringWrapper, that itself implements Keyring.\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 constructor(options: EthKeyringWrapperOptions<InnerKeyring>) {\n super({\n ...options,\n // We use a custom ID generator to ensure that account IDs are deterministic based on\n // the Ethereum address.\n registryOptions: { generateId: generateEthAccountId },\n });\n }\n\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"]}
|
package/dist/v2/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ 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("./keyring-v1-adapter.cjs"), exports);
|
|
17
18
|
__exportStar(require("./keyring-wrapper.cjs"), exports);
|
|
18
19
|
__exportStar(require("./eth/index.cjs"), exports);
|
|
19
20
|
//# sourceMappingURL=index.cjs.map
|
package/dist/v2/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,kDAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './eth';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAqC;AACrC,wDAAkC;AAClC,kDAAsB","sourcesContent":["export * from './keyring-v1-adapter';\nexport * from './keyring-wrapper';\nexport * from './eth';\n"]}
|
package/dist/v2/index.d.cts
CHANGED
package/dist/v2/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,yCAAqC;AACrC,sCAAkC;AAClC,gCAAsB"}
|
package/dist/v2/index.d.mts
CHANGED
package/dist/v2/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAAsB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,yCAAqC;AACrC,sCAAkC;AAClC,gCAAsB"}
|
package/dist/v2/index.mjs
CHANGED
package/dist/v2/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './eth';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,yCAAqC;AACrC,sCAAkC;AAClC,gCAAsB","sourcesContent":["export * from './keyring-v1-adapter';\nexport * from './keyring-wrapper';\nexport * from './eth';\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.KeyringV1Adapter = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it
|
|
18
|
+
* through the v1 {@link BaseKeyring} interface expected by `KeyringController`.
|
|
19
|
+
*
|
|
20
|
+
* ## Why this exists
|
|
21
|
+
*
|
|
22
|
+
* `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`
|
|
23
|
+
* interface — notably `getAccounts()` which must return `Promise<string[]>`
|
|
24
|
+
* (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`
|
|
25
|
+
* from `getAccounts()`, an incompatible signature.
|
|
26
|
+
*
|
|
27
|
+
* ## Architecture
|
|
28
|
+
*
|
|
29
|
+
* This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.
|
|
30
|
+
* `KeyringController` stores this adapter as the v1 keyring entry; its
|
|
31
|
+
* `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for
|
|
32
|
+
* the v2 entry — no state duplication.
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
* KeyringEntry {
|
|
36
|
+
* keyring: KeyringV1Adapter ← v1 face (this class)
|
|
37
|
+
* keyringV2: InnerKeyring ← v2 face (same instance via unwrap())
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.
|
|
42
|
+
* Defaults to the base {@link KeyringV2} interface. Specifying a concrete
|
|
43
|
+
* subtype preserves full type information through {@link unwrap}.
|
|
44
|
+
*/
|
|
45
|
+
class KeyringV1Adapter {
|
|
46
|
+
constructor(inner) {
|
|
47
|
+
_KeyringV1Adapter_inner.set(this, void 0);
|
|
48
|
+
__classPrivateFieldSet(this, _KeyringV1Adapter_inner, inner, "f");
|
|
49
|
+
this.type = inner.type;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the inner v2 {@link KeyringV2} instance.
|
|
53
|
+
*
|
|
54
|
+
* Intended for use by `KeyringController`'s `KeyringV2Builder` so that both
|
|
55
|
+
* the v1 and v2 keyring entries in a `KeyringEntry` share the same object.
|
|
56
|
+
*
|
|
57
|
+
* @returns The inner v2 keyring instance.
|
|
58
|
+
*/
|
|
59
|
+
unwrap() {
|
|
60
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the addresses of all accounts in this keyring.
|
|
64
|
+
*
|
|
65
|
+
* Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the
|
|
66
|
+
* v1 `BaseKeyring` interface (`string[]`).
|
|
67
|
+
*
|
|
68
|
+
* @returns A promise resolving to the list of account addresses.
|
|
69
|
+
*/
|
|
70
|
+
async getAccounts() {
|
|
71
|
+
const accounts = await __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").getAccounts();
|
|
72
|
+
return accounts.map((account) => account.address);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Serializes the keyring state.
|
|
76
|
+
*
|
|
77
|
+
* Delegates to the inner v2 instance.
|
|
78
|
+
*
|
|
79
|
+
* @returns A promise resolving to the serialized state.
|
|
80
|
+
*/
|
|
81
|
+
async serialize() {
|
|
82
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").serialize();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Restores keyring state from a serialized snapshot.
|
|
86
|
+
*
|
|
87
|
+
* Delegates to the inner v2 instance.
|
|
88
|
+
*
|
|
89
|
+
* @param state - The serialized state to restore.
|
|
90
|
+
* @returns A promise that resolves when deserialization is complete.
|
|
91
|
+
*/
|
|
92
|
+
async deserialize(state) {
|
|
93
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").deserialize(state);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.KeyringV1Adapter = KeyringV1Adapter;
|
|
97
|
+
_KeyringV1Adapter_inner = new WeakMap();
|
|
98
|
+
//# sourceMappingURL=keyring-v1-adapter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring-v1-adapter.cjs","sourceRoot":"","sources":["../../src/v2/keyring-v1-adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,gBAAgB;IAU3B,YAAY,KAAmB;QAFtB,0CAAqB;QAG5B,uBAAA,IAAI,2BAAU,KAAK,MAAA,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM;QACJ,OAAO,uBAAA,IAAI,+BAAO,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,+BAAO,CAAC,WAAW,EAAE,CAAC;QACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAuB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,uBAAA,IAAI,+BAAO,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,KAAW;QAC3B,OAAO,uBAAA,IAAI,+BAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF;AA9DD,4CA8DC","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\nimport type { Keyring as KeyringV2 } from '@metamask/keyring-api/v2';\nimport type { BaseKeyring } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\n/**\n * Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it\n * through the v1 {@link BaseKeyring} interface expected by `KeyringController`.\n *\n * ## Why this exists\n *\n * `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`\n * interface — notably `getAccounts()` which must return `Promise<string[]>`\n * (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`\n * from `getAccounts()`, an incompatible signature.\n *\n * ## Architecture\n *\n * This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.\n * `KeyringController` stores this adapter as the v1 keyring entry; its\n * `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for\n * the v2 entry — no state duplication.\n *\n * ```\n * KeyringEntry {\n * keyring: KeyringV1Adapter ← v1 face (this class)\n * keyringV2: InnerKeyring ← v2 face (same instance via unwrap())\n * }\n * ```\n *\n * @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.\n * Defaults to the base {@link KeyringV2} interface. Specifying a concrete\n * subtype preserves full type information through {@link unwrap}.\n */\nexport class KeyringV1Adapter<\n InnerKeyring extends KeyringV2 = KeyringV2,\n> implements BaseKeyring {\n /**\n * Keyring type identifier, mirroring the inner v2 instance's type.\n */\n readonly type: string;\n\n readonly #inner: InnerKeyring;\n\n constructor(inner: InnerKeyring) {\n this.#inner = inner;\n this.type = inner.type;\n }\n\n /**\n * Returns the inner v2 {@link KeyringV2} instance.\n *\n * Intended for use by `KeyringController`'s `KeyringV2Builder` so that both\n * the v1 and v2 keyring entries in a `KeyringEntry` share the same object.\n *\n * @returns The inner v2 keyring instance.\n */\n unwrap(): InnerKeyring {\n return this.#inner;\n }\n\n /**\n * Returns the addresses of all accounts in this keyring.\n *\n * Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the\n * v1 `BaseKeyring` interface (`string[]`).\n *\n * @returns A promise resolving to the list of account addresses.\n */\n async getAccounts(): Promise<string[]> {\n const accounts = await this.#inner.getAccounts();\n return accounts.map((account: KeyringAccount) => account.address);\n }\n\n /**\n * Serializes the keyring state.\n *\n * Delegates to the inner v2 instance.\n *\n * @returns A promise resolving to the serialized state.\n */\n async serialize(): Promise<Json> {\n return this.#inner.serialize();\n }\n\n /**\n * Restores keyring state from a serialized snapshot.\n *\n * Delegates to the inner v2 instance.\n *\n * @param state - The serialized state to restore.\n * @returns A promise that resolves when deserialization is complete.\n */\n async deserialize(state: Json): Promise<void> {\n return this.#inner.deserialize(state);\n }\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Keyring as KeyringV2 } from "@metamask/keyring-api/v2";
|
|
2
|
+
import type { BaseKeyring } from "@metamask/keyring-utils";
|
|
3
|
+
import type { Json } from "@metamask/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it
|
|
6
|
+
* through the v1 {@link BaseKeyring} interface expected by `KeyringController`.
|
|
7
|
+
*
|
|
8
|
+
* ## Why this exists
|
|
9
|
+
*
|
|
10
|
+
* `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`
|
|
11
|
+
* interface — notably `getAccounts()` which must return `Promise<string[]>`
|
|
12
|
+
* (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`
|
|
13
|
+
* from `getAccounts()`, an incompatible signature.
|
|
14
|
+
*
|
|
15
|
+
* ## Architecture
|
|
16
|
+
*
|
|
17
|
+
* This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.
|
|
18
|
+
* `KeyringController` stores this adapter as the v1 keyring entry; its
|
|
19
|
+
* `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for
|
|
20
|
+
* the v2 entry — no state duplication.
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* KeyringEntry {
|
|
24
|
+
* keyring: KeyringV1Adapter ← v1 face (this class)
|
|
25
|
+
* keyringV2: InnerKeyring ← v2 face (same instance via unwrap())
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.
|
|
30
|
+
* Defaults to the base {@link KeyringV2} interface. Specifying a concrete
|
|
31
|
+
* subtype preserves full type information through {@link unwrap}.
|
|
32
|
+
*/
|
|
33
|
+
export declare class KeyringV1Adapter<InnerKeyring extends KeyringV2 = KeyringV2> implements BaseKeyring {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Keyring type identifier, mirroring the inner v2 instance's type.
|
|
37
|
+
*/
|
|
38
|
+
readonly type: string;
|
|
39
|
+
constructor(inner: InnerKeyring);
|
|
40
|
+
/**
|
|
41
|
+
* Returns the inner v2 {@link KeyringV2} instance.
|
|
42
|
+
*
|
|
43
|
+
* Intended for use by `KeyringController`'s `KeyringV2Builder` so that both
|
|
44
|
+
* the v1 and v2 keyring entries in a `KeyringEntry` share the same object.
|
|
45
|
+
*
|
|
46
|
+
* @returns The inner v2 keyring instance.
|
|
47
|
+
*/
|
|
48
|
+
unwrap(): InnerKeyring;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the addresses of all accounts in this keyring.
|
|
51
|
+
*
|
|
52
|
+
* Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the
|
|
53
|
+
* v1 `BaseKeyring` interface (`string[]`).
|
|
54
|
+
*
|
|
55
|
+
* @returns A promise resolving to the list of account addresses.
|
|
56
|
+
*/
|
|
57
|
+
getAccounts(): Promise<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Serializes the keyring state.
|
|
60
|
+
*
|
|
61
|
+
* Delegates to the inner v2 instance.
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise resolving to the serialized state.
|
|
64
|
+
*/
|
|
65
|
+
serialize(): Promise<Json>;
|
|
66
|
+
/**
|
|
67
|
+
* Restores keyring state from a serialized snapshot.
|
|
68
|
+
*
|
|
69
|
+
* Delegates to the inner v2 instance.
|
|
70
|
+
*
|
|
71
|
+
* @param state - The serialized state to restore.
|
|
72
|
+
* @returns A promise that resolves when deserialization is complete.
|
|
73
|
+
*/
|
|
74
|
+
deserialize(state: Json): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=keyring-v1-adapter.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring-v1-adapter.d.cts","sourceRoot":"","sources":["../../src/v2/keyring-v1-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,iCAAiC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,gCAAgC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,gBAAgB,CAC3B,YAAY,SAAS,SAAS,GAAG,SAAS,CAC1C,YAAW,WAAW;;IACtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAIV,KAAK,EAAE,YAAY;IAK/B;;;;;;;OAOG;IACH,MAAM,IAAI,YAAY;IAItB;;;;;;;OAOG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtC;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;;;OAOG;IACG,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Keyring as KeyringV2 } from "@metamask/keyring-api/v2";
|
|
2
|
+
import type { BaseKeyring } from "@metamask/keyring-utils";
|
|
3
|
+
import type { Json } from "@metamask/utils";
|
|
4
|
+
/**
|
|
5
|
+
* Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it
|
|
6
|
+
* through the v1 {@link BaseKeyring} interface expected by `KeyringController`.
|
|
7
|
+
*
|
|
8
|
+
* ## Why this exists
|
|
9
|
+
*
|
|
10
|
+
* `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`
|
|
11
|
+
* interface — notably `getAccounts()` which must return `Promise<string[]>`
|
|
12
|
+
* (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`
|
|
13
|
+
* from `getAccounts()`, an incompatible signature.
|
|
14
|
+
*
|
|
15
|
+
* ## Architecture
|
|
16
|
+
*
|
|
17
|
+
* This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.
|
|
18
|
+
* `KeyringController` stores this adapter as the v1 keyring entry; its
|
|
19
|
+
* `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for
|
|
20
|
+
* the v2 entry — no state duplication.
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* KeyringEntry {
|
|
24
|
+
* keyring: KeyringV1Adapter ← v1 face (this class)
|
|
25
|
+
* keyringV2: InnerKeyring ← v2 face (same instance via unwrap())
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.
|
|
30
|
+
* Defaults to the base {@link KeyringV2} interface. Specifying a concrete
|
|
31
|
+
* subtype preserves full type information through {@link unwrap}.
|
|
32
|
+
*/
|
|
33
|
+
export declare class KeyringV1Adapter<InnerKeyring extends KeyringV2 = KeyringV2> implements BaseKeyring {
|
|
34
|
+
#private;
|
|
35
|
+
/**
|
|
36
|
+
* Keyring type identifier, mirroring the inner v2 instance's type.
|
|
37
|
+
*/
|
|
38
|
+
readonly type: string;
|
|
39
|
+
constructor(inner: InnerKeyring);
|
|
40
|
+
/**
|
|
41
|
+
* Returns the inner v2 {@link KeyringV2} instance.
|
|
42
|
+
*
|
|
43
|
+
* Intended for use by `KeyringController`'s `KeyringV2Builder` so that both
|
|
44
|
+
* the v1 and v2 keyring entries in a `KeyringEntry` share the same object.
|
|
45
|
+
*
|
|
46
|
+
* @returns The inner v2 keyring instance.
|
|
47
|
+
*/
|
|
48
|
+
unwrap(): InnerKeyring;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the addresses of all accounts in this keyring.
|
|
51
|
+
*
|
|
52
|
+
* Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the
|
|
53
|
+
* v1 `BaseKeyring` interface (`string[]`).
|
|
54
|
+
*
|
|
55
|
+
* @returns A promise resolving to the list of account addresses.
|
|
56
|
+
*/
|
|
57
|
+
getAccounts(): Promise<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Serializes the keyring state.
|
|
60
|
+
*
|
|
61
|
+
* Delegates to the inner v2 instance.
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise resolving to the serialized state.
|
|
64
|
+
*/
|
|
65
|
+
serialize(): Promise<Json>;
|
|
66
|
+
/**
|
|
67
|
+
* Restores keyring state from a serialized snapshot.
|
|
68
|
+
*
|
|
69
|
+
* Delegates to the inner v2 instance.
|
|
70
|
+
*
|
|
71
|
+
* @param state - The serialized state to restore.
|
|
72
|
+
* @returns A promise that resolves when deserialization is complete.
|
|
73
|
+
*/
|
|
74
|
+
deserialize(state: Json): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=keyring-v1-adapter.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring-v1-adapter.d.mts","sourceRoot":"","sources":["../../src/v2/keyring-v1-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,iCAAiC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,gCAAgC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,gBAAgB,CAC3B,YAAY,SAAS,SAAS,GAAG,SAAS,CAC1C,YAAW,WAAW;;IACtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAIV,KAAK,EAAE,YAAY;IAK/B;;;;;;;OAOG;IACH,MAAM,IAAI,YAAY;IAItB;;;;;;;OAOG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtC;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;;;OAOG;IACG,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _KeyringV1Adapter_inner;
|
|
13
|
+
/**
|
|
14
|
+
* Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it
|
|
15
|
+
* through the v1 {@link BaseKeyring} interface expected by `KeyringController`.
|
|
16
|
+
*
|
|
17
|
+
* ## Why this exists
|
|
18
|
+
*
|
|
19
|
+
* `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`
|
|
20
|
+
* interface — notably `getAccounts()` which must return `Promise<string[]>`
|
|
21
|
+
* (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`
|
|
22
|
+
* from `getAccounts()`, an incompatible signature.
|
|
23
|
+
*
|
|
24
|
+
* ## Architecture
|
|
25
|
+
*
|
|
26
|
+
* This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.
|
|
27
|
+
* `KeyringController` stores this adapter as the v1 keyring entry; its
|
|
28
|
+
* `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for
|
|
29
|
+
* the v2 entry — no state duplication.
|
|
30
|
+
*
|
|
31
|
+
* ```
|
|
32
|
+
* KeyringEntry {
|
|
33
|
+
* keyring: KeyringV1Adapter ← v1 face (this class)
|
|
34
|
+
* keyringV2: InnerKeyring ← v2 face (same instance via unwrap())
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.
|
|
39
|
+
* Defaults to the base {@link KeyringV2} interface. Specifying a concrete
|
|
40
|
+
* subtype preserves full type information through {@link unwrap}.
|
|
41
|
+
*/
|
|
42
|
+
export class KeyringV1Adapter {
|
|
43
|
+
constructor(inner) {
|
|
44
|
+
_KeyringV1Adapter_inner.set(this, void 0);
|
|
45
|
+
__classPrivateFieldSet(this, _KeyringV1Adapter_inner, inner, "f");
|
|
46
|
+
this.type = inner.type;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the inner v2 {@link KeyringV2} instance.
|
|
50
|
+
*
|
|
51
|
+
* Intended for use by `KeyringController`'s `KeyringV2Builder` so that both
|
|
52
|
+
* the v1 and v2 keyring entries in a `KeyringEntry` share the same object.
|
|
53
|
+
*
|
|
54
|
+
* @returns The inner v2 keyring instance.
|
|
55
|
+
*/
|
|
56
|
+
unwrap() {
|
|
57
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the addresses of all accounts in this keyring.
|
|
61
|
+
*
|
|
62
|
+
* Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the
|
|
63
|
+
* v1 `BaseKeyring` interface (`string[]`).
|
|
64
|
+
*
|
|
65
|
+
* @returns A promise resolving to the list of account addresses.
|
|
66
|
+
*/
|
|
67
|
+
async getAccounts() {
|
|
68
|
+
const accounts = await __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").getAccounts();
|
|
69
|
+
return accounts.map((account) => account.address);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Serializes the keyring state.
|
|
73
|
+
*
|
|
74
|
+
* Delegates to the inner v2 instance.
|
|
75
|
+
*
|
|
76
|
+
* @returns A promise resolving to the serialized state.
|
|
77
|
+
*/
|
|
78
|
+
async serialize() {
|
|
79
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").serialize();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Restores keyring state from a serialized snapshot.
|
|
83
|
+
*
|
|
84
|
+
* Delegates to the inner v2 instance.
|
|
85
|
+
*
|
|
86
|
+
* @param state - The serialized state to restore.
|
|
87
|
+
* @returns A promise that resolves when deserialization is complete.
|
|
88
|
+
*/
|
|
89
|
+
async deserialize(state) {
|
|
90
|
+
return __classPrivateFieldGet(this, _KeyringV1Adapter_inner, "f").deserialize(state);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_KeyringV1Adapter_inner = new WeakMap();
|
|
94
|
+
//# sourceMappingURL=keyring-v1-adapter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyring-v1-adapter.mjs","sourceRoot":"","sources":["../../src/v2/keyring-v1-adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,gBAAgB;IAU3B,YAAY,KAAmB;QAFtB,0CAAqB;QAG5B,uBAAA,IAAI,2BAAU,KAAK,MAAA,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM;QACJ,OAAO,uBAAA,IAAI,+BAAO,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,+BAAO,CAAC,WAAW,EAAE,CAAC;QACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAuB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,uBAAA,IAAI,+BAAO,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,KAAW;QAC3B,OAAO,uBAAA,IAAI,+BAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import type { KeyringAccount } from '@metamask/keyring-api';\nimport type { Keyring as KeyringV2 } from '@metamask/keyring-api/v2';\nimport type { BaseKeyring } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\n/**\n * Generic adapter that wraps a v2 {@link KeyringV2} instance and exposes it\n * through the v1 {@link BaseKeyring} interface expected by `KeyringController`.\n *\n * ## Why this exists\n *\n * `KeyringController` interacts with all keyrings via the v1 `BaseKeyring`\n * interface — notably `getAccounts()` which must return `Promise<string[]>`\n * (addresses). The v2 `Keyring` interface returns `Promise<KeyringAccount[]>`\n * from `getAccounts()`, an incompatible signature.\n *\n * ## Architecture\n *\n * This class holds a v2 `Keyring` instance and exposes it via {@link unwrap}.\n * `KeyringController` stores this adapter as the v1 keyring entry; its\n * `KeyringV2Builder` calls `unwrap()` to retrieve the same inner instance for\n * the v2 entry — no state duplication.\n *\n * ```\n * KeyringEntry {\n * keyring: KeyringV1Adapter ← v1 face (this class)\n * keyringV2: InnerKeyring ← v2 face (same instance via unwrap())\n * }\n * ```\n *\n * @typeParam InnerKeyring - The concrete v2 keyring type being wrapped.\n * Defaults to the base {@link KeyringV2} interface. Specifying a concrete\n * subtype preserves full type information through {@link unwrap}.\n */\nexport class KeyringV1Adapter<\n InnerKeyring extends KeyringV2 = KeyringV2,\n> implements BaseKeyring {\n /**\n * Keyring type identifier, mirroring the inner v2 instance's type.\n */\n readonly type: string;\n\n readonly #inner: InnerKeyring;\n\n constructor(inner: InnerKeyring) {\n this.#inner = inner;\n this.type = inner.type;\n }\n\n /**\n * Returns the inner v2 {@link KeyringV2} instance.\n *\n * Intended for use by `KeyringController`'s `KeyringV2Builder` so that both\n * the v1 and v2 keyring entries in a `KeyringEntry` share the same object.\n *\n * @returns The inner v2 keyring instance.\n */\n unwrap(): InnerKeyring {\n return this.#inner;\n }\n\n /**\n * Returns the addresses of all accounts in this keyring.\n *\n * Adapts the v2 `getAccounts()` (which returns `KeyringAccount[]`) to the\n * v1 `BaseKeyring` interface (`string[]`).\n *\n * @returns A promise resolving to the list of account addresses.\n */\n async getAccounts(): Promise<string[]> {\n const accounts = await this.#inner.getAccounts();\n return accounts.map((account: KeyringAccount) => account.address);\n }\n\n /**\n * Serializes the keyring state.\n *\n * Delegates to the inner v2 instance.\n *\n * @returns A promise resolving to the serialized state.\n */\n async serialize(): Promise<Json> {\n return this.#inner.serialize();\n }\n\n /**\n * Restores keyring state from a serialized snapshot.\n *\n * Delegates to the inner v2 instance.\n *\n * @param state - The serialized state to restore.\n * @returns A promise that resolves when deserialization is complete.\n */\n async deserialize(state: Json): Promise<void> {\n return this.#inner.deserialize(state);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-wrapper.cjs","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,6CAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"keyring-wrapper.cjs","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,6CAAoC;AAEpC,8EAAqE;AA4BrE;;;;;;;;;GASG;AACH,MAAsB,cAAc;IAyBlC,YAAY,OAA4C;QAnB/C,+CAAmC;QAI5C;;;WAGG;QACM,+BAAQ,IAAI,mBAAK,EAAE,EAAC;QAY3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC9B,uBAAA,IAAI,gCAAiB,OAAO,CAAC,YAAY,MAAA,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,iDAAsB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,YAAY;QACd,OAAO,uBAAA,IAAI,oCAAc,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,QAAQ,CACtB,QAA+B;QAE/B,OAAO,uBAAA,IAAI,4BAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CAAC,KAAW;QAC3B,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;YAC7B,wCAAwC;YACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YAEtB,iCAAiC;YACjC,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAEpC,iDAAiD;YACjD,yEAAyE;YACzE,8DAA8D;YAC9D,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAgBD;;;;;;;;;OASG;IACH,KAAK,CAAC,UAAU,CAAC,SAAoB;QACnC,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,4CAA4C;QAC5C,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAEzB,mCAAmC;QACnC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CA+CF;AA1LD,wCA0LC","sourcesContent":["import type { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n ExportAccountOptions,\n ExportedAccount,\n Keyring,\n KeyringCapabilities,\n KeyringType,\n} from '@metamask/keyring-api/v2';\nimport type {\n Keyring as LegacyKeyring,\n AccountId,\n} from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\n\nimport { KeyringAccountRegistry } from '../keyring-account-registry';\nimport type { KeyringAccountRegistryOptions } from '../keyring-account-registry';\n\n/**\n * Basic options for constructing a {@link KeyringWrapper}.\n */\nexport type KeyringWrapperOptions<InnerKeyring extends LegacyKeyring> = {\n /**\n * The underlying \"old\" keyring instance that this wrapper adapts.\n */\n inner: InnerKeyring;\n\n /**\n * The concrete keyring type exposed through the V2 interface.\n */\n type: KeyringType;\n\n /**\n * Capabilities of the underlying keyring.\n */\n capabilities: KeyringCapabilities;\n\n /**\n * Options forwarded to the {@link KeyringAccountRegistry} constructor.\n */\n registryOptions?: KeyringAccountRegistryOptions;\n};\n\n/**\n * Generic adapter that turns an existing {@link Keyring} implementation into a\n * {@link Keyring} instance.\n *\n * Consumers are expected to provide concrete mappings between high-level V2\n * operations and the underlying keyring methods (for example BIP-44 account\n * creation, private-key import, and request handling). This class focuses on\n * the common mechanics required by all adapters: state serialization,\n * account-ID/address mapping and basic account management.\n */\nexport abstract class KeyringWrapper<\n InnerKeyring extends LegacyKeyring,\n KeyringAccountType extends KeyringAccount = KeyringAccount,\n> implements Keyring {\n readonly type: `${KeyringType}`;\n\n readonly #capabilities: KeyringCapabilities;\n\n protected readonly inner: InnerKeyring;\n\n /**\n * Mutex to ensure exclusive access to the inner keyring during\n * operations that mutate its state.\n */\n readonly #lock = new Mutex();\n\n /**\n * Registry for KeyringAccount objects.\n * Provides O(1) lookups by AccountId or address.\n *\n * Subclasses should use this registry when creating accounts and\n * clear/update it when deleting accounts or deserializing state.\n */\n protected readonly registry: KeyringAccountRegistry<KeyringAccountType>;\n\n constructor(options: KeyringWrapperOptions<InnerKeyring>) {\n this.inner = options.inner;\n this.type = `${options.type}`;\n this.#capabilities = options.capabilities;\n this.registry = new KeyringAccountRegistry(options.registryOptions);\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Subclasses can override this getter to return capabilities dynamically\n * based on runtime state.\n *\n * @returns The keyring's capabilities.\n */\n get capabilities(): KeyringCapabilities {\n return this.#capabilities;\n }\n\n /**\n * Execute an operation with exclusive access to the inner keyring.\n *\n * This method ensures thread-safety for operations that read or mutate\n * the inner keyring state. All operations that modify the keyring\n * (createAccounts, deleteAccount, deserialize) should use this method\n * to prevent race conditions.\n *\n * Within the callback, use `this.inner` to access the inner keyring.\n *\n * @param callback - A function that performs the operation.\n * @returns The result of the callback.\n */\n protected async withLock<Result>(\n callback: () => Promise<Result>,\n ): Promise<Result> {\n return this.#lock.runExclusive(callback);\n }\n\n /**\n * Serialize the underlying keyring state to a JSON-serializable object.\n *\n * This simply delegates to the legacy keyring's {@link Keyring.serialize}\n * implementation.\n *\n * @returns The serialized keyring state.\n */\n async serialize(): Promise<Json> {\n return this.inner.serialize();\n }\n\n /**\n * Hydrate the underlying keyring from a previously serialized state.\n *\n * This clears the registry, delegates to the legacy keyring's\n * {@link Keyring.deserialize} implementation, and rebuilds the registry\n * by calling {@link getAccounts}.\n *\n * @param state - The serialized keyring state.\n */\n async deserialize(state: Json): Promise<void> {\n await this.withLock(async () => {\n // Clear the registry when deserializing\n this.registry.clear();\n\n // Deserialize the legacy keyring\n await this.inner.deserialize(state);\n\n // Rebuild the registry by calling getAccounts().\n // Subclass implementations of getAccounts() should populate the registry\n // as a side effect (see the abstract method's documentation).\n await this.getAccounts();\n });\n }\n\n /**\n * Return all accounts managed by this keyring.\n *\n * Concrete adapters are responsible for mapping the underlying keyring's\n * notion of accounts (typically addresses returned by\n * {@link Keyring.getAccounts}) into {@link KeyringAccount} objects.\n * Implementations should use the configured {@link KeyringAccountRegistry}\n * to establish the account ID/address mapping so that\n * {@link getAccount} works as expected.\n *\n * @returns The list of managed accounts.\n */\n abstract getAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Look up a single account by its {@link AccountId}.\n *\n * This method first checks the registry for O(1) lookup.\n * If not found, it falls back to calling {@link getAccounts} which\n * should populate the registry as a side effect.\n *\n * @param accountId - The AccountId to look up.\n * @returns The matching KeyringAccount.\n */\n async getAccount(accountId: AccountId): Promise<KeyringAccount> {\n let cached = this.registry.get(accountId);\n if (cached) {\n return cached;\n }\n\n // Prime the registry by calling getAccounts\n await this.getAccounts();\n\n // Try registry again after priming\n cached = this.registry.get(accountId);\n if (!cached) {\n throw new Error(`Account not found for id: ${accountId}`);\n }\n\n return cached;\n }\n\n /**\n * Create one or more new accounts managed by this keyring.\n *\n * Implementations are responsible for interpreting the\n * {@link CreateAccountOptions} (for example BIP-44 derivation or\n * private-key import) and returning the resulting {@link KeyringAccount}\n * objects. Implementors should also ensure that the registry is updated so\n * that {@link getAccount} works for newly created accounts.\n */\n abstract createAccounts(\n options: CreateAccountOptions,\n ): Promise<KeyringAccount[]>;\n\n /**\n * Remove the account associated with the given {@link AccountId} from this\n * keyring.\n *\n * Implementations are expected to translate the ID to an underlying\n * address (typically via the registry) and then invoke the appropriate\n * removal mechanism on the legacy keyring.\n */\n abstract deleteAccount(accountId: AccountId): Promise<void>;\n\n /**\n * Export the secrets associated with the given account in a format\n * described by {@link ExportAccountOptions}.\n *\n * This method is optional, and concrete adapters should only\n * implement it if the underlying keyring supports exporting\n * accounts.\n */\n exportAccount?(\n accountId: AccountId,\n options?: ExportAccountOptions,\n ): Promise<ExportedAccount>;\n\n /**\n * Handle a high-level {@link KeyringRequest} on behalf of this keyring.\n *\n * Concrete adapters are responsible for routing the request's method and\n * parameters to the appropriate legacy keyring APIs (for example signing\n * transactions or decrypting messages) and returning a JSON-serializable\n * result.\n */\n abstract submitRequest(request: KeyringRequest): Promise<Json>;\n}\n"]}
|
|
@@ -2,7 +2,8 @@ import type { KeyringAccount, KeyringRequest } from "@metamask/keyring-api";
|
|
|
2
2
|
import type { CreateAccountOptions, ExportAccountOptions, ExportedAccount, Keyring, KeyringCapabilities, KeyringType } from "@metamask/keyring-api/v2";
|
|
3
3
|
import type { Keyring as LegacyKeyring, AccountId } from "@metamask/keyring-utils";
|
|
4
4
|
import type { Json } from "@metamask/utils";
|
|
5
|
-
import { KeyringAccountRegistry
|
|
5
|
+
import { KeyringAccountRegistry } from "../keyring-account-registry.cjs";
|
|
6
|
+
import type { KeyringAccountRegistryOptions } from "../keyring-account-registry.cjs";
|
|
6
7
|
/**
|
|
7
8
|
* Basic options for constructing a {@link KeyringWrapper}.
|
|
8
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-wrapper.d.cts","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8B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,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;gBAE5D,OAAO,EAAE,qBAAqB,CAAC,YAAY,CAAC;IAOxD;;;;;;;OAOG;IACH,IAAI,YAAY,IAAI,mBAAmB,CAEtC;IAED;;;;;;;;;;;;OAYG;cACa,QAAQ,CAAC,MAAM,EAC7B,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;;;;OAQG;IACG,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7C;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAEjD;;;;;;;;;OASG;IACG,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC;IAkB/D;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,CACrB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,cAAc,EAAE,CAAC;IAE5B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;;;;OAOG;IACH,aAAa,CAAC,CACZ,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,eAAe,CAAC;IAE3B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAC/D"}
|
|
@@ -2,7 +2,8 @@ import type { KeyringAccount, KeyringRequest } from "@metamask/keyring-api";
|
|
|
2
2
|
import type { CreateAccountOptions, ExportAccountOptions, ExportedAccount, Keyring, KeyringCapabilities, KeyringType } from "@metamask/keyring-api/v2";
|
|
3
3
|
import type { Keyring as LegacyKeyring, AccountId } from "@metamask/keyring-utils";
|
|
4
4
|
import type { Json } from "@metamask/utils";
|
|
5
|
-
import { KeyringAccountRegistry
|
|
5
|
+
import { KeyringAccountRegistry } from "../keyring-account-registry.mjs";
|
|
6
|
+
import type { KeyringAccountRegistryOptions } from "../keyring-account-registry.mjs";
|
|
6
7
|
/**
|
|
7
8
|
* Basic options for constructing a {@link KeyringWrapper}.
|
|
8
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-wrapper.d.mts","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8BAA8B;AAC5E,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,WAAW,EACZ,iCAAiC;AAClC,OAAO,KAAK,EACV,OAAO,IAAI,aAAa,EACxB,SAAS,EACV,gCAAgC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,
|
|
1
|
+
{"version":3,"file":"keyring-wrapper.d.mts","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,8BAA8B;AAC5E,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,WAAW,EACZ,iCAAiC;AAClC,OAAO,KAAK,EACV,OAAO,IAAI,aAAa,EACxB,SAAS,EACV,gCAAgC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,EAAE,sBAAsB,EAAE,wCAAoC;AACrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,wCAAoC;AAEjF;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,YAAY,SAAS,aAAa,IAAI;IACtE;;OAEG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AS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;;;;OAOG;IACH,aAAa,CAAC,CACZ,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,eAAe,CAAC;IAE3B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-wrapper.mjs","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"keyring-wrapper.mjs","sourceRoot":"","sources":["../../src/v2/keyring-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,OAAO,EAAE,KAAK,EAAE,oBAAoB;AAEpC,OAAO,EAAE,sBAAsB,EAAE,wCAAoC;AA4BrE;;;;;;;;;GASG;AACH,MAAM,OAAgB,cAAc;IAyBlC,YAAY,OAA4C;QAnB/C,+CAAmC;QAI5C;;;WAGG;QACM,+BAAQ,IAAI,KAAK,EAAE,EAAC;QAY3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC9B,uBAAA,IAAI,gCAAiB,OAAO,CAAC,YAAY,MAAA,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,YAAY;QACd,OAAO,uBAAA,IAAI,oCAAc,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,QAAQ,CACtB,QAA+B;QAE/B,OAAO,uBAAA,IAAI,4BAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CAAC,KAAW;QAC3B,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;YAC7B,wCAAwC;YACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YAEtB,iCAAiC;YACjC,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAEpC,iDAAiD;YACjD,yEAAyE;YACzE,8DAA8D;YAC9D,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAgBD;;;;;;;;;OASG;IACH,KAAK,CAAC,UAAU,CAAC,SAAoB;QACnC,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,4CAA4C;QAC5C,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAEzB,mCAAmC;QACnC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CA+CF","sourcesContent":["import type { KeyringAccount, KeyringRequest } from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n ExportAccountOptions,\n ExportedAccount,\n Keyring,\n KeyringCapabilities,\n KeyringType,\n} from '@metamask/keyring-api/v2';\nimport type {\n Keyring as LegacyKeyring,\n AccountId,\n} from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\n\nimport { KeyringAccountRegistry } from '../keyring-account-registry';\nimport type { KeyringAccountRegistryOptions } from '../keyring-account-registry';\n\n/**\n * Basic options for constructing a {@link KeyringWrapper}.\n */\nexport type KeyringWrapperOptions<InnerKeyring extends LegacyKeyring> = {\n /**\n * The underlying \"old\" keyring instance that this wrapper adapts.\n */\n inner: InnerKeyring;\n\n /**\n * The concrete keyring type exposed through the V2 interface.\n */\n type: KeyringType;\n\n /**\n * Capabilities of the underlying keyring.\n */\n capabilities: KeyringCapabilities;\n\n /**\n * Options forwarded to the {@link KeyringAccountRegistry} constructor.\n */\n registryOptions?: KeyringAccountRegistryOptions;\n};\n\n/**\n * Generic adapter that turns an existing {@link Keyring} implementation into a\n * {@link Keyring} instance.\n *\n * Consumers are expected to provide concrete mappings between high-level V2\n * operations and the underlying keyring methods (for example BIP-44 account\n * creation, private-key import, and request handling). This class focuses on\n * the common mechanics required by all adapters: state serialization,\n * account-ID/address mapping and basic account management.\n */\nexport abstract class KeyringWrapper<\n InnerKeyring extends LegacyKeyring,\n KeyringAccountType extends KeyringAccount = KeyringAccount,\n> implements Keyring {\n readonly type: `${KeyringType}`;\n\n readonly #capabilities: KeyringCapabilities;\n\n protected readonly inner: InnerKeyring;\n\n /**\n * Mutex to ensure exclusive access to the inner keyring during\n * operations that mutate its state.\n */\n readonly #lock = new Mutex();\n\n /**\n * Registry for KeyringAccount objects.\n * Provides O(1) lookups by AccountId or address.\n *\n * Subclasses should use this registry when creating accounts and\n * clear/update it when deleting accounts or deserializing state.\n */\n protected readonly registry: KeyringAccountRegistry<KeyringAccountType>;\n\n constructor(options: KeyringWrapperOptions<InnerKeyring>) {\n this.inner = options.inner;\n this.type = `${options.type}`;\n this.#capabilities = options.capabilities;\n this.registry = new KeyringAccountRegistry(options.registryOptions);\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Subclasses can override this getter to return capabilities dynamically\n * based on runtime state.\n *\n * @returns The keyring's capabilities.\n */\n get capabilities(): KeyringCapabilities {\n return this.#capabilities;\n }\n\n /**\n * Execute an operation with exclusive access to the inner keyring.\n *\n * This method ensures thread-safety for operations that read or mutate\n * the inner keyring state. All operations that modify the keyring\n * (createAccounts, deleteAccount, deserialize) should use this method\n * to prevent race conditions.\n *\n * Within the callback, use `this.inner` to access the inner keyring.\n *\n * @param callback - A function that performs the operation.\n * @returns The result of the callback.\n */\n protected async withLock<Result>(\n callback: () => Promise<Result>,\n ): Promise<Result> {\n return this.#lock.runExclusive(callback);\n }\n\n /**\n * Serialize the underlying keyring state to a JSON-serializable object.\n *\n * This simply delegates to the legacy keyring's {@link Keyring.serialize}\n * implementation.\n *\n * @returns The serialized keyring state.\n */\n async serialize(): Promise<Json> {\n return this.inner.serialize();\n }\n\n /**\n * Hydrate the underlying keyring from a previously serialized state.\n *\n * This clears the registry, delegates to the legacy keyring's\n * {@link Keyring.deserialize} implementation, and rebuilds the registry\n * by calling {@link getAccounts}.\n *\n * @param state - The serialized keyring state.\n */\n async deserialize(state: Json): Promise<void> {\n await this.withLock(async () => {\n // Clear the registry when deserializing\n this.registry.clear();\n\n // Deserialize the legacy keyring\n await this.inner.deserialize(state);\n\n // Rebuild the registry by calling getAccounts().\n // Subclass implementations of getAccounts() should populate the registry\n // as a side effect (see the abstract method's documentation).\n await this.getAccounts();\n });\n }\n\n /**\n * Return all accounts managed by this keyring.\n *\n * Concrete adapters are responsible for mapping the underlying keyring's\n * notion of accounts (typically addresses returned by\n * {@link Keyring.getAccounts}) into {@link KeyringAccount} objects.\n * Implementations should use the configured {@link KeyringAccountRegistry}\n * to establish the account ID/address mapping so that\n * {@link getAccount} works as expected.\n *\n * @returns The list of managed accounts.\n */\n abstract getAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Look up a single account by its {@link AccountId}.\n *\n * This method first checks the registry for O(1) lookup.\n * If not found, it falls back to calling {@link getAccounts} which\n * should populate the registry as a side effect.\n *\n * @param accountId - The AccountId to look up.\n * @returns The matching KeyringAccount.\n */\n async getAccount(accountId: AccountId): Promise<KeyringAccount> {\n let cached = this.registry.get(accountId);\n if (cached) {\n return cached;\n }\n\n // Prime the registry by calling getAccounts\n await this.getAccounts();\n\n // Try registry again after priming\n cached = this.registry.get(accountId);\n if (!cached) {\n throw new Error(`Account not found for id: ${accountId}`);\n }\n\n return cached;\n }\n\n /**\n * Create one or more new accounts managed by this keyring.\n *\n * Implementations are responsible for interpreting the\n * {@link CreateAccountOptions} (for example BIP-44 derivation or\n * private-key import) and returning the resulting {@link KeyringAccount}\n * objects. Implementors should also ensure that the registry is updated so\n * that {@link getAccount} works for newly created accounts.\n */\n abstract createAccounts(\n options: CreateAccountOptions,\n ): Promise<KeyringAccount[]>;\n\n /**\n * Remove the account associated with the given {@link AccountId} from this\n * keyring.\n *\n * Implementations are expected to translate the ID to an underlying\n * address (typically via the registry) and then invoke the appropriate\n * removal mechanism on the legacy keyring.\n */\n abstract deleteAccount(accountId: AccountId): Promise<void>;\n\n /**\n * Export the secrets associated with the given account in a format\n * described by {@link ExportAccountOptions}.\n *\n * This method is optional, and concrete adapters should only\n * implement it if the underlying keyring supports exporting\n * accounts.\n */\n exportAccount?(\n accountId: AccountId,\n options?: ExportAccountOptions,\n ): Promise<ExportedAccount>;\n\n /**\n * Handle a high-level {@link KeyringRequest} on behalf of this keyring.\n *\n * Concrete adapters are responsible for routing the request's method and\n * parameters to the appropriate legacy keyring APIs (for example signing\n * transactions or decrypting messages) and returning a JSON-serializable\n * result.\n */\n abstract submitRequest(request: KeyringRequest): Promise<Json>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/keyring-sdk",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "MetaMask Keyring SDK",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"keyring",
|
|
7
|
+
"metamask"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://github.com/MetaMask/accounts/tree/main/packages/keyring-sdk#readme",
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/MetaMask/accounts/issues"
|
|
12
12
|
},
|
|
13
|
+
"license": "MIT",
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
15
16
|
"url": "https://github.com/MetaMask/accounts.git"
|
|
16
17
|
},
|
|
17
|
-
"
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"v2.js"
|
|
21
|
+
],
|
|
18
22
|
"sideEffects": false,
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
19
25
|
"exports": {
|
|
20
26
|
".": {
|
|
21
27
|
"import": {
|
|
@@ -39,12 +45,10 @@
|
|
|
39
45
|
},
|
|
40
46
|
"./package.json": "./package.json"
|
|
41
47
|
},
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"v2.js"
|
|
47
|
-
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
|
+
},
|
|
48
52
|
"scripts": {
|
|
49
53
|
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
50
54
|
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
@@ -64,8 +68,8 @@
|
|
|
64
68
|
"dependencies": {
|
|
65
69
|
"@ethereumjs/tx": "^5.4.0",
|
|
66
70
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
67
|
-
"@metamask/keyring-api": "^23.0
|
|
68
|
-
"@metamask/keyring-utils": "^3.
|
|
71
|
+
"@metamask/keyring-api": "^23.1.0",
|
|
72
|
+
"@metamask/keyring-utils": "^3.3.0",
|
|
69
73
|
"@metamask/scure-bip39": "^2.1.1",
|
|
70
74
|
"@metamask/superstruct": "^3.1.0",
|
|
71
75
|
"@metamask/utils": "^11.11.0",
|
|
@@ -76,7 +80,7 @@
|
|
|
76
80
|
"devDependencies": {
|
|
77
81
|
"@lavamoat/allow-scripts": "^3.2.1",
|
|
78
82
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
79
|
-
"@metamask/auto-changelog": "^
|
|
83
|
+
"@metamask/auto-changelog": "^6.1.0",
|
|
80
84
|
"@ts-bridge/cli": "^0.6.3",
|
|
81
85
|
"@types/jest": "^29.5.12",
|
|
82
86
|
"@types/node": "^20.12.12",
|
|
@@ -90,24 +94,20 @@
|
|
|
90
94
|
"ts-node": "^10.9.2",
|
|
91
95
|
"tsd": "^0.31.0",
|
|
92
96
|
"typedoc": "^0.25.13",
|
|
93
|
-
"typescript": "~5.
|
|
97
|
+
"typescript": "~5.3.3"
|
|
98
|
+
},
|
|
99
|
+
"tsd": {
|
|
100
|
+
"compilerOptions": {
|
|
101
|
+
"composite": "false"
|
|
102
|
+
},
|
|
103
|
+
"directory": "src"
|
|
94
104
|
},
|
|
95
105
|
"engines": {
|
|
96
106
|
"node": "^18.18 || >=20"
|
|
97
107
|
},
|
|
98
|
-
"publishConfig": {
|
|
99
|
-
"access": "public",
|
|
100
|
-
"registry": "https://registry.npmjs.org/"
|
|
101
|
-
},
|
|
102
108
|
"lavamoat": {
|
|
103
109
|
"allowScripts": {
|
|
104
110
|
"@lavamoat/preinstall-always-fail": false
|
|
105
111
|
}
|
|
106
|
-
},
|
|
107
|
-
"tsd": {
|
|
108
|
-
"directory": "src",
|
|
109
|
-
"compilerOptions": {
|
|
110
|
-
"composite": "false"
|
|
111
|
-
}
|
|
112
112
|
}
|
|
113
113
|
}
|