@swapkit/core 1.0.0-rc.8 → 1.0.0-rc.81

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.
@@ -0,0 +1,171 @@
1
+ export const woofiRouter = [
2
+ {
3
+ inputs: [
4
+ { internalType: 'address', name: '_weth', type: 'address' },
5
+ { internalType: 'address', name: '_pool', type: 'address' },
6
+ ],
7
+ stateMutability: 'nonpayable',
8
+ type: 'constructor',
9
+ },
10
+ {
11
+ anonymous: false,
12
+ inputs: [
13
+ { indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' },
14
+ { indexed: true, internalType: 'address', name: 'newOwner', type: 'address' },
15
+ ],
16
+ name: 'OwnershipTransferred',
17
+ type: 'event',
18
+ },
19
+ {
20
+ anonymous: false,
21
+ inputs: [{ indexed: false, internalType: 'address', name: 'newPool', type: 'address' }],
22
+ name: 'WooPoolChanged',
23
+ type: 'event',
24
+ },
25
+ {
26
+ anonymous: false,
27
+ inputs: [
28
+ {
29
+ indexed: false,
30
+ internalType: 'enum IWooRouterV2.SwapType',
31
+ name: 'swapType',
32
+ type: 'uint8',
33
+ },
34
+ { indexed: true, internalType: 'address', name: 'fromToken', type: 'address' },
35
+ { indexed: true, internalType: 'address', name: 'toToken', type: 'address' },
36
+ { indexed: false, internalType: 'uint256', name: 'fromAmount', type: 'uint256' },
37
+ { indexed: false, internalType: 'uint256', name: 'toAmount', type: 'uint256' },
38
+ { indexed: false, internalType: 'address', name: 'from', type: 'address' },
39
+ { indexed: true, internalType: 'address', name: 'to', type: 'address' },
40
+ { indexed: false, internalType: 'address', name: 'rebateTo', type: 'address' },
41
+ ],
42
+ name: 'WooRouterSwap',
43
+ type: 'event',
44
+ },
45
+ {
46
+ inputs: [],
47
+ name: 'WETH',
48
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
49
+ stateMutability: 'view',
50
+ type: 'function',
51
+ },
52
+ {
53
+ inputs: [
54
+ { internalType: 'address', name: 'approveTarget', type: 'address' },
55
+ { internalType: 'address', name: 'swapTarget', type: 'address' },
56
+ { internalType: 'address', name: 'fromToken', type: 'address' },
57
+ { internalType: 'address', name: 'toToken', type: 'address' },
58
+ { internalType: 'uint256', name: 'fromAmount', type: 'uint256' },
59
+ { internalType: 'uint256', name: 'minToAmount', type: 'uint256' },
60
+ { internalType: 'address payable', name: 'to', type: 'address' },
61
+ { internalType: 'bytes', name: 'data', type: 'bytes' },
62
+ ],
63
+ name: 'externalSwap',
64
+ outputs: [{ internalType: 'uint256', name: 'realToAmount', type: 'uint256' }],
65
+ stateMutability: 'payable',
66
+ type: 'function',
67
+ },
68
+ {
69
+ inputs: [{ internalType: 'address', name: 'stuckToken', type: 'address' }],
70
+ name: 'inCaseTokenGotStuck',
71
+ outputs: [],
72
+ stateMutability: 'nonpayable',
73
+ type: 'function',
74
+ },
75
+ {
76
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
77
+ name: 'isWhitelisted',
78
+ outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
79
+ stateMutability: 'view',
80
+ type: 'function',
81
+ },
82
+ {
83
+ inputs: [],
84
+ name: 'owner',
85
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
86
+ stateMutability: 'view',
87
+ type: 'function',
88
+ },
89
+ {
90
+ inputs: [
91
+ { internalType: 'address', name: 'fromToken', type: 'address' },
92
+ { internalType: 'address', name: 'toToken', type: 'address' },
93
+ { internalType: 'uint256', name: 'fromAmount', type: 'uint256' },
94
+ ],
95
+ name: 'querySwap',
96
+ outputs: [{ internalType: 'uint256', name: 'toAmount', type: 'uint256' }],
97
+ stateMutability: 'view',
98
+ type: 'function',
99
+ },
100
+ {
101
+ inputs: [],
102
+ name: 'quoteToken',
103
+ outputs: [{ internalType: 'address', name: '', type: 'address' }],
104
+ stateMutability: 'view',
105
+ type: 'function',
106
+ },
107
+ {
108
+ inputs: [],
109
+ name: 'renounceOwnership',
110
+ outputs: [],
111
+ stateMutability: 'nonpayable',
112
+ type: 'function',
113
+ },
114
+ {
115
+ inputs: [{ internalType: 'address', name: 'newPool', type: 'address' }],
116
+ name: 'setPool',
117
+ outputs: [],
118
+ stateMutability: 'nonpayable',
119
+ type: 'function',
120
+ },
121
+ {
122
+ inputs: [
123
+ { internalType: 'address', name: 'target', type: 'address' },
124
+ { internalType: 'bool', name: 'whitelisted', type: 'bool' },
125
+ ],
126
+ name: 'setWhitelisted',
127
+ outputs: [],
128
+ stateMutability: 'nonpayable',
129
+ type: 'function',
130
+ },
131
+ {
132
+ inputs: [
133
+ { internalType: 'address', name: 'fromToken', type: 'address' },
134
+ { internalType: 'address', name: 'toToken', type: 'address' },
135
+ { internalType: 'uint256', name: 'fromAmount', type: 'uint256' },
136
+ { internalType: 'uint256', name: 'minToAmount', type: 'uint256' },
137
+ { internalType: 'address payable', name: 'to', type: 'address' },
138
+ { internalType: 'address', name: 'rebateTo', type: 'address' },
139
+ ],
140
+ name: 'swap',
141
+ outputs: [{ internalType: 'uint256', name: 'realToAmount', type: 'uint256' }],
142
+ stateMutability: 'payable',
143
+ type: 'function',
144
+ },
145
+ {
146
+ inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }],
147
+ name: 'transferOwnership',
148
+ outputs: [],
149
+ stateMutability: 'nonpayable',
150
+ type: 'function',
151
+ },
152
+ {
153
+ inputs: [
154
+ { internalType: 'address', name: 'fromToken', type: 'address' },
155
+ { internalType: 'address', name: 'toToken', type: 'address' },
156
+ { internalType: 'uint256', name: 'fromAmount', type: 'uint256' },
157
+ ],
158
+ name: 'tryQuerySwap',
159
+ outputs: [{ internalType: 'uint256', name: 'toAmount', type: 'uint256' }],
160
+ stateMutability: 'view',
161
+ type: 'function',
162
+ },
163
+ {
164
+ inputs: [],
165
+ name: 'wooPool',
166
+ outputs: [{ internalType: 'contract IWooPPV2', name: '', type: 'address' }],
167
+ stateMutability: 'view',
168
+ type: 'function',
169
+ },
170
+ { stateMutability: 'payable', type: 'receive' },
171
+ ];
@@ -4,25 +4,55 @@ import { describe, expect, test } from 'vitest';
4
4
  import { getExplorerAddressUrl, getExplorerTxUrl } from '../explorerUrls.ts';
