@sodax/dapp-kit 2.3.0 → 2.4.0-rc.2
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/README.md +10 -2
- package/dist/index.d.ts +182 -31
- package/dist/index.mjs +297 -25
- package/package.json +10 -5
- package/src/hooks/_mutationContract.test.ts +1 -0
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.test.ts +28 -3
- package/src/hooks/bridge/getBridgeDetailedStatusRefetchInterval.ts +17 -8
- package/src/hooks/bridge/useBridge.ts +6 -0
- package/src/hooks/bridge/useBridgeDetailedStatus.test.ts +56 -1
- package/src/hooks/bridge/useBridgeDetailedStatus.ts +26 -9
- package/src/hooks/bridge/useBridgeWithApproval.test.ts +24 -1
- package/src/hooks/bridge/useBridgeWithApproval.ts +6 -0
- package/src/hooks/dex/useDexDeposit.ts +6 -0
- package/src/hooks/dex/useDexWithdraw.ts +12 -5
- package/src/hooks/mm/useBorrow.ts +15 -4
- package/src/hooks/mm/useRepay.ts +6 -0
- package/src/hooks/mm/useSupply.ts +6 -0
- package/src/hooks/mm/useWithdraw.ts +12 -5
- package/src/hooks/recovery/useWithdrawHubAsset.ts +12 -5
- package/src/hooks/shared/index.ts +4 -0
- package/src/hooks/shared/notFoundStreak.ts +5 -0
- package/src/hooks/shared/retryBeforeSubmission.ts +26 -0
- package/src/hooks/shared/useBalances.test.ts +10 -0
- package/src/hooks/shared/useBalances.ts +17 -4
- package/src/hooks/shared/useEstablishXrpTrustline.test.ts +113 -0
- package/src/hooks/shared/useEstablishXrpTrustline.ts +65 -0
- package/src/hooks/shared/useSafeMutation.retry.test.ts +47 -0
- package/src/hooks/shared/useSafeMutation.ts +8 -1
- package/src/hooks/shared/useXrpDestinationCheck.ts +75 -0
- package/src/hooks/shared/useXrpGate.test.ts +118 -0
- package/src/hooks/shared/useXrpGate.ts +81 -0
- package/src/hooks/shared/useXrpTrustlineReserveCheck.ts +45 -0
- package/src/hooks/swap/useCreateLimitOrder.ts +8 -0
- package/src/hooks/swap/useSwap.ts +6 -0
- package/src/hooks/swap/useSwapLifecycle.test.ts +73 -1
- package/src/hooks/swap/useSwapLifecycle.ts +29 -5
- package/src/hooks/swap/useSwapWithApproval.test.ts +24 -1
- package/src/hooks/swap/useSwapWithApproval.ts +6 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/swapLifecycle.test.ts +35 -0
- package/src/utils/swapLifecycle.ts +29 -5
- package/src/utils/xrpGate.test.ts +112 -0
- package/src/utils/xrpGate.ts +72 -0
|
@@ -10,6 +10,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
10
10
|
import {
|
|
11
11
|
advanceNotFoundStreak,
|
|
12
12
|
INITIAL_NOT_FOUND_STREAK,
|
|
13
|
+
MAX_MPC_RELAY_NOT_FOUND_POLLS,
|
|
13
14
|
MAX_NOT_FOUND_POLLS,
|
|
14
15
|
STATUS_POLL_MS,
|
|
15
16
|
} from '../shared/notFoundStreak.js';
|
|
@@ -20,9 +21,10 @@ import {
|
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Guards the polling-stop invariant for `useBridgeDetailedStatus.refetchInterval`: stop on a
|
|
23
|
-
* terminal or abandoned backend record, on any relay packet
|
|
24
|
-
* key, and on an exhausted not-delivered budget — but keep polling
|
|
25
|
-
* pure function because dapp-kit's vitest runs in the `node`
|
|
24
|
+
* terminal or abandoned backend record, on any relay packet or MPC deposit record (always
|
|
25
|
+
* terminal), on a rejected API key, and on an exhausted not-delivered budget — but keep polling
|
|
26
|
+
* through an outage. Tested as a pure function because dapp-kit's vitest runs in the `node`
|
|
27
|
+
* environment.
|
|
26
28
|
*/
|
|
27
29
|
const KEY_A = 'arb:0xaaa';
|
|
28
30
|
const KEY_B = 'arb:0xbbb';
|
|
@@ -52,6 +54,19 @@ const packet: PacketData = {
|
|
|
52
54
|
|
|
53
55
|
const relayed: Read = { ok: true, value: { source: 'relay', data: packet } };
|
|
54
56
|
|
|
57
|
+
const minted: Read = {
|
|
58
|
+
ok: true,
|
|
59
|
+
value: {
|
|
60
|
+
source: 'mpcRelay',
|
|
61
|
+
data: {
|
|
62
|
+
depositId: 'id',
|
|
63
|
+
status: 'minted',
|
|
64
|
+
createdAt: 0,
|
|
65
|
+
txs: { hubMint: { chain: 'sonic', hash: '0xdst', ts: 0 } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
55
70
|
const lookupFailed = (context: Record<string, unknown>): Read => ({
|
|
56
71
|
ok: false,
|
|
57
72
|
error: new SodaxError('LOOKUP_FAILED', 'no source could answer', {
|
|
@@ -61,6 +76,7 @@ const lookupFailed = (context: Record<string, unknown>): Read => ({
|
|
|
61
76
|
});
|
|
62
77
|
|
|
63
78
|
const notDelivered = lookupFailed({ reason: DETAILED_STATUS_NOT_DELIVERED });
|
|
79
|
+
const mpcRelayNotDelivered = lookupFailed({ reason: DETAILED_STATUS_NOT_DELIVERED, mpcRelay: true });
|
|
64
80
|
const outage = lookupFailed({});
|
|
65
81
|
const rejectedKey = lookupFailed({ status: 401 });
|
|
66
82
|
|
|
@@ -93,6 +109,10 @@ describe('getBridgeDetailedStatusRefetchInterval', () => {
|
|
|
93
109
|
expect(getBridgeDetailedStatusRefetchInterval(relayed, 0)).toBe(false);
|
|
94
110
|
});
|
|
95
111
|
|
|
112
|
+
it('stops on a minted MPC-relay deposit record — that arm is terminal on arrival too', () => {
|
|
113
|
+
expect(getBridgeDetailedStatusRefetchInterval(minted, 0)).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
|
|
96
116
|
it('stops on a rejected API key, at the first read', () => {
|
|
97
117
|
expect(getBridgeDetailedStatusRefetchInterval(rejectedKey, 0)).toBe(false);
|
|
98
118
|
});
|
|
@@ -102,6 +122,11 @@ describe('getBridgeDetailedStatusRefetchInterval', () => {
|
|
|
102
122
|
expect(getBridgeDetailedStatusRefetchInterval(notDelivered, MAX_NOT_FOUND_POLLS)).toBe(false);
|
|
103
123
|
});
|
|
104
124
|
|
|
125
|
+
it('gives a miss on a bridge with an MPC-relay end the longer budget', () => {
|
|
126
|
+
expect(getBridgeDetailedStatusRefetchInterval(mpcRelayNotDelivered, MAX_NOT_FOUND_POLLS)).toBe(STATUS_POLL_MS);
|
|
127
|
+
expect(getBridgeDetailedStatusRefetchInterval(mpcRelayNotDelivered, MAX_MPC_RELAY_NOT_FOUND_POLLS)).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
105
130
|
it('keeps polling an outage forever — that is how the read recovers', () => {
|
|
106
131
|
expect(getBridgeDetailedStatusRefetchInterval(outage, MAX_NOT_FOUND_POLLS)).toBe(STATUS_POLL_MS);
|
|
107
132
|
});
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type DetailedBridgeStatus,
|
|
6
6
|
type Result,
|
|
7
7
|
} from '@sodax/sdk';
|
|
8
|
-
import { MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
|
|
8
|
+
import { MAX_MPC_RELAY_NOT_FOUND_POLLS, MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Structural mirror of `useBridgeDetailedStatus`'s data type. Declared locally rather than imported
|
|
@@ -23,13 +23,19 @@ export function isBridgeNotDelivered(data: DetailedBridgeStatusRead): boolean {
|
|
|
23
23
|
return data !== undefined && !data.ok && data.error?.context?.reason === DETAILED_STATUS_NOT_DELIVERED;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** A read the SDK tags `context.mpcRelay`: a bridge with an MPC-relay end, which gets the longer budget. */
|
|
27
|
+
export function isBridgeMpcRelayRead(data: DetailedBridgeStatusRead): boolean {
|
|
28
|
+
return data !== undefined && !data.ok && data.error?.context?.mpcRelay === true;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Polling interval for `useBridgeDetailedStatus`.
|
|
28
33
|
*
|
|
29
34
|
* Unlike the swap analog there is no in-flight second arm to wait on: the relay arm only ever
|
|
30
|
-
* carries a matched `executed` packet,
|
|
31
|
-
* terminal
|
|
32
|
-
* run `MAX_NOT_FOUND_POLLS` times in a row
|
|
35
|
+
* carries a matched `executed` packet, and the MPC-relay arm a minted deposit record, so both are
|
|
36
|
+
* terminal on arrival. That leaves three stops — a terminal or abandoned backend record, a rejected
|
|
37
|
+
* API key, and the ambiguous relay miss once it has run `MAX_NOT_FOUND_POLLS` times in a row, or
|
|
38
|
+
* `MAX_MPC_RELAY_NOT_FOUND_POLLS` when the SDK tags it `context.mpcRelay`.
|
|
33
39
|
*
|
|
34
40
|
* Kept in its own pure module (no React/context imports) so it is unit-testable in dapp-kit's `node`
|
|
35
41
|
* test environment — importing the hook itself pulls in `useSodaxContext`.
|
|
@@ -39,14 +45,17 @@ export function getBridgeDetailedStatusRefetchInterval(
|
|
|
39
45
|
consecutiveNotFound: number,
|
|
40
46
|
): number | false {
|
|
41
47
|
if (data?.ok) {
|
|
42
|
-
if (data.value.source
|
|
48
|
+
if (data.value.source !== 'backend') return false;
|
|
43
49
|
// The two terminal states of the bridge wire contract, plus a record the backend abandoned
|
|
44
50
|
// while its status was still non-terminal.
|
|
45
51
|
const { status, abandonedAt } = data.value.data;
|
|
46
52
|
return status === 'executed' || status === 'failed' || abandonedAt ? false : STATUS_POLL_MS;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
if (data && !data.ok) {
|
|
55
|
+
// A rejected key is terminal — only a corrected key changes the answer, so stop asking.
|
|
56
|
+
if (isAuthFailure(data.error)) return false;
|
|
57
|
+
const budget = isBridgeMpcRelayRead(data) ? MAX_MPC_RELAY_NOT_FOUND_POLLS : MAX_NOT_FOUND_POLLS;
|
|
58
|
+
if (isBridgeNotDelivered(data) && consecutiveNotFound >= budget) return false;
|
|
59
|
+
}
|
|
51
60
|
return STATUS_POLL_MS;
|
|
52
61
|
}
|
|
@@ -6,6 +6,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Mutation variables for {@link useBridge}. Generic over `K extends SpokeChainKey` (defaults to
|
|
@@ -29,6 +30,11 @@ export function useBridge<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
29
30
|
return useSafeMutation<TxHashPair, Error, UseBridgeVars<K>>({
|
|
30
31
|
mutationKey: ['bridge'],
|
|
31
32
|
...mutationOptions,
|
|
33
|
+
retry: retryBeforeSubmission(
|
|
34
|
+
mutationOptions?.retry ??
|
|
35
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['bridge'])?.retry ??
|
|
36
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
37
|
+
),
|
|
32
38
|
mutationFn: async vars => unwrapResult(await sodax.bridge.bridge({ ...vars, raw: false })),
|
|
33
39
|
onSuccess: async (data, vars, ctx) => {
|
|
34
40
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
|
|
2
|
+
import { MAX_MPC_RELAY_NOT_FOUND_POLLS, MAX_NOT_FOUND_POLLS, STATUS_POLL_MS } from '../shared/notFoundStreak.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Pins the WIRING the pure-policy test cannot see: the hook must pass the read into the policy and
|
|
@@ -73,12 +73,36 @@ describe('useBridgeDetailedStatus wiring', () => {
|
|
|
73
73
|
);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
it('keys and reads by the destination too, which decides when a Tron-source bridge is delivered', async () => {
|
|
77
|
+
refCursor = 0;
|
|
78
|
+
useBridgeDetailedStatus({ params: { srcChainKey: 'tron', srcTxHash: SRC_TX, dstChainKey: SRC_CHAIN } });
|
|
79
|
+
expect(captured.queryKey).toEqual(['bridge', 'detailedStatus', 'tron', SRC_TX, SRC_CHAIN]);
|
|
80
|
+
await captured.queryFn();
|
|
81
|
+
expect(getDetailedStatus).toHaveBeenLastCalledWith(
|
|
82
|
+
{ srcChainKey: 'tron', srcTxHash: SRC_TX, dstChainKey: SRC_CHAIN },
|
|
83
|
+
undefined,
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
76
87
|
it('feeds the read into the policy, so a terminal answer stops the poll', () => {
|
|
77
88
|
render();
|
|
78
89
|
const relayed = { ok: true, value: { source: 'relay', data: { dst_tx_hash: '0xdst' } } };
|
|
79
90
|
expect(captured.refetchInterval({ state: { data: relayed, dataUpdateCount: 1 } })).toBe(false);
|
|
80
91
|
});
|
|
81
92
|
|
|
93
|
+
it('gives the leg after the hub mint a budget of its own', () => {
|
|
94
|
+
refSlots.length = 0;
|
|
95
|
+
render();
|
|
96
|
+
for (let update = 1; update <= MAX_NOT_FOUND_POLLS - 1; update++) {
|
|
97
|
+
captured.refetchInterval({ state: { data: notDeliveredRead, dataUpdateCount: update } });
|
|
98
|
+
}
|
|
99
|
+
const onwardMiss = {
|
|
100
|
+
ok: false,
|
|
101
|
+
error: { code: 'LOOKUP_FAILED', context: { reason: 'relay_not_delivered', hubTxHash: '0xhub' } },
|
|
102
|
+
};
|
|
103
|
+
expect(captured.refetchInterval({ state: { data: onwardMiss, dataUpdateCount: 40 } })).toBe(STATUS_POLL_MS);
|
|
104
|
+
});
|
|
105
|
+
|
|
82
106
|
it('advances the not-delivered budget once per update, and stops when it is spent', () => {
|
|
83
107
|
refSlots.length = 0;
|
|
84
108
|
render();
|
|
@@ -90,4 +114,35 @@ describe('useBridgeDetailedStatus wiring', () => {
|
|
|
90
114
|
expect(captured.refetchInterval({ state: { data: notDeliveredRead, dataUpdateCount: 39 } })).toBe(STATUS_POLL_MS);
|
|
91
115
|
expect(captured.refetchInterval({ state: { data: notDeliveredRead, dataUpdateCount: 40 } })).toBe(false);
|
|
92
116
|
});
|
|
117
|
+
|
|
118
|
+
it('gives a miss the SDK tags as an MPC-relay bridge the longer budget', () => {
|
|
119
|
+
refSlots.length = 0;
|
|
120
|
+
render();
|
|
121
|
+
const mpcRelayMiss = {
|
|
122
|
+
ok: false,
|
|
123
|
+
error: { code: 'LOOKUP_FAILED', context: { reason: 'relay_not_delivered', mpcRelay: true } },
|
|
124
|
+
};
|
|
125
|
+
for (let update = 1; update < MAX_MPC_RELAY_NOT_FOUND_POLLS; update++) {
|
|
126
|
+
expect(captured.refetchInterval({ state: { data: mpcRelayMiss, dataUpdateCount: update } })).toBe(STATUS_POLL_MS);
|
|
127
|
+
}
|
|
128
|
+
const last = { state: { data: mpcRelayMiss, dataUpdateCount: MAX_MPC_RELAY_NOT_FOUND_POLLS } };
|
|
129
|
+
expect(captured.refetchInterval(last)).toBe(false);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('does not let one untagged miss cut an MPC-relay streak to the short budget', () => {
|
|
133
|
+
refSlots.length = 0;
|
|
134
|
+
render();
|
|
135
|
+
const mpcRelayMiss = {
|
|
136
|
+
ok: false,
|
|
137
|
+
error: { code: 'LOOKUP_FAILED', context: { reason: 'relay_not_delivered', mpcRelay: true } },
|
|
138
|
+
};
|
|
139
|
+
let update = 0;
|
|
140
|
+
while (update < MAX_NOT_FOUND_POLLS + 5) {
|
|
141
|
+
update += 1;
|
|
142
|
+
captured.refetchInterval({ state: { data: mpcRelayMiss, dataUpdateCount: update } });
|
|
143
|
+
}
|
|
144
|
+
expect(captured.refetchInterval({ state: { data: notDeliveredRead, dataUpdateCount: update + 1 } })).toBe(
|
|
145
|
+
STATUS_POLL_MS,
|
|
146
|
+
);
|
|
147
|
+
});
|
|
93
148
|
});
|
|
@@ -12,6 +12,7 @@ import type { ReadHookParams } from '../shared/types.js';
|
|
|
12
12
|
import { advanceNotFoundStreak, INITIAL_NOT_FOUND_STREAK } from '../shared/notFoundStreak.js';
|
|
13
13
|
import {
|
|
14
14
|
getBridgeDetailedStatusRefetchInterval,
|
|
15
|
+
isBridgeMpcRelayRead,
|
|
15
16
|
isBridgeNotDelivered,
|
|
16
17
|
} from './getBridgeDetailedStatusRefetchInterval.js';
|
|
17
18
|
|
|
@@ -22,30 +23,41 @@ export type UseBridgeDetailedStatusParams = ReadHookParams<
|
|
|
22
23
|
{
|
|
23
24
|
srcChainKey: SpokeChainKey | undefined;
|
|
24
25
|
srcTxHash: string | undefined;
|
|
26
|
+
/** The bridge's destination; from Tron to another spoke the read waits for that leg. */
|
|
27
|
+
dstChainKey?: SpokeChainKey;
|
|
25
28
|
apiConfig?: RequestOverrideConfig;
|
|
26
29
|
}
|
|
27
30
|
>;
|
|
28
31
|
|
|
32
|
+
/** The hub tx a miss is waiting on past, once its first leg has reached the hub. */
|
|
33
|
+
function onwardHubTxHash(data: UseBridgeDetailedStatusResult): string | undefined {
|
|
34
|
+
const hubTxHash = data && !data.ok ? data.error.context?.hubTxHash : undefined;
|
|
35
|
+
return typeof hubTxHash === 'string' ? hubTxHash : undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
39
|
* Hook for monitoring a bridge from its source-chain transaction.
|
|
31
40
|
*
|
|
32
41
|
* `useBridgeApiSubmitTxStatus` needs the backend to still hold a usable record; this takes
|
|
33
|
-
* `(srcChainKey, srcTxHash)` — the pair you hold after `bridge()`
|
|
42
|
+
* `(srcChainKey, srcTxHash)` — the pair you hold after `bridge()`, plus `dstChainKey` for a bridge from Tron —
|
|
43
|
+
* and routes to whichever source
|
|
34
44
|
* can answer, so it also covers a bridge the client-side fallback completed. `data.value` is
|
|
35
45
|
* discriminated on `source`, and each variant carries that source's payload unmodified.
|
|
36
46
|
*
|
|
37
47
|
* Polls every 3s. Stops once the answering source is terminal (a relay packet always is), once the
|
|
38
48
|
* backend rejects the API key, and — like `useDetailedStatus` — after 40 consecutive *ambiguous*
|
|
39
|
-
* reads, meaning a `LOOKUP_FAILED` whose relay has no packet for the tx
|
|
49
|
+
* reads, meaning a `LOOKUP_FAILED` whose relay has no packet for the tx — 100, about 5 minutes, for a bridge
|
|
50
|
+
* with an MPC-relay end (`context.mpcRelay`), which settles more slowly. A dependency outage keeps
|
|
40
51
|
* polling instead, so the read recovers by itself; any real answer resets the budget. Override with
|
|
41
52
|
* `queryOptions.refetchInterval`.
|
|
42
53
|
*
|
|
43
54
|
* @example
|
|
44
55
|
* ```typescript
|
|
45
|
-
* const { data } = useBridgeDetailedStatus({ params: { srcChainKey, srcTxHash } });
|
|
56
|
+
* const { data } = useBridgeDetailedStatus({ params: { srcChainKey, srcTxHash, dstChainKey } });
|
|
46
57
|
* if (data?.ok && data.value.source === 'relay') console.log(data.value.data.dst_tx_hash);
|
|
47
58
|
* ```
|
|
48
59
|
*/
|
|
60
|
+
|
|
49
61
|
export const useBridgeDetailedStatus = ({
|
|
50
62
|
params,
|
|
51
63
|
queryOptions,
|
|
@@ -53,26 +65,31 @@ export const useBridgeDetailedStatus = ({
|
|
|
53
65
|
const { sodax } = useSodaxContext();
|
|
54
66
|
const srcChainKey = params?.srcChainKey;
|
|
55
67
|
const srcTxHash = params?.srcTxHash;
|
|
68
|
+
const dstChainKey = params?.dstChainKey;
|
|
56
69
|
const apiConfig = params?.apiConfig;
|
|
57
70
|
// Composite identity: a new bridge must start its own not-delivered budget.
|
|
58
|
-
const pollKey = srcChainKey && srcTxHash ? `${srcChainKey}:${srcTxHash}` : undefined;
|
|
71
|
+
const pollKey = srcChainKey && srcTxHash ? `${srcChainKey}:${srcTxHash}:${dstChainKey ?? ''}` : undefined;
|
|
59
72
|
const notFoundStreakRef = useRef({ ...INITIAL_NOT_FOUND_STREAK });
|
|
60
73
|
|
|
61
74
|
return useQuery({
|
|
62
|
-
queryKey: ['bridge', 'detailedStatus', srcChainKey, srcTxHash],
|
|
75
|
+
queryKey: ['bridge', 'detailedStatus', srcChainKey, srcTxHash, ...(dstChainKey ? [dstChainKey] : [])],
|
|
63
76
|
queryFn: async () => {
|
|
64
77
|
if (!srcChainKey || !srcTxHash) return undefined;
|
|
65
|
-
return sodax.bridge.getDetailedStatus({ srcChainKey, srcTxHash }, apiConfig);
|
|
78
|
+
return sodax.bridge.getDetailedStatus({ srcChainKey, srcTxHash, dstChainKey }, apiConfig);
|
|
66
79
|
},
|
|
67
80
|
enabled: !!srcChainKey && !!srcTxHash,
|
|
68
81
|
refetchInterval: query => {
|
|
82
|
+
// Reaching the hub is progress, so the leg after it gets a budget of its own. An MPC-relay miss counts
|
|
83
|
+
// on its own streak too, so one untagged miss in between cannot cut its longer budget short.
|
|
84
|
+
const { data } = query.state;
|
|
85
|
+
const leg = [onwardHubTxHash(data), isBridgeMpcRelayRead(data) ? 'mpcRelay' : undefined].filter(Boolean);
|
|
69
86
|
notFoundStreakRef.current = advanceNotFoundStreak(
|
|
70
87
|
notFoundStreakRef.current,
|
|
71
|
-
pollKey,
|
|
72
|
-
isBridgeNotDelivered(
|
|
88
|
+
pollKey && [pollKey, ...leg].join(':'),
|
|
89
|
+
isBridgeNotDelivered(data),
|
|
73
90
|
query.state.dataUpdateCount,
|
|
74
91
|
);
|
|
75
|
-
return getBridgeDetailedStatusRefetchInterval(
|
|
92
|
+
return getBridgeDetailedStatusRefetchInterval(data, notFoundStreakRef.current.consecutiveNotFound);
|
|
76
93
|
},
|
|
77
94
|
...queryOptions,
|
|
78
95
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainKeys } from '@sodax/sdk';
|
|
1
|
+
import { ATOMIC_BATCH_UNCONFIRMED, ChainKeys, SodaxError } from '@sodax/sdk';
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
const VARS = {
|
|
@@ -8,6 +8,7 @@ const VARS = {
|
|
|
8
8
|
|
|
9
9
|
type CapturedMutation = {
|
|
10
10
|
mutationKey: unknown;
|
|
11
|
+
retry: (failureCount: number, error: Error) => boolean;
|
|
11
12
|
mutationFn: (vars: unknown) => Promise<unknown>;
|
|
12
13
|
onSuccess: (data: unknown, vars: typeof VARS, ctx: unknown) => Promise<void>;
|
|
13
14
|
};
|
|
@@ -33,6 +34,28 @@ beforeEach(() => {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
describe('useBridgeWithApproval', () => {
|
|
37
|
+
it.each([
|
|
38
|
+
{ batchId: 'batch-1' },
|
|
39
|
+
{ reason: ATOMIC_BATCH_UNCONFIRMED },
|
|
40
|
+
])('suppresses configured retries after an unconfirmed batch ($context)', context => {
|
|
41
|
+
useBridgeWithApproval({ mutationOptions: { retry: 3 } });
|
|
42
|
+
const error = new SodaxError('TX_VERIFICATION_FAILED', 'Batch was sent but not confirmed', {
|
|
43
|
+
feature: 'bridge',
|
|
44
|
+
context,
|
|
45
|
+
});
|
|
46
|
+
expect(captured.retry(0, error)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('suppresses configured retries when the original source hash is known', () => {
|
|
50
|
+
useBridgeWithApproval({ mutationOptions: { retry: 3 } });
|
|
51
|
+
const error = new SodaxError('RELAY_TIMEOUT', 'Settlement pending', {
|
|
52
|
+
feature: 'bridge',
|
|
53
|
+
context: { srcTxHash: '0x1234' },
|
|
54
|
+
});
|
|
55
|
+
expect(captured.retry(0, error)).toBe(false);
|
|
56
|
+
expect(captured.retry(0, new Error('Before submission'))).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
36
59
|
it('keys the mutation under bridge and calls bridgeWithApproval in signed mode', async () => {
|
|
37
60
|
bridgeWithApproval.mockResolvedValueOnce({ ok: true, value: { approvalStrategy: 'atomic-batch' } });
|
|
38
61
|
useBridgeWithApproval();
|
|
@@ -4,6 +4,7 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
|
4
4
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
5
5
|
import type { MutationHookParams } from '../shared/types.js';
|
|
6
6
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
7
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
7
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -37,6 +38,11 @@ export function useBridgeWithApproval<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
37
38
|
return useSafeMutation<BridgeWithApprovalResponse, Error, UseBridgeWithApprovalVars<K>>({
|
|
38
39
|
mutationKey: ['bridge', 'bridgeWithApproval'],
|
|
39
40
|
...mutationOptions,
|
|
41
|
+
retry: retryBeforeSubmission(
|
|
42
|
+
mutationOptions?.retry ??
|
|
43
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['bridge', 'bridgeWithApproval'])?.retry ??
|
|
44
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
45
|
+
),
|
|
40
46
|
mutationFn: async vars => unwrapResult(await sodax.bridge.bridgeWithApproval({ ...vars, raw: false })),
|
|
41
47
|
onSuccess: async (data, vars, ctx) => {
|
|
42
48
|
invalidateBalances(queryClient, vars.params.srcChainKey, vars.params.dstChainKey);
|
|
@@ -5,6 +5,7 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
8
9
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -44,6 +45,11 @@ export function useDexDeposit<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
44
45
|
return useSafeMutation<TxHashPair, Error, UseDexDepositVars<K>>({
|
|
45
46
|
mutationKey: ['dex', 'deposit'],
|
|
46
47
|
...mutationOptions,
|
|
48
|
+
retry: retryBeforeSubmission(
|
|
49
|
+
mutationOptions?.retry ??
|
|
50
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['dex', 'deposit'])?.retry ??
|
|
51
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
52
|
+
),
|
|
47
53
|
mutationFn: async vars => unwrapResult(await sodax.dex.assetService.deposit({ ...vars, raw: false })),
|
|
48
54
|
onSuccess: async (data, vars, ctx) => {
|
|
49
55
|
const { params } = vars;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// packages/dapp-kit/src/hooks/dex/useDexWithdraw.ts
|
|
2
|
-
import type { AssetWithdrawAction, SpokeChainKey,
|
|
2
|
+
import type { AssetWithdrawAction, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
8
9
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -18,21 +19,27 @@ export type UseDexWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<A
|
|
|
18
19
|
* React hook for withdrawing an asset from a DEX pool.
|
|
19
20
|
*
|
|
20
21
|
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
21
|
-
* `onError`, `retry`). Returns the unwrapped
|
|
22
|
+
* `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
|
|
23
|
+
* from Tron the relay's `trackingId` beside the destination tx.
|
|
22
24
|
*/
|
|
23
25
|
export function useDexWithdraw<K extends SpokeChainKey = SpokeChainKey>({
|
|
24
26
|
mutationOptions,
|
|
25
|
-
}: MutationHookParams<
|
|
26
|
-
|
|
27
|
+
}: MutationHookParams<OutboundSettlement<K>, UseDexWithdrawVars<K>> = {}): SafeUseMutationResult<
|
|
28
|
+
OutboundSettlement<K>,
|
|
27
29
|
Error,
|
|
28
30
|
UseDexWithdrawVars<K>
|
|
29
31
|
> {
|
|
30
32
|
const { sodax } = useSodaxContext();
|
|
31
33
|
const queryClient = useQueryClient();
|
|
32
34
|
|
|
33
|
-
return useSafeMutation<
|
|
35
|
+
return useSafeMutation<OutboundSettlement<K>, Error, UseDexWithdrawVars<K>>({
|
|
34
36
|
mutationKey: ['dex', 'withdraw'],
|
|
35
37
|
...mutationOptions,
|
|
38
|
+
retry: retryBeforeSubmission(
|
|
39
|
+
mutationOptions?.retry ??
|
|
40
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['dex', 'withdraw'])?.retry ??
|
|
41
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
42
|
+
),
|
|
36
43
|
mutationFn: async vars => unwrapResult(await sodax.dex.assetService.withdraw({ ...vars, raw: false })),
|
|
37
44
|
onSuccess: async (data, vars, ctx) => {
|
|
38
45
|
const { params } = vars;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// packages/dapp-kit/src/hooks/mm/useBorrow.ts
|
|
2
|
-
import type { MoneyMarketBorrowActionParams, SpokeChainKey,
|
|
2
|
+
import type { MoneyMarketBorrowActionParams, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Mutation variables for {@link useBorrow}. Generic over `K extends SpokeChainKey` (defaults to
|
|
@@ -21,17 +22,27 @@ export type UseBorrowVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
|
21
22
|
* React hook for borrowing tokens from the Sodax money market protocol.
|
|
22
23
|
*
|
|
23
24
|
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
24
|
-
* `onError`, `retry`). Returns the unwrapped
|
|
25
|
+
* `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
|
|
26
|
+
* from Tron the relay's `trackingId` beside the destination tx.
|
|
25
27
|
*/
|
|
26
28
|
export function useBorrow<K extends SpokeChainKey = SpokeChainKey>({
|
|
27
29
|
mutationOptions,
|
|
28
|
-
}: MutationHookParams<
|
|
30
|
+
}: MutationHookParams<OutboundSettlement<K>, UseBorrowVars<K>> = {}): SafeUseMutationResult<
|
|
31
|
+
OutboundSettlement<K>,
|
|
32
|
+
Error,
|
|
33
|
+
UseBorrowVars<K>
|
|
34
|
+
> {
|
|
29
35
|
const { sodax } = useSodaxContext();
|
|
30
36
|
const queryClient = useQueryClient();
|
|
31
37
|
|
|
32
|
-
return useSafeMutation<
|
|
38
|
+
return useSafeMutation<OutboundSettlement<K>, Error, UseBorrowVars<K>>({
|
|
33
39
|
mutationKey: ['mm', 'borrow'],
|
|
34
40
|
...mutationOptions,
|
|
41
|
+
retry: retryBeforeSubmission(
|
|
42
|
+
mutationOptions?.retry ??
|
|
43
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['mm', 'borrow'])?.retry ??
|
|
44
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
45
|
+
),
|
|
35
46
|
mutationFn: async vars => unwrapResult(await sodax.moneyMarket.borrow({ ...vars, raw: false })),
|
|
36
47
|
onSuccess: async (data, vars, ctx) => {
|
|
37
48
|
const { params } = vars;
|
package/src/hooks/mm/useRepay.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
8
9
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -29,6 +30,11 @@ export function useRepay<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
29
30
|
return useSafeMutation<TxHashPair, Error, UseRepayVars<K>>({
|
|
30
31
|
mutationKey: ['mm', 'repay'],
|
|
31
32
|
...mutationOptions,
|
|
33
|
+
retry: retryBeforeSubmission(
|
|
34
|
+
mutationOptions?.retry ??
|
|
35
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['mm', 'repay'])?.retry ??
|
|
36
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
37
|
+
),
|
|
32
38
|
mutationFn: async vars => unwrapResult(await sodax.moneyMarket.repay({ ...vars, raw: false })),
|
|
33
39
|
onSuccess: async (data, vars, ctx) => {
|
|
34
40
|
const { params } = vars;
|
|
@@ -5,6 +5,7 @@ import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
8
9
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -44,6 +45,11 @@ export function useSupply<K extends SpokeChainKey = SpokeChainKey>({
|
|
|
44
45
|
return useSafeMutation<TxHashPair, Error, UseSupplyVars<K>>({
|
|
45
46
|
mutationKey: ['mm', 'supply'],
|
|
46
47
|
...mutationOptions,
|
|
48
|
+
retry: retryBeforeSubmission(
|
|
49
|
+
mutationOptions?.retry ??
|
|
50
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['mm', 'supply'])?.retry ??
|
|
51
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
52
|
+
),
|
|
47
53
|
mutationFn: async vars => unwrapResult(await sodax.moneyMarket.supply({ ...vars, raw: false })),
|
|
48
54
|
onSuccess: async (data, vars, ctx) => {
|
|
49
55
|
const { params } = vars;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// packages/dapp-kit/src/hooks/mm/useWithdraw.ts
|
|
2
|
-
import type { MoneyMarketWithdrawActionParams, SpokeChainKey,
|
|
2
|
+
import type { MoneyMarketWithdrawActionParams, SpokeChainKey, OutboundSettlement } from '@sodax/sdk';
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
8
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Mutation variables for {@link useWithdraw}. Generic over `K extends SpokeChainKey` (defaults to
|
|
@@ -21,21 +22,27 @@ export type UseWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<
|
|
|
21
22
|
* React hook for withdrawing supplied tokens from the Sodax money market protocol.
|
|
22
23
|
*
|
|
23
24
|
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
24
|
-
* `onError`, `retry`). Returns the unwrapped
|
|
25
|
+
* `onError`, `retry`). Returns the unwrapped {@link OutboundSettlement} on success: a tx pair, or
|
|
26
|
+
* from Tron the relay's `trackingId` beside the destination tx.
|
|
25
27
|
*/
|
|
26
28
|
export function useWithdraw<K extends SpokeChainKey = SpokeChainKey>({
|
|
27
29
|
mutationOptions,
|
|
28
|
-
}: MutationHookParams<
|
|
29
|
-
|
|
30
|
+
}: MutationHookParams<OutboundSettlement<K>, UseWithdrawVars<K>> = {}): SafeUseMutationResult<
|
|
31
|
+
OutboundSettlement<K>,
|
|
30
32
|
Error,
|
|
31
33
|
UseWithdrawVars<K>
|
|
32
34
|
> {
|
|
33
35
|
const { sodax } = useSodaxContext();
|
|
34
36
|
const queryClient = useQueryClient();
|
|
35
37
|
|
|
36
|
-
return useSafeMutation<
|
|
38
|
+
return useSafeMutation<OutboundSettlement<K>, Error, UseWithdrawVars<K>>({
|
|
37
39
|
mutationKey: ['mm', 'withdraw'],
|
|
38
40
|
...mutationOptions,
|
|
41
|
+
retry: retryBeforeSubmission(
|
|
42
|
+
mutationOptions?.retry ??
|
|
43
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['mm', 'withdraw'])?.retry ??
|
|
44
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
45
|
+
),
|
|
39
46
|
mutationFn: async vars => unwrapResult(await sodax.moneyMarket.withdraw({ ...vars, raw: false })),
|
|
40
47
|
onSuccess: async (data, vars, ctx) => {
|
|
41
48
|
const { params } = vars;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// packages/dapp-kit/src/hooks/recovery/useWithdrawHubAsset.ts
|
|
2
|
-
import type { SpokeChainKey,
|
|
2
|
+
import type { SpokeChainKey, SendMessageReturnType, WithdrawHubAssetAction } from '@sodax/sdk';
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { useSodaxContext } from '../shared/useSodaxContext.js';
|
|
5
5
|
import { invalidateBalances } from '../shared/invalidateBalances.js';
|
|
6
6
|
import type { MutationHookParams } from '../shared/types.js';
|
|
7
7
|
import { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';
|
|
8
|
+
import { retryBeforeSubmission } from '../shared/retryBeforeSubmission.js';
|
|
8
9
|
import { unwrapResult } from '../shared/unwrapResult.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -21,21 +22,27 @@ export type UseWithdrawHubAssetVars<K extends SpokeChainKey = SpokeChainKey> = O
|
|
|
21
22
|
* React hook for withdrawing a hub-side asset back to the user's spoke chain wallet.
|
|
22
23
|
*
|
|
23
24
|
* Throws on SDK failure so React Query's native error model engages (`isError`, `error`,
|
|
24
|
-
* `onError`, `retry`). Returns the
|
|
25
|
+
* `onError`, `retry`). Returns the spoke tx hash on success, or from an MPC-relay chain (Tron) the
|
|
26
|
+
* relay's `trackingId`, which is not a tx hash: never link it to an explorer.
|
|
25
27
|
*/
|
|
26
28
|
export function useWithdrawHubAsset<K extends SpokeChainKey = SpokeChainKey>({
|
|
27
29
|
mutationOptions,
|
|
28
|
-
}: MutationHookParams<
|
|
29
|
-
|
|
30
|
+
}: MutationHookParams<SendMessageReturnType<K, false>, UseWithdrawHubAssetVars<K>> = {}): SafeUseMutationResult<
|
|
31
|
+
SendMessageReturnType<K, false>,
|
|
30
32
|
Error,
|
|
31
33
|
UseWithdrawHubAssetVars<K>
|
|
32
34
|
> {
|
|
33
35
|
const { sodax } = useSodaxContext();
|
|
34
36
|
const queryClient = useQueryClient();
|
|
35
37
|
|
|
36
|
-
return useSafeMutation<
|
|
38
|
+
return useSafeMutation<SendMessageReturnType<K, false>, Error, UseWithdrawHubAssetVars<K>>({
|
|
37
39
|
mutationKey: ['recovery', 'withdrawHubAsset'],
|
|
38
40
|
...mutationOptions,
|
|
41
|
+
retry: retryBeforeSubmission(
|
|
42
|
+
mutationOptions?.retry ??
|
|
43
|
+
queryClient.getMutationDefaults?.(mutationOptions?.mutationKey ?? ['recovery', 'withdrawHubAsset'])?.retry ??
|
|
44
|
+
queryClient.getDefaultOptions?.().mutations?.retry,
|
|
45
|
+
),
|
|
39
46
|
mutationFn: async vars => unwrapResult(await sodax.recovery.withdrawHubAsset<K, false>({ ...vars, raw: false })),
|
|
40
47
|
onSuccess: async (data, vars, ctx) => {
|
|
41
48
|
const { params } = vars;
|
|
@@ -13,6 +13,10 @@ export * from './useNearStorageCheck.js';
|
|
|
13
13
|
export * from './useRegisterNearStorage.js';
|
|
14
14
|
export * from './useNearStorageGate.js';
|
|
15
15
|
export * from './useStellarGate.js';
|
|
16
|
+
export * from './useXrpDestinationCheck.js';
|
|
17
|
+
export * from './useXrpTrustlineReserveCheck.js';
|
|
18
|
+
export * from './useEstablishXrpTrustline.js';
|
|
19
|
+
export * from './useXrpGate.js';
|
|
16
20
|
export * from './useGetUserHubWalletAddress.js';
|
|
17
21
|
export * from './useXBalances.js';
|
|
18
22
|
export * from './useBalances.js';
|