@xyo-network/react-chain-provider 1.20.20 → 1.20.22
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/browser/components/connected/ConnectAccountsStack.d.ts +1 -0
- package/dist/browser/components/connected/ConnectAccountsStack.d.ts.map +1 -1
- package/dist/browser/contexts/gateway/Provider.d.ts +1 -5
- package/dist/browser/contexts/gateway/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/gateway/context.d.ts +4 -4
- package/dist/browser/contexts/gateway/context.d.ts.map +1 -1
- package/dist/browser/contexts/gateway/index.d.ts +0 -2
- package/dist/browser/contexts/gateway/index.d.ts.map +1 -1
- package/dist/browser/contexts/gateway/story/GatewayStatus.d.ts.map +1 -1
- package/dist/browser/contexts/in-page-gateways/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/in-page-gateways/state.d.ts +1 -1
- package/dist/browser/contexts/in-page-gateways/state.d.ts.map +1 -1
- package/dist/browser/hooks/index.d.ts +0 -1
- package/dist/browser/hooks/index.d.ts.map +1 -1
- package/dist/browser/hooks/useConnectAccount.d.ts +1 -0
- package/dist/browser/hooks/useConnectAccount.d.ts.map +1 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.mjs +281 -300
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +23 -23
- package/dist/browser/contexts/gateway/state.d.ts +0 -13
- package/dist/browser/contexts/gateway/state.d.ts.map +0 -1
- package/dist/browser/contexts/gateway/use.d.ts +0 -4
- package/dist/browser/contexts/gateway/use.d.ts.map +0 -1
- package/dist/browser/hooks/client/helpers/findCaveat.d.ts +0 -3
- package/dist/browser/hooks/client/helpers/findCaveat.d.ts.map +0 -1
- package/dist/browser/hooks/client/helpers/index.d.ts +0 -2
- package/dist/browser/hooks/client/helpers/index.d.ts.map +0 -1
- package/dist/browser/hooks/client/index.d.ts +0 -4
- package/dist/browser/hooks/client/index.d.ts.map +0 -1
- package/dist/browser/hooks/client/permissions/index.d.ts +0 -3
- package/dist/browser/hooks/client/permissions/index.d.ts.map +0 -1
- package/dist/browser/hooks/client/permissions/usePermissions.d.ts +0 -3
- package/dist/browser/hooks/client/permissions/usePermissions.d.ts.map +0 -1
- package/dist/browser/hooks/client/permissions/usePermissionsAccounts.d.ts +0 -3
- package/dist/browser/hooks/client/permissions/usePermissionsAccounts.d.ts.map +0 -1
- package/dist/browser/hooks/client/useClientFromWallet.d.ts +0 -3
- package/dist/browser/hooks/client/useClientFromWallet.d.ts.map +0 -1
- package/dist/browser/hooks/client/useGatewayFromWallet.d.ts +0 -3
- package/dist/browser/hooks/client/useGatewayFromWallet.d.ts.map +0 -1
- package/dist/browser/types/ContextGatewayType.d.ts +0 -3
- package/dist/browser/types/ContextGatewayType.d.ts.map +0 -1
- package/dist/browser/types/GatewayFromWallet.d.ts +0 -3
- package/dist/browser/types/GatewayFromWallet.d.ts.map +0 -1
- package/dist/browser/types/index.d.ts +0 -3
- package/dist/browser/types/index.d.ts.map +0 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -28,8 +28,8 @@ var ConnectedAccount = /* @__PURE__ */ __name(({ address }) => {
|
|
|
28
28
|
import { Alert, AlertTitle, Button, Stack as Stack2, Typography as Typography2 } from "@mui/material";
|
|
29
29
|
import { ButtonEx } from "@xylabs/react-button";
|
|
30
30
|
import { isDefined as isDefined5, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
31
|
-
import { ErrorRender
|
|
32
|
-
import
|
|
31
|
+
import { ErrorRender } from "@xyo-network/react-error";
|
|
32
|
+
import React2, { useEffect as useEffect3 } from "react";
|
|
33
33
|
|
|
34
34
|
// src/hooks/account/helpers/formatAccountBalanceHistory.ts
|
|
35
35
|
import { hexToBigInt } from "@xylabs/sdk-js";
|
|
@@ -162,270 +162,24 @@ var useAccountBalanceHistory = /* @__PURE__ */ __name((address, viewer, maxPage
|
|
|
162
162
|
]);
|
|
163
163
|
}, "useAccountBalanceHistory");
|
|
164
164
|
|
|
165
|
-
// src/hooks/client/permissions/usePermissions.ts
|
|
166
|
-
import { usePermissions } from "@xyo-network/react-chain-client";
|
|
167
|
-
|
|
168
|
-
// src/hooks/client/permissions/usePermissionsAccounts.ts
|
|
169
|
-
import { useAccountPermissions } from "@xyo-network/react-chain-client";
|
|
170
|
-
|
|
171
|
-
// src/hooks/client/useClientFromWallet.ts
|
|
172
|
-
import { useClient, useClientFromWallet } from "@xyo-network/react-chain-client";
|
|
173
|
-
|
|
174
|
-
// src/hooks/client/useGatewayFromWallet.ts
|
|
175
|
-
import { useGateway, useGatewayFromWallet } from "@xyo-network/react-chain-client";
|
|
176
|
-
|
|
177
|
-
// src/contexts/current-block/context.ts
|
|
178
|
-
import { createContextEx } from "@xylabs/react-shared";
|
|
179
|
-
var XL1CurrentBlockContext = createContextEx();
|
|
180
|
-
|
|
181
|
-
// src/contexts/current-block/Provider.tsx
|
|
182
|
-
import React2, { useMemo } from "react";
|
|
183
|
-
|
|
184
|
-
// src/contexts/current-block/usePollCurrentBlock.ts
|
|
185
|
-
import { isDefinedNotNull, isUndefinedOrNull } from "@xylabs/sdk-js";
|
|
186
|
-
import { startTransition, useEffect, useState } from "react";
|
|
187
|
-
var DEFAULT_POLL_INTERVAL = 1e4;
|
|
188
|
-
var usePollCurrentBlock = /* @__PURE__ */ __name((viewer, interval = DEFAULT_POLL_INTERVAL, pause = false) => {
|
|
189
|
-
const [currentBlock, setCurrentBlock] = useState(null);
|
|
190
|
-
const [error, setError] = useState();
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
let isMounted = true;
|
|
193
|
-
const fetchBlock = /* @__PURE__ */ __name(async () => {
|
|
194
|
-
if (isDefinedNotNull(viewer)) {
|
|
195
|
-
try {
|
|
196
|
-
const block = await viewer.currentBlock();
|
|
197
|
-
if (isMounted) {
|
|
198
|
-
startTransition(() => {
|
|
199
|
-
setCurrentBlock((existingBlock) => {
|
|
200
|
-
if (isUndefinedOrNull(existingBlock)) {
|
|
201
|
-
return block;
|
|
202
|
-
}
|
|
203
|
-
if (isDefinedNotNull(block) && existingBlock?.[0].block !== block[0].block) {
|
|
204
|
-
return block;
|
|
205
|
-
}
|
|
206
|
-
return existingBlock;
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
} catch (err) {
|
|
211
|
-
startTransition(() => {
|
|
212
|
-
setError(err);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}, "fetchBlock");
|
|
217
|
-
void fetchBlock();
|
|
218
|
-
const id = setInterval(() => {
|
|
219
|
-
if (!pause) {
|
|
220
|
-
void fetchBlock();
|
|
221
|
-
}
|
|
222
|
-
}, interval);
|
|
223
|
-
return () => {
|
|
224
|
-
isMounted = false;
|
|
225
|
-
clearInterval(id);
|
|
226
|
-
};
|
|
227
|
-
}, [
|
|
228
|
-
viewer,
|
|
229
|
-
interval,
|
|
230
|
-
pause
|
|
231
|
-
]);
|
|
232
|
-
return [
|
|
233
|
-
currentBlock,
|
|
234
|
-
error
|
|
235
|
-
];
|
|
236
|
-
}, "usePollCurrentBlock");
|
|
237
|
-
|
|
238
|
-
// src/contexts/current-block/Provider.tsx
|
|
239
|
-
var DEFAULT_POLLING_INTERVAL = 1e4;
|
|
240
|
-
var XL1CurrentBlockProvider = /* @__PURE__ */ __name(({ pollingConfig, viewer, children }) => {
|
|
241
|
-
const { interval } = useMemo(() => pollingConfig || {
|
|
242
|
-
interval: DEFAULT_POLLING_INTERVAL
|
|
243
|
-
}, [
|
|
244
|
-
pollingConfig
|
|
245
|
-
]);
|
|
246
|
-
const [currentBlock, currentBlockError] = usePollCurrentBlock(viewer, interval);
|
|
247
|
-
const value = useMemo(() => ({
|
|
248
|
-
block: currentBlock,
|
|
249
|
-
blockNumber: currentBlock?.[0].block,
|
|
250
|
-
chain: currentBlock?.[0].chain,
|
|
251
|
-
error: currentBlockError,
|
|
252
|
-
pollingConfig,
|
|
253
|
-
provided: true
|
|
254
|
-
}), [
|
|
255
|
-
currentBlock,
|
|
256
|
-
currentBlockError,
|
|
257
|
-
pollingConfig
|
|
258
|
-
]);
|
|
259
|
-
return /* @__PURE__ */ React2.createElement(XL1CurrentBlockContext, {
|
|
260
|
-
value
|
|
261
|
-
}, children);
|
|
262
|
-
}, "XL1CurrentBlockProvider");
|
|
263
|
-
|
|
264
|
-
// src/contexts/current-block/use.ts
|
|
265
|
-
import { useContextEx } from "@xylabs/react-shared";
|
|
266
|
-
var useXl1CurrentBlockContext = /* @__PURE__ */ __name((required = true) => useContextEx(XL1CurrentBlockContext, "XL1CurrentBlock", required), "useXl1CurrentBlockContext");
|
|
267
|
-
|
|
268
|
-
// src/contexts/gateway/context.ts
|
|
269
|
-
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
270
|
-
var GatewayContext = createContextEx2();
|
|
271
|
-
|
|
272
|
-
// src/contexts/gateway/Provider.tsx
|
|
273
|
-
import { isDefinedNotNull as isDefinedNotNull2, isNull } from "@xylabs/sdk-js";
|
|
274
|
-
import { useGatewayFromWallet as useGatewayFromWallet2 } from "@xyo-network/react-chain-client";
|
|
275
|
-
import { ErrorRender } from "@xyo-network/react-error";
|
|
276
|
-
import React4, { useMemo as useMemo3 } from "react";
|
|
277
|
-
|
|
278
|
-
// src/contexts/in-page-gateways/context.ts
|
|
279
|
-
import { createContextEx as createContextEx3 } from "@xylabs/react-shared";
|
|
280
|
-
var InPageGatewaysContext = createContextEx3();
|
|
281
|
-
|
|
282
|
-
// src/contexts/in-page-gateways/Provider.tsx
|
|
283
|
-
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
284
|
-
import React3, { startTransition as startTransition2, useCallback, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
285
|
-
var InPageGatewaysProvider = /* @__PURE__ */ __name(({ account, children }) => {
|
|
286
|
-
const [gateways, setGateways] = useState2({});
|
|
287
|
-
const [errors, setErrors] = useState2({});
|
|
288
|
-
const [previousAccount, setPreviousAccount] = useState2(account);
|
|
289
|
-
const clearAll = useCallback(() => {
|
|
290
|
-
setGateways({});
|
|
291
|
-
setErrors({});
|
|
292
|
-
}, []);
|
|
293
|
-
if (previousAccount !== account) {
|
|
294
|
-
clearAll();
|
|
295
|
-
setPreviousAccount(account);
|
|
296
|
-
}
|
|
297
|
-
useEffect2(() => {
|
|
298
|
-
let cancelled = false;
|
|
299
|
-
const buildAll = /* @__PURE__ */ __name(async () => {
|
|
300
|
-
const results = await Promise.allSettled(DefaultNetworks2.map(async (network) => {
|
|
301
|
-
const gateway = await buildGateway(network.id, account);
|
|
302
|
-
return {
|
|
303
|
-
id: network.id,
|
|
304
|
-
gateway
|
|
305
|
-
};
|
|
306
|
-
}));
|
|
307
|
-
if (cancelled) return;
|
|
308
|
-
const nextGateways = {};
|
|
309
|
-
const nextErrors = {};
|
|
310
|
-
for (const [index, result] of results.entries()) {
|
|
311
|
-
const networkId = DefaultNetworks2[index].id;
|
|
312
|
-
if (result.status === "fulfilled") {
|
|
313
|
-
nextGateways[networkId] = result.value.gateway;
|
|
314
|
-
} else {
|
|
315
|
-
nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
startTransition2(() => {
|
|
319
|
-
setGateways(nextGateways);
|
|
320
|
-
setErrors(nextErrors);
|
|
321
|
-
});
|
|
322
|
-
}, "buildAll");
|
|
323
|
-
void buildAll();
|
|
324
|
-
return () => {
|
|
325
|
-
cancelled = true;
|
|
326
|
-
};
|
|
327
|
-
}, [
|
|
328
|
-
account
|
|
329
|
-
]);
|
|
330
|
-
const value = useMemo2(() => {
|
|
331
|
-
const value2 = {
|
|
332
|
-
clearAll,
|
|
333
|
-
errors,
|
|
334
|
-
gateways,
|
|
335
|
-
provided: true
|
|
336
|
-
};
|
|
337
|
-
return value2;
|
|
338
|
-
}, [
|
|
339
|
-
clearAll,
|
|
340
|
-
errors,
|
|
341
|
-
gateways
|
|
342
|
-
]);
|
|
343
|
-
return /* @__PURE__ */ React3.createElement(InPageGatewaysContext, {
|
|
344
|
-
value
|
|
345
|
-
}, children);
|
|
346
|
-
}, "InPageGatewaysProvider");
|
|
347
|
-
|
|
348
|
-
// src/contexts/in-page-gateways/use.ts
|
|
349
|
-
import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
|
|
350
|
-
var useProvidedInPageGateways = /* @__PURE__ */ __name((required = true) => useContextEx2(InPageGatewaysContext, "InPageGateways", required), "useProvidedInPageGateways");
|
|
351
|
-
|
|
352
|
-
// src/contexts/gateway/Provider.tsx
|
|
353
|
-
var GatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
|
|
354
|
-
const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet2(gatewayName);
|
|
355
|
-
const { gateways: allGateways, errors: allGatewayErrors, clearAll } = useProvidedInPageGateways(true);
|
|
356
|
-
const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
|
|
357
|
-
const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
|
|
358
|
-
const { defaultGateway, gateways } = useMemo3(() => {
|
|
359
|
-
if (isNull(gatewayFromWallet)) {
|
|
360
|
-
return {
|
|
361
|
-
defaultGateway: gatewayFromConfig,
|
|
362
|
-
gateways: {
|
|
363
|
-
inPageGateway: gatewayFromConfig,
|
|
364
|
-
walletGateway: null
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
} else if (isDefinedNotNull2(gatewayFromWallet)) {
|
|
368
|
-
return {
|
|
369
|
-
defaultGateway: gatewayFromWallet,
|
|
370
|
-
gateways: {
|
|
371
|
-
inPageGateway: gatewayFromConfig,
|
|
372
|
-
walletGateway: gatewayFromWallet
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
defaultGateway: void 0,
|
|
378
|
-
gateways: {
|
|
379
|
-
inPageGateway: void 0,
|
|
380
|
-
walletGateway: void 0
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
}, [
|
|
384
|
-
gatewayFromConfig,
|
|
385
|
-
gatewayFromWallet
|
|
386
|
-
]);
|
|
387
|
-
const value = useMemo3(() => {
|
|
388
|
-
const value2 = {
|
|
389
|
-
defaultGateway,
|
|
390
|
-
error: gatewayFromWalletError || gatewayFromConfigError,
|
|
391
|
-
gateways,
|
|
392
|
-
provided: true,
|
|
393
|
-
resetGatewaysFromConfig: clearAll
|
|
394
|
-
};
|
|
395
|
-
return value2;
|
|
396
|
-
}, [
|
|
397
|
-
defaultGateway,
|
|
398
|
-
gatewayFromWalletError,
|
|
399
|
-
gatewayFromConfigError,
|
|
400
|
-
gateways,
|
|
401
|
-
clearAll
|
|
402
|
-
]);
|
|
403
|
-
return /* @__PURE__ */ React4.createElement(GatewayContext, {
|
|
404
|
-
value
|
|
405
|
-
}, /* @__PURE__ */ React4.createElement(ErrorRender, {
|
|
406
|
-
error: gatewayFromConfigError
|
|
407
|
-
}), children);
|
|
408
|
-
}, "GatewayProvider");
|
|
409
|
-
|
|
410
|
-
// src/contexts/gateway/use.ts
|
|
411
|
-
import { useContextEx as useContextEx3 } from "@xylabs/react-shared";
|
|
412
|
-
var useProvidedGateway = /* @__PURE__ */ __name((required = true) => useContextEx3(GatewayContext, "Gateway", required), "useProvidedGateway");
|
|
413
|
-
|
|
414
165
|
// src/hooks/gateway/useNetwork.ts
|
|
166
|
+
import { useProvidedGateway } from "@xyo-network/react-chain-client";
|
|
415
167
|
var useNetworkFromGateway = /* @__PURE__ */ __name(() => {
|
|
416
168
|
const { defaultGateway } = useProvidedGateway();
|
|
417
169
|
return defaultGateway?.connection?.network;
|
|
418
170
|
}, "useNetworkFromGateway");
|
|
419
171
|
|
|
420
172
|
// src/hooks/gateway/useRunner.ts
|
|
173
|
+
import { useProvidedGateway as useProvidedGateway2 } from "@xyo-network/react-chain-client";
|
|
421
174
|
var useRunnerFromGateway = /* @__PURE__ */ __name(() => {
|
|
422
|
-
const { defaultGateway } =
|
|
175
|
+
const { defaultGateway } = useProvidedGateway2();
|
|
423
176
|
return defaultGateway?.connection?.runner;
|
|
424
177
|
}, "useRunnerFromGateway");
|
|
425
178
|
|
|
426
179
|
// src/hooks/gateway/useViewer.ts
|
|
180
|
+
import { useProvidedGateway as useProvidedGateway3 } from "@xyo-network/react-chain-client";
|
|
427
181
|
var useViewerFromGateway = /* @__PURE__ */ __name(() => {
|
|
428
|
-
const { defaultGateway } =
|
|
182
|
+
const { defaultGateway } = useProvidedGateway3();
|
|
429
183
|
return defaultGateway?.connection?.viewer;
|
|
430
184
|
}, "useViewerFromGateway");
|
|
431
185
|
|
|
@@ -433,7 +187,7 @@ var useViewerFromGateway = /* @__PURE__ */ __name(() => {
|
|
|
433
187
|
import { getXyoClient, listenForClientInjection } from "@xyo-network/react-chain-client";
|
|
434
188
|
|
|
435
189
|
// src/hooks/helpers/transaction/Confirmation.ts
|
|
436
|
-
import { assertEx as assertEx2, delay, forget, isDefined as isDefined2, isNull
|
|
190
|
+
import { assertEx as assertEx2, delay, forget, isDefined as isDefined2, isNull } from "@xylabs/sdk-js";
|
|
437
191
|
var TransactionConfirmationStatus = class _TransactionConfirmationStatus {
|
|
438
192
|
static {
|
|
439
193
|
__name(this, "TransactionConfirmationStatus");
|
|
@@ -517,7 +271,7 @@ var TransactionConfirmationStatus = class _TransactionConfirmationStatus {
|
|
|
517
271
|
const remainingBlocks = this.exp - blockNumber;
|
|
518
272
|
const progress = Math.round((blockNumber - this.nbf) / (this.exp - this.nbf) * 100);
|
|
519
273
|
const tx = await this.viewer.transaction.byHash?.(this.txHash);
|
|
520
|
-
if (
|
|
274
|
+
if (isNull(tx)) {
|
|
521
275
|
this.onStatusUpdate?.({
|
|
522
276
|
confirmed: false,
|
|
523
277
|
blockNumber,
|
|
@@ -538,14 +292,14 @@ var TransactionConfirmationStatus = class _TransactionConfirmationStatus {
|
|
|
538
292
|
|
|
539
293
|
// src/hooks/useAddressBalance.ts
|
|
540
294
|
import { usePromise as usePromise2 } from "@xylabs/react-promise";
|
|
541
|
-
import { isUndefined as isUndefined2, isUndefinedOrNull
|
|
295
|
+
import { isUndefined as isUndefined2, isUndefinedOrNull } from "@xylabs/sdk-js";
|
|
542
296
|
import { ShiftedBigInt } from "@xyo-network/xl1-sdk";
|
|
543
|
-
import { useMemo
|
|
297
|
+
import { useMemo, useRef, useState } from "react";
|
|
544
298
|
var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh, reset) => {
|
|
545
|
-
const [balancesResult, setBalancesResult] =
|
|
546
|
-
const [loading, setLoading] =
|
|
547
|
-
const [balancesError, setBalancesError] =
|
|
548
|
-
const [previousReset, setPreviousReset] =
|
|
299
|
+
const [balancesResult, setBalancesResult] = useState();
|
|
300
|
+
const [loading, setLoading] = useState(false);
|
|
301
|
+
const [balancesError, setBalancesError] = useState();
|
|
302
|
+
const [previousReset, setPreviousReset] = useState(reset);
|
|
549
303
|
if (reset !== previousReset) {
|
|
550
304
|
setPreviousReset(reset);
|
|
551
305
|
setBalancesResult(void 0);
|
|
@@ -578,7 +332,7 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh, reset)
|
|
|
578
332
|
viewer,
|
|
579
333
|
refresh
|
|
580
334
|
]);
|
|
581
|
-
const shiftedBigInt =
|
|
335
|
+
const shiftedBigInt = useMemo(() => {
|
|
582
336
|
if (typeof balancesResult !== "bigint") return;
|
|
583
337
|
return new ShiftedBigInt(balancesResult, {
|
|
584
338
|
places: 18,
|
|
@@ -590,13 +344,13 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh, reset)
|
|
|
590
344
|
}, [
|
|
591
345
|
balancesResult
|
|
592
346
|
]);
|
|
593
|
-
const balanceIntlFriendly =
|
|
347
|
+
const balanceIntlFriendly = useMemo(() => {
|
|
594
348
|
return shiftedBigInt?.toFullString();
|
|
595
349
|
}, [
|
|
596
350
|
shiftedBigInt
|
|
597
351
|
]);
|
|
598
|
-
const shortBalanceIntlFriendly =
|
|
599
|
-
return
|
|
352
|
+
const shortBalanceIntlFriendly = useMemo(() => {
|
|
353
|
+
return isUndefinedOrNull(balancesResult) ? void 0 : balancesResult < 1000000000000n && balancesResult > 0n ? "<0.00001" : shiftedBigInt?.toShortString();
|
|
600
354
|
}, [
|
|
601
355
|
balancesResult,
|
|
602
356
|
shiftedBigInt
|
|
@@ -615,9 +369,9 @@ var useAddressBalance = /* @__PURE__ */ __name((address, viewer, refresh, reset)
|
|
|
615
369
|
import { usePromise as usePromise3 } from "@xylabs/react-promise";
|
|
616
370
|
import { forget as forget2, isDefined as isDefined3, isHash } from "@xylabs/sdk-js";
|
|
617
371
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/sdk-js";
|
|
618
|
-
import { useEffect
|
|
372
|
+
import { useEffect, useState as useState2 } from "react";
|
|
619
373
|
var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast, onStatusUpdate, runner, viewer) => {
|
|
620
|
-
const [status, setStatus] =
|
|
374
|
+
const [status, setStatus] = useState2();
|
|
621
375
|
const onStatusUpdateLocal = /* @__PURE__ */ __name((newStatus) => {
|
|
622
376
|
setStatus(newStatus);
|
|
623
377
|
onStatusUpdate?.(newStatus);
|
|
@@ -646,7 +400,7 @@ var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast
|
|
|
646
400
|
runner,
|
|
647
401
|
viewer
|
|
648
402
|
]);
|
|
649
|
-
|
|
403
|
+
useEffect(() => {
|
|
650
404
|
return () => {
|
|
651
405
|
if (transactionConfirmationStatus) {
|
|
652
406
|
forget2(transactionConfirmationStatus.stop());
|
|
@@ -664,14 +418,15 @@ var useConfirmTransactionBase = /* @__PURE__ */ __name((transaction, onBroadcast
|
|
|
664
418
|
// src/hooks/useConnectAccount.ts
|
|
665
419
|
import { asAddress } from "@xylabs/sdk-js";
|
|
666
420
|
import { assertEx as assertEx3 } from "@xylabs/sdk-js";
|
|
421
|
+
import { useAccountPermissions, useGatewayFromWallet } from "@xyo-network/react-chain-client";
|
|
667
422
|
import { MainNetwork } from "@xyo-network/xl1-sdk";
|
|
668
|
-
import { useCallback
|
|
423
|
+
import { useCallback, useState as useState3 } from "react";
|
|
669
424
|
var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, timeout) => {
|
|
670
|
-
const [connectError, setConnectError] =
|
|
425
|
+
const [connectError, setConnectError] = useState3();
|
|
671
426
|
const { gateway, error, timedout } = useGatewayFromWallet(gatewayName, timeout);
|
|
672
427
|
const [accountPermissions, accountPermissionsError] = useAccountPermissions();
|
|
673
|
-
const [address, setAddress] =
|
|
674
|
-
const connectSigner =
|
|
428
|
+
const [address, setAddress] = useState3();
|
|
429
|
+
const connectSigner = useCallback(async () => {
|
|
675
430
|
try {
|
|
676
431
|
setConnectError(void 0);
|
|
677
432
|
const assertedGateway = assertEx3(gateway, () => `Gateway ${gatewayName} is not available`);
|
|
@@ -697,10 +452,10 @@ var useConnectAccount = /* @__PURE__ */ __name((gatewayName = MainNetwork.id, ti
|
|
|
697
452
|
|
|
698
453
|
// src/hooks/useCurrentBlock.ts
|
|
699
454
|
import { usePromise as usePromise4 } from "@xylabs/react-promise";
|
|
700
|
-
import { isDefinedNotNull
|
|
455
|
+
import { isDefinedNotNull } from "@xylabs/sdk-js";
|
|
701
456
|
var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
|
|
702
457
|
return usePromise4(async () => {
|
|
703
|
-
if (
|
|
458
|
+
if (isDefinedNotNull(viewer) && refresh > 0) {
|
|
704
459
|
const block = await viewer.currentBlock();
|
|
705
460
|
return block;
|
|
706
461
|
}
|
|
@@ -712,7 +467,7 @@ var useCurrentBlock = /* @__PURE__ */ __name((refresh = 1, viewer) => {
|
|
|
712
467
|
var useCurrentBlockFromGateway = /* @__PURE__ */ __name((refresh = 1) => {
|
|
713
468
|
const viewer = useViewerFromGateway();
|
|
714
469
|
return usePromise4(async () => {
|
|
715
|
-
if (
|
|
470
|
+
if (isDefinedNotNull(viewer) && refresh > 0) {
|
|
716
471
|
const block = await viewer.currentBlock();
|
|
717
472
|
return block;
|
|
718
473
|
}
|
|
@@ -725,9 +480,9 @@ var useCurrentBlockFromGateway = /* @__PURE__ */ __name((refresh = 1) => {
|
|
|
725
480
|
// src/hooks/useNetwork.ts
|
|
726
481
|
import { isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
727
482
|
import { SimpleXyoNetwork } from "@xyo-network/xl1-sdk";
|
|
728
|
-
import { useMemo as
|
|
483
|
+
import { useMemo as useMemo2 } from "react";
|
|
729
484
|
var useNetwork = /* @__PURE__ */ __name((id) => {
|
|
730
|
-
const network =
|
|
485
|
+
const network = useMemo2(() => {
|
|
731
486
|
if (isUndefined3(id)) return;
|
|
732
487
|
return new SimpleXyoNetwork(id);
|
|
733
488
|
}, [
|
|
@@ -751,7 +506,7 @@ var useSigner = /* @__PURE__ */ __name((_provider, account) => {
|
|
|
751
506
|
import { usePromise as usePromise6 } from "@xylabs/react-promise";
|
|
752
507
|
import { delay as delay2, isDefined as isDefined4, isUndefined as isUndefined4 } from "@xylabs/sdk-js";
|
|
753
508
|
import { basicRemoteViewerLocator as basicRemoteViewerLocator2, LocalNetwork, SequenceNetwork, XyoViewerMoniker } from "@xyo-network/xl1-sdk";
|
|
754
|
-
import { useEffect as
|
|
509
|
+
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
755
510
|
var INTERVAL = 5e3;
|
|
756
511
|
var localRpcEndpoint = `${LocalNetwork.url}/rpc`;
|
|
757
512
|
var sequenceRpcEndpoint = `${SequenceNetwork.url}/rpc`;
|
|
@@ -764,8 +519,8 @@ var useCheckSequenceRpc = /* @__PURE__ */ __name(() => {
|
|
|
764
519
|
return isSequenceRpc;
|
|
765
520
|
}, "useCheckSequenceRpc");
|
|
766
521
|
var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
|
|
767
|
-
const [isLocalProducer, setIsLocalProducer] =
|
|
768
|
-
const [error, setError] =
|
|
522
|
+
const [isLocalProducer, setIsLocalProducer] = useState4(false);
|
|
523
|
+
const [error, setError] = useState4();
|
|
769
524
|
const [viewer] = usePromise6(async () => {
|
|
770
525
|
if (isUndefined4(endpoint)) return;
|
|
771
526
|
const locator = await basicRemoteViewerLocator2(endpoint, {
|
|
@@ -779,7 +534,7 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
|
|
|
779
534
|
}, [
|
|
780
535
|
endpoint
|
|
781
536
|
]);
|
|
782
|
-
|
|
537
|
+
useEffect2(() => {
|
|
783
538
|
if (isUndefined4(viewer)) return;
|
|
784
539
|
void (async () => {
|
|
785
540
|
setError(void 0);
|
|
@@ -805,7 +560,7 @@ var useCheckRpc = /* @__PURE__ */ __name((endpoint) => {
|
|
|
805
560
|
}, "useCheckRpc");
|
|
806
561
|
|
|
807
562
|
// src/hooks/viewer/ViewerWithDataLake.ts
|
|
808
|
-
import { isNull as
|
|
563
|
+
import { isNull as isNull2 } from "@xylabs/sdk-js";
|
|
809
564
|
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/sdk-js";
|
|
810
565
|
import { addDataLakePayloads, addDataLakePayloadsToPayloads, DataLakeViewerMoniker, JsonRpcXyoViewer } from "@xyo-network/xl1-sdk";
|
|
811
566
|
var ViewerWithDataLake = class extends JsonRpcXyoViewer {
|
|
@@ -835,7 +590,7 @@ var ViewerWithDataLake = class extends JsonRpcXyoViewer {
|
|
|
835
590
|
await PayloadBuilder3.addHashMeta(transaction[0]),
|
|
836
591
|
await PayloadBuilder3.addHashMeta(transaction[1])
|
|
837
592
|
] : null;
|
|
838
|
-
return
|
|
593
|
+
return isNull2(transaction) ? transaction : (await addDataLakePayloads([
|
|
839
594
|
await PayloadBuilder3.addHashMeta(transaction[0]),
|
|
840
595
|
await PayloadBuilder3.addHashMeta(transaction[1])
|
|
841
596
|
], this.dataLakeViewer))[0];
|
|
@@ -843,16 +598,16 @@ var ViewerWithDataLake = class extends JsonRpcXyoViewer {
|
|
|
843
598
|
};
|
|
844
599
|
|
|
845
600
|
// src/components/connected/ConnectAccountsStack.tsx
|
|
846
|
-
var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */
|
|
601
|
+
var DefaultConnectComponent = /* @__PURE__ */ __name((props) => /* @__PURE__ */ React2.createElement(ButtonEx, {
|
|
847
602
|
variant: "contained",
|
|
848
603
|
size: "small",
|
|
849
604
|
...props
|
|
850
605
|
}), "DefaultConnectComponent");
|
|
851
|
-
var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */
|
|
606
|
+
var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE__ */ React2.createElement(Alert, {
|
|
852
607
|
severity: "warning"
|
|
853
|
-
}, /* @__PURE__ */
|
|
608
|
+
}, /* @__PURE__ */ React2.createElement(AlertTitle, null, "XL1 Wallet Not Found"), /* @__PURE__ */ React2.createElement(Typography2, {
|
|
854
609
|
gutterBottom: true
|
|
855
|
-
}, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */
|
|
610
|
+
}, "Please ensure that your XL1 Wallet is installed to connect your account."), /* @__PURE__ */ React2.createElement(Button, {
|
|
856
611
|
sx: {
|
|
857
612
|
display: "flex",
|
|
858
613
|
justifySelf: "end"
|
|
@@ -865,7 +620,7 @@ var DefaultNoWalletInstalledComponent = /* @__PURE__ */ __name(() => /* @__PURE_
|
|
|
865
620
|
}, "Get XL1 Wallet")), "DefaultNoWalletInstalledComponent");
|
|
866
621
|
var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = ConnectedAccount, ConnectComponent = DefaultConnectComponent, NoWalletInstalledComponent = DefaultNoWalletInstalledComponent, onAccountConnected, onCancel, timeout, ...props }) => {
|
|
867
622
|
const { address, connectSigner, error, timedout } = useConnectAccount(void 0, timeout);
|
|
868
|
-
|
|
623
|
+
useEffect3(() => {
|
|
869
624
|
if (isDefined5(error) && isDefined5(onCancel)) {
|
|
870
625
|
onCancel();
|
|
871
626
|
}
|
|
@@ -873,7 +628,7 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
|
|
|
873
628
|
error,
|
|
874
629
|
onCancel
|
|
875
630
|
]);
|
|
876
|
-
|
|
631
|
+
useEffect3(() => {
|
|
877
632
|
if (isDefined5(address) && isDefined5(onAccountConnected)) {
|
|
878
633
|
onAccountConnected(address);
|
|
879
634
|
}
|
|
@@ -881,20 +636,253 @@ var ConnectAccountsStack = /* @__PURE__ */ __name(({ AccountComponent = Connecte
|
|
|
881
636
|
address,
|
|
882
637
|
onAccountConnected
|
|
883
638
|
]);
|
|
884
|
-
return /* @__PURE__ */
|
|
639
|
+
return /* @__PURE__ */ React2.createElement(Stack2, {
|
|
885
640
|
direction: "row",
|
|
886
641
|
alignItems: "start",
|
|
887
642
|
spacing: 2,
|
|
888
643
|
...props
|
|
889
|
-
}, isDefined5(address) ? /* @__PURE__ */
|
|
644
|
+
}, isDefined5(address) ? /* @__PURE__ */ React2.createElement(AccountComponent, {
|
|
890
645
|
address
|
|
891
|
-
}) : null, isUndefined5(address) && !timedout ? /* @__PURE__ */
|
|
646
|
+
}) : null, isUndefined5(address) && !timedout ? /* @__PURE__ */ React2.createElement(ConnectComponent, {
|
|
892
647
|
onClick: /* @__PURE__ */ __name(() => void connectSigner(), "onClick")
|
|
893
|
-
}, "Connect") : null, isUndefined5(address) && timedout ? /* @__PURE__ */
|
|
648
|
+
}, "Connect") : null, isUndefined5(address) && timedout ? /* @__PURE__ */ React2.createElement(NoWalletInstalledComponent, null) : null, /* @__PURE__ */ React2.createElement(ErrorRender, {
|
|
894
649
|
error,
|
|
895
650
|
scope: "ConnectSigner:error"
|
|
896
651
|
}));
|
|
897
652
|
}, "ConnectAccountsStack");
|
|
653
|
+
|
|
654
|
+
// src/contexts/current-block/context.ts
|
|
655
|
+
import { createContextEx } from "@xylabs/react-shared";
|
|
656
|
+
var XL1CurrentBlockContext = createContextEx();
|
|
657
|
+
|
|
658
|
+
// src/contexts/current-block/Provider.tsx
|
|
659
|
+
import React3, { useMemo as useMemo3 } from "react";
|
|
660
|
+
|
|
661
|
+
// src/contexts/current-block/usePollCurrentBlock.ts
|
|
662
|
+
import { isDefinedNotNull as isDefinedNotNull2, isUndefinedOrNull as isUndefinedOrNull2 } from "@xylabs/sdk-js";
|
|
663
|
+
import { startTransition, useEffect as useEffect4, useState as useState5 } from "react";
|
|
664
|
+
var DEFAULT_POLL_INTERVAL = 1e4;
|
|
665
|
+
var usePollCurrentBlock = /* @__PURE__ */ __name((viewer, interval = DEFAULT_POLL_INTERVAL, pause = false) => {
|
|
666
|
+
const [currentBlock, setCurrentBlock] = useState5(null);
|
|
667
|
+
const [error, setError] = useState5();
|
|
668
|
+
useEffect4(() => {
|
|
669
|
+
let isMounted = true;
|
|
670
|
+
const fetchBlock = /* @__PURE__ */ __name(async () => {
|
|
671
|
+
if (isDefinedNotNull2(viewer)) {
|
|
672
|
+
try {
|
|
673
|
+
const block = await viewer.currentBlock();
|
|
674
|
+
if (isMounted) {
|
|
675
|
+
startTransition(() => {
|
|
676
|
+
setCurrentBlock((existingBlock) => {
|
|
677
|
+
if (isUndefinedOrNull2(existingBlock)) {
|
|
678
|
+
return block;
|
|
679
|
+
}
|
|
680
|
+
if (isDefinedNotNull2(block) && existingBlock?.[0].block !== block[0].block) {
|
|
681
|
+
return block;
|
|
682
|
+
}
|
|
683
|
+
return existingBlock;
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
} catch (err) {
|
|
688
|
+
startTransition(() => {
|
|
689
|
+
setError(err);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}, "fetchBlock");
|
|
694
|
+
void fetchBlock();
|
|
695
|
+
const id = setInterval(() => {
|
|
696
|
+
if (!pause) {
|
|
697
|
+
void fetchBlock();
|
|
698
|
+
}
|
|
699
|
+
}, interval);
|
|
700
|
+
return () => {
|
|
701
|
+
isMounted = false;
|
|
702
|
+
clearInterval(id);
|
|
703
|
+
};
|
|
704
|
+
}, [
|
|
705
|
+
viewer,
|
|
706
|
+
interval,
|
|
707
|
+
pause
|
|
708
|
+
]);
|
|
709
|
+
return [
|
|
710
|
+
currentBlock,
|
|
711
|
+
error
|
|
712
|
+
];
|
|
713
|
+
}, "usePollCurrentBlock");
|
|
714
|
+
|
|
715
|
+
// src/contexts/current-block/Provider.tsx
|
|
716
|
+
var DEFAULT_POLLING_INTERVAL = 1e4;
|
|
717
|
+
var XL1CurrentBlockProvider = /* @__PURE__ */ __name(({ pollingConfig, viewer, children }) => {
|
|
718
|
+
const { interval } = useMemo3(() => pollingConfig || {
|
|
719
|
+
interval: DEFAULT_POLLING_INTERVAL
|
|
720
|
+
}, [
|
|
721
|
+
pollingConfig
|
|
722
|
+
]);
|
|
723
|
+
const [currentBlock, currentBlockError] = usePollCurrentBlock(viewer, interval);
|
|
724
|
+
const value = useMemo3(() => ({
|
|
725
|
+
block: currentBlock,
|
|
726
|
+
blockNumber: currentBlock?.[0].block,
|
|
727
|
+
chain: currentBlock?.[0].chain,
|
|
728
|
+
error: currentBlockError,
|
|
729
|
+
pollingConfig,
|
|
730
|
+
provided: true
|
|
731
|
+
}), [
|
|
732
|
+
currentBlock,
|
|
733
|
+
currentBlockError,
|
|
734
|
+
pollingConfig
|
|
735
|
+
]);
|
|
736
|
+
return /* @__PURE__ */ React3.createElement(XL1CurrentBlockContext, {
|
|
737
|
+
value
|
|
738
|
+
}, children);
|
|
739
|
+
}, "XL1CurrentBlockProvider");
|
|
740
|
+
|
|
741
|
+
// src/contexts/current-block/use.ts
|
|
742
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
743
|
+
var useXl1CurrentBlockContext = /* @__PURE__ */ __name((required = true) => useContextEx(XL1CurrentBlockContext, "XL1CurrentBlock", required), "useXl1CurrentBlockContext");
|
|
744
|
+
|
|
745
|
+
// src/contexts/gateway/context.ts
|
|
746
|
+
import { createContextEx as createContextEx2 } from "@xylabs/react-shared";
|
|
747
|
+
var GatewayContext = createContextEx2();
|
|
748
|
+
|
|
749
|
+
// src/contexts/gateway/Provider.tsx
|
|
750
|
+
import { isDefinedNotNull as isDefinedNotNull3, isNull as isNull3 } from "@xylabs/sdk-js";
|
|
751
|
+
import { useGatewayFromWallet as useGatewayFromWallet2 } from "@xyo-network/react-chain-client";
|
|
752
|
+
import { ErrorRender as ErrorRender2 } from "@xyo-network/react-error";
|
|
753
|
+
import React5, { useMemo as useMemo5 } from "react";
|
|
754
|
+
|
|
755
|
+
// src/contexts/in-page-gateways/context.ts
|
|
756
|
+
import { createContextEx as createContextEx3 } from "@xylabs/react-shared";
|
|
757
|
+
var InPageGatewaysContext = createContextEx3();
|
|
758
|
+
|
|
759
|
+
// src/contexts/in-page-gateways/Provider.tsx
|
|
760
|
+
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
761
|
+
import React4, { startTransition as startTransition2, useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as useState6 } from "react";
|
|
762
|
+
var InPageGatewaysProvider = /* @__PURE__ */ __name(({ account, children }) => {
|
|
763
|
+
const [gateways, setGateways] = useState6({});
|
|
764
|
+
const [errors, setErrors] = useState6({});
|
|
765
|
+
const [previousAccount, setPreviousAccount] = useState6(account);
|
|
766
|
+
const clearAll = useCallback2(() => {
|
|
767
|
+
setGateways({});
|
|
768
|
+
setErrors({});
|
|
769
|
+
}, []);
|
|
770
|
+
if (previousAccount !== account) {
|
|
771
|
+
clearAll();
|
|
772
|
+
setPreviousAccount(account);
|
|
773
|
+
}
|
|
774
|
+
useEffect5(() => {
|
|
775
|
+
let cancelled = false;
|
|
776
|
+
const buildAll = /* @__PURE__ */ __name(async () => {
|
|
777
|
+
const results = await Promise.allSettled(DefaultNetworks2.map(async (network) => {
|
|
778
|
+
const gateway = await buildGateway(network.id, account);
|
|
779
|
+
return {
|
|
780
|
+
id: network.id,
|
|
781
|
+
gateway
|
|
782
|
+
};
|
|
783
|
+
}));
|
|
784
|
+
if (cancelled) return;
|
|
785
|
+
const nextGateways = {};
|
|
786
|
+
const nextErrors = {};
|
|
787
|
+
for (const [index, result] of results.entries()) {
|
|
788
|
+
const networkId = DefaultNetworks2[index].id;
|
|
789
|
+
if (result.status === "fulfilled") {
|
|
790
|
+
nextGateways[networkId] = result.value.gateway;
|
|
791
|
+
} else {
|
|
792
|
+
nextErrors[networkId] = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
startTransition2(() => {
|
|
796
|
+
setGateways(nextGateways);
|
|
797
|
+
setErrors(nextErrors);
|
|
798
|
+
});
|
|
799
|
+
}, "buildAll");
|
|
800
|
+
void buildAll();
|
|
801
|
+
return () => {
|
|
802
|
+
cancelled = true;
|
|
803
|
+
};
|
|
804
|
+
}, [
|
|
805
|
+
account
|
|
806
|
+
]);
|
|
807
|
+
const value = useMemo4(() => {
|
|
808
|
+
const value2 = {
|
|
809
|
+
clearAll,
|
|
810
|
+
errors,
|
|
811
|
+
gateways,
|
|
812
|
+
provided: true
|
|
813
|
+
};
|
|
814
|
+
return value2;
|
|
815
|
+
}, [
|
|
816
|
+
clearAll,
|
|
817
|
+
errors,
|
|
818
|
+
gateways
|
|
819
|
+
]);
|
|
820
|
+
return /* @__PURE__ */ React4.createElement(InPageGatewaysContext, {
|
|
821
|
+
value
|
|
822
|
+
}, children);
|
|
823
|
+
}, "InPageGatewaysProvider");
|
|
824
|
+
|
|
825
|
+
// src/contexts/in-page-gateways/use.ts
|
|
826
|
+
import { useContextEx as useContextEx2 } from "@xylabs/react-shared";
|
|
827
|
+
var useProvidedInPageGateways = /* @__PURE__ */ __name((required = true) => useContextEx2(InPageGatewaysContext, "InPageGateways", required), "useProvidedInPageGateways");
|
|
828
|
+
|
|
829
|
+
// src/contexts/gateway/Provider.tsx
|
|
830
|
+
var GatewayProvider = /* @__PURE__ */ __name(({ gatewayName, children }) => {
|
|
831
|
+
const { gateway: gatewayFromWallet, error: gatewayFromWalletError } = useGatewayFromWallet2(gatewayName);
|
|
832
|
+
const { gateways: allGateways, errors: allGatewayErrors, clearAll } = useProvidedInPageGateways(true);
|
|
833
|
+
const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
|
|
834
|
+
const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
|
|
835
|
+
const { defaultGateway, gateways } = useMemo5(() => {
|
|
836
|
+
if (isNull3(gatewayFromWallet)) {
|
|
837
|
+
return {
|
|
838
|
+
defaultGateway: gatewayFromConfig,
|
|
839
|
+
gateways: {
|
|
840
|
+
inPageGateway: gatewayFromConfig,
|
|
841
|
+
walletGateway: null
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
} else if (isDefinedNotNull3(gatewayFromWallet)) {
|
|
845
|
+
return {
|
|
846
|
+
defaultGateway: gatewayFromWallet,
|
|
847
|
+
gateways: {
|
|
848
|
+
inPageGateway: gatewayFromConfig,
|
|
849
|
+
walletGateway: gatewayFromWallet
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
defaultGateway: void 0,
|
|
855
|
+
gateways: {
|
|
856
|
+
inPageGateway: void 0,
|
|
857
|
+
walletGateway: void 0
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}, [
|
|
861
|
+
gatewayFromConfig,
|
|
862
|
+
gatewayFromWallet
|
|
863
|
+
]);
|
|
864
|
+
const value = useMemo5(() => {
|
|
865
|
+
const value2 = {
|
|
866
|
+
defaultGateway,
|
|
867
|
+
error: gatewayFromWalletError || gatewayFromConfigError,
|
|
868
|
+
gateways,
|
|
869
|
+
provided: true,
|
|
870
|
+
resetGatewaysFromConfig: clearAll
|
|
871
|
+
};
|
|
872
|
+
return value2;
|
|
873
|
+
}, [
|
|
874
|
+
defaultGateway,
|
|
875
|
+
gatewayFromWalletError,
|
|
876
|
+
gatewayFromConfigError,
|
|
877
|
+
gateways,
|
|
878
|
+
clearAll
|
|
879
|
+
]);
|
|
880
|
+
return /* @__PURE__ */ React5.createElement(GatewayContext, {
|
|
881
|
+
value
|
|
882
|
+
}, /* @__PURE__ */ React5.createElement(ErrorRender2, {
|
|
883
|
+
error: gatewayFromConfigError
|
|
884
|
+
}), children);
|
|
885
|
+
}, "GatewayProvider");
|
|
898
886
|
export {
|
|
899
887
|
ConnectAccountsStack,
|
|
900
888
|
ConnectedAccount,
|
|
@@ -914,24 +902,17 @@ export {
|
|
|
914
902
|
getXyoClient,
|
|
915
903
|
listenForClientInjection,
|
|
916
904
|
useAccountBalanceHistory,
|
|
917
|
-
useAccountPermissions,
|
|
918
905
|
useAddressBalance,
|
|
919
906
|
useCheckLocalRpc,
|
|
920
907
|
useCheckRpc,
|
|
921
908
|
useCheckSequenceRpc,
|
|
922
|
-
useClient,
|
|
923
|
-
useClientFromWallet,
|
|
924
909
|
useConfirmTransactionBase,
|
|
925
910
|
useConnectAccount,
|
|
926
911
|
useCurrentBlock,
|
|
927
912
|
useCurrentBlockFromGateway,
|
|
928
|
-
useGateway,
|
|
929
|
-
useGatewayFromWallet,
|
|
930
913
|
useNetwork,
|
|
931
914
|
useNetworkFromGateway,
|
|
932
|
-
usePermissions,
|
|
933
915
|
usePollCurrentBlock,
|
|
934
|
-
useProvidedGateway,
|
|
935
916
|
useProvidedInPageGateways,
|
|
936
917
|
useRunnerFromGateway,
|
|
937
918
|
useSigner,
|