5
5
 
6
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
- );
7
+ [Chain.Binance, Chain.Maya, Chain.Kujira, Chain.THORChain].forEach((chain) => {
8
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
9
+ expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
10
+ `${ChainToExplorerUrl[chain]}/tx/123456789`,
11
+ );
14
12
 
15
- expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
16
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
17
- );
18
- });
13
+ expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
14
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
15
+ );
19
16
  });
17
+ });
18
+
19
+ [
20
+ Chain.Arbitrum,
21
+ Chain.Avalanche,
22
+ Chain.BinanceSmartChain,
23
+ Chain.Ethereum,
24
+ Chain.Optimism,
25
+ Chain.Polygon,
26
+ ].forEach((chain) => {
27
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
28
+ expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
29
+ `${ChainToExplorerUrl[chain]}/tx/0x123456789`,
30
+ );
31
+
32
+ expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
33
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
34
+ );
35
+ });
36
+ });
37
+
38
+ [Chain.Bitcoin, Chain.BitcoinCash, Chain.Dogecoin, Chain.Litecoin].forEach((chain) => {
39
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
40
+ expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
41
+ `${ChainToExplorerUrl[chain]}/transaction/0x123456789`,
42
+ );
43
+
44
+ expect(getExplorerAddressUrl({ chain, address: 'asdfg' })).toBe(
45
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
46
+ );
47
+ });
48
+ });
20
49
 
