@sodax/dapp-kit 1.2.7-beta → 1.3.1-beta-rc1

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "1.2.7-beta",
4
+ "version": "1.3.1-beta-rc1",
5
5
  "description": "dapp-kit of New World",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "viem": "2.29.2",
19
- "@sodax/sdk": "1.2.7-beta",
20
- "@sodax/types": "1.2.7-beta"
19
+ "@sodax/sdk": "1.3.1-beta-rc1",
20
+ "@sodax/types": "1.3.1-beta-rc1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "19.0.8",
@@ -38,14 +38,27 @@ export function useMMAllowance({
38
38
 
39
39
  const defaultQueryOptions = {
40
40
  queryKey: ['mm', 'allowance', params?.token, params?.action],
41
- enabled: !!spokeProvider,
41
+ /**
42
+ * IMPORTANT: Skip allowance checks for 'borrow' and 'withdraw' actions.
43
+ *
44
+ * Reason: According to the SDK's MoneyMarketService.isAllowanceValid() implementation,
45
+ * borrow and withdraw actions do NOT require ERC-20 token approval. The SDK's
46
+ * isAllowanceValid() method always returns `true` for these actions without making
47
+ * any on-chain allowance checks.
48
+ *
49
+ * This optimization prevents unnecessary RPC calls and avoids showing confusing states for actions that don't actually need approval.
50
+ *
51
+ * Only 'supply' and 'repay' actions require token approval and should trigger allowance checks.
52
+ */
53
+ enabled: !!spokeProvider && !!params && params.action !== 'borrow' && params.action !== 'withdraw',
42
54
  refetchInterval: 5000,
55
+ gcTime: 0, // Don't cache failed queries
43
56
  };
44
57
 
45
58
  queryOptions = {
46
59
  ...defaultQueryOptions,
47
60
  ...queryOptions, // override default query options if provided
48
- }
61
+ };
49
62
 
50
63
  return useQuery({
51
64
  ...queryOptions,
@@ -53,6 +66,21 @@ export function useMMAllowance({
53
66
  if (!spokeProvider) throw new Error('Spoke provider is required');
54
67
  if (!params) throw new Error('Params are required');
55
68
 
69
+ /**
70
+ * Early return for borrow/withdraw actions: these actions do NOT require ERC-20 token approval.
71
+ *
72
+ * The SDK's MoneyMarketService.isAllowanceValid() always returns `true` for borrow/withdraw
73
+ * without checking on-chain allowance. This is because:
74
+ * - Borrow: User receives tokens (no approval needed)
75
+ * - Withdraw: User withdraws their own supplied tokens (no approval needed)
76
+ *
77
+ * By returning `true` here, we avoid unnecessary RPC calls and ensure consistent behavior
78
+ * with the SDK's implementation.
79
+ */
80
+ if (params.action === 'borrow' || params.action === 'withdraw') {
81
+ return true;
82
+ }
83
+
56
84
  const allowance = await sodax.moneyMarket.isAllowanceValid(params, spokeProvider);
57
85
 
58
86
  if (!allowance.ok) {
@@ -47,13 +47,6 @@ export function useMMApprove(): UseMutationResult<string, Error, UseMMApprovePar
47
47
  return allowance.value;
48
48
  },
49
49
  onSuccess: (_, { params, spokeProvider }: UseMMApproveParams) => {
50
- console.log('onSuccess invoked with queryKey:', [
51
- 'mm',
52
- 'allowance',
53
- spokeProvider?.chainConfig.chain.id,
54
- params.token,
55
- params.action,
56
- ]);
57
50
  // Invalidate allowance query to refetch updated approval status
58
51
  queryClient.invalidateQueries({
59
52
  queryKey: ['mm', 'allowance', spokeProvider?.chainConfig.chain.id, params.token, params.action],
@@ -18,6 +18,8 @@ import {
18
18
  SONIC_MAINNET_CHAIN_ID,
19
19
  SonicSpokeProvider,
20
20
  type SonicSpokeChainConfig,
21
+ NearSpokeProvider,
22
+ type NearSpokeChainConfig,
21
23
  } from '@sodax/sdk';
22
24
  import type {
23
25
  IEvmWalletProvider,
@@ -27,6 +29,7 @@ import type {
27
29
  IInjectiveWalletProvider,
28
30
  IStellarWalletProvider,
29
31
  ISolanaWalletProvider,
32
+ INearWalletProvider,
30
33
  } from '@sodax/types';
31
34
  import { useMemo } from 'react';
32
35
 
@@ -64,9 +67,12 @@ export function useSpokeProvider(
64
67
  spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,
65
68
  );
66
69
  }
70
+ // EVM RPC: flat RpcConfig keyed by chain id (same shape as app's rpcConfig)
71
+ const evmRpcUrl = rpcConfig[spokeChainId];
67
72
  return new EvmSpokeProvider(
68
73
  walletProvider as IEvmWalletProvider,
69
74
  spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,
75
+ typeof evmRpcUrl === 'string' ? evmRpcUrl : undefined,
70
76
  );
71
77
  }
72
78
 
@@ -117,6 +123,13 @@ export function useSpokeProvider(
117
123
  );
118
124
  }
119
125
 
126
+ if (xChainType === 'NEAR') {
127
+ return new NearSpokeProvider(
128
+ walletProvider as INearWalletProvider,
129
+ spokeChainConfig[spokeChainId] as NearSpokeChainConfig,
130
+ );
131
+ }
132
+
120
133
  return undefined;
121
134
  }, [spokeChainId, xChainType, walletProvider, rpcConfig]);
122
135
 
@@ -23,12 +23,12 @@ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
23
23
  export function useConvertedAssets(amount: bigint | undefined, refetchInterval = 10000): UseQueryResult<bigint, Error> {
24
24
  const { sodax } = useSodaxContext();
25
25
 
26
- console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });
26
+ // console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });
27
27
 
28
28
  return useQuery({
29
29
  queryKey: ['soda', 'convertedAssets', amount?.toString()],
30
30
  queryFn: async () => {
31
- console.log('useConvertedAssets queryFn called with amount:', amount?.toString());
31
+ // console.log('useConvertedAssets queryFn called with amount:', amount?.toString());
32
32
  if (!amount || amount <= 0n) {
33
33
  throw new Error('Amount must be greater than 0');
34
34
  }