@swapkit/core 1.0.0-rc.17 → 1.0.0-rc.170

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 (45) hide show
  1. package/dist/index.js +3 -0
  2. package/dist/index.js.map +37 -0
  3. package/package.json +26 -49
  4. package/src/__tests__/helpers.test.ts +65 -0
  5. package/src/aggregator/contracts/avaxGeneric.ts +50 -50
  6. package/src/aggregator/contracts/avaxWoofi.ts +80 -80
  7. package/src/aggregator/contracts/bscGeneric.ts +59 -59
  8. package/src/aggregator/contracts/ethGeneric.ts +50 -50
  9. package/src/aggregator/contracts/index.ts +30 -28
  10. package/src/aggregator/contracts/pancakeV2.ts +80 -80
  11. package/src/aggregator/contracts/pangolin.ts +65 -65
  12. package/src/aggregator/contracts/routers/index.ts +58 -0
  13. package/src/aggregator/contracts/routers/kyber.ts +402 -0
  14. package/src/aggregator/contracts/routers/oneinch.ts +2188 -0
  15. package/src/aggregator/contracts/routers/pancakeswap.ts +340 -0
  16. package/src/aggregator/contracts/routers/pangolin.ts +340 -0
  17. package/src/aggregator/contracts/routers/sushiswap.ts +340 -0
  18. package/src/aggregator/contracts/routers/traderJoe.ts +340 -0
  19. package/src/aggregator/contracts/routers/uniswapv2.ts +340 -0
  20. package/src/aggregator/contracts/routers/uniswapv3.ts +254 -0
  21. package/src/aggregator/contracts/routers/woofi.ts +171 -0
  22. package/src/aggregator/contracts/sushiswap.ts +65 -65
  23. package/src/aggregator/contracts/traderJoe.ts +65 -65
  24. package/src/aggregator/contracts/uniswapV2.ts +65 -65
  25. package/src/aggregator/contracts/uniswapV2Leg.ts +70 -70
  26. package/src/aggregator/contracts/uniswapV3_100.ts +70 -70
  27. package/src/aggregator/contracts/uniswapV3_10000.ts +70 -70
  28. package/src/aggregator/contracts/uniswapV3_3000.ts +70 -70
  29. package/src/aggregator/contracts/uniswapV3_500.ts +70 -70
  30. package/src/aggregator/getSwapParams.ts +12 -12
  31. package/src/client.ts +438 -0
  32. package/src/helpers/explorerUrls.ts +45 -0
  33. package/src/index.ts +6 -4
  34. package/src/types.ts +44 -0
  35. package/LICENSE +0 -201
  36. package/dist/index-9e36735e.cjs +0 -1
  37. package/dist/index-cf1865cd.js +0 -649
  38. package/dist/index.cjs +0 -2
  39. package/dist/index.d.ts +0 -216
  40. package/dist/index.es.js +0 -4181
  41. package/src/client/__tests__/helpers.test.ts +0 -69
  42. package/src/client/explorerUrls.ts +0 -62
  43. package/src/client/index.ts +0 -699
  44. package/src/client/thornode.ts +0 -31
  45. package/src/client/types.ts +0 -103
