@swapkit/core 1.0.0-rc.100 → 1.0.0-rc.101
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -16
- package/dist/index.es.js +485 -473
- package/dist/index.es.js.map +1 -1
- package/package.json +13 -13
- package/src/client/index.ts +24 -21
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "swapkit-oss",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@swapkit/helpers": "1.0.0-rc.
|
|
5
|
-
"@swapkit/types": "1.0.0-rc.
|
|
4
|
+
"@swapkit/helpers": "1.0.0-rc.73",
|
|
5
|
+
"@swapkit/types": "1.0.0-rc.39"
|
|
6
6
|
},
|
|
7
7
|
"description": "SwapKit Lib core",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@vitest/coverage-istanbul": "1.3.1",
|
|
10
10
|
"vite": "5.1.3",
|
|
11
11
|
"vitest": "1.3.1",
|
|
12
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
13
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
14
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
15
|
-
"@swapkit/toolbox-substrate": "1.0.0-rc.
|
|
16
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.
|
|
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"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
20
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
21
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
22
|
-
"@swapkit/toolbox-substrate": "1.0.0-rc.
|
|
23
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.
|
|
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"
|
|
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.
|
|
48
|
+
"version": "1.0.0-rc.101",
|
|
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",
|
package/src/client/index.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { AssetValue, SwapKitError } from "@swapkit/helpers";
|
|
2
2
|
import { Chain } from "@swapkit/types";
|
|
3
|
+
import {
|
|
4
|
+
getExplorerAddressUrl as getAddressUrl,
|
|
5
|
+
getExplorerTxUrl as getTxUrl,
|
|
6
|
+
} from "../helpers/explorerUrls.ts";
|
|
3
7
|
import type {
|
|
4
8
|
ChainWallet,
|
|
5
9
|
ConnectWalletParamsLocal as ConnectWalletParams,
|
|
6
10
|
SwapWithRouteParams,
|
|
7
11
|
} from "../types.ts";
|
|
8
12
|
|
|
9
|
-
type ProviderName = "thorchain" | "chainflip" | "mayachain";
|
|
10
|
-
enum ApproveMode {
|
|
13
|
+
export type ProviderName = "thorchain" | "chainflip" | "mayachain";
|
|
14
|
+
export enum ApproveMode {
|
|
11
15
|
Approve = "approve",
|
|
12
16
|
CheckOnly = "checkOnly",
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly"
|
|
19
|
+
export type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly"
|
|
16
20
|
? Promise<boolean>
|
|
17
21
|
: Promise<string>;
|
|
18
22
|
|
|
@@ -33,7 +37,7 @@ export type SwapParams = (SwapWithRouteParams | GenericSwapParams) & {
|
|
|
33
37
|
};
|
|
34
38
|
};
|
|
35
39
|
|
|
36
|
-
type SwapKitReturnType = SwapKitProviders & {
|
|
40
|
+
export type SwapKitReturnType = SwapKitProviders & {
|
|
37
41
|
getAddress: (chain: Chain) => string;
|
|
38
42
|
getWallet: (chain: Chain) => ChainWallet<Chain> | undefined;
|
|
39
43
|
getWalletWithBalance: (
|
|
@@ -41,6 +45,8 @@ type SwapKitReturnType = SwapKitProviders & {
|
|
|
41
45
|
potentialScamFilter?: boolean,
|
|
42
46
|
) => Promise<ChainWallet<Chain>>;
|
|
43
47
|
getBalance: (chain: Chain, potentialScamFilter?: boolean) => AssetValue[];
|
|
48
|
+
getExplorerTxUrl: (chain: Chain, txHash: string) => string;
|
|
49
|
+
getExplorerAddressUrl: (chain: Chain, address: string) => string;
|
|
44
50
|
swap: (params: SwapParams) => Promise<string>;
|
|
45
51
|
validateAddress: (params: { address: string; chain: Chain }) =>
|
|
46
52
|
| boolean
|
|
@@ -53,9 +59,9 @@ type SwapKitReturnType = SwapKitProviders & {
|
|
|
53
59
|
) => boolean | Promise<boolean>;
|
|
54
60
|
};
|
|
55
61
|
|
|
56
|
-
type Wallets = { [K in Chain]?: ChainWallet<K> };
|
|
57
|
-
type AvailableProviders<T> = T | { [K in ProviderName]?: ProviderMethods };
|
|
58
|
-
type ProviderMethods = {
|
|
62
|
+
export type Wallets = { [K in Chain]?: ChainWallet<K> };
|
|
63
|
+
export type AvailableProviders<T> = T | { [K in ProviderName]?: ProviderMethods };
|
|
64
|
+
export type ProviderMethods = {
|
|
59
65
|
swap: (swapParams: SwapParams) => Promise<string>;
|
|
60
66
|
[key: string]: any;
|
|
61
67
|
};
|
|
@@ -65,20 +71,9 @@ export type SwapKitProvider = ({ wallets, stagenet }: { wallets: Wallets; stagen
|
|
|
65
71
|
methods: ProviderMethods;
|
|
66
72
|
};
|
|
67
73
|
|
|
68
|
-
type
|
|
69
|
-
chains: Chain[];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
type KeystoreWalletConnectParams = BaseSwapkitWalletConnectParams & {
|
|
73
|
-
phrase: string;
|
|
74
|
-
index?: number;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
type WalletConnectParams = KeystoreWalletConnectParams;
|
|
78
|
-
|
|
79
|
-
type SwapKitWallet = {
|
|
74
|
+
export type SwapKitWallet = {
|
|
80
75
|
connectMethodName: string;
|
|
81
|
-
connect: (params: ConnectWalletParams) => (connectParams:
|
|
76
|
+
connect: (params: ConnectWalletParams) => (connectParams: any) => void;
|
|
82
77
|
};
|
|
83
78
|
|
|
84
79
|
export function SwapKit<
|
|
@@ -98,7 +93,7 @@ export function SwapKit<
|
|
|
98
93
|
config?: Record<string, any>;
|
|
99
94
|
apis: Record<string, any>;
|
|
100
95
|
rpcUrls: Record<string, any>;
|
|
101
|
-
}): SwapKitReturnType & ConnectWalletMethods {
|
|
96
|
+
}): SwapKitReturnType & ConnectWalletMethods & AvailableProviders<ExtendedProviders> {
|
|
102
97
|
const connectedWallets: Wallets = {};
|
|
103
98
|
const availableProviders: AvailableProviders<ExtendedProviders> = {};
|
|
104
99
|
|
|
@@ -197,6 +192,12 @@ export function SwapKit<
|
|
|
197
192
|
function getBalance(chain: Chain) {
|
|
198
193
|
return getWallet(chain)?.balance || [];
|
|
199
194
|
}
|
|
195
|
+
function getExplorerTxUrl(chain: Chain, txHash: string) {
|
|
196
|
+
return getTxUrl({ chain, txHash });
|
|
197
|
+
}
|
|
198
|
+
function getExplorerAddressUrl(chain: Chain, address: string) {
|
|
199
|
+
return getAddressUrl({ chain, address });
|
|
200
|
+
}
|
|
200
201
|
/**
|
|
201
202
|
* TODO: Figure out validation without connecting to wallet
|
|
202
203
|
*/
|
|
@@ -244,6 +245,8 @@ export function SwapKit<
|
|
|
244
245
|
approveAssetValue,
|
|
245
246
|
getAddress,
|
|
246
247
|
getBalance,
|
|
248
|
+
getExplorerAddressUrl,
|
|
249
|
+
getExplorerTxUrl,
|
|
247
250
|
getWallet,
|
|
248
251
|
getWalletWithBalance,
|
|
249
252
|
isAssetValueApproved,
|