@swapkit/core 1.0.0-rc.119 → 1.0.0-rc.120

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/package.json CHANGED
@@ -1,35 +1,26 @@
1
1
  {
2
2
  "author": "swapkit-oss",
3
3
  "dependencies": {
4
- "@swapkit/helpers": "1.0.0-rc.83",
5
- "@swapkit/types": "1.0.0-rc.47"
4
+ "@swapkit/helpers": "1.0.0-rc.84",
5
+ "@swapkit/types": "1.0.0-rc.48"
6
6
  },
7
- "description": "SwapKit Lib core",
7
+ "description": "SwapKit - Core",
8
8
  "devDependencies": {
9
- "@vitest/coverage-istanbul": "1.4.0",
10
- "vite": "5.1.6",
11
- "vitest": "1.4.0",
12
- "@swapkit/tokens": "1.0.0-rc.44",
13
- "@swapkit/toolbox-cosmos": "1.0.0-rc.100",
14
- "@swapkit/toolbox-evm": "1.0.0-rc.89",
15
- "@swapkit/toolbox-substrate": "1.0.0-rc.18",
16
- "@swapkit/toolbox-utxo": "1.0.0-rc.91"
9
+ "@swapkit/tokens": "1.0.0-rc.45",
10
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.101",
11
+ "@swapkit/toolbox-evm": "1.0.0-rc.90",
12
+ "@swapkit/toolbox-substrate": "1.0.0-rc.19",
13
+ "@swapkit/toolbox-utxo": "1.0.0-rc.92",
14
+ "bun-types": "1.1.1"
17
15
  },
18
16
  "peerDependencies": {
19
- "@swapkit/helpers": "1.0.0-rc.83",
20
- "@swapkit/tokens": "1.0.0-rc.44",
21
- "@swapkit/toolbox-evm": "1.0.0-rc.89",
22
- "@swapkit/toolbox-cosmos": "1.0.0-rc.100",
23
- "@swapkit/toolbox-substrate": "1.0.0-rc.18",
24
- "@swapkit/toolbox-utxo": "1.0.0-rc.91",
25
- "@swapkit/types": "1.0.0-rc.47"
26
- },
27
- "exports": {
28
- ".": {
29
- "import": "./dist/index.es.js",
30
- "require": "./dist/index.cjs",
31
- "types": "./dist/index.d.ts"
32
- }
17
+ "@swapkit/helpers": "1.0.0-rc.84",
18
+ "@swapkit/tokens": "1.0.0-rc.45",
19
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.101",
20
+ "@swapkit/toolbox-evm": "1.0.0-rc.90",
21
+ "@swapkit/toolbox-substrate": "1.0.0-rc.19",
22
+ "@swapkit/toolbox-utxo": "1.0.0-rc.92",
23
+ "@swapkit/types": "1.0.0-rc.48"
33
24
  },
34
25
  "files": [
35
26
  "src/",
@@ -37,22 +28,22 @@
37
28
  ],
38
29
  "homepage": "https://github.com/thorswap/SwapKit",
39
30
  "license": "Apache-2.0",
40
- "main": "./dist/index.cjs",
41
- "module": "./dist/index.es.js",
31
+ "main": "./dist/index.js",
42
32
  "name": "@swapkit/core",
43
33
  "react-native": "./src/index.ts",
44
34
  "repository": {
45
35
  "type": "git",
46
36
  "url": "git+https://github.com/thorswap/SwapKit.git"
47
37
  },
48
- "type": "module",
49
- "types": "./dist/index.d.ts",
50
- "version": "1.0.0-rc.119",
51
38
  "scripts": {
52
- "build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
53
- "clean": "rm -rf dist vite.config.ts.* node_modules",
39
+ "build": "bun run ./build.ts",
40
+ "clean": "rm -rf .turbo dist node_modules tsconfig.tsbuildinfo",
54
41
  "lint": "biome check --apply ./src",
55
- "test": "vitest --run",
56
- "test:coverage": "vitest run --coverage"
57
- }
58
- }
42
+ "test": "echo 'bun test'",
43
+ "test:coverage": "echo 'bun test --coverage'",
44
+ "type-check": "tsc --noEmit"
45
+ },
46
+ "type": "module",
47
+ "types": "./src/index.ts",
48
+ "version": "1.0.0-rc.120"
49
+ }
@@ -1,10 +1,10 @@
1
+ import { describe, expect, test } from "bun:test";
1
2
  import { Chain, ChainToExplorerUrl, CosmosChains, EVMChains, UTXOChains } from "@swapkit/types";
