@swapkit/core 1.0.0-rc.65 → 1.0.0-rc.67
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/index.cjs +3 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.es.js +52 -53
- package/dist/index.es.js.map +1 -0
- package/package.json +17 -20
- package/src/client/__tests__/helpers.test.ts +14 -30
- package/src/client/explorerUrls.ts +6 -7
package/package.json
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "swapkit-oss-team",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@swapkit/helpers": "1.0.0-rc.
|
|
5
|
-
"@swapkit/types": "1.0.0-rc.
|
|
4
|
+
"@swapkit/helpers": "1.0.0-rc.51",
|
|
5
|
+
"@swapkit/types": "1.0.0-rc.28"
|
|
6
6
|
},
|
|
7
7
|
"description": "SwapKit Lib core",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@vitest/coverage-istanbul": "1.0.
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"@
|
|
16
|
-
"@swapkit/
|
|
17
|
-
"@swapkit/
|
|
18
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.53",
|
|
19
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.53",
|
|
20
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.52"
|
|
9
|
+
"@vitest/coverage-istanbul": "1.0.4",
|
|
10
|
+
"vite": "5.0.7",
|
|
11
|
+
"vitest": "1.0.4",
|
|
12
|
+
"@internal/config": "null-rc.0",
|
|
13
|
+
"@swapkit/api": "1.0.0-rc.28",
|
|
14
|
+
"@swapkit/tokens": "1.0.0-rc.29",
|
|
15
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.55",
|
|
16
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.55",
|
|
17
|
+
"@swapkit/toolbox-utxo": "1.0.0-rc.54"
|
|
21
18
|
},
|
|
22
19
|
"peerDependencies": {
|
|
23
|
-
"@swapkit/api": "1.0.0-rc.
|
|
24
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
25
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
26
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
27
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.
|
|
20
|
+
"@swapkit/api": "1.0.0-rc.28",
|
|
21
|
+
"@swapkit/tokens": "1.0.0-rc.29",
|
|
22
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.55",
|
|
23
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.55",
|
|
24
|
+
"@swapkit/toolbox-utxo": "1.0.0-rc.54"
|
|
28
25
|
},
|
|
29
26
|
"eslintConfig": {
|
|
30
27
|
"extends": "../../../internal/eslint-config"
|
|
@@ -52,7 +49,7 @@
|
|
|
52
49
|
"repository": "https://github.com/thorswap/SwapKit.git",
|
|
53
50
|
"type": "module",
|
|
54
51
|
"types": "./dist/index.d.ts",
|
|
55
|
-
"version": "1.0.0-rc.
|
|
52
|
+
"version": "1.0.0-rc.67",
|
|
56
53
|
"scripts": {
|
|
57
54
|
"build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
|
|
58
55
|
"clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
|
|
@@ -4,14 +4,7 @@ import { describe, expect, test } from 'vitest';
|
|
|
4
4
|
import { getExplorerAddressUrl, getExplorerTxUrl } from '../explorerUrls.ts';
|
|
5
5
|
|
|
6
6
|
describe('Explorer URLs', () => {
|
|
7
|
-
[
|
|
8
|
-
Chain.Binance,
|
|
9
|
-
Chain.Bitcoin,
|
|
10
|
-
Chain.BitcoinCash,
|
|
11
|
-
Chain.Maya,
|
|
12
|
-
Chain.Kujira,
|
|
13
|
-
Chain.THORChain,
|
|
14
|
-
].forEach((chain) => {
|
|
7
|
+
[Chain.Binance, Chain.Maya, Chain.Kujira, Chain.THORChain].forEach((chain) => {
|
|
15
8
|
test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
|
|
16
9
|
expect(getExplorerTxUrl({ chain, txHash: '0x123456789' })).toBe(
|
|
17
10
|
`${ChainToExplorerUrl[chain]}/tx/123456789`,
|
|
@@ -42,11 +35,24 @@ describe('Explorer URLs', () => {
|
|
|
42
35
|
});
|
|
43
36
|
});
|
|
44
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
|
+
});
|
|
49
|
+
|
|
45
50
|
test('getExplorerTxUrl throws Error for unsupported Chain', () => {
|
|
46
51
|
expect(() =>
|
|
47
52
|
getExplorerTxUrl({ chain: 'unsupported' as Chain, txHash: '0x12345' }),
|
|
48
53
|
).toThrowError('Unsupported chain: unsupported');
|
|
49
54
|
});
|
|
55
|
+
|
|
50
56
|
test('getExplorerAddressUrl throws Error for unsupported Chain', () => {
|
|
51
57
|
expect(() =>
|
|
52
58
|
getExplorerAddressUrl({ chain: 'unsupported' as Chain, address: 'asdfg' }),
|
|
@@ -58,17 +64,6 @@ describe('Explorer URLs', () => {
|
|
|
58
64
|
);
|
|
59
65
|
});
|
|
60
66
|
|
|
61
|
-
test('getExplorerTxUrl returns correct URL for Litecoin', () => {
|
|
62
|
-
expect(getExplorerTxUrl({ chain: Chain.Litecoin, txHash: 'efghi' })).toBe(
|
|
63
|
-
'https://ltc.bitaps.com/efghi',
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
test('getExplorerAddressUrl returns correct URL for Litecoin', () => {
|
|
67
|
-
expect(getExplorerAddressUrl({ chain: Chain.Litecoin, address: '12345' })).toBe(
|
|
68
|
-
'https://ltc.bitaps.com/12345',
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
67
|
test('getExplorerTxUrl returns correct URL for Cosmos', () => {
|
|
73
68
|
expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: 'pqrst' })).toBe(
|
|
74
69
|
'https://cosmos.bigdipper.live/transactions/pqrst',
|
|
@@ -79,15 +74,4 @@ describe('Explorer URLs', () => {
|
|
|
79
74
|
'https://cosmos.bigdipper.live/account/zabcd',
|
|
80
75
|
);
|
|
81
76
|
});
|
|
82
|
-
|
|
83
|
-
test('getExplorerTxUrl returns correct URL for Doge', () => {
|
|
84
|
-
expect(getExplorerTxUrl({ chain: Chain.Dogecoin, txHash: 'uvwxy' })).toBe(
|
|
85
|
-
'https://blockchair.com/dogecoin/transaction/uvwxy',
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
test('getExplorerAddressUrl returns correct URL for Doge', () => {
|
|
89
|
-
expect(getExplorerAddressUrl({ chain: Chain.Dogecoin, address: 'efghi' })).toBe(
|
|
90
|
-
'https://blockchair.com/dogecoin/address/efghi',
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
77
|
});
|
|
@@ -5,8 +5,6 @@ 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:
|
|
@@ -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}`);
|