@metamask-previews/assets-controllers 87.1.0-preview-d41a7f35 → 87.1.0-preview-ee982ebe
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 +0 -16
- package/dist/TokenBalancesController.cjs +0 -2
- package/dist/TokenBalancesController.cjs.map +1 -1
- package/dist/TokenBalancesController.d.cts +1 -2
- package/dist/TokenBalancesController.d.cts.map +1 -1
- package/dist/TokenBalancesController.d.mts +1 -2
- package/dist/TokenBalancesController.d.mts.map +1 -1
- package/dist/TokenBalancesController.mjs +0 -2
- package/dist/TokenBalancesController.mjs.map +1 -1
- package/dist/TokenDetectionController.cjs +11 -30
- package/dist/TokenDetectionController.cjs.map +1 -1
- package/dist/TokenDetectionController.d.cts +1 -2
- package/dist/TokenDetectionController.d.cts.map +1 -1
- package/dist/TokenDetectionController.d.mts +1 -2
- package/dist/TokenDetectionController.d.mts.map +1 -1
- package/dist/TokenDetectionController.mjs +11 -30
- package/dist/TokenDetectionController.mjs.map +1 -1
- package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs +5 -5
- package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs.map +1 -1
- package/dist/multi-chain-accounts-service/api-balance-fetcher.d.cts +1 -2
- package/dist/multi-chain-accounts-service/api-balance-fetcher.d.cts.map +1 -1
- package/dist/multi-chain-accounts-service/api-balance-fetcher.d.mts +1 -2
- package/dist/multi-chain-accounts-service/api-balance-fetcher.d.mts.map +1 -1
- package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs +5 -5
- package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs.map +1 -1
- package/dist/multi-chain-accounts-service/multi-chain-accounts.cjs +8 -18
- package/dist/multi-chain-accounts-service/multi-chain-accounts.cjs.map +1 -1
- package/dist/multi-chain-accounts-service/multi-chain-accounts.d.cts +2 -4
- package/dist/multi-chain-accounts-service/multi-chain-accounts.d.cts.map +1 -1
- package/dist/multi-chain-accounts-service/multi-chain-accounts.d.mts +2 -4
- package/dist/multi-chain-accounts-service/multi-chain-accounts.d.mts.map +1 -1
- package/dist/multi-chain-accounts-service/multi-chain-accounts.mjs +8 -18
- package/dist/multi-chain-accounts-service/multi-chain-accounts.mjs.map +1 -1
- package/package.json +1 -3
|
@@ -38,21 +38,16 @@ exports.fetchSupportedNetworks = fetchSupportedNetworks;
|
|
|
38
38
|
* @param options - params to pass down for a more refined search
|
|
39
39
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
40
40
|
* @param platform - indicates whether the platform is extension or mobile
|
|
41
|
-
* @param jwtToken - optional JWT token for authentication
|
|
42
41
|
* @returns a Balances Response
|
|
43
42
|
*/
|
|
44
|
-
async function fetchMultiChainBalances(address, options, platform
|
|
43
|
+
async function fetchMultiChainBalances(address, options, platform) {
|
|
45
44
|
const url = getBalancesUrl(address, {
|
|
46
45
|
networks: options?.networks?.join(),
|
|
47
46
|
});
|
|
48
|
-
const headers = {
|
|
49
|
-
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
50
|
-
};
|
|
51
|
-
if (jwtToken) {
|
|
52
|
-
headers.Authorization = `Bearer ${jwtToken}`;
|
|
53
|
-
}
|
|
54
47
|
const response = await (0, controller_utils_1.handleFetch)(url, {
|
|
55
|
-
headers
|
|
48
|
+
headers: {
|
|
49
|
+
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
50
|
+
},
|
|
56
51
|
});
|
|
57
52
|
return response;
|
|
58
53
|
}
|
|
@@ -64,22 +59,17 @@ exports.fetchMultiChainBalances = fetchMultiChainBalances;
|
|
|
64
59
|
* @param options.accountAddresses - the account addresses that you want to filter by
|
|
65
60
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
66
61
|
* @param platform - indicates whether the platform is extension or mobile
|
|
67
|
-
* @param jwtToken - optional JWT token for authentication
|
|
68
62
|
* @returns a Balances Response
|
|
69
63
|
*/
|
|
70
|
-
async function fetchMultiChainBalancesV4(options, platform
|
|
64
|
+
async function fetchMultiChainBalancesV4(options, platform) {
|
|
71
65
|
const url = getBalancesUrlV4({
|
|
72
66
|
accountAddresses: options?.accountAddresses?.join(),
|
|
73
67
|
networks: options?.networks?.join(),
|
|
74
68
|
});
|
|
75
|
-
const headers = {
|
|
76
|
-
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
77
|
-
};
|
|
78
|
-
if (jwtToken) {
|
|
79
|
-
headers.Authorization = `Bearer ${jwtToken}`;
|
|
80
|
-
}
|
|
81
69
|
const response = await (0, controller_utils_1.handleFetch)(url, {
|
|
82
|
-
headers
|
|
70
|
+
headers: {
|
|
71
|
+
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
72
|
+
},
|
|
83
73
|
});
|
|
84
74
|
return response;
|
|
85
75
|
}
|
|
@@ -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;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,QAA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C;IACH,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"]}
|
|
@@ -14,12 +14,11 @@ export declare function fetchSupportedNetworks(): Promise<number[]>;
|
|
|
14
14
|
* @param options - params to pass down for a more refined search
|
|
15
15
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
16
16
|
* @param platform - indicates whether the platform is extension or mobile
|
|
17
|
-
* @param jwtToken - optional JWT token for authentication
|
|
18
17
|
* @returns a Balances Response
|
|
19
18
|
*/
|
|
20
19
|
export declare function fetchMultiChainBalances(address: string, options: {
|
|
21
20
|
networks?: number[];
|
|
22
|
-
}, platform: 'extension' | 'mobile'
|
|
21
|
+
}, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
|
|
23
22
|
/**
|
|
24
23
|
* Fetches Balances for multiple networks.
|
|
25
24
|
*
|
|
@@ -27,11 +26,10 @@ export declare function fetchMultiChainBalances(address: string, options: {
|
|
|
27
26
|
* @param options.accountAddresses - the account addresses that you want to filter by
|
|
28
27
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
29
28
|
* @param platform - indicates whether the platform is extension or mobile
|
|
30
|
-
* @param jwtToken - optional JWT token for authentication
|
|
31
29
|
* @returns a Balances Response
|
|
32
30
|
*/
|
|
33
31
|
export declare function fetchMultiChainBalancesV4(options: {
|
|
34
32
|
accountAddresses?: CaipAccountAddress[];
|
|
35
33
|
networks?: number[];
|
|
36
|
-
}, platform: 'extension' | 'mobile'
|
|
34
|
+
}, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
|
|
37
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":"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
|
|
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"}
|
|
@@ -14,12 +14,11 @@ export declare function fetchSupportedNetworks(): Promise<number[]>;
|
|
|
14
14
|
* @param options - params to pass down for a more refined search
|
|
15
15
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
16
16
|
* @param platform - indicates whether the platform is extension or mobile
|
|
17
|
-
* @param jwtToken - optional JWT token for authentication
|
|
18
17
|
* @returns a Balances Response
|
|
19
18
|
*/
|
|
20
19
|
export declare function fetchMultiChainBalances(address: string, options: {
|
|
21
20
|
networks?: number[];
|
|
22
|
-
}, platform: 'extension' | 'mobile'
|
|
21
|
+
}, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
|
|
23
22
|
/**
|
|
24
23
|
* Fetches Balances for multiple networks.
|
|
25
24
|
*
|
|
@@ -27,11 +26,10 @@ export declare function fetchMultiChainBalances(address: string, options: {
|
|
|
27
26
|
* @param options.accountAddresses - the account addresses that you want to filter by
|
|
28
27
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
29
28
|
* @param platform - indicates whether the platform is extension or mobile
|
|
30
|
-
* @param jwtToken - optional JWT token for authentication
|
|
31
29
|
* @returns a Balances Response
|
|
32
30
|
*/
|
|
33
31
|
export declare function fetchMultiChainBalancesV4(options: {
|
|
34
32
|
accountAddresses?: CaipAccountAddress[];
|
|
35
33
|
networks?: number[];
|
|
36
|
-
}, platform: 'extension' | 'mobile'
|
|
34
|
+
}, platform: 'extension' | 'mobile'): Promise<GetBalancesResponse>;
|
|
37
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":"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
|
|
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"}
|
|
@@ -34,21 +34,16 @@ export async function fetchSupportedNetworks() {
|
|
|
34
34
|
* @param options - params to pass down for a more refined search
|
|
35
35
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
36
36
|
* @param platform - indicates whether the platform is extension or mobile
|
|
37
|
-
* @param jwtToken - optional JWT token for authentication
|
|
38
37
|
* @returns a Balances Response
|
|
39
38
|
*/
|
|
40
|
-
export async function fetchMultiChainBalances(address, options, platform
|
|
39
|
+
export async function fetchMultiChainBalances(address, options, platform) {
|
|
41
40
|
const url = getBalancesUrl(address, {
|
|
42
41
|
networks: options?.networks?.join(),
|
|
43
42
|
});
|
|
44
|
-
const headers = {
|
|
45
|
-
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
46
|
-
};
|
|
47
|
-
if (jwtToken) {
|
|
48
|
-
headers.Authorization = `Bearer ${jwtToken}`;
|
|
49
|
-
}
|
|
50
43
|
const response = await handleFetch(url, {
|
|
51
|
-
headers
|
|
44
|
+
headers: {
|
|
45
|
+
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
46
|
+
},
|
|
52
47
|
});
|
|
53
48
|
return response;
|
|
54
49
|
}
|
|
@@ -59,22 +54,17 @@ export async function fetchMultiChainBalances(address, options, platform, jwtTok
|
|
|
59
54
|
* @param options.accountAddresses - the account addresses that you want to filter by
|
|
60
55
|
* @param options.networks - the networks (in decimal) that you want to filter by
|
|
61
56
|
* @param platform - indicates whether the platform is extension or mobile
|
|
62
|
-
* @param jwtToken - optional JWT token for authentication
|
|
63
57
|
* @returns a Balances Response
|
|
64
58
|
*/
|
|
65
|
-
export async function fetchMultiChainBalancesV4(options, platform
|
|
59
|
+
export async function fetchMultiChainBalancesV4(options, platform) {
|
|
66
60
|
const url = getBalancesUrlV4({
|
|
67
61
|
accountAddresses: options?.accountAddresses?.join(),
|
|
68
62
|
networks: options?.networks?.join(),
|
|
69
63
|
});
|
|
70
|
-
const headers = {
|
|
71
|
-
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
72
|
-
};
|
|
73
|
-
if (jwtToken) {
|
|
74
|
-
headers.Authorization = `Bearer ${jwtToken}`;
|
|
75
|
-
}
|
|
76
64
|
const response = await handleFetch(url, {
|
|
77
|
-
headers
|
|
65
|
+
headers: {
|
|
66
|
+
'x-metamask-clientproduct': `metamask-${platform}`,
|
|
67
|
+
},
|
|
78
68
|
});
|
|
79
69
|
return response;
|
|
80
70
|
}
|
|
@@ -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;AAUzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AAEh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AAE;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/assets-controllers",
|
|
3
|
-
"version": "87.1.0-preview-
|
|
3
|
+
"version": "87.1.0-preview-ee982ebe",
|
|
4
4
|
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
"@metamask/permission-controller": "^12.1.0",
|
|
97
97
|
"@metamask/phishing-controller": "^15.0.0",
|
|
98
98
|
"@metamask/preferences-controller": "^21.0.0",
|
|
99
|
-
"@metamask/profile-sync-controller": "^26.0.0",
|
|
100
99
|
"@metamask/providers": "^22.1.0",
|
|
101
100
|
"@metamask/snaps-controllers": "^14.0.1",
|
|
102
101
|
"@metamask/transaction-controller": "^61.1.0",
|
|
@@ -125,7 +124,6 @@
|
|
|
125
124
|
"@metamask/permission-controller": "^12.0.0",
|
|
126
125
|
"@metamask/phishing-controller": "^15.0.0",
|
|
127
126
|
"@metamask/preferences-controller": "^21.0.0",
|
|
128
|
-
"@metamask/profile-sync-controller": "^26.0.0",
|
|
129
127
|
"@metamask/providers": "^22.0.0",
|
|
130
128
|
"@metamask/snaps-controllers": "^14.0.0",
|
|
131
129
|
"@metamask/transaction-controller": "^61.0.0",
|