@swapkit/core 1.0.0-rc.76 → 1.0.0-rc.78

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
@@ -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.31",
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.64",
16
- "@swapkit/toolbox-evm": "1.0.0-rc.63",
15
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.65",
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.31",
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.64",
23
- "@swapkit/toolbox-evm": "1.0.0-rc.63",
22
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.65",
23
+ "@swapkit/toolbox-evm": "1.0.0-rc.64",
24
24
  "@swapkit/toolbox-utxo": "1.0.0-rc.62"
25
25
  },
26
26
  "eslintConfig": {
@@ -49,7 +49,7 @@
49
49
  "repository": "https://github.com/thorswap/SwapKit.git",
50
50
  "type": "module",
51
51
  "types": "./dist/index.d.ts",
52
- "version": "1.0.0-rc.76",
52
+ "version": "1.0.0-rc.78",
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",
@@ -87,17 +87,44 @@ export class SwapKitCore<T = ''> {
87
87
  };
88
88
 
89
89
  swap = async ({ streamSwap, recipient, route, feeOptionKey }: SwapParams) => {
90
- const { quoteMode } = route.meta;
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
- : Chain.BinanceSmartChain;
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 (AGG_SWAP.includes(quoteMode)) {
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
 
@@ -439,7 +466,7 @@ export class SwapKitCore<T = ''> {
439
466
  to: 'sym' | 'rune' | 'asset';
440
467
  }) => {
441
468
  const targetAsset =
442
- to === 'rune'
469
+ to === 'rune' && from !== 'rune'
443
470
  ? AssetValue.fromChainOrSignature(Chain.THORChain)
444
471
  : (from === 'sym' && to === 'sym') || from === 'rune' || from === 'asset'
445
472
  ? undefined