@metamask-previews/multichain-account-controller 0.0.0-preview-7b670bb5 → 0.0.0-preview-6a859e5b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MultichainAccountController.cjs +0 -4
- package/dist/MultichainAccountController.cjs.map +1 -1
- package/dist/MultichainAccountController.d.cts +1 -1
- package/dist/MultichainAccountController.d.cts.map +1 -1
- package/dist/MultichainAccountController.d.mts +1 -1
- package/dist/MultichainAccountController.d.mts.map +1 -1
- package/dist/MultichainAccountController.mjs +1 -5
- package/dist/MultichainAccountController.mjs.map +1 -1
- package/dist/index.cjs +3 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -4
@@ -13,11 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
13
13
|
var _MultichainAccountController_instances, _MultichainAccountController_messenger, _MultichainAccountController_providers, _MultichainAccountController_wallets, _MultichainAccountController_getWallet;
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.MultichainAccountController = void 0;
|
16
|
-
const keyring_api_1 = require("@metamask/keyring-api");
|
17
|
-
const keyring_controller_1 = require("@metamask/keyring-controller");
|
18
|
-
const keyring_snap_client_1 = require("@metamask/keyring-snap-client");
|
19
16
|
const multichain_account_api_1 = require("@metamask/multichain-account-api");
|
20
|
-
const snaps_utils_1 = require("@metamask/snaps-utils");
|
21
17
|
const EvmAccountProvider_1 = require("./providers/EvmAccountProvider.cjs");
|
22
18
|
const SolAccountProvider_1 = require("./providers/SolAccountProvider.cjs");
|
23
19
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MultichainAccountController.cjs","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"MultichainAccountController.cjs","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,6EAK0C;AAG1C,2EAAoE;AACpE,2EAAoE;AAiDpE;;GAEG;AACH,MAAa,2BAA2B;IAOtC;;;;;;OAMG;IACH,YAAY,EAAE,SAAS,EAAsC;;QAbpD,yDAAiD;QAEjD,yDAA8B;QAE9B,uDAAkE;QAUzE,uBAAA,IAAI,0CAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,wCAAY,IAAI,GAAG,EAAE,MAAA,CAAC;QAC1B,mFAAmF;QACnF,uBAAA,IAAI,0CAAc;YAChB,IAAI,uCAAkB,CAAC,uBAAA,IAAI,8CAAW,CAAC;YACvC,IAAI,uCAAkB,CAAC,uBAAA,IAAI,8CAAW,CAAC;SACxC,MAAA,CAAC;QAEF,oCAAoC;QACpC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,uBAAA,IAAI,8CAAW,EAAE;YACtC,KAAK,MAAM,aAAa,IAAI,QAAQ,CAAC,iBAAiB,EAAE,EAAE;gBACxD,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;aACnC;SACF;QAED,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YAC1C,gFAAgF;YAChF,oDAAoD;YACpD,MAAM,MAAM,GAAG,IAAI,uDAA8B,CAAC;gBAChD,aAAa;gBACb,SAAS,EAAE,uBAAA,IAAI,8CAAW;aAC3B,CAAC,CAAC;YAEH,uBAAA,IAAI,4CAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;SACtC;IACH,CAAC;IAgBD,oBAAoB,CAAC,EACnB,aAAa,EACb,UAAU,GAIX;QACC,MAAM,iBAAiB,GACrB,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEtD,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,oCAAoC,UAAU,EAAE,CAAC,CAAC;SACnE;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,qBAAqB,CAAC,EACpB,aAAa,GAGd;QACC,OAAO,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,QAAQ,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,EAChC,aAAa,GAGd;QACC,OAAO,MAAM,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,2BAA2B,EAAE,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,mCAAmC,CAAC,EACxC,aAAa,GAGd;QACC,OAAO,MAAM,uBAAA,IAAI,sFAAW,MAAf,IAAI,EACf,aAAa,CACd,CAAC,mCAAmC,EAAE,CAAC;IAC1C,CAAC;CACF;AAnGD,kEAmGC;uTAxDY,aAA8B;IACvC,MAAM,MAAM,GAAG,uBAAA,IAAI,4CAAS,CAAC,GAAG,CAC9B,IAAA,oDAA2B,EAAC,aAAa,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type { KeyringControllerWithKeyringAction } from '@metamask/keyring-controller';\nimport type {\n AccountProvider,\n MultichainAccountWalletId,\n} from '@metamask/multichain-account-api';\nimport {\n MultichainAccountWalletAdapter,\n toMultichainAccountWalletId,\n type MultichainAccount,\n type MultichainAccountWallet,\n} from '@metamask/multichain-account-api';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\n\n/**\n * All actions that {@link MultichainAccountController} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountControllerActions = never;\n/**\n * All events that {@link MultichainAccountController} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountControllerEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountController}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountController}\n * subscribes to.\n */\nexport type AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountController} needs to access.\n */\nexport type MultichainAccountControllerMessenger = RestrictedMessenger<\n 'MultichainAccountController',\n MultichainAccountControllerActions | AllowedActions,\n MultichainAccountControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * The options that {@link MultichainAccountController} takes.\n */\ntype MultichainAccountControllerOptions = {\n messenger: MultichainAccountControllerMessenger;\n};\n\n/**\n * Stateless controller to expose multichain accounts capabilities.\n */\nexport class MultichainAccountController {\n readonly #messenger: MultichainAccountControllerMessenger;\n\n readonly #providers: AccountProvider[];\n\n readonly #wallets: Map<MultichainAccountWalletId, MultichainAccountWallet>;\n\n /**\n * Constructs a new MultichainAccountController.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountController.\n */\n constructor({ messenger }: MultichainAccountControllerOptions) {\n this.#messenger = messenger;\n this.#wallets = new Map();\n // TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.\n this.#providers = [\n new EvmAccountProvider(this.#messenger),\n new SolAccountProvider(this.#messenger),\n ];\n\n // Gather all entropy sources first.\n const entropySources = new Set<EntropySourceId>();\n for (const provider of this.#providers) {\n for (const entropySource of provider.getEntropySources()) {\n entropySources.add(entropySource);\n }\n }\n\n for (const entropySource of entropySources) {\n // This will automatically create all multichain accounts for that wallet (based\n // on the accounts owned by each account providers).\n const wallet = new MultichainAccountWalletAdapter({\n entropySource,\n providers: this.#providers,\n });\n\n this.#wallets.set(wallet.id, wallet);\n }\n }\n\n #getWallet(entropySource: EntropySourceId): MultichainAccountWallet {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error(\n 'Unknown wallet, not wallet matching this entropy source',\n );\n }\n\n return wallet;\n }\n\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount {\n const multichainAccount =\n this.#getWallet(entropySource).accounts[groupIndex];\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount[] {\n return this.#getWallet(entropySource).accounts;\n }\n\n async createNextMultichainAccount({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): Promise<MultichainAccount> {\n return await this.#getWallet(entropySource).createNextMultichainAccount();\n }\n\n async discoverAndCreateMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): Promise<MultichainAccount[]> {\n return await this.#getWallet(\n entropySource,\n ).discoverAndCreateMultichainAccounts();\n }\n}\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
2
2
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
3
|
-
import {
|
3
|
+
import type { EntropySourceId } from "@metamask/keyring-api";
|
4
4
|
import type { KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
5
5
|
import { type MultichainAccount } from "@metamask/multichain-account-api";
|
6
6
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MultichainAccountController.d.cts","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,
|
1
|
+
{"version":3,"file":"MultichainAccountController.d.cts","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,qCAAqC;AAKvF,OAAO,EAGL,KAAK,iBAAiB,EAEvB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAK9G;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CAAC;AACvD;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,oCAAoC,GAAG,mBAAmB,CACpE,6BAA6B,EAC7B,kCAAkC,GAAG,cAAc,EACnD,iCAAiC,GAAG,aAAa,EACjD,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,kCAAkC,GAAG;IACxC,SAAS,EAAE,oCAAoC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,qBAAa,2BAA2B;;IAOtC;;;;;;OAMG;gBACS,EAAE,SAAS,EAAE,EAAE,kCAAkC;IA2C7D,oBAAoB,CAAC,EACnB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,iBAAiB;IAWrB,qBAAqB,CAAC,EACpB,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,iBAAiB,EAAE;IAIjB,2BAA2B,CAAC,EAChC,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxB,mCAAmC,CAAC,EACxC,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAKjC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
2
2
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
3
|
-
import {
|
3
|
+
import type { EntropySourceId } from "@metamask/keyring-api";
|
4
4
|
import type { KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
5
5
|
import { type MultichainAccount } from "@metamask/multichain-account-api";
|
6
6
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MultichainAccountController.d.mts","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,
|
1
|
+
{"version":3,"file":"MultichainAccountController.d.mts","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,qCAAqC;AAKvF,OAAO,EAGL,KAAK,iBAAiB,EAEvB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAK9G;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CAAC;AACvD;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,oCAAoC,GAAG,mBAAmB,CACpE,6BAA6B,EAC7B,kCAAkC,GAAG,cAAc,EACnD,iCAAiC,GAAG,aAAa,EACjD,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC;AAEF;;GAEG;AACH,KAAK,kCAAkC,GAAG;IACxC,SAAS,EAAE,oCAAoC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,qBAAa,2BAA2B;;IAOtC;;;;;;OAMG;gBACS,EAAE,SAAS,EAAE,EAAE,kCAAkC;IA2C7D,oBAAoB,CAAC,EACnB,aAAa,EACb,UAAU,GACX,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,iBAAiB;IAWrB,qBAAqB,CAAC,EACpB,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,iBAAiB,EAAE;IAIjB,2BAA2B,CAAC,EAChC,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxB,mCAAmC,CAAC,EACxC,aAAa,GACd,EAAE;QACD,aAAa,EAAE,eAAe,CAAC;KAChC,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;CAKjC"}
|
@@ -10,11 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
11
|
};
|
12
12
|
var _MultichainAccountController_instances, _MultichainAccountController_messenger, _MultichainAccountController_providers, _MultichainAccountController_wallets, _MultichainAccountController_getWallet;
|
13
|
-
import {
|
14
|
-
import { KeyringTypes } from "@metamask/keyring-controller";
|
15
|
-
import { KeyringClient } from "@metamask/keyring-snap-client";
|
16
|
-
import { MultichainAccountAdapter, MultichainAccountWalletAdapter, toMultichainAccountWalletId } from "@metamask/multichain-account-api";
|
17
|
-
import { HandlerType } from "@metamask/snaps-utils";
|
13
|
+
import { MultichainAccountWalletAdapter, toMultichainAccountWalletId } from "@metamask/multichain-account-api";
|
18
14
|
import { EvmAccountProvider } from "./providers/EvmAccountProvider.mjs";
|
19
15
|
import { SolAccountProvider } from "./providers/SolAccountProvider.mjs";
|
20
16
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MultichainAccountController.mjs","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"MultichainAccountController.mjs","sourceRoot":"","sources":["../src/MultichainAccountController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAG5B,yCAAyC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AAiDpE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAOtC;;;;;;OAMG;IACH,YAAY,EAAE,SAAS,EAAsC;;QAbpD,yDAAiD;QAEjD,yDAA8B;QAE9B,uDAAkE;QAUzE,uBAAA,IAAI,0CAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,wCAAY,IAAI,GAAG,EAAE,MAAA,CAAC;QAC1B,mFAAmF;QACnF,uBAAA,IAAI,0CAAc;YAChB,IAAI,kBAAkB,CAAC,uBAAA,IAAI,8CAAW,CAAC;YACvC,IAAI,kBAAkB,CAAC,uBAAA,IAAI,8CAAW,CAAC;SACxC,MAAA,CAAC;QAEF,oCAAoC;QACpC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,uBAAA,IAAI,8CAAW,EAAE;YACtC,KAAK,MAAM,aAAa,IAAI,QAAQ,CAAC,iBAAiB,EAAE,EAAE;gBACxD,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;aACnC;SACF;QAED,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YAC1C,gFAAgF;YAChF,oDAAoD;YACpD,MAAM,MAAM,GAAG,IAAI,8BAA8B,CAAC;gBAChD,aAAa;gBACb,SAAS,EAAE,uBAAA,IAAI,8CAAW;aAC3B,CAAC,CAAC;YAEH,uBAAA,IAAI,4CAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;SACtC;IACH,CAAC;IAgBD,oBAAoB,CAAC,EACnB,aAAa,EACb,UAAU,GAIX;QACC,MAAM,iBAAiB,GACrB,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEtD,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,oCAAoC,UAAU,EAAE,CAAC,CAAC;SACnE;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,qBAAqB,CAAC,EACpB,aAAa,GAGd;QACC,OAAO,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,QAAQ,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,EAChC,aAAa,GAGd;QACC,OAAO,MAAM,uBAAA,IAAI,sFAAW,MAAf,IAAI,EAAY,aAAa,CAAC,CAAC,2BAA2B,EAAE,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,mCAAmC,CAAC,EACxC,aAAa,GAGd;QACC,OAAO,MAAM,uBAAA,IAAI,sFAAW,MAAf,IAAI,EACf,aAAa,CACd,CAAC,mCAAmC,EAAE,CAAC;IAC1C,CAAC;CACF;uTAxDY,aAA8B;IACvC,MAAM,MAAM,GAAG,uBAAA,IAAI,4CAAS,CAAC,GAAG,CAC9B,2BAA2B,CAAC,aAAa,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type { KeyringControllerWithKeyringAction } from '@metamask/keyring-controller';\nimport type {\n AccountProvider,\n MultichainAccountWalletId,\n} from '@metamask/multichain-account-api';\nimport {\n MultichainAccountWalletAdapter,\n toMultichainAccountWalletId,\n type MultichainAccount,\n type MultichainAccountWallet,\n} from '@metamask/multichain-account-api';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\n\n/**\n * All actions that {@link MultichainAccountController} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountControllerActions = never;\n/**\n * All events that {@link MultichainAccountController} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountControllerEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountController}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountController}\n * subscribes to.\n */\nexport type AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountController} needs to access.\n */\nexport type MultichainAccountControllerMessenger = RestrictedMessenger<\n 'MultichainAccountController',\n MultichainAccountControllerActions | AllowedActions,\n MultichainAccountControllerEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n\n/**\n * The options that {@link MultichainAccountController} takes.\n */\ntype MultichainAccountControllerOptions = {\n messenger: MultichainAccountControllerMessenger;\n};\n\n/**\n * Stateless controller to expose multichain accounts capabilities.\n */\nexport class MultichainAccountController {\n readonly #messenger: MultichainAccountControllerMessenger;\n\n readonly #providers: AccountProvider[];\n\n readonly #wallets: Map<MultichainAccountWalletId, MultichainAccountWallet>;\n\n /**\n * Constructs a new MultichainAccountController.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountController.\n */\n constructor({ messenger }: MultichainAccountControllerOptions) {\n this.#messenger = messenger;\n this.#wallets = new Map();\n // TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.\n this.#providers = [\n new EvmAccountProvider(this.#messenger),\n new SolAccountProvider(this.#messenger),\n ];\n\n // Gather all entropy sources first.\n const entropySources = new Set<EntropySourceId>();\n for (const provider of this.#providers) {\n for (const entropySource of provider.getEntropySources()) {\n entropySources.add(entropySource);\n }\n }\n\n for (const entropySource of entropySources) {\n // This will automatically create all multichain accounts for that wallet (based\n // on the accounts owned by each account providers).\n const wallet = new MultichainAccountWalletAdapter({\n entropySource,\n providers: this.#providers,\n });\n\n this.#wallets.set(wallet.id, wallet);\n }\n }\n\n #getWallet(entropySource: EntropySourceId): MultichainAccountWallet {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error(\n 'Unknown wallet, not wallet matching this entropy source',\n );\n }\n\n return wallet;\n }\n\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount {\n const multichainAccount =\n this.#getWallet(entropySource).accounts[groupIndex];\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount[] {\n return this.#getWallet(entropySource).accounts;\n }\n\n async createNextMultichainAccount({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): Promise<MultichainAccount> {\n return await this.#getWallet(entropySource).createNextMultichainAccount();\n }\n\n async discoverAndCreateMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): Promise<MultichainAccount[]> {\n return await this.#getWallet(\n entropySource,\n ).discoverAndCreateMultichainAccounts();\n }\n}\n"]}
|
package/dist/index.cjs
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* @param name - The name to greet.
|
7
|
-
* @returns The greeting.
|
8
|
-
*/
|
9
|
-
function greeter(name) {
|
10
|
-
return `Hello, ${name}!`;
|
11
|
-
}
|
12
|
-
exports.default = greeter;
|
3
|
+
exports.MultichainAccountController = void 0;
|
4
|
+
var MultichainAccountController_1 = require("./MultichainAccountController.cjs");
|
5
|
+
Object.defineProperty(exports, "MultichainAccountController", { enumerable: true, get: function () { return MultichainAccountController_1.MultichainAccountController; } });
|
13
6
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iFAA4E;AAAnE,0IAAA,2BAA2B,OAAA","sourcesContent":["export type { MultichainAccountControllerMessenger } from './MultichainAccountController';\nexport { MultichainAccountController } from './MultichainAccountController';\n"]}
|
package/dist/index.d.cts
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*
|
4
|
-
* @param name - The name to greet.
|
5
|
-
* @returns The greeting.
|
6
|
-
*/
|
7
|
-
export default function greeter(name: string): string;
|
1
|
+
export type { MultichainAccountControllerMessenger } from "./MultichainAccountController.cjs";
|
2
|
+
export { MultichainAccountController } from "./MultichainAccountController.cjs";
|
8
3
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oCAAoC,EAAE,0CAAsC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,0CAAsC"}
|
package/dist/index.d.mts
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*
|
4
|
-
* @param name - The name to greet.
|
5
|
-
* @returns The greeting.
|
6
|
-
*/
|
7
|
-
export default function greeter(name: string): string;
|
1
|
+
export type { MultichainAccountControllerMessenger } from "./MultichainAccountController.mjs";
|
2
|
+
export { MultichainAccountController } from "./MultichainAccountController.mjs";
|
8
3
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oCAAoC,EAAE,0CAAsC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,0CAAsC"}
|
package/dist/index.mjs
CHANGED
@@ -1,10 +1,2 @@
|
|
1
|
-
|
2
|
-
* Example function that returns a greeting for the given name.
|
3
|
-
*
|
4
|
-
* @param name - The name to greet.
|
5
|
-
* @returns The greeting.
|
6
|
-
*/
|
7
|
-
export default function greeter(name) {
|
8
|
-
return `Hello, ${name}!`;
|
9
|
-
}
|
1
|
+
export { MultichainAccountController } from "./MultichainAccountController.mjs";
|
10
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,0CAAsC","sourcesContent":["export type { MultichainAccountControllerMessenger } from './MultichainAccountController';\nexport { MultichainAccountController } from './MultichainAccountController';\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask-previews/multichain-account-controller",
|
3
|
-
"version": "0.0.0-preview-
|
3
|
+
"version": "0.0.0-preview-6a859e5b",
|
4
4
|
"description": "example",
|
5
5
|
"keywords": [
|
6
6
|
"MetaMask",
|
@@ -18,9 +18,14 @@
|
|
18
18
|
"sideEffects": false,
|
19
19
|
"exports": {
|
20
20
|
".": {
|
21
|
-
"import":
|
22
|
-
|
23
|
-
|
21
|
+
"import": {
|
22
|
+
"types": "./dist/index.d.mts",
|
23
|
+
"default": "./dist/index.mjs"
|
24
|
+
},
|
25
|
+
"require": {
|
26
|
+
"types": "./dist/index.d.cts",
|
27
|
+
"default": "./dist/index.cjs"
|
28
|
+
}
|
24
29
|
},
|
25
30
|
"./package.json": "./package.json"
|
26
31
|
},
|