@@ -1,69 +0,0 @@
1
- import { Chain, ChainToExplorerUrl } from '@swapkit/types';
2
- import { describe, expect, test } from 'vitest';
3
-
4
- import { getExplorerAddressUrl, getExplorerTxUrl } from '../explorerUrls.ts';
5
-
6
- describe('Explorer URLs', () => {
7
- Object.values(Chain)
8
- .filter((c) => ![Chain.Litecoin, Chain.Dogecoin, Chain.Cosmos].includes(c))
9
- .forEach((chain) => {
10
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
11
- expect(getExplorerTxUrl({ chain, txHash: '0x12345' })).toBe(
12
- `${ChainToExplorerUrl[chain]}/tx/0x12345`,
13
- );
14
-
15
- expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
16
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
17
- );
18
- });
19
- });
20
-
21
- test('getExplorerTxUrl throws Error for unsupported Chain', () => {
22
- expect(() =>
23
- getExplorerTxUrl({ chain: 'unsupported' as Chain, txHash: '0x12345' }),
24
- ).toThrowError('Unsupported chain: unsupported');
25
- });
26
- test('getExplorerAddressUrl throws Error for unsupported Chain', () => {
27
- expect(() =>
28
- getExplorerAddressUrl({ chain: 'unsupported' as Chain, address: 'asdfg' }),
29
- ).toThrowError('Unsupported chain: unsupported');
30
- });
31
- test('getExplorerTxUrl adds 0x for EVM like chains', () => {
32
- expect(getExplorerTxUrl({ chain: Chain.Ethereum, txHash: '12345' })).toBe(
33
- 'https://etherscan.io/tx/0x12345',
34
- );
35
- });
36
-
37
- test('getExplorerTxUrl returns correct URL for Litecoin', () => {
38
- expect(getExplorerTxUrl({ chain: Chain.Litecoin, txHash: 'efghi' })).toBe(
39
- 'https://ltc.bitaps.com/efghi',
40
- );
41
- });
42
- test('getExplorerAddressUrl returns correct URL for Litecoin', () => {
43
- expect(getExplorerAddressUrl({ chain: Chain.Litecoin, address: '12345' })).toBe(
44
- 'https://ltc.bitaps.com/12345',
45
- );
46
- });
47
-
48
- test('getExplorerTxUrl returns correct URL for Cosmos', () => {
49
- expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: 'pqrst' })).toBe(
50
- 'https://cosmos.bigdipper.live/transactions/pqrst',
51
- );
52
- });
53
- test('getExplorerAddressUrl returns correct URL for Cosmos', () => {
54
- expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: 'zabcd' })).toBe(
55
- 'https://cosmos.bigdipper.live/account/zabcd',
56
- );
57
- });
58
-
59
- test('getExplorerTxUrl returns correct URL for Doge', () => {
60
- expect(getExplorerTxUrl({ chain: Chain.Dogecoin, txHash: 'uvwxy' })).toBe(
61
- 'https://blockchair.com/dogecoin/transaction/uvwxy',
62
- );
63
- });
64
- test('getExplorerAddressUrl returns correct URL for Doge', () => {
65
- expect(getExplorerAddressUrl({ chain: Chain.Dogecoin, address: 'efghi' })).toBe(
66
- 'https://blockchair.com/dogecoin/address/efghi',
67
- );
68
- });
69
- });
@@ -1,62 +0,0 @@
1
- import { Chain, ChainToExplorerUrl } from '@swapkit/types';
2
-
3
- export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Chain }) => {
4
- const baseUrl = ChainToExplorerUrl[chain];
5
-
6
- switch (chain) {
7
- case Chain.Binance:
8
- case Chain.Bitcoin:
9
- case Chain.BitcoinCash:
10
- case Chain.Maya:
11
- case Chain.Kujira:
12
- case Chain.THORChain:
13
- return `${baseUrl}/tx/${txHash}`;
14
-
15
- case Chain.Arbitrum:
16
- case Chain.Avalanche:
17
- case Chain.BinanceSmartChain:
18
- case Chain.Ethereum:
19
- case Chain.Optimism:
20
- case Chain.Polygon:
21
- return `${baseUrl}/tx/${txHash.startsWith('0x') ? txHash : `0x${txHash}`}`;
22
-
23
- case Chain.Cosmos:
24
- return `${baseUrl}/transactions/${txHash}`;
25
- case Chain.Dogecoin:
26
- return `${baseUrl}/transaction/${txHash.toLowerCase()}`;
27
- case Chain.Litecoin:
28
- return `${baseUrl}/${txHash}`;
29
-
30
- default:
31
- throw new Error(`Unsupported chain: ${chain}`);
32
- }
33
- };
34
-
35
- export const getExplorerAddressUrl = ({ chain, address }: { address: string; chain: Chain }) => {
36
- const baseUrl = ChainToExplorerUrl[chain];
37
-
38
- switch (chain) {
39
- case Chain.Arbitrum:
40
- case Chain.Avalanche:
41
- case Chain.Binance:
42
- case Chain.BinanceSmartChain:
43
- case Chain.Bitcoin:
44
- case Chain.BitcoinCash:
45
- case Chain.Dogecoin:
46
- case Chain.Ethereum:
47
- case Chain.Maya:
48
- case Chain.Optimism:
49
- case Chain.Polygon:
50
- case Chain.Kujira:
51
- case Chain.THORChain:
52
- return `${baseUrl}/address/${address}`;
53
-
54
- case Chain.Cosmos:
55
- return `${baseUrl}/account/${address}`;
56
- case Chain.Litecoin:
57
- return `${baseUrl}/${address}`;
58
-
59
- default:
60
- throw new Error(`Unsupported chain: ${chain}`);
61
- }
62
- };