@metamask/assets-controllers 73.1.0 → 73.2.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/dist/AccountTrackerController.cjs +51 -1
  3. package/dist/AccountTrackerController.cjs.map +1 -1
  4. package/dist/AccountTrackerController.d.cts +40 -1
  5. package/dist/AccountTrackerController.d.cts.map +1 -1
  6. package/dist/AccountTrackerController.d.mts +40 -1
  7. package/dist/AccountTrackerController.d.mts.map +1 -1
  8. package/dist/AccountTrackerController.mjs +51 -1
  9. package/dist/AccountTrackerController.mjs.map +1 -1
  10. package/dist/TokenBalancesController.cjs +278 -319
  11. package/dist/TokenBalancesController.cjs.map +1 -1
  12. package/dist/TokenBalancesController.d.cts +51 -93
  13. package/dist/TokenBalancesController.d.cts.map +1 -1
  14. package/dist/TokenBalancesController.d.mts +51 -93
  15. package/dist/TokenBalancesController.d.mts.map +1 -1
  16. package/dist/TokenBalancesController.mjs +277 -317
  17. package/dist/TokenBalancesController.mjs.map +1 -1
  18. package/dist/assetsUtil.cjs +13 -1
  19. package/dist/assetsUtil.cjs.map +1 -1
  20. package/dist/assetsUtil.d.cts +8 -0
  21. package/dist/assetsUtil.d.cts.map +1 -1
  22. package/dist/assetsUtil.d.mts +8 -0
  23. package/dist/assetsUtil.d.mts.map +1 -1
  24. package/dist/assetsUtil.mjs +12 -1
  25. package/dist/assetsUtil.mjs.map +1 -1
  26. package/dist/balances.cjs +447 -0
  27. package/dist/balances.cjs.map +1 -0
  28. package/dist/balances.d.cts +88 -0
  29. package/dist/balances.d.cts.map +1 -0
  30. package/dist/balances.d.mts +88 -0
  31. package/dist/balances.d.mts.map +1 -0
  32. package/dist/balances.mjs +441 -0
  33. package/dist/balances.mjs.map +1 -0
  34. package/dist/constants.cjs +13 -1
  35. package/dist/constants.cjs.map +1 -1
  36. package/dist/constants.d.cts +1 -0
  37. package/dist/constants.d.cts.map +1 -1
  38. package/dist/constants.d.mts +1 -0
  39. package/dist/constants.d.mts.map +1 -1
  40. package/dist/constants.mjs +12 -0
  41. package/dist/constants.mjs.map +1 -1
  42. package/dist/index.cjs +6 -3
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +6 -4
  45. package/dist/index.d.cts.map +1 -1
  46. package/dist/index.d.mts +6 -4
  47. package/dist/index.d.mts.map +1 -1
  48. package/dist/index.mjs +2 -1
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs +247 -0
  51. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs.map +1 -0
  52. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.cts +30 -0
  53. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.cts.map +1 -0
  54. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.mts +30 -0
  55. package/dist/multi-chain-accounts-service/api-balance-fetcher.d.mts.map +1 -0
  56. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs +247 -0
  57. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs.map +1 -0
  58. package/dist/multi-chain-accounts-service/multi-chain-accounts.cjs +35 -1
  59. package/dist/multi-chain-accounts-service/multi-chain-accounts.cjs.map +1 -1
  60. package/dist/multi-chain-accounts-service/multi-chain-accounts.d.cts +16 -0
  61. package/dist/multi-chain-accounts-service/multi-chain-accounts.d.cts.map +1 -1
  62. package/dist/multi-chain-accounts-service/multi-chain-accounts.d.mts +16 -0
  63. package/dist/multi-chain-accounts-service/multi-chain-accounts.d.mts.map +1 -1
  64. package/dist/multi-chain-accounts-service/multi-chain-accounts.mjs +33 -0
  65. package/dist/multi-chain-accounts-service/multi-chain-accounts.mjs.map +1 -1
  66. package/dist/multi-chain-accounts-service/types.cjs.map +1 -1
  67. package/dist/multi-chain-accounts-service/types.d.cts +8 -0
  68. package/dist/multi-chain-accounts-service/types.d.cts.map +1 -1
  69. package/dist/multi-chain-accounts-service/types.d.mts +8 -0
  70. package/dist/multi-chain-accounts-service/types.d.mts.map +1 -1
  71. package/dist/multi-chain-accounts-service/types.mjs.map +1 -1
  72. package/dist/multicall.cjs +457 -1
  73. package/dist/multicall.cjs.map +1 -1
  74. package/dist/multicall.d.cts +51 -0
  75. package/dist/multicall.d.cts.map +1 -1
  76. package/dist/multicall.d.mts +51 -0
  77. package/dist/multicall.d.mts.map +1 -1
  78. package/dist/multicall.mjs +457 -0
  79. package/dist/multicall.mjs.map +1 -1
  80. package/dist/rpc-service/rpc-balance-fetcher.cjs +184 -0
  81. package/dist/rpc-service/rpc-balance-fetcher.cjs.map +1 -0
  82. package/dist/rpc-service/rpc-balance-fetcher.d.cts +34 -0
  83. package/dist/rpc-service/rpc-balance-fetcher.d.cts.map +1 -0
  84. package/dist/rpc-service/rpc-balance-fetcher.d.mts +34 -0
  85. package/dist/rpc-service/rpc-balance-fetcher.d.mts.map +1 -0
  86. package/dist/rpc-service/rpc-balance-fetcher.mjs +184 -0
  87. package/dist/rpc-service/rpc-balance-fetcher.mjs.map +1 -0
  88. package/package.json +9 -9
  89. package/dist/selectors/balanceSelectors.cjs +0 -328
  90. package/dist/selectors/balanceSelectors.cjs.map +0 -1
  91. package/dist/selectors/balanceSelectors.d.cts +0 -1676
  92. package/dist/selectors/balanceSelectors.d.cts.map +0 -1
  93. package/dist/selectors/balanceSelectors.d.mts +0 -1676
  94. package/dist/selectors/balanceSelectors.d.mts.map +0 -1
  95. package/dist/selectors/balanceSelectors.mjs +0 -321
  96. package/dist/selectors/balanceSelectors.mjs.map +0 -1
