@metamask-previews/account-tree-controller 0.7.0-preview-4375dc2 → 0.7.0-preview-bfa447b
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 +10 -3
- package/dist/AccountTreeController.cjs +100 -8
- package/dist/AccountTreeController.cjs.map +1 -1
- package/dist/AccountTreeController.d.cts +72 -4
- package/dist/AccountTreeController.d.cts.map +1 -1
- package/dist/AccountTreeController.d.mts +72 -4
- package/dist/AccountTreeController.d.mts.map +1 -1
- package/dist/AccountTreeController.mjs +101 -9
- package/dist/AccountTreeController.mjs.map +1 -1
- package/dist/group.cjs +0 -72
- package/dist/group.cjs.map +1 -1
- package/dist/group.d.cts +1 -26
- package/dist/group.d.cts.map +1 -1
- package/dist/group.d.mts +1 -26
- package/dist/group.d.mts.map +1 -1
- package/dist/group.mjs +1 -70
- package/dist/group.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/rules/entropy.cjs +4 -3
- package/dist/rules/entropy.cjs.map +1 -1
- package/dist/rules/entropy.d.cts.map +1 -1
- package/dist/rules/entropy.d.mts.map +1 -1
- package/dist/rules/entropy.mjs +4 -3
- package/dist/rules/entropy.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +7 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +7 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/wallet.cjs +0 -74
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +1 -41
- package/dist/wallet.d.cts.map +1 -1
- package/dist/wallet.d.mts +1 -41
- package/dist/wallet.d.mts.map +1 -1
- package/dist/wallet.mjs +1 -72
- package/dist/wallet.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet.d.mts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { AccountWalletType, AccountWalletId, MultichainAccountWalletId } from "@metamask/account-api";
|
|
2
|
-
import { type AccountGroupId
|
|
2
|
+
import { type AccountGroupId } from "@metamask/account-api";
|
|
3
3
|
import type { EntropySourceId } from "@metamask/keyring-api";
|
|
4
4
|
import type { KeyringTypes } from "@metamask/keyring-controller";
|
|
5
|
-
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
6
5
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
7
6
|
import type { AccountGroupMultichainAccountObject, AccountGroupObject, AccountGroupSingleAccountObject } from "./group.mjs";
|
|
8
|
-
import { AccountTreeGroup } from "./group.mjs";
|
|
9
7
|
import type { UpdatableField, ExtractFieldValues } from "./type-utils.mjs";
|
|
10
|
-
import { type AccountTreeControllerMessenger } from "./types.mjs";
|
|
11
8
|
/**
|
|
12
9
|
* Persisted metadata for account wallets (stored in controller state for persistence/sync).
|
|
13
10
|
*/
|
|
@@ -44,7 +41,6 @@ export type AccountWalletEntropyObject = {
|
|
|
44
41
|
metadata: AccountTreeWalletMetadata & {
|
|
45
42
|
entropy: {
|
|
46
43
|
id: EntropySourceId;
|
|
47
|
-
index: number;
|
|
48
44
|
};
|
|
49
45
|
};
|
|
50
46
|
};
|
|
@@ -94,41 +90,5 @@ export type AccountWalletObjectOf<WalletType extends AccountWalletType> = Extrac
|
|
|
94
90
|
}, {
|
|
95
91
|
type: WalletType;
|
|
96
92
|
}>['object'];
|
|
97
|
-
/**
|
|
98
|
-
* Account wallet coming from the {@link AccountTreeController}.
|
|
99
|
-
*/
|
|
100
|
-
export declare class AccountTreeWallet implements AccountWallet<InternalAccount> {
|
|
101
|
-
#private;
|
|
102
|
-
protected messenger: AccountTreeControllerMessenger;
|
|
103
|
-
protected groups: Map<AccountGroupId, AccountTreeGroup>;
|
|
104
|
-
constructor({ messenger, wallet, }: {
|
|
105
|
-
messenger: AccountTreeControllerMessenger;
|
|
106
|
-
wallet: AccountWalletObject;
|
|
107
|
-
});
|
|
108
|
-
get id(): AccountWalletId;
|
|
109
|
-
get type(): AccountWalletType;
|
|
110
|
-
get name(): string;
|
|
111
|
-
/**
|
|
112
|
-
* Gets account tree group for a given ID.
|
|
113
|
-
*
|
|
114
|
-
* @param groupId - Group ID.
|
|
115
|
-
* @returns Account tree group, or undefined if not found.
|
|
116
|
-
*/
|
|
117
|
-
getAccountGroup(groupId: AccountGroupId): AccountTreeGroup | undefined;
|
|
118
|
-
/**
|
|
119
|
-
* Gets account tree group for a given ID.
|
|
120
|
-
*
|
|
121
|
-
* @param groupId - Group ID.
|
|
122
|
-
* @throws If the account group is not found.
|
|
123
|
-
* @returns Account tree group.
|
|
124
|
-
*/
|
|
125
|
-
getAccountGroupOrThrow(groupId: AccountGroupId): AccountTreeGroup;
|
|
126
|
-
/**
|
|
127
|
-
* Gets all account tree groups.
|
|
128
|
-
*
|
|
129
|
-
* @returns Account tree groups.
|
|
130
|
-
*/
|
|
131
|
-
getAccountGroups(): AccountTreeGroup[];
|
|
132
|
-
}
|
|
133
93
|
export {};
|
|
134
94
|
//# sourceMappingURL=wallet.d.mts.map
|
package/dist/wallet.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EAC1B,8BAA8B;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EAC1B,8BAA8B;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAE,8BAA8B;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK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G;QACpC,IAAI,EAAE;YACJ,EAAE,EAAE,MAAM,CAAC;SACZ,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAChC,EAAE,EAAE,eAAe,CAAC;IACpB,MAAM,EAAE;QACN,CAAC,OAAO,EAAE,cAAc,GAAG,+BAA+B,CAAC;KAC5D,CAAC;IACF,QAAQ,EAAE,yBAAyB,GAAG;QACpC,OAAO,EAAE;YACP,IAAI,EAAE,YAAY,CAAC;SACpB,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CACnD,0BAA0B,GAC1B,uBAAuB,GACvB,0BAA0B,CAC7B,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,UAAU,SAAS,iBAAiB,IACpE,OAAO,CACH;IAAE,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAAC,MAAM,EAAE,0BAA0B,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAAC,MAAM,EAAE,0BAA0B,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,EACnE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CACrB,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/wallet.mjs
CHANGED
|
@@ -1,73 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
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");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _AccountTreeWallet_wallet;
|
|
13
|
-
import { AccountTreeGroup } from "./group.mjs";
|
|
14
|
-
/**
|
|
15
|
-
* Account wallet coming from the {@link AccountTreeController}.
|
|
16
|
-
*/
|
|
17
|
-
export class AccountTreeWallet {
|
|
18
|
-
constructor({ messenger, wallet, }) {
|
|
19
|
-
_AccountTreeWallet_wallet.set(this, void 0);
|
|
20
|
-
this.messenger = messenger;
|
|
21
|
-
__classPrivateFieldSet(this, _AccountTreeWallet_wallet, wallet, "f");
|
|
22
|
-
this.groups = new Map();
|
|
23
|
-
for (const [groupId, group] of Object.entries(__classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").groups)) {
|
|
24
|
-
this.groups.set(groupId, new AccountTreeGroup({
|
|
25
|
-
messenger: this.messenger,
|
|
26
|
-
wallet: this,
|
|
27
|
-
group,
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
get id() {
|
|
32
|
-
return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").id;
|
|
33
|
-
}
|
|
34
|
-
get type() {
|
|
35
|
-
return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").type;
|
|
36
|
-
}
|
|
37
|
-
get name() {
|
|
38
|
-
return __classPrivateFieldGet(this, _AccountTreeWallet_wallet, "f").metadata.name;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Gets account tree group for a given ID.
|
|
42
|
-
*
|
|
43
|
-
* @param groupId - Group ID.
|
|
44
|
-
* @returns Account tree group, or undefined if not found.
|
|
45
|
-
*/
|
|
46
|
-
getAccountGroup(groupId) {
|
|
47
|
-
return this.groups.get(groupId);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets account tree group for a given ID.
|
|
51
|
-
*
|
|
52
|
-
* @param groupId - Group ID.
|
|
53
|
-
* @throws If the account group is not found.
|
|
54
|
-
* @returns Account tree group.
|
|
55
|
-
*/
|
|
56
|
-
getAccountGroupOrThrow(groupId) {
|
|
57
|
-
const group = this.getAccountGroup(groupId);
|
|
58
|
-
if (!group) {
|
|
59
|
-
throw new Error('Unable to get account group');
|
|
60
|
-
}
|
|
61
|
-
return group;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Gets all account tree groups.
|
|
65
|
-
*
|
|
66
|
-
* @returns Account tree groups.
|
|
67
|
-
*/
|
|
68
|
-
getAccountGroups() {
|
|
69
|
-
return Array.from(this.groups.values());
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
_AccountTreeWallet_wallet = new WeakMap();
|
|
1
|
+
export {};
|
|
73
2
|
//# sourceMappingURL=wallet.mjs.map
|
package/dist/wallet.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountWalletType,\n AccountWalletId,\n MultichainAccountWalletId,\n} from '@metamask/account-api';\nimport { type AccountGroupId } from '@metamask/account-api';\nimport type { EntropySourceId } from '@metamask/keyring-api';\nimport type { KeyringTypes } from '@metamask/keyring-controller';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\nimport type {\n AccountGroupMultichainAccountObject,\n AccountGroupObject,\n AccountGroupSingleAccountObject,\n} from './group';\nimport type { UpdatableField, ExtractFieldValues } from './type-utils.js';\n\n/**\n * Persisted metadata for account wallets (stored in controller state for persistence/sync).\n */\nexport type AccountTreeWalletPersistedMetadata = {\n /** Custom name set by user, overrides default naming logic */\n name?: UpdatableField<string>;\n};\n\n/**\n * Tree metadata for account wallets (required plain values extracted from persisted metadata).\n */\nexport type AccountTreeWalletMetadata = Required<\n ExtractFieldValues<AccountTreeWalletPersistedMetadata>\n>;\n\n/**\n * Type constraint for a {@link AccountGroupObject}. If one of its union-members\n * does not match this contraint, {@link AccountGroupObject} will resolve\n * to `never`.\n */\ntype IsAccountWalletObject<\n Type extends {\n type: AccountWalletType;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupObject;\n };\n metadata: AccountTreeWalletMetadata;\n },\n> = Type;\n\n/**\n * Account wallet object for the \"entropy\" wallet category.\n */\nexport type AccountWalletEntropyObject = {\n type: AccountWalletType.Entropy;\n id: MultichainAccountWalletId;\n groups: {\n // NOTE: Using `MultichainAccountGroupId` instead of `AccountGroupId` would introduce\n // some type problems when using a group ID as an `AccountGroupId` directly. This\n // would require some up-cast to a `MultichainAccountGroupId` which could be considered\n // unsafe... So we keep it as a `AccountGroupId` for now.\n [groupId: AccountGroupId]: AccountGroupMultichainAccountObject;\n };\n metadata: AccountTreeWalletMetadata & {\n entropy: {\n id: EntropySourceId;\n };\n };\n};\n\n/**\n * Account wallet object for the \"snap\" wallet category.\n */\nexport type AccountWalletSnapObject = {\n type: AccountWalletType.Snap;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: AccountTreeWalletMetadata & {\n snap: {\n id: SnapId;\n };\n };\n};\n\n/**\n * Account wallet object for the \"keyring\" wallet category.\n */\nexport type AccountWalletKeyringObject = {\n type: AccountWalletType.Keyring;\n id: AccountWalletId;\n groups: {\n [groupId: AccountGroupId]: AccountGroupSingleAccountObject;\n };\n metadata: AccountTreeWalletMetadata & {\n keyring: {\n type: KeyringTypes;\n };\n };\n};\n\n/**\n * Account wallet metadata for the \"keyring\" wallet category.\n */\nexport type AccountWalletObject = IsAccountWalletObject<\n | AccountWalletEntropyObject\n | AccountWalletSnapObject\n | AccountWalletKeyringObject\n>;\n\nexport type AccountWalletObjectOf<WalletType extends AccountWalletType> =\n Extract<\n | { type: AccountWalletType.Entropy; object: AccountWalletEntropyObject }\n | { type: AccountWalletType.Keyring; object: AccountWalletKeyringObject }\n | { type: AccountWalletType.Snap; object: AccountWalletSnapObject },\n { type: WalletType }\n >['object'];\n"]}
|
package/package.json
CHANGED