@swapkit/core 1.0.0-rc.77 → 1.0.0-rc.79
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +538 -521
- package/dist/index.es.js.map +1 -1
- package/package.json +11 -11
- package/src/client/index.ts +31 -4
package/package.json
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"vite": "5.0.7",
|
|
11
11
|
"vitest": "1.0.4",
|
|
12
12
|
"@internal/config": "null-rc.0",
|
|
13
|
-
"@swapkit/api": "1.0.0-rc.
|
|
13
|
+
"@swapkit/api": "1.0.0-rc.32",
|
|
14
14
|
"@swapkit/tokens": "1.0.0-rc.32",
|
|
15
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
16
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
15
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.66",
|
|
16
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.64",
|
|
17
17
|
"@swapkit/toolbox-utxo": "1.0.0-rc.62"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@swapkit/api": "1.0.0-rc.
|
|
20
|
+
"@swapkit/api": "1.0.0-rc.32",
|
|
21
21
|
"@swapkit/tokens": "1.0.0-rc.32",
|
|
22
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
23
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
22
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.66",
|
|
23
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.64",
|
|
24
24
|
"@swapkit/toolbox-utxo": "1.0.0-rc.62"
|
|
25
25
|
},
|
|
26
26
|
"eslintConfig": {
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"main": "./dist/index.cjs",
|
|
43
43
|
"module": "./dist/index.es.js",
|
|
44
44
|
"name": "@swapkit/core",
|
|
45
|
-
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
47
|
-
},
|
|
48
45
|
"react-native": "./src/index.ts",
|
|
49
|
-
"repository":
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/thorswap/SwapKit.git"
|
|
49
|
+
},
|
|
50
50
|
"type": "module",
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
|
-
"version": "1.0.0-rc.
|
|
52
|
+
"version": "1.0.0-rc.79",
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
|
|
55
55
|
"clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
|
package/src/client/index.ts
CHANGED
|
@@ -87,17 +87,44 @@ export class SwapKitCore<T = ''> {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
swap = async ({ streamSwap, recipient, route, feeOptionKey }: SwapParams) => {
|
|
90
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
meta: { quoteMode },
|
|
92
|
+
evmTransactionDetails: contractCallParams,
|
|
93
|
+
} = route;
|
|
91
94
|
const evmChain = quoteMode.startsWith('ERC20-')
|
|
92
95
|
? Chain.Ethereum
|
|
93
96
|
: quoteMode.startsWith('ARC20-')
|
|
94
97
|
? Chain.Avalanche
|
|
95
|
-
:
|
|
98
|
+
: quoteMode.startsWith('BEP20-')
|
|
99
|
+
? Chain.BinanceSmartChain
|
|
100
|
+
: undefined;
|
|
96
101
|
|
|
97
102
|
if (!route.complete) throw new SwapKitError('core_swap_route_not_complete');
|
|
98
103
|
|
|
99
104
|
try {
|
|
100
|
-
if (
|
|
105
|
+
if (contractCallParams && evmChain) {
|
|
106
|
+
const walletMethods = this.connectedWallets[evmChain];
|
|
107
|
+
|
|
108
|
+
if (!walletMethods?.call) {
|
|
109
|
+
throw new SwapKitError('core_wallet_connection_not_found');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const { contractAddress, contractMethod, contractParams, contractParamsStreaming } =
|
|
113
|
+
contractCallParams;
|
|
114
|
+
|
|
115
|
+
if (!(streamSwap ? contractParamsStreaming : contractParams)) {
|
|
116
|
+
throw new SwapKitError('core_swap_route_transaction_not_found');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return await walletMethods.call<string>({
|
|
120
|
+
contractAddress,
|
|
121
|
+
abi: lowercasedContractAbiMapping[contractAddress.toLowerCase()],
|
|
122
|
+
funcName: contractMethod,
|
|
123
|
+
funcParams: streamSwap ? contractParamsStreaming : contractParams,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (AGG_SWAP.includes(quoteMode) && evmChain) {
|
|
101
128
|
const walletMethods = this.connectedWallets[evmChain];
|
|
102
129
|
if (!walletMethods?.sendTransaction) {
|
|
103
130
|
throw new SwapKitError('core_wallet_connection_not_found');
|
|
@@ -143,7 +170,7 @@ export class SwapKitCore<T = ''> {
|
|
|
143
170
|
});
|
|
144
171
|
}
|
|
145
172
|
|
|
146
|
-
if (SWAP_IN.includes(quoteMode)) {
|
|
173
|
+
if (SWAP_IN.includes(quoteMode) && evmChain) {
|
|
147
174
|
const { calldata, contract: contractAddress } = route;
|
|
148
175
|
if (!contractAddress) throw new SwapKitError('core_swap_contract_not_found');
|
|
149
176
|
|