@@ -0,0 +1,30 @@
1
+ import type { Web3Provider } from "@ethersproject/providers";
2
+ import type { InternalAccount } from "@metamask/keyring-internal-api";
3
+ import type { Hex } from "@metamask/utils";
4
+ import BN from "bn.js";
5
+ export type ChainIdHex = Hex;
6
+ export type ChecksumAddress = Hex;
7
+ export type ProcessedBalance = {
8
+ success: boolean;
9
+ value?: BN;
10
+ account: ChecksumAddress;
11
+ token: ChecksumAddress;
12
+ chainId: ChainIdHex;
13
+ };
14
+ export type BalanceFetcher = {
15
+ supports(chainId: ChainIdHex): boolean;
16
+ fetch(input: {
17
+ chainIds: ChainIdHex[];
18
+ queryAllAccounts: boolean;
19
+ selectedAccount: ChecksumAddress;
20
+ allAccounts: InternalAccount[];
21
+ }): Promise<ProcessedBalance[]>;
22
+ };
23
+ export type GetProviderFunction = (chainId: ChainIdHex) => Web3Provider;
24
+ export declare class AccountsApiBalanceFetcher implements BalanceFetcher {
25
+ #private;
26
+ constructor(platform?: 'extension' | 'mobile', getProvider?: GetProviderFunction);
27
+ supports(chainId: ChainIdHex): boolean;
28
+ fetch({ chainIds, queryAllAccounts, selectedAccount, allAccounts, }: Parameters<BalanceFetcher['fetch']>[0]): Promise<ProcessedBalance[]>;
29
+ }
30
+ //# sourceMappingURL=api-balance-fetcher.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-balance-fetcher.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/api-balance-fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,iCAAiC;AAM7D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EAAsB,GAAG,EAAE,wBAAwB;AAC/D,OAAO,EAAE,cAAc;AAcvB,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC;AAC7B,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;IACvC,KAAK,CAAC,KAAK,EAAE;QACX,QAAQ,EAAE,UAAU,EAAE,CAAC;QACvB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,eAAe,CAAC;QACjC,WAAW,EAAE,eAAe,EAAE,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CACjC,CAAC;AAUF,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,UAAU,KAAK,YAAY,CAAC;AAExE,qBAAa,yBAA0B,YAAW,cAAc;;gBAM5D,QAAQ,GAAE,WAAW,GAAG,QAAsB,EAC9C,WAAW,CAAC,EAAE,mBAAmB;IAMnC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IA0KhC,KAAK,CAAC,EACV,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,WAAW,GACZ,EAAE,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAqGxE"}
@@ -0,0 +1,247 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
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 _AccountsApiBalanceFetcher_instances, _AccountsApiBalanceFetcher_platform, _AccountsApiBalanceFetcher_getProvider, _AccountsApiBalanceFetcher_fetchStakedBalances, _AccountsApiBalanceFetcher_fetchBalances;
13
+ function $importDefault(module) {
14
+ if (module?.__esModule) {
15
+ return module.default;
16
+ }
17
+ return module;
18
+ }
19
+ import { Contract } from "@ethersproject/contracts";
20
+ import { safelyExecute, toHex, toChecksumHexAddress } from "@metamask/controller-utils";
21
+ import $BN from "bn.js";
22
+ const BN = $importDefault($BN);
23
+ import { fetchMultiChainBalancesV4 } from "./multi-chain-accounts.mjs";
24
+ import { STAKING_CONTRACT_ADDRESS_BY_CHAINID } from "../AssetsContractController.mjs";
25
+ import { accountAddressToCaipReference, reduceInBatchesSerially, SupportedStakedBalanceNetworks } from "../assetsUtil.mjs";
26
+ import { SUPPORTED_NETWORKS_ACCOUNTS_API_V4 } from "../constants.mjs";
27
+ // Maximum number of account addresses that can be sent to the accounts API in a single request
28
+ const ACCOUNTS_API_BATCH_SIZE = 50;
29
+ const checksum = (addr) => toChecksumHexAddress(addr);
30
+ const toCaipAccount = (chainId, account) => accountAddressToCaipReference(chainId, account);
31
+ export class AccountsApiBalanceFetcher {
32
+ constructor(platform = 'extension', getProvider) {
33
+ _AccountsApiBalanceFetcher_instances.add(this);
34
+ _AccountsApiBalanceFetcher_platform.set(this, 'extension');
35
+ _AccountsApiBalanceFetcher_getProvider.set(this, void 0);
36
+ __classPrivateFieldSet(this, _AccountsApiBalanceFetcher_platform, platform, "f");
37
+ __classPrivateFieldSet(this, _AccountsApiBalanceFetcher_getProvider, getProvider, "f");
38
+ }
39
+ supports(chainId) {
40
+ return SUPPORTED_NETWORKS_ACCOUNTS_API_V4.includes(chainId);
41
+ }
42
+ async fetch({ chainIds, queryAllAccounts, selectedAccount, allAccounts, }) {
43
+ const caipAddrs = [];
44
+ for (const chainId of chainIds.filter((c) => this.supports(c))) {
45
+ if (queryAllAccounts) {
46
+ allAccounts.forEach((a) => caipAddrs.push(toCaipAccount(chainId, a.address)));
47
+ }
48
+ else {
49
+ caipAddrs.push(toCaipAccount(chainId, selectedAccount));
50
+ }
51
+ }
52
+ if (!caipAddrs.length) {
53
+ return [];
54
+ }
55
+ const [balances, stakedBalances] = await Promise.all([
56
+ safelyExecute(() => __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_instances, "m", _AccountsApiBalanceFetcher_fetchBalances).call(this, caipAddrs)),
57
+ __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_instances, "m", _AccountsApiBalanceFetcher_fetchStakedBalances).call(this, caipAddrs),
58
+ ]);
59
+ const results = [];
60
+ // Collect all unique addresses and chains from the CAIP addresses
61
+ const addressChainMap = new Map();
62
+ caipAddrs.forEach((caipAddr) => {
63
+ const [, chainRef, address] = caipAddr.split(':');
64
+ const chainId = toHex(parseInt(chainRef, 10));
65
+ const checksumAddress = checksum(address);
66
+ if (!addressChainMap.has(checksumAddress)) {
67
+ addressChainMap.set(checksumAddress, new Set());
68
+ }
69
+ addressChainMap.get(checksumAddress)?.add(chainId);
70
+ });
71
+ // Ensure native token entries exist for all addresses on all requested chains
72
+ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
73
+ const nativeBalancesFromAPI = new Map(); // key: `${address}-${chainId}`
74
+ // Process regular API balances
75
+ if (balances) {
76
+ const apiBalances = balances.flatMap((b) => {
77
+ const account = b.accountAddress?.split(':')[2];
78
+ if (!account) {
79
+ return [];
80
+ }
81
+ const token = checksum(b.address);
82
+ const chainId = toHex(b.chainId);
83
+ let value;
84
+ try {
85
+ value = new BN((parseFloat(b.balance) * 10 ** b.decimals).toFixed(0));
86
+ }
87
+ catch {
88
+ value = undefined;
89
+ }
90
+ // Track native balances for later
91
+ if (token === ZERO_ADDRESS && value !== undefined) {
92
+ nativeBalancesFromAPI.set(`${account}-${chainId}`, value);
93
+ }
94
+ return [
95
+ {
96
+ success: value !== undefined,
97
+ value,
98
+ account,
99
+ token,
100
+ chainId,
101
+ },
102
+ ];
103
+ });
104
+ results.push(...apiBalances);
105
+ }
106
+ // Ensure native token entries exist for all addresses/chains, even if not returned by API
107
+ addressChainMap.forEach((chains, address) => {
108
+ chains.forEach((chainId) => {
109
+ const key = `${address}-${chainId}`;
110
+ const existingBalance = nativeBalancesFromAPI.get(key);
111
+ if (!existingBalance) {
112
+ // Add zero native balance entry if API didn't return one
113
+ results.push({
114
+ success: true,
115
+ value: new BN('0'),
116
+ account: address,
117
+ token: ZERO_ADDRESS,
118
+ chainId,
119
+ });
120
+ }
121
+ });
122
+ });
123
+ // Add staked balances
124
+ results.push(...stakedBalances);
125
+ return results;
126
+ }
127
+ }
128
+ _AccountsApiBalanceFetcher_platform = new WeakMap(), _AccountsApiBalanceFetcher_getProvider = new WeakMap(), _AccountsApiBalanceFetcher_instances = new WeakSet(), _AccountsApiBalanceFetcher_fetchStakedBalances = async function _AccountsApiBalanceFetcher_fetchStakedBalances(addrs) {
129
+ // Return empty array if no provider is available for blockchain calls
130
+ if (!__classPrivateFieldGet(this, _AccountsApiBalanceFetcher_getProvider, "f")) {
131
+ return [];
132
+ }
133
+ const results = [];
134
+ // Group addresses by chain ID
135
+ const addressesByChain = {};
136
+ for (const caipAddr of addrs) {
137
+ const [, chainRef, address] = caipAddr.split(':');
138
+ const chainId = toHex(parseInt(chainRef, 10));
139
+ const checksumAddress = checksum(address);
140
+ if (!addressesByChain[chainId]) {
141
+ addressesByChain[chainId] = [];
142
+ }
143
+ addressesByChain[chainId].push(checksumAddress);
144
+ }
145
+ // Process each supported chain
146
+ for (const [chainId, addresses] of Object.entries(addressesByChain)) {
147
+ const chainIdHex = chainId;
148
+ // Only fetch staked balance on supported networks (mainnet and hoodi)
149
+ if (![
150
+ SupportedStakedBalanceNetworks.mainnet,
151
+ SupportedStakedBalanceNetworks.hoodi,
152
+ ].includes(chainIdHex)) {
153
+ continue;
154
+ }
155
+ // Only fetch staked balance if contract address exists
156
+ if (!(chainIdHex in STAKING_CONTRACT_ADDRESS_BY_CHAINID)) {
157
+ continue;
158
+ }
159
+ const contractAddress = STAKING_CONTRACT_ADDRESS_BY_CHAINID[chainIdHex];
160
+ const provider = __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_getProvider, "f").call(this, chainIdHex);
161
+ const abi = [
162
+ {
163
+ inputs: [
164
+ { internalType: 'address', name: 'account', type: 'address' },
165
+ ],
166
+ name: 'getShares',
167
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
168
+ stateMutability: 'view',
169
+ type: 'function',
170
+ },
171
+ {
172
+ inputs: [
173
+ { internalType: 'uint256', name: 'shares', type: 'uint256' },
174
+ ],
175
+ name: 'convertToAssets',
176
+ outputs: [
177
+ { internalType: 'uint256', name: 'assets', type: 'uint256' },
178
+ ],
179
+ stateMutability: 'view',
180
+ type: 'function',
181
+ },
182
+ ];
183
+ try {
184
+ const contract = new Contract(contractAddress, abi, provider);
185
+ // Get shares for each address
186
+ for (const address of addresses) {
187
+ try {
188
+ const shares = await safelyExecute(() => contract.getShares(address));
189
+ if (shares && shares.gt(0)) {
190
+ // Convert shares to assets (actual staked ETH amount)
191
+ const assets = await safelyExecute(() => contract.convertToAssets(shares));
192
+ if (assets) {
193
+ results.push({
194
+ success: true,
195
+ value: new BN(assets.toString()),
196
+ account: address,
197
+ token: checksum(contractAddress),
198
+ chainId: chainIdHex,
199
+ });
200
+ }
201
+ }
202
+ else {
203
+ // Return zero balance for accounts with no staked assets
204
+ results.push({
205
+ success: true,
206
+ value: new BN('0'),
207
+ account: address,
208
+ token: checksum(contractAddress),
209
+ chainId: chainIdHex,
210
+ });
211
+ }
212
+ }
213
+ catch (error) {
214
+ // Log error and continue with next address
215
+ console.error(`Error fetching staked balance for ${address}:`, error);
216
+ results.push({
217
+ success: false,
218
+ account: address,
219
+ token: checksum(contractAddress),
220
+ chainId: chainIdHex,
221
+ });
222
+ }
223
+ }
224
+ }
225
+ catch (error) {
226
+ console.error(`Error setting up staking contract for chain ${chainId}:`, error);
227
+ }
228
+ }
229
+ return results;
230
+ }, _AccountsApiBalanceFetcher_fetchBalances = async function _AccountsApiBalanceFetcher_fetchBalances(addrs) {
231
+ // If we have fewer than or equal to the batch size, make a single request
232
+ if (addrs.length <= ACCOUNTS_API_BATCH_SIZE) {
233
+ const { balances } = await fetchMultiChainBalancesV4({ accountAddresses: addrs }, __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_platform, "f"));
234
+ return balances;
235
+ }
236
+ const allBalances = await reduceInBatchesSerially({
237
+ values: addrs,
238
+ batchSize: ACCOUNTS_API_BATCH_SIZE,
239
+ eachBatch: async (workingResult, batch) => {
240
+ const { balances } = await fetchMultiChainBalancesV4({ accountAddresses: batch }, __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_platform, "f"));
241
+ return [...(workingResult || []), ...balances];
242
+ },
243
+ initialResult: [],
244
+ });
245
+ return allBalances;
246
+ };
247
+ //# sourceMappingURL=api-balance-fetcher.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-balance-fetcher.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/api-balance-fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AAEpD,OAAO,EACL,aAAa,EACb,KAAK,EACL,oBAAoB,EACrB,mCAAmC;AAGpC,OAAO,GAAE,cAAc;;AAEvB,OAAO,EAAE,yBAAyB,EAAE,mCAA+B;AACnE,OAAO,EAAE,mCAAmC,EAAE,wCAAoC;AAClF,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,8BAA8B,EAC/B,0BAAsB;AACvB,OAAO,EAAE,kCAAkC,EAAE,yBAAqB;AAElE,+FAA+F;AAC/F,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAuBnC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAmB,EAAE,CACjD,oBAAoB,CAAC,IAAI,CAAoB,CAAC;AAEhD,MAAM,aAAa,GAAG,CACpB,OAAmB,EACnB,OAAwB,EACJ,EAAE,CAAC,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAIzE,MA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AE,GAAG,MAAM,yBAAyB,CAClD,EAAE,gBAAgB,EAAE,KAAK,EAAE,EAC3B,uBAAA,IAAI,2CAAU,CACf,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;QACjD,CAAC;QACD,aAAa,EAAE,EAAE;KAClB,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport type { Web3Provider } from '@ethersproject/providers';\nimport {\n safelyExecute,\n toHex,\n toChecksumHexAddress,\n} from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type { CaipAccountAddress, Hex } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { fetchMultiChainBalancesV4 } from './multi-chain-accounts';\nimport { STAKING_CONTRACT_ADDRESS_BY_CHAINID } from '../AssetsContractController';\nimport {\n accountAddressToCaipReference,\n reduceInBatchesSerially,\n SupportedStakedBalanceNetworks,\n} from '../assetsUtil';\nimport { SUPPORTED_NETWORKS_ACCOUNTS_API_V4 } from '../constants';\n\n// Maximum number of account addresses that can be sent to the accounts API in a single request\nconst ACCOUNTS_API_BATCH_SIZE = 50;\n\nexport type ChainIdHex = Hex;\nexport type ChecksumAddress = Hex;\n\nexport type ProcessedBalance = {\n success: boolean;\n value?: BN;\n account: ChecksumAddress;\n token: ChecksumAddress;\n chainId: ChainIdHex;\n};\n\nexport type BalanceFetcher = {\n supports(chainId: ChainIdHex): boolean;\n fetch(input: {\n chainIds: ChainIdHex[];\n queryAllAccounts: boolean;\n selectedAccount: ChecksumAddress;\n allAccounts: InternalAccount[];\n }): Promise<ProcessedBalance[]>;\n};\n\nconst checksum = (addr: string): ChecksumAddress =>\n toChecksumHexAddress(addr) as ChecksumAddress;\n\nconst toCaipAccount = (\n chainId: ChainIdHex,\n account: ChecksumAddress,\n): CaipAccountAddress => accountAddressToCaipReference(chainId, account);\n\nexport type GetProviderFunction = (chainId: ChainIdHex) => Web3Provider;\n\nexport class AccountsApiBalanceFetcher implements BalanceFetcher {\n readonly #platform: 'extension' | 'mobile' = 'extension';\n\n readonly #getProvider?: GetProviderFunction;\n\n constructor(\n platform: 'extension' | 'mobile' = 'extension',\n getProvider?: GetProviderFunction,\n ) {\n this.#platform = platform;\n this.#getProvider = getProvider;\n }\n\n supports(chainId: ChainIdHex): boolean {\n return SUPPORTED_NETWORKS_ACCOUNTS_API_V4.includes(chainId);\n }\n\n async #fetchStakedBalances(\n addrs: CaipAccountAddress[],\n ): Promise<ProcessedBalance[]> {\n // Return empty array if no provider is available for blockchain calls\n if (!this.#getProvider) {\n return [];\n }\n\n const results: ProcessedBalance[] = [];\n\n // Group addresses by chain ID\n const addressesByChain: Record<ChainIdHex, ChecksumAddress[]> = {};\n\n for (const caipAddr of addrs) {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10)) as ChainIdHex;\n const checksumAddress = checksum(address);\n\n if (!addressesByChain[chainId]) {\n addressesByChain[chainId] = [];\n }\n addressesByChain[chainId].push(checksumAddress);\n }\n\n // Process each supported chain\n for (const [chainId, addresses] of Object.entries(addressesByChain)) {\n const chainIdHex = chainId as ChainIdHex;\n\n // Only fetch staked balance on supported networks (mainnet and hoodi)\n if (\n ![\n SupportedStakedBalanceNetworks.mainnet,\n SupportedStakedBalanceNetworks.hoodi,\n ].includes(chainIdHex as SupportedStakedBalanceNetworks)\n ) {\n continue;\n }\n\n // Only fetch staked balance if contract address exists\n if (!(chainIdHex in STAKING_CONTRACT_ADDRESS_BY_CHAINID)) {\n continue;\n }\n\n const contractAddress =\n STAKING_CONTRACT_ADDRESS_BY_CHAINID[\n chainIdHex as keyof typeof STAKING_CONTRACT_ADDRESS_BY_CHAINID\n ];\n const provider = this.#getProvider(chainIdHex);\n\n const abi = [\n {\n inputs: [\n { internalType: 'address', name: 'account', type: 'address' },\n ],\n name: 'getShares',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { internalType: 'uint256', name: 'shares', type: 'uint256' },\n ],\n name: 'convertToAssets',\n outputs: [\n { internalType: 'uint256', name: 'assets', type: 'uint256' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n ];\n\n try {\n const contract = new Contract(contractAddress, abi, provider);\n\n // Get shares for each address\n for (const address of addresses) {\n try {\n const shares = await safelyExecute(() =>\n contract.getShares(address),\n );\n\n if (shares && (shares as BigNumber).gt(0)) {\n // Convert shares to assets (actual staked ETH amount)\n const assets = await safelyExecute(() =>\n contract.convertToAssets(shares),\n );\n\n if (assets) {\n results.push({\n success: true,\n value: new BN((assets as BigNumber).toString()),\n account: address,\n token: checksum(contractAddress) as ChecksumAddress,\n chainId: chainIdHex,\n });\n }\n } else {\n // Return zero balance for accounts with no staked assets\n results.push({\n success: true,\n value: new BN('0'),\n account: address,\n token: checksum(contractAddress) as ChecksumAddress,\n chainId: chainIdHex,\n });\n }\n } catch (error) {\n // Log error and continue with next address\n console.error(\n `Error fetching staked balance for ${address}:`,\n error,\n );\n results.push({\n success: false,\n account: address,\n token: checksum(contractAddress) as ChecksumAddress,\n chainId: chainIdHex,\n });\n }\n }\n } catch (error) {\n console.error(\n `Error setting up staking contract for chain ${chainId}:`,\n error,\n );\n }\n }\n\n return results;\n }\n\n async #fetchBalances(addrs: CaipAccountAddress[]) {\n // If we have fewer than or equal to the batch size, make a single request\n if (addrs.length <= ACCOUNTS_API_BATCH_SIZE) {\n const { balances } = await fetchMultiChainBalancesV4(\n { accountAddresses: addrs },\n this.#platform,\n );\n return balances;\n }\n\n // Otherwise, batch the requests to respect the 50-element limit\n type BalanceData = Awaited<\n ReturnType<typeof fetchMultiChainBalancesV4>\n >['balances'][number];\n\n const allBalances = await reduceInBatchesSerially<\n CaipAccountAddress,\n BalanceData[]\n >({\n values: addrs,\n batchSize: ACCOUNTS_API_BATCH_SIZE,\n eachBatch: async (workingResult, batch) => {\n const { balances } = await fetchMultiChainBalancesV4(\n { accountAddresses: batch },\n this.#platform,\n );\n return [...(workingResult || []), ...balances];\n },\n initialResult: [],\n });\n\n return allBalances;\n }\n\n async fetch({\n chainIds,\n queryAllAccounts,\n selectedAccount,\n allAccounts,\n }: Parameters<BalanceFetcher['fetch']>[0]): Promise<ProcessedBalance[]> {\n const caipAddrs: CaipAccountAddress[] = [];\n\n for (const chainId of chainIds.filter((c) => this.supports(c))) {\n if (queryAllAccounts) {\n allAccounts.forEach((a) =>\n caipAddrs.push(toCaipAccount(chainId, a.address as ChecksumAddress)),\n );\n } else {\n caipAddrs.push(toCaipAccount(chainId, selectedAccount));\n }\n }\n\n if (!caipAddrs.length) {\n return [];\n }\n\n const [balances, stakedBalances] = await Promise.all([\n safelyExecute(() => this.#fetchBalances(caipAddrs)),\n this.#fetchStakedBalances(caipAddrs),\n ]);\n\n const results: ProcessedBalance[] = [];\n\n // Collect all unique addresses and chains from the CAIP addresses\n const addressChainMap = new Map<string, Set<ChainIdHex>>();\n caipAddrs.forEach((caipAddr) => {\n const [, chainRef, address] = caipAddr.split(':');\n const chainId = toHex(parseInt(chainRef, 10)) as ChainIdHex;\n const checksumAddress = checksum(address);\n\n if (!addressChainMap.has(checksumAddress)) {\n addressChainMap.set(checksumAddress, new Set());\n }\n addressChainMap.get(checksumAddress)?.add(chainId);\n });\n\n // Ensure native token entries exist for all addresses on all requested chains\n const ZERO_ADDRESS =\n '0x0000000000000000000000000000000000000000' as ChecksumAddress;\n const nativeBalancesFromAPI = new Map<string, BN>(); // key: `${address}-${chainId}`\n\n // Process regular API balances\n if (balances) {\n const apiBalances = balances.flatMap((b) => {\n const account = b.accountAddress?.split(':')[2] as ChecksumAddress;\n if (!account) {\n return [];\n }\n const token = checksum(b.address);\n const chainId = toHex(b.chainId) as ChainIdHex;\n\n let value: BN | undefined;\n try {\n value = new BN((parseFloat(b.balance) * 10 ** b.decimals).toFixed(0));\n } catch {\n value = undefined;\n }\n\n // Track native balances for later\n if (token === ZERO_ADDRESS && value !== undefined) {\n nativeBalancesFromAPI.set(`${account}-${chainId}`, value);\n }\n\n return [\n {\n success: value !== undefined,\n value,\n account,\n token,\n chainId,\n },\n ];\n });\n results.push(...apiBalances);\n }\n\n // Ensure native token entries exist for all addresses/chains, even if not returned by API\n addressChainMap.forEach((chains, address) => {\n chains.forEach((chainId) => {\n const key = `${address}-${chainId}`;\n const existingBalance = nativeBalancesFromAPI.get(key);\n\n if (!existingBalance) {\n // Add zero native balance entry if API didn't return one\n results.push({\n success: true,\n value: new BN('0'),\n account: address as ChecksumAddress,\n token: ZERO_ADDRESS,\n chainId,\n });\n }\n });\n });\n\n // Add staked balances\n results.push(...stakedBalances);\n\n return results;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchMultiChainBalances = exports.fetchSupportedNetworks = exports.MULTICHAIN_ACCOUNTS_DOMAIN = void 0;
3
+ exports.fetchMultiChainBalancesV4 = exports.fetchMultiChainBalances = exports.fetchSupportedNetworks = exports.MULTICHAIN_ACCOUNTS_DOMAIN = void 0;
4
4
  const controller_utils_1 = require("@metamask/controller-utils");
