@capxul/sdk-react 4.2.0-rc.1 → 4.2.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/dist/capxul-source.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": {
|
|
3
|
-
"commit": "
|
|
4
|
-
"tree": "
|
|
3
|
+
"commit": "4547e113caca6cf936b489dda3c22c68ea2f30d8",
|
|
4
|
+
"tree": "6ccaeaf77b6d8fef28eacd312d0b884a383c502f",
|
|
5
5
|
"branch": "codex/programme-rc",
|
|
6
6
|
"repository": "https://github.com/Xelmar-tech/infrastructure",
|
|
7
7
|
"lockfileSha256": "5870f53b72706d103220c1bcf733cb4fb71196aea32a9cfbdc277d73cc959264"
|
|
8
8
|
},
|
|
9
9
|
"name": "@capxul/sdk-react",
|
|
10
|
-
"version": "4.2.0-rc.
|
|
10
|
+
"version": "4.2.0-rc.3"
|
|
11
11
|
}
|
|
@@ -215,6 +215,7 @@ function normalizeOrganization(organization) {
|
|
|
215
215
|
return null;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
const accountInFlight = (state) => state.phase === "authenticated" && (state.account.at === "deriving" || state.account.at === "claiming");
|
|
218
219
|
function createAuth(client, clearAuthenticatedQueries) {
|
|
219
220
|
const runtime = client._internal.identity;
|
|
220
221
|
const read = async (invocation) => {
|
|
@@ -225,8 +226,42 @@ function createAuth(client, clearAuthenticatedQueries) {
|
|
|
225
226
|
const result = await runtime.send({ _tag: "EnsureAccount" }, invocation);
|
|
226
227
|
return failure(result) ?? { ok: true };
|
|
227
228
|
};
|
|
229
|
+
const settledAccount = (invocation) => new Promise((resolve) => {
|
|
230
|
+
let done = false;
|
|
231
|
+
let stop = null;
|
|
232
|
+
const onAbort = () => finish({
|
|
233
|
+
ok: false,
|
|
234
|
+
reason: "CANCELLED"
|
|
235
|
+
});
|
|
236
|
+
const finish = (result) => {
|
|
237
|
+
if (done) return;
|
|
238
|
+
done = true;
|
|
239
|
+
stop?.();
|
|
240
|
+
invocation?.signal?.removeEventListener("abort", onAbort);
|
|
241
|
+
resolve(result);
|
|
242
|
+
};
|
|
243
|
+
if (invocation?.signal?.aborted) {
|
|
244
|
+
onAbort();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
invocation?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
248
|
+
const unsubscribe = runtime.subscribe((state) => {
|
|
249
|
+
if (!accountInFlight(state)) finish({ ok: true });
|
|
250
|
+
});
|
|
251
|
+
if (done) {
|
|
252
|
+
unsubscribe();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
stop = unsubscribe;
|
|
256
|
+
if (!accountInFlight(runtime.snapshot())) finish({ ok: true });
|
|
257
|
+
});
|
|
228
258
|
const reachClaimed = async (invocation) => {
|
|
229
259
|
let state = runtime.snapshot();
|
|
260
|
+
if (accountInFlight(state)) {
|
|
261
|
+
const settled = await settledAccount(invocation);
|
|
262
|
+
if (!settled.ok) return settled;
|
|
263
|
+
state = runtime.snapshot();
|
|
264
|
+
}
|
|
230
265
|
if (state.phase !== "authenticated" || state.account.at === "unknown") {
|
|
231
266
|
const result = await runtime.send({ _tag: "EnsureAccount" }, invocation);
|
|
232
267
|
const refused = failure(result);
|
|
@@ -238,6 +273,16 @@ function createAuth(client, clearAuthenticatedQueries) {
|
|
|
238
273
|
reason: "WRONG_STATE"
|
|
239
274
|
};
|
|
240
275
|
if (state.account.at === "claimed") return { ok: true };
|
|
276
|
+
if (accountInFlight(state)) {
|
|
277
|
+
const settled = await settledAccount(invocation);
|
|
278
|
+
if (!settled.ok) return settled;
|
|
279
|
+
state = runtime.snapshot();
|
|
280
|
+
if (state.phase !== "authenticated") return {
|
|
281
|
+
ok: false,
|
|
282
|
+
reason: "WRONG_STATE"
|
|
283
|
+
};
|
|
284
|
+
if (state.account.at === "claimed") return { ok: true };
|
|
285
|
+
}
|
|
241
286
|
const event = state.account.at === "failed" ? { _tag: "RetryAccount" } : state.account.at === "counterfactual" ? { _tag: "ClaimAccount" } : { _tag: "EnsureAccount" };
|
|
242
287
|
const result = await runtime.send(event, invocation);
|
|
243
288
|
const refused = failure(result);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as useCapxulAuth, c as useCapxulIdentityOrNull, d as capxulKeys, f as useCapxulClientOrNull, i as entered, l as useCapxulSend, n as CapxulOnboardingController, o as useCapxulDestination, p as useCapxul, r as CapxulProvider, s as useCapxulIdentity, t as CapxulAuthenticationController, u as useCapxulTransitions } from "./controllers-
|
|
2
|
+
import { a as useCapxulAuth, c as useCapxulIdentityOrNull, d as capxulKeys, f as useCapxulClientOrNull, i as entered, l as useCapxulSend, n as CapxulOnboardingController, o as useCapxulDestination, p as useCapxul, r as CapxulProvider, s as useCapxulIdentity, t as CapxulAuthenticationController, u as useCapxulTransitions } from "./controllers-ByS8ZrVm.mjs";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { CAPXUL_OPERATIONS, CapxulError, EVM_ADDRESS_RE, Errors, HANDLE_RE, PAYMENT_DIRECTIONS, PAYMENT_STATUSES, fingerprintPaymentIntent, formatMoney, isCapxulError, isClaimed, isClaimed as isClaimed$1, isMoneyParseError, isRestoring, isRestoring as isRestoring$1, parseMoney, paymentPhase, resolveIdentityDestination, toEvmAddress, toPartyId } from "@capxul/sdk";
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as CapxulOnboardingController, r as CapxulProvider, t as CapxulAuthenticationController } from "../controllers-
|
|
1
|
+
import { n as CapxulOnboardingController, r as CapxulProvider, t as CapxulAuthenticationController } from "../controllers-ByS8ZrVm.mjs";
|
|
2
2
|
import "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createCapxulTestClient } from "@capxul/sdk/testing";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk-react",
|
|
3
|
-
"version": "4.2.0-rc.
|
|
3
|
+
"version": "4.2.0-rc.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Xelmar-tech/infrastructure.git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@capxul/sdk": "4.2.0-rc.
|
|
29
|
+
"@capxul/sdk": "4.2.0-rc.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@tanstack/react-query": "^5.66.9",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"vite-plus": "0.3.0",
|
|
45
45
|
"vitest": "4.1.11",
|
|
46
46
|
"@capxul/errors": "0.3.0",
|
|
47
|
-
"@capxul/
|
|
48
|
-
"@capxul/
|
|
47
|
+
"@capxul/typescript-config": "0.0.0",
|
|
48
|
+
"@capxul/types": "0.3.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@tanstack/react-query": "^5.66.9",
|