@swapkit/core 1.0.0-rc.101 → 1.0.0-rc.103

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,8 +1,8 @@
1
1
  {
2
2
  "author": "swapkit-oss",
3
3
  "dependencies": {
4
- "@swapkit/helpers": "1.0.0-rc.73",
5
- "@swapkit/types": "1.0.0-rc.39"
4
+ "@swapkit/helpers": "1.0.0-rc.74",
5
+ "@swapkit/types": "1.0.0-rc.40"
6
6
  },
7
7
  "description": "SwapKit Lib core",
8
8
  "devDependencies": {
@@ -10,17 +10,17 @@
10
10
  "vite": "5.1.3",
11
11
  "vitest": "1.3.1",
12
12
  "@swapkit/tokens": "1.0.0-rc.36",
13
- "@swapkit/toolbox-cosmos": "1.0.0-rc.84",
14
- "@swapkit/toolbox-evm": "1.0.0-rc.79",
15
- "@swapkit/toolbox-substrate": "1.0.0-rc.7",
16
- "@swapkit/toolbox-utxo": "1.0.0-rc.78"
13
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.85",
14
+ "@swapkit/toolbox-evm": "1.0.0-rc.80",
15
+ "@swapkit/toolbox-substrate": "1.0.0-rc.9",
16
+ "@swapkit/toolbox-utxo": "1.0.0-rc.80"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "@swapkit/tokens": "1.0.0-rc.36",
20
- "@swapkit/toolbox-cosmos": "1.0.0-rc.84",
21
- "@swapkit/toolbox-evm": "1.0.0-rc.79",
22
- "@swapkit/toolbox-substrate": "1.0.0-rc.7",
23
- "@swapkit/toolbox-utxo": "1.0.0-rc.78"
20
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.85",
21
+ "@swapkit/toolbox-evm": "1.0.0-rc.80",
22
+ "@swapkit/toolbox-substrate": "1.0.0-rc.9",
23
+ "@swapkit/toolbox-utxo": "1.0.0-rc.80"
24
24
  },
25
25
  "exports": {
26
26
  ".": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "type": "module",
47
47
  "types": "./dist/index.d.ts",
48
- "version": "1.0.0-rc.101",
48
+ "version": "1.0.0-rc.103",
49
49
  "scripts": {
50
50
  "build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
51
51
  "clean": "rm -rf dist vite.config.ts.* node_modules",
@@ -1,79 +1,84 @@
1
- import { Chain, ChainToExplorerUrl, CosmosChains, EVMChains, UTXOChains } from "@swapkit/types";
1
+ import {
2
+ Chain,
3
+ ChainToExplorerUrl,
4
+ CosmosChains,
5
+ EVMChains,
6
+ SubstrateChains,
7
+ UTXOChains,
8
+ } from "@swapkit/types";
2
9
  import { describe, expect, test } from "vitest";
3
10
  import { getExplorerAddressUrl, getExplorerTxUrl } from "../helpers/explorerUrls.ts";
4
11
 
5
12
  describe("Explorer URLs", () => {
6
- for (const chain of CosmosChains.filter((c) => c !== Chain.Cosmos)) {
7
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
8
- expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
9
- `${ChainToExplorerUrl[chain]}/tx/123456789`,
10
- );
13
+ describe("CosmosChains", () => {
14
+ for (const chain of CosmosChains.filter((c) => c !== Chain.Cosmos)) {
15
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
16
+ expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
17
+ `${ChainToExplorerUrl[chain]}/tx/123456789`,
18
+ );
11
19
 
12
- expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
13
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
14
- );
15
- });
16
- }
20
+ expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
21
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
22
+ );
23
+ });
24
+ }
17
25
 
18
- for (const chain of EVMChains) {
19
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
20
- expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
21
- `${ChainToExplorerUrl[chain]}/tx/0x123456789`,
26
+ test(`getExplorerTxUrl returns correct URL for ${Chain.Cosmos}`, () => {
27
+ expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: "0x123456789" })).toBe(
28
+ `${ChainToExplorerUrl[Chain.Cosmos]}/transactions/0x123456789`,
22
29
  );
23
30
 
24
- expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
25
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
31
+ expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: "asdfg" })).toBe(
32
+ `${ChainToExplorerUrl[Chain.Cosmos]}/account/asdfg`,
26
33
  );
27
34
  });
28
- }
35
+ });
29
36
 
30
- for (const chain of UTXOChains.filter((c) => c !== Chain.Dash)) {
31
- test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
32
- expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
33
- `${ChainToExplorerUrl[chain]}/transaction/0x123456789`,
34
- );
37
+ describe("EVMChains & SubstrateChains", () => {
38
+ for (const chain of [...EVMChains, Chain.Polkadot]) {
39
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
40
+ expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
41
+ `${ChainToExplorerUrl[chain]}/tx/0x123456789`,
42
+ );
43
+
44
+ expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
45
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
46
+ );
47
+ });
48
+ }
35
49
 