5
5
  exports.MULTICHAIN_ACCOUNTS_DOMAIN = 'https://accounts.api.cx.metamask.io';
6
6
  const getBalancesUrl = (address, queryParams) => {
@@ -10,8 +10,19 @@ const getBalancesUrl = (address, queryParams) => {
10
10
  }
11
11
  return url;
12
12
  };
13
+ const getBalancesUrlV4 = (queryParams) => {
14
+ const url = new URL(`${exports.MULTICHAIN_ACCOUNTS_DOMAIN}/v4/multiaccount/balances`);
15
+ if (queryParams?.networks !== undefined) {
16
+ url.searchParams.append('networks', queryParams.networks);
17
+ }
18
+ if (queryParams?.accountAddresses !== undefined) {
19
+ url.searchParams.append('accountAddresses', queryParams.accountAddresses);
20
+ }
21
+ return url;
22
+ };
13
23
  /**
14
24
  * Fetches Supported Networks.
25
+ *
15
26
  * @returns supported networks (decimal)
16
27
  */
17
28
  async function fetchSupportedNetworks() {
@@ -22,6 +33,7 @@ async function fetchSupportedNetworks() {
22
33
  exports.fetchSupportedNetworks = fetchSupportedNetworks;
23
34
  /**
24
35
  * Fetches Balances for multiple networks.
36
+ *
25
37
  * @param address - address to fetch balances from
26
38
  * @param options - params to pass down for a more refined search
27
39
  * @param options.networks - the networks (in decimal) that you want to filter by
@@ -40,4 +52,26 @@ async function fetchMultiChainBalances(address, options, platform) {
40
52
  return response;
41
53
  }
42
54
  exports.fetchMultiChainBalances = fetchMultiChainBalances;
55
+ /**
56
+ * Fetches Balances for multiple networks.
57
+ *
58
+ * @param options - params to pass down for a more refined search
59
+ * @param options.accountAddresses - the account addresses that you want to filter by
60
+ * @param options.networks - the networks (in decimal) that you want to filter by
61
+ * @param platform - indicates whether the platform is extension or mobile
62
+ * @returns a Balances Response
63
+ */
64
+ async function fetchMultiChainBalancesV4(options, platform) {
65
+ const url = getBalancesUrlV4({
66
+ accountAddresses: options?.accountAddresses?.join(),
67
+ networks: options?.networks?.join(),
68
+ });
69
+ const response = await (0, controller_utils_1.handleFetch)(url, {
70
+ headers: {
71
+ 'x-metamask-clientproduct': `metamask-${platform}`,
72
+ },
73
+ });
74
+ return response;
75
+ }
76
+ exports.fetchMultiChainBalancesV4 = fetchMultiChainBalancesV4;
43
77
  //# sourceMappingURL=multi-chain-accounts.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-chain-accounts.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":";;;AAAA,iEAAyD;AAQ5C,QAAA,0BAA0B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,cAAc,GAAG,CACrB,OAAe,EACf,WAAoC,EACpC,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,GAAG,kCAA0B,gBAAgB,OAAO,WAAW,CAChE,CAAC;IAEF,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,sBAAsB;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,kCAA0B,uBAAuB,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAiC,MAAM,IAAA,8BAAW,EAAC,GAAG,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,WAAW,CAAC;AAC9B,CAAC;AAJD,wDAIC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,OAAgC,EAChC,QAAgC;IAEhC,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,EAAE;QAClC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;KACpC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAwB,MAAM,IAAA,8BAAW,EAAC,GAAG,EAAE;QAC3D,OAAO,EAAE;YACP,0BAA0B,EAAE,YAAY,QAAQ,EAAE;SACnD;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAdD,0DAcC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\n\nimport type {\n GetBalancesQueryParams,\n GetBalancesResponse,\n GetSupportedNetworksResponse,\n} from './types';\n\nexport const MULTICHAIN_ACCOUNTS_DOMAIN = 'https://accounts.api.cx.metamask.io';\n\nconst getBalancesUrl = (\n address: string,\n queryParams?: GetBalancesQueryParams,\n) => {\n const url = new URL(\n `${MULTICHAIN_ACCOUNTS_DOMAIN}/v2/accounts/${address}/balances`,\n );\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n return url;\n};\n\n/**\n * Fetches Supported Networks.\n * @returns supported networks (decimal)\n */\nexport async function fetchSupportedNetworks(): Promise<number[]> {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v1/supportedNetworks`);\n const response: GetSupportedNetworksResponse = await handleFetch(url);\n return response.fullSupport;\n}\n\n/**\n * Fetches Balances for multiple networks.\n * @param address - address to fetch balances from\n * @param options - params to pass down for a more refined search\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalances(\n address: string,\n options: { networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrl(address, {\n networks: options?.networks?.join(),\n });\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n"]}
1
+ {"version":3,"file":"multi-chain-accounts.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":";;;AAAA,iEAAyD;AAU5C,QAAA,0BAA0B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,cAAc,GAAG,CACrB,OAAe,EACf,WAAoC,EACpC,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,GAAG,kCAA0B,gBAAgB,OAAO,WAAW,CAChE,CAAC;IAEF,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,WAAsC,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,kCAA0B,2BAA2B,CAAC,CAAC;IAE9E,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;I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H,OAAO,QAAQ,CAAC;AAClB,CAAC;AAfD,8DAeC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { CaipAccountAddress } from '@metamask/utils';\n\nimport type {\n GetBalancesQueryParams,\n GetBalancesQueryParamsV4,\n GetBalancesResponse,\n GetSupportedNetworksResponse,\n} from './types';\n\nexport const MULTICHAIN_ACCOUNTS_DOMAIN = 'https://accounts.api.cx.metamask.io';\n\nconst getBalancesUrl = (\n address: string,\n queryParams?: GetBalancesQueryParams,\n) => {\n const url = new URL(\n `${MULTICHAIN_ACCOUNTS_DOMAIN}/v2/accounts/${address}/balances`,\n );\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n return url;\n};\n\nconst getBalancesUrlV4 = (queryParams?: GetBalancesQueryParamsV4) => {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v4/multiaccount/balances`);\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n if (queryParams?.accountAddresses !== undefined) {\n url.searchParams.append('accountAddresses', queryParams.accountAddresses);\n }\n\n return url;\n};\n\n/**\n * Fetches Supported Networks.\n *\n * @returns supported networks (decimal)\n */\nexport async function fetchSupportedNetworks(): Promise<number[]> {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v1/supportedNetworks`);\n const response: GetSupportedNetworksResponse = await handleFetch(url);\n return response.fullSupport;\n}\n\n/**\n * Fetches Balances for multiple networks.\n *\n * @param address - address to fetch balances from\n * @param options - params to pass down for a more refined search\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalances(\n address: string,\n options: { networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrl(address, {\n networks: options?.networks?.join(),\n });\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n\n/**\n * Fetches Balances for multiple networks.\n *\n * @param options - params to pass down for a more refined search\n * @param options.accountAddresses - the account addresses that you want to filter by\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalancesV4(\n options: { accountAddresses?: CaipAccountAddress[]; networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrlV4({\n accountAddresses: options?.accountAddresses?.join(),\n networks: options?.networks?.join(),\n });\n\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n"]}
@@ -1,12 +1,15 @@
1
+ import type { CaipAccountAddress } from "@metamask/utils";
1
2
  import type { GetBalancesResponse } from "./types.cjs";
2
3
  export declare const MULTICHAIN_ACCOUNTS_DOMAIN = "https://accounts.api.cx.metamask.io";
3
4
  /**
4
5
  * Fetches Supported Networks.
6
+ *
5
7
  * @returns supported networks (decimal)
6
8
  */
7
9
  export declare function fetchSupportedNetworks(): Promise<number[]>;
8
10
  /**
9
11
  * Fetches Balances for multiple networks.
12
+ *
10
13
  * @param address - address to fetch balances from
11
14
  * @param options - params to pass down for a more refined search
12
15
  * @param options.networks - the networks (in decimal) that you want to filter by
@@ -16,4 +19,17 @@ export declare function fetchSupportedNetworks(): Promise<number[]>;
16
19
  export declare function fetchMultiChainBalances(address: string, options: {
17
20
  networks?: number[];
18
21
  }, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
22
+ /**
23
+ * Fetches Balances for multiple networks.
24
+ *
25
+ * @param options - params to pass down for a more refined search
26
+ * @param options.accountAddresses - the account addresses that you want to filter by
27
+ * @param options.networks - the networks (in decimal) that you want to filter by
28
+ * @param platform - indicates whether the platform is extension or mobile
29
+ * @returns a Balances Response
30
+ */
31
+ export declare function fetchMultiChainBalancesV4(options: {
32
+ accountAddresses?: CaipAccountAddress[];
33
+ networks?: number[];
34
+ }, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
19
35
  //# sourceMappingURL=multi-chain-accounts.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-chain-accounts.d.cts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,mBAAmB,EAEpB,oBAAgB;AAEjB,eAAO,MAAM,0BAA0B,wCAAwC,CAAC;AAiBhF;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhE;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAChC,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAWjC"}
1
+ {"version":3,"file":"multi-chain-accounts.d.cts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB;AAE1D,OAAO,KAAK,EAGV,mBAAmB,EAEpB,oBAAgB;AAEjB,eAAO,MAAM,0BAA0B,wCAAwC,CAAC;AA+BhF;;;;GAIG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAChC,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAWjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE;IAAE,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EACzE,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAajC"}
@@ -1,12 +1,15 @@
1
+ import type { CaipAccountAddress } from "@metamask/utils";
1
2
  import type { GetBalancesResponse } from "./types.mjs";
2
3
  export declare const MULTICHAIN_ACCOUNTS_DOMAIN = "https://accounts.api.cx.metamask.io";
3
4
  /**
4
5
  * Fetches Supported Networks.
6
+ *
5
7
  * @returns supported networks (decimal)
6
8
  */
7
9
  export declare function fetchSupportedNetworks(): Promise<number[]>;
8
10
  /**
9
11
  * Fetches Balances for multiple networks.
12
+ *
10
13
  * @param address - address to fetch balances from
11
14
  * @param options - params to pass down for a more refined search
12
15
  * @param options.networks - the networks (in decimal) that you want to filter by
@@ -16,4 +19,17 @@ export declare function fetchSupportedNetworks(): Promise<number[]>;
16
19
  export declare function fetchMultiChainBalances(address: string, options: {
17
20
  networks?: number[];
18
21
  }, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
22
+ /**
23
+ * Fetches Balances for multiple networks.
24
+ *
25
+ * @param options - params to pass down for a more refined search
26
+ * @param options.accountAddresses - the account addresses that you want to filter by
27
+ * @param options.networks - the networks (in decimal) that you want to filter by
28
+ * @param platform - indicates whether the platform is extension or mobile
29
+ * @returns a Balances Response
30
+ */
31
+ export declare function fetchMultiChainBalancesV4(options: {
32
+ accountAddresses?: CaipAccountAddress[];
33
+ networks?: number[];
34
+ }, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
19
35
  //# sourceMappingURL=multi-chain-accounts.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-chain-accounts.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,mBAAmB,EAEpB,oBAAgB;AAEjB,eAAO,MAAM,0BAA0B,wCAAwC,CAAC;AAiBhF;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhE;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAChC,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAWjC"}
1
+ {"version":3,"file":"multi-chain-accounts.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB;AAE1D,OAAO,KAAK,EAGV,mBAAmB,EAEpB,oBAAgB;AAEjB,eAAO,MAAM,0BAA0B,wCAAwC,CAAC;AA+BhF;;;;GAIG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAIhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAChC,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAWjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE;IAAE,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EACzE,QAAQ,EAAE,WAAW,GAAG,QAAQ,gCAajC"}
@@ -7,8 +7,19 @@ const getBalancesUrl = (address, queryParams) => {
7
7
  }
8
8
  return url;
9
9
  };
10
+ const getBalancesUrlV4 = (queryParams) => {
11
+ const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v4/multiaccount/balances`);
12
+ if (queryParams?.networks !== undefined) {
13
+ url.searchParams.append('networks', queryParams.networks);
14
+ }
15
+ if (queryParams?.accountAddresses !== undefined) {
16
+ url.searchParams.append('accountAddresses', queryParams.accountAddresses);
17
+ }
18
+ return url;
19
+ };
10
20
  /**
11
21
  * Fetches Supported Networks.
22
+ *
12
23
  * @returns supported networks (decimal)
13
24
  */
14
25
  export async function fetchSupportedNetworks() {
@@ -18,6 +29,7 @@ export async function fetchSupportedNetworks() {
18
29
  }
19
30
  /**
20
31
  * Fetches Balances for multiple networks.
32
+ *
21
33
  * @param address - address to fetch balances from
22
34
  * @param options - params to pass down for a more refined search
23
35
  * @param options.networks - the networks (in decimal) that you want to filter by
@@ -35,4 +47,25 @@ export async function fetchMultiChainBalances(address, options, platform) {
35
47
  });
36
48
  return response;
37
49
  }
50
+ /**
51
+ * Fetches Balances for multiple networks.
52
+ *
53
+ * @param options - params to pass down for a more refined search
54
+ * @param options.accountAddresses - the account addresses that you want to filter by
55
+ * @param options.networks - the networks (in decimal) that you want to filter by
56
+ * @param platform - indicates whether the platform is extension or mobile
57
+ * @returns a Balances Response
58
+ */
59
+ export async function fetchMultiChainBalancesV4(options, platform) {
60
+ const url = getBalancesUrlV4({
61
+ accountAddresses: options?.accountAddresses?.join(),
62
+ networks: options?.networks?.join(),
63
+ });
64
+ const response = await handleFetch(url, {
65
+ headers: {
66
+ 'x-metamask-clientproduct': `metamask-${platform}`,
67
+ },
68
+ });
69
+ return response;
70
+ }
38
71
  //# sourceMappingURL=multi-chain-accounts.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-chain-accounts.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAQzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,cAAc,GAAG,CACrB,OAAe,EACf,WAAoC,EACpC,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,GAAG,0BAA0B,gBAAgB,OAAO,WAAW,CAChE,CAAC;IAEF,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,0BAA0B,uBAAuB,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAiC,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,WAAW,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,OAAgC,EAChC,QAAgC;IAEhC,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,EAAE;QAClC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;KACpC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAwB,MAAM,WAAW,CAAC,GAAG,EAAE;QAC3D,OAAO,EAAE;YACP,0BAA0B,EAAE,YAAY,QAAQ,EAAE;SACnD;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\n\nimport type {\n GetBalancesQueryParams,\n GetBalancesResponse,\n GetSupportedNetworksResponse,\n} from './types';\n\nexport const MULTICHAIN_ACCOUNTS_DOMAIN = 'https://accounts.api.cx.metamask.io';\n\nconst getBalancesUrl = (\n address: string,\n queryParams?: GetBalancesQueryParams,\n) => {\n const url = new URL(\n `${MULTICHAIN_ACCOUNTS_DOMAIN}/v2/accounts/${address}/balances`,\n );\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n return url;\n};\n\n/**\n * Fetches Supported Networks.\n * @returns supported networks (decimal)\n */\nexport async function fetchSupportedNetworks(): Promise<number[]> {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v1/supportedNetworks`);\n const response: GetSupportedNetworksResponse = await handleFetch(url);\n return response.fullSupport;\n}\n\n/**\n * Fetches Balances for multiple networks.\n * @param address - address to fetch balances from\n * @param options - params to pass down for a more refined search\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalances(\n address: string,\n options: { networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrl(address, {\n networks: options?.networks?.join(),\n });\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n"]}
1
+ {"version":3,"file":"multi-chain-accounts.mjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/multi-chain-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAUzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AAEhF,MAAM,cAAc,GAAG,CACrB,OAAe,EACf,WAAoC,EACpC,EAAE;IACF,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,GAAG,0BAA0B,gBAAgB,OAAO,WAAW,CAChE,CAAC;IAEF,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,WAAsC,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,0BAA0B,2BAA2B,CAAC,CAAC;IAE9E,IAAI,WAAW,EAAE,QAAQ,KAAK,SAAS,EAAE;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KAC3D;IAED,IAAI,WAAW,EAAE,gBAAgB,KAAK,SAAS,EAAE;QAC/C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,kBAAkB,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;KAC3E;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,0BAA0B,uBAAuB,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAiC,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,WAAW,CAAC;AAC9B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,OAAgC,EAChC,QAAgC;IAEhC,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,EAAE;QAClC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;KACpC,CAAC,CAAC;IACH,MAAM,QAAQ,GAAwB,MAAM,WAAW,CAAC,GAAG,EAAE;QAC3D,OAAO,EAAE;YACP,0BAA0B,EAAE,YAAY,QAAQ,EAAE;SACnD;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAyE,EACzE,QAAgC;IAEhC,MAAM,GAAG,GAAG,gBAAgB,CAAC;QAC3B,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE;QACnD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE;KACpC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAwB,MAAM,WAAW,CAAC,GAAG,EAAE;QAC3D,OAAO,EAAE;YACP,0BAA0B,EAAE,YAAY,QAAQ,EAAE;SACnD;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { CaipAccountAddress } from '@metamask/utils';\n\nimport type {\n GetBalancesQueryParams,\n GetBalancesQueryParamsV4,\n GetBalancesResponse,\n GetSupportedNetworksResponse,\n} from './types';\n\nexport const MULTICHAIN_ACCOUNTS_DOMAIN = 'https://accounts.api.cx.metamask.io';\n\nconst getBalancesUrl = (\n address: string,\n queryParams?: GetBalancesQueryParams,\n) => {\n const url = new URL(\n `${MULTICHAIN_ACCOUNTS_DOMAIN}/v2/accounts/${address}/balances`,\n );\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n return url;\n};\n\nconst getBalancesUrlV4 = (queryParams?: GetBalancesQueryParamsV4) => {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v4/multiaccount/balances`);\n\n if (queryParams?.networks !== undefined) {\n url.searchParams.append('networks', queryParams.networks);\n }\n\n if (queryParams?.accountAddresses !== undefined) {\n url.searchParams.append('accountAddresses', queryParams.accountAddresses);\n }\n\n return url;\n};\n\n/**\n * Fetches Supported Networks.\n *\n * @returns supported networks (decimal)\n */\nexport async function fetchSupportedNetworks(): Promise<number[]> {\n const url = new URL(`${MULTICHAIN_ACCOUNTS_DOMAIN}/v1/supportedNetworks`);\n const response: GetSupportedNetworksResponse = await handleFetch(url);\n return response.fullSupport;\n}\n\n/**\n * Fetches Balances for multiple networks.\n *\n * @param address - address to fetch balances from\n * @param options - params to pass down for a more refined search\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalances(\n address: string,\n options: { networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrl(address, {\n networks: options?.networks?.join(),\n });\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n\n/**\n * Fetches Balances for multiple networks.\n *\n * @param options - params to pass down for a more refined search\n * @param options.accountAddresses - the account addresses that you want to filter by\n * @param options.networks - the networks (in decimal) that you want to filter by\n * @param platform - indicates whether the platform is extension or mobile\n * @returns a Balances Response\n */\nexport async function fetchMultiChainBalancesV4(\n options: { accountAddresses?: CaipAccountAddress[]; networks?: number[] },\n platform: 'extension' | 'mobile',\n) {\n const url = getBalancesUrlV4({\n accountAddresses: options?.accountAddresses?.join(),\n networks: options?.networks?.join(),\n });\n\n const response: GetBalancesResponse = await handleFetch(url, {\n headers: {\n 'x-metamask-clientproduct': `metamask-${platform}`,\n },\n });\n return response;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n unprocessedNetworks: number[];\n};\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"","sourcesContent":["export type GetSupportedNetworksResponse = {\n fullSupport: number[];\n partialSupport: {\n balances: number[];\n };\n};\n\nexport type GetBalancesQueryParams = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n /** Whether or not to filter the assets to contain only the tokens existing in the Token API */\n filterSupportedTokens?: boolean;\n /** Specific token addresses to fetch balances for across specified network(s) */\n includeTokenAddresses?: string;\n /** Whether to include balances of the account's staked asset balances */\n includeStakedAssets?: boolean;\n};\n\nexport type GetBalancesQueryParamsV4 = {\n /** Comma-separated network/chain IDs */\n networks?: string;\n\n /** Comma-separated account addresses */\n accountAddresses?: string;\n};\n\nexport type GetBalancesResponse = {\n count: number;\n balances: {\n /** Underlying object type. Seems to be always `token` */\n object: string;\n /** Token Type: This is only supplied as `native` to native chain tokens (e.g. - ETH, POL) */\n type?: string;\n /** Timestamp is only provided for `native` chain tokens */\n timestamp?: string;\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n chainId: number;\n /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */\n balance: string;\n /** Account address for V4 API responses */\n accountAddress?: string;\n }[];\n /** networks that failed to process, if no network is processed, returns HTTP 422 */\n unprocessedNetworks: number[];\n};\n"]}
@@ -14,6 +14,12 @@ export type GetBalancesQueryParams = {
14
14
  /** Whether to include balances of the account's staked asset balances */
15
15
  includeStakedAssets?: boolean;
16
16
  };
