@metamask/assets-controllers 8.0.0 → 9.1.0

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 CHANGED
@@ -6,6 +6,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [9.1.0]
10
+ ### Added
11
+ - Add a fifth argument, `source`, to NftController's `addNft` method ([#1417](https://github.com/MetaMask/core/pull/1417))
12
+ - This argument can be used to specify whether the NFT was detected, added manually, or suggested by a dapp
13
+
14
+ ### Fixed
15
+ - Fix `watchNft` in NftController to ensure that if the network changes before the user accepts the request, the NFT is added to the chain ID and address before the request was initiated ([#1417](https://github.com/MetaMask/core/pull/1417))
16
+
17
+ ## [9.0.0]
18
+ ### Added
19
+ - **BREAKING**: Add required options `getSelectedAddress` and `getMultiAccountBalancesEnabled` to AccountTrackerController constructor and make use of them when refreshing account balances ([#1146](https://github.com/MetaMask/core/pull/1146))
20
+ - Previously, the controller would refresh all account balances, but these options can be used to only refresh the currently selected account
21
+ - **BREAKING:** Add logic to support validating and adding ERC721 and ERC1155 tokens to NFTController state via `wallet_watchAsset` API. ([#1173](https://github.com/MetaMask/core/pull/1173), [#1406](https://github.com/MetaMask/core/pull/1406))
22
+ - The `NFTController` now has a new `watchNFT` method that can be called to send a message to the `ApprovalController` and prompt the user to add an NFT to their wallet state.
23
+ - The `NFTController` now requires an instance of a ControllerMessenger to be passed to its constructor. This is messenger is used to pass the `watchNFT` message to the `ApprovalController`.
24
+
25
+ ### Changed
26
+ - Add dependency on `@ethersproject/address` ([#1173](https://github.com/MetaMask/core.git/pull/1173))
27
+ - Replace `eth-rpc-errors` with `@metamask/rpc-errors` ([#1173](https://github.com/MetaMask/core.git/pull/1173))
28
+
9
29
  ## [8.0.0]
10
30
  ### Added
11
31
  - Support NFT detection on Ethereum Mainnet custom RPC endpoints ([#1360](https://github.com/MetaMask/core/pull/1360))
@@ -148,7 +168,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
148
168
  ### Changed
149
169
  - Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))
150
170
 
151
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@8.0.0...HEAD
171
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@9.1.0...HEAD
172
+ [9.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@9.0.0...@metamask/assets-controllers@9.1.0
173
+ [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@8.0.0...@metamask/assets-controllers@9.0.0
152
174
  [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@7.0.0...@metamask/assets-controllers@8.0.0
153
175
  [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@6.0.0...@metamask/assets-controllers@7.0.0
154
176
  [6.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@5.1.0...@metamask/assets-controllers@6.0.0
@@ -44,18 +44,24 @@ export declare class AccountTrackerController extends BaseController<AccountTrac
44
44
  */
45
45
  name: string;
46
46
  private getIdentities;
47
+ private getSelectedAddress;
48
+ private getMultiAccountBalancesEnabled;
47
49
  /**
48
50
  * Creates an AccountTracker instance.
49
51
  *
50
52
  * @param options - The controller options.
51
53
  * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.
52
54
  * @param options.getIdentities - Gets the identities from the Preferences store.
55
+ * @param options.getSelectedAddress - Gets the selected address from the Preferences store.
56
+ * @param options.getMultiAccountBalancesEnabled - Gets the multi account balances enabled flag from the Preferences store.
53
57
  * @param config - Initial options used to configure this controller.
54
58
  * @param state - Initial state to set on this controller.
55
59
  */
56
- constructor({ onPreferencesStateChange, getIdentities, }: {
60
+ constructor({ onPreferencesStateChange, getIdentities, getSelectedAddress, getMultiAccountBalancesEnabled, }: {
57
61
  onPreferencesStateChange: (listener: (preferencesState: PreferencesState) => void) => void;
58
62
  getIdentities: () => PreferencesState['identities'];
63
+ getSelectedAddress: () => PreferencesState['selectedAddress'];
64
+ getMultiAccountBalancesEnabled: () => PreferencesState['isMultiAccountBalancesEnabled'];
59
65
  }, config?: Partial<AccountTrackerConfig>, state?: Partial<AccountTrackerState>);
60
66
  /**
61
67
  * Sets a new provider.
@@ -73,9 +79,18 @@ export declare class AccountTrackerController extends BaseController<AccountTrac
73
79
  */
74
80
  poll(interval?: number): Promise<void>;
75
81
  /**
76
- * Refreshes all accounts in the current keychain.
82
+ * Refreshes the balances of the accounts depending on the multi-account setting.
83
+ * If multi-account is disabled, only updates the selected account balance.
84
+ * If multi-account is enabled, updates balances for all accounts.
77
85
  */
78
86
  refresh: () => Promise<void>;
87
+ /**
88
+ * Fetches the balance of a given address from the blockchain.
89
+ *
90
+ * @param address - The account address to fetch the balance for.
91
+ * @returns A promise that resolves to the balance in a hex string format.
92
+ */
93
+ private getBalanceFromChain;
79
94
  /**
80
95
  * Sync accounts balances with some additional addresses.
81
96
  *
@@ -1 +1 @@
1
- {"version":3,"file":"AccountTrackerController.d.ts","sourceRoot":"","sources":["../src/AccountTrackerController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAOpE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,QAAQ,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAA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,OAAO,CAAC,mBAAmB,CAAC;IAiBtC;;;;;;OAMG;IACH,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAE9B;IAED,IAAI,QAAQ,IAJW,QAAQ,CAM9B;IAED;;;;OAIG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5C;;;;OAIG;IACH,OAAO,sBAgBL;IAEF;;;;;OAKG;YACW,mBAAmB;IASjC;;;;;OAKG;IACG,wBAAwB,CAC5B,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAyBhD;AAED,eAAe,wBAAwB,CAAC"}
@@ -28,10 +28,12 @@ class AccountTrackerController extends base_controller_1.BaseController {
28
28
  * @param options - The controller options.
29
29
  * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.
30
30
  * @param options.getIdentities - Gets the identities from the Preferences store.
31
+ * @param options.getSelectedAddress - Gets the selected address from the Preferences store.
32
+ * @param options.getMultiAccountBalancesEnabled - Gets the multi account balances enabled flag from the Preferences store.
31
33
  * @param config - Initial options used to configure this controller.
32
34
  * @param state - Initial state to set on this controller.
33
35
  */
34
- constructor({ onPreferencesStateChange, getIdentities, }, config, state) {
36
+ constructor({ onPreferencesStateChange, getIdentities, getSelectedAddress, getMultiAccountBalancesEnabled, }, config, state) {
35
37
  super(config, state);
36
38
  this.mutex = new async_mutex_1.Mutex();
37
39
  /**
@@ -39,17 +41,21 @@ class AccountTrackerController extends base_controller_1.BaseController {
39
41
  */
40
42
  this.name = 'AccountTrackerController';
41
43
  /**
42
- * Refreshes all accounts in the current keychain.
44
+ * Refreshes the balances of the accounts depending on the multi-account setting.
45
+ * If multi-account is disabled, only updates the selected account balance.
46
+ * If multi-account is enabled, updates balances for all accounts.
43
47
  */
44
48
  this.refresh = () => __awaiter(this, void 0, void 0, function* () {
45
49
  this.syncAccounts();
46
50
  const accounts = Object.assign({}, this.state.accounts);
47
- for (const address in accounts) {
48
- yield (0, controller_utils_1.safelyExecuteWithTimeout)(() => __awaiter(this, void 0, void 0, function* () {
49
- (0, utils_1.assert)(this.ethQuery, 'Provider not set.');
50
- const balance = yield (0, controller_utils_1.query)(this.ethQuery, 'getBalance', [address]);
51
- accounts[address] = { balance: (0, controller_utils_1.BNToHex)(balance) };
52
- }));
51
+ const isMultiAccountBalancesEnabled = this.getMultiAccountBalancesEnabled();
52
+ const accountsToUpdate = isMultiAccountBalancesEnabled
53
+ ? Object.keys(accounts)
54
+ : [this.getSelectedAddress()];
55
+ for (const address of accountsToUpdate) {
56
+ accounts[address] = {
57
+ balance: (0, controller_utils_1.BNToHex)(yield this.getBalanceFromChain(address)),
58
+ };
53
59
  }
54
60
  this.update({ accounts });
55
61
  });
@@ -59,6 +65,8 @@ class AccountTrackerController extends base_controller_1.BaseController {
59
65
  this.defaultState = { accounts: {} };
60
66
  this.initialize();
61
67
  this.getIdentities = getIdentities;
68
+ this.getSelectedAddress = getSelectedAddress;
69
+ this.getMultiAccountBalancesEnabled = getMultiAccountBalancesEnabled;
62
70
  onPreferencesStateChange(() => {
63
71
  this.refresh();
64
72
  });
@@ -108,6 +116,20 @@ class AccountTrackerController extends base_controller_1.BaseController {
108
116
  }, this.config.interval);
109
117
  });
110
118
  }
119
+ /**
120
+ * Fetches the balance of a given address from the blockchain.
121
+ *
122
+ * @param address - The account address to fetch the balance for.
123
+ * @returns A promise that resolves to the balance in a hex string format.
124
+ */
125
+ getBalanceFromChain(address) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ return yield (0, controller_utils_1.safelyExecuteWithTimeout)(() => __awaiter(this, void 0, void 0, function* () {
128
+ (0, utils_1.assert)(this.ethQuery, 'Provider not set.');
129
+ return yield (0, controller_utils_1.query)(this.ethQuery, 'getBalance', [address]);
130
+ }));
131
+ });
132
+ }
111
133
  /**
112
134
  * Sync accounts balances with some additional addresses.
113
135
  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AC,GAAG,EAAE,IAAI,EAAE,EAAE;oBAChC,IAAI,CAAC,IAAI,EAAE;wBACT,OAAO,GAAG,CAAC;qBACZ;oBAED,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;oBAChC,uCACK,GAAG,KACN,CAAC,OAAO,CAAC,EAAE;4BACT,OAAO;yBACR,IACD;gBACJ,CAAC,EAAE,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAxJD,4DAwJC;AAED,kBAAe,wBAAwB,CAAC","sourcesContent":["import EthQuery from 'eth-query';\nimport type { Provider } from 'eth-query';\nimport { Mutex } from 'async-mutex';\nimport {\n BaseConfig,\n BaseController,\n BaseState,\n} from '@metamask/base-controller';\nimport { assert } from '@metamask/utils';\nimport { PreferencesState } from '@metamask/preferences-controller';\nimport {\n BNToHex,\n query,\n safelyExecuteWithTimeout,\n} from '@metamask/controller-utils';\n\n/**\n * @type AccountInformation\n *\n * Account information object\n * @property balance - Hex string of an account balancec in wei\n */\nexport interface AccountInformation {\n balance: string;\n}\n\n/**\n * @type AccountTrackerConfig\n *\n * Account tracker controller configuration\n * @property provider - Provider used to create a new underlying EthQuery instance\n */\nexport interface AccountTrackerConfig extends BaseConfig {\n interval: number;\n provider?: Provider;\n}\n\n/**\n * @type AccountTrackerState\n *\n * Account tracker controller state\n * @property accounts - Map of addresses to account information\n */\nexport interface AccountTrackerState extends BaseState {\n accounts: { [address: string]: AccountInformation };\n}\n\n/**\n * Controller that tracks the network balances for all user accounts.\n */\nexport class AccountTrackerController extends BaseController<\n AccountTrackerConfig,\n AccountTrackerState\n> {\n private ethQuery?: EthQuery;\n\n private mutex = new Mutex();\n\n private handle?: ReturnType<typeof setTimeout>;\n\n private syncAccounts() {\n const { accounts } = this.state;\n const addresses = Object.keys(this.getIdentities());\n const existing = Object.keys(accounts);\n const newAddresses = addresses.filter(\n (address) => existing.indexOf(address) === -1,\n );\n const oldAddresses = existing.filter(\n (address) => addresses.indexOf(address) === -1,\n );\n newAddresses.forEach((address) => {\n accounts[address] = { balance: '0x0' };\n });\n\n oldAddresses.forEach((address) => {\n delete accounts[address];\n });\n this.update({ accounts: { ...accounts } });\n }\n\n /**\n * Name of this controller used during composition\n */\n override name = 'AccountTrackerController';\n\n private getIdentities: () => PreferencesState['identities'];\n\n /**\n * Creates an AccountTracker instance.\n *\n * @param options - The controller options.\n * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.\n * @param options.getIdentities - Gets the identities from the Preferences store.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n onPreferencesStateChange,\n getIdentities,\n }: {\n onPreferencesStateChange: (\n listener: (preferencesState: PreferencesState) => void,\n ) => void;\n getIdentities: () => PreferencesState['identities'];\n },\n config?: Partial<AccountTrackerConfig>,\n state?: Partial<AccountTrackerState>,\n ) {\n super(config, state);\n this.defaultConfig = {\n interval: 10000,\n };\n this.defaultState = { accounts: {} };\n this.initialize();\n this.getIdentities = getIdentities;\n onPreferencesStateChange(() => {\n this.refresh();\n });\n this.poll();\n }\n\n /**\n * Sets a new provider.\n *\n * TODO: Replace this wth a method.\n *\n * @param provider - Provider used to create a new underlying EthQuery instance.\n */\n set provider(provider: Provider) {\n this.ethQuery = new EthQuery(provider);\n }\n\n get provider() {\n throw new Error('Property only used for setting');\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - Polling interval trigger a 'refresh'.\n */\n async poll(interval?: number): Promise<void> {\n const releaseLock = await this.mutex.acquire();\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await this.refresh();\n this.handle = setTimeout(() => {\n releaseLock();\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Refreshes all accounts in the current keychain.\n */\n refresh = async () => {\n this.syncAccounts();\n const accounts = { ...this.state.accounts };\n for (const address in accounts) {\n await safelyExecuteWithTimeout(async () => {\n assert(this.ethQuery, 'Provider not set.');\n const balance = await query(this.ethQuery, 'getBalance', [address]);\n accounts[address] = { balance: BNToHex(balance) };\n });\n }\n this.update({ accounts });\n };\n\n /**\n * Sync accounts balances with some additional addresses.\n *\n * @param addresses - the additional addresses, may be hardware wallet addresses.\n * @returns accounts - addresses with synced balance\n */\n async syncBalanceWithAddresses(\n addresses: string[],\n ): Promise<Record<string, { balance: string }>> {\n return await Promise.all(\n addresses.map((address): Promise<[string, string] | undefined> => {\n return safelyExecuteWithTimeout(async () => {\n assert(this.ethQuery, 'Provider not set.');\n const balance = await query(this.ethQuery, 'getBalance', [address]);\n return [address, balance];\n });\n }),\n ).then((value) => {\n return value.reduce((obj, item) => {\n if (!item) {\n return obj;\n }\n\n const [address, balance] = item;\n return {\n ...obj,\n [address]: {\n balance,\n },\n };\n }, {});\n });\n }\n}\n\nexport default AccountTrackerController;\n"]}
1
+ {"version":3,"file":"AccountTrackerController.js","sourceRoot":"","sources":["../src/AccountTrackerController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AAEjC,6CAAoC;AACpC,+DAImC;AACnC,2CAAyC;AAEzC,iEAIoC;AAiCpC;;GAEG;AACH,MAAa,wBAAyB,SAAQ,gCAG7C;IAsCC;;;;;;;;;;OAUG;IACH,YACE,EACE,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,8BAA8B,GAQ/B,EACD,MAAsC,EACtC,KAAoC;QAEpC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QA/Df,UAAK,GAAG,IAAI,mBAAK,EAAE,CAAC;QAwB5B;;WAEG;QACM,SAAI,GAAG,0BAA0B,CAAC;QAkF3C;;;;WAIG;QACH,YAAO,GAAG,GAAS,EAAE;YACnB,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,QAAQ,qBAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAE,CAAC;YAC5C,MAAM,6BAA6B,GAAG,IAAI,CAAC,8BAA8B,EAAE,CAAC;YAE5E,MAAM,gBAAgB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QACL,CAAC;KAAA;CACF;AA1LD,4DA0LC;AAED,kBAAe,wBAAwB,CAAC","sourcesContent":["import EthQuery from 'eth-query';\nimport type { Provider } from 'eth-query';\nimport { Mutex } from 'async-mutex';\nimport {\n BaseConfig,\n BaseController,\n BaseState,\n} from '@metamask/base-controller';\nimport { assert } from '@metamask/utils';\nimport { PreferencesState } from '@metamask/preferences-controller';\nimport {\n BNToHex,\n query,\n safelyExecuteWithTimeout,\n} from '@metamask/controller-utils';\n\n/**\n * @type AccountInformation\n *\n * Account information object\n * @property balance - Hex string of an account balancec in wei\n */\nexport interface AccountInformation {\n balance: string;\n}\n\n/**\n * @type AccountTrackerConfig\n *\n * Account tracker controller configuration\n * @property provider - Provider used to create a new underlying EthQuery instance\n */\nexport interface AccountTrackerConfig extends BaseConfig {\n interval: number;\n provider?: Provider;\n}\n\n/**\n * @type AccountTrackerState\n *\n * Account tracker controller state\n * @property accounts - Map of addresses to account information\n */\nexport interface AccountTrackerState extends BaseState {\n accounts: { [address: string]: AccountInformation };\n}\n\n/**\n * Controller that tracks the network balances for all user accounts.\n */\nexport class AccountTrackerController extends BaseController<\n AccountTrackerConfig,\n AccountTrackerState\n> {\n private ethQuery?: EthQuery;\n\n private mutex = new Mutex();\n\n private handle?: ReturnType<typeof setTimeout>;\n\n private syncAccounts() {\n const { accounts } = this.state;\n const addresses = Object.keys(this.getIdentities());\n const existing = Object.keys(accounts);\n const newAddresses = addresses.filter(\n (address) => existing.indexOf(address) === -1,\n );\n const oldAddresses = existing.filter(\n (address) => addresses.indexOf(address) === -1,\n );\n newAddresses.forEach((address) => {\n accounts[address] = { balance: '0x0' };\n });\n\n oldAddresses.forEach((address) => {\n delete accounts[address];\n });\n this.update({ accounts: { ...accounts } });\n }\n\n /**\n * Name of this controller used during composition\n */\n override name = 'AccountTrackerController';\n\n private getIdentities: () => PreferencesState['identities'];\n\n private getSelectedAddress: () => PreferencesState['selectedAddress'];\n\n private getMultiAccountBalancesEnabled: () => PreferencesState['isMultiAccountBalancesEnabled'];\n\n /**\n * Creates an AccountTracker instance.\n *\n * @param options - The controller options.\n * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.\n * @param options.getIdentities - Gets the identities from the Preferences store.\n * @param options.getSelectedAddress - Gets the selected address from the Preferences store.\n * @param options.getMultiAccountBalancesEnabled - Gets the multi account balances enabled flag from the Preferences store.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n onPreferencesStateChange,\n getIdentities,\n getSelectedAddress,\n getMultiAccountBalancesEnabled,\n }: {\n onPreferencesStateChange: (\n listener: (preferencesState: PreferencesState) => void,\n ) => void;\n getIdentities: () => PreferencesState['identities'];\n getSelectedAddress: () => PreferencesState['selectedAddress'];\n getMultiAccountBalancesEnabled: () => PreferencesState['isMultiAccountBalancesEnabled'];\n },\n config?: Partial<AccountTrackerConfig>,\n state?: Partial<AccountTrackerState>,\n ) {\n super(config, state);\n this.defaultConfig = {\n interval: 10000,\n };\n this.defaultState = { accounts: {} };\n this.initialize();\n this.getIdentities = getIdentities;\n this.getSelectedAddress = getSelectedAddress;\n this.getMultiAccountBalancesEnabled = getMultiAccountBalancesEnabled;\n onPreferencesStateChange(() => {\n this.refresh();\n });\n this.poll();\n }\n\n /**\n * Sets a new provider.\n *\n * TODO: Replace this wth a method.\n *\n * @param provider - Provider used to create a new underlying EthQuery instance.\n */\n set provider(provider: Provider) {\n this.ethQuery = new EthQuery(provider);\n }\n\n get provider() {\n throw new Error('Property only used for setting');\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - Polling interval trigger a 'refresh'.\n */\n async poll(interval?: number): Promise<void> {\n const releaseLock = await this.mutex.acquire();\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await this.refresh();\n this.handle = setTimeout(() => {\n releaseLock();\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Refreshes the balances of the accounts depending on the multi-account setting.\n * If multi-account is disabled, only updates the selected account balance.\n * If multi-account is enabled, updates balances for all accounts.\n */\n refresh = async () => {\n this.syncAccounts();\n const accounts = { ...this.state.accounts };\n const isMultiAccountBalancesEnabled = this.getMultiAccountBalancesEnabled();\n\n const accountsToUpdate = isMultiAccountBalancesEnabled\n ? Object.keys(accounts)\n : [this.getSelectedAddress()];\n\n for (const address of accountsToUpdate) {\n accounts[address] = {\n balance: BNToHex(await this.getBalanceFromChain(address)),\n };\n }\n\n this.update({ accounts });\n };\n\n /**\n * Fetches the balance of a given address from the blockchain.\n *\n * @param address - The account address to fetch the balance for.\n * @returns A promise that resolves to the balance in a hex string format.\n */\n private async getBalanceFromChain(\n address: string,\n ): Promise<string | undefined> {\n return await safelyExecuteWithTimeout(async () => {\n assert(this.ethQuery, 'Provider not set.');\n return await query(this.ethQuery, 'getBalance', [address]);\n });\n }\n\n /**\n * Sync accounts balances with some additional addresses.\n *\n * @param addresses - the additional addresses, may be hardware wallet addresses.\n * @returns accounts - addresses with synced balance\n */\n async syncBalanceWithAddresses(\n addresses: string[],\n ): Promise<Record<string, { balance: string }>> {\n return await Promise.all(\n addresses.map((address): Promise<[string, string] | undefined> => {\n return safelyExecuteWithTimeout(async () => {\n assert(this.ethQuery, 'Provider not set.');\n const balance = await query(this.ethQuery, 'getBalance', [address]);\n return [address, balance];\n });\n }),\n ).then((value) => {\n return value.reduce((obj, item) => {\n if (!item) {\n return obj;\n }\n\n const [address, balance] = item;\n return {\n ...obj,\n [address]: {\n balance,\n },\n };\n }, {});\n });\n }\n}\n\nexport default AccountTrackerController;\n"]}
@@ -1,11 +1,25 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import type { Hex } from '@metamask/utils';
4
- import { BaseController, BaseConfig, BaseState } from '@metamask/base-controller';
4
+ import { BaseController, BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller';
5
5
  import type { PreferencesState } from '@metamask/preferences-controller';
6
6
  import type { NetworkState } from '@metamask/network-controller';
7
+ import { AddApprovalRequest } from '@metamask/approval-controller';
7
8
  import type { ApiNftCreator, ApiNftLastSale } from './NftDetectionController';
8
9
  import type { AssetsContractController } from './AssetsContractController';
10
+ import { Source } from './constants';
11
+ declare type NFTStandardType = 'ERC721' | 'ERC1155';
12
+ declare type SuggestedNftMeta = {
13
+ asset: {
14
+ address: string;
15
+ tokenId: string;
16
+ } & NftMetadata;
17
+ id: string;
18
+ time: number;
19
+ type: NFTStandardType;
20
+ interactingAddress: string;
21
+ origin: string;
22
+ };
9
23
  /**
10
24
  * @type Nft
11
25
  *
@@ -133,11 +147,28 @@ export interface NftState extends BaseState {
133
147
  };
134
148
  ignoredNfts: Nft[];
135
149
  }
150
+ interface NftAsset {
151
+ address: string;
152
+ tokenId: string;
153
+ }
154
+ /**
155
+ * The name of the {@link NftController}.
156
+ */
157
+ declare const controllerName = "NftController";
158
+ /**
159
+ * The external actions available to the {@link NftController}.
160
+ */
161
+ declare type AllowedActions = AddApprovalRequest;
162
+ /**
163
+ * The messenger of the {@link NftController}.
164
+ */
165
+ export declare type NftControllerMessenger = RestrictedControllerMessenger<typeof controllerName, AllowedActions, never, AllowedActions['type'], never>;
136
166
  /**
137
167
  * Controller that stores assets and exposes convenience methods
138
168
  */
139
169
  export declare class NftController extends BaseController<NftConfig, NftState> {
140
170
  private mutex;
171
+ private messagingSystem;
141
172
  private getNftApi;
142
173
  private getNftContractInformationApi;
143
174
  /**
@@ -146,8 +177,8 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
146
177
  * @param newCollection - the modified piece of state to update in the controller's store
147
178
  * @param baseStateKey - The root key in the store to update.
148
179
  * @param passedConfig - An object containing the selectedAddress and chainId that are passed through the auto-detection flow.
149
- * @param passedConfig.userAddress - the address passed through the NFT detection flow to ensure detected assets are stored to the correct account
150
- * @param passedConfig.chainId - the chainId passed through the NFT detection flow to ensure detected assets are stored to the correct account
180
+ * @param passedConfig.userAddress - the address passed through the NFT detection flow to ensure assets are stored to the correct account
181
+ * @param passedConfig.chainId - the chainId passed through the NFT detection flow to ensure assets are stored to the correct account
151
182
  */
152
183
  private updateNestedNftState;
153
184
  /**
@@ -210,7 +241,8 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
210
241
  * @param tokenId - The NFT identifier.
211
242
  * @param nftMetadata - NFT optional information (name, image and description).
212
243
  * @param nftContract - An object containing contract data of the NFT being added.
213
- * @param detection - The chain ID and address of the currently selected network and account at the moment the NFT was detected.
244
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
245
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
214
246
  * @returns Promise resolving to the current NFT list.
215
247
  */
216
248
  private addIndividualNft;
@@ -218,7 +250,8 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
218
250
  * Adds an NFT contract to the stored NFT contracts list.
219
251
  *
220
252
  * @param address - Hex address of the NFT contract.
221
- * @param detection - The chain ID and address of the currently selected network and account at the moment the NFT was detected.
253
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
254
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
222
255
  * @returns Promise resolving to the current NFT contracts list.
223
256
  */
224
257
  private addNftContract;
@@ -277,10 +310,11 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
277
310
  * @param options.getERC1155TokenURI - Gets the URI of the ERC1155 token at the given address, with the given ID.
278
311
  * @param options.onNftAdded - Callback that is called when an NFT is added. Currently used pass data
279
312
  * for tracking the NFT added event.
313
+ * @param options.messenger - The controller messenger.
280
314
  * @param config - Initial options used to configure this controller.
281
315
  * @param state - Initial state to set on this controller.
282
316
  */
283
- constructor({ chainId: initialChainId, onPreferencesStateChange, onNetworkStateChange, getERC721AssetName, getERC721AssetSymbol, getERC721TokenURI, getERC721OwnerOf, getERC1155BalanceOf, getERC1155TokenURI, onNftAdded, }: {
317
+ constructor({ chainId: initialChainId, onPreferencesStateChange, onNetworkStateChange, getERC721AssetName, getERC721AssetSymbol, getERC721TokenURI, getERC721OwnerOf, getERC1155BalanceOf, getERC1155TokenURI, onNftAdded, messenger, }: {
284
318
  chainId: Hex;
285
319
  onPreferencesStateChange: (listener: (preferencesState: PreferencesState) => void) => void;
286
320
  onNetworkStateChange: (listener: (networkState: NetworkState) => void) => void;
@@ -297,7 +331,21 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
297
331
  standard: string | null;
298
332
  source: string;
299
333
  }) => void;
334
+ messenger: NftControllerMessenger;
300
335
  }, config?: Partial<BaseConfig>, state?: Partial<NftState>);
336
+ validateWatchNft(asset: NftAsset, type: NFTStandardType, accountAddress: string): Promise<void>;
337
+ /**
338
+ * Adds a new suggestedAsset to state. Parameters will be validated according to
339
+ * asset type being watched. A `<suggestedNftMeta.id>:pending` hub event will be emitted once added.
340
+ *
341
+ * @param asset - The asset to be watched. For now ERC721 and ERC1155 tokens are accepted.
342
+ * @param asset.address - The address of the asset contract.
343
+ * @param asset.tokenId - The ID of the asset.
344
+ * @param type - The asset type.
345
+ * @param origin - Domain origin to register the asset from.
346
+ * @returns Object containing a Promise resolving to the suggestedAsset address if accepted.
347
+ */
348
+ watchNft(asset: NftAsset, type: NFTStandardType, origin: string): Promise<void>;
301
349
  /**
302
350
  * Sets an OpenSea API key to retrieve NFT information.
303
351
  *
@@ -327,10 +375,11 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
327
375
  * @param address - Hex address of the NFT contract.
328
376
  * @param tokenId - The NFT identifier.
329
377
  * @param nftMetadata - NFT optional metadata.
330
- * @param detection - The chain ID and address of the currently selected network and account at the moment the NFT was detected.
378
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
379
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
331
380
  * @returns Promise resolving to the current NFT list.
332
381
  */
333
- addNft(address: string, tokenId: string, nftMetadata?: NftMetadata, detection?: AccountParams): Promise<void>;
382
+ addNft(address: string, tokenId: string, nftMetadata?: NftMetadata, accountParams?: AccountParams, source?: Source): Promise<void>;
334
383
  /**
335
384
  * Removes an NFT from the stored token list.
336
385
  *
@@ -356,8 +405,8 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
356
405
  * @param nft - The NFT object to check and update.
357
406
  * @param batch - A boolean indicating whether this method is being called as part of a batch or single update.
358
407
  * @param accountParams - The userAddress and chainId to check ownership against
359
- * @param accountParams.userAddress - the address passed through the confirmed transaction flow to ensure detected assets are stored to the correct account
360
- * @param accountParams.chainId - the chainId passed through the confirmed transaction flow to ensure detected assets are stored to the correct account
408
+ * @param accountParams.userAddress - the address passed through the confirmed transaction flow to ensure assets are stored to the correct account
409
+ * @param accountParams.chainId - the chainId passed through the confirmed transaction flow to ensure assets are stored to the correct account
361
410
  * @returns the NFT with the updated isCurrentlyOwned value
362
411
  */
363
412
  checkAndUpdateSingleNftOwnershipStatus(nft: Nft, batch: boolean, { userAddress, chainId }?: {
@@ -408,6 +457,7 @@ export declare class NftController extends BaseController<NftConfig, NftState> {
408
457
  * @returns a boolean indicating if the reset was well succeded or not
409
458
  */
410
459
  resetNftTransactionStatusByTransactionId(transactionId: string, selectedAddress: string, chainId: Hex): boolean;
460
+ _requestApproval(suggestedNftMeta: SuggestedNftMeta): Promise<unknown>;
411
461
  }
412
462
  export default NftController;
413
463
  //# sourceMappingURL=NftController.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NftController.d.ts","sourceRoot":"","sources":["../src/NftController.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAajE,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,M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