21
50
  test('getExplorerTxUrl throws Error for unsupported Chain', () => {
22
51
  expect(() =>
23
52
  getExplorerTxUrl({ chain: 'unsupported' as Chain, txHash: '0x12345' }),
24
53
  ).toThrowError('Unsupported chain: unsupported');
25
54
  });
55
+
26
56
  test('getExplorerAddressUrl throws Error for unsupported Chain', () => {
27
57
  expect(() =>
28
58
  getExplorerAddressUrl({ chain: 'unsupported' as Chain, address: 'asdfg' }),
@@ -34,17 +64,6 @@ describe('Explorer URLs', () => {
34
64
  );
35
65
  });
36
66
 
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
67
  test('getExplorerTxUrl returns correct URL for Cosmos', () => {
49
68
  expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: 'pqrst' })).toBe(
50
69
  'https://cosmos.bigdipper.live/transactions/pqrst',
@@ -55,15 +74,4 @@ describe('Explorer URLs', () => {
55
74
  'https://cosmos.bigdipper.live/account/zabcd',
56
75
  );
57
76
  });
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
77
  });
@@ -5,12 +5,10 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
5
5
 
6
6
  switch (chain) {
7
7
  case Chain.Binance:
8
- case Chain.Bitcoin:
9
- case Chain.BitcoinCash:
10
8
  case Chain.Maya:
11
9
  case Chain.Kujira:
12
10
  case Chain.THORChain:
13
- return `${baseUrl}/tx/${txHash}`;
11
+ return `${baseUrl}/tx/${txHash.startsWith('0x') ? txHash.slice(2) : txHash}`;
14
12
 
15
13
  case Chain.Arbitrum:
16
14
  case Chain.Avalanche:
@@ -22,10 +20,12 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
22
20
 
23
21
  case Chain.Cosmos:
24
22
  return `${baseUrl}/transactions/${txHash}`;
23
+
24
+ case Chain.Litecoin:
25
+ case Chain.Bitcoin:
26
+ case Chain.BitcoinCash:
25
27
  case Chain.Dogecoin:
26
28
  return `${baseUrl}/transaction/${txHash.toLowerCase()}`;
27
- case Chain.Litecoin:
28
- return `${baseUrl}/${txHash}`;
29
29
 
30
30
  default:
31
31
  throw new Error(`Unsupported chain: ${chain}`);
@@ -44,17 +44,16 @@ export const getExplorerAddressUrl = ({ chain, address }: { address: string; cha
44
44
  case Chain.BitcoinCash:
45
45
  case Chain.Dogecoin:
46
46
  case Chain.Ethereum:
47
+ case Chain.Kujira:
48
+ case Chain.Litecoin:
47
49
  case Chain.Maya:
48
50
  case Chain.Optimism:
49
51
  case Chain.Polygon:
50
- case Chain.Kujira:
51
52
  case Chain.THORChain:
52
53
  return `${baseUrl}/address/${address}`;
53
54
 
54
55
  case Chain.Cosmos:
55
56
  return `${baseUrl}/account/${address}`;
56
- case Chain.Litecoin:
57
- return `${baseUrl}/${address}`;
58
57
 
59
58
  default:
60
59
  throw new Error(`Unsupported chain: ${chain}`);