17
+ export type GetBalancesQueryParamsV4 = {
18
+ /** Comma-separated network/chain IDs */
19
+ networks?: string;
20
+ /** Comma-separated account addresses */
21
+ accountAddresses?: string;
22
+ };
17
23
  export type GetBalancesResponse = {
18
24
  count: number;
19
25
  balances: {
@@ -30,6 +36,8 @@ export type GetBalancesResponse = {
30
36
  chainId: number;
31
37
  /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */
32
38
  balance: string;
39
+ /** Account address for V4 API responses */
40
+ accountAddress?: string;
33
41
  }[];
34
42
  /** networks that failed to process, if no network is processed, returns HTTP 422 */
35
43
  unprocessedNetworks: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAA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iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,yDAAyD;QACzD,MAAM,EAAE,MAAM,CAAC;QACf,6FAA6F;QAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2DAA2D;QAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oGAAoG;QACpG,OAAO,EAAE,MAAM,CAAC;QAChB,2CAA2C;QAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC"}
@@ -14,6 +14,12 @@ export type GetBalancesQueryParams = {
14
14
  /** Whether to include balances of the account's staked asset balances */
15
15
  includeStakedAssets?: boolean;
16
16
  };
17
+ export type GetBalancesQueryParamsV4 = {
18
+ /** Comma-separated network/chain IDs */
19
+ networks?: string;
20
+ /** Comma-separated account addresses */
21
+ accountAddresses?: string;
22
+ };
17
23
  export type GetBalancesResponse = {
18
24
  count: number;
19
25
  balances: {
@@ -30,6 +36,8 @@ export type GetBalancesResponse = {
30
36
  chainId: number;
31
37
  /** string representation of the balance in decimal format (decimals adjusted). e.g. - 123.456789 */
32
38
  balance: string;
39
+ /** Account address for V4 API responses */
40
+ accountAddress?: string;
33
41
  }[];
34
42
  /** networks that failed to process, if no network is processed, returns HTTP 422 */
35
43
  unprocessedNetworks: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+FAA+F;IAC/F,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,yDAAyD;QACzD,MAAM,EAAE,MAAM,CAAC;QACf,6FAA6F;QAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2DAA2D;QAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,oGAAoG;QACpG,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ,qFAAqF;IACrF,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC"}
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/multi-chain-accounts-service/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;I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