@metamask-previews/multichain-account-service 2.1.0-preview-ee982ebe → 2.1.0-preview-7f5161b8
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 +6 -0
- package/dist/MultichainAccountGroup.cjs.map +1 -1
- package/dist/MultichainAccountGroup.d.cts +2 -2
- package/dist/MultichainAccountGroup.d.mts +2 -2
- package/dist/MultichainAccountGroup.mjs.map +1 -1
- package/dist/MultichainAccountService.cjs +49 -5
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts +23 -6
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts +23 -6
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +49 -5
- package/dist/MultichainAccountService.mjs.map +1 -1
- package/dist/MultichainAccountWallet.cjs.map +1 -1
- package/dist/MultichainAccountWallet.d.cts +2 -2
- package/dist/MultichainAccountWallet.d.mts +2 -2
- package/dist/MultichainAccountWallet.mjs.map +1 -1
- package/dist/analytics/index.cjs +18 -0
- package/dist/analytics/index.cjs.map +1 -0
- package/dist/analytics/index.d.cts +2 -0
- package/dist/analytics/index.d.cts.map +1 -0
- package/dist/analytics/index.d.mts +2 -0
- package/dist/analytics/index.d.mts.map +1 -0
- package/dist/analytics/index.mjs +2 -0
- package/dist/analytics/index.mjs.map +1 -0
- package/dist/analytics/traces.cjs +21 -0
- package/dist/analytics/traces.cjs.map +1 -0
- package/dist/analytics/traces.d.cts +13 -0
- package/dist/analytics/traces.d.cts.map +1 -0
- package/dist/analytics/traces.d.mts +13 -0
- package/dist/analytics/traces.d.mts.map +1 -0
- package/dist/analytics/traces.mjs +17 -0
- package/dist/analytics/traces.mjs.map +1 -0
- package/dist/constants/traces.cjs +9 -0
- package/dist/constants/traces.cjs.map +1 -0
- package/dist/constants/traces.d.cts +5 -0
- package/dist/constants/traces.d.cts.map +1 -0
- package/dist/constants/traces.d.mts +5 -0
- package/dist/constants/traces.d.mts.map +1 -0
- package/dist/constants/traces.mjs +6 -0
- package/dist/constants/traces.mjs.map +1 -0
- package/dist/providers/AccountProviderWrapper.cjs +11 -0
- package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.cts +7 -0
- package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
- package/dist/providers/AccountProviderWrapper.d.mts +7 -0
- package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
- package/dist/providers/AccountProviderWrapper.mjs +11 -0
- package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.cts +13 -3
- package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.d.mts +13 -3
- package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
- package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
- package/dist/providers/BtcAccountProvider.cjs +23 -43
- package/dist/providers/BtcAccountProvider.cjs.map +1 -1
- package/dist/providers/BtcAccountProvider.d.cts +3 -21
- package/dist/providers/BtcAccountProvider.d.cts.map +1 -1
- package/dist/providers/BtcAccountProvider.d.mts +3 -21
- package/dist/providers/BtcAccountProvider.d.mts.map +1 -1
- package/dist/providers/BtcAccountProvider.mjs +23 -43
- package/dist/providers/BtcAccountProvider.mjs.map +1 -1
- package/dist/providers/EvmAccountProvider.cjs +37 -22
- package/dist/providers/EvmAccountProvider.cjs.map +1 -1
- package/dist/providers/EvmAccountProvider.d.cts +3 -1
- package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
- package/dist/providers/EvmAccountProvider.d.mts +3 -1
- package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
- package/dist/providers/EvmAccountProvider.mjs +37 -22
- package/dist/providers/EvmAccountProvider.mjs.map +1 -1
- package/dist/providers/SnapAccountProvider.cjs +80 -9
- package/dist/providers/SnapAccountProvider.cjs.map +1 -1
- package/dist/providers/SnapAccountProvider.d.cts +6 -1
- package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
- package/dist/providers/SnapAccountProvider.d.mts +6 -1
- package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
- package/dist/providers/SnapAccountProvider.mjs +80 -9
- package/dist/providers/SnapAccountProvider.mjs.map +1 -1
- package/dist/providers/SolAccountProvider.cjs +25 -38
- 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 +25 -38
- package/dist/providers/SolAccountProvider.mjs.map +1 -1
- package/dist/providers/TrxAccountProvider.cjs +22 -43
- package/dist/providers/TrxAccountProvider.cjs.map +1 -1
- package/dist/providers/TrxAccountProvider.d.cts +2 -2
- package/dist/providers/TrxAccountProvider.d.cts.map +1 -1
- package/dist/providers/TrxAccountProvider.d.mts +2 -2
- package/dist/providers/TrxAccountProvider.d.mts.map +1 -1
- package/dist/providers/TrxAccountProvider.mjs +22 -43
- package/dist/providers/TrxAccountProvider.mjs.map +1 -1
- package/dist/providers/utils.cjs.map +1 -1
- package/dist/providers/utils.mjs.map +1 -1
- package/dist/tests/accounts.cjs +28 -1
- package/dist/tests/accounts.cjs.map +1 -1
- package/dist/tests/accounts.d.cts +11 -7
- package/dist/tests/accounts.d.cts.map +1 -1
- package/dist/tests/accounts.d.mts +11 -7
- package/dist/tests/accounts.d.mts.map +1 -1
- package/dist/tests/accounts.mjs +25 -0
- package/dist/tests/accounts.mjs.map +1 -1
- package/dist/tests/providers.cjs +1 -0
- package/dist/tests/providers.cjs.map +1 -1
- package/dist/tests/providers.d.cts +1 -0
- package/dist/tests/providers.d.cts.map +1 -1
- package/dist/tests/providers.d.mts +1 -0
- package/dist/tests/providers.d.mts.map +1 -1
- package/dist/tests/providers.mjs +1 -0
- package/dist/tests/providers.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +9 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +9 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
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");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _TrxAccountProvider_instances, _TrxAccountProvider_client, _TrxAccountProvider_getKeyringClientFromSnapId;
|
|
13
1
|
import { assertIsBip44Account } from "@metamask/account-api";
|
|
14
2
|
import { TrxAccountType, TrxScope } from "@metamask/keyring-api";
|
|
15
3
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
16
|
-
import { KeyringClient } from "@metamask/keyring-snap-client";
|
|
17
|
-
import { HandlerType } from "@metamask/snaps-utils";
|
|
18
4
|
import { SnapAccountProvider } from "./SnapAccountProvider.mjs";
|
|
19
5
|
import { withRetry, withTimeout } from "./utils.mjs";
|
|
6
|
+
import { traceFallback } from "../analytics/index.mjs";
|
|
7
|
+
import { TraceName } from "../constants/traces.mjs";
|
|
20
8
|
export const TRX_ACCOUNT_PROVIDER_NAME = 'Tron';
|
|
21
9
|
export class TrxAccountProvider extends SnapAccountProvider {
|
|
22
10
|
constructor(messenger, config = {
|
|
@@ -29,11 +17,8 @@ export class TrxAccountProvider extends SnapAccountProvider {
|
|
|
29
17
|
createAccounts: {
|
|
30
18
|
timeoutMs: 3000,
|
|
31
19
|
},
|
|
32
|
-
}) {
|
|
33
|
-
super(TrxAccountProvider.TRX_SNAP_ID, messenger, config);
|
|
34
|
-
_TrxAccountProvider_instances.add(this);
|
|
35
|
-
_TrxAccountProvider_client.set(this, void 0);
|
|
36
|
-
__classPrivateFieldSet(this, _TrxAccountProvider_client, __classPrivateFieldGet(this, _TrxAccountProvider_instances, "m", _TrxAccountProvider_getKeyringClientFromSnapId).call(this, TrxAccountProvider.TRX_SNAP_ID), "f");
|
|
20
|
+
}, trace = traceFallback) {
|
|
21
|
+
super(TrxAccountProvider.TRX_SNAP_ID, messenger, config, trace);
|
|
37
22
|
}
|
|
38
23
|
getName() {
|
|
39
24
|
return TrxAccountProvider.NAME;
|
|
@@ -56,33 +41,27 @@ export class TrxAccountProvider extends SnapAccountProvider {
|
|
|
56
41
|
});
|
|
57
42
|
}
|
|
58
43
|
async discoverAccounts({ entropySource, groupIndex, }) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
44
|
+
return await super.trace({
|
|
45
|
+
name: TraceName.SnapDiscoverAccounts,
|
|
46
|
+
data: {
|
|
47
|
+
provider: this.getName(),
|
|
48
|
+
},
|
|
49
|
+
}, async () => {
|
|
50
|
+
const discoveredAccounts = await withRetry(() => withTimeout(this.client.discoverAccounts([TrxScope.Mainnet], entropySource, groupIndex), this.config.discovery.timeoutMs), {
|
|
51
|
+
maxAttempts: this.config.discovery.maxAttempts,
|
|
52
|
+
backOffMs: this.config.discovery.backOffMs,
|
|
53
|
+
});
|
|
54
|
+
if (!discoveredAccounts.length) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const createdAccounts = await this.createAccounts({
|
|
58
|
+
entropySource,
|
|
59
|
+
groupIndex,
|
|
60
|
+
});
|
|
61
|
+
return createdAccounts;
|
|
69
62
|
});
|
|
70
|
-
return createdAccounts;
|
|
71
63
|
}
|
|
72
64
|
}
|
|
73
|
-
_TrxAccountProvider_client = new WeakMap(), _TrxAccountProvider_instances = new WeakSet(), _TrxAccountProvider_getKeyringClientFromSnapId = function _TrxAccountProvider_getKeyringClientFromSnapId(snapId) {
|
|
74
|
-
return new KeyringClient({
|
|
75
|
-
send: async (request) => {
|
|
76
|
-
const response = await this.messenger.call('SnapController:handleRequest', {
|
|
77
|
-
snapId: snapId,
|
|
78
|
-
origin: 'metamask',
|
|
79
|
-
handler: HandlerType.OnKeyringRequest,
|
|
80
|
-
request,
|
|
81
|
-
});
|
|
82
|
-
return response;
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
65
|
TrxAccountProvider.NAME = TRX_ACCOUNT_PROVIDER_NAME;
|
|
87
66
|
TrxAccountProvider.TRX_SNAP_ID = 'npm:@metamask/tron-wallet-snap';
|
|
88
67
|
//# sourceMappingURL=TrxAccountProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrxAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TrxAccountProvider.mjs","sourceRoot":"","sources":["../../src/providers/TrxAccountProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAqB,8BAA8B;AAGhF,OAAO,EAAE,cAAc,EA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,OAAO;aACxB,CAAC,EACF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CACrC,CAAC;YAEF,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAC9B,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,EACrB,aAAa,EACb,UAAU,GAIX;QACC,OAAO,MAAM,KAAK,CAAC,KAAK,CACtB;YACE,IAAI,EAAE,SAAS,CAAC,oBAAoB;YACpC,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;aACzB;SACF,EACD,KAAK,IAAI,EAAE;YACT,MAAM,kBAAkB,GAAG,MAAM,SAAS,CACxC,GAAG,EAAE,CACH,WAAW,CACT,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAC1B,CAAC,QAAQ,CAAC,OAAO,CAAC,EAClB,aAAa,EACb,UAAU,CACX,EACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAChC,EACH;gBACE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW;gBAC9C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS;aAC3C,CACF,CAAC;YAEF,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;gBAC/B,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;gBAChD,aAAa;gBACb,UAAU;aACX,CAAC,CAAC;YAEH,OAAO,eAAe,CAAC;QACzB,CAAC,CACF,CAAC;IACJ,CAAC;;AArGM,uBAAI,GAAG,yBAAyB,CAAC;AAEjC,8BAAW,GAAG,gCAA0C,CAAC","sourcesContent":["import { assertIsBip44Account, type Bip44Account } from '@metamask/account-api';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { EntropySourceId, KeyringAccount } from '@metamask/keyring-api';\nimport { TrxAccountType, TrxScope } 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 {\n SnapAccountProvider,\n type SnapAccountProviderConfig,\n} from './SnapAccountProvider';\nimport { withRetry, withTimeout } from './utils';\nimport { traceFallback } from '../analytics';\nimport { TraceName } from '../constants/traces';\nimport type { MultichainAccountServiceMessenger } from '../types';\n\nexport type TrxAccountProviderConfig = SnapAccountProviderConfig;\n\nexport const TRX_ACCOUNT_PROVIDER_NAME = 'Tron' as const;\n\nexport class TrxAccountProvider extends SnapAccountProvider {\n static NAME = TRX_ACCOUNT_PROVIDER_NAME;\n\n static TRX_SNAP_ID = 'npm:@metamask/tron-wallet-snap' as SnapId;\n\n constructor(\n messenger: MultichainAccountServiceMessenger,\n config: TrxAccountProviderConfig = {\n maxConcurrency: 3,\n discovery: {\n timeoutMs: 2000,\n maxAttempts: 3,\n backOffMs: 1000,\n },\n createAccounts: {\n timeoutMs: 3000,\n },\n },\n trace: TraceCallback = traceFallback,\n ) {\n super(TrxAccountProvider.TRX_SNAP_ID, messenger, config, trace);\n }\n\n getName(): string {\n return TrxAccountProvider.NAME;\n }\n\n isAccountCompatible(account: Bip44Account<InternalAccount>): boolean {\n return (\n account.type === TrxAccountType.Eoa &&\n account.metadata.keyring.type === (KeyringTypes.snap as string)\n );\n }\n\n async createAccounts({\n entropySource,\n groupIndex: index,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return this.withMaxConcurrency(async () => {\n const createAccount = await this.getRestrictedSnapAccountCreator();\n\n const account = await withTimeout(\n createAccount({\n entropySource,\n index,\n addressType: TrxAccountType.Eoa,\n scope: TrxScope.Mainnet,\n }),\n this.config.createAccounts.timeoutMs,\n );\n\n assertIsBip44Account(account);\n return [account];\n });\n }\n\n async discoverAccounts({\n entropySource,\n groupIndex,\n }: {\n entropySource: EntropySourceId;\n groupIndex: number;\n }): Promise<Bip44Account<KeyringAccount>[]> {\n return await super.trace(\n {\n name: TraceName.SnapDiscoverAccounts,\n data: {\n provider: this.getName(),\n },\n },\n async () => {\n const discoveredAccounts = await withRetry(\n () =>\n withTimeout(\n this.client.discoverAccounts(\n [TrxScope.Mainnet],\n entropySource,\n groupIndex,\n ),\n this.config.discovery.timeoutMs,\n ),\n {\n maxAttempts: this.config.discovery.maxAttempts,\n backOffMs: this.config.discovery.backOffMs,\n },\n );\n\n if (!discoveredAccounts.length) {\n return [];\n }\n\n const createdAccounts = await this.createAccounts({\n entropySource,\n groupIndex,\n });\n\n return createdAccounts;\n },\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,SAAS,CAC7B,WAA6B,EAC7B,EACE,WAAW,GAAG,CAAC,EACf,SAAS,GAAG,GAAG,MACiC,EAAE;IAEpD,IAAI,SAAS,CAAC;IACd,IAAI,OAAO,GAAG,SAAS,CAAC;IACxB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;;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":["/** Timeout error. */\nexport class TimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Execute a function with exponential backoff on transient failures.\n *\n * @param fnToExecute - The function to execute.\n * @param options - The options for the retry.\n * @param options.maxAttempts - The maximum number of attempts.\n * @param options.backOffMs - The backoff in milliseconds.\n * @throws An error if the transaction count cannot be retrieved.\n * @returns The result of the function.\n */\nexport async function withRetry<T>(\n fnToExecute: () => Promise<T>,\n {\n maxAttempts = 3,\n backOffMs = 500,\n }: { maxAttempts?: number; backOffMs?: number } = {},\n): Promise<T> {\n let lastError;\n let backOff = backOffMs;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fnToExecute();\n } catch (error) {\n lastError = error;\n if (attempt >= maxAttempts) {\n break;\n }\n const delay = backOff;\n await new Promise((resolve) => setTimeout(resolve, delay));\n backOff *= 2;\n }\n }\n throw lastError;\n}\n\n/**\n * Execute a promise with a timeout.\n *\n * @param promise - The promise to execute.\n * @param timeoutMs - The timeout in milliseconds.\n * @returns The result of the promise.\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number = 500,\n): Promise<T> {\n let timer;\n try {\n return await Promise.race<T>([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(\n () => reject(new TimeoutError('Timed out')),\n timeoutMs,\n );\n }),\n ]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../src/providers/utils.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,WAA6B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B,YAAoB,GAAG;IAEvB,IAAI,KAAK,CAAC;IACV,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAI;YAC3B,OAAO;YACP,IAAI,OAAO,CAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;gBAClC,KAAK,GAAG,UAAU,CAChB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC,EAC3C,SAAS,CACV,CAAC;YACJ,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/** Timeout error. */\nexport class TimeoutError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Execute a function with exponential backoff on transient failures.\n *\n * @param fnToExecute - The function to execute.\n * @param options - The options for the retry.\n * @param options.maxAttempts - The maximum number of attempts.\n * @param options.backOffMs - The backoff in milliseconds.\n * @throws An error if the transaction count cannot be retrieved.\n * @returns The result of the function.\n */\nexport async function withRetry<T>(\n fnToExecute: () => Promise<T>,\n {\n maxAttempts = 3,\n backOffMs = 500,\n }: { maxAttempts?: number; backOffMs?: number } = {},\n): Promise<T> {\n let lastError;\n let backOff = backOffMs;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fnToExecute();\n } catch (error) {\n lastError = error;\n if (attempt >= maxAttempts) {\n break;\n }\n const delay = backOff;\n await new Promise((resolve) => setTimeout(resolve, delay));\n backOff *= 2;\n }\n }\n throw lastError;\n}\n\n/**\n * Execute a promise with a timeout.\n *\n * @param promise - The promise to execute.\n * @param timeoutMs - The timeout in milliseconds.\n * @returns The result of the promise.\n */\nexport async function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number = 500,\n): Promise<T> {\n let timer;\n try {\n return await Promise.race<T>([\n promise,\n new Promise<T>((_resolve, reject) => {\n timer = setTimeout(\n () => reject(new TimeoutError('Timed out')),\n timeoutMs,\n );\n }),\n ]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n"]}
|
package/dist/tests/accounts.cjs
CHANGED
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
};
|
|
13
13
|
var _MockAccountBuilder_account;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.mockAsInternalAccount = exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = exports.MOCK_WALLET_1_SOL_ACCOUNT = exports.MOCK_WALLET_1_EVM_ACCOUNT = exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_BTC_P2TR_ACCOUNT_1 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = exports.MOCK_BTC_P2TR_DISCOVERED_ACCOUNT_1 = exports.MOCK_TRX_DISCOVERED_ACCOUNT_1 = exports.MOCK_SOL_DISCOVERED_ACCOUNT_1 = exports.MOCK_TRX_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = exports.MOCK_HD_KEYRING_2 = exports.MOCK_HD_KEYRING_1 = exports.MOCK_MNEMONIC = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = exports.ETH_EOA_METHODS = void 0;
|
|
15
|
+
exports.mockAsInternalAccount = exports.MOCK_WALLET_1_BTC_P2TR_ACCOUNT = exports.MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = exports.MOCK_WALLET_1_SOL_ACCOUNT = exports.MOCK_WALLET_1_EVM_ACCOUNT = exports.MOCK_WALLET_1_ENTROPY_SOURCE = exports.MockAccountBuilder = exports.asKeyringAccount = exports.isInternalAccount = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_4 = exports.MOCK_SNAP_ACCOUNT_3 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_BTC_P2TR_ACCOUNT_1 = exports.MOCK_BTC_P2WPKH_ACCOUNT_1 = exports.MOCK_BTC_P2TR_DISCOVERED_ACCOUNT_1 = exports.MOCK_TRX_DISCOVERED_ACCOUNT_1 = exports.MOCK_SOL_DISCOVERED_ACCOUNT_1 = exports.MOCK_TRX_ACCOUNT_1 = exports.MOCK_SOL_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = exports.MOCK_HD_KEYRING_2 = exports.MOCK_HD_KEYRING_1 = exports.MOCK_MNEMONIC = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = exports.ETH_EOA_METHODS = void 0;
|
|
16
16
|
const account_api_1 = require("@metamask/account-api");
|
|
17
17
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
18
18
|
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
@@ -248,6 +248,23 @@ exports.MOCK_HARDWARE_ACCOUNT_1 = {
|
|
|
248
248
|
lastSelected: 0,
|
|
249
249
|
},
|
|
250
250
|
};
|
|
251
|
+
function isInternalAccount(account) {
|
|
252
|
+
// Meant to be used for testing, so we keep this simple.
|
|
253
|
+
return Object.prototype.hasOwnProperty.call(account, 'metadata');
|
|
254
|
+
}
|
|
255
|
+
exports.isInternalAccount = isInternalAccount;
|
|
256
|
+
function asKeyringAccount(account) {
|
|
257
|
+
const { id, type, address, scopes, options, methods } = account;
|
|
258
|
+
return {
|
|
259
|
+
id,
|
|
260
|
+
type,
|
|
261
|
+
address,
|
|
262
|
+
scopes,
|
|
263
|
+
options,
|
|
264
|
+
methods,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
exports.asKeyringAccount = asKeyringAccount;
|
|
251
268
|
class MockAccountBuilder {
|
|
252
269
|
constructor(account) {
|
|
253
270
|
_MockAccountBuilder_account.set(this, void 0);
|
|
@@ -281,6 +298,16 @@ class MockAccountBuilder {
|
|
|
281
298
|
}
|
|
282
299
|
return this;
|
|
283
300
|
}
|
|
301
|
+
withSnapId(snapId) {
|
|
302
|
+
if (isInternalAccount(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
303
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").metadata.snap = {
|
|
304
|
+
enabled: true,
|
|
305
|
+
id: snapId,
|
|
306
|
+
name: `Name: ${snapId}`,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
284
311
|
get() {
|
|
285
312
|
return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
|
|
286
313
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAuD;AAMvD,uDAc+B;AAC/B,qEAA4D;AAE5D,+BAAkC;AAErB,QAAA,eAAe,GAAG;IAC7B,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,IAAI;IACd,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAS,CAAC,CAAC;AAEhC,QAAA,WAAW,GAAG;IACzB,EAAE,EAAE,s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,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,gCAAgC,GAAG,kBAAkB,CAAC,IAAI,CACrE,iCAAyB,CAC1B;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AACI,QAAA,8BAA8B,GAAG,kBAAkB,CAAC,IAAI,CACnE,+BAAuB,CACxB;KACE,iBAAiB,CAAC,oCAA4B,CAAC;KAC/C,cAAc,CAAC,CAAC,CAAC;KACjB,GAAG,EAAE,CAAC;AAET,SAAgB,qBAAqB,CACnC,OAAuB;IAEvB,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE;YACR,IAAI,EAAE,gBAAgB;YACtB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,OAAO,EAAE;gBACP,IAAI,EAAE,mBAAmB;aAC1B;SACF;KACF,CAAC;AACJ,CAAC;AAbD,sDAaC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\nimport type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type {\n DiscoveredAccount,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n TrxAccountType,\n TrxMethod,\n TrxScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { v4 as uuid } from 'uuid';\n\nexport const ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_MNEMONIC =\n 'abandon ability able about above absent absorb abstract absurd abuse access accident';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<InternalAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n metadata: {\n name: 'Solana Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_TRX_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [TrxMethod.SignMessageV2, TrxMethod.VerifyMessageV2],\n type: TrxAccountType.Eoa,\n scopes: [TrxScope.Mainnet],\n metadata: {\n name: 'Tron Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SOL_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [SolScope.Mainnet],\n derivationPath: `m/44'/501'/0'/0'`,\n};\n\nexport const MOCK_TRX_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [TrxScope.Mainnet],\n derivationPath: `m/44'/195'/0'/0'`,\n};\n\nexport const MOCK_BTC_P2TR_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [BtcScope.Mainnet],\n derivationPath: `m/44'/0'/0'/0'`,\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: Object.values(BtcMethod),\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n metadata: {\n name: 'Bitcoin Native Segwit Account 1',\n importTime: 0,\n keyring: {\n type: KeyringTypes.snap,\n },\n snap: {\n id: 'mock-btc-snap-id',\n enabled: true,\n name: 'Mock Bitcoin Snap',\n },\n },\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: Object.values(BtcMethod),\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n metadata: {\n name: 'Bitcoin Taproot Account 1',\n importTime: 0,\n keyring: {\n type: KeyringTypes.snap,\n },\n snap: {\n id: 'mock-btc-snap-id',\n enabled: true,\n name: 'Mock Bitcoin Snap',\n },\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: InternalAccount['id']) {\n this.#account.id = id;\n return this;\n }\n\n withUuid() {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string) {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n\nexport function mockAsInternalAccount(\n account: KeyringAccount,\n): InternalAccount {\n return {\n ...account,\n metadata: {\n name: 'Mocked Account',\n importTime: Date.now(),\n keyring: {\n type: 'mock-keyring-type',\n },\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,uDAAuD;AAMvD,uDAc+B;AAC/B,qEAA4D;AAG5D,+BAAkC;AAErB,QAAA,eAAe,GAAG;IAC7B,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,IAAI;IACd,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAS,CAAC,CAAC;AAEhC,QAAA,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEW,QAAA,WAAW,GAAG;I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nimport type { Bip44Account } from '@metamask/account-api';\nimport { isBip44Account } from '@metamask/account-api';\nimport type {\n DiscoveredAccount,\n EntropySourceId,\n KeyringAccount,\n} from '@metamask/keyring-api';\nimport {\n BtcAccountType,\n BtcMethod,\n BtcScope,\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n TrxAccountType,\n TrxMethod,\n TrxScope,\n} 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';\nimport { v4 as uuid } from 'uuid';\n\nexport const ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_MNEMONIC =\n 'abandon ability able about above absent absorb abstract absurd abuse access accident';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: Bip44Account<InternalAccount> = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SOL_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet, SolScope.Testnet, SolScope.Devnet],\n metadata: {\n name: 'Solana Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_TRX_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [TrxMethod.SignMessageV2, TrxMethod.VerifyMessageV2],\n type: TrxAccountType.Eoa,\n scopes: [TrxScope.Mainnet],\n metadata: {\n name: 'Tron Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SOL_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [SolScope.Mainnet],\n derivationPath: `m/44'/501'/0'/0'`,\n};\n\nexport const MOCK_TRX_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [TrxScope.Mainnet],\n derivationPath: `m/44'/195'/0'/0'`,\n};\n\nexport const MOCK_BTC_P2TR_DISCOVERED_ACCOUNT_1: DiscoveredAccount = {\n type: 'bip44',\n scopes: [BtcScope.Mainnet],\n derivationPath: `m/44'/0'/0'/0'`,\n};\n\nexport const MOCK_BTC_P2WPKH_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'b0f030d8-e101-4b5a-a3dd-13f8ca8ec1db',\n type: BtcAccountType.P2wpkh,\n methods: Object.values(BtcMethod),\n address: 'bc1qx8ls07cy8j8nrluy2u0xwn7gh8fxg0rg4s8zze',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Mainnet],\n metadata: {\n name: 'Bitcoin Native Segwit Account 1',\n importTime: 0,\n keyring: {\n type: KeyringTypes.snap,\n },\n snap: {\n id: 'mock-btc-snap-id',\n enabled: true,\n name: 'Mock Bitcoin Snap',\n },\n },\n};\n\nexport const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<InternalAccount> = {\n id: 'a20c2e1a-6ff6-40ba-b8e0-ccdb6f9933bb',\n type: BtcAccountType.P2tr,\n methods: Object.values(BtcMethod),\n address: 'tb1p5cyxnuxmeuwuvkwfem96lxx9wex9kkf4mt9ll6q60jfsnrzqg4sszkqjnh',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n scopes: [BtcScope.Testnet],\n metadata: {\n name: 'Bitcoin Taproot Account 1',\n importTime: 0,\n keyring: {\n type: KeyringTypes.snap,\n },\n snap: {\n id: 'mock-btc-snap-id',\n enabled: true,\n name: 'Mock Bitcoin Snap',\n },\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1 = MOCK_SOL_ACCOUNT_1;\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_3 = MOCK_BTC_P2WPKH_ACCOUNT_1;\nexport const MOCK_SNAP_ACCOUNT_4 = MOCK_BTC_P2TR_ACCOUNT_1;\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport function isInternalAccount(\n account: KeyringAccount,\n): account is InternalAccount {\n // Meant to be used for testing, so we keep this simple.\n return Object.prototype.hasOwnProperty.call(account, 'metadata');\n}\n\nexport function asKeyringAccount<Account extends KeyringAccount>(\n account: Account,\n): KeyringAccount {\n const { id, type, address, scopes, options, methods } = account;\n\n return {\n id,\n type,\n address,\n scopes,\n options,\n methods,\n };\n}\n\nexport class MockAccountBuilder<Account extends KeyringAccount> {\n readonly #account: Account;\n\n constructor(account: Account) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from<Account extends KeyringAccount>(\n account: Account,\n ): MockAccountBuilder<Account> {\n return new MockAccountBuilder(account);\n }\n\n withId(id: InternalAccount['id']) {\n this.#account.id = id;\n return this;\n }\n\n withUuid() {\n this.#account.id = uuid();\n return this;\n }\n\n withAddressSuffix(suffix: string) {\n this.#account.address += suffix;\n return this;\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n withSnapId(snapId: SnapId) {\n if (isInternalAccount(this.#account)) {\n this.#account.metadata.snap = {\n enabled: true,\n id: snapId,\n name: `Name: ${snapId}`,\n };\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n\nexport const MOCK_WALLET_1_ENTROPY_SOURCE = MOCK_ENTROPY_SOURCE_1;\n\nexport const MOCK_WALLET_1_EVM_ACCOUNT = MockAccountBuilder.from(\n MOCK_HD_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_SOL_ACCOUNT = MockAccountBuilder.from(\n MOCK_SOL_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2WPKH_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\nexport const MOCK_WALLET_1_BTC_P2TR_ACCOUNT = MockAccountBuilder.from(\n MOCK_BTC_P2TR_ACCOUNT_1,\n)\n .withEntropySource(MOCK_WALLET_1_ENTROPY_SOURCE)\n .withGroupIndex(0)\n .get();\n\nexport function mockAsInternalAccount(\n account: KeyringAccount,\n): InternalAccount {\n return {\n ...account,\n metadata: {\n name: 'Mocked Account',\n importTime: Date.now(),\n keyring: {\n type: 'mock-keyring-type',\n },\n },\n };\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import type { DiscoveredAccount, EntropySourceId, KeyringAccount } from "@metama
|
|
|
3
3
|
import { EthMethod } from "@metamask/keyring-api";
|
|
4
4
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
5
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
6
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
6
7
|
export declare const ETH_EOA_METHODS: readonly [EthMethod.PersonalSign, EthMethod.Sign, EthMethod.SignTransaction, EthMethod.SignTypedDataV1, EthMethod.SignTypedDataV3, EthMethod.SignTypedDataV4];
|
|
7
8
|
export declare const MOCK_SNAP_1: {
|
|
8
9
|
id: string;
|
|
@@ -51,7 +52,7 @@ export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<InternalAccount>;
|
|
|
51
52
|
export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
|
|
52
53
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
53
54
|
id: string;
|
|
54
|
-
options: Record<string, import("@metamask/
|
|
55
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
55
56
|
entropy?: {
|
|
56
57
|
type: "mnemonic";
|
|
57
58
|
id: string;
|
|
@@ -84,7 +85,7 @@ export declare const MOCK_SNAP_ACCOUNT_2: InternalAccount;
|
|
|
84
85
|
export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
85
86
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
86
87
|
id: string;
|
|
87
|
-
options: Record<string, import("@metamask/
|
|
88
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
88
89
|
entropy?: {
|
|
89
90
|
type: "mnemonic";
|
|
90
91
|
id: string;
|
|
@@ -116,7 +117,7 @@ export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
|
116
117
|
export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
117
118
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
118
119
|
id: string;
|
|
119
|
-
options: Record<string, import("@metamask/
|
|
120
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
120
121
|
entropy?: {
|
|
121
122
|
type: "mnemonic";
|
|
122
123
|
id: string;
|
|
@@ -146,6 +147,8 @@ export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
|
146
147
|
methods: string[];
|
|
147
148
|
}>;
|
|
148
149
|
export declare const MOCK_HARDWARE_ACCOUNT_1: InternalAccount;
|
|
150
|
+
export declare function isInternalAccount(account: KeyringAccount): account is InternalAccount;
|
|
151
|
+
export declare function asKeyringAccount<Account extends KeyringAccount>(account: Account): KeyringAccount;
|
|
149
152
|
export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
150
153
|
#private;
|
|
151
154
|
constructor(account: Account);
|
|
@@ -155,13 +158,14 @@ export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
|
155
158
|
withAddressSuffix(suffix: string): this;
|
|
156
159
|
withEntropySource(entropySource: EntropySourceId): this;
|
|
157
160
|
withGroupIndex(groupIndex: number): this;
|
|
161
|
+
withSnapId(snapId: SnapId): this;
|
|
158
162
|
get(): Account;
|
|
159
163
|
}
|
|
160
164
|
export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
|
|
161
165
|
export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
162
166
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
163
167
|
id: string;
|
|
164
|
-
options: Record<string, import("@metamask/
|
|
168
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
165
169
|
entropy?: {
|
|
166
170
|
type: "mnemonic";
|
|
167
171
|
id: string;
|
|
@@ -193,7 +197,7 @@ export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
|
193
197
|
export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
194
198
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
195
199
|
id: string;
|
|
196
|
-
options: Record<string, import("@metamask/
|
|
200
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
197
201
|
entropy?: {
|
|
198
202
|
type: "mnemonic";
|
|
199
203
|
id: string;
|
|
@@ -225,7 +229,7 @@ export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
|
225
229
|
export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
226
230
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
227
231
|
id: string;
|
|
228
|
-
options: Record<string, import("@metamask/
|
|
232
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
229
233
|
entropy?: {
|
|
230
234
|
type: "mnemonic";
|
|
231
235
|
id: string;
|
|
@@ -257,7 +261,7 @@ export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
|
257
261
|
export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
|
|
258
262
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
259
263
|
id: string;
|
|
260
|
-
options: Record<string, import("@metamask/
|
|
264
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
261
265
|
entropy?: {
|
|
262
266
|
type: "mnemonic";
|
|
263
267
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,EAKL,SAAS,EASV,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;
|
|
1
|
+
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,EAKL,SAAS,EASV,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;A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C,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,GACtB,OAAO,IAAI,eAAe,CAG5B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,cAAc,EAC7D,OAAO,EAAE,OAAO,GACf,cAAc,CAWhB;AAED,qBAAa,kBAAkB,CAAC,OAAO,SAAS,cAAc;;gBAGhD,OAAO,EAAE,OAAO;IAK5B,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,cAAc,EACxC,OAAO,EAAE,OAAO,GACf,kBAAkB,CAAC,OAAO,CAAC;IAI9B,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC;IAKhC,QAAQ;IAKR,iBAAiB,CAAC,MAAM,EAAE,MAAM;IAKhC,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,UAAU,CAAC,MAAM,EAAE,MAAM;IAWzB,GAAG;CAGJ;AAED,eAAO,MAAM,4BAA4B,sBAAwB,CAAC;AAElE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK9B,CAAC;AACT,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK9B,CAAC;AACT,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKrC,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnC,CAAC;AAET,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,GACtB,eAAe,CAWjB"}
|
|
@@ -3,6 +3,7 @@ import type { DiscoveredAccount, EntropySourceId, KeyringAccount } from "@metama
|
|
|
3
3
|
import { EthMethod } from "@metamask/keyring-api";
|
|
4
4
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
5
5
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
6
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
6
7
|
export declare const ETH_EOA_METHODS: readonly [EthMethod.PersonalSign, EthMethod.Sign, EthMethod.SignTransaction, EthMethod.SignTypedDataV1, EthMethod.SignTypedDataV3, EthMethod.SignTypedDataV4];
|
|
7
8
|
export declare const MOCK_SNAP_1: {
|
|
8
9
|
id: string;
|
|
@@ -51,7 +52,7 @@ export declare const MOCK_BTC_P2TR_ACCOUNT_1: Bip44Account<InternalAccount>;
|
|
|
51
52
|
export declare const MOCK_SNAP_ACCOUNT_1: Bip44Account<{
|
|
52
53
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
53
54
|
id: string;
|
|
54
|
-
options: Record<string, import("@metamask/
|
|
55
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
55
56
|
entropy?: {
|
|
56
57
|
type: "mnemonic";
|
|
57
58
|
id: string;
|
|
@@ -84,7 +85,7 @@ export declare const MOCK_SNAP_ACCOUNT_2: InternalAccount;
|
|
|
84
85
|
export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
85
86
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
86
87
|
id: string;
|
|
87
|
-
options: Record<string, import("@metamask/
|
|
88
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
88
89
|
entropy?: {
|
|
89
90
|
type: "mnemonic";
|
|
90
91
|
id: string;
|
|
@@ -116,7 +117,7 @@ export declare const MOCK_SNAP_ACCOUNT_3: Bip44Account<{
|
|
|
116
117
|
export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
117
118
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
118
119
|
id: string;
|
|
119
|
-
options: Record<string, import("@metamask/
|
|
120
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
120
121
|
entropy?: {
|
|
121
122
|
type: "mnemonic";
|
|
122
123
|
id: string;
|
|
@@ -146,6 +147,8 @@ export declare const MOCK_SNAP_ACCOUNT_4: Bip44Account<{
|
|
|
146
147
|
methods: string[];
|
|
147
148
|
}>;
|
|
148
149
|
export declare const MOCK_HARDWARE_ACCOUNT_1: InternalAccount;
|
|
150
|
+
export declare function isInternalAccount(account: KeyringAccount): account is InternalAccount;
|
|
151
|
+
export declare function asKeyringAccount<Account extends KeyringAccount>(account: Account): KeyringAccount;
|
|
149
152
|
export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
150
153
|
#private;
|
|
151
154
|
constructor(account: Account);
|
|
@@ -155,13 +158,14 @@ export declare class MockAccountBuilder<Account extends KeyringAccount> {
|
|
|
155
158
|
withAddressSuffix(suffix: string): this;
|
|
156
159
|
withEntropySource(entropySource: EntropySourceId): this;
|
|
157
160
|
withGroupIndex(groupIndex: number): this;
|
|
161
|
+
withSnapId(snapId: SnapId): this;
|
|
158
162
|
get(): Account;
|
|
159
163
|
}
|
|
160
164
|
export declare const MOCK_WALLET_1_ENTROPY_SOURCE = "mock-keyring-id-1";
|
|
161
165
|
export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
162
166
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
163
167
|
id: string;
|
|
164
|
-
options: Record<string, import("@metamask/
|
|
168
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
165
169
|
entropy?: {
|
|
166
170
|
type: "mnemonic";
|
|
167
171
|
id: string;
|
|
@@ -193,7 +197,7 @@ export declare const MOCK_WALLET_1_EVM_ACCOUNT: Bip44Account<{
|
|
|
193
197
|
export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
194
198
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
195
199
|
id: string;
|
|
196
|
-
options: Record<string, import("@metamask/
|
|
200
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
197
201
|
entropy?: {
|
|
198
202
|
type: "mnemonic";
|
|
199
203
|
id: string;
|
|
@@ -225,7 +229,7 @@ export declare const MOCK_WALLET_1_SOL_ACCOUNT: Bip44Account<{
|
|
|
225
229
|
export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
226
230
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
227
231
|
id: string;
|
|
228
|
-
options: Record<string, import("@metamask/
|
|
232
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
229
233
|
entropy?: {
|
|
230
234
|
type: "mnemonic";
|
|
231
235
|
id: string;
|
|
@@ -257,7 +261,7 @@ export declare const MOCK_WALLET_1_BTC_P2WPKH_ACCOUNT: Bip44Account<{
|
|
|
257
261
|
export declare const MOCK_WALLET_1_BTC_P2TR_ACCOUNT: Bip44Account<{
|
|
258
262
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
|
|
259
263
|
id: string;
|
|
260
|
-
options: Record<string, import("@metamask/
|
|
264
|
+
options: Record<string, import("@metamask/snaps-sdk").Json> & {
|
|
261
265
|
entropy?: {
|
|
262
266
|
type: "mnemonic";
|
|
263
267
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,EAKL,SAAS,EASV,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;
|
|
1
|
+
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,8BAA8B;AAC/B,OAAO,EAKL,SAAS,EASV,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAGlD,eAAO,MAAM,eAAe,+JAOlB,CAAC;AAIX,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,eAAO,MAAM,aAAa,yFAC8D,CAAC;AAEzF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,eAAe,CAqB3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,eAAe,CAqB3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,eAAe,CAsB5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAA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B,sBAAwB,CAAC;AAElE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK9B,CAAC;AACT,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK9B,CAAC;AACT,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKrC,CAAC;AACT,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnC,CAAC;AAET,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,GACtB,eAAe,CAWjB"}
|
package/dist/tests/accounts.mjs
CHANGED
|
@@ -245,6 +245,21 @@ export const MOCK_HARDWARE_ACCOUNT_1 = {
|
|
|
245
245
|
lastSelected: 0,
|
|
246
246
|
},
|
|
247
247
|
};
|
|
248
|
+
export function isInternalAccount(account) {
|
|
249
|
+
// Meant to be used for testing, so we keep this simple.
|
|
250
|
+
return Object.prototype.hasOwnProperty.call(account, 'metadata');
|
|
251
|
+
}
|
|
252
|
+
export function asKeyringAccount(account) {
|
|
253
|
+
const { id, type, address, scopes, options, methods } = account;
|
|
254
|
+
return {
|
|
255
|
+
id,
|
|
256
|
+
type,
|
|
257
|
+
address,
|
|
258
|
+
scopes,
|
|
259
|
+
options,
|
|
260
|
+
methods,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
248
263
|
export class MockAccountBuilder {
|
|
249
264
|
constructor(account) {
|
|
250
265
|
_MockAccountBuilder_account.set(this, void 0);
|
|
@@ -278,6 +293,16 @@ export class MockAccountBuilder {
|
|
|
278
293
|
}
|
|
279
294
|
return this;
|
|
280
295
|
}
|
|
296
|
+
withSnapId(snapId) {
|
|
297
|
+
if (isInternalAccount(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
298
|
+
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").metadata.snap = {
|
|
299
|
+
enabled: true,
|
|
300
|
+
id: snapId,
|
|
301
|
+
name: `Name: ${snapId}`,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
281
306
|
get() {
|
|
282
307
|
return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
|
|
283
308
|
}
|