@metamask-previews/eth-snap-keyring 22.3.0-e51c895 → 22.4.0-5951828
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 +21 -1
- package/dist/SnapKeyring.cjs +31 -16
- package/dist/SnapKeyring.cjs.map +1 -1
- package/dist/SnapKeyring.d.cts +1 -1
- package/dist/SnapKeyring.d.cts.map +1 -1
- package/dist/SnapKeyring.d.mts +1 -1
- package/dist/SnapKeyring.d.mts.map +1 -1
- package/dist/SnapKeyring.mjs +31 -16
- package/dist/SnapKeyring.mjs.map +1 -1
- package/dist/SnapKeyringV1.cjs +16 -2
- package/dist/SnapKeyringV1.cjs.map +1 -1
- package/dist/SnapKeyringV1.d.cts +21 -2
- package/dist/SnapKeyringV1.d.cts.map +1 -1
- package/dist/SnapKeyringV1.d.mts +21 -2
- package/dist/SnapKeyringV1.d.mts.map +1 -1
- package/dist/SnapKeyringV1.mjs +16 -2
- package/dist/SnapKeyringV1.mjs.map +1 -1
- package/dist/events.cjs +4 -5
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +4 -4
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +4 -4
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +1 -2
- package/dist/events.mjs.map +1 -1
- package/dist/v2/SnapKeyring.cjs +202 -58
- package/dist/v2/SnapKeyring.cjs.map +1 -1
- package/dist/v2/SnapKeyring.d.cts +67 -24
- package/dist/v2/SnapKeyring.d.cts.map +1 -1
- package/dist/v2/SnapKeyring.d.mts +67 -24
- package/dist/v2/SnapKeyring.d.mts.map +1 -1
- package/dist/v2/SnapKeyring.mjs +202 -58
- package/dist/v2/SnapKeyring.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapKeyringV1.d.cts","sourceRoot":"","sources":["../src/SnapKeyringV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IAcjC;;;;;;;OAOG;IACG,iBAAiB,CACrB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC;IAmalB;;;;;;;;OAQG;IACH,SAAS,CAAC,kBAAkB,CAC1B,OAAO,EAAE,cAAc,GACtB,cAAc,GAAG,SAAS;CA+D9B"}
|
package/dist/SnapKeyringV1.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import type { TypedDataV1, TypedMessage } from "@metamask/eth-sig-util";
|
|
|
3
3
|
import { SignTypedDataVersion } from "@metamask/eth-sig-util";
|
|
4
4
|
import type { KeyringAccount, BtcMethod, CaipChainId, ResolvedAccountAddress, KeyringExecutionContext, EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch } from "@metamask/keyring-api";
|
|
5
5
|
import { EthMethod } from "@metamask/keyring-api";
|
|
6
|
+
import type { CreateAccountOptions } from "@metamask/keyring-api/v2";
|
|
6
7
|
import { KeyringInternalSnapClient } from "@metamask/keyring-internal-snap-client";
|
|
7
8
|
import { KeyringAccountRegistry } from "@metamask/keyring-sdk";
|
|
8
9
|
import type { AccountId, JsonRpcRequest } from "@metamask/keyring-utils";
|
|
@@ -72,6 +73,12 @@ export type SnapKeyringV1Options = {
|
|
|
72
73
|
* Defaults to `false`.
|
|
73
74
|
*/
|
|
74
75
|
isAnyAccountTypeAllowed?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Account registry to use. When provided (e.g. by a owning `SnapKeyring`
|
|
78
|
+
* v2 instance), the registry is shared by reference. When omitted, a new
|
|
79
|
+
* registry is created (useful for standalone / test usage).
|
|
80
|
+
*/
|
|
81
|
+
registry?: KeyringAccountRegistry;
|
|
75
82
|
};
|
|
76
83
|
/**
|
|
77
84
|
* Per-snap coordinator for the v1 (event-driven) keyring flow.
|
|
@@ -110,7 +117,7 @@ export declare class SnapKeyringV1 {
|
|
|
110
117
|
* @returns The internal snap client.
|
|
111
118
|
*/
|
|
112
119
|
protected get client(): KeyringInternalSnapClient;
|
|
113
|
-
constructor({ messenger, callbacks, isAnyAccountTypeAllowed, }: SnapKeyringV1Options);
|
|
120
|
+
constructor({ messenger, callbacks, isAnyAccountTypeAllowed, registry, }: SnapKeyringV1Options);
|
|
114
121
|
/**
|
|
115
122
|
* Bind this keyring to a snap ID and create the internal snap client.
|
|
116
123
|
*
|
|
@@ -120,7 +127,7 @@ export declare class SnapKeyringV1 {
|
|
|
120
127
|
* @param snapId - The snap ID to bind this keyring to.
|
|
121
128
|
* @throws If the keyring is already bound to a different snap ID.
|
|
122
129
|
*/
|
|
123
|
-
|
|
130
|
+
bindSnapId(snapId: SnapId): void;
|
|
124
131
|
/**
|
|
125
132
|
* Destroy this keyring, rejecting any pending requests.
|
|
126
133
|
*
|
|
@@ -140,6 +147,18 @@ export declare class SnapKeyringV1 {
|
|
|
140
147
|
* @returns The account object returned by the snap.
|
|
141
148
|
*/
|
|
142
149
|
createAccount(options: Record<string, Json>, internalOptions?: SnapKeyringInternalOptions): Promise<KeyringAccount>;
|
|
150
|
+
/**
|
|
151
|
+
* Create one or more accounts using the v1 synchronous RPC flow.
|
|
152
|
+
*
|
|
153
|
+
* Delegates to the v1 internal snap client, which wraps `options` in
|
|
154
|
+
* `{ options }` before sending `keyring_createAccounts` — unlike the v2
|
|
155
|
+
* client which sends flat `options`. Called by `SnapKeyring` (v2) when the
|
|
156
|
+
* snap has no declared capabilities (i.e. it is a v1 snap).
|
|
157
|
+
*
|
|
158
|
+
* @param options - Account creation options forwarded to the snap.
|
|
159
|
+
* @returns The array of accounts returned by the snap.
|
|
160
|
+
*/
|
|
161
|
+
createAccounts(options: CreateAccountOptions): Promise<KeyringAccount[]>;
|
|
143
162
|
/**
|
|
144
163
|
* Handle an incoming message from the Snap.
|
|
145
164
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapKeyringV1.d.mts","sourceRoot":"","sources":["../src/SnapKeyringV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,+BAA+B;AACxE,OAAO,EAAE,oBAAoB,EAAE,+BAA+B;AAC9D,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,8BAA8B;AAC/B,OAAO,EAEL,SAAS,EAQV,8BAA8B;
|
|
1
|
+
{"version":3,"file":"SnapKeyringV1.d.mts","sourceRoot":"","sources":["../src/SnapKeyringV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,+BAA+B;AACxE,OAAO,EAAE,oBAAoB,EAAE,+BAA+B;AAC9D,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,8BAA8B;AAC/B,OAAO,EAEL,SAAS,EAQV,8BAA8B;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,iCAAiC;AAErE,OAAO,EAAE,yBAAyB,EAAE,+CAA+C;AACnF,OAAO,EAAE,sBAAsB,EAAE,8BAA8B;AAM/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC;AAGzE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAO,IAAI,EAAmB,wBAAwB;AAqBlE,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAkB;AAE5D,OAAO,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AAE,cAAc,EACvB,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,oBAAoB,CAAC;IAchC;;;;;;;;OAQG;IACG,kBAAkB,CACtB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IAcjC;;;;;;;OAOG;IACG,iBAAiB,CACrB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC;IAmalB;;;;;;;;OAQG;IACH,SAAS,CAAC,kBAAkB,CAC1B,OAAO,EAAE,cAAc,GACtB,cAAc,GAAG,SAAS;CA+D9B"}
|
package/dist/SnapKeyringV1.mjs
CHANGED
|
@@ -70,7 +70,7 @@ export class SnapKeyringV1 {
|
|
|
70
70
|
get client() {
|
|
71
71
|
return this.context.client;
|
|
72
72
|
}
|
|
73
|
-
constructor({ messenger, callbacks, isAnyAccountTypeAllowed = false, }) {
|
|
73
|
+
constructor({ messenger, callbacks, isAnyAccountTypeAllowed = false, registry, }) {
|
|
74
74
|
_SnapKeyringV1_instances.add(this);
|
|
75
75
|
/** Snap ID and RPC client. Set via {@link bindSnapId}. */
|
|
76
76
|
_SnapKeyringV1_context.set(this, void 0);
|
|
@@ -92,7 +92,7 @@ export class SnapKeyringV1 {
|
|
|
92
92
|
* The currently selected account IDs for this snap.
|
|
93
93
|
*/
|
|
94
94
|
_SnapKeyringV1_selectedAccounts.set(this, void 0);
|
|
95
|
-
this.registry = new KeyringAccountRegistry();
|
|
95
|
+
this.registry = registry ?? new KeyringAccountRegistry();
|
|
96
96
|
this.messenger = messenger;
|
|
97
97
|
__classPrivateFieldSet(this, _SnapKeyringV1_callbacks, callbacks, "f");
|
|
98
98
|
__classPrivateFieldSet(this, _SnapKeyringV1_isAnyAccountTypeAllowed, isAnyAccountTypeAllowed, "f");
|
|
@@ -152,6 +152,20 @@ export class SnapKeyringV1 {
|
|
|
152
152
|
async createAccount(options, internalOptions) {
|
|
153
153
|
return __classPrivateFieldGet(this, _SnapKeyringV1_instances, "m", _SnapKeyringV1_createSnapAccount).call(this, options, internalOptions);
|
|
154
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Create one or more accounts using the v1 synchronous RPC flow.
|
|
157
|
+
*
|
|
158
|
+
* Delegates to the v1 internal snap client, which wraps `options` in
|
|
159
|
+
* `{ options }` before sending `keyring_createAccounts` — unlike the v2
|
|
160
|
+
* client which sends flat `options`. Called by `SnapKeyring` (v2) when the
|
|
161
|
+
* snap has no declared capabilities (i.e. it is a v1 snap).
|
|
162
|
+
*
|
|
163
|
+
* @param options - Account creation options forwarded to the snap.
|
|
164
|
+
* @returns The array of accounts returned by the snap.
|
|
165
|
+
*/
|
|
166
|
+
async createAccounts(options) {
|
|
167
|
+
return this.client.createAccounts(options);
|
|
168
|
+
}
|
|
155
169
|
/**
|
|
156
170
|
* Handle an incoming message from the Snap.
|
|
157
171
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SnapKeyringV1.mjs","sourceRoot":"","sources":["../src/SnapKeyringV1.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB;AAEpD,OAAO,EAAE,oBAAoB,EAAE,+BAA+B;AAY9D,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,EACZ,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,qCAAqC,EACtC,8BAA8B;AAC/B,OAAO,EAAE,6BAA6B,EAAE,uCAAuC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,+CAA+C;AACnF,OAAO,EAAE,sBAAsB,EAAE,8BAA8B;AAC/D,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACzB,mCAAmC;AAGpC,OAAO,EAAE,UAAU,EAAE,gCA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AC,SAAS,EAAE,OAAO,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,6CAAsB,QAG1B;IACC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,QAAQ,CAAC;IACzD,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IACjE,IAAI,GAAG,EAAE,CAAC;QACR,uBAAA,IAAI,oEAAqB,MAAzB,IAAI,EAAsB,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,MAAM,uBAAA,IAAI,gCAAW,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC,mFAQoB,GAAW;IAC9B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,MAAM,cAAc,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,cAAc,GAClB,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,EAAE,cAAc;QACrE,EAAE,CAAC;IACL,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,uCAAuC,IAAI,CAAC,MAAM,GAAG,CACpF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';\nimport { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport type {\n KeyringAccount,\n BtcMethod,\n CaipChainId,\n ResolvedAccountAddress,\n KeyringExecutionContext,\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '@metamask/keyring-api';\nimport {\n AnyAccountType,\n EthMethod,\n KeyringEvent,\n EthBytesStruct,\n EthBaseUserOperationStruct,\n EthUserOperationPatchStruct,\n AccountBalancesUpdatedEventStruct,\n AccountAssetListUpdatedEventStruct,\n AccountTransactionsUpdatedEventStruct,\n} from '@metamask/keyring-api';\nimport { toKeyringRequestWithoutOrigin } from '@metamask/keyring-internal-api';\nimport { KeyringInternalSnapClient } from '@metamask/keyring-internal-snap-client';\nimport { KeyringAccountRegistry } from '@metamask/keyring-sdk';\nimport {\n GetSelectedAccountsRequestStruct,\n SnapManageAccountsMethod,\n} from '@metamask/keyring-snap-sdk';\nimport type { GetSelectedAccountsResponse } from '@metamask/keyring-snap-sdk';\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport { strictMask } from '@metamask/keyring-utils';\nimport type { ExtractEventPayload } from '@metamask/messenger';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { assert, mask, object, string } from '@metamask/superstruct';\nimport type { Hex, Json, DeferredPromise } from '@metamask/utils';\nimport {\n bigIntToHex,\n hasProperty,\n KnownCaipNamespace,\n toCaipChainId,\n createDeferredPromise,\n} from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport { normalizeAccount, transformAccount } from './account';\nimport { normalizeAccountAddress } from './account';\nimport {\n AccountCreatedEventStruct,\n AccountUpdatedEventStruct,\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n} from './events';\nimport { projectLogger as log } from './logger';\nimport { getInternalOptionsOf } from './options';\nimport type { SnapKeyringInternalOptions } from './options';\nimport { PLATFORM_VERSION_FOR_KEYRING_REQUEST_WITH_ORIGIN } from './platform-versions';\nimport type {\n SnapKeyringEvents,\n SnapKeyringMessenger,\n} from './SnapKeyringMessenger';\nimport type { SnapMessage } from './types';\nimport { SnapMessageStruct } from './types';\nimport { equalsIgnoreCase, sanitizeUrl, throwError, toJson } from './util';\n\n// TODO: to be removed when this is added to the keyring-api\nexport type AccountMethod = EthMethod | BtcMethod;\n\n/**\n * Holds the snap ID and its RPC client once a {@link SnapKeyringV1} instance\n * has been bound via {@link SnapKeyringV1.bindSnapId}.\n */\ntype SnapKeyringV1Context = {\n snapId: SnapId;\n client: KeyringInternalSnapClient;\n};\n\n/**\n * Callback type to filter unknown account ID from a mapping account ID mapping.\n */\ntype FilterAccountIdFunction = <Entry>(\n accountMapping: Record<AccountId, Entry>,\n) => Record<AccountId, Entry>;\n\n/**\n * Callbacks injected by the parent `SnapKeyring` to delegate global concerns.\n *\n * These cover operations that span multiple snaps or require parent-level\n * coordination (account approval UI, persistence, global uniqueness checks).\n */\nexport type SnapKeyringV1Callbacks = {\n /**\n * Called when a new account is being created (v1 event-driven flow).\n * Handles the user-approval dialog and account registration in the UI.\n */\n addAccount: (\n address: string,\n snapId: SnapId,\n handleUserInput: (accepted: boolean) => Promise<void>,\n onceSaved: Promise<AccountId>,\n accountNameSuggestion?: string,\n internalOptions?: SnapKeyringInternalOptions,\n ) => Promise<void>;\n\n /**\n * Called when an account is being deleted.\n * Handles the user-approval dialog and account removal in the UI.\n */\n removeAccount: (\n address: string,\n snapId: SnapId,\n handleUserInput: (accepted: boolean) => Promise<void>,\n ) => Promise<void>;\n\n /**\n * Persist keyring state to disk via KeyringController.\n */\n saveState: () => Promise<void>;\n\n /**\n * Redirect the user to a URL after an async snap request.\n */\n redirectUser: (snapId: SnapId, url: string, message: string) => Promise<void>;\n\n /**\n * Check global uniqueness (address + ID). Throws if the account cannot be used.\n * Must remain in the parent because it checks cross-snap invariants.\n */\n assertAccountCanBeUsed: (account: KeyringAccount) => Promise<void>;\n\n /**\n * Called synchronously whenever a new account is added to the registry.\n * Optional — consumers that don't need cross-instance indexing can omit this.\n */\n onRegister?: (accountId: AccountId) => void;\n\n /**\n * Called synchronously whenever an account is removed from the registry.\n * Optional — consumers that don't need cross-instance indexing can omit this.\n */\n onUnregister?: (accountId: AccountId) => void;\n};\n\n/**\n * Options for creating a `SnapKeyringV1` instance.\n */\nexport type SnapKeyringV1Options = {\n messenger: SnapKeyringMessenger;\n callbacks: SnapKeyringV1Callbacks;\n /**\n * Whether to allow the creation and update of generic accounts.\n * Defaults to `false`.\n */\n isAnyAccountTypeAllowed?: boolean;\n};\n\n/**\n * Per-snap coordinator for the v1 (event-driven) keyring flow.\n *\n * Each instance is scoped to exactly one `SnapId`. It handles all Snap\n * keyring events (account lifecycle, request approval, asset updates) and\n * owns the per-snap request / internal-options state.\n *\n * Designed to be subclassed: `SnapKeyringV2` extends this class and adds the\n * `KeyringV2` interface on top, sharing the same registry and client.\n */\nexport class SnapKeyringV1 {\n /** Snap ID and RPC client. Set via {@link bindSnapId}. */\n #context: SnapKeyringV1Context | undefined;\n\n /** Account registry — shared with subclass (e.g. SnapKeyringV2). */\n protected readonly registry: KeyringAccountRegistry;\n\n /** Messenger for snap controller calls and event publishing. */\n protected readonly messenger: SnapKeyringMessenger;\n\n /** Injected callbacks for parent-level coordination. */\n readonly #callbacks: SnapKeyringV1Callbacks;\n\n /** Whether to allow the creation and update of generic accounts. */\n readonly #isAnyAccountTypeAllowed: boolean;\n\n /**\n * Pending async request promises, keyed by request ID.\n * Plain Map is sufficient here since this instance is already snap-scoped.\n */\n readonly #requests: Map<string, DeferredPromise<any>>;\n\n /**\n * Correlation ID -> internal options, used to thread options from\n * `createAccount` through to the `AccountCreated` event handler.\n */\n readonly #options: Map<string, SnapKeyringInternalOptions>;\n\n /**\n * The currently selected account IDs for this snap.\n */\n #selectedAccounts: AccountId[];\n\n /**\n * Initialized context (snap ID + RPC client).\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The initialized context.\n */\n protected get context(): SnapKeyringV1Context {\n if (this.#context === undefined) {\n throw new Error(\n 'SnapKeyring has not been initialized: call deserialize() first',\n );\n }\n return this.#context;\n }\n\n /**\n * The snap ID this instance is scoped to.\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The snap ID.\n */\n get snapId(): SnapId {\n return this.context.snapId;\n }\n\n /**\n * Snap client for keyring RPC calls.\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The internal snap client.\n */\n protected get client(): KeyringInternalSnapClient {\n return this.context.client;\n }\n\n constructor({\n messenger,\n callbacks,\n isAnyAccountTypeAllowed = false,\n }: SnapKeyringV1Options) {\n this.registry = new KeyringAccountRegistry();\n this.messenger = messenger;\n this.#callbacks = callbacks;\n this.#isAnyAccountTypeAllowed = isAnyAccountTypeAllowed;\n this.#requests = new Map();\n this.#options = new Map();\n this.#selectedAccounts = [];\n }\n\n /**\n * Bind this keyring to a snap ID and create the internal snap client.\n *\n * Idempotent for the same `snapId`; throws if called again with a different\n * one to prevent accidentally swapping a keyring's identity.\n *\n * @param snapId - The snap ID to bind this keyring to.\n * @throws If the keyring is already bound to a different snap ID.\n */\n protected bindSnapId(snapId: SnapId): void {\n if (this.#context !== undefined && this.#context.snapId !== snapId) {\n throw new Error(\n `SnapKeyring bound to '${this.#context.snapId}' cannot be rebound to '${snapId}'`,\n );\n }\n if (this.#context === undefined) {\n this.#context = {\n snapId,\n client: new KeyringInternalSnapClient({\n messenger: this.messenger,\n snapId,\n }),\n };\n }\n }\n\n // ──────────────────────────────────────────────\n // Public API\n // ──────────────────────────────────────────────\n\n /**\n * Destroy this keyring, rejecting any pending requests.\n *\n * Called when the per-snap entry is removed from the parent `SnapKeyring`,\n * either because all accounts were deleted or because state was re-deserialized.\n */\n async destroy(): Promise<void> {\n for (const promise of this.#requests.values()) {\n promise.reject(\n new Error(`Keyring for snap '${this.snapId}' has been destroyed`),\n );\n }\n this.#requests.clear();\n }\n\n /**\n * Create a single account using the v1 event-driven flow.\n *\n * Handles the reserved 'metamask' field, correlation IDs, and internal\n * options registration. The account is ultimately added to the registry\n * via the `AccountCreated` event handler, not the return value.\n *\n * @param options - Account creation options.\n * @param internalOptions - Internal Snap keyring options.\n * @returns The account object returned by the snap.\n */\n async createAccount(\n options: Record<string, Json>,\n internalOptions?: SnapKeyringInternalOptions,\n ): Promise<KeyringAccount> {\n return this.#createSnapAccount(options, internalOptions);\n }\n\n /**\n * Handle an incoming message from the Snap.\n *\n * Routes the message to the appropriate private handler based on the method.\n *\n * @param message - The message sent by the Snap.\n * @returns The execution result.\n */\n async handleKeyringSnapMessage(message: SnapMessage): Promise<Json> {\n assert(message, SnapMessageStruct);\n switch (message.method) {\n case `${KeyringEvent.AccountCreated}`: {\n return this.#handleAccountCreated(message);\n }\n\n case `${KeyringEvent.AccountUpdated}`: {\n return this.#handleAccountUpdated(message);\n }\n\n case `${KeyringEvent.AccountDeleted}`: {\n return this.#handleAccountDeleted(message);\n }\n\n case `${KeyringEvent.RequestApproved}`: {\n return this.#handleRequestApproved(message);\n }\n\n case `${KeyringEvent.RequestRejected}`: {\n return this.#handleRequestRejected(message);\n }\n\n case `${KeyringEvent.AccountBalancesUpdated}`: {\n return this.#handleAccountBalancesUpdated(message);\n }\n\n case `${KeyringEvent.AccountAssetListUpdated}`: {\n return this.#handleAccountAssetListUpdated(message);\n }\n\n case `${KeyringEvent.AccountTransactionsUpdated}`: {\n return this.#handleAccountTransactionsUpdated(message);\n }\n\n case `${SnapManageAccountsMethod.GetSelectedAccounts}`: {\n return this.#handleGetSelectedAccounts(message);\n }\n\n default:\n throw new Error(`Method not supported: ${message.method}`);\n }\n }\n\n /**\n * Submit a snap request for the given account.\n *\n * Manages the request promise lifecycle (creation, resolution, cleanup) and\n * handles both synchronous and asynchronous (redirect) responses.\n *\n * @param options - The request options.\n * @param options.origin - The sender origin.\n * @param options.account - The account to submit the request for.\n * @param options.method - The method to call.\n * @param options.params - The method parameters.\n * @param options.scope - The CAIP-2 chain ID.\n * @param options.noPending - Whether the response is allowed to be pending.\n * @returns A promise that resolves to the keyring response.\n */\n async submitSnapRequest<Response extends Json>({\n origin,\n account,\n method,\n params,\n scope,\n noPending,\n }: {\n origin: string;\n account: KeyringAccount;\n method: AccountMethod;\n params?: Json[] | Record<string, Json> | undefined;\n scope: string;\n noPending: boolean;\n }): Promise<Response> {\n if (!(account.methods as AccountMethod[]).includes(method)) {\n throw new Error(\n `Method '${method}' not supported for account ${account.address}`,\n );\n }\n\n // Will both catch `undefined` and \"empty\" origins.\n if (!origin?.trim()) {\n throw new Error('An `origin` is required');\n }\n\n const requestId = uuid();\n\n // Create the promise before calling the Snap to prevent a race condition\n // where the Snap responds before we have a chance to create it.\n const requestPromise = this.#createRequestPromise<Response>(requestId);\n\n try {\n const useOrigin = this.messenger.call(\n 'SnapController:isMinimumPlatformVersion',\n this.snapId,\n PLATFORM_VERSION_FOR_KEYRING_REQUEST_WITH_ORIGIN,\n );\n\n const request = {\n id: requestId,\n origin,\n scope,\n account: account.id,\n request: {\n method,\n ...(params !== undefined && { params }),\n },\n };\n\n log('Submit Snap request: ', request);\n\n let response;\n if (useOrigin) {\n response = await this.client.submitRequest(request);\n } else {\n response = await this.client.submitRequestWithoutOrigin(\n toKeyringRequestWithoutOrigin(request),\n );\n }\n\n if (noPending && response.pending) {\n throw new Error(\n `Request '${requestId}' to Snap '${this.snapId}' is pending and noPending is true.`,\n );\n }\n\n if (!response.pending) {\n this.#requests.delete(requestId);\n return response.result as Response;\n }\n\n if (response.redirect?.message || response.redirect?.url) {\n await this.#handleAsyncRedirect(response.redirect);\n }\n\n return requestPromise.promise;\n } catch (error) {\n log('Snap Request failed: ', { requestId });\n this.#requests.delete(requestId);\n throw error;\n }\n }\n\n /**\n * Update the selected accounts for this snap.\n *\n * @param accountIds - The account IDs to set as selected.\n */\n async setSelectedAccounts(accountIds: AccountId[]): Promise<void> {\n this.#selectedAccounts = accountIds;\n try {\n await this.client.setSelectedAccounts(accountIds);\n } catch (error: any) {\n console.error(\n `Failed to set selected accounts for ${this.snapId} snap: '${error.message}'`,\n );\n }\n }\n\n /**\n * Resolve the account address associated with a signing request.\n *\n * Delegates directly to the snap-scoped client, which already has the\n * snap ID baked in from construction time.\n *\n * @param scope - CAIP-2 chain ID.\n * @param request - Signing request object.\n * @returns The resolved address if found, `null` otherwise.\n */\n async resolveAccountAddress(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null> {\n return this.client.resolveAccountAddress(scope, request);\n }\n\n /**\n * Sign a transaction for the given account.\n *\n * @param account - The account to sign the transaction for.\n * @param transaction - The transaction to sign.\n * @param _opts - Transaction options (unused).\n * @returns A promise that resolves to the signed transaction.\n */\n async signTransaction(\n account: KeyringAccount,\n transaction: TypedTransaction,\n /* istanbul ignore next */\n _opts = {},\n ): Promise<Json | TypedTransaction> {\n const chainId = transaction.common.chainId();\n const tx = toJson({\n ...transaction.toJSON(),\n from: normalizeAccountAddress(account),\n type: `0x${transaction.type.toString(16)}`,\n chainId: bigIntToHex(chainId),\n });\n\n const signedTx = await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.SignTransaction,\n params: [tx],\n scope: toCaipChainId(KnownCaipNamespace.Eip155, `${chainId}`),\n noPending: false,\n });\n\n // ! It's *** CRITICAL *** that we mask the signature here, otherwise the\n // ! Snap could overwrite the transaction.\n const signature = mask(\n signedTx,\n object({\n r: string(),\n s: string(),\n v: string(),\n }),\n );\n\n return TransactionFactory.fromTxData({\n ...(tx as Record<string, Json>),\n r: signature.r as Hex,\n s: signature.s as Hex,\n v: signature.v as Hex,\n });\n }\n\n /**\n * Sign a typed data message for the given account.\n *\n * @param account - The account to sign the typed data for.\n * @param data - The typed data to sign.\n * @param opts - Signing options.\n * @param opts.version - The typed data version to use.\n * @returns A promise that resolves to the signature.\n */\n async signTypedData(\n account: KeyringAccount,\n data: Record<string, unknown>[] | TypedDataV1 | TypedMessage<any>,\n opts: { version: SignTypedDataVersion },\n ): Promise<string> {\n const methods = {\n [SignTypedDataVersion.V1]: EthMethod.SignTypedDataV1,\n [SignTypedDataVersion.V3]: EthMethod.SignTypedDataV3,\n [SignTypedDataVersion.V4]: EthMethod.SignTypedDataV4,\n };\n\n // Use 'V1' by default to match other keyring implementations. V1 will be\n // used if the version is not specified or not supported.\n const method = methods[opts.version] || EthMethod.SignTypedDataV1;\n\n // Extract chain ID as if it was a typed message (as defined by EIP-712), if\n // input is not a typed message, then chain ID will be undefined!\n const chainId = (data as TypedMessage<any>).domain?.chainId;\n\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method,\n params: toJson<Json[]>([address, data]),\n scope:\n chainId === undefined\n ? ''\n : toCaipChainId(KnownCaipNamespace.Eip155, `${chainId}`),\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a message (eth_sign) for the given account.\n *\n * @param account - The account to sign the message for.\n * @param hash - The data to sign.\n * @returns A promise that resolves to the signature.\n */\n async signMessage(account: KeyringAccount, hash: any): Promise<string> {\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.Sign,\n params: toJson<Json[]>([address, hash]),\n scope: '',\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a personal message for the given account.\n *\n * Note: KeyringController says this should return a Buffer but it actually\n * expects a string.\n *\n * @param account - The account to sign the message for.\n * @param data - The data to sign.\n * @returns A promise that resolves to the signature.\n */\n async signPersonalMessage(\n account: KeyringAccount,\n data: any,\n ): Promise<string> {\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PersonalSign,\n params: toJson<Json[]>([data, address]),\n scope: '',\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param account - The account to prepare the user operation for.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real one.\n */\n async prepareUserOperation(\n account: KeyringAccount,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PrepareUserOperation,\n params: toJson<Json[]>(transactions),\n noPending: true,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthBaseUserOperationStruct,\n );\n }\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param account - The account to patch the user operation for.\n * @param userOp - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n */\n async patchUserOperation(\n account: KeyringAccount,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PatchUserOperation,\n params: toJson<Json[]>([userOp]),\n noPending: true,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthUserOperationPatchStruct,\n );\n }\n\n /**\n * Signs a UserOperation.\n *\n * @param account - The account to sign the user operation for.\n * @param userOp - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns A promise that resolves to the signature.\n */\n async signUserOperation(\n account: KeyringAccount,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.SignUserOperation,\n params: toJson<Json[]>([userOp]),\n noPending: false,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthBytesStruct,\n );\n }\n\n // ──────────────────────────────────────────────\n // Private handlers\n // ──────────────────────────────────────────────\n\n /**\n * Handle an Account Created event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountCreated(message: SnapMessage): Promise<null> {\n assert(message, AccountCreatedEventStruct);\n const {\n metamask,\n account: newAccountFromEvent,\n accountNameSuggestion,\n displayAccountNameSuggestion,\n displayConfirmation,\n } = message.params;\n\n // READ THIS CAREFULLY:\n // ------------------------------------------------------------------------\n // The account creation flow is now asynchronous. We expect the Snap to\n // first create the account data and then fire the \"AccountCreated\" event.\n\n // Potentially migrate the account.\n const account = normalizeAccount(transformAccount(newAccountFromEvent));\n const { address } = account;\n\n if (this.getExistingAccount(account)) {\n // If the account already exists, we skip it.\n return null;\n }\n\n // Make sure this new account is valid.\n await this.#callbacks.assertAccountCanBeUsed(account);\n\n // A deferred promise that will be resolved once the Snap keyring has saved\n // its internal state.\n // This part of the flow is run asynchronously, so we have no other way of\n // letting the MetaMask client that this \"save\" has been run.\n // NOTE: Another way of fixing that could be to rely on events through the\n // messenger maybe?\n const onceSaved = createDeferredPromise<AccountId>();\n\n // Add the account to the keyring, but wait for the MetaMask client to\n // approve the account creation first.\n await this.#callbacks.addAccount(\n address,\n this.snapId,\n // This callback is passed to the MetaMask client, it will be called whenever\n // the end user will accept or not the account creation.\n async (accepted: boolean) => {\n if (accepted) {\n // We consider the account to be created on the Snap keyring only if\n // the user accepted it. Meaning that the Snap MIGHT HAVE created the\n // account on its own state, but the Snap keyring MIGHT NOT HAVE it yet.\n //\n // e.g The account creation dialog crashed on MetaMask, this callback\n // will never be called, but the Snap still has the account.\n this.registry.set(account);\n this.#callbacks.onRegister?.(account.id);\n\n // This is the \"true async part\". We do not `await` for this call, mainly\n // because this callback will persist the account on the client side\n // (through the `AccountsController`).\n //\n // Since this will happen after the Snap account creation and Snap\n // event, if anything goes wrong, we will delete the account by\n // calling `deleteAccount` on the Snap.\n // eslint-disable-next-line no-void\n void this.#callbacks\n .saveState()\n .then(() => {\n // This allows the MetaMask client to be \"notified\" when then\n // Snap keyring has truly persisted its state. From there, we should\n // be able to use the account (e.g. to display account creation\n // confirmation dialogs).\n onceSaved.resolve(account.id);\n })\n .catch(\n /* istanbul ignore next */\n async (error: unknown) => {\n // FIXME: There's a potential race condition here, if the Snap did\n // not persist the account yet (this should mostly be for older Snaps).\n this.registry.delete(account.id);\n this.#callbacks.onUnregister?.(account.id);\n await this.client\n .deleteAccount(account.id)\n /* istanbul ignore next */\n .catch((deleteError: unknown) => {\n console.error(\n `Account '${account.id}' may not have been removed from snap '${this.snapId}':`,\n deleteError,\n );\n });\n\n // This allows the MetaMask client to be \"notified\" that something went\n // wrong with the Snap keyring. (e.g. useful to display account creation\n // error dialogs).\n onceSaved.reject(error);\n },\n );\n }\n },\n onceSaved.promise,\n accountNameSuggestion,\n getInternalOptionsOf([\n // 1. We use the internal options from the Snap keyring.\n this.#getInternalOptions(metamask?.correlationId) ?? {},\n // 2. We use the ones coming from the Snap.\n {\n displayConfirmation,\n displayAccountNameSuggestion,\n },\n ]),\n );\n\n return null;\n }\n\n /**\n * Handle an Account Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountUpdatedEventStruct);\n const { account: newAccountFromEvent } = message.params;\n const oldAccount =\n this.registry.get(newAccountFromEvent.id) ??\n throwError(`Account '${newAccountFromEvent.id}' not found`);\n\n // Potentially migrate the account.\n const newAccount = transformAccount(newAccountFromEvent);\n\n // The `AnyAccountType.Account` generic account type is allowed only during\n // development, so we check whether it's allowed before continuing.\n //\n // An account cannot be updated if the `isAnyAccountTypeAllowed` flag is\n // set to `false` and the new or old account is a generic account.\n const isGenericAccountInvolved =\n newAccount.type === AnyAccountType.Account ||\n oldAccount.type === AnyAccountType.Account;\n\n if (!this.#isAnyAccountTypeAllowed && isGenericAccountInvolved) {\n throw new Error(`Cannot update generic account '${newAccount.id}'`);\n }\n\n // The address of the account cannot be changed. In the future, we will\n // support changing the address of an account since it will be required to\n // support UTXO-based chains.\n if (!equalsIgnoreCase(oldAccount.address, newAccount.address)) {\n throw new Error(`Cannot change address of account '${newAccount.id}'`);\n }\n\n this.registry.set(newAccount);\n await this.#callbacks.saveState();\n return null;\n }\n\n /**\n * Handle an Account Deleted event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountDeleted(message: SnapMessage): Promise<null> {\n assert(message, AccountDeletedEventStruct);\n const { id } = message.params;\n const account = this.registry.get(id);\n\n // We can ignore the case where the account was already removed from the\n // keyring, making the deletion idempotent.\n //\n // This happens when the keyring calls the Snap to delete an account, and\n // the Snap calls the keyring back with an `AccountDeleted` event.\n if (account === undefined) {\n return null;\n }\n\n await this.#callbacks.removeAccount(\n normalizeAccountAddress(account),\n this.snapId,\n async (accepted) => {\n if (accepted) {\n await this.#callbacks.saveState();\n }\n },\n );\n return null;\n }\n\n /**\n * Handle a Request Approved event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleRequestApproved(message: SnapMessage): Promise<null> {\n assert(message, RequestApprovedEventStruct);\n const { id, result } = message.params;\n const promise =\n this.#requests.get(id) ?? throwError(`Request '${id}' not found`);\n\n this.#requests.delete(id);\n promise.resolve(result);\n return null;\n }\n\n /**\n * Handle a Request Rejected event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleRequestRejected(message: SnapMessage): Promise<null> {\n assert(message, RequestRejectedEventStruct);\n const { id } = message.params;\n const promise =\n this.#requests.get(id) ?? throwError(`Request '${id}' not found`);\n\n this.#requests.delete(id);\n promise.reject(new Error(`Request rejected by user or snap.`));\n return null;\n }\n\n /**\n * Handle a Get Selected Accounts method call from the Snap.\n *\n * @param message - Method call message.\n * @returns The selected accounts.\n */\n async #handleGetSelectedAccounts(\n message: SnapMessage,\n ): Promise<GetSelectedAccountsResponse> {\n assert(message, GetSelectedAccountsRequestStruct);\n return this.#selectedAccounts;\n }\n\n /**\n * Handle an Account Balances Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountBalancesUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountBalancesUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountBalancesUpdated',\n (filter) => {\n event.balances = filter(event.balances);\n return [event];\n },\n );\n }\n\n /**\n * Handle an Account Asset List Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountAssetListUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountAssetListUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountAssetListUpdated',\n (filter) => {\n event.assets = filter(event.assets);\n return [event];\n },\n );\n }\n\n /**\n * Handle an Account Transactions Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountTransactionsUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountTransactionsUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountTransactionsUpdated',\n (filter) => {\n event.transactions = filter(event.transactions);\n return [event];\n },\n );\n }\n\n // ──────────────────────────────────────────────\n // Private helpers\n // ──────────────────────────────────────────────\n\n /**\n * Re-publish an account event after filtering out accounts that don't\n * belong to this snap.\n *\n * Uses the registry as the source of truth: only accounts present in\n * this snap's registry are forwarded. This prevents a snap from emitting\n * updates for accounts it doesn't own.\n *\n * @param event - The event type to re-publish.\n * @param filteredEventCallback - Callback that receives the filter function\n * and returns the event payload to publish.\n * @template EventType - A Snap keyring event type.\n * @returns `null`.\n */\n async #rePublishAccountEvent<EventType extends SnapKeyringEvents['type']>(\n event: EventType,\n filteredEventCallback: (\n filter: FilterAccountIdFunction,\n ) => ExtractEventPayload<SnapKeyringEvents, EventType>,\n ): Promise<null> {\n const filter: FilterAccountIdFunction = <Entry>(\n accountMapping: Record<AccountId, Entry>,\n ): Record<AccountId, Entry> => {\n return Object.entries(accountMapping).reduce<Record<AccountId, Entry>>(\n (filtered, [accountId, entry]) => {\n if (this.registry.has(accountId)) {\n filtered[accountId] = entry;\n } else {\n console.warn(\n `SnapKeyring - ${event} - Found an unknown account ID \"${accountId}\" for Snap ID \"${this.snapId}\". Skipping.`,\n );\n }\n return filtered;\n },\n {},\n );\n };\n\n this.messenger.publish(event, ...filteredEventCallback(filter));\n return null;\n }\n\n /**\n * Core logic for the v1 `createAccount` flow.\n *\n * Handles the reserved 'metamask' field, correlation IDs, and internal\n * options registration. The account is ultimately added to the registry\n * via the `AccountCreated` event handler, not the return value.\n *\n * @param options - Account creation options.\n * @param internalOptions - Internal Snap keyring options.\n * @returns The account object returned by the snap.\n */\n async #createSnapAccount(\n options: Record<string, Json>,\n internalOptions?: SnapKeyringInternalOptions,\n ): Promise<KeyringAccount> {\n const reserved = 'metamask';\n if (hasProperty(options, reserved)) {\n throw new Error(\n `The '${reserved}' property is reserved for internal use`,\n );\n }\n\n if (!internalOptions) {\n return await this.client.createAccount(options);\n }\n\n const correlationId = uuid();\n this.#options.set(correlationId, internalOptions);\n\n return await this.client.createAccount({\n ...options,\n metamask: {\n correlationId,\n },\n });\n }\n\n /**\n * Retrieve and consume internal options for a given correlation ID.\n *\n * NOTE: The options are deleted from the map on retrieval (pop semantics).\n *\n * @param correlationId - Correlation ID associated with the internal options.\n * @returns Internal options if found, `undefined` otherwise.\n */\n #getInternalOptions(\n correlationId: string | undefined,\n ): SnapKeyringInternalOptions | undefined {\n if (!correlationId) {\n return undefined;\n }\n\n const options = this.#options.get(correlationId);\n if (options) {\n this.#options.delete(correlationId);\n return options;\n }\n\n console.warn(\n `SnapKeyring - Received unmapped correlation ID: \"${correlationId}\"`,\n );\n return undefined;\n }\n\n /**\n * Idempotency check: account already exists in this snap with same address.\n *\n * Protected so that `SnapKeyringV2` can reuse it without duplicating the\n * logic.\n *\n * @param account - The account to check.\n * @returns The existing account if found, `undefined` otherwise.\n */\n protected getExistingAccount(\n account: KeyringAccount,\n ): KeyringAccount | undefined {\n const address = normalizeAccountAddress(account);\n const existing = this.registry.get(account.id);\n if (existing && normalizeAccountAddress(existing) === address) {\n return existing;\n }\n return undefined;\n }\n\n /**\n * Create a deferred promise for a request and store it.\n *\n * @param requestId - The unique request identifier.\n * @returns The deferred promise.\n */\n #createRequestPromise<Response>(\n requestId: string,\n ): DeferredPromise<Response> {\n const promise = createDeferredPromise<Response>();\n this.#requests.set(requestId, promise);\n return promise;\n }\n\n /**\n * Handle an async redirect response from the Snap.\n *\n * @param redirect - The redirect information.\n * @param redirect.message - The message to show the user.\n * @param redirect.url - The URL to redirect to.\n */\n async #handleAsyncRedirect(redirect: {\n message?: string;\n url?: string;\n }): Promise<void> {\n const { message = '', url: redirectUrl = '' } = redirect;\n const url = redirectUrl ? sanitizeUrl(redirectUrl) : redirectUrl;\n if (url) {\n this.#validateRedirectUrl(url);\n }\n await this.#callbacks.redirectUser(this.snapId, url, message);\n }\n\n /**\n * Validates that a redirect URL is in the Snap's allowed origins.\n *\n * @param url - The URL to validate.\n * @throws An error if the URL's origin is not in the Snap's allowed origins.\n */\n #validateRedirectUrl(url: string): void {\n const { origin } = new URL(url);\n const snap = this.messenger.call('SnapController:getSnap', this.snapId);\n if (!snap) {\n throw new Error(`Snap '${this.snapId}' not found.`);\n }\n const allowedOrigins =\n snap.manifest.initialPermissions['endowment:keyring']?.allowedOrigins ??\n [];\n if (!allowedOrigins.includes(origin)) {\n throw new Error(\n `Redirect URL domain '${origin}' is not an allowed origin by snap '${this.snapId}'`,\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SnapKeyringV1.mjs","sourceRoot":"","sources":["../src/SnapKeyringV1.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB;AAEpD,OAAO,EAAE,oBAAoB,EAAE,+BAA+B;AAY9D,OAAO,EACL,cAAc,EACd,SAAS,EACT,YAAY,EACZ,cAAc,EACd,0BAA0B,EAC1B,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,qCAAqC,EACtC,8BAA8B;AAE/B,OAAO,EAAE,6BAA6B,EAAE,uCAAuC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,+CAA+C;AACnF,OAAO,EAAE,sBAAsB,EAAE,8BAA8B;AAC/D,OAAO,EACL,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MAAM,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,uCAAuC,IAAI,CAAC,MAAM,GAAG,CACpF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type { TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';\nimport { SignTypedDataVersion } from '@metamask/eth-sig-util';\nimport type {\n KeyringAccount,\n BtcMethod,\n CaipChainId,\n ResolvedAccountAddress,\n KeyringExecutionContext,\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '@metamask/keyring-api';\nimport {\n AnyAccountType,\n EthMethod,\n KeyringEvent,\n EthBytesStruct,\n EthBaseUserOperationStruct,\n EthUserOperationPatchStruct,\n AccountBalancesUpdatedEventStruct,\n AccountAssetListUpdatedEventStruct,\n AccountTransactionsUpdatedEventStruct,\n} from '@metamask/keyring-api';\nimport type { CreateAccountOptions } from '@metamask/keyring-api/v2';\nimport { toKeyringRequestWithoutOrigin } from '@metamask/keyring-internal-api';\nimport { KeyringInternalSnapClient } from '@metamask/keyring-internal-snap-client';\nimport { KeyringAccountRegistry } from '@metamask/keyring-sdk';\nimport {\n GetSelectedAccountsRequestStruct,\n SnapManageAccountsMethod,\n} from '@metamask/keyring-snap-sdk';\nimport type { GetSelectedAccountsResponse } from '@metamask/keyring-snap-sdk';\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport { strictMask } from '@metamask/keyring-utils';\nimport type { ExtractEventPayload } from '@metamask/messenger';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { assert, mask, object, string } from '@metamask/superstruct';\nimport type { Hex, Json, DeferredPromise } from '@metamask/utils';\nimport {\n bigIntToHex,\n hasProperty,\n KnownCaipNamespace,\n toCaipChainId,\n createDeferredPromise,\n} from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport { normalizeAccount, transformAccount } from './account';\nimport { normalizeAccountAddress } from './account';\nimport {\n AccountCreatedEventStruct,\n AccountUpdatedEventStruct,\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n} from './events';\nimport { projectLogger as log } from './logger';\nimport { getInternalOptionsOf } from './options';\nimport type { SnapKeyringInternalOptions } from './options';\nimport { PLATFORM_VERSION_FOR_KEYRING_REQUEST_WITH_ORIGIN } from './platform-versions';\nimport type {\n SnapKeyringEvents,\n SnapKeyringMessenger,\n} from './SnapKeyringMessenger';\nimport type { SnapMessage } from './types';\nimport { SnapMessageStruct } from './types';\nimport { equalsIgnoreCase, sanitizeUrl, throwError, toJson } from './util';\n\n// TODO: to be removed when this is added to the keyring-api\nexport type AccountMethod = EthMethod | BtcMethod;\n\n/**\n * Holds the snap ID and its RPC client once a {@link SnapKeyringV1} instance\n * has been bound via {@link SnapKeyringV1.bindSnapId}.\n */\ntype SnapKeyringV1Context = {\n snapId: SnapId;\n client: KeyringInternalSnapClient;\n};\n\n/**\n * Callback type to filter unknown account ID from a mapping account ID mapping.\n */\ntype FilterAccountIdFunction = <Entry>(\n accountMapping: Record<AccountId, Entry>,\n) => Record<AccountId, Entry>;\n\n/**\n * Callbacks injected by the parent `SnapKeyring` to delegate global concerns.\n *\n * These cover operations that span multiple snaps or require parent-level\n * coordination (account approval UI, persistence, global uniqueness checks).\n */\nexport type SnapKeyringV1Callbacks = {\n /**\n * Called when a new account is being created (v1 event-driven flow).\n * Handles the user-approval dialog and account registration in the UI.\n */\n addAccount: (\n address: string,\n snapId: SnapId,\n handleUserInput: (accepted: boolean) => Promise<void>,\n onceSaved: Promise<AccountId>,\n accountNameSuggestion?: string,\n internalOptions?: SnapKeyringInternalOptions,\n ) => Promise<void>;\n\n /**\n * Called when an account is being deleted.\n * Handles the user-approval dialog and account removal in the UI.\n */\n removeAccount: (\n address: string,\n snapId: SnapId,\n handleUserInput: (accepted: boolean) => Promise<void>,\n ) => Promise<void>;\n\n /**\n * Persist keyring state to disk via KeyringController.\n */\n saveState: () => Promise<void>;\n\n /**\n * Redirect the user to a URL after an async snap request.\n */\n redirectUser: (snapId: SnapId, url: string, message: string) => Promise<void>;\n\n /**\n * Check global uniqueness (address + ID). Throws if the account cannot be used.\n * Must remain in the parent because it checks cross-snap invariants.\n */\n assertAccountCanBeUsed: (account: KeyringAccount) => Promise<void>;\n\n /**\n * Called synchronously whenever a new account is added to the registry.\n * Optional — consumers that don't need cross-instance indexing can omit this.\n */\n onRegister?: (accountId: AccountId) => void;\n\n /**\n * Called synchronously whenever an account is removed from the registry.\n * Optional — consumers that don't need cross-instance indexing can omit this.\n */\n onUnregister?: (accountId: AccountId) => void;\n};\n\n/**\n * Options for creating a `SnapKeyringV1` instance.\n */\nexport type SnapKeyringV1Options = {\n messenger: SnapKeyringMessenger;\n callbacks: SnapKeyringV1Callbacks;\n /**\n * Whether to allow the creation and update of generic accounts.\n * Defaults to `false`.\n */\n isAnyAccountTypeAllowed?: boolean;\n /**\n * Account registry to use. When provided (e.g. by a owning `SnapKeyring`\n * v2 instance), the registry is shared by reference. When omitted, a new\n * registry is created (useful for standalone / test usage).\n */\n registry?: KeyringAccountRegistry;\n};\n\n/**\n * Per-snap coordinator for the v1 (event-driven) keyring flow.\n *\n * Each instance is scoped to exactly one `SnapId`. It handles all Snap\n * keyring events (account lifecycle, request approval, asset updates) and\n * owns the per-snap request / internal-options state.\n *\n * Designed to be subclassed: `SnapKeyringV2` extends this class and adds the\n * `KeyringV2` interface on top, sharing the same registry and client.\n */\nexport class SnapKeyringV1 {\n /** Snap ID and RPC client. Set via {@link bindSnapId}. */\n #context: SnapKeyringV1Context | undefined;\n\n /** Account registry — shared with subclass (e.g. SnapKeyringV2). */\n protected readonly registry: KeyringAccountRegistry;\n\n /** Messenger for snap controller calls and event publishing. */\n protected readonly messenger: SnapKeyringMessenger;\n\n /** Injected callbacks for parent-level coordination. */\n readonly #callbacks: SnapKeyringV1Callbacks;\n\n /** Whether to allow the creation and update of generic accounts. */\n readonly #isAnyAccountTypeAllowed: boolean;\n\n /**\n * Pending async request promises, keyed by request ID.\n * Plain Map is sufficient here since this instance is already snap-scoped.\n */\n readonly #requests: Map<string, DeferredPromise<any>>;\n\n /**\n * Correlation ID -> internal options, used to thread options from\n * `createAccount` through to the `AccountCreated` event handler.\n */\n readonly #options: Map<string, SnapKeyringInternalOptions>;\n\n /**\n * The currently selected account IDs for this snap.\n */\n #selectedAccounts: AccountId[];\n\n /**\n * Initialized context (snap ID + RPC client).\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The initialized context.\n */\n protected get context(): SnapKeyringV1Context {\n if (this.#context === undefined) {\n throw new Error(\n 'SnapKeyring has not been initialized: call deserialize() first',\n );\n }\n return this.#context;\n }\n\n /**\n * The snap ID this instance is scoped to.\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The snap ID.\n */\n get snapId(): SnapId {\n return this.context.snapId;\n }\n\n /**\n * Snap client for keyring RPC calls.\n *\n * @throws If the keyring has not been initialized yet.\n * @returns The internal snap client.\n */\n protected get client(): KeyringInternalSnapClient {\n return this.context.client;\n }\n\n constructor({\n messenger,\n callbacks,\n isAnyAccountTypeAllowed = false,\n registry,\n }: SnapKeyringV1Options) {\n this.registry = registry ?? new KeyringAccountRegistry();\n this.messenger = messenger;\n this.#callbacks = callbacks;\n this.#isAnyAccountTypeAllowed = isAnyAccountTypeAllowed;\n this.#requests = new Map();\n this.#options = new Map();\n this.#selectedAccounts = [];\n }\n\n /**\n * Bind this keyring to a snap ID and create the internal snap client.\n *\n * Idempotent for the same `snapId`; throws if called again with a different\n * one to prevent accidentally swapping a keyring's identity.\n *\n * @param snapId - The snap ID to bind this keyring to.\n * @throws If the keyring is already bound to a different snap ID.\n */\n bindSnapId(snapId: SnapId): void {\n if (this.#context !== undefined && this.#context.snapId !== snapId) {\n throw new Error(\n `SnapKeyring bound to '${this.#context.snapId}' cannot be rebound to '${snapId}'`,\n );\n }\n if (this.#context === undefined) {\n this.#context = {\n snapId,\n client: new KeyringInternalSnapClient({\n messenger: this.messenger,\n snapId,\n }),\n };\n }\n }\n\n // ──────────────────────────────────────────────\n // Public API\n // ──────────────────────────────────────────────\n\n /**\n * Destroy this keyring, rejecting any pending requests.\n *\n * Called when the per-snap entry is removed from the parent `SnapKeyring`,\n * either because all accounts were deleted or because state was re-deserialized.\n */\n async destroy(): Promise<void> {\n for (const promise of this.#requests.values()) {\n promise.reject(\n new Error(`Keyring for snap '${this.snapId}' has been destroyed`),\n );\n }\n this.#requests.clear();\n }\n\n /**\n * Create a single account using the v1 event-driven flow.\n *\n * Handles the reserved 'metamask' field, correlation IDs, and internal\n * options registration. The account is ultimately added to the registry\n * via the `AccountCreated` event handler, not the return value.\n *\n * @param options - Account creation options.\n * @param internalOptions - Internal Snap keyring options.\n * @returns The account object returned by the snap.\n */\n async createAccount(\n options: Record<string, Json>,\n internalOptions?: SnapKeyringInternalOptions,\n ): Promise<KeyringAccount> {\n return this.#createSnapAccount(options, internalOptions);\n }\n\n /**\n * Create one or more accounts using the v1 synchronous RPC flow.\n *\n * Delegates to the v1 internal snap client, which wraps `options` in\n * `{ options }` before sending `keyring_createAccounts` — unlike the v2\n * client which sends flat `options`. Called by `SnapKeyring` (v2) when the\n * snap has no declared capabilities (i.e. it is a v1 snap).\n *\n * @param options - Account creation options forwarded to the snap.\n * @returns The array of accounts returned by the snap.\n */\n async createAccounts(\n options: CreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return this.client.createAccounts(options);\n }\n\n /**\n * Handle an incoming message from the Snap.\n *\n * Routes the message to the appropriate private handler based on the method.\n *\n * @param message - The message sent by the Snap.\n * @returns The execution result.\n */\n async handleKeyringSnapMessage(message: SnapMessage): Promise<Json> {\n assert(message, SnapMessageStruct);\n switch (message.method) {\n case `${KeyringEvent.AccountCreated}`: {\n return this.#handleAccountCreated(message);\n }\n\n case `${KeyringEvent.AccountUpdated}`: {\n return this.#handleAccountUpdated(message);\n }\n\n case `${KeyringEvent.AccountDeleted}`: {\n return this.#handleAccountDeleted(message);\n }\n\n case `${KeyringEvent.RequestApproved}`: {\n return this.#handleRequestApproved(message);\n }\n\n case `${KeyringEvent.RequestRejected}`: {\n return this.#handleRequestRejected(message);\n }\n\n case `${KeyringEvent.AccountBalancesUpdated}`: {\n return this.#handleAccountBalancesUpdated(message);\n }\n\n case `${KeyringEvent.AccountAssetListUpdated}`: {\n return this.#handleAccountAssetListUpdated(message);\n }\n\n case `${KeyringEvent.AccountTransactionsUpdated}`: {\n return this.#handleAccountTransactionsUpdated(message);\n }\n\n case `${SnapManageAccountsMethod.GetSelectedAccounts}`: {\n return this.#handleGetSelectedAccounts(message);\n }\n\n default:\n throw new Error(`Method not supported: ${message.method}`);\n }\n }\n\n /**\n * Submit a snap request for the given account.\n *\n * Manages the request promise lifecycle (creation, resolution, cleanup) and\n * handles both synchronous and asynchronous (redirect) responses.\n *\n * @param options - The request options.\n * @param options.origin - The sender origin.\n * @param options.account - The account to submit the request for.\n * @param options.method - The method to call.\n * @param options.params - The method parameters.\n * @param options.scope - The CAIP-2 chain ID.\n * @param options.noPending - Whether the response is allowed to be pending.\n * @returns A promise that resolves to the keyring response.\n */\n async submitSnapRequest<Response extends Json>({\n origin,\n account,\n method,\n params,\n scope,\n noPending,\n }: {\n origin: string;\n account: KeyringAccount;\n method: AccountMethod;\n params?: Json[] | Record<string, Json> | undefined;\n scope: string;\n noPending: boolean;\n }): Promise<Response> {\n if (!(account.methods as AccountMethod[]).includes(method)) {\n throw new Error(\n `Method '${method}' not supported for account ${account.address}`,\n );\n }\n\n // Will both catch `undefined` and \"empty\" origins.\n if (!origin?.trim()) {\n throw new Error('An `origin` is required');\n }\n\n const requestId = uuid();\n\n // Create the promise before calling the Snap to prevent a race condition\n // where the Snap responds before we have a chance to create it.\n const requestPromise = this.#createRequestPromise<Response>(requestId);\n\n try {\n const useOrigin = this.messenger.call(\n 'SnapController:isMinimumPlatformVersion',\n this.snapId,\n PLATFORM_VERSION_FOR_KEYRING_REQUEST_WITH_ORIGIN,\n );\n\n const request = {\n id: requestId,\n origin,\n scope,\n account: account.id,\n request: {\n method,\n ...(params !== undefined && { params }),\n },\n };\n\n log('Submit Snap request: ', request);\n\n let response;\n if (useOrigin) {\n response = await this.client.submitRequest(request);\n } else {\n response = await this.client.submitRequestWithoutOrigin(\n toKeyringRequestWithoutOrigin(request),\n );\n }\n\n if (noPending && response.pending) {\n throw new Error(\n `Request '${requestId}' to Snap '${this.snapId}' is pending and noPending is true.`,\n );\n }\n\n if (!response.pending) {\n this.#requests.delete(requestId);\n return response.result as Response;\n }\n\n if (response.redirect?.message || response.redirect?.url) {\n await this.#handleAsyncRedirect(response.redirect);\n }\n\n return requestPromise.promise;\n } catch (error) {\n log('Snap Request failed: ', { requestId });\n this.#requests.delete(requestId);\n throw error;\n }\n }\n\n /**\n * Update the selected accounts for this snap.\n *\n * @param accountIds - The account IDs to set as selected.\n */\n async setSelectedAccounts(accountIds: AccountId[]): Promise<void> {\n this.#selectedAccounts = accountIds;\n try {\n await this.client.setSelectedAccounts(accountIds);\n } catch (error: any) {\n console.error(\n `Failed to set selected accounts for ${this.snapId} snap: '${error.message}'`,\n );\n }\n }\n\n /**\n * Resolve the account address associated with a signing request.\n *\n * Delegates directly to the snap-scoped client, which already has the\n * snap ID baked in from construction time.\n *\n * @param scope - CAIP-2 chain ID.\n * @param request - Signing request object.\n * @returns The resolved address if found, `null` otherwise.\n */\n async resolveAccountAddress(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null> {\n return this.client.resolveAccountAddress(scope, request);\n }\n\n /**\n * Sign a transaction for the given account.\n *\n * @param account - The account to sign the transaction for.\n * @param transaction - The transaction to sign.\n * @param _opts - Transaction options (unused).\n * @returns A promise that resolves to the signed transaction.\n */\n async signTransaction(\n account: KeyringAccount,\n transaction: TypedTransaction,\n /* istanbul ignore next */\n _opts = {},\n ): Promise<Json | TypedTransaction> {\n const chainId = transaction.common.chainId();\n const tx = toJson({\n ...transaction.toJSON(),\n from: normalizeAccountAddress(account),\n type: `0x${transaction.type.toString(16)}`,\n chainId: bigIntToHex(chainId),\n });\n\n const signedTx = await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.SignTransaction,\n params: [tx],\n scope: toCaipChainId(KnownCaipNamespace.Eip155, `${chainId}`),\n noPending: false,\n });\n\n // ! It's *** CRITICAL *** that we mask the signature here, otherwise the\n // ! Snap could overwrite the transaction.\n const signature = mask(\n signedTx,\n object({\n r: string(),\n s: string(),\n v: string(),\n }),\n );\n\n return TransactionFactory.fromTxData({\n ...(tx as Record<string, Json>),\n r: signature.r as Hex,\n s: signature.s as Hex,\n v: signature.v as Hex,\n });\n }\n\n /**\n * Sign a typed data message for the given account.\n *\n * @param account - The account to sign the typed data for.\n * @param data - The typed data to sign.\n * @param opts - Signing options.\n * @param opts.version - The typed data version to use.\n * @returns A promise that resolves to the signature.\n */\n async signTypedData(\n account: KeyringAccount,\n data: Record<string, unknown>[] | TypedDataV1 | TypedMessage<any>,\n opts: { version: SignTypedDataVersion },\n ): Promise<string> {\n const methods = {\n [SignTypedDataVersion.V1]: EthMethod.SignTypedDataV1,\n [SignTypedDataVersion.V3]: EthMethod.SignTypedDataV3,\n [SignTypedDataVersion.V4]: EthMethod.SignTypedDataV4,\n };\n\n // Use 'V1' by default to match other keyring implementations. V1 will be\n // used if the version is not specified or not supported.\n const method = methods[opts.version] || EthMethod.SignTypedDataV1;\n\n // Extract chain ID as if it was a typed message (as defined by EIP-712), if\n // input is not a typed message, then chain ID will be undefined!\n const chainId = (data as TypedMessage<any>).domain?.chainId;\n\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method,\n params: toJson<Json[]>([address, data]),\n scope:\n chainId === undefined\n ? ''\n : toCaipChainId(KnownCaipNamespace.Eip155, `${chainId}`),\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a message (eth_sign) for the given account.\n *\n * @param account - The account to sign the message for.\n * @param hash - The data to sign.\n * @returns A promise that resolves to the signature.\n */\n async signMessage(account: KeyringAccount, hash: any): Promise<string> {\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.Sign,\n params: toJson<Json[]>([address, hash]),\n scope: '',\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Sign a personal message for the given account.\n *\n * Note: KeyringController says this should return a Buffer but it actually\n * expects a string.\n *\n * @param account - The account to sign the message for.\n * @param data - The data to sign.\n * @returns A promise that resolves to the signature.\n */\n async signPersonalMessage(\n account: KeyringAccount,\n data: any,\n ): Promise<string> {\n const address = normalizeAccountAddress(account);\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PersonalSign,\n params: toJson<Json[]>([data, address]),\n scope: '',\n noPending: false,\n }),\n EthBytesStruct,\n );\n }\n\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param account - The account to prepare the user operation for.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real one.\n */\n async prepareUserOperation(\n account: KeyringAccount,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PrepareUserOperation,\n params: toJson<Json[]>(transactions),\n noPending: true,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthBaseUserOperationStruct,\n );\n }\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param account - The account to patch the user operation for.\n * @param userOp - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n */\n async patchUserOperation(\n account: KeyringAccount,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.PatchUserOperation,\n params: toJson<Json[]>([userOp]),\n noPending: true,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthUserOperationPatchStruct,\n );\n }\n\n /**\n * Signs a UserOperation.\n *\n * @param account - The account to sign the user operation for.\n * @param userOp - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns A promise that resolves to the signature.\n */\n async signUserOperation(\n account: KeyringAccount,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string> {\n return strictMask(\n await this.submitSnapRequest({\n origin: 'metamask',\n account,\n method: EthMethod.SignUserOperation,\n params: toJson<Json[]>([userOp]),\n noPending: false,\n scope: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),\n }),\n EthBytesStruct,\n );\n }\n\n // ──────────────────────────────────────────────\n // Private handlers\n // ──────────────────────────────────────────────\n\n /**\n * Handle an Account Created event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountCreated(message: SnapMessage): Promise<null> {\n assert(message, AccountCreatedEventStruct);\n const {\n metamask,\n account: newAccountFromEvent,\n accountNameSuggestion,\n displayAccountNameSuggestion,\n displayConfirmation,\n } = message.params;\n\n // READ THIS CAREFULLY:\n // ------------------------------------------------------------------------\n // The account creation flow is now asynchronous. We expect the Snap to\n // first create the account data and then fire the \"AccountCreated\" event.\n\n // Potentially migrate the account.\n const account = normalizeAccount(transformAccount(newAccountFromEvent));\n const { address } = account;\n\n if (this.getExistingAccount(account)) {\n // If the account already exists, we skip it.\n return null;\n }\n\n // Make sure this new account is valid.\n await this.#callbacks.assertAccountCanBeUsed(account);\n\n // A deferred promise that will be resolved once the Snap keyring has saved\n // its internal state.\n // This part of the flow is run asynchronously, so we have no other way of\n // letting the MetaMask client that this \"save\" has been run.\n // NOTE: Another way of fixing that could be to rely on events through the\n // messenger maybe?\n const onceSaved = createDeferredPromise<AccountId>();\n\n // Add the account to the keyring, but wait for the MetaMask client to\n // approve the account creation first.\n await this.#callbacks.addAccount(\n address,\n this.snapId,\n // This callback is passed to the MetaMask client, it will be called whenever\n // the end user will accept or not the account creation.\n async (accepted: boolean) => {\n if (accepted) {\n // We consider the account to be created on the Snap keyring only if\n // the user accepted it. Meaning that the Snap MIGHT HAVE created the\n // account on its own state, but the Snap keyring MIGHT NOT HAVE it yet.\n //\n // e.g The account creation dialog crashed on MetaMask, this callback\n // will never be called, but the Snap still has the account.\n this.registry.set(account);\n this.#callbacks.onRegister?.(account.id);\n\n // This is the \"true async part\". We do not `await` for this call, mainly\n // because this callback will persist the account on the client side\n // (through the `AccountsController`).\n //\n // Since this will happen after the Snap account creation and Snap\n // event, if anything goes wrong, we will delete the account by\n // calling `deleteAccount` on the Snap.\n // eslint-disable-next-line no-void\n void this.#callbacks\n .saveState()\n .then(() => {\n // This allows the MetaMask client to be \"notified\" when then\n // Snap keyring has truly persisted its state. From there, we should\n // be able to use the account (e.g. to display account creation\n // confirmation dialogs).\n onceSaved.resolve(account.id);\n })\n .catch(\n /* istanbul ignore next */\n async (error: unknown) => {\n // FIXME: There's a potential race condition here, if the Snap did\n // not persist the account yet (this should mostly be for older Snaps).\n this.registry.delete(account.id);\n this.#callbacks.onUnregister?.(account.id);\n await this.client\n .deleteAccount(account.id)\n /* istanbul ignore next */\n .catch((deleteError: unknown) => {\n console.error(\n `Account '${account.id}' may not have been removed from snap '${this.snapId}':`,\n deleteError,\n );\n });\n\n // This allows the MetaMask client to be \"notified\" that something went\n // wrong with the Snap keyring. (e.g. useful to display account creation\n // error dialogs).\n onceSaved.reject(error);\n },\n );\n }\n },\n onceSaved.promise,\n accountNameSuggestion,\n getInternalOptionsOf([\n // 1. We use the internal options from the Snap keyring.\n this.#getInternalOptions(metamask?.correlationId) ?? {},\n // 2. We use the ones coming from the Snap.\n {\n displayConfirmation,\n displayAccountNameSuggestion,\n },\n ]),\n );\n\n return null;\n }\n\n /**\n * Handle an Account Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountUpdatedEventStruct);\n const { account: newAccountFromEvent } = message.params;\n const oldAccount =\n this.registry.get(newAccountFromEvent.id) ??\n throwError(`Account '${newAccountFromEvent.id}' not found`);\n\n // Potentially migrate the account.\n const newAccount = transformAccount(newAccountFromEvent);\n\n // The `AnyAccountType.Account` generic account type is allowed only during\n // development, so we check whether it's allowed before continuing.\n //\n // An account cannot be updated if the `isAnyAccountTypeAllowed` flag is\n // set to `false` and the new or old account is a generic account.\n const isGenericAccountInvolved =\n newAccount.type === AnyAccountType.Account ||\n oldAccount.type === AnyAccountType.Account;\n\n if (!this.#isAnyAccountTypeAllowed && isGenericAccountInvolved) {\n throw new Error(`Cannot update generic account '${newAccount.id}'`);\n }\n\n // The address of the account cannot be changed. In the future, we will\n // support changing the address of an account since it will be required to\n // support UTXO-based chains.\n if (!equalsIgnoreCase(oldAccount.address, newAccount.address)) {\n throw new Error(`Cannot change address of account '${newAccount.id}'`);\n }\n\n this.registry.set(newAccount);\n await this.#callbacks.saveState();\n return null;\n }\n\n /**\n * Handle an Account Deleted event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountDeleted(message: SnapMessage): Promise<null> {\n assert(message, AccountDeletedEventStruct);\n const { id } = message.params;\n const account = this.registry.get(id);\n\n // We can ignore the case where the account was already removed from the\n // keyring, making the deletion idempotent.\n //\n // This happens when the keyring calls the Snap to delete an account, and\n // the Snap calls the keyring back with an `AccountDeleted` event.\n if (account === undefined) {\n return null;\n }\n\n await this.#callbacks.removeAccount(\n normalizeAccountAddress(account),\n this.snapId,\n async (accepted) => {\n if (accepted) {\n await this.#callbacks.saveState();\n }\n },\n );\n return null;\n }\n\n /**\n * Handle a Request Approved event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleRequestApproved(message: SnapMessage): Promise<null> {\n assert(message, RequestApprovedEventStruct);\n const { id, result } = message.params;\n const promise =\n this.#requests.get(id) ?? throwError(`Request '${id}' not found`);\n\n this.#requests.delete(id);\n promise.resolve(result);\n return null;\n }\n\n /**\n * Handle a Request Rejected event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleRequestRejected(message: SnapMessage): Promise<null> {\n assert(message, RequestRejectedEventStruct);\n const { id } = message.params;\n const promise =\n this.#requests.get(id) ?? throwError(`Request '${id}' not found`);\n\n this.#requests.delete(id);\n promise.reject(new Error(`Request rejected by user or snap.`));\n return null;\n }\n\n /**\n * Handle a Get Selected Accounts method call from the Snap.\n *\n * @param message - Method call message.\n * @returns The selected accounts.\n */\n async #handleGetSelectedAccounts(\n message: SnapMessage,\n ): Promise<GetSelectedAccountsResponse> {\n assert(message, GetSelectedAccountsRequestStruct);\n return this.#selectedAccounts;\n }\n\n /**\n * Handle an Account Balances Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountBalancesUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountBalancesUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountBalancesUpdated',\n (filter) => {\n event.balances = filter(event.balances);\n return [event];\n },\n );\n }\n\n /**\n * Handle an Account Asset List Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountAssetListUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountAssetListUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountAssetListUpdated',\n (filter) => {\n event.assets = filter(event.assets);\n return [event];\n },\n );\n }\n\n /**\n * Handle an Account Transactions Updated event from the Snap.\n *\n * @param message - Event message.\n * @returns `null`.\n */\n async #handleAccountTransactionsUpdated(message: SnapMessage): Promise<null> {\n assert(message, AccountTransactionsUpdatedEventStruct);\n const event = message.params;\n return this.#rePublishAccountEvent(\n 'SnapKeyring:accountTransactionsUpdated',\n (filter) => {\n event.transactions = filter(event.transactions);\n return [event];\n },\n );\n }\n\n // ──────────────────────────────────────────────\n // Private helpers\n // ──────────────────────────────────────────────\n\n /**\n * Re-publish an account event after filtering out accounts that don't\n * belong to this snap.\n *\n * Uses the registry as the source of truth: only accounts present in\n * this snap's registry are forwarded. This prevents a snap from emitting\n * updates for accounts it doesn't own.\n *\n * @param event - The event type to re-publish.\n * @param filteredEventCallback - Callback that receives the filter function\n * and returns the event payload to publish.\n * @template EventType - A Snap keyring event type.\n * @returns `null`.\n */\n async #rePublishAccountEvent<EventType extends SnapKeyringEvents['type']>(\n event: EventType,\n filteredEventCallback: (\n filter: FilterAccountIdFunction,\n ) => ExtractEventPayload<SnapKeyringEvents, EventType>,\n ): Promise<null> {\n const filter: FilterAccountIdFunction = <Entry>(\n accountMapping: Record<AccountId, Entry>,\n ): Record<AccountId, Entry> => {\n return Object.entries(accountMapping).reduce<Record<AccountId, Entry>>(\n (filtered, [accountId, entry]) => {\n if (this.registry.has(accountId)) {\n filtered[accountId] = entry;\n } else {\n console.warn(\n `SnapKeyring - ${event} - Found an unknown account ID \"${accountId}\" for Snap ID \"${this.snapId}\". Skipping.`,\n );\n }\n return filtered;\n },\n {},\n );\n };\n\n this.messenger.publish(event, ...filteredEventCallback(filter));\n return null;\n }\n\n /**\n * Core logic for the v1 `createAccount` flow.\n *\n * Handles the reserved 'metamask' field, correlation IDs, and internal\n * options registration. The account is ultimately added to the registry\n * via the `AccountCreated` event handler, not the return value.\n *\n * @param options - Account creation options.\n * @param internalOptions - Internal Snap keyring options.\n * @returns The account object returned by the snap.\n */\n async #createSnapAccount(\n options: Record<string, Json>,\n internalOptions?: SnapKeyringInternalOptions,\n ): Promise<KeyringAccount> {\n const reserved = 'metamask';\n if (hasProperty(options, reserved)) {\n throw new Error(\n `The '${reserved}' property is reserved for internal use`,\n );\n }\n\n if (!internalOptions) {\n return await this.client.createAccount(options);\n }\n\n const correlationId = uuid();\n this.#options.set(correlationId, internalOptions);\n\n return await this.client.createAccount({\n ...options,\n metamask: {\n correlationId,\n },\n });\n }\n\n /**\n * Retrieve and consume internal options for a given correlation ID.\n *\n * NOTE: The options are deleted from the map on retrieval (pop semantics).\n *\n * @param correlationId - Correlation ID associated with the internal options.\n * @returns Internal options if found, `undefined` otherwise.\n */\n #getInternalOptions(\n correlationId: string | undefined,\n ): SnapKeyringInternalOptions | undefined {\n if (!correlationId) {\n return undefined;\n }\n\n const options = this.#options.get(correlationId);\n if (options) {\n this.#options.delete(correlationId);\n return options;\n }\n\n console.warn(\n `SnapKeyring - Received unmapped correlation ID: \"${correlationId}\"`,\n );\n return undefined;\n }\n\n /**\n * Idempotency check: account already exists in this snap with same address.\n *\n * Protected so that `SnapKeyringV2` can reuse it without duplicating the\n * logic.\n *\n * @param account - The account to check.\n * @returns The existing account if found, `undefined` otherwise.\n */\n protected getExistingAccount(\n account: KeyringAccount,\n ): KeyringAccount | undefined {\n const address = normalizeAccountAddress(account);\n const existing = this.registry.get(account.id);\n if (existing && normalizeAccountAddress(existing) === address) {\n return existing;\n }\n return undefined;\n }\n\n /**\n * Create a deferred promise for a request and store it.\n *\n * @param requestId - The unique request identifier.\n * @returns The deferred promise.\n */\n #createRequestPromise<Response>(\n requestId: string,\n ): DeferredPromise<Response> {\n const promise = createDeferredPromise<Response>();\n this.#requests.set(requestId, promise);\n return promise;\n }\n\n /**\n * Handle an async redirect response from the Snap.\n *\n * @param redirect - The redirect information.\n * @param redirect.message - The message to show the user.\n * @param redirect.url - The URL to redirect to.\n */\n async #handleAsyncRedirect(redirect: {\n message?: string;\n url?: string;\n }): Promise<void> {\n const { message = '', url: redirectUrl = '' } = redirect;\n const url = redirectUrl ? sanitizeUrl(redirectUrl) : redirectUrl;\n if (url) {\n this.#validateRedirectUrl(url);\n }\n await this.#callbacks.redirectUser(this.snapId, url, message);\n }\n\n /**\n * Validates that a redirect URL is in the Snap's allowed origins.\n *\n * @param url - The URL to validate.\n * @throws An error if the URL's origin is not in the Snap's allowed origins.\n */\n #validateRedirectUrl(url: string): void {\n const { origin } = new URL(url);\n const snap = this.messenger.call('SnapController:getSnap', this.snapId);\n if (!snap) {\n throw new Error(`Snap '${this.snapId}' not found.`);\n }\n const allowedOrigins =\n snap.manifest.initialPermissions['endowment:keyring']?.allowedOrigins ??\n [];\n if (!allowedOrigins.includes(origin)) {\n throw new Error(\n `Redirect URL domain '${origin}' is not an allowed origin by snap '${this.snapId}'`,\n );\n }\n }\n}\n"]}
|
package/dist/events.cjs
CHANGED
|
@@ -5,19 +5,18 @@ const keyring_api_1 = require("@metamask/keyring-api");
|
|
|
5
5
|
Object.defineProperty(exports, "AccountDeletedEventStruct", { enumerable: true, get: function () { return keyring_api_1.AccountDeletedEventStruct; } });
|
|
6
6
|
Object.defineProperty(exports, "RequestApprovedEventStruct", { enumerable: true, get: function () { return keyring_api_1.RequestApprovedEventStruct; } });
|
|
7
7
|
Object.defineProperty(exports, "RequestRejectedEventStruct", { enumerable: true, get: function () { return keyring_api_1.RequestRejectedEventStruct; } });
|
|
8
|
-
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
9
8
|
const superstruct_1 = require("@metamask/superstruct");
|
|
10
9
|
const account_1 = require("./account.cjs");
|
|
11
|
-
exports.AccountCreatedEventStruct = (0,
|
|
10
|
+
exports.AccountCreatedEventStruct = (0, superstruct_1.object)({
|
|
12
11
|
...keyring_api_1.AccountCreatedEventStruct.schema,
|
|
13
|
-
params: (0,
|
|
12
|
+
params: (0, superstruct_1.object)({
|
|
14
13
|
...keyring_api_1.AccountCreatedEventStruct.schema.params.schema,
|
|
15
14
|
account: (0, superstruct_1.union)([account_1.KeyringAccountV1Struct, keyring_api_1.KeyringAccountStruct]),
|
|
16
15
|
}),
|
|
17
16
|
});
|
|
18
|
-
exports.AccountUpdatedEventStruct = (0,
|
|
17
|
+
exports.AccountUpdatedEventStruct = (0, superstruct_1.object)({
|
|
19
18
|
...keyring_api_1.AccountUpdatedEventStruct.schema,
|
|
20
|
-
params: (0,
|
|
19
|
+
params: (0, superstruct_1.object)({
|
|
21
20
|
...keyring_api_1.AccountUpdatedEventStruct.schema.params.schema,
|
|
22
21
|
account: (0, superstruct_1.union)([account_1.KeyringAccountV1Struct, keyring_api_1.KeyringAccountStruct]),
|
|
23
22
|
}),
|
package/dist/events.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.cjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;
|
|
1
|
+
{"version":3,"file":"events.cjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AA0B7B,0GA9BA,uCAAyB,OA8BA;AACzB,2GA9BA,wCAA0B,OA8BA;AAC1B,2GA9BA,wCAA0B,OA8BA;AA3B5B,uDAAsD;AAEtD,2CAAmD;AAEtC,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C,GAAG,uCAAiC,CAAC,MAAM;IAE3C,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,GAAG,uCAAiC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;QACzD,OAAO,EAAE,IAAA,mBAAK,EAAC,CAAC,gCAAsB,EAAE,kCAAoB,CAAC,CAAC;KAC/D,CAAC;CACH,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C,GAAG,uCAAiC,CAAC,MAAM;IAE3C,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,GAAG,uCAAiC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;QACzD,OAAO,EAAE,IAAA,mBAAK,EAAC,CAAC,gCAAsB,EAAE,kCAAoB,CAAC,CAAC;KAC/D,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n AccountCreatedEventStruct as OriginalAccountCreatedEventStruct,\n AccountUpdatedEventStruct as OriginalAccountUpdatedEventStruct,\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n KeyringAccountStruct,\n} from '@metamask/keyring-api';\nimport { object, union } from '@metamask/superstruct';\n\nimport { KeyringAccountV1Struct } from './account';\n\nexport const AccountCreatedEventStruct = object({\n ...OriginalAccountCreatedEventStruct.schema,\n\n params: object({\n ...OriginalAccountCreatedEventStruct.schema.params.schema,\n account: union([KeyringAccountV1Struct, KeyringAccountStruct]),\n }),\n});\n\nexport const AccountUpdatedEventStruct = object({\n ...OriginalAccountUpdatedEventStruct.schema,\n\n params: object({\n ...OriginalAccountUpdatedEventStruct.schema.params.schema,\n account: union([KeyringAccountV1Struct, KeyringAccountStruct]),\n }),\n});\n\n// Re-export the all keyring events, so we don't have to mix between events coming\n// from `@metamask/keyring-api` and the local ones:\nexport {\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n};\n"]}
|
package/dist/events.d.cts
CHANGED
|
@@ -132,14 +132,14 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
132
132
|
};
|
|
133
133
|
methods: string[];
|
|
134
134
|
}, null>;
|
|
135
|
-
metamask: import("@metamask/superstruct").
|
|
135
|
+
metamask: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
136
136
|
correlationId: string;
|
|
137
137
|
}, {
|
|
138
138
|
correlationId: import("@metamask/superstruct").Struct<string, null>;
|
|
139
139
|
}>;
|
|
140
|
-
accountNameSuggestion: import("@metamask/superstruct").
|
|
141
|
-
displayConfirmation: import("@metamask/superstruct").
|
|
142
|
-
displayAccountNameSuggestion: import("@metamask/superstruct").
|
|
140
|
+
accountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<string, null>;
|
|
141
|
+
displayConfirmation: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
142
|
+
displayAccountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
143
143
|
}>;
|
|
144
144
|
method: import("@metamask/superstruct").Struct<"notify:accountCreated", "notify:accountCreated">;
|
|
145
145
|
}>;
|
package/dist/events.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;
|
|
1
|
+
{"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;AAK/B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAIH,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,GAC3B,CAAC"}
|
package/dist/events.d.mts
CHANGED
|
@@ -132,14 +132,14 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
|
|
|
132
132
|
};
|
|
133
133
|
methods: string[];
|
|
134
134
|
}, null>;
|
|
135
|
-
metamask: import("@metamask/superstruct").
|
|
135
|
+
metamask: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
136
136
|
correlationId: string;
|
|
137
137
|
}, {
|
|
138
138
|
correlationId: import("@metamask/superstruct").Struct<string, null>;
|
|
139
139
|
}>;
|
|
140
|
-
accountNameSuggestion: import("@metamask/superstruct").
|
|
141
|
-
displayConfirmation: import("@metamask/superstruct").
|
|
142
|
-
displayAccountNameSuggestion: import("@metamask/superstruct").
|
|
140
|
+
accountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<string, null>;
|
|
141
|
+
displayConfirmation: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
142
|
+
displayAccountNameSuggestion: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
143
143
|
}>;
|
|
144
144
|
method: import("@metamask/superstruct").Struct<"notify:accountCreated", "notify:accountCreated">;
|
|
145
145
|
}>;
|
package/dist/events.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;
|
|
1
|
+
{"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAE3B,8BAA8B;AAK/B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpC,CAAC;AAIH,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,GAC3B,CAAC"}
|
package/dist/events.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AccountCreatedEventStruct as OriginalAccountCreatedEventStruct, AccountUpdatedEventStruct as OriginalAccountUpdatedEventStruct, AccountDeletedEventStruct, RequestApprovedEventStruct, RequestRejectedEventStruct, KeyringAccountStruct } from "@metamask/keyring-api";
|
|
2
|
-
import { object } from "@metamask/
|
|
3
|
-
import { union } from "@metamask/superstruct";
|
|
2
|
+
import { object, union } from "@metamask/superstruct";
|
|
4
3
|
import { KeyringAccountV1Struct } from "./account.mjs";
|
|
5
4
|
export const AccountCreatedEventStruct = object({
|
|
6
5
|
...OriginalAccountCreatedEventStruct.schema,
|
package/dist/events.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,IAAI,iCAAiC,EAC9D,yBAAyB,IAAI,iCAAiC,EAC9D,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,EACrB,8BAA8B;AAC/B,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,IAAI,iCAAiC,EAC9D,yBAAyB,IAAI,iCAAiC,EAC9D,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,EACrB,8BAA8B;AAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAEtD,OAAO,EAAE,sBAAsB,EAAE,sBAAkB;AAEnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C,GAAG,iCAAiC,CAAC,MAAM;IAE3C,MAAM,EAAE,MAAM,CAAC;QACb,GAAG,iCAAiC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;QACzD,OAAO,EAAE,KAAK,CAAC,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;KAC/D,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C,GAAG,iCAAiC,CAAC,MAAM;IAE3C,MAAM,EAAE,MAAM,CAAC;QACb,GAAG,iCAAiC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;QACzD,OAAO,EAAE,KAAK,CAAC,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;KAC/D,CAAC;CACH,CAAC,CAAC;AAEH,kFAAkF;AAClF,mDAAmD;AACnD,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC3B,CAAC","sourcesContent":["import {\n AccountCreatedEventStruct as OriginalAccountCreatedEventStruct,\n AccountUpdatedEventStruct as OriginalAccountUpdatedEventStruct,\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n KeyringAccountStruct,\n} from '@metamask/keyring-api';\nimport { object, union } from '@metamask/superstruct';\n\nimport { KeyringAccountV1Struct } from './account';\n\nexport const AccountCreatedEventStruct = object({\n ...OriginalAccountCreatedEventStruct.schema,\n\n params: object({\n ...OriginalAccountCreatedEventStruct.schema.params.schema,\n account: union([KeyringAccountV1Struct, KeyringAccountStruct]),\n }),\n});\n\nexport const AccountUpdatedEventStruct = object({\n ...OriginalAccountUpdatedEventStruct.schema,\n\n params: object({\n ...OriginalAccountUpdatedEventStruct.schema.params.schema,\n account: union([KeyringAccountV1Struct, KeyringAccountStruct]),\n }),\n});\n\n// Re-export the all keyring events, so we don't have to mix between events coming\n// from `@metamask/keyring-api` and the local ones:\nexport {\n AccountDeletedEventStruct,\n RequestApprovedEventStruct,\n RequestRejectedEventStruct,\n};\n"]}
|