2
- import { describe, expect, test } from "vitest";
3
3
  import { getExplorerAddressUrl, getExplorerTxUrl } from "../helpers/explorerUrls.ts";
4
4
 
5
5
  describe("Explorer URLs", () => {
6
6
  describe("CosmosChains", () => {
7
- for (const chain of CosmosChains.filter((c) => c !== Chain.Cosmos)) {
7
+ for (const chain of CosmosChains) {
8
8
  test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
9
9
  expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
10
10
  `${ChainToExplorerUrl[chain]}/tx/123456789`,
@@ -15,16 +15,6 @@ describe("Explorer URLs", () => {
15
15
  );
16
16
  });
17
17
  }
18
-
19
- test(`getExplorerTxUrl returns correct URL for ${Chain.Cosmos}`, () => {
20
- expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: "0x123456789" })).toBe(
21
- `${ChainToExplorerUrl[Chain.Cosmos]}/transactions/0x123456789`,
22
- );
23
-
24
- expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: "asdfg" })).toBe(
25
- `${ChainToExplorerUrl[Chain.Cosmos]}/account/asdfg`,
26
- );
27
- });
28
18
  });
29
19
 
30
20
  describe("EVMChains & SubstrateChains", () => {
@@ -60,18 +50,4 @@ describe("Explorer URLs", () => {
60
50
  });
61
51
  }
62
52
  });
63
-
64
- describe("Unsupported chains", () => {
65
- test("getExplorerTxUrl throws Error for unsupported Chain", () => {
66
- expect(() =>
67
- getExplorerTxUrl({ chain: "unsupported" as Chain, txHash: "0x12345" }),
68
- ).toThrowError("Unsupported chain: unsupported");
69
- });
70
-
71
- test("getExplorerAddressUrl throws Error for unsupported Chain", () => {
72
- expect(() =>
73
- getExplorerAddressUrl({ chain: "unsupported" as Chain, address: "asdfg" }),
74
- ).toThrowError("Unsupported chain: unsupported");
75
- });
76
- });
77
53
  });
