@metamask-previews/multichain-account-service 4.1.0-preview-a9886279 → 5.0.0-preview-6a568504
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 +36 -1
- package/dist/MultichainAccountGroup.cjs +84 -45
- package/dist/MultichainAccountGroup.cjs.map +1 -1
- package/dist/MultichainAccountGroup.d.cts +17 -4
- package/dist/MultichainAccountGroup.d.cts.map +1 -1
- package/dist/MultichainAccountGroup.d.mts +17 -4
- package/dist/MultichainAccountGroup.d.mts.map +1 -1
- package/dist/MultichainAccountGroup.mjs +84 -45
- package/dist/MultichainAccountGroup.mjs.map +1 -1
- package/dist/MultichainAccountService.cjs +150 -112
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts +49 -20
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts +49 -20
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +151 -113
- package/dist/MultichainAccountService.mjs.map +1 -1
- package/dist/MultichainAccountWallet.cjs +108 -123
- package/dist/MultichainAccountWallet.cjs.map +1 -1
- package/dist/MultichainAccountWallet.d.cts +5 -4
- package/dist/MultichainAccountWallet.d.cts.map +1 -1
- package/dist/MultichainAccountWallet.d.mts +5 -4
- package/dist/MultichainAccountWallet.d.mts.map +1 -1
- package/dist/MultichainAccountWallet.mjs +108 -123
- package/dist/MultichainAccountWallet.mjs.map +1 -1
- package/dist/providers/AccountProviderWrapper.cjs +18 -0
- package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.cts +12 -0
- package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.mts +12 -0
- package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
- package/dist/providers/AccountProviderWrapper.mjs +18 -0
- package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.cjs +45 -20
- package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.cts +58 -6
- package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.mts +58 -6
- package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.mjs +45 -20
- package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
- package/dist/providers/BtcAccountProvider.cjs +47 -32
- package/dist/providers/BtcAccountProvider.cjs.map +1 -1
- package/dist/providers/BtcAccountProvider.d.cts +2 -1
- package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
- package/dist/providers/BtcAccountProvider.d.mts +2 -1
- package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
- package/dist/providers/BtcAccountProvider.mjs +47 -32
- package/dist/providers/BtcAccountProvider.mjs.map +1 -1
- package/dist/providers/EvmAccountProvider.cjs +39 -5
- package/dist/providers/EvmAccountProvider.cjs.map +1 -1
- package/dist/providers/EvmAccountProvider.d.cts +8 -0
- package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
- package/dist/providers/EvmAccountProvider.d.mts +8 -0
- package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
- package/dist/providers/EvmAccountProvider.mjs +39 -5
- package/dist/providers/EvmAccountProvider.mjs.map +1 -1
- package/dist/providers/SnapAccountProvider.cjs +81 -54
- package/dist/providers/SnapAccountProvider.cjs.map +1 -1
- package/dist/providers/SnapAccountProvider.d.cts +16 -4
- package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
- package/dist/providers/SnapAccountProvider.d.mts +16 -4
- package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
- package/dist/providers/SnapAccountProvider.mjs +81 -54
- package/dist/providers/SnapAccountProvider.mjs.map +1 -1
- package/dist/providers/SolAccountProvider.cjs +40 -31
- package/dist/providers/SolAccountProvider.cjs.map +1 -1
- package/dist/providers/SolAccountProvider.d.cts.map +1 -1
- package/dist/providers/SolAccountProvider.d.mts.map +1 -1
- package/dist/providers/SolAccountProvider.mjs +40 -31
- package/dist/providers/SolAccountProvider.mjs.map +1 -1
- package/dist/providers/TrxAccountProvider.cjs +48 -29
- package/dist/providers/TrxAccountProvider.cjs.map +1 -1
- package/dist/providers/TrxAccountProvider.d.cts +1 -0
- package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
- package/dist/providers/TrxAccountProvider.d.mts +1 -0
- package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
- package/dist/providers/TrxAccountProvider.mjs +48 -29
- package/dist/providers/TrxAccountProvider.mjs.map +1 -1
- package/dist/snaps/SnapPlatformWatcher.cjs +60 -0
- package/dist/snaps/SnapPlatformWatcher.cjs.map +1 -0
- package/dist/snaps/SnapPlatformWatcher.d.cts +8 -0
- package/dist/snaps/SnapPlatformWatcher.d.cts.map +1 -0
- package/dist/snaps/SnapPlatformWatcher.d.mts +8 -0
- package/dist/snaps/SnapPlatformWatcher.d.mts.map +1 -0
- package/dist/snaps/SnapPlatformWatcher.mjs +57 -0
- package/dist/snaps/SnapPlatformWatcher.mjs.map +1 -0
- package/dist/tests/messenger.cjs +12 -1
- package/dist/tests/messenger.cjs.map +1 -1
- package/dist/tests/messenger.d.cts +9 -4
- package/dist/tests/messenger.d.cts.map +1 -1
- package/dist/tests/messenger.d.mts +9 -4
- package/dist/tests/messenger.d.mts.map +1 -1
- package/dist/tests/messenger.mjs +12 -1
- package/dist/tests/messenger.mjs.map +1 -1
- package/dist/tests/providers.cjs +62 -7
- package/dist/tests/providers.cjs.map +1 -1
- package/dist/tests/providers.d.cts +17 -3
- package/dist/tests/providers.d.cts.map +1 -1
- package/dist/tests/providers.d.mts +17 -3
- package/dist/tests/providers.d.mts.map +1 -1
- package/dist/tests/providers.mjs +60 -6
- package/dist/tests/providers.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +14 -6
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +14 -6
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +1 -11
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +0 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +0 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +0 -9
- package/dist/utils.mjs.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,4BAA4B;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,
|
|
1
|
+
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,4BAA4B;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,MAAM,MAAM,kCAAkC,GAC5C,gBAAgB,CAAC,iCAAiC,CAAC,CAAC;AAEtD,MAAM,MAAM,iCAAiC,GAC3C,eAAe,CAAC,iCAAiC,CAAC,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG,SAAS,CACnC,gBAAgB,EAChB,kCAAkC,EAClC,iCAAiC,CAClC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAClD,aAAa,EAAE,aAAa,EAC5B,KAAK,CAAC,EAAE;IACN,OAAO,CAAC,EAAE,kCAAkC,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,MAAM,CAAC,EAAE,iCAAiC,CAAC,MAAM,CAAC,EAAE,CAAC;CACtD,GACA,iCAAiC,CAuCnC"}
|
package/dist/tests/messenger.mjs
CHANGED
|
@@ -14,9 +14,12 @@ export function getRootMessenger() {
|
|
|
14
14
|
* Retrieves a restricted messenger for the MultichainAccountService.
|
|
15
15
|
*
|
|
16
16
|
* @param rootMessenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().
|
|
17
|
+
* @param extra - Extra messenger options.
|
|
18
|
+
* @param extra.actions - Extra actions to delegate.
|
|
19
|
+
* @param extra.events - Extra events to delegate.
|
|
17
20
|
* @returns The restricted messenger for the MultichainAccountService.
|
|
18
21
|
*/
|
|
19
|
-
export function getMultichainAccountServiceMessenger(rootMessenger) {
|
|
22
|
+
export function getMultichainAccountServiceMessenger(rootMessenger, extra) {
|
|
20
23
|
const messenger = new Messenger({
|
|
21
24
|
namespace: 'MultichainAccountService',
|
|
22
25
|
parent: rootMessenger,
|
|
@@ -27,6 +30,7 @@ export function getMultichainAccountServiceMessenger(rootMessenger) {
|
|
|
27
30
|
'AccountsController:getAccount',
|
|
28
31
|
'AccountsController:getAccountByAddress',
|
|
29
32
|
'AccountsController:listMultichainAccounts',
|
|
33
|
+
'SnapController:getState',
|
|
30
34
|
'SnapController:handleRequest',
|
|
31
35
|
'KeyringController:withKeyring',
|
|
32
36
|
'KeyringController:getState',
|
|
@@ -34,11 +38,18 @@ export function getMultichainAccountServiceMessenger(rootMessenger) {
|
|
|
34
38
|
'KeyringController:addNewKeyring',
|
|
35
39
|
'NetworkController:findNetworkClientIdByChainId',
|
|
36
40
|
'NetworkController:getNetworkClientById',
|
|
41
|
+
'KeyringController:createNewVaultAndKeychain',
|
|
42
|
+
'KeyringController:createNewVaultAndRestore',
|
|
43
|
+
'AccountsController:getAccounts',
|
|
44
|
+
'KeyringController:removeAccount',
|
|
45
|
+
...(extra?.actions ?? []),
|
|
37
46
|
],
|
|
38
47
|
events: [
|
|
39
48
|
'KeyringController:stateChange',
|
|
49
|
+
'SnapController:stateChange',
|
|
40
50
|
'AccountsController:accountAdded',
|
|
41
51
|
'AccountsController:accountRemoved',
|
|
52
|
+
...(extra?.events ?? []),
|
|
42
53
|
],
|
|
43
54
|
});
|
|
44
55
|
return messenger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAqBpE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,kBAAkB;QAC7B,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAqBpE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,kBAAkB;QAC7B,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oCAAoC,CAClD,aAA4B,EAC5B,KAGC;IAED,MAAM,SAAS,GAAG,IAAI,SAAS,CAK7B;QACA,SAAS,EAAE,0BAA0B;QACrC,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IACH,aAAa,CAAC,QAAQ,CAAC;QACrB,SAAS;QACT,OAAO,EAAE;YACP,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,yBAAyB;YACzB,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;YAC5B,qCAAqC;YACrC,iCAAiC;YACjC,gDAAgD;YAChD,wCAAwC;YACxC,6CAA6C;YAC7C,4CAA4C;YAC5C,gCAAgC;YAChC,iCAAiC;YACjC,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE,CAAC;SAC1B;QACD,MAAM,EAAE;YACN,+BAA+B;YAC/B,4BAA4B;YAC5B,iCAAiC;YACjC,mCAAmC;YACnC,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC;SACzB;KACF,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type AllMultichainAccountServiceActions =\n MessengerActions<MultichainAccountServiceMessenger>;\n\nexport type AllMultichainAccountServiceEvents =\n MessengerEvents<MultichainAccountServiceMessenger>;\n\nexport type RootMessenger = Messenger<\n MockAnyNamespace,\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents\n>;\n\n/**\n * Creates and returns a root messenger for testing\n *\n * @returns A messenger instance\n */\nexport function getRootMessenger(): RootMessenger {\n return new Messenger({\n namespace: MOCK_ANY_NAMESPACE,\n captureException: jest.fn(),\n });\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param rootMessenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @param extra - Extra messenger options.\n * @param extra.actions - Extra actions to delegate.\n * @param extra.events - Extra events to delegate.\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n rootMessenger: RootMessenger,\n extra?: {\n actions?: AllMultichainAccountServiceActions['type'][];\n events?: AllMultichainAccountServiceEvents['type'][];\n },\n): MultichainAccountServiceMessenger {\n const messenger = new Messenger<\n 'MultichainAccountService',\n AllMultichainAccountServiceActions,\n AllMultichainAccountServiceEvents,\n RootMessenger\n >({\n namespace: 'MultichainAccountService',\n parent: rootMessenger,\n });\n rootMessenger.delegate({\n messenger,\n actions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:getState',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n 'KeyringController:getKeyringsByType',\n 'KeyringController:addNewKeyring',\n 'NetworkController:findNetworkClientIdByChainId',\n 'NetworkController:getNetworkClientById',\n 'KeyringController:createNewVaultAndKeychain',\n 'KeyringController:createNewVaultAndRestore',\n 'AccountsController:getAccounts',\n 'KeyringController:removeAccount',\n ...(extra?.actions ?? []),\n ],\n events: [\n 'KeyringController:stateChange',\n 'SnapController:stateChange',\n 'AccountsController:accountAdded',\n 'AccountsController:accountRemoved',\n ...(extra?.events ?? []),\n ],\n });\n return messenger;\n}\n"]}
|
package/dist/tests/providers.cjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const account_api_1 = require("@metamask/account-api");
|
|
3
|
+
exports.mockCreateAccountsOnce = exports.setupBip44AccountProvider = exports.makeMockAccountProvider = void 0;
|
|
5
4
|
const providers_1 = require("../providers/index.cjs");
|
|
6
5
|
function makeMockAccountProvider(accounts = []) {
|
|
7
6
|
return {
|
|
8
|
-
accounts,
|
|
7
|
+
mockAccounts: accounts,
|
|
8
|
+
accounts: new Set(),
|
|
9
9
|
constructor: jest.fn(),
|
|
10
|
+
alignAccounts: jest.fn(),
|
|
11
|
+
init: jest.fn(),
|
|
10
12
|
resyncAccounts: jest.fn(),
|
|
11
13
|
getAccount: jest.fn(),
|
|
12
14
|
getAccounts: jest.fn(),
|
|
@@ -14,26 +16,79 @@ function makeMockAccountProvider(accounts = []) {
|
|
|
14
16
|
discoverAccounts: jest.fn(),
|
|
15
17
|
isAccountCompatible: jest.fn(),
|
|
16
18
|
getName: jest.fn(),
|
|
19
|
+
isDisabled: jest.fn(),
|
|
20
|
+
setEnabled: jest.fn(),
|
|
21
|
+
isEnabled: true,
|
|
17
22
|
};
|
|
18
23
|
}
|
|
19
24
|
exports.makeMockAccountProvider = makeMockAccountProvider;
|
|
20
|
-
function
|
|
25
|
+
function setupBip44AccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), index, }) {
|
|
21
26
|
// You can mock this and all other mocks will re-use that list
|
|
22
27
|
// of accounts.
|
|
23
|
-
mocks.
|
|
24
|
-
|
|
28
|
+
mocks.mockAccounts = accounts;
|
|
29
|
+
mocks.accounts = new Set(accounts.map((account) => account.id));
|
|
30
|
+
// Toggle enabled state only
|
|
31
|
+
mocks.setEnabled.mockImplementation((enabled) => {
|
|
32
|
+
mocks.isEnabled = enabled;
|
|
33
|
+
});
|
|
34
|
+
mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);
|
|
35
|
+
const getAccounts = () => mocks.mockAccounts.filter((account) => [...mocks.accounts].includes(account.id));
|
|
25
36
|
mocks.getName.mockImplementation(() => name);
|
|
26
37
|
mocks.getAccounts.mockImplementation(getAccounts);
|
|
27
38
|
mocks.getAccount.mockImplementation((id) =>
|
|
28
39
|
// Assuming this never fails.
|
|
29
40
|
getAccounts().find((account) => account.id === id));
|
|
30
41
|
mocks.createAccounts.mockResolvedValue([]);
|
|
42
|
+
mocks.alignAccounts.mockImplementation(async ({ entropySource, groupIndex, }) => {
|
|
43
|
+
if (mocks.isDisabled()) {
|
|
44
|
+
const wrapperAlign = providers_1.AccountProviderWrapper.prototype.alignAccounts;
|
|
45
|
+
const ids = await wrapperAlign.call({ isEnabled: false, isDisabled: () => true }, { entropySource, groupIndex });
|
|
46
|
+
return ids;
|
|
47
|
+
}
|
|
48
|
+
const createdAccounts = await mocks.createAccounts({
|
|
49
|
+
entropySource,
|
|
50
|
+
groupIndex,
|
|
51
|
+
});
|
|
52
|
+
const baseAlign = providers_1.BaseBip44AccountProvider.prototype.alignAccounts;
|
|
53
|
+
const ids = await baseAlign.call({ createAccounts: async () => createdAccounts }, { entropySource, groupIndex });
|
|
54
|
+
return ids;
|
|
55
|
+
});
|
|
56
|
+
mocks.init.mockImplementation((accountIds) => {
|
|
57
|
+
accountIds.forEach((id) => mocks.accounts.add(id));
|
|
58
|
+
});
|
|
31
59
|
if (index === 0) {
|
|
32
60
|
// Make the first provider to always be an `EvmAccountProvider`, since we
|
|
33
61
|
// check for this pre-condition in some methods.
|
|
34
62
|
Object.setPrototypeOf(mocks, providers_1.EvmAccountProvider.prototype);
|
|
35
63
|
}
|
|
64
|
+
if (index !== 0) {
|
|
65
|
+
Object.setPrototypeOf(mocks, providers_1.AccountProviderWrapper.prototype);
|
|
66
|
+
}
|
|
36
67
|
return mocks;
|
|
37
68
|
}
|
|
38
|
-
exports.
|
|
69
|
+
exports.setupBip44AccountProvider = setupBip44AccountProvider;
|
|
70
|
+
/**
|
|
71
|
+
* Helper to mock a single createAccounts call while updating the provider's
|
|
72
|
+
* internal state so subsequent getAccount/getAccounts can resolve the accounts.
|
|
73
|
+
*
|
|
74
|
+
* @param provider - The mock provider whose createAccounts call to mock.
|
|
75
|
+
* @param created - The accounts to be returned and persisted in the mock state.
|
|
76
|
+
*/
|
|
77
|
+
function mockCreateAccountsOnce(provider, created) {
|
|
78
|
+
provider.createAccounts.mockImplementationOnce(async () => {
|
|
79
|
+
// Add newly created accounts to the provider's internal store
|
|
80
|
+
for (const acc of created) {
|
|
81
|
+
if (!provider.mockAccounts.some((a) => a.id === acc.id)) {
|
|
82
|
+
provider.mockAccounts.push(acc);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Merge IDs into the visible list used by getAccounts/getAccount
|
|
86
|
+
const ids = created.map((a) => a.id);
|
|
87
|
+
for (const id of ids) {
|
|
88
|
+
provider.accounts.add(id);
|
|
89
|
+
}
|
|
90
|
+
return created;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports.mockCreateAccountsOnce = mockCreateAccountsOnce;
|
|
39
94
|
//# sourceMappingURL=providers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"providers.cjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";;;AAGA,sDAIsB;AAoBtB,SAAgB,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AApBD,0DAoBC;AAED,SAAgB,yBAAyB,CAAC,EACxC,IAAI,GAAG,iBAAiB,EACxB,QAAQ,EACR,KAAK,GAAG,uBAAuB,EAAE,EACjC,KAAK,GAON;IACC,8DAA8D;IAC9D,eAAe;IACf,KAAK,CAAC,YAAY,GAAG,QAAQ,CAAC;IAC9B,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;I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AC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,iEAAiE;QACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,wDAmBC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport {\n AccountProviderWrapper,\n EvmAccountProvider,\n BaseBip44AccountProvider,\n} from '../providers';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible: jest.Mock;\n getName: jest.Mock;\n isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = () =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n mocks.alignAccounts.mockImplementation(\n async ({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => {\n if (mocks.isDisabled()) {\n const wrapperAlign = (\n AccountProviderWrapper.prototype as unknown as {\n alignAccounts: (\n this: { isEnabled: boolean },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await wrapperAlign.call(\n { isEnabled: false, isDisabled: () => true },\n { entropySource, groupIndex },\n );\n return ids;\n }\n const createdAccounts = await mocks.createAccounts({\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (o: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<unknown[]>;\n },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await baseAlign.call(\n { createAccounts: async () => createdAccounts },\n { entropySource, groupIndex },\n );\n\n return ids;\n },\n );\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n"]}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
3
3
|
export type MockAccountProvider = {
|
|
4
|
-
|
|
4
|
+
mockAccounts: KeyringAccount[];
|
|
5
|
+
accounts: Set<KeyringAccount['id']>;
|
|
5
6
|
constructor: jest.Mock;
|
|
7
|
+
alignAccounts: jest.Mock;
|
|
8
|
+
init: jest.Mock;
|
|
6
9
|
resyncAccounts: jest.Mock;
|
|
7
10
|
getAccount: jest.Mock;
|
|
8
11
|
getAccounts: jest.Mock;
|
|
9
12
|
createAccounts: jest.Mock;
|
|
10
13
|
discoverAccounts: jest.Mock;
|
|
11
|
-
isAccountCompatible
|
|
14
|
+
isAccountCompatible: jest.Mock;
|
|
12
15
|
getName: jest.Mock;
|
|
16
|
+
isEnabled: boolean;
|
|
17
|
+
isDisabled: jest.Mock;
|
|
18
|
+
setEnabled: jest.Mock;
|
|
13
19
|
};
|
|
14
20
|
export declare function makeMockAccountProvider(accounts?: KeyringAccount[]): MockAccountProvider;
|
|
15
|
-
export declare function
|
|
21
|
+
export declare function setupBip44AccountProvider({ name, accounts, mocks, index, }: {
|
|
16
22
|
name?: string;
|
|
17
23
|
mocks?: MockAccountProvider;
|
|
18
24
|
accounts: KeyringAccount[];
|
|
19
25
|
filter?: (account: KeyringAccount) => boolean;
|
|
20
26
|
index?: number;
|
|
21
27
|
}): MockAccountProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to mock a single createAccounts call while updating the provider's
|
|
30
|
+
* internal state so subsequent getAccount/getAccounts can resolve the accounts.
|
|
31
|
+
*
|
|
32
|
+
* @param provider - The mock provider whose createAccounts call to mock.
|
|
33
|
+
* @param created - The accounts to be returned and persisted in the mock state.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
|
|
22
36
|
//# sourceMappingURL=providers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.cts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"providers.d.cts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,8BAA8B;AAQ7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;IAChB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC;IACvB,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC;IAC1B,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC5B,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;IACtB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,cAAc,EAAO,GAC9B,mBAAmB,CAkBrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,IAAwB,EACxB,QAAQ,EACR,KAAiC,EACjC,KAAK,GACN,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,mBAAmB,CA2FtB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,cAAc,EAAE,GACxB,IAAI,CAgBN"}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
3
3
|
export type MockAccountProvider = {
|
|
4
|
-
|
|
4
|
+
mockAccounts: KeyringAccount[];
|
|
5
|
+
accounts: Set<KeyringAccount['id']>;
|
|
5
6
|
constructor: jest.Mock;
|
|
7
|
+
alignAccounts: jest.Mock;
|
|
8
|
+
init: jest.Mock;
|
|
6
9
|
resyncAccounts: jest.Mock;
|
|
7
10
|
getAccount: jest.Mock;
|
|
8
11
|
getAccounts: jest.Mock;
|
|
9
12
|
createAccounts: jest.Mock;
|
|
10
13
|
discoverAccounts: jest.Mock;
|
|
11
|
-
isAccountCompatible
|
|
14
|
+
isAccountCompatible: jest.Mock;
|
|
12
15
|
getName: jest.Mock;
|
|
16
|
+
isEnabled: boolean;
|
|
17
|
+
isDisabled: jest.Mock;
|
|
18
|
+
setEnabled: jest.Mock;
|
|
13
19
|
};
|
|
14
20
|
export declare function makeMockAccountProvider(accounts?: KeyringAccount[]): MockAccountProvider;
|
|
15
|
-
export declare function
|
|
21
|
+
export declare function setupBip44AccountProvider({ name, accounts, mocks, index, }: {
|
|
16
22
|
name?: string;
|
|
17
23
|
mocks?: MockAccountProvider;
|
|
18
24
|
accounts: KeyringAccount[];
|
|
19
25
|
filter?: (account: KeyringAccount) => boolean;
|
|
20
26
|
index?: number;
|
|
21
27
|
}): MockAccountProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to mock a single createAccounts call while updating the provider's
|
|
30
|
+
* internal state so subsequent getAccount/getAccounts can resolve the accounts.
|
|
31
|
+
*
|
|
32
|
+
* @param provider - The mock provider whose createAccounts call to mock.
|
|
33
|
+
* @param created - The accounts to be returned and persisted in the mock state.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mockCreateAccountsOnce(provider: MockAccountProvider, created: KeyringAccount[]): void;
|
|
22
36
|
//# sourceMappingURL=providers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"providers.d.mts","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,8BAA8B;AAQ7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,cAAc,EA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
|
|
2
|
-
import { EvmAccountProvider } from "../providers/index.mjs";
|
|
1
|
+
import { AccountProviderWrapper, EvmAccountProvider, BaseBip44AccountProvider } from "../providers/index.mjs";
|
|
3
2
|
export function makeMockAccountProvider(accounts = []) {
|
|
4
3
|
return {
|
|
5
|
-
accounts,
|
|
4
|
+
mockAccounts: accounts,
|
|
5
|
+
accounts: new Set(),
|
|
6
6
|
constructor: jest.fn(),
|
|
7
|
+
alignAccounts: jest.fn(),
|
|
8
|
+
init: jest.fn(),
|
|
7
9
|
resyncAccounts: jest.fn(),
|
|
8
10
|
getAccount: jest.fn(),
|
|
9
11
|
getAccounts: jest.fn(),
|
|
@@ -11,24 +13,76 @@ export function makeMockAccountProvider(accounts = []) {
|
|
|
11
13
|
discoverAccounts: jest.fn(),
|
|
12
14
|
isAccountCompatible: jest.fn(),
|
|
13
15
|
getName: jest.fn(),
|
|
16
|
+
isDisabled: jest.fn(),
|
|
17
|
+
setEnabled: jest.fn(),
|
|
18
|
+
isEnabled: true,
|
|
14
19
|
};
|
|
15
20
|
}
|
|
16
|
-
export function
|
|
21
|
+
export function setupBip44AccountProvider({ name = 'Mocked Provider', accounts, mocks = makeMockAccountProvider(), index, }) {
|
|
17
22
|
// You can mock this and all other mocks will re-use that list
|
|
18
23
|
// of accounts.
|
|
19
|
-
mocks.
|
|
20
|
-
|
|
24
|
+
mocks.mockAccounts = accounts;
|
|
25
|
+
mocks.accounts = new Set(accounts.map((account) => account.id));
|
|
26
|
+
// Toggle enabled state only
|
|
27
|
+
mocks.setEnabled.mockImplementation((enabled) => {
|
|
28
|
+
mocks.isEnabled = enabled;
|
|
29
|
+
});
|
|
30
|
+
mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);
|
|
31
|
+
const getAccounts = () => mocks.mockAccounts.filter((account) => [...mocks.accounts].includes(account.id));
|
|
21
32
|
mocks.getName.mockImplementation(() => name);
|
|
22
33
|
mocks.getAccounts.mockImplementation(getAccounts);
|
|
23
34
|
mocks.getAccount.mockImplementation((id) =>
|
|
24
35
|
// Assuming this never fails.
|
|
25
36
|
getAccounts().find((account) => account.id === id));
|
|
26
37
|
mocks.createAccounts.mockResolvedValue([]);
|
|
38
|
+
mocks.alignAccounts.mockImplementation(async ({ entropySource, groupIndex, }) => {
|
|
39
|
+
if (mocks.isDisabled()) {
|
|
40
|
+
const wrapperAlign = AccountProviderWrapper.prototype.alignAccounts;
|
|
41
|
+
const ids = await wrapperAlign.call({ isEnabled: false, isDisabled: () => true }, { entropySource, groupIndex });
|
|
42
|
+
return ids;
|
|
43
|
+
}
|
|
44
|
+
const createdAccounts = await mocks.createAccounts({
|
|
45
|
+
entropySource,
|
|
46
|
+
groupIndex,
|
|
47
|
+
});
|
|
48
|
+
const baseAlign = BaseBip44AccountProvider.prototype.alignAccounts;
|
|
49
|
+
const ids = await baseAlign.call({ createAccounts: async () => createdAccounts }, { entropySource, groupIndex });
|
|
50
|
+
return ids;
|
|
51
|
+
});
|
|
52
|
+
mocks.init.mockImplementation((accountIds) => {
|
|
53
|
+
accountIds.forEach((id) => mocks.accounts.add(id));
|
|
54
|
+
});
|
|
27
55
|
if (index === 0) {
|
|
28
56
|
// Make the first provider to always be an `EvmAccountProvider`, since we
|
|
29
57
|
// check for this pre-condition in some methods.
|
|
30
58
|
Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);
|
|
31
59
|
}
|
|
60
|
+
if (index !== 0) {
|
|
61
|
+
Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);
|
|
62
|
+
}
|
|
32
63
|
return mocks;
|
|
33
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Helper to mock a single createAccounts call while updating the provider's
|
|
67
|
+
* internal state so subsequent getAccount/getAccounts can resolve the accounts.
|
|
68
|
+
*
|
|
69
|
+
* @param provider - The mock provider whose createAccounts call to mock.
|
|
70
|
+
* @param created - The accounts to be returned and persisted in the mock state.
|
|
71
|
+
*/
|
|
72
|
+
export function mockCreateAccountsOnce(provider, created) {
|
|
73
|
+
provider.createAccounts.mockImplementationOnce(async () => {
|
|
74
|
+
// Add newly created accounts to the provider's internal store
|
|
75
|
+
for (const acc of created) {
|
|
76
|
+
if (!provider.mockAccounts.some((a) => a.id === acc.id)) {
|
|
77
|
+
provider.mockAccounts.push(acc);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Merge IDs into the visible list used by getAccounts/getAccount
|
|
81
|
+
const ids = created.map((a) => a.id);
|
|
82
|
+
for (const id of ids) {
|
|
83
|
+
provider.accounts.add(id);
|
|
84
|
+
}
|
|
85
|
+
return created;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
34
88
|
//# sourceMappingURL=providers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"providers.mjs","sourceRoot":"","sources":["../../src/tests/providers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACzB,+BAAqB;AAoBtB,MAAM,UAAU,uBAAuB,CACrC,WAA6B,EAAE;IAE/B,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;QACzB,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3B,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,UAAU,EAAE,IAA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AAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAA6B,EAC7B,OAAyB;IAEzB,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,KAAK,IAAI,EAAE;QACxD,8DAA8D;QAC9D,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,iEAAiE;QACjE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\n\nimport {\n AccountProviderWrapper,\n EvmAccountProvider,\n BaseBip44AccountProvider,\n} from '../providers';\n\nexport type MockAccountProvider = {\n mockAccounts: KeyringAccount[];\n accounts: Set<KeyringAccount['id']>;\n constructor: jest.Mock;\n alignAccounts: jest.Mock;\n init: jest.Mock;\n resyncAccounts: jest.Mock;\n getAccount: jest.Mock;\n getAccounts: jest.Mock;\n createAccounts: jest.Mock;\n discoverAccounts: jest.Mock;\n isAccountCompatible: jest.Mock;\n getName: jest.Mock;\n isEnabled: boolean;\n isDisabled: jest.Mock;\n setEnabled: jest.Mock;\n};\n\nexport function makeMockAccountProvider(\n accounts: KeyringAccount[] = [],\n): MockAccountProvider {\n return {\n mockAccounts: accounts,\n accounts: new Set(),\n constructor: jest.fn(),\n alignAccounts: jest.fn(),\n init: jest.fn(),\n resyncAccounts: jest.fn(),\n getAccount: jest.fn(),\n getAccounts: jest.fn(),\n createAccounts: jest.fn(),\n discoverAccounts: jest.fn(),\n isAccountCompatible: jest.fn(),\n getName: jest.fn(),\n isDisabled: jest.fn(),\n setEnabled: jest.fn(),\n isEnabled: true,\n };\n}\n\nexport function setupBip44AccountProvider({\n name = 'Mocked Provider',\n accounts,\n mocks = makeMockAccountProvider(),\n index,\n}: {\n name?: string;\n mocks?: MockAccountProvider;\n accounts: KeyringAccount[];\n filter?: (account: KeyringAccount) => boolean;\n index?: number;\n}): MockAccountProvider {\n // You can mock this and all other mocks will re-use that list\n // of accounts.\n mocks.mockAccounts = accounts;\n mocks.accounts = new Set(accounts.map((account) => account.id));\n // Toggle enabled state only\n mocks.setEnabled.mockImplementation((enabled: boolean) => {\n mocks.isEnabled = enabled;\n });\n mocks.isDisabled.mockImplementation(() => !mocks.isEnabled);\n\n const getAccounts = () =>\n mocks.mockAccounts.filter((account) =>\n [...mocks.accounts].includes(account.id),\n );\n\n mocks.getName.mockImplementation(() => name);\n\n mocks.getAccounts.mockImplementation(getAccounts);\n mocks.getAccount.mockImplementation(\n (id: Bip44Account<KeyringAccount>['id']) =>\n // Assuming this never fails.\n getAccounts().find((account) => account.id === id),\n );\n mocks.createAccounts.mockResolvedValue([]);\n mocks.alignAccounts.mockImplementation(\n async ({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => {\n if (mocks.isDisabled()) {\n const wrapperAlign = (\n AccountProviderWrapper.prototype as unknown as {\n alignAccounts: (\n this: { isEnabled: boolean },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await wrapperAlign.call(\n { isEnabled: false, isDisabled: () => true },\n { entropySource, groupIndex },\n );\n return ids;\n }\n const createdAccounts = await mocks.createAccounts({\n entropySource,\n groupIndex,\n });\n\n const baseAlign = (\n BaseBip44AccountProvider.prototype as unknown as {\n alignAccounts: (\n this: {\n createAccounts: (o: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }) => Promise<unknown[]>;\n },\n opts: { entropySource: EntropySourceId; groupIndex: number },\n ) => Promise<string[]>;\n }\n ).alignAccounts;\n const ids = await baseAlign.call(\n { createAccounts: async () => createdAccounts },\n { entropySource, groupIndex },\n );\n\n return ids;\n },\n );\n mocks.init.mockImplementation(\n (accountIds: Bip44Account<KeyringAccount>['id'][]) => {\n accountIds.forEach((id) => mocks.accounts.add(id));\n },\n );\n\n if (index === 0) {\n // Make the first provider to always be an `EvmAccountProvider`, since we\n // check for this pre-condition in some methods.\n Object.setPrototypeOf(mocks, EvmAccountProvider.prototype);\n }\n\n if (index !== 0) {\n Object.setPrototypeOf(mocks, AccountProviderWrapper.prototype);\n }\n\n return mocks;\n}\n\n/**\n * Helper to mock a single createAccounts call while updating the provider's\n * internal state so subsequent getAccount/getAccounts can resolve the accounts.\n *\n * @param provider - The mock provider whose createAccounts call to mock.\n * @param created - The accounts to be returned and persisted in the mock state.\n */\nexport function mockCreateAccountsOnce(\n provider: MockAccountProvider,\n created: KeyringAccount[],\n): void {\n provider.createAccounts.mockImplementationOnce(async () => {\n // Add newly created accounts to the provider's internal store\n for (const acc of created) {\n if (!provider.mockAccounts.some((a) => a.id === acc.id)) {\n provider.mockAccounts.push(acc);\n }\n }\n // Merge IDs into the visible list used by getAccounts/getAccount\n const ids = created.map((a) => a.id);\n for (const id of ids) {\n provider.accounts.add(id);\n }\n\n return created;\n });\n}\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Bip44Account,\n MultichainAccountGroup,\n MultichainAccountWalletId,\n MultichainAccountWalletStatus,\n} from '@metamask/account-api';\nimport type {\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerGetAccountsAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { KeyringAccount } from '@metamask/keyring-api';\nimport type {\n KeyringControllerAddNewKeyringAction,\n KeyringControllerCreateNewVaultAndKeychainAction,\n KeyringControllerCreateNewVaultAndRestoreAction,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerGetStateAction,\n KeyringControllerRemoveAccountAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type {\n HandleSnapRequest as SnapControllerHandleSnapRequestAction,\n SnapControllerGetStateAction,\n SnapStateChange as SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\n\nimport type {\n MultichainAccountService,\n serviceName,\n} from './MultichainAccountService';\n\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `${typeof serviceName}:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `${typeof serviceName}:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `${typeof serviceName}:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `${typeof serviceName}:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `${typeof serviceName}:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `${typeof serviceName}:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `${typeof serviceName}:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `${typeof serviceName}:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `${typeof serviceName}:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `${typeof serviceName}:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `${typeof serviceName}:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\nexport type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {\n type: `${typeof serviceName}:ensureCanUseSnapPlatform`;\n handler: MultichainAccountService['ensureCanUseSnapPlatform'];\n};\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions =\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceEnsureCanUseSnapPlatformAction;\n\nexport type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupCreated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceMultichainAccountGroupUpdatedEvent = {\n type: `${typeof serviceName}:multichainAccountGroupUpdated`;\n payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];\n};\n\nexport type MultichainAccountServiceWalletStatusChangeEvent = {\n type: `${typeof serviceName}:walletStatusChange`;\n payload: [MultichainAccountWalletId, MultichainAccountWalletStatus];\n};\n\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents =\n | MultichainAccountServiceMultichainAccountGroupCreatedEvent\n | MultichainAccountServiceMultichainAccountGroupUpdatedEvent\n | MultichainAccountServiceWalletStatusChangeEvent;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\ntype AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerGetStateAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerAddNewKeyringAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | KeyringControllerCreateNewVaultAndKeychainAction\n | KeyringControllerCreateNewVaultAndRestoreAction\n | KeyringControllerRemoveAccountAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\ntype AllowedEvents =\n | SnapControllerStateChangeEvent\n | KeyringControllerStateChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = Messenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n>;\n\nexport type MultichainAccountServiceConfig = {\n trace?: TraceCallback;\n};\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Bip44Account, MultichainAccountGroup, MultichainAccountWalletId, MultichainAccountWalletStatus } from "@metamask/account-api";
|
|
2
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerGetAccountsAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
3
3
|
import type { TraceCallback } from "@metamask/controller-utils";
|
|
4
4
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
5
|
-
import type { KeyringControllerAddNewKeyringAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
5
|
+
import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerRemoveAccountAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { Messenger } from "@metamask/messenger";
|
|
7
7
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
|
|
8
|
-
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
8
|
+
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction, SnapControllerGetStateAction, SnapStateChange as SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
|
|
9
9
|
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.cjs";
|
|
10
10
|
export type MultichainAccountServiceGetMultichainAccountGroupAction = {
|
|
11
11
|
type: `${typeof serviceName}:getMultichainAccountGroup`;
|
|
@@ -51,11 +51,19 @@ export type MultichainAccountServiceResyncAccountsAction = {
|
|
|
51
51
|
type: `${typeof serviceName}:resyncAccounts`;
|
|
52
52
|
handler: MultichainAccountService['resyncAccounts'];
|
|
53
53
|
};
|
|
54
|
+
export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
|
|
55
|
+
type: `${typeof serviceName}:removeMultichainAccountWallet`;
|
|
56
|
+
handler: MultichainAccountService['removeMultichainAccountWallet'];
|
|
57
|
+
};
|
|
58
|
+
export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
|
|
59
|
+
type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
|
|
60
|
+
handler: MultichainAccountService['ensureCanUseSnapPlatform'];
|
|
61
|
+
};
|
|
54
62
|
/**
|
|
55
63
|
* All actions that {@link MultichainAccountService} registers so that other
|
|
56
64
|
* modules can call them.
|
|
57
65
|
*/
|
|
58
|
-
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction;
|
|
66
|
+
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
|
|
59
67
|
export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
|
|
60
68
|
type: `${typeof serviceName}:multichainAccountGroupCreated`;
|
|
61
69
|
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
@@ -77,12 +85,12 @@ export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainA
|
|
|
77
85
|
* All actions registered by other modules that {@link MultichainAccountService}
|
|
78
86
|
* calls.
|
|
79
87
|
*/
|
|
80
|
-
type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction;
|
|
88
|
+
type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerCreateNewVaultAndKeychainAction | KeyringControllerCreateNewVaultAndRestoreAction | KeyringControllerRemoveAccountAction;
|
|
81
89
|
/**
|
|
82
90
|
* All events published by other modules that {@link MultichainAccountService}
|
|
83
91
|
* subscribes to.
|
|
84
92
|
*/
|
|
85
|
-
type AllowedEvents = KeyringControllerStateChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
93
|
+
type AllowedEvents = SnapControllerStateChangeEvent | KeyringControllerStateChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
86
94
|
/**
|
|
87
95
|
* The messenger restricted to actions and events that
|
|
88
96
|
* {@link MultichainAccountService} needs to access.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC9B,8BAA8B;AAC/B,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EACV,oCAAoC,EACpC,wCAAwC,EACxC,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC5C,qCAAqC;AACtC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC9B,8BAA8B;AAC/B,OAAO,KAAK,EACV,mCAAmC,EACnC,qCAAqC,EACrC,kCAAkC,EAClC,2CAA2C,EAC3C,mCAAmC,EACnC,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EACV,oCAAoC,EACpC,gDAAgD,EAChD,+CAA+C,EAC/C,wCAAwC,EACxC,+BAA+B,EAC/B,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CA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AsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,GAAG,OAAO,WAAW,gCAAgC,CAAC;IAC5D,OAAO,EAAE,CAAC,sBAAsB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,GAAG,OAAO,WAAW,qBAAqB,CAAC;IACjD,OAAO,EAAE,CAAC,yBAAyB,EAAE,6BAA6B,CAAC,CAAC;CACrE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GACtC,0DAA0D,GAC1D,0DAA0D,GAC1D,+CAA+C,CAAC;AAEpD;;;GAGG;AACH,KAAK,cAAc,GACf,8CAA8C,GAC9C,mCAAmC,GACnC,kCAAkC,GAClC,2CAA2C,GAC3C,4BAA4B,GAC5B,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,GAC/B,wCAAwC,GACxC,oCAAoC,GACpC,2CAA2C,GAC3C,mDAAmD,GACnD,gDAAgD,GAChD,+CAA+C,GAC/C,oCAAoC,CAAC;AAEzC;;;GAGG;AACH,KAAK,aAAa,GACd,8BAA8B,GAC9B,iCAAiC,GACjC,mCAAmC,GACnC,qCAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Bip44Account, MultichainAccountGroup, MultichainAccountWalletId, MultichainAccountWalletStatus } from "@metamask/account-api";
|
|
2
|
-
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
|
+
import type { AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerGetAccountsAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
3
3
|
import type { TraceCallback } from "@metamask/controller-utils";
|
|
4
4
|
import type { KeyringAccount } from "@metamask/keyring-api";
|
|
5
|
-
import type { KeyringControllerAddNewKeyringAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
5
|
+
import type { KeyringControllerAddNewKeyringAction, KeyringControllerCreateNewVaultAndKeychainAction, KeyringControllerCreateNewVaultAndRestoreAction, KeyringControllerGetKeyringsByTypeAction, KeyringControllerGetStateAction, KeyringControllerRemoveAccountAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { Messenger } from "@metamask/messenger";
|
|
7
7
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
|
|
8
|
-
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
8
|
+
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction, SnapControllerGetStateAction, SnapStateChange as SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
|
|
9
9
|
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.mjs";
|
|
10
10
|
export type MultichainAccountServiceGetMultichainAccountGroupAction = {
|
|
11
11
|
type: `${typeof serviceName}:getMultichainAccountGroup`;
|
|
@@ -51,11 +51,19 @@ export type MultichainAccountServiceResyncAccountsAction = {
|
|
|
51
51
|
type: `${typeof serviceName}:resyncAccounts`;
|
|
52
52
|
handler: MultichainAccountService['resyncAccounts'];
|
|
53
53
|
};
|
|
54
|
+
export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
|
|
55
|
+
type: `${typeof serviceName}:removeMultichainAccountWallet`;
|
|
56
|
+
handler: MultichainAccountService['removeMultichainAccountWallet'];
|
|
57
|
+
};
|
|
58
|
+
export type MultichainAccountServiceEnsureCanUseSnapPlatformAction = {
|
|
59
|
+
type: `${typeof serviceName}:ensureCanUseSnapPlatform`;
|
|
60
|
+
handler: MultichainAccountService['ensureCanUseSnapPlatform'];
|
|
61
|
+
};
|
|
54
62
|
/**
|
|
55
63
|
* All actions that {@link MultichainAccountService} registers so that other
|
|
56
64
|
* modules can call them.
|
|
57
65
|
*/
|
|
58
|
-
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction;
|
|
66
|
+
export type MultichainAccountServiceActions = MultichainAccountServiceGetMultichainAccountGroupAction | MultichainAccountServiceGetMultichainAccountGroupsAction | MultichainAccountServiceGetMultichainAccountWalletAction | MultichainAccountServiceGetMultichainAccountWalletsAction | MultichainAccountServiceCreateNextMultichainAccountGroupAction | MultichainAccountServiceCreateMultichainAccountGroupAction | MultichainAccountServiceSetBasicFunctionalityAction | MultichainAccountServiceAlignWalletAction | MultichainAccountServiceAlignWalletsAction | MultichainAccountServiceCreateMultichainAccountWalletAction | MultichainAccountServiceResyncAccountsAction | MultichainAccountServiceRemoveMultichainAccountWalletAction | MultichainAccountServiceEnsureCanUseSnapPlatformAction;
|
|
59
67
|
export type MultichainAccountServiceMultichainAccountGroupCreatedEvent = {
|
|
60
68
|
type: `${typeof serviceName}:multichainAccountGroupCreated`;
|
|
61
69
|
payload: [MultichainAccountGroup<Bip44Account<KeyringAccount>>];
|
|
@@ -77,12 +85,12 @@ export type MultichainAccountServiceEvents = MultichainAccountServiceMultichainA
|
|
|
77
85
|
* All actions registered by other modules that {@link MultichainAccountService}
|
|
78
86
|
* calls.
|
|
79
87
|
*/
|
|
80
|
-
type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction;
|
|
88
|
+
type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerGetStateAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction | KeyringControllerGetKeyringsByTypeAction | KeyringControllerAddNewKeyringAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerCreateNewVaultAndKeychainAction | KeyringControllerCreateNewVaultAndRestoreAction | KeyringControllerRemoveAccountAction;
|
|
81
89
|
/**
|
|
82
90
|
* All events published by other modules that {@link MultichainAccountService}
|
|
83
91
|
* subscribes to.
|
|
84
92
|
*/
|
|
85
|
-
type AllowedEvents = KeyringControllerStateChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
93
|
+
type AllowedEvents = SnapControllerStateChangeEvent | KeyringControllerStateChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent;
|
|
86
94
|
/**
|
|
87
95
|
* The messenger restricted to actions and events that
|
|
88
96
|
* {@link MultichainAccountService} needs to access.
|