@metamask-previews/multichain-account-service 0.2.1-preview-0cb117e2 → 0.2.1-preview-bd86fa14
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 +1 -11
- package/dist/MultichainAccountService.cjs +36 -113
- package/dist/MultichainAccountService.cjs.map +1 -1
- package/dist/MultichainAccountService.d.cts +5 -36
- package/dist/MultichainAccountService.d.cts.map +1 -1
- package/dist/MultichainAccountService.d.mts +5 -36
- package/dist/MultichainAccountService.d.mts.map +1 -1
- package/dist/MultichainAccountService.mjs +35 -112
- 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 +19 -4
- package/dist/providers/BaseAccountProvider.cjs.map +1 -1
- package/dist/providers/BaseAccountProvider.d.cts +19 -5
- package/dist/providers/BaseAccountProvider.d.cts.map +1 -1
- package/dist/providers/BaseAccountProvider.d.mts +19 -5
- package/dist/providers/BaseAccountProvider.d.mts.map +1 -1
- package/dist/providers/BaseAccountProvider.mjs +17 -3
- package/dist/providers/BaseAccountProvider.mjs.map +1 -1
- package/dist/providers/EvmAccountProvider.cjs.map +1 -1
- package/dist/providers/EvmAccountProvider.d.cts +1 -2
- package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
- package/dist/providers/EvmAccountProvider.d.mts +1 -2
- 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 +1 -2
- package/dist/providers/SolAccountProvider.d.cts.map +1 -1
- package/dist/providers/SolAccountProvider.d.mts +1 -2
- package/dist/providers/SolAccountProvider.d.mts.map +1 -1
- package/dist/providers/SolAccountProvider.mjs.map +1 -1
- package/dist/tests/accounts.cjs +3 -7
- package/dist/tests/accounts.cjs.map +1 -1
- package/dist/tests/accounts.d.cts +0 -1
- package/dist/tests/accounts.d.cts.map +1 -1
- package/dist/tests/accounts.d.mts +0 -1
- package/dist/tests/accounts.d.mts.map +1 -1
- package/dist/tests/accounts.mjs +1 -5
- package/dist/tests/accounts.mjs.map +1 -1
- package/dist/tests/messenger.cjs +1 -5
- 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 +1 -5
- package/dist/tests/messenger.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -20
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +3 -20
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -3
package/dist/tests/accounts.cjs
CHANGED
|
@@ -13,9 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _MockAccountBuilder_account;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MockAccountBuilder = exports.MOCK_HARDWARE_ACCOUNT_1 = exports.MOCK_SNAP_ACCOUNT_2 = exports.MOCK_SNAP_ACCOUNT_1 = exports.MOCK_HD_ACCOUNT_2 = exports.MOCK_HD_ACCOUNT_1 = exports.MOCK_HD_KEYRING_2 = exports.MOCK_HD_KEYRING_1 = exports.MOCK_ENTROPY_SOURCE_2 = exports.MOCK_ENTROPY_SOURCE_1 = exports.MOCK_SNAP_2 = exports.MOCK_SNAP_1 = void 0;
|
|
16
|
-
const account_api_1 = require("@metamask/account-api");
|
|
17
16
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
18
17
|
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
18
|
+
const BaseAccountProvider_1 = require("../providers/BaseAccountProvider.cjs");
|
|
19
19
|
const ETH_EOA_METHODS = [
|
|
20
20
|
keyring_api_1.EthMethod.PersonalSign,
|
|
21
21
|
keyring_api_1.EthMethod.Sign,
|
|
@@ -158,18 +158,14 @@ class MockAccountBuilder {
|
|
|
158
158
|
static from(account) {
|
|
159
159
|
return new MockAccountBuilder(account);
|
|
160
160
|
}
|
|
161
|
-
withId(id) {
|
|
162
|
-
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
165
161
|
withEntropySource(entropySource) {
|
|
166
|
-
if ((0,
|
|
162
|
+
if ((0, BaseAccountProvider_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
167
163
|
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
|
|
168
164
|
}
|
|
169
165
|
return this;
|
|
170
166
|
}
|
|
171
167
|
withGroupIndex(groupIndex) {
|
|
172
|
-
if ((0,
|
|
168
|
+
if ((0, BaseAccountProvider_1.isBip44Account)(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
173
169
|
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
|
|
174
170
|
}
|
|
175
171
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"accounts.cjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uDAQ+B;AAC/B,qEAA4D;AAG5D,8EAAkE;AAElE,MAAM,eAAe,GAAG;IACtB,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,IAAI;IACd,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,eA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C,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,iBAAiB,CAAC,aAA8B;QAC9C,IAAI,IAAA,oCAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,IAAA,oCAAc,EAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF;AA7BD,gDA6BC","sourcesContent":["import type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { isBip44Account } from '../providers/BaseAccountProvider';\n\nconst 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_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: 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: 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_SNAP_ACCOUNT_1: 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],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\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_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 {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\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: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\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"]}
|
|
@@ -44,7 +44,6 @@ export declare class MockAccountBuilder {
|
|
|
44
44
|
#private;
|
|
45
45
|
constructor(account: InternalAccount);
|
|
46
46
|
static from(account: InternalAccount): MockAccountBuilder;
|
|
47
|
-
withId(id: InternalAccount['id']): this;
|
|
48
47
|
withEntropySource(entropySource: EntropySourceId): this;
|
|
49
48
|
withGroupIndex(groupIndex: number): this;
|
|
50
49
|
get(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.cts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAetE,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,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
|
|
@@ -44,7 +44,6 @@ export declare class MockAccountBuilder {
|
|
|
44
44
|
#private;
|
|
45
45
|
constructor(account: InternalAccount);
|
|
46
46
|
static from(account: InternalAccount): MockAccountBuilder;
|
|
47
|
-
withId(id: InternalAccount['id']): this;
|
|
48
47
|
withEntropySource(entropySource: EntropySourceId): this;
|
|
49
48
|
withGroupIndex(groupIndex: number): this;
|
|
50
49
|
get(): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.mts","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAU7D,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAetE,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,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAqB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAsBjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,eAarC,CAAC;AAEF,qBAAa,kBAAkB;;gBAGjB,OAAO,EAAE,eAAe;IAKpC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB;IAIzD,iBAAiB,CAAC,aAAa,EAAE,eAAe;IAOhD,cAAc,CAAC,UAAU,EAAE,MAAM;IAOjC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGJ"}
|
package/dist/tests/accounts.mjs
CHANGED
|
@@ -10,9 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _MockAccountBuilder_account;
|
|
13
|
-
import { isBip44Account } from "@metamask/account-api";
|
|
14
13
|
import { EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
|
|
15
14
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
15
|
+
import { isBip44Account } from "../providers/BaseAccountProvider.mjs";
|
|
16
16
|
const ETH_EOA_METHODS = [
|
|
17
17
|
EthMethod.PersonalSign,
|
|
18
18
|
EthMethod.Sign,
|
|
@@ -155,10 +155,6 @@ export class MockAccountBuilder {
|
|
|
155
155
|
static from(account) {
|
|
156
156
|
return new MockAccountBuilder(account);
|
|
157
157
|
}
|
|
158
|
-
withId(id) {
|
|
159
|
-
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").id = id;
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
158
|
withEntropySource(entropySource) {
|
|
163
159
|
if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
|
|
164
160
|
__classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,E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C;QACb,YAAY,EAAE,CAAC;KAChB;CACF,CAAC;AAEF,MAAM,OAAO,kBAAkB;IAG7B,YAAY,OAAwB;QAF3B,8CAA0B;QAGjC,mDAAmD;QACnD,uBAAA,IAAI,+BAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAA,CAAC;IACtD,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAwB;QAClC,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,iBAAiB,CAAC,aAA8B;QAC9C,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,aAAa,CAAC;SAClD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAC,UAAkB;QAC/B,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { isBip44Account } from '../providers/BaseAccountProvider';\n\nconst 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_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: 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: 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_SNAP_ACCOUNT_1: 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],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\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_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 {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\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: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\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"]}
|
package/dist/tests/messenger.cjs
CHANGED
|
@@ -20,11 +20,7 @@ exports.getRootMessenger = getRootMessenger;
|
|
|
20
20
|
function getMultichainAccountServiceMessenger(messenger) {
|
|
21
21
|
return messenger.getRestricted({
|
|
22
22
|
name: 'MultichainAccountService',
|
|
23
|
-
allowedEvents: [
|
|
24
|
-
'KeyringController:stateChange',
|
|
25
|
-
'AccountsController:accountAdded',
|
|
26
|
-
'AccountsController:accountRemoved',
|
|
27
|
-
],
|
|
23
|
+
allowedEvents: ['KeyringController:stateChange'],
|
|
28
24
|
allowedActions: [
|
|
29
25
|
'AccountsController:getAccount',
|
|
30
26
|
'AccountsController:getAccountByAddress',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.cjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAUtD;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,2BAAS,EAGjB,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE
|
|
1
|
+
{"version":3,"file":"messenger.cjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAUtD;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,2BAAS,EAGjB,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC;AAfD,oFAeC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Messenger } from "@metamask/base-controller";
|
|
2
|
-
import type { AllowedActions,
|
|
2
|
+
import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new root messenger instance for testing.
|
|
5
5
|
*
|
|
6
6
|
* @returns A new Messenger instance.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getRootMessenger(): Messenger<
|
|
8
|
+
export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves a restricted messenger for the MultichainAccountService.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,
|
|
1
|
+
{"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Messenger } from "@metamask/base-controller";
|
|
2
|
-
import type { AllowedActions,
|
|
2
|
+
import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new root messenger instance for testing.
|
|
5
5
|
*
|
|
6
6
|
* @returns A new Messenger instance.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getRootMessenger(): Messenger<
|
|
8
|
+
export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves a restricted messenger for the MultichainAccountService.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,
|
|
1
|
+
{"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
|
package/dist/tests/messenger.mjs
CHANGED
|
@@ -16,11 +16,7 @@ export function getRootMessenger() {
|
|
|
16
16
|
export function getMultichainAccountServiceMessenger(messenger) {
|
|
17
17
|
return messenger.getRestricted({
|
|
18
18
|
name: 'MultichainAccountService',
|
|
19
|
-
allowedEvents: [
|
|
20
|
-
'KeyringController:stateChange',
|
|
21
|
-
'AccountsController:accountAdded',
|
|
22
|
-
'AccountsController:accountRemoved',
|
|
23
|
-
],
|
|
19
|
+
allowedEvents: ['KeyringController:stateChange'],
|
|
24
20
|
allowedActions: [
|
|
25
21
|
'AccountsController:getAccount',
|
|
26
22
|
'AccountsController:getAccountByAddress',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,EAGjB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE
|
|
1
|
+
{"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,EAGjB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents = KeyringControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
4
4
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
5
|
-
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.cjs";
|
|
6
|
-
export type MultichainAccountServiceGetMultichainAccountAction = {
|
|
7
|
-
type: `${typeof serviceName}:getMultichainAccount`;
|
|
8
|
-
handler: MultichainAccountService['getMultichainAccount'];
|
|
9
|
-
};
|
|
10
|
-
export type MultichainAccountServiceGetMultichainAccountsAction = {
|
|
11
|
-
type: `${typeof serviceName}:getMultichainAccounts`;
|
|
12
|
-
handler: MultichainAccountService['getMultichainAccounts'];
|
|
13
|
-
};
|
|
14
|
-
export type MultichainAccountServiceGetMultichainAccountWalletAction = {
|
|
15
|
-
type: `${typeof serviceName}:getMultichainAccountWallet`;
|
|
16
|
-
handler: MultichainAccountService['getMultichainAccountWallet'];
|
|
17
|
-
};
|
|
18
|
-
export type MultichainAccountServiceGetMultichainAccountWalletsAction = {
|
|
19
|
-
type: `${typeof serviceName}:getMultichainAccountWallets`;
|
|
20
|
-
handler: MultichainAccountService['getMultichainAccountWallets'];
|
|
21
|
-
};
|
|
22
5
|
/**
|
|
23
6
|
* All actions that {@link MultichainAccountService} registers so that other
|
|
24
7
|
* modules can call them.
|
|
25
8
|
*/
|
|
26
|
-
export type MultichainAccountServiceActions =
|
|
9
|
+
export type MultichainAccountServiceActions = never;
|
|
27
10
|
/**
|
|
28
11
|
* All events that {@link MultichainAccountService} publishes so that other modules
|
|
29
12
|
* can subscribe to them.
|
|
@@ -38,7 +21,7 @@ export type AllowedActions = AccountsControllerListMultichainAccountsAction | Ac
|
|
|
38
21
|
* All events published by other modules that {@link MultichainAccountService}
|
|
39
22
|
* subscribes to.
|
|
40
23
|
*/
|
|
41
|
-
export type AllowedEvents = KeyringControllerStateChangeEvent
|
|
24
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent;
|
|
42
25
|
/**
|
|
43
26
|
* The messenger restricted to actions and events that
|
|
44
27
|
* {@link MultichainAccountService} needs to access.
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { RestrictedMessenger } from "@metamask/base-controller";
|
|
3
3
|
import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
|
|
4
4
|
import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
|
|
5
|
-
import type { MultichainAccountService, serviceName } from "./MultichainAccountService.mjs";
|
|
6
|
-
export type MultichainAccountServiceGetMultichainAccountAction = {
|
|
7
|
-
type: `${typeof serviceName}:getMultichainAccount`;
|
|
8
|
-
handler: MultichainAccountService['getMultichainAccount'];
|
|
9
|
-
};
|
|
10
|
-
export type MultichainAccountServiceGetMultichainAccountsAction = {
|
|
11
|
-
type: `${typeof serviceName}:getMultichainAccounts`;
|
|
12
|
-
handler: MultichainAccountService['getMultichainAccounts'];
|
|
13
|
-
};
|
|
14
|
-
export type MultichainAccountServiceGetMultichainAccountWalletAction = {
|
|
15
|
-
type: `${typeof serviceName}:getMultichainAccountWallet`;
|
|
16
|
-
handler: MultichainAccountService['getMultichainAccountWallet'];
|
|
17
|
-
};
|
|
18
|
-
export type MultichainAccountServiceGetMultichainAccountWalletsAction = {
|
|
19
|
-
type: `${typeof serviceName}:getMultichainAccountWallets`;
|
|
20
|
-
handler: MultichainAccountService['getMultichainAccountWallets'];
|
|
21
|
-
};
|
|
22
5
|
/**
|
|
23
6
|
* All actions that {@link MultichainAccountService} registers so that other
|
|
24
7
|
* modules can call them.
|
|
25
8
|
*/
|
|
26
|
-
export type MultichainAccountServiceActions =
|
|
9
|
+
export type MultichainAccountServiceActions = never;
|
|
27
10
|
/**
|
|
28
11
|
* All events that {@link MultichainAccountService} publishes so that other modules
|
|
29
12
|
* can subscribe to them.
|
|
@@ -38,7 +21,7 @@ export type AllowedActions = AccountsControllerListMultichainAccountsAction | Ac
|
|
|
38
21
|
* All events published by other modules that {@link MultichainAccountService}
|
|
39
22
|
* subscribes to.
|
|
40
23
|
*/
|
|
41
|
-
export type AllowedEvents = KeyringControllerStateChangeEvent
|
|
24
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent;
|
|
42
25
|
/**
|
|
43
26
|
* The messenger restricted to actions and events that
|
|
44
27
|
* {@link MultichainAccountService} needs to access.
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents = KeyringControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/multichain-account-service",
|
|
3
|
-
"version": "0.2.1-preview-
|
|
3
|
+
"version": "0.2.1-preview-bd86fa14",
|
|
4
4
|
"description": "Service to manage multichain accounts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@metamask/account-api": "^0.2.0",
|
|
50
51
|
"@metamask/base-controller": "^8.0.1",
|
|
51
52
|
"@metamask/keyring-api": "^19.0.0",
|
|
52
53
|
"@metamask/keyring-internal-api": "^7.0.0",
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
"@metamask/superstruct": "^3.1.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@metamask/account-api": "^0.3.0",
|
|
60
60
|
"@metamask/accounts-controller": "^32.0.0",
|
|
61
61
|
"@metamask/auto-changelog": "^3.4.4",
|
|
62
62
|
"@metamask/eth-snap-keyring": "^14.0.0",
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"webextension-polyfill": "^0.12.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@metamask/account-api": "^0.3.0",
|
|
77
76
|
"@metamask/accounts-controller": "^32.0.0",
|
|
78
77
|
"@metamask/keyring-controller": "^22.0.0",
|
|
79
78
|
"@metamask/providers": "^22.0.0",
|