@@ -34,7 +34,7 @@ type GenericSwapParams = {
34
34
  export type SwapParams = (SwapWithRouteParams | GenericSwapParams) & {
35
35
  provider?: {
36
36
  name: PluginName;
37
- config: Record<string, any>;
37
+ config: Record<string, Todo>;
38
38
  };
39
39
  };
40
40
 
@@ -46,8 +46,8 @@ export type SwapKitReturnType = SwapKitPlugins & {
46
46
  potentialScamFilter?: boolean,
47
47
  ) => Promise<ChainWallet<Chain>>;
48
48
  getBalance: (chain: Chain, potentialScamFilter?: boolean) => AssetValue[];
49
- getExplorerTxUrl: (chain: Chain, txHash: string) => string;
50
- getExplorerAddressUrl: (chain: Chain, address: string) => string;
49
+ getExplorerTxUrl: typeof getTxUrl;
50
+ getExplorerAddressUrl: typeof getAddressUrl;
51
51
  swap: (params: SwapParams) => Promise<string>;
52
52
  validateAddress: (params: { address: string; chain: Chain }) =>
53
53
  | boolean
@@ -64,7 +64,7 @@ export type Wallets = { [K in Chain]?: ChainWallet<K> };
64
64
  export type AvailableProviders<T> = T | { [K in PluginName]?: ProviderMethods };
65
65
  export type ProviderMethods = {
66
66
  swap: (swapParams: SwapParams) => Promise<string>;
67
- [key: string]: any;
67
+ [key: string]: Todo;
68
68
  };
69
69
 
70
70
  export type SwapKitPlugin = ({ wallets, stagenet }: { wallets: Wallets; stagenet?: boolean }) => {
@@ -74,12 +74,12 @@ export type SwapKitPlugin = ({ wallets, stagenet }: { wallets: Wallets; stagenet
74
74
 
75
75
  export type SwapKitWallet = {
76
76
  connectMethodName: string;
77
- connect: (params: ConnectWalletParams) => (connectParams: any) => undefined | string;
77
+ connect: (params: ConnectWalletParams) => (connectParams: Todo) => undefined | string;
78
78
  };
79
79
 
80
80
  export function SwapKit<
81
81
  ExtendedProviders extends {},
82
- ConnectWalletMethods extends Record<string, ReturnType<SwapKitWallet["connect"]>>,
82
+ ConnectWalletMethods = Record<string, ReturnType<SwapKitWallet["connect"]>>,
83
83
  >({
84
84
  stagenet,
85
85
  wallets,
@@ -91,9 +91,9 @@ export function SwapKit<
91
91
  plugins: SwapKitPlugin[];
92
92
  stagenet: boolean;
93
93
  wallets: SwapKitWallet[];
94
- config?: Record<string, any>;
95
- apis: Record<string, any>;
96
- rpcUrls: Record<string, any>;
94
+ config?: Record<string, Todo>;
95
+ apis: Record<string, Todo>;
96
+ rpcUrls: Record<string, Todo>;
97
97
  }): SwapKitReturnType & ConnectWalletMethods & AvailableProviders<ExtendedProviders> {
98
98
  const connectedWallets: Wallets = {};
99
99
  const availablePlugins: AvailableProviders<ExtendedProviders> = {};
@@ -105,7 +105,8 @@ export function SwapKit<
105
105
  }
106
106
 
107
107
  const connectWalletMethods = wallets.reduce((acc, wallet) => {
108
- (acc[wallet.connectMethodName] as ReturnType<SwapKitWallet["connect"]>) = wallet.connect({
108
+ // @ts-expect-error
109
+ acc[wallet.connectMethodName] = wallet.connect({
109
110
  addChain,
110
111
  config,
111
112
  apis,
@@ -190,12 +191,6 @@ export function SwapKit<
190
191
  function getBalance(chain: Chain) {
191
192
  return getWallet(chain)?.balance || [];
192
193
  }
193
- function getExplorerTxUrl(chain: Chain, txHash: string) {
194
- return getTxUrl({ chain, txHash });
195
- }
196
- function getExplorerAddressUrl(chain: Chain, address: string) {
197
- return getAddressUrl({ chain, address });
198
- }
199
194
  /**
200
195
  * TODO: Figure out validation without connecting to wallet
201
196
  */
@@ -207,16 +202,14 @@ export function SwapKit<
207
202
  const defaultBalance = [AssetValue.fromChainOrSignature(chain)];
208
203
  const wallet = getWallet(chain);
209
204
 
210
- try {
211
- if (!wallet) throw new SwapKitError("core_wallet_connection_not_found");
212
- const balance = await wallet?.getBalance(wallet.address, potentialScamFilter);
205
+ if (!wallet) {
206
+ throw new SwapKitError("core_wallet_connection_not_found");
207
+ }
213
208
 
214
- wallet.balance = balance?.length ? balance : defaultBalance;
209
+ const balance = await wallet?.getBalance(wallet.address, potentialScamFilter);
210
+ wallet.balance = balance?.length ? balance : defaultBalance;
215
211
 
216
- return wallet;
217
- } catch (error) {
218
- throw new SwapKitError("core_wallet_connection_not_found", error);
219
- }
212
+ return wallet;
220
213
  }
221
214
 
222
215
  /**
@@ -240,11 +233,13 @@ export function SwapKit<
240
233
  return {
241
234
  ...availablePlugins,
242
235
  ...connectWalletMethods,
236
+
237
+ getExplorerAddressUrl: getAddressUrl,
238
+ getExplorerTxUrl: getTxUrl,
239
+
243
240
  approveAssetValue,
244
241
  getAddress,
245
242
  getBalance,
246
- getExplorerAddressUrl,
247
- getExplorerTxUrl,
248
243
  getWallet,
249
244
  getWalletWithBalance,
250
245
  isAssetValueApproved,
package/src/client/old.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { ErrorKeys, QuoteRoute, ThornameRegisterParam } from "@swapkit/helpers";
2
2
  import {
3
3
  AssetValue,
4
+ SwapKitApi,
4
5
  SwapKitError,
5
6
  SwapKitNumber,
6
7
  gasFeeMultiplier,
7
8
  getMemoFor,
8
9
  getMinAmountByChain,
10
+ wrapWithThrow,
9
11
  } from "@swapkit/helpers";
10
12
  import type { CosmosLikeToolbox } from "@swapkit/toolbox-cosmos";
11
13
  import type { AVAXToolbox, BSCToolbox, ETHToolbox, EVMToolbox } from "@swapkit/toolbox-evm";
@@ -35,8 +37,6 @@ import { lowercasedContractAbiMapping } from "../aggregator/contracts/index.ts";
35
37
  import { getSwapInParams } from "../aggregator/getSwapParams.ts";
36
38
 
37
39
  import { getExplorerAddressUrl, getExplorerTxUrl } from "../helpers/explorerUrls.ts";
38
- import { getMayaMimirData } from "../helpers/mayanode.js";
39
- import { getThorInboundData, getThorMimirData } from "../helpers/thornode.ts";
40
40
  import type {
41
41
  CoreTxParams,
42
42
  EVMWallet,
@@ -266,7 +266,9 @@ export class SwapKitCore<T = ""> {
266
266
  if (!walletInstance) throw new SwapKitError("core_wallet_connection_not_found");
267
267
 
268
268
  try {
269
- return await walletInstance.transfer(this.#prepareTxParams(params));
269
+ const tx = await walletInstance.transfer(this.#prepareTxParams(params));
270
+
271
+ return tx;
270
272
  } catch (error) {
271
273
  throw new SwapKitError("core_swap_transaction_error", error);
272
274
  }
@@ -290,8 +292,9 @@ export class SwapKitCore<T = ""> {
290
292
  if (!isAddressValidated) {
291
293
  throw new SwapKitError("core_transaction_invalid_sender_address");
292
294
  }
293
-
294
- if (!walletInstance) throw new SwapKitError("core_wallet_connection_not_found");
295
+ if (!walletInstance) {
296
+ throw new SwapKitError("core_wallet_connection_not_found");
297
+ }
295
298
 
296
299
  const params = this.#prepareTxParams({
297
300
  assetValue,
@@ -305,7 +308,8 @@ export class SwapKitCore<T = ""> {
305
308
  case Chain.THORChain:
306
309
  case Chain.Maya: {
307
310
  const wallet = walletInstance as ThorchainWallet;
308
- return await (recipient === "" ? wallet.deposit(params) : wallet.transfer(params));
311
+ const tx = await (recipient === "" ? wallet.deposit(params) : wallet.transfer(params));
312
+ return tx;
309
313
  }
310
314
 
311
315
  case Chain.Ethereum:
@@ -320,9 +324,11 @@ export class SwapKitCore<T = ""> {
320
324
  ? TCBscDepositABI
321
325
  : TCEthereumVaultAbi;
322
326
 
323
- const response = await (
324
- walletInstance as EVMWallet<typeof AVAXToolbox | typeof ETHToolbox | typeof BSCToolbox>
325
- ).call({
327
+ const wallet = walletInstance as EVMWallet<
328
+ typeof AVAXToolbox | typeof ETHToolbox | typeof BSCToolbox
329
+ >;
330
+
331
+ const response = await wallet.call({
326
332
  abi,
327
333
  contractAddress:
328
334
  router || ((await this.#getInboundDataByChain(chain as EVMChain)).router as string),
@@ -345,12 +351,15 @@ export class SwapKitCore<T = ""> {
345
351
  }
346
352
 
347
353
  default: {
348
- return await walletInstance.transfer(params);
354
+ const tx = await walletInstance.transfer(params);
355
+ return tx;
349
356
  }
350
357
  }
351
- } catch (error: any) {
358
+ } catch (error) {
352
359
  const errorMessage =
353
- typeof error === "string" ? error.toLowerCase() : error?.message.toLowerCase();
360
+ // @ts-expect-error - this is fine as we are checking for string
361
+ typeof error === "string" ? error.toLowerCase() : error?.message?.toLowerCase();
362
+
354
363
  const isInsufficientFunds = errorMessage?.includes("insufficient funds");
355
364
  const isGas = errorMessage?.includes("gas");
356
365
  const isServer = errorMessage?.includes("server");
@@ -383,32 +392,22 @@ export class SwapKitCore<T = ""> {
383
392
  throw new SwapKitError("core_transaction_create_liquidity_invalid_params");
384
393
  }
385
394
 
386
- let runeTx = "";
387
- let assetTx = "";
395
+ const assetAddress = this.getAddress(assetValue.chain);
396
+ const runeAddress = this.getAddress(Chain.THORChain);
388
397
 
389
- try {
390
- runeTx = await this.#depositToPool({
398
+ const runeTx = await wrapWithThrow(() => {
399
+ return this.#depositToPool({
391
400
  assetValue: runeAssetValue,
392
- memo: getMemoFor(MemoType.DEPOSIT, {
393
- ...assetValue,
394
- address: this.getAddress(assetValue.chain),
395
- }),
401
+ memo: getMemoFor(MemoType.DEPOSIT, { ...assetValue, address: assetAddress }),
396
402
  });
397
- } catch (error) {
398
- throw new SwapKitError("core_transaction_create_liquidity_rune_error", error);
399
- }
403
+ }, "core_transaction_create_liquidity_rune_error");
400
404
 
401
- try {
402
- assetTx = await this.#depositToPool({
405
+ const assetTx = await wrapWithThrow(() => {
406
+ return this.#depositToPool({
403
407
  assetValue,
404
- memo: getMemoFor(MemoType.DEPOSIT, {
405
- ...assetValue,
406
- address: this.getAddress(Chain.THORChain),
407
- }),
408
+ memo: getMemoFor(MemoType.DEPOSIT, { ...assetValue, address: runeAddress }),
408
409
  });
409
- } catch (error) {
410
- throw new SwapKitError("core_transaction_create_liquidity_asset_error", error);
411
- }
410
+ }, "core_transaction_create_liquidity_asset_error");
412
411
 
413
412
  return { runeTx, assetTx };
414
413
  };
@@ -444,38 +443,22 @@ export class SwapKitCore<T = ""> {
444
443
  throw new SwapKitError("core_transaction_add_liquidity_no_rune_address");
445
444
  }
446
445
 
447
- let runeTx: string | undefined;
448
- let assetTx: string | undefined;
449
-
450
- if (runeTransfer && runeAssetValue) {
451
- try {
452
- runeTx = await this.#depositToPool({
453
- assetValue: runeAssetValue,
454
- memo: getMemoFor(MemoType.DEPOSIT, {
455
- chain,
456
- symbol,
457
- address: assetAddress,
458
- }),
459
- });
460
- } catch (error) {
461
- throw new SwapKitError("core_transaction_add_liquidity_rune_error", error);
462
- }
463
- }
464
-
465
- if (assetTransfer && assetValue) {
466
- try {
467
- assetTx = await this.#depositToPool({
468
- assetValue,
469
- memo: getMemoFor(MemoType.DEPOSIT, {
470
- chain,
471
- symbol,
472
- address: runeAddress,
473
- }),
474
- });
475
- } catch (error) {
476
- throw new SwapKitError("core_transaction_add_liquidity_asset_error", error);
477
- }
478
- }
446
+ const runeTx = await wrapWithThrow(() => {
447
+ return this.#depositToPool({
448
+ assetValue: runeAssetValue,
449
+ memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: assetAddress }),
450
+ });
451
+ }, "core_transaction_add_liquidity_rune_error");
452
+
453
+ const assetTx =
454
+ assetTransfer && assetValue
455
+ ? wrapWithThrow(() => {
456
+ return this.#depositToPool({
457
+ assetValue,
458
+ memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: runeAddress }),
459
+ });
460
+ }, "core_transaction_add_liquidity_asset_error")
461
+ : null;
479
462
 
480
463
  return { runeTx, assetTx };
481
464
  };
@@ -494,9 +477,10 @@ export class SwapKitCore<T = ""> {
494
477
  if (symmetric && !address) {
495
478
  throw new SwapKitError("core_transaction_add_liquidity_invalid_params");
496
479
  }
480
+
497
481
  const memo = getMemoFor(MemoType.DEPOSIT, {
498
482
  chain: poolAddress.split(".")[0] as Chain,
499
- symbol: poolAddress.split(".")[1],
483
+ symbol: poolAddress.split(".")[1] as string,
500
484
  address: symmetric ? address : "",
501
485
  });
502
486
 
@@ -697,7 +681,7 @@ export class SwapKitCore<T = ""> {
697
681
  throw new SwapKitError("core_wallet_evmwallet_not_installed");
698
682
  };
699
683
  // biome-ignore lint/suspicious/useAwait: Extended methods
700
- connectWalletconnect = async (_chains: Chain[], _options?: any): Promise<void> => {
684
+ connectWalletconnect = async (_chains: Chain[], _options?: Todo): Promise<void> => {
701
685
  throw new SwapKitError("core_wallet_walletconnect_not_installed");
702
686
  };
703
687
  // biome-ignore lint/suspicious/useAwait: Extended methods
@@ -737,7 +721,7 @@ export class SwapKitCore<T = ""> {
737
721
  return { gas_rate: "0", router: "", address: "", halted: false, chain };
738
722
 
739
723
  default: {
740
- const inboundData = await getThorInboundData(this.stagenet);
724
+ const inboundData = await SwapKitApi.getInboundAddresses({ stagenet: this.stagenet });
741
725
  const chainAddressData = inboundData.find((item) => item.chain === chain);
742
726
 
743
727
  if (!chainAddressData) throw new SwapKitError("core_inbound_data_not_found");
@@ -754,13 +738,13 @@ export class SwapKitCore<T = ""> {
754
738
  balance,
755
739
  walletType,
756
740
  ...rest
757
- }: AddChainWalletParams<any>) => {
741
+ }: AddChainWalletParams<Todo>) => {
758
742
  this.connectedChains[chain as Chain] = {
759
743
  address: address || "",
760
744
  balance: balance || [],
761
745
  walletType: walletType || "unknown",
762
746
  };
763
- this.connectedWallets[chain as Chain] = { ...rest } as any;
747
+ this.connectedWallets[chain as Chain] = { ...rest } as Todo;
764
748
  };
765
749
 
766
750
  #approve = async <T = string>({
@@ -781,11 +765,15 @@ export class SwapKitCore<T = ""> {
781
765
  const walletMethods = this.connectedWallets[chain as EVMChain];
782
766
  const walletAction = type === "checkOnly" ? walletMethods?.isApproved : walletMethods?.approve;
783
767
 
784
- if (!walletAction) throw new SwapKitError("core_wallet_connection_not_found");
768
+ if (!walletAction) {
769
+ throw new SwapKitError("core_wallet_connection_not_found");
770
+ }
785
771
 
786
772
  const from = this.getAddress(chain);
787
773
 
788
- if (!(address && from)) throw new SwapKitError("core_approve_asset_address_or_from_not_found");
774
+ if (!(address && from)) {
775
+ throw new SwapKitError("core_approve_asset_address_or_from_not_found");
776
+ }
789
777
 
790
778
  const spenderAddress =
791
779
  contractAddress || ((await this.#getInboundDataByChain(chain)).router as string);
@@ -808,11 +796,11 @@ export class SwapKitCore<T = ""> {
808
796
  feeOptionKey?: FeeOption;
809
797
  }) => {
810
798
  const {
811
- gas_rate,
799
+ gas_rate = "0",
812
800
  router,
813
801
  address: poolAddress,
814
802
  } = await this.#getInboundDataByChain(assetValue.chain);
815
- const feeRate = (Number.parseInt(gas_rate) || 0) * gasFeeMultiplier[feeOptionKey];
803
+ const feeRate = Number.parseInt(gas_rate) * gasFeeMultiplier[feeOptionKey];
816
804
 
817
805
  return this.deposit({
818
806
  assetValue,
@@ -820,7 +808,7 @@ export class SwapKitCore<T = ""> {
820
808
  memo,
821
809
  router,
822
810
  feeRate,
823
- });
811
+ }) as Promise<string>;
824
812
  };
825
813
 
826
814
  #thorchainTransfer = async ({
@@ -830,7 +818,7 @@ export class SwapKitCore<T = ""> {
830
818
  assetValue: AssetValue;
831
819
  memo: string;
832
820
  }) => {
833
- const mimir = await getThorMimirData(this.stagenet);
821
+ const mimir = await SwapKitApi.getMimirInfo({ stagenet: this.stagenet });
834
822
 
835
823
  // check if trading is halted or not
836
824
  if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
@@ -847,7 +835,7 @@ export class SwapKitCore<T = ""> {
847
835
  assetValue: AssetValue;
848
836
  memo: string;
849
837
  }) => {
850
- const mimir = await getMayaMimirData(this.stagenet);
838
+ const mimir = await SwapKitApi.getMimirInfo({ type: "mayachain", stagenet: this.stagenet });
851
839
 
852
840
  // check if trading is halted or not
853
841
  if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
@@ -1,12 +1,13 @@
1
1
  import { Chain, ChainToExplorerUrl } from "@swapkit/types";
2
2
 
3
- export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Chain }) => {
3
+ export function getExplorerTxUrl({ chain, txHash }: { txHash: string; chain: Chain }) {
4
4
  const baseUrl = ChainToExplorerUrl[chain];
5
5
 
6
6
  switch (chain) {
7
7
  case Chain.Binance:
8
8
  case Chain.Maya:
9
9
  case Chain.Kujira:
10
+ case Chain.Cosmos:
10
11
  case Chain.THORChain:
11
12
  return `${baseUrl}/tx/${txHash.startsWith("0x") ? txHash.slice(2) : txHash}`;
12
13
 
@@ -19,9 +20,6 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
19
20
  case Chain.Polygon:
20
21
  return `${baseUrl}/tx/${txHash.startsWith("0x") ? txHash : `0x${txHash}`}`;
21
22
 
22
- case Chain.Cosmos:
23
- return `${baseUrl}/transactions/${txHash}`;
24
-
25
23
  case Chain.Litecoin:
26
24
  case Chain.Bitcoin:
27
25
  case Chain.BitcoinCash:
@@ -31,33 +29,10 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
31
29
  default:
32
30
  throw new Error(`Unsupported chain: ${chain}`);
33
31
  }
34
- };
32
+ }
35
33
 
36
- export const getExplorerAddressUrl = ({ chain, address }: { address: string; chain: Chain }) => {
34
+ export function getExplorerAddressUrl({ chain, address }: { address: string; chain: Chain }) {
37
35
  const baseUrl = ChainToExplorerUrl[chain];
38
36
 
39
- switch (chain) {
40
- case Chain.Arbitrum:
41
- case Chain.Avalanche:
42
- case Chain.Binance:
43
- case Chain.BinanceSmartChain:
44
- case Chain.Bitcoin:
45
- case Chain.BitcoinCash:
46
- case Chain.Dogecoin:
47
- case Chain.Ethereum:
48
- case Chain.Kujira:
49
- case Chain.Litecoin:
50
- case Chain.Maya:
51
- case Chain.Optimism:
52
- case Chain.Polkadot:
53
- case Chain.Polygon:
54
- case Chain.THORChain:
55
- return `${baseUrl}/address/${address}`;
56
-
57
- case Chain.Cosmos:
58
- return `${baseUrl}/account/${address}`;
59
-
60
- default:
61
- throw new Error(`Unsupported chain: ${chain}`);
62
- }
63
- };
37
+ return `${baseUrl}/address/${address}`;
38
+ }
package/src/types.ts CHANGED
@@ -135,8 +135,8 @@ export type SwapWithRouteParams = {
135
135
  streamSwap?: boolean;
136
136
  };
137
137
 
138
- type ApisType = { [key in UTXOChain]?: string | any } & {
139
- [key in EVMChain]?: string | any;
138
+ type ApisType = { [key in UTXOChain]?: string | Todo } & {
139
+ [key in EVMChain]?: string | Todo;
140
140
  } & {
141
141
  [key in CosmosChain]?: string;
142
142
  };