36
- expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
37
- `${ChainToExplorerUrl[chain]}/address/asdfg`,
50
+ test("getExplorerTxUrl adds 0x for EVM like chains", () => {
51
+ expect(getExplorerTxUrl({ chain: Chain.Ethereum, txHash: "12345" })).toBe(
52
+ "https://etherscan.io/tx/0x12345",
38
53
  );
39
54
  });
40
- }
41
-
42
- test(`getExplorerTxUrl returns correct URL for ${Chain.Cosmos}`, () => {
43
- expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: "0x123456789" })).toBe(
44
- `${ChainToExplorerUrl[Chain.Cosmos]}/transactions/0x123456789`,
45
- );
46
-
47
- expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: "asdfg" })).toBe(
48
- `${ChainToExplorerUrl[Chain.Cosmos]}/account/asdfg`,
49
- );
50
55
  });
51
56
 
52
- test("getExplorerTxUrl throws Error for unsupported Chain", () => {
53
- expect(() =>
54
- getExplorerTxUrl({ chain: "unsupported" as Chain, txHash: "0x12345" }),
55
- ).toThrowError("Unsupported chain: unsupported");
56
- });
57
+ describe("UTXOChains", () => {
58
+ for (const chain of UTXOChains.filter((c) => c !== Chain.Dash)) {
59
+ test(`getExplorerTxUrl returns correct URL for ${chain}`, () => {
60
+ expect(getExplorerTxUrl({ chain, txHash: "0x123456789" })).toBe(
61
+ `${ChainToExplorerUrl[chain]}/transaction/0x123456789`,
62
+ );
57
63
 
58
- test("getExplorerAddressUrl throws Error for unsupported Chain", () => {
59
- expect(() =>
60
- getExplorerAddressUrl({ chain: "unsupported" as Chain, address: "asdfg" }),
61
- ).toThrowError("Unsupported chain: unsupported");
62
- });
63
- test("getExplorerTxUrl adds 0x for EVM like chains", () => {
64
- expect(getExplorerTxUrl({ chain: Chain.Ethereum, txHash: "12345" })).toBe(
65
- "https://etherscan.io/tx/0x12345",
66
- );
64
+ expect(getExplorerAddressUrl({ chain, address: "asdfg" })).toBe(
65
+ `${ChainToExplorerUrl[chain]}/address/asdfg`,
66
+ );
67
+ });
68
+ }
67
69
  });
68
70
 
69
- test("getExplorerTxUrl returns correct URL for Cosmos", () => {
70
- expect(getExplorerTxUrl({ chain: Chain.Cosmos, txHash: "pqrst" })).toBe(
71
- "https://cosmos.bigdipper.live/transactions/pqrst",
72
- );
73
- });
74
- test("getExplorerAddressUrl returns correct URL for Cosmos", () => {
75
- expect(getExplorerAddressUrl({ chain: Chain.Cosmos, address: "zabcd" })).toBe(
76
- "https://cosmos.bigdipper.live/account/zabcd",
77
- );
71
+ describe("Unsupported chains", () => {
72
+ test("getExplorerTxUrl throws Error for unsupported Chain", () => {
73
+ expect(() =>
74
+ getExplorerTxUrl({ chain: "unsupported" as Chain, txHash: "0x12345" }),
75
+ ).toThrowError("Unsupported chain: unsupported");
76
+ });
77
+
78
+ test("getExplorerAddressUrl throws Error for unsupported Chain", () => {
79
+ expect(() =>
80
+ getExplorerAddressUrl({ chain: "unsupported" as Chain, address: "asdfg" }),
81
+ ).toThrowError("Unsupported chain: unsupported");
82
+ });
78
83
  });
79
84
  });
@@ -15,6 +15,7 @@ export const getExplorerTxUrl = ({ chain, txHash }: { txHash: string; chain: Cha
15
15
  case Chain.BinanceSmartChain:
16
16
  case Chain.Ethereum:
17
17
  case Chain.Optimism:
18
+ case Chain.Polkadot:
18
19
  case Chain.Polygon:
19
20
  return `${baseUrl}/tx/${txHash.startsWith("0x") ? txHash : `0x${txHash}`}`;
20
21
 
@@ -48,6 +49,7 @@ export const getExplorerAddressUrl = ({ chain, address }: { address: string; cha
48
49
  case Chain.Litecoin:
49
50
  case Chain.Maya:
50
51
  case Chain.Optimism:
52
+ case Chain.Polkadot:
51
53
  case Chain.Polygon:
52
54
  case Chain.THORChain:
53
55
  return `${baseUrl}/address/${address}`;