@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.
@@ -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 = chain === Chain.Solana ? unformattedAddress : unformattedAddress?.toLowerCase();
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
 
@@ -333,6 +333,7 @@ const errorCodes = {
333
333
  toolbox_tron_no_signer: 50801,
334
334
  toolbox_tron_invalid_token_identifier: 50802,
335
335
  toolbox_tron_token_transfer_failed: 50803,
336
+ toolbox_tron_transaction_creation_failed: 50804,
336
337
  /**
337
338
  * Toolboxes - Near
338
339
  */