@metamask-previews/account-tree-controller 0.4.0-preview-2fc30c00 → 0.4.0-preview-ea7474e2
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/dist/AccountTreeGroup.cjs +1 -1
- package/dist/AccountTreeGroup.cjs.map +1 -1
- package/dist/AccountTreeGroup.d.cts +2 -2
- package/dist/AccountTreeGroup.d.cts.map +1 -1
- package/dist/AccountTreeGroup.d.mts +2 -2
- package/dist/AccountTreeGroup.d.mts.map +1 -1
- package/dist/AccountTreeGroup.mjs +1 -1
- package/dist/AccountTreeGroup.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ class MutableAccountTreeGroup {
|
|
|
25
25
|
this.messenger = messenger;
|
|
26
26
|
__classPrivateFieldSet(this, _MutableAccountTreeGroup_accounts, new Set(), "f");
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
getAccountIds() {
|
|
29
29
|
return Array.from(__classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")); // FIXME: Should we force the copy here?
|
|
30
30
|
}
|
|
31
31
|
getAccounts() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountTreeGroup.cjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAK+B;AAKlB,QAAA,0BAA0B,GAAW,SAAS,CAAC;AAiB5D,0FAA0F;AAC1F,iDAAiD;AACjD,MAAa,uBAAuB;IASlC,YACE,SAAyC,EACzC,MAAsC,EACtC,EAAU;QALH,oDAA0B;QAOjC,IAAI,CAAC,EAAE,GAAG,IAAA,8BAAgB,EAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,uBAAA,IAAI,qCAAa,IAAI,GAAG,EAAE,MAAA,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,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,kCAA0B,CAAC;IACpC,CAAC;CACF;AAtDD,0DAsDC","sourcesContent":["import {\n toAccountGroupId,\n type AccountGroup,\n type AccountGroupId,\n type AccountWallet,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { AccountTreeControllerMessenger } from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport type AccountTreeGroup = {\n /**\n * Account IDs for that account group.\n */\n getAccountIds(): AccountId[];\n\n /**\n * Gets the default name for that account group.\n */\n getDefaultName(): string;\n} & AccountGroup<InternalAccount>;\n\n// This class is meant to be used internally by every rules. It exposes mutable operations\n// which should not leak outside of this package.\nexport class MutableAccountTreeGroup implements AccountTreeGroup {\n readonly id: AccountGroupId;\n\n readonly wallet: AccountWallet<InternalAccount>;\n\n readonly messenger: AccountTreeControllerMessenger;\n\n readonly #accounts: Set<AccountId>;\n\n constructor(\n messenger: AccountTreeControllerMessenger,\n wallet: AccountWallet<InternalAccount>,\n id: string,\n ) {\n this.id = toAccountGroupId(wallet.id, id);\n this.wallet = wallet;\n this.messenger = messenger;\n\n this.#accounts = new Set();\n }\n\n getAccountIds(): AccountId[] {\n return Array.from(this.#accounts); // FIXME: Should we force the copy here?\n }\n\n getAccounts(): InternalAccount[] {\n const accounts = [];\n\n for (const id of this.#accounts) {\n const account = this.getAccount(id);\n\n // FIXME: I'm really not sure we should skip those but... We could be\n // \"de-sync\" with the AccountsController and might have some dangling\n // account IDs.\n if (!account) {\n console.warn(`! Unable to get account: \"${id}\"`);\n continue;\n }\n accounts.push(account);\n }\n return accounts;\n }\n\n getAccount(id: AccountId): InternalAccount | undefined {\n return this.messenger.call('AccountsController:getAccount', id);\n }\n\n addAccount(account: InternalAccount) {\n this.#accounts.add(account.id);\n }\n\n getDefaultName(): string {\n return DEFAULT_ACCOUNT_GROUP_NAME;\n }\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export type AccountTreeGroup = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Account IDs for that account group.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
getAccountIds(): AccountId[];
|
|
14
14
|
/**
|
|
15
15
|
* Gets the default name for that account group.
|
|
16
16
|
*/
|
|
@@ -22,7 +22,7 @@ export declare class MutableAccountTreeGroup implements AccountTreeGroup {
|
|
|
22
22
|
readonly wallet: AccountWallet<InternalAccount>;
|
|
23
23
|
readonly messenger: AccountTreeControllerMessenger;
|
|
24
24
|
constructor(messenger: AccountTreeControllerMessenger, wallet: AccountWallet<InternalAccount>, id: string);
|
|
25
|
-
|
|
25
|
+
getAccountIds(): AccountId[];
|
|
26
26
|
getAccounts(): InternalAccount[];
|
|
27
27
|
getAccount(id: AccountId): InternalAccount | undefined;
|
|
28
28
|
addAccount(account: InternalAccount): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountTreeGroup.d.cts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"AccountTreeGroup.d.cts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,aAAa,IAAI,SAAS,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAIlC,qBAAa,uBAAwB,YAAW,gBAAgB;;IAC9D,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAEhD,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;gBAKjD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,EACtC,EAAE,EAAE,MAAM;IASZ,aAAa,IAAI,SAAS,EAAE;IAI5B,WAAW,IAAI,eAAe,EAAE;IAkBhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS;IAItD,UAAU,CAAC,OAAO,EAAE,eAAe;IAInC,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -10,7 +10,7 @@ export type AccountTreeGroup = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Account IDs for that account group.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
getAccountIds(): AccountId[];
|
|
14
14
|
/**
|
|
15
15
|
* Gets the default name for that account group.
|
|
16
16
|
*/
|
|
@@ -22,7 +22,7 @@ export declare class MutableAccountTreeGroup implements AccountTreeGroup {
|
|
|
22
22
|
readonly wallet: AccountWallet<InternalAccount>;
|
|
23
23
|
readonly messenger: AccountTreeControllerMessenger;
|
|
24
24
|
constructor(messenger: AccountTreeControllerMessenger, wallet: AccountWallet<InternalAccount>, id: string);
|
|
25
|
-
|
|
25
|
+
getAccountIds(): AccountId[];
|
|
26
26
|
getAccounts(): InternalAccount[];
|
|
27
27
|
getAccount(id: AccountId): InternalAccount | undefined;
|
|
28
28
|
addAccount(account: InternalAccount): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountTreeGroup.d.mts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"AccountTreeGroup.d.mts","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AACzD,OAAO,KAAK,EAAE,8BAA8B,EAAE,YAAY;AAE1D,eAAO,MAAM,0BAA0B,EAAE,MAAkB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,aAAa,IAAI,SAAS,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAIlC,qBAAa,uBAAwB,YAAW,gBAAgB;;IAC9D,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAE5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAEhD,QAAQ,CAAC,SAAS,EAAE,8BAA8B,CAAC;gBAKjD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,EACtC,EAAE,EAAE,MAAM;IASZ,aAAa,IAAI,SAAS,EAAE;IAI5B,WAAW,IAAI,eAAe,EAAE;IAkBhC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS;IAItD,UAAU,CAAC,OAAO,EAAE,eAAe;IAInC,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -22,7 +22,7 @@ export class MutableAccountTreeGroup {
|
|
|
22
22
|
this.messenger = messenger;
|
|
23
23
|
__classPrivateFieldSet(this, _MutableAccountTreeGroup_accounts, new Set(), "f");
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
getAccountIds() {
|
|
26
26
|
return Array.from(__classPrivateFieldGet(this, _MutableAccountTreeGroup_accounts, "f")); // FIXME: Should we force the copy here?
|
|
27
27
|
}
|
|
28
28
|
getAccounts() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountTreeGroup.mjs","sourceRoot":"","sources":["../src/AccountTreeGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAIjB,8BAA8B;AAK/B,MAAM,CAAC,MAAM,0BAA0B,GAAW,SAAS,CAAC;AAiB5D,0FAA0F;AAC1F,iDAAiD;AACjD,MAAM,OAAO,uBAAuB;IASlC,YACE,SAAyC,EACzC,MAAsC,EACtC,EAAU;QALH,oDAA0B;QAOjC,IAAI,CAAC,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,uBA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E,CAAC,CAAC;IAClE,CAAC;IAED,UAAU,CAAC,OAAwB;QACjC,uBAAA,IAAI,yCAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF","sourcesContent":["import {\n toAccountGroupId,\n type AccountGroup,\n type AccountGroupId,\n type AccountWallet,\n} from '@metamask/account-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { AccountTreeControllerMessenger } from 'src';\n\nexport const DEFAULT_ACCOUNT_GROUP_NAME: string = 'Default';\n\n/**\n * Account group coming from the {@link AccountTreeController}.\n */\nexport type AccountTreeGroup = {\n /**\n * Account IDs for that account group.\n */\n getAccountIds(): AccountId[];\n\n /**\n * Gets the default name for that account group.\n */\n getDefaultName(): string;\n} & AccountGroup<InternalAccount>;\n\n// This class is meant to be used internally by every rules. It exposes mutable operations\n// which should not leak outside of this package.\nexport class MutableAccountTreeGroup implements AccountTreeGroup {\n readonly id: AccountGroupId;\n\n readonly wallet: AccountWallet<InternalAccount>;\n\n readonly messenger: AccountTreeControllerMessenger;\n\n readonly #accounts: Set<AccountId>;\n\n constructor(\n messenger: AccountTreeControllerMessenger,\n wallet: AccountWallet<InternalAccount>,\n id: string,\n ) {\n this.id = toAccountGroupId(wallet.id, id);\n this.wallet = wallet;\n this.messenger = messenger;\n\n this.#accounts = new Set();\n }\n\n getAccountIds(): AccountId[] {\n return Array.from(this.#accounts); // FIXME: Should we force the copy here?\n }\n\n getAccounts(): InternalAccount[] {\n const accounts = [];\n\n for (const id of this.#accounts) {\n const account = this.getAccount(id);\n\n // FIXME: I'm really not sure we should skip those but... We could be\n // \"de-sync\" with the AccountsController and might have some dangling\n // account IDs.\n if (!account) {\n console.warn(`! Unable to get account: \"${id}\"`);\n continue;\n }\n accounts.push(account);\n }\n return accounts;\n }\n\n getAccount(id: AccountId): InternalAccount | undefined {\n return this.messenger.call('AccountsController:getAccount', id);\n }\n\n addAccount(account: InternalAccount) {\n this.#accounts.add(account.id);\n }\n\n getDefaultName(): string {\n return DEFAULT_ACCOUNT_GROUP_NAME;\n }\n}\n"]}
|
package/package.json
CHANGED