@sodax/dapp-kit 2.0.0-rc.1 → 2.0.0-rc.3
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/ai-exported/AGENTS.md +1 -1
- package/ai-exported/integration/ai-rules.md +1 -0
- package/ai-exported/integration/architecture.md +9 -7
- package/ai-exported/integration/features/README.md +10 -10
- package/ai-exported/integration/features/auxiliary-services.md +3 -3
- package/ai-exported/integration/features/money-market.md +30 -2
- package/ai-exported/integration/recipes/money-market.md +5 -4
- package/ai-exported/integration/recipes/setup.md +24 -0
- package/ai-exported/integration/recipes/wallet-connectivity.md +27 -0
- package/ai-exported/integration/reference/README.md +1 -1
- package/ai-exported/integration/reference/glossary.md +2 -0
- package/ai-exported/integration/reference/hooks-index.md +12 -16
- package/ai-exported/integration/reference/public-api.md +2 -2
- package/ai-exported/migration/breaking-changes/sdk-leakage.md +2 -0
- package/ai-exported/migration/features/auxiliary-services.md +3 -3
- package/ai-exported/migration/features/bridge.md +50 -13
- package/ai-exported/migration/features/money-market.md +45 -3
- package/ai-exported/migration/features/swap.md +17 -2
- package/ai-exported/migration/recipes.md +11 -14
- package/ai-exported/migration/reference/renamed-hooks.md +2 -0
- package/dist/index.cjs +3 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/providers/SodaxProvider.tsx +15 -11
|
@@ -27,7 +27,9 @@ Pair: [`../../integration/features/swap.md`](../../integration/features/swap.md)
|
|
|
27
27
|
+ if (!walletProvider) return;
|
|
28
28
|
- const result = await swap.mutateAsync({ params: intentParams });
|
|
29
29
|
- if (result.ok) {
|
|
30
|
-
-
|
|
30
|
+
- // v1: result.value was a TUPLE — destructure positionally
|
|
31
|
+
- const [executionResponse] = result.value;
|
|
32
|
+
- const txHash = executionResponse.intent_hash;
|
|
31
33
|
- /* ... */
|
|
32
34
|
- } else {
|
|
33
35
|
- toast.error(result.error.message);
|
|
@@ -37,12 +39,25 @@ Pair: [`../../integration/features/swap.md`](../../integration/features/swap.md)
|
|
|
37
39
|
+ toast.error(result.error instanceof Error ? result.error.message : 'Swap failed');
|
|
38
40
|
+ return;
|
|
39
41
|
+ }
|
|
40
|
-
+
|
|
42
|
+
+ // v2: result.value is a NAMED OBJECT (SwapResponse) — destructure by name
|
|
43
|
+
+ const { solverExecutionResponse, intent, intentDeliveryInfo } = result.value;
|
|
44
|
+
+ const intentHash = solverExecutionResponse.intent_hash; // protocol-level intent id (v1 ≈ executionResponse.intent_hash)
|
|
45
|
+
+ const spokeTxHash = intentDeliveryInfo.srcTxHash; // on-chain tx hash on srcChainKey — use for tx-history display
|
|
41
46
|
+ /* ... */
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
```
|
|
45
50
|
|
|
51
|
+
#### `SwapResponse` field map (`result.value`)
|
|
52
|
+
|
|
53
|
+
| Field | Type | Use it for |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `solverExecutionResponse` | `{ answer: 'OK'; intent_hash: Hex }` | Protocol-level intent identifier. **`solverExecutionResponse.intent_hash` is the v2 equivalent of v1's `executionResponse.intent_hash`.** Pass it to `useStatus({ params: { intentTxHash } })` to poll execution status. |
|
|
56
|
+
| `intent` | `Intent` | Intent metadata (`intentId: bigint`, `creator`, tokens, amounts, `srcChain`/`dstChain` as `IntentRelayChainId` bigints). **No transaction hashes on this object** — don't read `intent.intent_hash` (does not exist) or `intent.tx_hash`. |
|
|
57
|
+
| `intentDeliveryInfo` | `{ srcChainKey, srcTxHash, srcAddress, dstChainKey, dstTxHash, dstAddress }` | **On-chain transaction hashes.** `srcTxHash` is the spoke-chain tx on `srcChainKey` (the one that typically feeds a user-facing transaction history); `dstTxHash` is the delivery tx on `dstChainKey`. |
|
|
58
|
+
|
|
59
|
+
**Porting `[executionResponse] = result.value` (v1 tuple) → v2:** rename to `{ solverExecutionResponse } = result.value`. Any `executionResponse.intent_hash` read becomes `solverExecutionResponse.intent_hash`. If the value was being used as the **transaction hash** in a transaction-history row (not as the intent identifier), switch to `intentDeliveryInfo.srcTxHash` instead — `intent_hash` and `srcTxHash` are not interchangeable.
|
|
60
|
+
|
|
46
61
|
### `useSwapApprove` — return shape
|
|
47
62
|
|
|
48
63
|
```diff
|
|
@@ -42,28 +42,25 @@ for (const file of project.getSourceFiles('src/**/*.{ts,tsx}')) {
|
|
|
42
42
|
await project.save();
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
## Codemod 2: useSpokeProvider deletion
|
|
45
|
+
## Codemod 2: useSpokeProvider deletion (2-arg → 1-arg)
|
|
46
46
|
|
|
47
|
-
`useSpokeProvider` is gone in v2.
|
|
47
|
+
`useSpokeProvider` is gone in v2. Replace with `useWalletProvider` from `@sodax/wallet-sdk-react`.
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
# 1. Find all usages first.
|
|
51
|
-
grep -rE '\buseSpokeProvider\b' src/
|
|
52
|
-
|
|
53
|
-
# 2. Manual delete + rewrite each (no safe sed for this — context varies).
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Per call site, the rewrite:
|
|
49
|
+
v1 had **two positional args**: `useSpokeProvider(spokeChainId, walletProvider)`. v2 collapses to a single options object: `useWalletProvider({ xChainId })`. The second v1 argument is **dropped entirely** — v2 resolves the wallet provider from the wallet-sdk-react store internally based on `xChainId`. If your v1 code constructed a wallet provider separately to pass in, delete that construction code too.
|
|
57
50
|
|
|
58
51
|
```diff
|
|
52
|
+
- // v1 — 2 positional args (chainKey + walletProvider)
|
|
59
53
|
- import { useSpokeProvider } from '@sodax/dapp-kit';
|
|
60
|
-
- const spokeProvider = useSpokeProvider(
|
|
54
|
+
- const spokeProvider = useSpokeProvider(srcChainId, walletProvider);
|
|
55
|
+
|
|
56
|
+
+ // v2 — 1 options arg, no external walletProvider
|
|
61
57
|
+ import { useWalletProvider } from '@sodax/wallet-sdk-react';
|
|
62
|
-
+
|
|
63
|
-
+ const walletProvider = useWalletProvider({ xChainId: ChainKeys.BSC_MAINNET });
|
|
58
|
+
+ const walletProvider = useWalletProvider({ xChainId: srcChainId });
|
|
64
59
|
```
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
A naive single-pass regex over `useSpokeProvider\(([^)]+)\)` eats both args and produces invalid `useWalletProvider({ xChainId: chainKey, walletProvider })`. Do the rewrite in two passes: first the call shape (drop the second positional arg), then the import (from `@sodax/dapp-kit` → `@sodax/wallet-sdk-react`). A small number of v1 callers used the single-arg form `useSpokeProvider(chainId)` — handle those separately since they don't have a second arg to drop.
|
|
62
|
+
|
|
63
|
+
Update downstream consumers of `spokeProvider` to use `walletProvider` instead — usually inside `mutate(vars)` payloads or query hook params. The field name on payloads also renamed `spokeProvider:` → `walletProvider:` (see `@sodax/sdk/ai-exported/migration/checklist.md` step 7b).
|
|
67
64
|
|
|
68
65
|
## Codemod 3: invalidate*Queries utilities deletion
|
|
69
66
|
|
|
@@ -29,6 +29,8 @@ These keep their name but their TypeScript signature is different. Usually requi
|
|
|
29
29
|
| `useMMAllowance` | Query params: `{ params: { payload: MoneyMarketParams<K> } }`. For `'borrow'` / `'withdraw'` actions: `enabled: false` — `data` stays `undefined`. |
|
|
30
30
|
| `useUserReservesData` | Param key rename: `address → userAddress`; chain key is `spokeChainKey`. |
|
|
31
31
|
| `useUserFormattedSummary` | Same. |
|
|
32
|
+
| `useATokensBalances` | Params: `{ aTokens, spokeProvider, userAddress } → { params: { aTokens, spokeChainKey, userAddress } }`. `spokeProvider` dropped; chain key is **`spokeChainKey`** (NOT `srcChainKey`); user field is **`userAddress`** (NOT `address`). Data: `Map<Address, bigint> \| undefined` (already unwrapped). |
|
|
33
|
+
| `useAToken` | Unaffected by the position-hook renames — takes only `{ aToken }`. Data: `Erc20Token & { chainKey }` (`hubAsset` / `vault` NOT included). |
|
|
32
34
|
| All staking mutations | Same as MM. Plus dedicated approve hooks per token (`useStakeApprove` ↔ `useUnstakeApprove` ↔ `useInstantUnstakeApprove`). |
|
|
33
35
|
| `useStakeRatio` | Return: `Result<bigint> → [xSodaAmount, previewDepositAmount]` (unwrapped tuple — NOT Result-wrapped in v2). |
|
|
34
36
|
| `useStakingInfo` / `useUnstakingInfo` / `useUnstakingInfoWithPenalty` / `useStakingConfig` / `useInstantUnstakeRatio` / `useConvertedAssets` | All unwrapped in v2 (hooks throw on SDK `!ok`). Branch on `isError`/`error`, not `data?.ok`. |
|
package/dist/index.cjs
CHANGED
|
@@ -2484,10 +2484,9 @@ function useClaimRewards({
|
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
var SodaxProvider = ({ children, config }) => {
|
|
2487
|
-
const
|
|
2488
|
-
const
|
|
2489
|
-
|
|
2490
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SodaxContext.Provider, { value: { sodax }, children });
|
|
2487
|
+
const sodax = react.useMemo(() => new sdk.Sodax(config), [config]);
|
|
2488
|
+
const contextValue = react.useMemo(() => ({ sodax }), [sodax]);
|
|
2489
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SodaxContext.Provider, { value: contextValue, children });
|
|
2491
2490
|
};
|
|
2492
2491
|
var defaultOnMutationError = (error) => {
|
|
2493
2492
|
console.error("[sodax] Mutation error:", error);
|