@metamask-previews/multichain-account-service 0.2.1-preview-bd86fa14 → 0.3.0-preview-1abef88
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 +15 -2
- package/dist/MultichainAccountService.cjs +113 -36
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts +36 -5
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts +36 -5
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +112 -35
- package/dist/MultichainAccountService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/BaseAccountProvider.cjs +4 -19
- package/dist/providers/BaseAccountProvider.cjs.map +1 -1
- package/dist/providers/BaseAccountProvider.d.cts +5 -19
- package/dist/providers/BaseAccountProvider.d.cts.map +1 -1
- package/dist/providers/BaseAccountProvider.d.mts +5 -19
- package/dist/providers/BaseAccountProvider.d.mts.map +1 -1
- package/dist/providers/BaseAccountProvider.mjs +3 -17
- package/dist/providers/BaseAccountProvider.mjs.map +1 -1
- package/dist/providers/EvmAccountProvider.cjs.map +1 -1
- package/dist/providers/EvmAccountProvider.d.cts +2 -1
- package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
- package/dist/providers/EvmAccountProvider.d.mts +2 -1
- package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
- package/dist/providers/EvmAccountProvider.mjs.map +1 -1
- package/dist/providers/SolAccountProvider.cjs.map +1 -1
- package/dist/providers/SolAccountProvider.d.cts +2 -1
- package/dist/providers/SolAccountProvider.d.cts.map +1 -1
- package/dist/providers/SolAccountProvider.d.mts +2 -1
- package/dist/providers/SolAccountProvider.d.mts.map +1 -1
- package/dist/providers/SolAccountProvider.mjs.map +1 -1
- package/dist/tests/accounts.cjs +7 -3
- package/dist/tests/accounts.cjs.map +1 -1
- package/dist/tests/accounts.d.cts +1 -0
- package/dist/tests/accounts.d.cts.map +1 -1
- package/dist/tests/accounts.d.mts +1 -0
- package/dist/tests/accounts.d.mts.map +1 -1
- package/dist/tests/accounts.mjs +5 -1
- package/dist/tests/accounts.mjs.map +1 -1
- package/dist/tests/messenger.cjs +5 -1
- package/dist/tests/messenger.cjs.map +1 -1
- package/dist/tests/messenger.d.cts +2 -2
- package/dist/tests/messenger.d.cts.map +1 -1
- package/dist/tests/messenger.d.mts +2 -2
- package/dist/tests/messenger.d.mts.map +1 -1
- package/dist/tests/messenger.mjs +5 -1
- package/dist/tests/messenger.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +20 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +20 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +4 -3
|
@@ -9,21 +9,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _MultichainAccountService_instances, _MultichainAccountService_messenger, _MultichainAccountService_providers, _MultichainAccountService_wallets,
|
|
13
|
-
import { MultichainAccountWallet, toMultichainAccountWalletId } from "@metamask/account-api";
|
|
12
|
+
var _MultichainAccountService_instances, _MultichainAccountService_messenger, _MultichainAccountService_providers, _MultichainAccountService_wallets, _MultichainAccountService_accountIdToContext, _MultichainAccountService_handleOnAccountAdded, _MultichainAccountService_handleOnAccountRemoved, _MultichainAccountService_getWallet;
|
|
13
|
+
import { isBip44Account, MultichainAccountWallet, toMultichainAccountWalletId } from "@metamask/account-api";
|
|
14
14
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
15
15
|
import { EvmAccountProvider } from "./providers/EvmAccountProvider.mjs";
|
|
16
16
|
import { SolAccountProvider } from "./providers/SolAccountProvider.mjs";
|
|
17
|
-
const serviceName = 'MultichainAccountService';
|
|
18
|
-
/**
|
|
19
|
-
* Select keyrings from keyring controller state.
|
|
20
|
-
*
|
|
21
|
-
* @param state - The keyring controller state.
|
|
22
|
-
* @returns The keyrings.
|
|
23
|
-
*/
|
|
24
|
-
function selectKeyringControllerKeyrings(state) {
|
|
25
|
-
return state.keyrings;
|
|
26
|
-
}
|
|
17
|
+
export const serviceName = 'MultichainAccountService';
|
|
27
18
|
/**
|
|
28
19
|
* Service to expose multichain accounts capabilities.
|
|
29
20
|
*/
|
|
@@ -40,29 +31,84 @@ export class MultichainAccountService {
|
|
|
40
31
|
_MultichainAccountService_messenger.set(this, void 0);
|
|
41
32
|
_MultichainAccountService_providers.set(this, void 0);
|
|
42
33
|
_MultichainAccountService_wallets.set(this, void 0);
|
|
34
|
+
_MultichainAccountService_accountIdToContext.set(this, void 0);
|
|
43
35
|
/**
|
|
44
36
|
* The name of the service.
|
|
45
37
|
*/
|
|
46
38
|
this.name = serviceName;
|
|
47
39
|
__classPrivateFieldSet(this, _MultichainAccountService_messenger, messenger, "f");
|
|
48
40
|
__classPrivateFieldSet(this, _MultichainAccountService_wallets, new Map(), "f");
|
|
41
|
+
__classPrivateFieldSet(this, _MultichainAccountService_accountIdToContext, new Map(), "f");
|
|
49
42
|
// TODO: Rely on keyring capabilities once the keyring API is used by all keyrings.
|
|
50
43
|
__classPrivateFieldSet(this, _MultichainAccountService_providers, [
|
|
51
44
|
new EvmAccountProvider(__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f")),
|
|
52
45
|
new SolAccountProvider(__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f")),
|
|
53
46
|
], "f");
|
|
47
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccount', (...args) => this.getMultichainAccount(...args));
|
|
48
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccounts', (...args) => this.getMultichainAccounts(...args));
|
|
49
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccountWallet', (...args) => this.getMultichainAccountWallet(...args));
|
|
50
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").registerActionHandler('MultichainAccountService:getMultichainAccountWallets', (...args) => this.getMultichainAccountWallets(...args));
|
|
54
51
|
}
|
|
55
52
|
/**
|
|
56
53
|
* Initialize the service and constructs the internal reprensentation of
|
|
57
54
|
* multichain accounts and wallets.
|
|
58
55
|
*/
|
|
59
56
|
init() {
|
|
60
|
-
//
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
// Create initial wallets.
|
|
58
|
+
const { keyrings } = __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").call('KeyringController:getState');
|
|
59
|
+
for (const keyring of keyrings) {
|
|
60
|
+
if (keyring.type === KeyringTypes.hd) {
|
|
61
|
+
// Only HD keyrings have an entropy source/SRP.
|
|
62
|
+
const entropySource = keyring.metadata.id;
|
|
63
|
+
// This will automatically "associate" all multichain accounts for that wallet
|
|
64
|
+
// (based on the accounts owned by each account providers).
|
|
65
|
+
const wallet = new MultichainAccountWallet({
|
|
66
|
+
entropySource,
|
|
67
|
+
providers: __classPrivateFieldGet(this, _MultichainAccountService_providers, "f"),
|
|
68
|
+
});
|
|
69
|
+
__classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").set(wallet.id, wallet);
|
|
70
|
+
// Reverse mapping between account ID and their multichain wallet/account:
|
|
71
|
+
for (const multichainAccount of wallet.getMultichainAccounts()) {
|
|
72
|
+
for (const account of multichainAccount.getAccounts()) {
|
|
73
|
+
__classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").set(account.id, {
|
|
74
|
+
wallet,
|
|
75
|
+
multichainAccount,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").subscribe('AccountsController:accountAdded', (account) => __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_handleOnAccountAdded).call(this, account));
|
|
82
|
+
__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").subscribe('AccountsController:accountRemoved', (id) => __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_handleOnAccountRemoved).call(this, id));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets a reference to the wallet and multichain account for a given account ID.
|
|
86
|
+
*
|
|
87
|
+
* @param id - Account ID.
|
|
88
|
+
* @returns An object with references to the wallet and multichain account associated for
|
|
89
|
+
* that account ID, or undefined if this account ID is not part of any.
|
|
90
|
+
*/
|
|
91
|
+
getMultichainAccountAndWallet(id) {
|
|
92
|
+
return __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").get(id);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets a reference to the multichain account wallet matching this entropy source.
|
|
96
|
+
*
|
|
97
|
+
* @param options - Options.
|
|
98
|
+
* @param options.entropySource - The entropy source of the multichain account.
|
|
99
|
+
* @throws If none multichain account match this entropy.
|
|
100
|
+
* @returns A reference to the multichain account wallet.
|
|
101
|
+
*/
|
|
102
|
+
getMultichainAccountWallet({ entropySource, }) {
|
|
103
|
+
return __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_getWallet).call(this, entropySource);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets an array of all multichain account wallets.
|
|
107
|
+
*
|
|
108
|
+
* @returns An array of all multichain account wallets.
|
|
109
|
+
*/
|
|
110
|
+
getMultichainAccountWallets() {
|
|
111
|
+
return Array.from(__classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").values());
|
|
66
112
|
}
|
|
67
113
|
/**
|
|
68
114
|
* Gets a reference to the multichain account matching this entropy source and group index.
|
|
@@ -92,25 +138,56 @@ export class MultichainAccountService {
|
|
|
92
138
|
return __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_getWallet).call(this, entropySource).getMultichainAccounts();
|
|
93
139
|
}
|
|
94
140
|
}
|
|
95
|
-
_MultichainAccountService_messenger = new WeakMap(), _MultichainAccountService_providers = new WeakMap(), _MultichainAccountService_wallets = new WeakMap(), _MultichainAccountService_instances = new WeakSet(),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
141
|
+
_MultichainAccountService_messenger = new WeakMap(), _MultichainAccountService_providers = new WeakMap(), _MultichainAccountService_wallets = new WeakMap(), _MultichainAccountService_accountIdToContext = new WeakMap(), _MultichainAccountService_instances = new WeakSet(), _MultichainAccountService_handleOnAccountAdded = function _MultichainAccountService_handleOnAccountAdded(account) {
|
|
142
|
+
// We completely omit non-BIP-44 accounts!
|
|
143
|
+
if (!isBip44Account(account)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let sync = true;
|
|
147
|
+
let wallet = __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").get(toMultichainAccountWalletId(account.options.entropy.id));
|
|
148
|
+
if (!wallet) {
|
|
149
|
+
// That's a new wallet.
|
|
150
|
+
wallet = new MultichainAccountWallet({
|
|
151
|
+
entropySource: account.options.entropy.id,
|
|
152
|
+
providers: __classPrivateFieldGet(this, _MultichainAccountService_providers, "f"),
|
|
153
|
+
});
|
|
154
|
+
__classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").set(wallet.id, wallet);
|
|
155
|
+
// If that's a new wallet wallet. There's nothing to "force-sync".
|
|
156
|
+
sync = false;
|
|
157
|
+
}
|
|
158
|
+
let multichainAccount = wallet.getMultichainAccount(account.options.entropy.groupIndex);
|
|
159
|
+
if (!multichainAccount) {
|
|
160
|
+
// This new account is a new multichain account, let the wallet know
|
|
161
|
+
// it has to re-sync with its providers.
|
|
162
|
+
if (sync) {
|
|
163
|
+
wallet.sync();
|
|
112
164
|
}
|
|
165
|
+
multichainAccount = wallet.getMultichainAccount(account.options.entropy.groupIndex);
|
|
166
|
+
// If that's a new multichain account. There's nothing to "force-sync".
|
|
167
|
+
sync = false;
|
|
168
|
+
}
|
|
169
|
+
// We have to check against `undefined` in case `getMultichainAccount` is
|
|
170
|
+
// not able to find this multichain account (which should not be possible...)
|
|
171
|
+
if (multichainAccount) {
|
|
172
|
+
if (sync) {
|
|
173
|
+
multichainAccount.sync();
|
|
174
|
+
}
|
|
175
|
+
// Same here, this account should have been already grouped in that
|
|
176
|
+
// multichain account.
|
|
177
|
+
__classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").set(account.id, {
|
|
178
|
+
wallet,
|
|
179
|
+
multichainAccount,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}, _MultichainAccountService_handleOnAccountRemoved = function _MultichainAccountService_handleOnAccountRemoved(id) {
|
|
183
|
+
// Force sync of the appropriate wallet if an account got removed.
|
|
184
|
+
const found = __classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").get(id);
|
|
185
|
+
if (found) {
|
|
186
|
+
const { wallet } = found;
|
|
187
|
+
wallet.sync();
|
|
113
188
|
}
|
|
189
|
+
// Safe to call delete even if the `id` was not referencing a BIP-44 account.
|
|
190
|
+
__classPrivateFieldGet(this, _MultichainAccountService_accountIdToContext, "f").delete(id);
|
|
114
191
|
}, _MultichainAccountService_getWallet = function _MultichainAccountService_getWallet(entropySource) {
|
|
115
192
|
const wallet = __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").get(toMultichainAccountWalletId(entropySource));
|
|
116
193
|
if (!wallet) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultichainAccountService.mjs","sourceRoot":"","sources":["../src/MultichainAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAE5B,8BAA8B;AAM/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AAGpE,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAS/C;;;;;GAKG;AACH,SAAS,+BAA+B,CAAC,KAA6B;IACpE,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAenC;;;;;;OAMG;IACH,YAAY,EAAE,SAAS,EAAmC;;QArBjD,sDAA8C;QAE9C,sDAA+C;QAE/C,oDAGP;QAEF;;WAEG;QACH,SAAI,GAAuB,WAAW,CAAC;QAUrC,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,qCAAY,IAAI,GAAG,EAAE,MAAA,CAAC;QAC1B,mFAAmF;QACnF,uBAAA,IAAI,uCAAc;YAChB,IAAI,kBAAkB,CAAC,uBAAA,IAAI,2CAAW,CAAC;YACvC,IAAI,kBAAkB,CAAC,uBAAA,IAAI,2CAAW,CAAC;SACxC,MAAA,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,oCAAoC;QACpC,MAAM,KAAK,GAAG,uBAAA,IAAI,2CAAW,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACjE,uBAAA,IAAI,kGAA6B,MAAjC,IAAI,EAA8B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAElD,uBAAA,IAAI,2CAAW,CAAC,SAAS,CACvB,+BAA+B,EAC/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,qFAGC,aAA8B;IAE9B,MAAM,MAAM,GAAG,uBAAA,IAAI,yCAAS,CAAC,GAAG,CAC9B,2BAA2B,CAAC,aAAa,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n MultichainAccountWalletId,\n AccountProvider,\n} from '@metamask/account-api';\nimport {\n MultichainAccountWallet,\n toMultichainAccountWalletId,\n type MultichainAccount,\n} from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nconst serviceName = 'MultichainAccountService';\n\n/**\n * The options that {@link MultichainAccountService} takes.\n */\ntype MultichainAccountServiceOptions = {\n messenger: MultichainAccountServiceMessenger;\n};\n\n/**\n * Select keyrings from keyring controller state.\n *\n * @param state - The keyring controller state.\n * @returns The keyrings.\n */\nfunction selectKeyringControllerKeyrings(state: KeyringControllerState) {\n return state.keyrings;\n}\n\n/**\n * Service to expose multichain accounts capabilities.\n */\nexport class MultichainAccountService {\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #providers: AccountProvider<InternalAccount>[];\n\n readonly #wallets: Map<\n MultichainAccountWalletId,\n MultichainAccountWallet<InternalAccount>\n >;\n\n /**\n * The name of the service.\n */\n name: typeof serviceName = serviceName;\n\n /**\n * Constructs a new MultichainAccountService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountService.\n */\n constructor({ messenger }: MultichainAccountServiceOptions) {\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\n /**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\n init(): void {\n // Gather all entropy sources first.\n const state = this.#messenger.call('KeyringController:getState');\n this.#setMultichainAccountWallets(state.keyrings);\n\n this.#messenger.subscribe(\n 'KeyringController:stateChange',\n (keyrings) => {\n this.#setMultichainAccountWallets(keyrings);\n },\n selectKeyringControllerKeyrings,\n );\n }\n\n #setMultichainAccountWallets(keyrings: KeyringObject[]) {\n for (const keyring of keyrings) {\n if (keyring.type === (KeyringTypes.hd as string)) {\n // Only HD keyrings have an entropy source/SRP.\n const entropySource = keyring.metadata.id;\n\n // Do not re-create wallets if they exists. Even if a keyrings got new accounts, this\n // will be handled by the `*AccountProvider`s which are always in-sync with their\n // keyrings and controllers (like the `AccountsController`).\n if (!this.#wallets.has(toMultichainAccountWalletId(entropySource))) {\n // This will automatically \"associate\" all multichain accounts for that wallet\n // (based on the accounts owned by each account providers).\n const wallet = new MultichainAccountWallet({\n entropySource,\n providers: this.#providers,\n });\n\n this.#wallets.set(wallet.id, wallet);\n }\n }\n }\n }\n\n #getWallet(\n entropySource: EntropySourceId,\n ): MultichainAccountWallet<InternalAccount> {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error('Unknown wallet, no wallet matching this entropy source');\n }\n\n return wallet;\n }\n\n /**\n * Gets a reference to the multichain account matching this entropy source and group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount<InternalAccount> {\n const multichainAccount =\n this.#getWallet(entropySource).getMultichainAccount(groupIndex);\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n /**\n * Gets all multichain accounts for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount<InternalAccount>[] {\n return this.#getWallet(entropySource).getMultichainAccounts();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MultichainAccountService.mjs","sourceRoot":"","sources":["../src/MultichainAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAE5B,8BAA8B;AAE/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AAGpE,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAetD;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAoBnC;;;;;;OAMG;IACH,YAAY,EAAE,SAAS,EAAmC;;QA1BjD,sDAA8C;QAE9C,sDAA6D;QAE7D,oDAGP;QAEO,+DAGP;QAEF;;WAEG;QACH,SAAI,GAAuB,WAAW,CAAC;QAUrC,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,qCAAY,IAAI,GAAG,EAAE,MAAA,CAAC;QAC1B,uBAAA,IAAI,gDAAuB,IAAI,GAAG,EAAE,MAAA,CAAC;QACrC,mFAAmF;QACnF,uBAAA,IAAI,uCAAc;YAChB,IAAI,kBAAkB,CAAC,uBAAA,IAAI,2CAAW,CAAC;YACvC,IAAI,kBAAkB,CAAC,uBAAA,IAAI,2CAAW,CAAC;SACxC,MAAA,CAAC;QAEF,uBAAA,IAAI,2CAAW,CAAC,qBAAqB,CACnC,+CAA+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AAC,IAAI,EAAE,CAAC;SAC1B;QAED,mEAAmE;QACnE,sBAAsB;QACtB,uBAAA,IAAI,oDAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE;YACvC,MAAM;YACN,iBAAiB;SAClB,CAAC,CAAC;KACJ;AACH,CAAC,+GAEuB,EAAyB;IAC/C,kEAAkE;IAClE,MAAM,KAAK,GAAG,uBAAA,IAAI,oDAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,KAAK,EAAE;QACT,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,MAAM,CAAC,IAAI,EAAE,CAAC;KACf;IAED,6EAA6E;IAC7E,uBAAA,IAAI,oDAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC,qFAGC,aAA8B;IAE9B,MAAM,MAAM,GAAG,uBAAA,IAAI,yCAAS,CAAC,GAAG,CAC9B,2BAA2B,CAAC,aAAa,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n MultichainAccountWalletId,\n AccountProvider,\n Bip44Account,\n} from '@metamask/account-api';\nimport {\n isBip44Account,\n MultichainAccountWallet,\n toMultichainAccountWalletId,\n type MultichainAccount,\n} from '@metamask/account-api';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { EvmAccountProvider } from './providers/EvmAccountProvider';\nimport { SolAccountProvider } from './providers/SolAccountProvider';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport const serviceName = 'MultichainAccountService';\n\n/**\n * The options that {@link MultichainAccountService} takes.\n */\ntype MultichainAccountServiceOptions = {\n messenger: MultichainAccountServiceMessenger;\n};\n\n/** Reverse mapping object used to map account IDs and their wallet/multichain account. */\ntype AccountContext<Account extends Bip44Account<KeyringAccount>> = {\n wallet: MultichainAccountWallet<Account>;\n multichainAccount: MultichainAccount<Account>;\n};\n\n/**\n * Service to expose multichain accounts capabilities.\n */\nexport class MultichainAccountService {\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #providers: AccountProvider<Bip44Account<InternalAccount>>[];\n\n readonly #wallets: Map<\n MultichainAccountWalletId,\n MultichainAccountWallet<Bip44Account<InternalAccount>>\n >;\n\n readonly #accountIdToContext: Map<\n Bip44Account<InternalAccount>['id'],\n AccountContext<Bip44Account<InternalAccount>>\n >;\n\n /**\n * The name of the service.\n */\n name: typeof serviceName = serviceName;\n\n /**\n * Constructs a new MultichainAccountService.\n *\n * @param options - The options.\n * @param options.messenger - The messenger suited to this\n * MultichainAccountService.\n */\n constructor({ messenger }: MultichainAccountServiceOptions) {\n this.#messenger = messenger;\n this.#wallets = new Map();\n this.#accountIdToContext = 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 this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccount',\n (...args) => this.getMultichainAccount(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccounts',\n (...args) => this.getMultichainAccounts(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccountWallet',\n (...args) => this.getMultichainAccountWallet(...args),\n );\n this.#messenger.registerActionHandler(\n 'MultichainAccountService:getMultichainAccountWallets',\n (...args) => this.getMultichainAccountWallets(...args),\n );\n }\n\n /**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\n init(): void {\n // Create initial wallets.\n const { keyrings } = this.#messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n if (keyring.type === (KeyringTypes.hd as string)) {\n // Only HD keyrings have an entropy source/SRP.\n const entropySource = keyring.metadata.id;\n\n // This will automatically \"associate\" all multichain accounts for that wallet\n // (based on the accounts owned by each account providers).\n const wallet = new MultichainAccountWallet({\n entropySource,\n providers: this.#providers,\n });\n this.#wallets.set(wallet.id, wallet);\n\n // Reverse mapping between account ID and their multichain wallet/account:\n for (const multichainAccount of wallet.getMultichainAccounts()) {\n for (const account of multichainAccount.getAccounts()) {\n this.#accountIdToContext.set(account.id, {\n wallet,\n multichainAccount,\n });\n }\n }\n }\n }\n\n this.#messenger.subscribe('AccountsController:accountAdded', (account) =>\n this.#handleOnAccountAdded(account),\n );\n this.#messenger.subscribe('AccountsController:accountRemoved', (id) =>\n this.#handleOnAccountRemoved(id),\n );\n }\n\n #handleOnAccountAdded(account: InternalAccount): void {\n // We completely omit non-BIP-44 accounts!\n if (!isBip44Account(account)) {\n return;\n }\n\n let sync = true;\n\n let wallet = this.#wallets.get(\n toMultichainAccountWalletId(account.options.entropy.id),\n );\n if (!wallet) {\n // That's a new wallet.\n wallet = new MultichainAccountWallet({\n entropySource: account.options.entropy.id,\n providers: this.#providers,\n });\n this.#wallets.set(wallet.id, wallet);\n\n // If that's a new wallet wallet. There's nothing to \"force-sync\".\n sync = false;\n }\n\n let multichainAccount = wallet.getMultichainAccount(\n account.options.entropy.groupIndex,\n );\n if (!multichainAccount) {\n // This new account is a new multichain account, let the wallet know\n // it has to re-sync with its providers.\n if (sync) {\n wallet.sync();\n }\n\n multichainAccount = wallet.getMultichainAccount(\n account.options.entropy.groupIndex,\n );\n\n // If that's a new multichain account. There's nothing to \"force-sync\".\n sync = false;\n }\n\n // We have to check against `undefined` in case `getMultichainAccount` is\n // not able to find this multichain account (which should not be possible...)\n if (multichainAccount) {\n if (sync) {\n multichainAccount.sync();\n }\n\n // Same here, this account should have been already grouped in that\n // multichain account.\n this.#accountIdToContext.set(account.id, {\n wallet,\n multichainAccount,\n });\n }\n }\n\n #handleOnAccountRemoved(id: InternalAccount['id']): void {\n // Force sync of the appropriate wallet if an account got removed.\n const found = this.#accountIdToContext.get(id);\n if (found) {\n const { wallet } = found;\n\n wallet.sync();\n }\n\n // Safe to call delete even if the `id` was not referencing a BIP-44 account.\n this.#accountIdToContext.delete(id);\n }\n\n #getWallet(\n entropySource: EntropySourceId,\n ): MultichainAccountWallet<Bip44Account<InternalAccount>> {\n const wallet = this.#wallets.get(\n toMultichainAccountWalletId(entropySource),\n );\n\n if (!wallet) {\n throw new Error('Unknown wallet, no wallet matching this entropy source');\n }\n\n return wallet;\n }\n\n /**\n * Gets a reference to the wallet and multichain account for a given account ID.\n *\n * @param id - Account ID.\n * @returns An object with references to the wallet and multichain account associated for\n * that account ID, or undefined if this account ID is not part of any.\n */\n getMultichainAccountAndWallet(\n id: InternalAccount['id'],\n ): AccountContext<Bip44Account<InternalAccount>> | undefined {\n return this.#accountIdToContext.get(id);\n }\n\n /**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\n getMultichainAccountWallet({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccountWallet<Bip44Account<InternalAccount>> {\n return this.#getWallet(entropySource);\n }\n\n /**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\n getMultichainAccountWallets(): MultichainAccountWallet<\n Bip44Account<InternalAccount>\n >[] {\n return Array.from(this.#wallets.values());\n }\n\n /**\n * Gets a reference to the multichain account matching this entropy source and group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\n getMultichainAccount({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): MultichainAccount<Bip44Account<InternalAccount>> {\n const multichainAccount =\n this.#getWallet(entropySource).getMultichainAccount(groupIndex);\n\n if (!multichainAccount) {\n throw new Error(`No multichain account for index: ${groupIndex}`);\n }\n\n return multichainAccount;\n }\n\n /**\n * Gets all multichain accounts for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\n getMultichainAccounts({\n entropySource,\n }: {\n entropySource: EntropySourceId;\n }): MultichainAccount<Bip44Account<InternalAccount>>[] {\n return this.#getWallet(entropySource).getMultichainAccounts();\n }\n}\n"]}
|
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":";;;AASA,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountsAction,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, } from "./types.cjs";
|
|
1
|
+
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountsAction, } from "./types.cjs";
|
|
2
2
|
export { MultichainAccountService } from "./MultichainAccountService.cjs";
|
|
3
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,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,kDAAkD,EAClD,wDAAwD,EACxD,yDAAyD,EACzD,mDAAmD,GACpD,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, } from "./types.mjs";
|
|
1
|
+
export type { MultichainAccountServiceActions, MultichainAccountServiceEvents, MultichainAccountServiceMessenger, MultichainAccountServiceGetMultichainAccountAction, MultichainAccountServiceGetMultichainAccountWalletAction, MultichainAccountServiceGetMultichainAccountWalletsAction, MultichainAccountServiceGetMultichainAccountsAction, } from "./types.mjs";
|
|
2
2
|
export { MultichainAccountService } from "./MultichainAccountService.mjs";
|
|
3
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,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,kDAAkD,EAClD,wDAAwD,EACxD,yDAAyD,EACzD,mDAAmD,GACpD,oBAAgB;AACjB,OAAO,EAAE,wBAAwB,EAAE,uCAAmC"}
|
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":"AASA,OAAO,EAAE,wBAAwB,EAAE,uCAAmC","sourcesContent":["export type {\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n MultichainAccountServiceGetMultichainAccountAction,\n MultichainAccountServiceGetMultichainAccountWalletAction,\n MultichainAccountServiceGetMultichainAccountWalletsAction,\n MultichainAccountServiceGetMultichainAccountsAction,\n} from './types';\nexport { MultichainAccountService } from './MultichainAccountService';\n"]}
|
|
@@ -6,23 +6,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
};
|
|
7
7
|
var _BaseAccountProvider_instances, _BaseAccountProvider_getAccounts;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.BaseAccountProvider =
|
|
10
|
-
const
|
|
11
|
-
/**
|
|
12
|
-
* Checks if an account is BIP-44 compatible.
|
|
13
|
-
*
|
|
14
|
-
* @param account - The account to be tested.
|
|
15
|
-
* @returns True if the account is BIP-44 compatible.
|
|
16
|
-
*/
|
|
17
|
-
function isBip44Account(account) {
|
|
18
|
-
if (!account.options.entropy ||
|
|
19
|
-
account.options.entropy.type !== keyring_api_1.KeyringAccountEntropyTypeOption.Mnemonic) {
|
|
20
|
-
console.warn("! Found an HD account with invalid entropy options: account won't be associated to its wallet.");
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
exports.isBip44Account = isBip44Account;
|
|
9
|
+
exports.BaseAccountProvider = void 0;
|
|
10
|
+
const account_api_1 = require("@metamask/account-api");
|
|
26
11
|
class BaseAccountProvider {
|
|
27
12
|
constructor(messenger) {
|
|
28
13
|
_BaseAccountProvider_instances.add(this);
|
|
@@ -48,8 +33,8 @@ _BaseAccountProvider_instances = new WeakSet(), _BaseAccountProvider_getAccounts
|
|
|
48
33
|
// accounts, including EVM and non-EVM. We might wanna change this action
|
|
49
34
|
// name once we fully support multichain accounts.
|
|
50
35
|
'AccountsController:listMultichainAccounts')) {
|
|
51
|
-
if (
|
|
52
|
-
|
|
36
|
+
if ((0, account_api_1.isBip44Account)(account) &&
|
|
37
|
+
this.isAccountCompatible(account) &&
|
|
53
38
|
filter(account)) {
|
|
54
39
|
accounts.push(account);
|
|
55
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"BaseAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAI+B;AAK/B,MAAsB,mBAAmB;IAKvC,YAAY,SAA4C;;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAyBD,WAAW;QACT,OAAO,uBAAA,IAAI,wEAAa,MAAjB,IAAI,CAAe,CAAC;IAC7B,CAAC;IAED,UAAU,CAAC,EAAyB;QAClC,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;AAhDD,kDAgDC;6HAtCG,SAAgD,GAAG,EAAE,CAAC,IAAI;IAE1D,MAAM,QAAQ,GAAoC,EAAE,CAAC;IAErD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI;IACvC,2EAA2E;IAC3E,yEAAyE;IACzE,kDAAkD;IAClD,2CAA2C,CAC5C,EAAE;QACD,IACE,IAAA,4BAAc,EAAC,OAAO,CAAC;YACvB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,EACf;YACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n isBip44Account,\n type AccountProvider,\n type Bip44Account,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<Bip44Account<InternalAccount>>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n isBip44Account(account) &&\n this.isAccountCompatible(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): Bip44Account<InternalAccount>[] {\n return this.#getAccounts();\n }\n\n getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount> {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n}\n"]}
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { AccountId } from "@metamask/accounts-controller";
|
|
3
|
-
import type { KeyringAccount, KeyringAccountEntropyMnemonicOptions } from "@metamask/keyring-api";
|
|
1
|
+
import { type AccountProvider, type Bip44Account } from "@metamask/account-api";
|
|
4
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
3
|
import type { MultichainAccountServiceMessenger } from "../types.cjs";
|
|
6
|
-
export
|
|
7
|
-
options: {
|
|
8
|
-
entropy: KeyringAccountEntropyMnemonicOptions;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Checks if an account is BIP-44 compatible.
|
|
13
|
-
*
|
|
14
|
-
* @param account - The account to be tested.
|
|
15
|
-
* @returns True if the account is BIP-44 compatible.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
|
|
18
|
-
export declare abstract class BaseAccountProvider implements AccountProvider<InternalAccount> {
|
|
4
|
+
export declare abstract class BaseAccountProvider implements AccountProvider<Bip44Account<InternalAccount>> {
|
|
19
5
|
#private;
|
|
20
6
|
protected readonly messenger: MultichainAccountServiceMessenger;
|
|
21
7
|
constructor(messenger: MultichainAccountServiceMessenger);
|
|
22
|
-
getAccounts(): InternalAccount[];
|
|
23
|
-
getAccount(id:
|
|
24
|
-
abstract isAccountCompatible(account: InternalAccount): boolean;
|
|
8
|
+
getAccounts(): Bip44Account<InternalAccount>[];
|
|
9
|
+
getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount>;
|
|
10
|
+
abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
25
11
|
}
|
|
26
12
|
//# sourceMappingURL=BaseAccountProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"BaseAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,8BAAsB,mBACpB,YAAW,eAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;;IAEzD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,YAAY,CAAC,eAAe,CAAC,EAAE;IAI9C,UAAU,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC;IAWpE,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAC9E"}
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { AccountId } from "@metamask/accounts-controller";
|
|
3
|
-
import type { KeyringAccount, KeyringAccountEntropyMnemonicOptions } from "@metamask/keyring-api";
|
|
1
|
+
import { type AccountProvider, type Bip44Account } from "@metamask/account-api";
|
|
4
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
5
3
|
import type { MultichainAccountServiceMessenger } from "../types.mjs";
|
|
6
|
-
export
|
|
7
|
-
options: {
|
|
8
|
-
entropy: KeyringAccountEntropyMnemonicOptions;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Checks if an account is BIP-44 compatible.
|
|
13
|
-
*
|
|
14
|
-
* @param account - The account to be tested.
|
|
15
|
-
* @returns True if the account is BIP-44 compatible.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isBip44Account<Account extends KeyringAccount>(account: Account): account is Bip44Account<Account>;
|
|
18
|
-
export declare abstract class BaseAccountProvider implements AccountProvider<InternalAccount> {
|
|
4
|
+
export declare abstract class BaseAccountProvider implements AccountProvider<Bip44Account<InternalAccount>> {
|
|
19
5
|
#private;
|
|
20
6
|
protected readonly messenger: MultichainAccountServiceMessenger;
|
|
21
7
|
constructor(messenger: MultichainAccountServiceMessenger);
|
|
22
|
-
getAccounts(): InternalAccount[];
|
|
23
|
-
getAccount(id:
|
|
24
|
-
abstract isAccountCompatible(account: InternalAccount): boolean;
|
|
8
|
+
getAccounts(): Bip44Account<InternalAccount>[];
|
|
9
|
+
getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount>;
|
|
10
|
+
abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
25
11
|
}
|
|
26
12
|
//# sourceMappingURL=BaseAccountProvider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"BaseAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAiB;AAElE,8BAAsB,mBACpB,YAAW,eAAe,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;;IAEzD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iCAAiC,CAAC;gBAEpD,SAAS,EAAE,iCAAiC;IA2BxD,WAAW,IAAI,YAAY,CAAC,eAAe,CAAC,EAAE;IAI9C,UAAU,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC;IAWpE,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAC9E"}
|
|
@@ -4,21 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _BaseAccountProvider_instances, _BaseAccountProvider_getAccounts;
|
|
7
|
-
import {
|
|
8
|
-
/**
|
|
9
|
-
* Checks if an account is BIP-44 compatible.
|
|
10
|
-
*
|
|
11
|
-
* @param account - The account to be tested.
|
|
12
|
-
* @returns True if the account is BIP-44 compatible.
|
|
13
|
-
*/
|
|
14
|
-
export function isBip44Account(account) {
|
|
15
|
-
if (!account.options.entropy ||
|
|
16
|
-
account.options.entropy.type !== KeyringAccountEntropyTypeOption.Mnemonic) {
|
|
17
|
-
console.warn("! Found an HD account with invalid entropy options: account won't be associated to its wallet.");
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
7
|
+
import { isBip44Account } from "@metamask/account-api";
|
|
22
8
|
export class BaseAccountProvider {
|
|
23
9
|
constructor(messenger) {
|
|
24
10
|
_BaseAccountProvider_instances.add(this);
|
|
@@ -43,8 +29,8 @@ _BaseAccountProvider_instances = new WeakSet(), _BaseAccountProvider_getAccounts
|
|
|
43
29
|
// accounts, including EVM and non-EVM. We might wanna change this action
|
|
44
30
|
// name once we fully support multichain accounts.
|
|
45
31
|
'AccountsController:listMultichainAccounts')) {
|
|
46
|
-
if (
|
|
47
|
-
|
|
32
|
+
if (isBip44Account(account) &&
|
|
33
|
+
this.isAccountCompatible(account) &&
|
|
48
34
|
filter(account)) {
|
|
49
35
|
accounts.push(account);
|
|
50
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"BaseAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/BaseAccountProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,cAAc,EAGf,8BAA8B;AAK/B,MAAM,OAAgB,mBAAmB;IAKvC,YAAY,SAA4C;;QACtD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAyBD,WAAW;QACT,OAAO,uBAAA,IAAI,wEAAa,MAAjB,IAAI,CAAe,CAAC;IAC7B,CAAC;IAED,UAAU,CAAC,EAAyB;QAClC,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,uBAAA,IAAI,wEAAa,MAAjB,IAAI,EAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;SAClD;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;6HAtCG,SAAgD,GAAG,EAAE,CAAC,IAAI;IAE1D,MAAM,QAAQ,GAAoC,EAAE,CAAC;IAErD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI;IACvC,2EAA2E;IAC3E,yEAAyE;IACzE,kDAAkD;IAClD,2CAA2C,CAC5C,EAAE;QACD,IACE,cAAc,CAAC,OAAO,CAAC;YACvB,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjC,MAAM,CAAC,OAAO,CAAC,EACf;YACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n isBip44Account,\n type AccountProvider,\n type Bip44Account,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport abstract class BaseAccountProvider\n implements AccountProvider<Bip44Account<InternalAccount>>\n{\n protected readonly messenger: MultichainAccountServiceMessenger;\n\n constructor(messenger: MultichainAccountServiceMessenger) {\n this.messenger = messenger;\n }\n\n #getAccounts(\n filter: (account: InternalAccount) => boolean = () => true,\n ): Bip44Account<InternalAccount>[] {\n const accounts: Bip44Account<InternalAccount>[] = [];\n\n for (const account of this.messenger.call(\n // NOTE: Even though the name is misleading, this only fetches all internal\n // accounts, including EVM and non-EVM. We might wanna change this action\n // name once we fully support multichain accounts.\n 'AccountsController:listMultichainAccounts',\n )) {\n if (\n isBip44Account(account) &&\n this.isAccountCompatible(account) &&\n filter(account)\n ) {\n accounts.push(account);\n }\n }\n\n return accounts;\n }\n\n getAccounts(): Bip44Account<InternalAccount>[] {\n return this.#getAccounts();\n }\n\n getAccount(id: InternalAccount['id']): Bip44Account<InternalAccount> {\n // TODO: Maybe just use a proper find for faster lookup?\n const [found] = this.#getAccounts((account) => account.id === id);\n\n if (!found) {\n throw new Error(`Unable to find account: ${id}`);\n }\n\n return found;\n }\n\n abstract isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EvmAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,qEAA4D;AAG5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IACzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF;AAPD,gDAOC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Bip44Account } from "@metamask/account-api";
|
|
1
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
3
|
import { BaseAccountProvider } from "./BaseAccountProvider.cjs";
|
|
3
4
|
export declare class EvmAccountProvider extends BaseAccountProvider {
|
|
4
|
-
isAccountCompatible(account: InternalAccount): boolean;
|
|
5
|
+
isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
5
6
|
}
|
|
6
7
|
//# sourceMappingURL=EvmAccountProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EvmAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Bip44Account } from "@metamask/account-api";
|
|
1
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
3
|
import { BaseAccountProvider } from "./BaseAccountProvider.mjs";
|
|
3
4
|
export declare class EvmAccountProvider extends BaseAccountProvider {
|
|
4
|
-
isAccountCompatible(account: InternalAccount): boolean;
|
|
5
|
+
isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
5
6
|
}
|
|
6
7
|
//# sourceMappingURL=EvmAccountProvider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EvmAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvmAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EvmAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/EvmAccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IACzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG;YACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,EAAa,CAC9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { EthAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class EvmAccountProvider extends BaseAccountProvider {\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === EthAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.hd as string)\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SolAccountProvider.cjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,qEAA4D;AAI5D,mEAA4D;AAE5D,MAAa,kBAAmB,SAAQ,yCAAmB;IAGzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,4BAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,iCAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AARH,gDASC;AARQ,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Bip44Account } from "@metamask/account-api";
|
|
1
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
3
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
4
|
import { BaseAccountProvider } from "./BaseAccountProvider.cjs";
|
|
4
5
|
export declare class SolAccountProvider extends BaseAccountProvider {
|
|
5
6
|
static SOLANA_SNAP_ID: SnapId;
|
|
6
|
-
isAccountCompatible(account: InternalAccount): boolean;
|
|
7
|
+
isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=SolAccountProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SolAccountProvider.d.cts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Bip44Account } from "@metamask/account-api";
|
|
1
2
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
3
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
4
|
import { BaseAccountProvider } from "./BaseAccountProvider.mjs";
|
|
4
5
|
export declare class SolAccountProvider extends BaseAccountProvider {
|
|
5
6
|
static SOLANA_SNAP_ID: SnapId;
|
|
6
|
-
isAccountCompatible(account: InternalAccount): boolean;
|
|
7
|
+
isAccountCompatible(account: Bip44Account<InternalAccount>): boolean;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=SolAccountProvider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SolAccountProvider.d.mts","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAG1D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,MAAM,CAAC,cAAc,SAAgD;IAErE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,eAAe,CAAC,GAAG,OAAO;CAMrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SolAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/SolAccountProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,8BAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,mBAAmB,EAAE,kCAA8B;AAE5D,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAGzD,mBAAmB,CAAC,OAAsC;QACxD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,WAAW;YAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAM,YAAY,CAAC,IAAe,CAChE,CAAC;IACJ,CAAC;;AAPM,iCAAc,GAAG,kCAA4C,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport { SolAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport { BaseAccountProvider } from './BaseAccountProvider';\n\nexport class SolAccountProvider extends BaseAccountProvider {\n static SOLANA_SNAP_ID = 'npm:@metamask/solana-wallet-snap' as SnapId;\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === SolAccountType.DataAccount &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n}\n"]}
|