@ravnexchange/react 0.1.2 → 0.1.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/dist/polling.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPollingTerminal = void 0;
|
|
4
4
|
exports.msUntilExpiry = msUntilExpiry;
|
|
5
|
-
// isPollingTerminal lives in @ravnexchange/sdk (core)
|
|
5
|
+
// isPollingTerminal lives in @ravnexchange/sdk (core): executeAndTrack needs it too and core
|
|
6
6
|
// can't depend on this React package. Re-exported here so existing @ravnexchange/react imports
|
|
7
7
|
// don't break.
|
|
8
8
|
var sdk_1 = require("@ravnexchange/sdk");
|
package/dist/useRavnExecute.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface UseRavnExecuteResult {
|
|
|
6
6
|
error: unknown;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Thin state wrapper around client.execute(). Deliberately does NOT sign or send anything
|
|
9
|
+
* Thin state wrapper around client.execute(). Deliberately does NOT sign or send anything:
|
|
10
10
|
* this package has no opinion on wallets. Branch on the returned executionType and hand it to
|
|
11
11
|
* whatever signer the integrator already has (wagmi, ethers, a hardware wallet, ...).
|
|
12
12
|
*/
|
package/dist/useRavnExecute.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useRavnExecute = useRavnExecute;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
/**
|
|
6
|
-
* Thin state wrapper around client.execute(). Deliberately does NOT sign or send anything
|
|
6
|
+
* Thin state wrapper around client.execute(). Deliberately does NOT sign or send anything:
|
|
7
7
|
* this package has no opinion on wallets. Branch on the returned executionType and hand it to
|
|
8
8
|
* whatever signer the integrator already has (wagmi, ethers, a hardware wallet, ...).
|
|
9
9
|
*/
|
package/dist/useRavnQuote.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export interface UseRavnQuoteResult {
|
|
|
3
3
|
quote: QuoteDTO | null;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
error: unknown;
|
|
6
|
-
/** True once quote.expiresAt has passed
|
|
6
|
+
/** True once quote.expiresAt has passed: stop letting the user sign, call refetch(). */
|
|
7
7
|
isExpired: boolean;
|
|
8
8
|
refetch: () => void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Fetches a quote and flips `isExpired` on its own timer when expiresAt passes
|
|
11
|
+
* Fetches a quote and flips `isExpired` on its own timer when expiresAt passes, no polling,
|
|
12
12
|
* just one setTimeout per quote. Pass `params: null` to skip fetching (e.g. amount not entered
|
|
13
13
|
* yet). Does not auto-refetch on expiry: that's a UX choice (silently re-pricing behind a user's
|
|
14
14
|
* back is worse than telling them to ask again), left to the caller.
|
package/dist/useRavnQuote.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.useRavnQuote = useRavnQuote;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const polling_1 = require("./polling");
|
|
6
6
|
/**
|
|
7
|
-
* Fetches a quote and flips `isExpired` on its own timer when expiresAt passes
|
|
7
|
+
* Fetches a quote and flips `isExpired` on its own timer when expiresAt passes, no polling,
|
|
8
8
|
* just one setTimeout per quote. Pass `params: null` to skip fetching (e.g. amount not entered
|
|
9
9
|
* yet). Does not auto-refetch on expiry: that's a UX choice (silently re-pricing behind a user's
|
|
10
10
|
* back is worse than telling them to ask again), left to the caller.
|
|
@@ -46,7 +46,7 @@ function useRavnQuote(client, params) {
|
|
|
46
46
|
return () => {
|
|
47
47
|
cancelled = true;
|
|
48
48
|
};
|
|
49
|
-
// paramsKey (not params) drives refetch
|
|
49
|
+
// paramsKey (not params) drives refetch: a fresh object with the same fields shouldn't refire.
|
|
50
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
51
|
}, [client, paramsKey, generation]);
|
|
52
52
|
const expiresAt = quote?.expiresAt;
|
package/dist/useRavnStatus.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface UseRavnStatusResult {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function isPermanentError(err: unknown): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Polls GET /v1/status until it reaches a terminal state (see isPollingTerminal
|
|
9
|
+
* Polls GET /v1/status until it reaches a terminal state (see isPollingTerminal: "unknown"
|
|
10
10
|
* counts as terminal, it means the venue has no live tracker and never will for this swap).
|
|
11
11
|
* Pass `params: null` to not poll at all (e.g. before execution has produced a ref).
|
|
12
12
|
*/
|
package/dist/useRavnStatus.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.useRavnStatus = useRavnStatus;
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const sdk_1 = require("@ravnexchange/sdk");
|
|
7
7
|
const polling_1 = require("./polling");
|
|
8
|
-
// Codes the API itself defines as request-shaped, not transient
|
|
8
|
+
// Codes the API itself defines as request-shaped, not transient: retrying with the exact same
|
|
9
9
|
// arguments can never turn one of these into success. Anything else (RATE_LIMITED, INTERNAL, a
|
|
10
10
|
// network failure) is worth retrying through.
|
|
11
11
|
const PERMANENT_ERROR_CODES = new Set(["UNAUTHORIZED", "INVALID_REQUEST", "QUOTE_INVALID", "NOT_FOUND"]);
|
|
@@ -13,7 +13,7 @@ function isPermanentError(err) {
|
|
|
13
13
|
return err instanceof sdk_1.RavnApiError && PERMANENT_ERROR_CODES.has(err.code);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Polls GET /v1/status until it reaches a terminal state (see isPollingTerminal
|
|
16
|
+
* Polls GET /v1/status until it reaches a terminal state (see isPollingTerminal: "unknown"
|
|
17
17
|
* counts as terminal, it means the venue has no live tracker and never will for this swap).
|
|
18
18
|
* Pass `params: null` to not poll at all (e.g. before execution has produced a ref).
|
|
19
19
|
*/
|
|
@@ -46,7 +46,7 @@ function useRavnStatus(client, params, intervalMs = 4000) {
|
|
|
46
46
|
return;
|
|
47
47
|
setError(err);
|
|
48
48
|
// Keep polling through a transient network/5xx error rather than giving up on the
|
|
49
|
-
// swap's status forever
|
|
49
|
+
// swap's status forever, but a permanent error (bad API key, invalid ref) can never
|
|
50
50
|
// resolve by asking again with the same arguments, so stop rather than spam the API
|
|
51
51
|
// for as long as the component happens to stay mounted.
|
|
52
52
|
if (!isPermanentError(err)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ravnexchange/react",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "React hooks for @ravnexchange/sdk
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "React hooks for @ravnexchange/sdk: quote/execute/status state management. Bring your own wallet.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"files": ["dist"],
|