@swapkit/helpers 3.0.0-beta.17 → 3.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +3 -3
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +6 -6
- package/dist/index.js +3 -3
- package/dist/index.js.map +6 -6
- package/package.json +2 -2
- package/src/api/swapkitApi/endpoints.ts +15 -8
- package/src/modules/__tests__/assetValue.test.ts +3 -2
- package/src/modules/assetValue.ts +5 -1
- package/src/modules/requestClient.ts +2 -5
- package/src/modules/swapKitError.ts +1 -0
|
@@ -27,6 +27,8 @@ import { BigIntArithmetics, formatBigIntToSafeValue } from "./bigIntArithmetics"
|
|
|
27
27
|
import { SwapKitError } from "./swapKitError";
|
|
28
28
|
import type { SwapKitValueType } from "./swapKitNumber";
|
|
29
29
|
|
|
30
|
+
const CASE_SENSITIVE_CHAINS = [Chain.Solana, Chain.Tron];
|
|
31
|
+
|
|
30
32
|
const staticTokensMap = new Map<
|
|
31
33
|
TokenNames | string,
|
|
32
34
|
{ tax?: TokenTax; decimal: number; identifier: string }
|
|
@@ -372,7 +374,9 @@ function getAssetBaseInfo({ symbol, chain }: { symbol: string; chain: Chain }) {
|
|
|
372
374
|
const unformattedAddress =
|
|
373
375
|
splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
374
376
|
|
|
375
|
-
const address =
|
|
377
|
+
const address = CASE_SENSITIVE_CHAINS.includes(chain)
|
|
378
|
+
? unformattedAddress
|
|
379
|
+
: unformattedAddress?.toLowerCase();
|
|
376
380
|
const ticker = (
|
|
377
381
|
splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-")
|
|
378
382
|
) as string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SKConfig } from "./swapKitConfig";
|
|
2
1
|
import { SwapKitError } from "./swapKitError";
|
|
3
2
|
|
|
4
3
|
type Options = RequestInit & {
|
|
@@ -10,6 +9,7 @@ type Options = RequestInit & {
|
|
|
10
9
|
onError?: (error: any) => any;
|
|
11
10
|
onSuccess?: (response: any) => any;
|
|
12
11
|
searchParams?: Record<string, string>;
|
|
12
|
+
getDynamicHeader?: () => Record<string, string> | {};
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const RequestClient = {
|
|
@@ -31,7 +31,7 @@ function fetchWithConfig(method: "GET" | "POST", extendOptions: Options = {}) {
|
|
|
31
31
|
|
|
32
32
|
try {
|
|
33
33
|
const requestUrl = buildUrl(url, searchParams);
|
|
34
|
-
const headers = buildHeaders(isJson, headersOptions);
|
|
34
|
+
const headers = buildHeaders(isJson, { ...headersOptions, ...options.getDynamicHeader?.() });
|
|
35
35
|
|
|
36
36
|
const response = await fetch(requestUrl, { ...options, method, body: bodyToSend, headers });
|
|
37
37
|
|
|
@@ -57,12 +57,9 @@ function fetchWithConfig(method: "GET" | "POST", extendOptions: Options = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function buildHeaders(isJson: boolean, headersOptions?: HeadersInit) {
|
|
60
|
-
const { swapKit } = SKConfig.get("apiKeys");
|
|
61
|
-
|
|
62
60
|
return {
|
|
63
61
|
...headersOptions,
|
|
64
62
|
...(isJson ? { "Content-Type": "application/json" } : {}),
|
|
65
|
-
...(swapKit ? { "x-api-key": swapKit } : {}),
|
|
66
63
|
};
|
|
67
64
|
}
|
|
68
65
|
|