@rango-dev/widget-embedded 0.40.2-next.7 → 0.40.2-next.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.40.2-next.7",
3
+ "version": "0.40.2-next.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -54,4 +54,4 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
57
- }
57
+ }
@@ -23,10 +23,9 @@ import {
23
23
  import { useFetchAllQuotes } from './useFetchAllQuotes';
24
24
 
25
25
  const DEBOUNCE_DELAY = 600;
26
- const FIRST_INDEX = 0;
27
26
 
28
27
  type FetchQuoteParams = Omit<
29
- Parameters<typeof createQuoteRequestBody>[typeof FIRST_INDEX],
28
+ Parameters<typeof createQuoteRequestBody>[0],
30
29
  'fromToken' | 'toToken'
31
30
  > & { fromToken: Token | null; toToken: Token | null };
32
31
 
@@ -48,6 +47,10 @@ export function useSwapInput({
48
47
  const { excludeLiquiditySources: configExcludeLiquiditySources, routing } =
49
48
  useAppStore().config;
50
49
  const { connectedWallets } = useAppStore();
50
+ const anyContractWalletConnected = connectedWallets.some(
51
+ (wallet) => wallet.isContractWallet
52
+ );
53
+ const contractCall = anyContractWalletConnected;
51
54
 
52
55
  const {
53
56
  fromToken,
@@ -119,6 +122,7 @@ export function useSwapInput({
119
122
  affiliateRef,
120
123
  affiliatePercent,
121
124
  affiliateWallets,
125
+ contractCall,
122
126
  });
123
127
  if (isRoutingEnabled('experimental', routing)) {
124
128
  requestBody.experimental = true;
@@ -227,6 +231,7 @@ export function useSwapInput({
227
231
  affiliateRef,
228
232
  affiliatePercent,
229
233
  affiliateWallets,
234
+ contractCall,
230
235
  });
231
236
  return cancelFetch;
232
237
  }, [
@@ -245,6 +250,7 @@ export function useSwapInput({
245
250
  userSlippage,
246
251
  affiliateRef,
247
252
  affiliatePercent,
253
+ contractCall,
248
254
  JSON.stringify(affiliateWallets),
249
255
  ]);
250
256
 
@@ -261,6 +267,7 @@ export function useSwapInput({
261
267
  affiliateRef,
262
268
  affiliatePercent,
263
269
  affiliateWallets,
270
+ contractCall,
264
271
  }),
265
272
  loading,
266
273
  };
@@ -259,6 +259,7 @@ export const createWalletsSlice = keepLastUpdated<AppStoreState, WalletsSlice>(
259
259
  return {
260
260
  address: account.address,
261
261
  chain: account.chain,
262
+ isContractWallet: account.isContractWallet,
262
263
  explorerUrl: null,
263
264
  walletType: account.walletType,
264
265
  selected: shouldMarkWalletAsSelected,
@@ -5,6 +5,7 @@ export interface Wallet {
5
5
  chain: string;
6
6
  address: string;
7
7
  walletType: WalletType;
8
+ isContractWallet?: boolean;
8
9
  }
9
10
 
10
11
  export type Balance = {
package/src/utils/swap.ts CHANGED
@@ -455,6 +455,7 @@ export function createQuoteRequestBody(params: {
455
455
  affiliatePercent: number | null;
456
456
  affiliateWallets: { [key: string]: string } | null;
457
457
  destination?: string;
458
+ contractCall: boolean;
458
459
  }): BestRouteRequest {
459
460
  const {
460
461
  fromToken,
@@ -470,6 +471,7 @@ export function createQuoteRequestBody(params: {
470
471
  affiliatePercent,
471
472
  affiliateWallets,
472
473
  destination,
474
+ contractCall,
473
475
  } = params;
474
476
  const selectedWalletsMap = selectedWallets?.reduce(
475
477
  (
@@ -509,6 +511,7 @@ export function createQuoteRequestBody(params: {
509
511
  connectedWallets,
510
512
  selectedWallets: selectedWalletsMap ?? {},
511
513
  slippage: slippage.toString(),
514
+ contractCall,
512
515
  ...(destination && { destination: destination }),
513
516
  ...(excludeLiquiditySources && {
514
517
  swapperGroups: disabledLiquiditySources.concat(liquiditySources ?? []),
@@ -45,6 +45,8 @@ export type ExtendedModalWalletInfo = WalletInfoWithExtra &
45
45
  Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
46
46
 
47
47
  export function mapStatusToWalletState(state: WalletState): WalletStatus {
48
+ // TODO: refactor
49
+ // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
48
50
  switch (true) {
49
51
  case state.connected:
50
52
  return WalletStatus.CONNECTED;
@@ -137,7 +139,11 @@ export function prepareAccountsForWalletStore(
137
139
  ): Wallet[] {
138
140
  const result: Wallet[] = [];
139
141
 
140
- function addAccount(network: Network, address: string) {
142
+ function addAccount(
143
+ network: Network,
144
+ address: string,
145
+ isContractWallet?: boolean
146
+ ) {
141
147
  const accountForChainAlreadyExists = !!result.find(
142
148
  (account) => account.chain === network
143
149
  );
@@ -146,6 +152,7 @@ export function prepareAccountsForWalletStore(
146
152
  address,
147
153
  chain: network,
148
154
  walletType: wallet,
155
+ isContractWallet: isContractWallet ?? false,
149
156
  };
150
157
 
151
158
  result.push(newAccount);
@@ -192,7 +199,7 @@ export function prepareAccountsForWalletStore(
192
199
  * for contract wallets like Safe wallet, we should add only account for the
193
200
  * current connected blockchain not all of the supported blockchains
194
201
  */
195
- addAccount(network, address.toLowerCase());
202
+ addAccount(network, address.toLowerCase(), isContractWallet);
196
203
  } else {
197
204
  /*
198
205
  * all evm chains are not supported in wallets, so we are adding