@cofhe/react 0.0.0-alpha-20260601105140 → 0.0.0-alpha-20260603065951
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/{chunk-GWNGM2KD.cjs → chunk-4FH4QHHA.cjs} +566 -483
- package/dist/chunk-4FH4QHHA.cjs.map +1 -0
- package/dist/{chunk-AFU2LVEH.js → chunk-VMORHIR7.js} +475 -392
- package/dist/chunk-VMORHIR7.js.map +1 -0
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -76
- package/dist/index.d.ts +175 -76
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +6 -0
- package/dist/ui-base.cjs +2 -2
- package/dist/ui-base.d.cts +2 -2
- package/dist/ui-base.d.ts +2 -2
- package/dist/ui-base.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-AFU2LVEH.js.map +0 -1
- package/dist/chunk-GWNGM2KD.cjs.map +0 -1
- package/dist/{StatusBarContent-BOe91ztF.d.cts → StatusBarContent-C-8PjeD6.d.cts} +8 -8
- package/dist/{StatusBarContent-BOe91ztF.d.ts → StatusBarContent-C-8PjeD6.d.ts} +8 -8
|
@@ -1047,6 +1047,7 @@ function CofheProvider(props) {
|
|
|
1047
1047
|
{
|
|
1048
1048
|
value: {
|
|
1049
1049
|
client: cofheClient,
|
|
1050
|
+
transactionRenderers: props.transactionRenderers,
|
|
1050
1051
|
state: {
|
|
1051
1052
|
position,
|
|
1052
1053
|
setPosition,
|
|
@@ -2618,32 +2619,46 @@ var TransactionStatus = /* @__PURE__ */ ((TransactionStatus3) => {
|
|
|
2618
2619
|
TransactionStatus3["Confirmed"] = "confirmed";
|
|
2619
2620
|
return TransactionStatus3;
|
|
2620
2621
|
})(TransactionStatus || {});
|
|
2621
|
-
var TransactionActionType =
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
return TransactionActionType2;
|
|
2628
|
-
})(TransactionActionType || {});
|
|
2629
|
-
var actionToStringMap = {
|
|
2630
|
-
["shieldSend" /* ShieldSend */]: "Shielded Transfer",
|
|
2631
|
-
["shield" /* Shield */]: "Shield",
|
|
2632
|
-
["unshield" /* Unshield */]: "Unshield",
|
|
2633
|
-
["claim" /* Claim */]: "Claim",
|
|
2634
|
-
["approve" /* Approve */]: "Approve"
|
|
2622
|
+
var TransactionActionType = {
|
|
2623
|
+
ShieldSend: "shieldSend",
|
|
2624
|
+
Shield: "shield",
|
|
2625
|
+
Unshield: "unshield",
|
|
2626
|
+
Claim: "claim",
|
|
2627
|
+
Approve: "approve"
|
|
2635
2628
|
};
|
|
2636
|
-
var
|
|
2629
|
+
var actionToStringMap = {
|
|
2630
|
+
[TransactionActionType.ShieldSend]: "Shielded Transfer",
|
|
2631
|
+
[TransactionActionType.Shield]: "Shield",
|
|
2632
|
+
[TransactionActionType.Unshield]: "Unshield",
|
|
2633
|
+
[TransactionActionType.Claim]: "Claim",
|
|
2634
|
+
[TransactionActionType.Approve]: "Approve"
|
|
2635
|
+
};
|
|
2636
|
+
var actionToString = (a, fallbackTitle) => _nullishCoalesce(_nullishCoalesce(actionToStringMap[a], () => ( fallbackTitle)), () => ( a));
|
|
2637
|
+
var isCustomTransactionActionType = (actionType) => actionType.startsWith("custom-");
|
|
2637
2638
|
var statusToStringMap = {
|
|
2638
2639
|
["pending" /* Pending */]: "Pending",
|
|
2639
2640
|
["failed" /* Failed */]: "Failed",
|
|
2640
2641
|
["confirmed" /* Confirmed */]: "Confirmed"
|
|
2641
2642
|
};
|
|
2642
2643
|
var statusToString = (a) => statusToStringMap[a];
|
|
2644
|
+
function normalizeAddressList(addresses) {
|
|
2645
|
+
if (!addresses || addresses.length === 0) return void 0;
|
|
2646
|
+
return Array.from(new Set(addresses.map((address) => address.toLowerCase())));
|
|
2647
|
+
}
|
|
2648
|
+
function transactionMatchesToken(tx, tokenAddress) {
|
|
2649
|
+
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
2650
|
+
if ("token" in tx && tx.token.address.toLowerCase() === normalizedTokenAddress) return true;
|
|
2651
|
+
return _nullishCoalesce(_optionalChain([tx, 'access', _88 => _88.tokenTags, 'optionalAccess', _89 => _89.some, 'call', _90 => _90((tag) => tag.toLowerCase() === normalizedTokenAddress)]), () => ( false));
|
|
2652
|
+
}
|
|
2643
2653
|
var bigintStorage = _middleware.createJSONStorage.call(void 0, () => localStorage, bigintJSONStorageOptions);
|
|
2644
2654
|
function constructNewTx(transaction) {
|
|
2655
|
+
const tokenTags = normalizeAddressList([
|
|
2656
|
+
..._nullishCoalesce(transaction.tokenTags, () => ( [])),
|
|
2657
|
+
..."token" in transaction ? [transaction.token.address] : []
|
|
2658
|
+
]);
|
|
2645
2659
|
return {
|
|
2646
2660
|
...transaction,
|
|
2661
|
+
...tokenTags ? { tokenTags } : {},
|
|
2647
2662
|
status: "pending" /* Pending */,
|
|
2648
2663
|
timestamp: Date.now()
|
|
2649
2664
|
};
|
|
@@ -2679,7 +2694,7 @@ var useTransactionStore = _zustand.create.call(void 0, )(
|
|
|
2679
2694
|
[hash]: {
|
|
2680
2695
|
...chainTxs[hash],
|
|
2681
2696
|
status,
|
|
2682
|
-
receipt: _nullishCoalesce(_optionalChain([minedData, 'optionalAccess',
|
|
2697
|
+
receipt: _nullishCoalesce(_optionalChain([minedData, 'optionalAccess', _91 => _91.receipt]), () => ( chainTxs[hash].receipt))
|
|
2683
2698
|
}
|
|
2684
2699
|
}
|
|
2685
2700
|
}
|
|
@@ -2687,7 +2702,7 @@ var useTransactionStore = _zustand.create.call(void 0, )(
|
|
|
2687
2702
|
});
|
|
2688
2703
|
},
|
|
2689
2704
|
getTransaction: (chainId, hash) => {
|
|
2690
|
-
return _optionalChain([get, 'call',
|
|
2705
|
+
return _optionalChain([get, 'call', _92 => _92(), 'access', _93 => _93.transactions, 'access', _94 => _94[chainId], 'optionalAccess', _95 => _95[hash]]);
|
|
2691
2706
|
},
|
|
2692
2707
|
getAllTransactions: (chainId, account) => {
|
|
2693
2708
|
const chainTxs = get().transactions[chainId];
|
|
@@ -2696,7 +2711,8 @@ var useTransactionStore = _zustand.create.call(void 0, )(
|
|
|
2696
2711
|
getAllTransactionsByToken: (chainId, tokenAddress, account) => {
|
|
2697
2712
|
const chainTxs = get().transactions[chainId];
|
|
2698
2713
|
return chainTxs ? Object.values(chainTxs).filter((tx) => {
|
|
2699
|
-
|
|
2714
|
+
if (!transactionMatchesToken(tx, tokenAddress)) return false;
|
|
2715
|
+
return !account || tx.account.toLowerCase() === account.toLowerCase();
|
|
2700
2716
|
}).sort((a, b) => b.timestamp - a.timestamp) : [];
|
|
2701
2717
|
},
|
|
2702
2718
|
clearTransactions: (chainId) => {
|
|
@@ -2730,7 +2746,7 @@ function useCofheWriteContract(options) {
|
|
|
2730
2746
|
const publicClient = useCofhePublicClient();
|
|
2731
2747
|
const mutation = useInternalMutation({
|
|
2732
2748
|
...options,
|
|
2733
|
-
mutationKey: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2749
|
+
mutationKey: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _96 => _96.mutationKey]), () => ( ["cofhe", "walletWriteContract"])),
|
|
2734
2750
|
mutationFn: async (variables) => {
|
|
2735
2751
|
(0, import_ts_essentials5.assert)(walletClient, "WalletClient is required to write to a contract");
|
|
2736
2752
|
(0, import_ts_essentials5.assert)(publicClient, "PublicClient is required to simulate contract before writing");
|
|
@@ -2754,6 +2770,138 @@ function useCofheWriteContract(options) {
|
|
|
2754
2770
|
};
|
|
2755
2771
|
}
|
|
2756
2772
|
|
|
2773
|
+
// src/hooks/useTransactionGlobalLifecycle.ts
|
|
2774
|
+
|
|
2775
|
+
var TOAST_DELAY_MS = 1e4;
|
|
2776
|
+
function useTransactionGlobalToastsLifecycle() {
|
|
2777
|
+
const { addToast } = usePortalToasts();
|
|
2778
|
+
return {
|
|
2779
|
+
// 1.tx is submitted
|
|
2780
|
+
onTransactionSubmitted: (transaction) => {
|
|
2781
|
+
cofheLogger.log("____ Transaction submitted:", transaction);
|
|
2782
|
+
addToast(
|
|
2783
|
+
{
|
|
2784
|
+
variant: "info",
|
|
2785
|
+
title: `${transaction.actionType} Transaction Submitted`,
|
|
2786
|
+
description: `${transaction.actionType} transaction has been submitted.`,
|
|
2787
|
+
transaction: {
|
|
2788
|
+
hash: transaction.hash,
|
|
2789
|
+
chainId: transaction.chainId
|
|
2790
|
+
}
|
|
2791
|
+
},
|
|
2792
|
+
TOAST_DELAY_MS
|
|
2793
|
+
);
|
|
2794
|
+
},
|
|
2795
|
+
onTransactionSubmitError: (error, transactionType) => {
|
|
2796
|
+
let humanReadableError;
|
|
2797
|
+
if (error instanceof _viem.ContractFunctionExecutionError) {
|
|
2798
|
+
if (error.cause instanceof _viem.ContractFunctionRevertedError) {
|
|
2799
|
+
const reasonOfRevert = error.cause.raw;
|
|
2800
|
+
if (typeof reasonOfRevert === "string") {
|
|
2801
|
+
humanReadableError = cofheHumanizeRevertReason(reasonOfRevert);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
cofheLogger.error("____ Transaction submission failed for type:", transactionType, "with error:", error);
|
|
2806
|
+
addToast(
|
|
2807
|
+
{
|
|
2808
|
+
variant: "error",
|
|
2809
|
+
title: `${transactionType} Transaction Submission Failed`,
|
|
2810
|
+
description: _nullishCoalesce(humanReadableError, () => ( (error instanceof Error ? error.message : "An unknown error occurred during transaction submission.")))
|
|
2811
|
+
},
|
|
2812
|
+
TOAST_DELAY_MS
|
|
2813
|
+
);
|
|
2814
|
+
},
|
|
2815
|
+
// 2.a. tx is mined (could be success or fail)
|
|
2816
|
+
onTransactionMined: (transaction, receipt) => {
|
|
2817
|
+
cofheLogger.log("____ Transaction mined:", transaction, "with receipt:", receipt);
|
|
2818
|
+
if (receipt.status === "success") {
|
|
2819
|
+
addToast(
|
|
2820
|
+
{
|
|
2821
|
+
variant: "success",
|
|
2822
|
+
title: `${transaction.actionType} Transaction Mined`,
|
|
2823
|
+
description: `${transaction.actionType} transaction has been mined.`,
|
|
2824
|
+
transaction: {
|
|
2825
|
+
hash: transaction.hash,
|
|
2826
|
+
chainId: transaction.chainId
|
|
2827
|
+
}
|
|
2828
|
+
},
|
|
2829
|
+
TOAST_DELAY_MS
|
|
2830
|
+
);
|
|
2831
|
+
} else {
|
|
2832
|
+
addToast(
|
|
2833
|
+
{
|
|
2834
|
+
variant: "error",
|
|
2835
|
+
title: `${transaction.actionType} Transaction Failed`,
|
|
2836
|
+
description: `${transaction.actionType} transaction has failed.`,
|
|
2837
|
+
transaction: {
|
|
2838
|
+
hash: transaction.hash,
|
|
2839
|
+
chainId: transaction.chainId
|
|
2840
|
+
}
|
|
2841
|
+
},
|
|
2842
|
+
TOAST_DELAY_MS
|
|
2843
|
+
);
|
|
2844
|
+
}
|
|
2845
|
+
},
|
|
2846
|
+
// 2.b. tx receipt fetch failed
|
|
2847
|
+
onWatchReceiptFailure: (error, transaction) => {
|
|
2848
|
+
cofheLogger.error("____ Transaction receipt fetch failed for tx:", transaction, "with error:", error);
|
|
2849
|
+
addToast(
|
|
2850
|
+
{
|
|
2851
|
+
variant: "error",
|
|
2852
|
+
title: `${transaction.actionType} Transaction Fetch Failed`,
|
|
2853
|
+
description: `Fetching ${transaction.actionType} transaction has failed.`,
|
|
2854
|
+
transaction: {
|
|
2855
|
+
hash: transaction.hash,
|
|
2856
|
+
chainId: transaction.chainId
|
|
2857
|
+
}
|
|
2858
|
+
},
|
|
2859
|
+
TOAST_DELAY_MS
|
|
2860
|
+
);
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
function useTransactionGlobalLifecycle() {
|
|
2865
|
+
const {
|
|
2866
|
+
onTransactionSubmitted: handleToastsOnTransactionSubmitted,
|
|
2867
|
+
onTransactionMined: handleToastsOnTransactionMined,
|
|
2868
|
+
onWatchReceiptFailure: handleToastsOnWatchReceiptFailure,
|
|
2869
|
+
onTransactionSubmitError: handleToastsOnTransactionSubmitError
|
|
2870
|
+
} = useTransactionGlobalToastsLifecycle();
|
|
2871
|
+
return {
|
|
2872
|
+
onTransactionSubmitted: handleToastsOnTransactionSubmitted,
|
|
2873
|
+
onTransactionMined: handleToastsOnTransactionMined,
|
|
2874
|
+
onWatchReceiptFailure: handleToastsOnWatchReceiptFailure,
|
|
2875
|
+
onTransactionSubmitError: handleToastsOnTransactionSubmitError
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
// src/hooks/useCofheTokenApprove.ts
|
|
2880
|
+
function useCofheTokenApprove(writeMutationOptions) {
|
|
2881
|
+
const { onSuccess: passedOnSuccess, onError: passedOnError, ...restOfOptions } = writeMutationOptions || {};
|
|
2882
|
+
const { onTransactionSubmitError } = useTransactionGlobalLifecycle();
|
|
2883
|
+
return useCofheWriteContract({
|
|
2884
|
+
...restOfOptions,
|
|
2885
|
+
onError: (error, variables, onMutateResult, context) => {
|
|
2886
|
+
if (passedOnError) passedOnError(error, variables, onMutateResult, context);
|
|
2887
|
+
onTransactionSubmitError(error, TransactionActionType.Approve);
|
|
2888
|
+
},
|
|
2889
|
+
onSuccess: (hash, variables, onMutateResult, context) => {
|
|
2890
|
+
if (passedOnSuccess) passedOnSuccess(hash, variables, onMutateResult, context);
|
|
2891
|
+
if (!hasExtras(variables)) return;
|
|
2892
|
+
const { token, tokenAmount, account } = variables.extras;
|
|
2893
|
+
useTransactionStore.getState().addTransaction({
|
|
2894
|
+
hash,
|
|
2895
|
+
token,
|
|
2896
|
+
tokenAmount,
|
|
2897
|
+
chainId: token.chainId,
|
|
2898
|
+
actionType: TransactionActionType.Approve,
|
|
2899
|
+
account
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
});
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2757
2905
|
// src/hooks/useCofheTokenLists.ts
|
|
2758
2906
|
|
|
2759
2907
|
|
|
@@ -3209,7 +3357,7 @@ function getShieldApproveContractConfig() {
|
|
|
3209
3357
|
}
|
|
3210
3358
|
function getShieldEthContractConfig(token) {
|
|
3211
3359
|
const contracts = getShieldContractsForToken(token);
|
|
3212
|
-
if (!_optionalChain([contracts, 'optionalAccess',
|
|
3360
|
+
if (!_optionalChain([contracts, 'optionalAccess', _97 => _97.native])) {
|
|
3213
3361
|
throw new Error(
|
|
3214
3362
|
`shield ETH config is not defined for confidentialityType: ${token.extensions.fhenix.confidentialityType}`
|
|
3215
3363
|
);
|
|
@@ -3218,7 +3366,7 @@ function getShieldEthContractConfig(token) {
|
|
|
3218
3366
|
}
|
|
3219
3367
|
function getShieldWrappedPairContractConfig(token) {
|
|
3220
3368
|
const contracts = getShieldContractsForToken(token);
|
|
3221
|
-
if (!_optionalChain([contracts, 'optionalAccess',
|
|
3369
|
+
if (!_optionalChain([contracts, 'optionalAccess', _98 => _98.wrappedPair])) {
|
|
3222
3370
|
throw new Error(
|
|
3223
3371
|
`shield wrapped pair config is not defined for confidentialityType: ${token.extensions.fhenix.confidentialityType}`
|
|
3224
3372
|
);
|
|
@@ -3241,7 +3389,7 @@ function getClaimSingleContractConfig(confidentialityType) {
|
|
|
3241
3389
|
}
|
|
3242
3390
|
function getClaimAllContractConfig(confidentialityType) {
|
|
3243
3391
|
const contracts = getContractsForType(confidentialityType).claims;
|
|
3244
|
-
if (!_optionalChain([contracts, 'optionalAccess',
|
|
3392
|
+
if (!_optionalChain([contracts, 'optionalAccess', _99 => _99.all])) {
|
|
3245
3393
|
throw new Error(`claim-all config is not defined for confidentialityType: ${confidentialityType}`);
|
|
3246
3394
|
}
|
|
3247
3395
|
return contracts.all;
|
|
@@ -3292,7 +3440,7 @@ function useResolvedCofheToken({ chainId: _chainId, address }, queryOptions) {
|
|
|
3292
3440
|
const cofheChainId = useCofheChainId();
|
|
3293
3441
|
const chainId = _nullishCoalesce(_chainId, () => ( cofheChainId));
|
|
3294
3442
|
return useInternalQuery({
|
|
3295
|
-
queryKey: ["resolvedCofheToken", chainId, _optionalChain([address, 'optionalAccess',
|
|
3443
|
+
queryKey: ["resolvedCofheToken", chainId, _optionalChain([address, 'optionalAccess', _100 => _100.toLowerCase, 'call', _101 => _101()])],
|
|
3296
3444
|
queryFn: async () => {
|
|
3297
3445
|
if (!publicClient) {
|
|
3298
3446
|
throw new Error("PublicClient is required to resolve a token");
|
|
@@ -3379,8 +3527,8 @@ function useResolvedCofheToken({ chainId: _chainId, address }, queryOptions) {
|
|
|
3379
3527
|
],
|
|
3380
3528
|
allowFailure: true
|
|
3381
3529
|
});
|
|
3382
|
-
const pairDecimals = _optionalChain([pairMetadata, 'access',
|
|
3383
|
-
const pairSymbol = _optionalChain([pairMetadata, 'access',
|
|
3530
|
+
const pairDecimals = _optionalChain([pairMetadata, 'access', _102 => _102[0], 'optionalAccess', _103 => _103.status]) === "success" ? pairMetadata[0].result : void 0;
|
|
3531
|
+
const pairSymbol = _optionalChain([pairMetadata, 'access', _104 => _104[1], 'optionalAccess', _105 => _105.status]) === "success" ? pairMetadata[1].result : void 0;
|
|
3384
3532
|
if (pairDecimals != null && pairSymbol != null) {
|
|
3385
3533
|
erc20Pair = {
|
|
3386
3534
|
address: pairAddress,
|
|
@@ -3406,7 +3554,7 @@ function useResolvedCofheToken({ chainId: _chainId, address }, queryOptions) {
|
|
|
3406
3554
|
erc20Pair
|
|
3407
3555
|
});
|
|
3408
3556
|
},
|
|
3409
|
-
enabled: (_nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
3557
|
+
enabled: (_nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _106 => _106.enabled]), () => ( true))) && !!publicClient && !!chainId && !!address,
|
|
3410
3558
|
staleTime: Infinity,
|
|
3411
3559
|
...queryOptions
|
|
3412
3560
|
});
|
|
@@ -3414,7 +3562,7 @@ function useResolvedCofheToken({ chainId: _chainId, address }, queryOptions) {
|
|
|
3414
3562
|
|
|
3415
3563
|
// src/hooks/useCofheTokenLists.ts
|
|
3416
3564
|
function isSupportedToken(token) {
|
|
3417
|
-
const confidentialityType = _optionalChain([token, 'access',
|
|
3565
|
+
const confidentialityType = _optionalChain([token, 'access', _107 => _107.extensions, 'optionalAccess', _108 => _108.fhenix, 'optionalAccess', _109 => _109.confidentialityType]);
|
|
3418
3566
|
return isSupportedTokenConfidentialityType(confidentialityType);
|
|
3419
3567
|
}
|
|
3420
3568
|
var TokenListFetchError = class extends Error {
|
|
@@ -3431,8 +3579,8 @@ function getCustomTokensForChain(customTokensByChainId, chainId) {
|
|
|
3431
3579
|
}
|
|
3432
3580
|
function useCofheTokenLists({ chainId }, queryOptions) {
|
|
3433
3581
|
const widgetConfig = useCofheContext().client.config.react;
|
|
3434
|
-
const tokensListsUrls = chainId ? _optionalChain([widgetConfig, 'access',
|
|
3435
|
-
const queriesOptions = _optionalChain([tokensListsUrls, 'optionalAccess',
|
|
3582
|
+
const tokensListsUrls = chainId ? _optionalChain([widgetConfig, 'access', _110 => _110.tokenLists, 'optionalAccess', _111 => _111[chainId]]) : [];
|
|
3583
|
+
const queriesOptions = _optionalChain([tokensListsUrls, 'optionalAccess', _112 => _112.map, 'call', _113 => _113((url) => ({
|
|
3436
3584
|
cacheTime: Infinity,
|
|
3437
3585
|
staleTime: Infinity,
|
|
3438
3586
|
refetchOnMount: false,
|
|
@@ -3512,7 +3660,7 @@ function useCofheToken({ chainId: _chainId, address }, metdataQueryOptions) {
|
|
|
3512
3660
|
},
|
|
3513
3661
|
{
|
|
3514
3662
|
...metdataQueryOptions,
|
|
3515
|
-
enabled: (_nullishCoalesce(_optionalChain([metdataQueryOptions, 'optionalAccess',
|
|
3663
|
+
enabled: (_nullishCoalesce(_optionalChain([metdataQueryOptions, 'optionalAccess', _114 => _114.enabled]), () => ( true))) && !!address && !!chainId && !tokenFromList
|
|
3516
3664
|
}
|
|
3517
3665
|
);
|
|
3518
3666
|
return _nullishCoalesce(tokenFromList, () => ( resolvedToken.data));
|
|
@@ -3620,10 +3768,10 @@ async function fetchUnshieldClaimsSummary({
|
|
|
3620
3768
|
}
|
|
3621
3769
|
function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions) {
|
|
3622
3770
|
const publicClient = useCofhePublicClient();
|
|
3623
|
-
const confidentialityType = _optionalChain([token, 'optionalAccess',
|
|
3771
|
+
const confidentialityType = _optionalChain([token, 'optionalAccess', _115 => _115.extensions, 'access', _116 => _116.fhenix, 'access', _117 => _117.confidentialityType]);
|
|
3624
3772
|
const queryKey = constructUnshieldClaimsQueryKey({
|
|
3625
|
-
chainId: _optionalChain([token, 'optionalAccess',
|
|
3626
|
-
tokenAddress: _optionalChain([token, 'optionalAccess',
|
|
3773
|
+
chainId: _optionalChain([token, 'optionalAccess', _118 => _118.chainId]),
|
|
3774
|
+
tokenAddress: _optionalChain([token, 'optionalAccess', _119 => _119.address]),
|
|
3627
3775
|
confidentialityType,
|
|
3628
3776
|
accountAddress: account
|
|
3629
3777
|
});
|
|
@@ -3644,7 +3792,7 @@ function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions
|
|
|
3644
3792
|
accountAddress: account,
|
|
3645
3793
|
confidentialityType,
|
|
3646
3794
|
signal,
|
|
3647
|
-
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess',
|
|
3795
|
+
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess', _120 => _120.blockHashToBeAwareOf])
|
|
3648
3796
|
});
|
|
3649
3797
|
}),
|
|
3650
3798
|
refetchOnMount: false,
|
|
@@ -3661,114 +3809,6 @@ function useCofheTokenClaimable({ accountAddress: account, token }, queryOptions
|
|
|
3661
3809
|
var import_ts_essentials7 = __toESM(require_dist(), 1);
|
|
3662
3810
|
|
|
3663
3811
|
|
|
3664
|
-
|
|
3665
|
-
// src/hooks/useTransactionGlobalLifecycle.ts
|
|
3666
|
-
|
|
3667
|
-
var TOAST_DELAY_MS = 1e4;
|
|
3668
|
-
function useTransactionGlobalToastsLifecycle() {
|
|
3669
|
-
const { addToast } = usePortalToasts();
|
|
3670
|
-
return {
|
|
3671
|
-
// 1.tx is submitted
|
|
3672
|
-
onTransactionSubmitted: (transaction) => {
|
|
3673
|
-
cofheLogger.log("____ Transaction submitted:", transaction);
|
|
3674
|
-
addToast(
|
|
3675
|
-
{
|
|
3676
|
-
variant: "info",
|
|
3677
|
-
title: `${transaction.actionType} Transaction Submitted`,
|
|
3678
|
-
description: `${transaction.actionType} transaction has been submitted.`,
|
|
3679
|
-
transaction: {
|
|
3680
|
-
hash: transaction.hash,
|
|
3681
|
-
chainId: transaction.chainId
|
|
3682
|
-
}
|
|
3683
|
-
},
|
|
3684
|
-
TOAST_DELAY_MS
|
|
3685
|
-
);
|
|
3686
|
-
},
|
|
3687
|
-
onTransactionSubmitError: (error, transactionType) => {
|
|
3688
|
-
let humanReadableError;
|
|
3689
|
-
if (error instanceof _viem.ContractFunctionExecutionError) {
|
|
3690
|
-
if (error.cause instanceof _viem.ContractFunctionRevertedError) {
|
|
3691
|
-
const reasonOfRevert = error.cause.raw;
|
|
3692
|
-
if (typeof reasonOfRevert === "string") {
|
|
3693
|
-
humanReadableError = cofheHumanizeRevertReason(reasonOfRevert);
|
|
3694
|
-
}
|
|
3695
|
-
}
|
|
3696
|
-
}
|
|
3697
|
-
cofheLogger.error("____ Transaction submission failed for type:", transactionType, "with error:", error);
|
|
3698
|
-
addToast(
|
|
3699
|
-
{
|
|
3700
|
-
variant: "error",
|
|
3701
|
-
title: `${transactionType} Transaction Submission Failed`,
|
|
3702
|
-
description: _nullishCoalesce(humanReadableError, () => ( (error instanceof Error ? error.message : "An unknown error occurred during transaction submission.")))
|
|
3703
|
-
},
|
|
3704
|
-
TOAST_DELAY_MS
|
|
3705
|
-
);
|
|
3706
|
-
},
|
|
3707
|
-
// 2.a. tx is mined (could be success or fail)
|
|
3708
|
-
onTransactionMined: (transaction, receipt) => {
|
|
3709
|
-
cofheLogger.log("____ Transaction mined:", transaction, "with receipt:", receipt);
|
|
3710
|
-
if (receipt.status === "success") {
|
|
3711
|
-
addToast(
|
|
3712
|
-
{
|
|
3713
|
-
variant: "success",
|
|
3714
|
-
title: `${transaction.actionType} Transaction Mined`,
|
|
3715
|
-
description: `${transaction.actionType} transaction has been mined.`,
|
|
3716
|
-
transaction: {
|
|
3717
|
-
hash: transaction.hash,
|
|
3718
|
-
chainId: transaction.chainId
|
|
3719
|
-
}
|
|
3720
|
-
},
|
|
3721
|
-
TOAST_DELAY_MS
|
|
3722
|
-
);
|
|
3723
|
-
} else {
|
|
3724
|
-
addToast(
|
|
3725
|
-
{
|
|
3726
|
-
variant: "error",
|
|
3727
|
-
title: `${transaction.actionType} Transaction Failed`,
|
|
3728
|
-
description: `${transaction.actionType} transaction has failed.`,
|
|
3729
|
-
transaction: {
|
|
3730
|
-
hash: transaction.hash,
|
|
3731
|
-
chainId: transaction.chainId
|
|
3732
|
-
}
|
|
3733
|
-
},
|
|
3734
|
-
TOAST_DELAY_MS
|
|
3735
|
-
);
|
|
3736
|
-
}
|
|
3737
|
-
},
|
|
3738
|
-
// 2.b. tx receipt fetch failed
|
|
3739
|
-
onWatchReceiptFailure: (error, transaction) => {
|
|
3740
|
-
cofheLogger.error("____ Transaction receipt fetch failed for tx:", transaction, "with error:", error);
|
|
3741
|
-
addToast(
|
|
3742
|
-
{
|
|
3743
|
-
variant: "error",
|
|
3744
|
-
title: `${transaction.actionType} Transaction Fetch Failed`,
|
|
3745
|
-
description: `Fetching ${transaction.actionType} transaction has failed.`,
|
|
3746
|
-
transaction: {
|
|
3747
|
-
hash: transaction.hash,
|
|
3748
|
-
chainId: transaction.chainId
|
|
3749
|
-
}
|
|
3750
|
-
},
|
|
3751
|
-
TOAST_DELAY_MS
|
|
3752
|
-
);
|
|
3753
|
-
}
|
|
3754
|
-
};
|
|
3755
|
-
}
|
|
3756
|
-
function useTransactionGlobalLifecycle() {
|
|
3757
|
-
const {
|
|
3758
|
-
onTransactionSubmitted: handleToastsOnTransactionSubmitted,
|
|
3759
|
-
onTransactionMined: handleToastsOnTransactionMined,
|
|
3760
|
-
onWatchReceiptFailure: handleToastsOnWatchReceiptFailure,
|
|
3761
|
-
onTransactionSubmitError: handleToastsOnTransactionSubmitError
|
|
3762
|
-
} = useTransactionGlobalToastsLifecycle();
|
|
3763
|
-
return {
|
|
3764
|
-
onTransactionSubmitted: handleToastsOnTransactionSubmitted,
|
|
3765
|
-
onTransactionMined: handleToastsOnTransactionMined,
|
|
3766
|
-
onWatchReceiptFailure: handleToastsOnWatchReceiptFailure,
|
|
3767
|
-
onTransactionSubmitError: handleToastsOnTransactionSubmitError
|
|
3768
|
-
};
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
|
-
// src/hooks/useCofheTokenClaimUnshielded.ts
|
|
3772
3812
|
function getCofheTokenClaimUnshieldedCallArgs(params) {
|
|
3773
3813
|
const { token, account, claim, claims } = params;
|
|
3774
3814
|
const tokenAddress = token.address;
|
|
@@ -3789,7 +3829,7 @@ function getCofheTokenClaimUnshieldedCallArgs(params) {
|
|
|
3789
3829
|
chain: void 0
|
|
3790
3830
|
};
|
|
3791
3831
|
}
|
|
3792
|
-
if (!_optionalChain([claims, 'optionalAccess',
|
|
3832
|
+
if (!_optionalChain([claims, 'optionalAccess', _121 => _121.length])) {
|
|
3793
3833
|
return void 0;
|
|
3794
3834
|
}
|
|
3795
3835
|
const contractConfig = getClaimAllContractConfig(confidentialityType);
|
|
@@ -3868,7 +3908,7 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
3868
3908
|
token: input.token,
|
|
3869
3909
|
tokenAmount: decryptResult.decryptedValue,
|
|
3870
3910
|
chainId,
|
|
3871
|
-
actionType:
|
|
3911
|
+
actionType: TransactionActionType.Claim,
|
|
3872
3912
|
account
|
|
3873
3913
|
});
|
|
3874
3914
|
} catch (error) {
|
|
@@ -3928,7 +3968,7 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
3928
3968
|
},
|
|
3929
3969
|
onError: (error, variables, onMutateResult, context) => {
|
|
3930
3970
|
if (onError) onError(error, variables, onMutateResult, context);
|
|
3931
|
-
onTransactionSubmitError(error,
|
|
3971
|
+
onTransactionSubmitError(error, TransactionActionType.Claim);
|
|
3932
3972
|
},
|
|
3933
3973
|
onSuccess: async (hash, input, onMutateResult, context) => {
|
|
3934
3974
|
(0, import_ts_essentials7.assert)(chainId, "Chain ID is required for claim");
|
|
@@ -3942,7 +3982,7 @@ function useCofheTokenClaimUnshielded(options) {
|
|
|
3942
3982
|
token: input.token,
|
|
3943
3983
|
tokenAmount: input.amount,
|
|
3944
3984
|
chainId,
|
|
3945
|
-
actionType:
|
|
3985
|
+
actionType: TransactionActionType.Claim,
|
|
3946
3986
|
account
|
|
3947
3987
|
});
|
|
3948
3988
|
},
|
|
@@ -3967,7 +4007,7 @@ function useCofheDecrypt({
|
|
|
3967
4007
|
const enabled = !!input && BigInt(input.ctHash) > 0n && !!client && (_nullishCoalesce(userEnabled, () => ( true)));
|
|
3968
4008
|
return useInternalQuery({
|
|
3969
4009
|
enabled,
|
|
3970
|
-
queryKey: ["decryptCiphertext", _optionalChain([input, 'optionalAccess',
|
|
4010
|
+
queryKey: ["decryptCiphertext", _optionalChain([input, 'optionalAccess', _122 => _122.ctHash, 'access', _123 => _123.toString, 'call', _124 => _124()]), _optionalChain([input, 'optionalAccess', _125 => _125.utype])],
|
|
3971
4011
|
queryFn: async () => {
|
|
3972
4012
|
(0, import_ts_essentials8.assert)(input, "input is guaranteed to be defined by enabled condition");
|
|
3973
4013
|
const builder = client.decryptForView(input.ctHash, input.utype);
|
|
@@ -4026,7 +4066,7 @@ function useCofheReadContractAndDecrypt(params, {
|
|
|
4026
4066
|
|
|
4027
4067
|
|
|
4028
4068
|
|
|
4029
|
-
var import_ts_essentials9 = __toESM(require_dist()
|
|
4069
|
+
var import_ts_essentials9 = __toESM(require_dist());
|
|
4030
4070
|
|
|
4031
4071
|
// src/utils/format.ts
|
|
4032
4072
|
var _bignumberjs = require('bignumber.js'); var _bignumberjs2 = _interopRequireDefault(_bignumberjs);
|
|
@@ -4039,58 +4079,173 @@ function formatTokenAmount(amount, decimals, displayDecimals) {
|
|
|
4039
4079
|
// the only precise way, without parseFloat
|
|
4040
4080
|
};
|
|
4041
4081
|
}
|
|
4042
|
-
function unitToWei(amount, decimals) {
|
|
4043
|
-
return BigInt(new (0, _bignumberjs2.default)(amount).multipliedBy(10 ** decimals).toFixed(0));
|
|
4044
|
-
}
|
|
4045
|
-
function formatUsdAmount(amount, displayDecimals = 2) {
|
|
4046
|
-
const amountBN = _bignumberjs2.default.isBigNumber(amount) ? amount : new (0, _bignumberjs2.default)(amount);
|
|
4047
|
-
return `$${amountBN.toFormat(displayDecimals)}`;
|
|
4082
|
+
function unitToWei(amount, decimals) {
|
|
4083
|
+
return BigInt(new (0, _bignumberjs2.default)(amount).multipliedBy(10 ** decimals).toFixed(0));
|
|
4084
|
+
}
|
|
4085
|
+
function formatUsdAmount(amount, displayDecimals = 2) {
|
|
4086
|
+
const amountBN = _bignumberjs2.default.isBigNumber(amount) ? amount : new (0, _bignumberjs2.default)(amount);
|
|
4087
|
+
return `$${amountBN.toFormat(displayDecimals)}`;
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
// src/hooks/useCofheTokenDecryptedBalance.ts
|
|
4091
|
+
function useCofheTokenDecryptedBalance({ token, accountAddress, displayDecimals = 5 }, options) {
|
|
4092
|
+
const { enabled: userEnabled = true, ...restOptions } = _nullishCoalesce(options, () => ( {}));
|
|
4093
|
+
const contractConfig = token && getTokenContractConfig(token.extensions.fhenix.confidentialityType);
|
|
4094
|
+
const {
|
|
4095
|
+
decrypted: { data: decryptedData, isFetching: isDecryptionFetching },
|
|
4096
|
+
encrypted: { isFetching: isEncryptedFetching, refetch: refetchCiphertext },
|
|
4097
|
+
disabledDueToMissingValidPermit
|
|
4098
|
+
} = useCofheReadContractAndDecrypt(
|
|
4099
|
+
{
|
|
4100
|
+
address: _optionalChain([token, 'optionalAccess', _126 => _126.address]),
|
|
4101
|
+
abi: _optionalChain([contractConfig, 'optionalAccess', _127 => _127.abi]),
|
|
4102
|
+
functionName: _optionalChain([contractConfig, 'optionalAccess', _128 => _128.functionName]),
|
|
4103
|
+
args: accountAddress ? [accountAddress] : void 0,
|
|
4104
|
+
requiresPermit: true
|
|
4105
|
+
},
|
|
4106
|
+
{
|
|
4107
|
+
readQueryOptions: {
|
|
4108
|
+
refetchOnMount: false,
|
|
4109
|
+
enabled: userEnabled && !!token
|
|
4110
|
+
},
|
|
4111
|
+
decryptingQueryOptions: {
|
|
4112
|
+
refetchOnMount: false,
|
|
4113
|
+
select: (amountWei) => {
|
|
4114
|
+
(0, import_ts_essentials9.assert)(token, "Token must be defined to format confidential balance");
|
|
4115
|
+
if (typeof amountWei !== "bigint") {
|
|
4116
|
+
throw new Error("Expected bigint from confidential decryption");
|
|
4117
|
+
}
|
|
4118
|
+
return formatTokenAmount(amountWei, token.decimals, displayDecimals);
|
|
4119
|
+
}
|
|
4120
|
+
},
|
|
4121
|
+
...restOptions
|
|
4122
|
+
}
|
|
4123
|
+
);
|
|
4124
|
+
return {
|
|
4125
|
+
disabledDueToMissingValidPermit,
|
|
4126
|
+
data: decryptedData,
|
|
4127
|
+
isFetching: isDecryptionFetching || isEncryptedFetching,
|
|
4128
|
+
refetch: refetchCiphertext
|
|
4129
|
+
};
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
// src/hooks/useCofheTokenPublicBalance.ts
|
|
4133
|
+
var import_ts_essentials10 = __toESM(require_dist(), 1);
|
|
4134
|
+
|
|
4135
|
+
|
|
4136
|
+
function constructPublicTokenBalanceQueryKey({
|
|
4137
|
+
chainId,
|
|
4138
|
+
accountAddress,
|
|
4139
|
+
tokenAddress
|
|
4140
|
+
}) {
|
|
4141
|
+
return ["tokenBalance", chainId, _optionalChain([accountAddress, 'optionalAccess', _129 => _129.toLowerCase, 'call', _130 => _130()]), _optionalChain([tokenAddress, 'optionalAccess', _131 => _131.toLowerCase, 'call', _132 => _132()])];
|
|
4142
|
+
}
|
|
4143
|
+
function constructPublicTokenBalanceQueryKeyForInvalidation({
|
|
4144
|
+
chainId,
|
|
4145
|
+
accountAddress,
|
|
4146
|
+
tokenAddress
|
|
4147
|
+
}) {
|
|
4148
|
+
return constructPublicTokenBalanceQueryKey({
|
|
4149
|
+
chainId,
|
|
4150
|
+
accountAddress,
|
|
4151
|
+
tokenAddress
|
|
4152
|
+
});
|
|
4153
|
+
}
|
|
4154
|
+
function getPublicTokenBalanceSource(token) {
|
|
4155
|
+
const confidentialityType = _optionalChain([token, 'optionalAccess', _133 => _133.extensions, 'access', _134 => _134.fhenix, 'access', _135 => _135.confidentialityType]);
|
|
4156
|
+
const underlyingErc20 = _optionalChain([token, 'optionalAccess', _136 => _136.extensions, 'access', _137 => _137.fhenix, 'access', _138 => _138.erc20Pair]);
|
|
4157
|
+
const publicBalanceSourceType = getPublicBalanceSourceType(confidentialityType);
|
|
4158
|
+
const tokenToFetchBalanceFrom = publicBalanceSourceType === "erc20Pair" ? underlyingErc20 : publicBalanceSourceType === "token" ? token : void 0;
|
|
4159
|
+
if (!tokenToFetchBalanceFrom) return void 0;
|
|
4160
|
+
return {
|
|
4161
|
+
address: tokenToFetchBalanceFrom.address,
|
|
4162
|
+
decimals: tokenToFetchBalanceFrom.decimals
|
|
4163
|
+
};
|
|
4164
|
+
}
|
|
4165
|
+
function createPublicTokenBalanceQueryOptions(params) {
|
|
4166
|
+
const { publicClient, accountAddress, tokenAddress, queryOptions } = params;
|
|
4167
|
+
const { enabled: userEnabled, ...restQueryOptions } = _nullishCoalesce(queryOptions, () => ( {}));
|
|
4168
|
+
const baseEnabled = !!publicClient && !!accountAddress && !!tokenAddress;
|
|
4169
|
+
const enabled = baseEnabled && (_nullishCoalesce(userEnabled, () => ( true)));
|
|
4170
|
+
const queryKey = constructPublicTokenBalanceQueryKey({
|
|
4171
|
+
chainId: _optionalChain([publicClient, 'optionalAccess', _139 => _139.chain, 'optionalAccess', _140 => _140.id]),
|
|
4172
|
+
accountAddress,
|
|
4173
|
+
tokenAddress
|
|
4174
|
+
});
|
|
4175
|
+
return {
|
|
4176
|
+
queryKey,
|
|
4177
|
+
queryFn: withInvalidationContext(
|
|
4178
|
+
async ({ invalidationContext, signal }) => {
|
|
4179
|
+
(0, import_ts_essentials10.assert)(tokenAddress, "Token address is required to fetch token balance");
|
|
4180
|
+
(0, import_ts_essentials10.assert)(publicClient, "PublicClient is required to fetch token balance");
|
|
4181
|
+
(0, import_ts_essentials10.assert)(accountAddress, "Account address is required to fetch token balance");
|
|
4182
|
+
const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
4183
|
+
const balance = await maybeWaitUntilRpcAware(
|
|
4184
|
+
publicClient,
|
|
4185
|
+
{
|
|
4186
|
+
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess', _141 => _141.blockHashToBeAwareOf]),
|
|
4187
|
+
readDescription: isNativeToken ? "read native balance" : "read ERC20 balance",
|
|
4188
|
+
read: () => isNativeToken ? publicClient.getBalance({
|
|
4189
|
+
address: accountAddress
|
|
4190
|
+
}) : publicClient.readContract({
|
|
4191
|
+
address: tokenAddress,
|
|
4192
|
+
abi: ERC20_BALANCE_OF_ABI,
|
|
4193
|
+
functionName: "balanceOf",
|
|
4194
|
+
args: [accountAddress]
|
|
4195
|
+
})
|
|
4196
|
+
},
|
|
4197
|
+
{ signal }
|
|
4198
|
+
);
|
|
4199
|
+
return balance;
|
|
4200
|
+
}
|
|
4201
|
+
),
|
|
4202
|
+
enabled,
|
|
4203
|
+
refetchOnMount: false,
|
|
4204
|
+
...restQueryOptions
|
|
4205
|
+
};
|
|
4206
|
+
}
|
|
4207
|
+
function useTokenBalance({ tokenAddress, accountAddress }, queryOptions) {
|
|
4208
|
+
const publicClient = useCofhePublicClient();
|
|
4209
|
+
return useInternalQuery(
|
|
4210
|
+
createPublicTokenBalanceQueryOptions({
|
|
4211
|
+
publicClient,
|
|
4212
|
+
accountAddress,
|
|
4213
|
+
tokenAddress,
|
|
4214
|
+
queryOptions
|
|
4215
|
+
})
|
|
4216
|
+
);
|
|
4048
4217
|
}
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4218
|
+
function useCofheTokenPublicBalance({ token, accountAddress, displayDecimals = 5 }, options) {
|
|
4219
|
+
const connectedAccount = useCofheAccount();
|
|
4220
|
+
const account = accountAddress || connectedAccount;
|
|
4052
4221
|
const { enabled: userEnabled = true, ...restOptions } = _nullishCoalesce(options, () => ( {}));
|
|
4053
|
-
const
|
|
4054
|
-
const {
|
|
4055
|
-
decrypted: { data: decryptedData, isFetching: isDecryptionFetching },
|
|
4056
|
-
encrypted: { isFetching: isEncryptedFetching, refetch: refetchCiphertext },
|
|
4057
|
-
disabledDueToMissingValidPermit
|
|
4058
|
-
} = useCofheReadContractAndDecrypt(
|
|
4222
|
+
const tokenToFetchBalanceFrom = getPublicTokenBalanceSource(token);
|
|
4223
|
+
const { data, isFetching, refetch } = useTokenBalance(
|
|
4059
4224
|
{
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
functionName: _optionalChain([contractConfig, 'optionalAccess', _127 => _127.functionName]),
|
|
4063
|
-
args: accountAddress ? [accountAddress] : void 0,
|
|
4064
|
-
requiresPermit: true
|
|
4225
|
+
tokenAddress: _optionalChain([tokenToFetchBalanceFrom, 'optionalAccess', _142 => _142.address]),
|
|
4226
|
+
accountAddress: account
|
|
4065
4227
|
},
|
|
4066
4228
|
{
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
(0, import_ts_essentials9.assert)(token, "Token must be defined to format confidential balance");
|
|
4075
|
-
if (typeof amountWei !== "bigint") {
|
|
4076
|
-
throw new Error("Expected bigint from confidential decryption");
|
|
4077
|
-
}
|
|
4078
|
-
return formatTokenAmount(amountWei, token.decimals, displayDecimals);
|
|
4079
|
-
}
|
|
4229
|
+
enabled: userEnabled,
|
|
4230
|
+
select: (value) => {
|
|
4231
|
+
(0, import_ts_essentials10.assert)(
|
|
4232
|
+
typeof _optionalChain([tokenToFetchBalanceFrom, 'optionalAccess', _143 => _143.decimals]) === "number",
|
|
4233
|
+
"Token decimals must be defined to format public token balance"
|
|
4234
|
+
);
|
|
4235
|
+
return formatTokenAmount(value, tokenToFetchBalanceFrom.decimals, displayDecimals);
|
|
4080
4236
|
},
|
|
4081
4237
|
...restOptions
|
|
4082
4238
|
}
|
|
4083
4239
|
);
|
|
4084
4240
|
return {
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
refetch: refetchCiphertext
|
|
4241
|
+
data,
|
|
4242
|
+
isFetching,
|
|
4243
|
+
refetch
|
|
4089
4244
|
};
|
|
4090
4245
|
}
|
|
4091
4246
|
|
|
4092
4247
|
// src/hooks/useCofheTokensClaimable.ts
|
|
4093
|
-
var
|
|
4248
|
+
var import_ts_essentials12 = __toESM(require_dist(), 1);
|
|
4094
4249
|
|
|
4095
4250
|
|
|
4096
4251
|
|
|
@@ -4100,9 +4255,9 @@ var import_ts_essentials11 = __toESM(require_dist(), 1);
|
|
|
4100
4255
|
function useNormalizedList(items, options) {
|
|
4101
4256
|
return _react.useMemo.call(void 0, () => {
|
|
4102
4257
|
if (!items || items.length === 0) return [];
|
|
4103
|
-
const filter2 = _optionalChain([options, 'optionalAccess',
|
|
4104
|
-
const dedupeKey = _optionalChain([options, 'optionalAccess',
|
|
4105
|
-
const sort = _optionalChain([options, 'optionalAccess',
|
|
4258
|
+
const filter2 = _optionalChain([options, 'optionalAccess', _144 => _144.filter]);
|
|
4259
|
+
const dedupeKey = _optionalChain([options, 'optionalAccess', _145 => _145.dedupeKey]);
|
|
4260
|
+
const sort = _optionalChain([options, 'optionalAccess', _146 => _146.sort]);
|
|
4106
4261
|
const filtered = filter2 ? items.filter(filter2) : items;
|
|
4107
4262
|
const deduped = (() => {
|
|
4108
4263
|
if (!dedupeKey) return filtered;
|
|
@@ -4118,11 +4273,11 @@ function useNormalizedList(items, options) {
|
|
|
4118
4273
|
})();
|
|
4119
4274
|
if (sort) deduped.sort(sort);
|
|
4120
4275
|
return deduped;
|
|
4121
|
-
}, [items, _optionalChain([options, 'optionalAccess',
|
|
4276
|
+
}, [items, _optionalChain([options, 'optionalAccess', _147 => _147.dedupeKey]), _optionalChain([options, 'optionalAccess', _148 => _148.filter]), _optionalChain([options, 'optionalAccess', _149 => _149.sort])]);
|
|
4122
4277
|
}
|
|
4123
4278
|
|
|
4124
4279
|
// src/hooks/useStoredTransactions.ts
|
|
4125
|
-
var
|
|
4280
|
+
var import_ts_essentials11 = __toESM(require_dist());
|
|
4126
4281
|
|
|
4127
4282
|
function useStoredTransactions({
|
|
4128
4283
|
chainId,
|
|
@@ -4152,10 +4307,10 @@ function useStoredTransactions({
|
|
|
4152
4307
|
[transactionsAsArray, filter2, account]
|
|
4153
4308
|
);
|
|
4154
4309
|
const reduced = _react.useMemo.call(void 0, () => {
|
|
4155
|
-
return _optionalChain([reducer, 'optionalCall',
|
|
4310
|
+
return _optionalChain([reducer, 'optionalCall', _150 => _150(filtered)]);
|
|
4156
4311
|
}, [filtered, reducer]);
|
|
4157
4312
|
const uniqueHashes = new Set(filtered.map((tx) => tx.hash));
|
|
4158
|
-
(0,
|
|
4313
|
+
(0, import_ts_essentials11.assert)(
|
|
4159
4314
|
uniqueHashes.size === filtered.length,
|
|
4160
4315
|
"There should be no duplicate transactions with the same hash in the result"
|
|
4161
4316
|
);
|
|
@@ -4178,7 +4333,7 @@ function useStoredTransactions({
|
|
|
4178
4333
|
|
|
4179
4334
|
// src/hooks/useCofheTokensClaimable.ts
|
|
4180
4335
|
function isClaimableToken(token) {
|
|
4181
|
-
return isTokenConfidentialityTypeClaimable(_optionalChain([token, 'access',
|
|
4336
|
+
return isTokenConfidentialityTypeClaimable(_optionalChain([token, 'access', _151 => _151.extensions, 'optionalAccess', _152 => _152.fhenix, 'optionalAccess', _153 => _153.confidentialityType]));
|
|
4182
4337
|
}
|
|
4183
4338
|
function claimableDedupeKey(token) {
|
|
4184
4339
|
const confidentialityType = token.extensions.fhenix.confidentialityType;
|
|
@@ -4188,10 +4343,11 @@ function claimableSort(a, b) {
|
|
|
4188
4343
|
if (a.chainId !== b.chainId) return a.chainId - b.chainId;
|
|
4189
4344
|
return a.address.toLowerCase().localeCompare(b.address.toLowerCase());
|
|
4190
4345
|
}
|
|
4191
|
-
var pendingClaimsFilter = (tx) => tx.actionType ===
|
|
4192
|
-
var pendingUnshieldsFilter = (tx) => tx.actionType ===
|
|
4346
|
+
var pendingClaimsFilter = (tx) => tx.actionType === TransactionActionType.Claim && tx.status === "pending" /* Pending */;
|
|
4347
|
+
var pendingUnshieldsFilter = (tx) => tx.actionType === TransactionActionType.Unshield && tx.status === "pending" /* Pending */;
|
|
4193
4348
|
var asBooleanByTokenAddressLowercase = (txs) => {
|
|
4194
4349
|
return txs.reduce((acc, tx) => {
|
|
4350
|
+
if (!tx.token) return acc;
|
|
4195
4351
|
const key = tx.token.address.toLowerCase();
|
|
4196
4352
|
acc[key] = true;
|
|
4197
4353
|
return acc;
|
|
@@ -4230,19 +4386,19 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
|
|
|
4230
4386
|
return {
|
|
4231
4387
|
queryKey,
|
|
4232
4388
|
queryFn: withInvalidationContext(async ({ signal, invalidationContext }) => {
|
|
4233
|
-
(0,
|
|
4389
|
+
(0, import_ts_essentials12.assert)(
|
|
4234
4390
|
isTokenConfidentialityTypeClaimable(confidentialityType),
|
|
4235
4391
|
"confidentialityType narrowed by token guard"
|
|
4236
4392
|
);
|
|
4237
|
-
(0,
|
|
4238
|
-
(0,
|
|
4393
|
+
(0, import_ts_essentials12.assert)(account, "account is required to fetch unshield claims");
|
|
4394
|
+
(0, import_ts_essentials12.assert)(publicClient, "publicClient is required to fetch unshield claims");
|
|
4239
4395
|
return fetchUnshieldClaimsSummary({
|
|
4240
4396
|
publicClient,
|
|
4241
4397
|
token,
|
|
4242
4398
|
accountAddress: account,
|
|
4243
4399
|
confidentialityType,
|
|
4244
4400
|
signal,
|
|
4245
|
-
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess',
|
|
4401
|
+
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess', _154 => _154.blockHashToBeAwareOf])
|
|
4246
4402
|
});
|
|
4247
4403
|
}),
|
|
4248
4404
|
refetchOnMount: false,
|
|
@@ -4298,7 +4454,7 @@ function useCofheTokensClaimable({ tokens, accountAddress: account }, queryOptio
|
|
|
4298
4454
|
// src/hooks/useCofheTokenShield.ts
|
|
4299
4455
|
|
|
4300
4456
|
|
|
4301
|
-
var
|
|
4457
|
+
var import_ts_essentials13 = __toESM(require_dist(), 1);
|
|
4302
4458
|
function getCofheTokenShieldCallArgs(params) {
|
|
4303
4459
|
const { token, amount, account } = params;
|
|
4304
4460
|
const tokenAddress = token.address;
|
|
@@ -4307,8 +4463,8 @@ function getCofheTokenShieldCallArgs(params) {
|
|
|
4307
4463
|
throw new Error("confidentialityType is required in token extensions");
|
|
4308
4464
|
}
|
|
4309
4465
|
assertTokenOperationSupported(confidentialityType, "shield");
|
|
4310
|
-
const erc20PairAddress = _optionalChain([token, 'access',
|
|
4311
|
-
const isEth = _optionalChain([erc20PairAddress, 'optionalAccess',
|
|
4466
|
+
const erc20PairAddress = _optionalChain([token, 'access', _155 => _155.extensions, 'access', _156 => _156.fhenix, 'access', _157 => _157.erc20Pair, 'optionalAccess', _158 => _158.address]);
|
|
4467
|
+
const isEth = _optionalChain([erc20PairAddress, 'optionalAccess', _159 => _159.toLowerCase, 'call', _160 => _160()]) === ETH_ADDRESS_LOWERCASE;
|
|
4312
4468
|
if (isEth) {
|
|
4313
4469
|
const contractConfig2 = getShieldEthContractConfig(token);
|
|
4314
4470
|
return {
|
|
@@ -4380,8 +4536,8 @@ function useCofheTokenShield(options) {
|
|
|
4380
4536
|
}
|
|
4381
4537
|
assertTokenOperationSupported(confidentialityType, "shield");
|
|
4382
4538
|
let hash;
|
|
4383
|
-
const erc20PairAddress = _optionalChain([input, 'access',
|
|
4384
|
-
const isEth = _optionalChain([erc20PairAddress, 'optionalAccess',
|
|
4539
|
+
const erc20PairAddress = _optionalChain([input, 'access', _161 => _161.token, 'access', _162 => _162.extensions, 'access', _163 => _163.fhenix, 'access', _164 => _164.erc20Pair, 'optionalAccess', _165 => _165.address]);
|
|
4540
|
+
const isEth = _optionalChain([erc20PairAddress, 'optionalAccess', _166 => _166.toLowerCase, 'call', _167 => _167()]) === ETH_ADDRESS_LOWERCASE;
|
|
4385
4541
|
const { main: shieldCallArgs } = getCofheTokenShieldCallArgs({
|
|
4386
4542
|
token: input.token,
|
|
4387
4543
|
amount: input.amount,
|
|
@@ -4394,7 +4550,7 @@ function useCofheTokenShield(options) {
|
|
|
4394
4550
|
});
|
|
4395
4551
|
hash = await walletClient.writeContract({ ...request, chain: void 0 });
|
|
4396
4552
|
} else {
|
|
4397
|
-
_optionalChain([input, 'access',
|
|
4553
|
+
_optionalChain([input, 'access', _168 => _168.onStatusChange, 'optionalCall', _169 => _169("Please confirm shield in wallet...")]);
|
|
4398
4554
|
const { request: shieldRequest } = await publicClient.simulateContract({
|
|
4399
4555
|
...shieldCallArgs,
|
|
4400
4556
|
account: walletClient.account
|
|
@@ -4405,18 +4561,18 @@ function useCofheTokenShield(options) {
|
|
|
4405
4561
|
},
|
|
4406
4562
|
onError: (error, variables, onMutateResult, context) => {
|
|
4407
4563
|
if (onError) onError(error, variables, onMutateResult, context);
|
|
4408
|
-
onTransactionSubmitError(error,
|
|
4564
|
+
onTransactionSubmitError(error, TransactionActionType.Shield);
|
|
4409
4565
|
},
|
|
4410
4566
|
onSuccess: async (hash, input, onMutateResult, context) => {
|
|
4411
|
-
(0,
|
|
4412
|
-
(0,
|
|
4567
|
+
(0, import_ts_essentials13.assert)(chainId, "Chain ID is required for token shield");
|
|
4568
|
+
(0, import_ts_essentials13.assert)(account, "Wallet account is required for token shield");
|
|
4413
4569
|
if (onSuccess) await onSuccess(hash, input, onMutateResult, context);
|
|
4414
4570
|
useTransactionStore.getState().addTransaction({
|
|
4415
4571
|
hash,
|
|
4416
4572
|
token: input.token,
|
|
4417
4573
|
tokenAmount: input.amount,
|
|
4418
4574
|
chainId,
|
|
4419
|
-
actionType:
|
|
4575
|
+
actionType: TransactionActionType.Shield,
|
|
4420
4576
|
account
|
|
4421
4577
|
});
|
|
4422
4578
|
},
|
|
@@ -4428,7 +4584,7 @@ function useCofheTokenShield(options) {
|
|
|
4428
4584
|
|
|
4429
4585
|
|
|
4430
4586
|
// src/hooks/useCofheReadContracts.ts
|
|
4431
|
-
var
|
|
4587
|
+
var import_ts_essentials14 = __toESM(require_dist(), 1);
|
|
4432
4588
|
|
|
4433
4589
|
|
|
4434
4590
|
var QUERY_CACHE_PREFIX3 = "cofheReadContracts";
|
|
@@ -4462,7 +4618,7 @@ function useCofheReadContracts(params, queryOptions) {
|
|
|
4462
4618
|
publicClient,
|
|
4463
4619
|
cofheChainId,
|
|
4464
4620
|
contracts,
|
|
4465
|
-
userEnabled: _optionalChain([queryOptions, 'optionalAccess',
|
|
4621
|
+
userEnabled: _optionalChain([queryOptions, 'optionalAccess', _170 => _170.enabled])
|
|
4466
4622
|
});
|
|
4467
4623
|
const { enabled: _ignoredEnabled, ...restQueryOptions } = queryOptions || {};
|
|
4468
4624
|
return useInternalQuery({
|
|
@@ -4470,11 +4626,11 @@ function useCofheReadContracts(params, queryOptions) {
|
|
|
4470
4626
|
queryKey: constructCofheReadContractsQueryKey({
|
|
4471
4627
|
cofheChainId,
|
|
4472
4628
|
contracts,
|
|
4473
|
-
allowFailure: _optionalChain([multicallOptions, 'optionalAccess',
|
|
4629
|
+
allowFailure: _optionalChain([multicallOptions, 'optionalAccess', _171 => _171.allowFailure])
|
|
4474
4630
|
}),
|
|
4475
4631
|
queryFn: async () => {
|
|
4476
|
-
(0,
|
|
4477
|
-
(0,
|
|
4632
|
+
(0, import_ts_essentials14.assert)(publicClient, "PublicClient should be guaranteed by enabled check");
|
|
4633
|
+
(0, import_ts_essentials14.assert)(contracts && contracts.length > 0, "Contracts should be guaranteed by enabled check");
|
|
4478
4634
|
const raw = await publicClient.multicall({
|
|
4479
4635
|
contracts,
|
|
4480
4636
|
...multicallOptions || {}
|
|
@@ -4546,7 +4702,7 @@ function useCofheTokensWithExistingEncryptedBalances({ chainId: _chainId, accoun
|
|
|
4546
4702
|
{
|
|
4547
4703
|
refetchOnMount: false,
|
|
4548
4704
|
...queryOptions,
|
|
4549
|
-
enabled: (_nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
4705
|
+
enabled: (_nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _172 => _172.enabled]), () => ( true))) && !!account && tokens.length > 0
|
|
4550
4706
|
}
|
|
4551
4707
|
);
|
|
4552
4708
|
const { tokensWithExistingEncryptedBalance, ctHashByTokenAddress, error } = _react.useMemo.call(void 0, () => {
|
|
@@ -4651,7 +4807,7 @@ function useCofheTokenTransfer(writeMutationOptions) {
|
|
|
4651
4807
|
writingMutationOptions: {
|
|
4652
4808
|
onError: (error, variables, onMutateResult, context) => {
|
|
4653
4809
|
if (passedOnError) passedOnError(error, variables, onMutateResult, context);
|
|
4654
|
-
onTransactionSubmitError(error,
|
|
4810
|
+
onTransactionSubmitError(error, TransactionActionType.ShieldSend);
|
|
4655
4811
|
},
|
|
4656
4812
|
onSuccess: (hash, variables, onMutateResult, context) => {
|
|
4657
4813
|
if (passedOnSuccess) passedOnSuccess(hash, variables, onMutateResult, context);
|
|
@@ -4662,7 +4818,7 @@ function useCofheTokenTransfer(writeMutationOptions) {
|
|
|
4662
4818
|
token: extras.token,
|
|
4663
4819
|
tokenAmount: extras.amount,
|
|
4664
4820
|
chainId: extras.token.chainId,
|
|
4665
|
-
actionType:
|
|
4821
|
+
actionType: TransactionActionType.ShieldSend,
|
|
4666
4822
|
account: extras.userAddress
|
|
4667
4823
|
});
|
|
4668
4824
|
},
|
|
@@ -4699,20 +4855,44 @@ function useCofheTokenTransfer(writeMutationOptions) {
|
|
|
4699
4855
|
};
|
|
4700
4856
|
}
|
|
4701
4857
|
|
|
4858
|
+
// src/hooks/useCofheTransactions.ts
|
|
4859
|
+
|
|
4860
|
+
function addCofheTransaction(transaction) {
|
|
4861
|
+
useTransactionStore.getState().addTransaction(transaction);
|
|
4862
|
+
}
|
|
4863
|
+
function useCofheTransactions() {
|
|
4864
|
+
const transactions = useTransactionStore((state) => state.transactions);
|
|
4865
|
+
const addTransaction = _react.useCallback.call(void 0, (transaction) => {
|
|
4866
|
+
addCofheTransaction(transaction);
|
|
4867
|
+
}, []);
|
|
4868
|
+
const clearTransactions = useTransactionStore((state) => state.clearTransactions);
|
|
4869
|
+
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
4870
|
+
const getAllTransactions = useTransactionStore((state) => state.getAllTransactions);
|
|
4871
|
+
const getAllTransactionsByToken = useTransactionStore((state) => state.getAllTransactionsByToken);
|
|
4872
|
+
return {
|
|
4873
|
+
transactions,
|
|
4874
|
+
addTransaction,
|
|
4875
|
+
clearTransactions,
|
|
4876
|
+
getTransaction,
|
|
4877
|
+
getAllTransactions,
|
|
4878
|
+
getAllTransactionsByToken
|
|
4879
|
+
};
|
|
4880
|
+
}
|
|
4881
|
+
|
|
4702
4882
|
// src/hooks/useCofheTokenUnshield.ts
|
|
4703
4883
|
|
|
4704
4884
|
|
|
4705
|
-
var
|
|
4885
|
+
var import_ts_essentials16 = __toESM(require_dist(), 1);
|
|
4706
4886
|
|
|
4707
4887
|
// src/hooks/useStoredTransaction.ts
|
|
4708
4888
|
|
|
4709
|
-
var
|
|
4889
|
+
var import_ts_essentials15 = __toESM(require_dist(), 1);
|
|
4710
4890
|
function useStoredTransaction(txHash) {
|
|
4711
4891
|
const filter2 = _react.useMemo.call(void 0, () => {
|
|
4712
4892
|
return (tx) => tx.hash === txHash;
|
|
4713
4893
|
}, [txHash]);
|
|
4714
4894
|
const { filteredTxs } = useStoredTransactions({ filter: filter2 });
|
|
4715
|
-
(0,
|
|
4895
|
+
(0, import_ts_essentials15.assert)(filteredTxs.length <= 1, "There should be at most one transaction with a given hash");
|
|
4716
4896
|
return filteredTxs[0];
|
|
4717
4897
|
}
|
|
4718
4898
|
|
|
@@ -4732,7 +4912,7 @@ function useOnceTransactionMined({
|
|
|
4732
4912
|
});
|
|
4733
4913
|
return {
|
|
4734
4914
|
transaction,
|
|
4735
|
-
isMining: _optionalChain([transaction, 'optionalAccess',
|
|
4915
|
+
isMining: _optionalChain([transaction, 'optionalAccess', _173 => _173.status]) === "pending"
|
|
4736
4916
|
};
|
|
4737
4917
|
}
|
|
4738
4918
|
function useStoredTransactionStatusEffect({
|
|
@@ -4743,8 +4923,8 @@ function useStoredTransactionStatusEffect({
|
|
|
4743
4923
|
const previousTransactionRef = _react.useRef.call(void 0, void 0);
|
|
4744
4924
|
_react.useEffect.call(void 0, () => {
|
|
4745
4925
|
if (!onTransactionStatusChange) return;
|
|
4746
|
-
if (_optionalChain([previousTransactionRef, 'access',
|
|
4747
|
-
onTransactionStatusChange(_optionalChain([previousTransactionRef, 'access',
|
|
4926
|
+
if (_optionalChain([previousTransactionRef, 'access', _174 => _174.current, 'optionalAccess', _175 => _175.status]) !== _optionalChain([transaction, 'optionalAccess', _176 => _176.status]) && !!transaction) {
|
|
4927
|
+
onTransactionStatusChange(_optionalChain([previousTransactionRef, 'access', _177 => _177.current, 'optionalAccess', _178 => _178.status]), transaction.status, transaction);
|
|
4748
4928
|
previousTransactionRef.current = transaction;
|
|
4749
4929
|
}
|
|
4750
4930
|
}, [onTransactionStatusChange, transaction]);
|
|
@@ -4804,7 +4984,7 @@ function useCofheTokenUnshieldMutation(options) {
|
|
|
4804
4984
|
amount: input.amount,
|
|
4805
4985
|
account: walletClient.account.address
|
|
4806
4986
|
});
|
|
4807
|
-
_optionalChain([input, 'access',
|
|
4987
|
+
_optionalChain([input, 'access', _179 => _179.onStatusChange, 'optionalCall', _180 => _180("Please confirm in wallet...")]);
|
|
4808
4988
|
const { request } = await publicClient.simulateContract({
|
|
4809
4989
|
...unshieldCallArgs,
|
|
4810
4990
|
account: walletClient.account
|
|
@@ -4814,18 +4994,18 @@ function useCofheTokenUnshieldMutation(options) {
|
|
|
4814
4994
|
},
|
|
4815
4995
|
onError: (error, variables, onMutateResult, context) => {
|
|
4816
4996
|
if (onError) onError(error, variables, onMutateResult, context);
|
|
4817
|
-
onTransactionSubmitError(error,
|
|
4997
|
+
onTransactionSubmitError(error, TransactionActionType.Unshield);
|
|
4818
4998
|
},
|
|
4819
4999
|
onSuccess: async (hash, input, onMutateResult, context) => {
|
|
4820
|
-
(0,
|
|
4821
|
-
(0,
|
|
5000
|
+
(0, import_ts_essentials16.assert)(chainId, "Chain ID is required for token unshield");
|
|
5001
|
+
(0, import_ts_essentials16.assert)(account, "Wallet account is required for token unshield");
|
|
4822
5002
|
if (onSuccess) await onSuccess(hash, input, onMutateResult, context);
|
|
4823
5003
|
useTransactionStore.getState().addTransaction({
|
|
4824
5004
|
hash,
|
|
4825
5005
|
token: input.token,
|
|
4826
5006
|
tokenAmount: input.amount,
|
|
4827
5007
|
chainId,
|
|
4828
|
-
actionType:
|
|
5008
|
+
actionType: TransactionActionType.Unshield,
|
|
4829
5009
|
account
|
|
4830
5010
|
});
|
|
4831
5011
|
},
|
|
@@ -4909,7 +5089,7 @@ function parseCoingeckoSimpleTokenPriceUsd({
|
|
|
4909
5089
|
}) {
|
|
4910
5090
|
const key = normalizeCoingeckoContractAddress(contractAddress);
|
|
4911
5091
|
const obj = responseJson;
|
|
4912
|
-
const usd = _optionalChain([obj, 'optionalAccess',
|
|
5092
|
+
const usd = _optionalChain([obj, 'optionalAccess', _181 => _181[key], 'optionalAccess', _182 => _182.usd]);
|
|
4913
5093
|
if (typeof usd !== "number" || !Number.isFinite(usd)) return null;
|
|
4914
5094
|
return usd;
|
|
4915
5095
|
}
|
|
@@ -4918,7 +5098,7 @@ function parseCoingeckoSimplePriceUsd({
|
|
|
4918
5098
|
coinId
|
|
4919
5099
|
}) {
|
|
4920
5100
|
const obj = responseJson;
|
|
4921
|
-
const usd = _optionalChain([obj, 'optionalAccess',
|
|
5101
|
+
const usd = _optionalChain([obj, 'optionalAccess', _183 => _183[coinId], 'optionalAccess', _184 => _184.usd]);
|
|
4922
5102
|
if (typeof usd !== "number" || !Number.isFinite(usd)) return null;
|
|
4923
5103
|
return usd;
|
|
4924
5104
|
}
|
|
@@ -4977,131 +5157,14 @@ function useCoingeckoUsdPrice({
|
|
|
4977
5157
|
return parseCoingeckoSimpleTokenPriceUsd({ responseJson: json, contractAddress: tokenAddress });
|
|
4978
5158
|
},
|
|
4979
5159
|
// Reasonable defaults; consumer can override via queryOptions.
|
|
4980
|
-
staleTime: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
4981
|
-
refetchOnWindowFocus: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
5160
|
+
staleTime: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _185 => _185.staleTime]), () => ( 6e4)),
|
|
5161
|
+
refetchOnWindowFocus: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _186 => _186.refetchOnWindowFocus]), () => ( false)),
|
|
4982
5162
|
...queryOptions
|
|
4983
5163
|
});
|
|
4984
5164
|
}
|
|
4985
5165
|
|
|
4986
5166
|
// src/hooks/useTokensWithPublicBalances.ts
|
|
4987
5167
|
|
|
4988
|
-
|
|
4989
|
-
// src/hooks/useCofheTokenPublicBalance.ts
|
|
4990
|
-
var import_ts_essentials16 = __toESM(require_dist(), 1);
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
function constructPublicTokenBalanceQueryKey({
|
|
4994
|
-
chainId,
|
|
4995
|
-
accountAddress,
|
|
4996
|
-
tokenAddress
|
|
4997
|
-
}) {
|
|
4998
|
-
return ["tokenBalance", chainId, _optionalChain([accountAddress, 'optionalAccess', _171 => _171.toLowerCase, 'call', _172 => _172()]), _optionalChain([tokenAddress, 'optionalAccess', _173 => _173.toLowerCase, 'call', _174 => _174()])];
|
|
4999
|
-
}
|
|
5000
|
-
function constructPublicTokenBalanceQueryKeyForInvalidation({
|
|
5001
|
-
chainId,
|
|
5002
|
-
accountAddress,
|
|
5003
|
-
tokenAddress
|
|
5004
|
-
}) {
|
|
5005
|
-
return constructPublicTokenBalanceQueryKey({
|
|
5006
|
-
chainId,
|
|
5007
|
-
accountAddress,
|
|
5008
|
-
tokenAddress
|
|
5009
|
-
});
|
|
5010
|
-
}
|
|
5011
|
-
function getPublicTokenBalanceSource(token) {
|
|
5012
|
-
const confidentialityType = _optionalChain([token, 'optionalAccess', _175 => _175.extensions, 'access', _176 => _176.fhenix, 'access', _177 => _177.confidentialityType]);
|
|
5013
|
-
const underlyingErc20 = _optionalChain([token, 'optionalAccess', _178 => _178.extensions, 'access', _179 => _179.fhenix, 'access', _180 => _180.erc20Pair]);
|
|
5014
|
-
const publicBalanceSourceType = getPublicBalanceSourceType(confidentialityType);
|
|
5015
|
-
const tokenToFetchBalanceFrom = publicBalanceSourceType === "erc20Pair" ? underlyingErc20 : publicBalanceSourceType === "token" ? token : void 0;
|
|
5016
|
-
if (!tokenToFetchBalanceFrom) return void 0;
|
|
5017
|
-
return {
|
|
5018
|
-
address: tokenToFetchBalanceFrom.address,
|
|
5019
|
-
decimals: tokenToFetchBalanceFrom.decimals
|
|
5020
|
-
};
|
|
5021
|
-
}
|
|
5022
|
-
function createPublicTokenBalanceQueryOptions(params) {
|
|
5023
|
-
const { publicClient, accountAddress, tokenAddress, queryOptions } = params;
|
|
5024
|
-
const { enabled: userEnabled, ...restQueryOptions } = _nullishCoalesce(queryOptions, () => ( {}));
|
|
5025
|
-
const baseEnabled = !!publicClient && !!accountAddress && !!tokenAddress;
|
|
5026
|
-
const enabled = baseEnabled && (_nullishCoalesce(userEnabled, () => ( true)));
|
|
5027
|
-
const queryKey = constructPublicTokenBalanceQueryKey({
|
|
5028
|
-
chainId: _optionalChain([publicClient, 'optionalAccess', _181 => _181.chain, 'optionalAccess', _182 => _182.id]),
|
|
5029
|
-
accountAddress,
|
|
5030
|
-
tokenAddress
|
|
5031
|
-
});
|
|
5032
|
-
return {
|
|
5033
|
-
queryKey,
|
|
5034
|
-
queryFn: withInvalidationContext(
|
|
5035
|
-
async ({ invalidationContext, signal }) => {
|
|
5036
|
-
(0, import_ts_essentials16.assert)(tokenAddress, "Token address is required to fetch token balance");
|
|
5037
|
-
(0, import_ts_essentials16.assert)(publicClient, "PublicClient is required to fetch token balance");
|
|
5038
|
-
(0, import_ts_essentials16.assert)(accountAddress, "Account address is required to fetch token balance");
|
|
5039
|
-
const isNativeToken = tokenAddress.toLowerCase() === ETH_ADDRESS_LOWERCASE;
|
|
5040
|
-
const balance = await maybeWaitUntilRpcAware(
|
|
5041
|
-
publicClient,
|
|
5042
|
-
{
|
|
5043
|
-
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess', _183 => _183.blockHashToBeAwareOf]),
|
|
5044
|
-
readDescription: isNativeToken ? "read native balance" : "read ERC20 balance",
|
|
5045
|
-
read: () => isNativeToken ? publicClient.getBalance({
|
|
5046
|
-
address: accountAddress
|
|
5047
|
-
}) : publicClient.readContract({
|
|
5048
|
-
address: tokenAddress,
|
|
5049
|
-
abi: ERC20_BALANCE_OF_ABI,
|
|
5050
|
-
functionName: "balanceOf",
|
|
5051
|
-
args: [accountAddress]
|
|
5052
|
-
})
|
|
5053
|
-
},
|
|
5054
|
-
{ signal }
|
|
5055
|
-
);
|
|
5056
|
-
return balance;
|
|
5057
|
-
}
|
|
5058
|
-
),
|
|
5059
|
-
enabled,
|
|
5060
|
-
refetchOnMount: false,
|
|
5061
|
-
...restQueryOptions
|
|
5062
|
-
};
|
|
5063
|
-
}
|
|
5064
|
-
function useTokenBalance({ tokenAddress, accountAddress }, queryOptions) {
|
|
5065
|
-
const publicClient = useCofhePublicClient();
|
|
5066
|
-
return useInternalQuery(
|
|
5067
|
-
createPublicTokenBalanceQueryOptions({
|
|
5068
|
-
publicClient,
|
|
5069
|
-
accountAddress,
|
|
5070
|
-
tokenAddress,
|
|
5071
|
-
queryOptions
|
|
5072
|
-
})
|
|
5073
|
-
);
|
|
5074
|
-
}
|
|
5075
|
-
function useCofheTokenPublicBalance({ token, accountAddress, displayDecimals = 5 }, options) {
|
|
5076
|
-
const connectedAccount = useCofheAccount();
|
|
5077
|
-
const account = accountAddress || connectedAccount;
|
|
5078
|
-
const { enabled: userEnabled = true, ...restOptions } = _nullishCoalesce(options, () => ( {}));
|
|
5079
|
-
const tokenToFetchBalanceFrom = getPublicTokenBalanceSource(token);
|
|
5080
|
-
const { data, isFetching, refetch } = useTokenBalance(
|
|
5081
|
-
{
|
|
5082
|
-
tokenAddress: _optionalChain([tokenToFetchBalanceFrom, 'optionalAccess', _184 => _184.address]),
|
|
5083
|
-
accountAddress: account
|
|
5084
|
-
},
|
|
5085
|
-
{
|
|
5086
|
-
enabled: userEnabled,
|
|
5087
|
-
select: (value) => {
|
|
5088
|
-
(0, import_ts_essentials16.assert)(
|
|
5089
|
-
typeof _optionalChain([tokenToFetchBalanceFrom, 'optionalAccess', _185 => _185.decimals]) === "number",
|
|
5090
|
-
"Token decimals must be defined to format public token balance"
|
|
5091
|
-
);
|
|
5092
|
-
return formatTokenAmount(value, tokenToFetchBalanceFrom.decimals, displayDecimals);
|
|
5093
|
-
},
|
|
5094
|
-
...restOptions
|
|
5095
|
-
}
|
|
5096
|
-
);
|
|
5097
|
-
return {
|
|
5098
|
-
data,
|
|
5099
|
-
isFetching,
|
|
5100
|
-
refetch
|
|
5101
|
-
};
|
|
5102
|
-
}
|
|
5103
|
-
|
|
5104
|
-
// src/hooks/useTokensWithPublicBalances.ts
|
|
5105
5168
|
function useTokensWithPublicBalances({ chainId: _chainId, accountAddress, displayDecimals = 5 } = {}, options) {
|
|
5106
5169
|
const connectedAccount = useCofheAccount();
|
|
5107
5170
|
const account = _nullishCoalesce(accountAddress, () => ( connectedAccount));
|
|
@@ -5196,7 +5259,7 @@ function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled:
|
|
|
5196
5259
|
const publicClient = useCofhePublicClient();
|
|
5197
5260
|
const cofheChainId = useCofheChainId();
|
|
5198
5261
|
const chainId = _nullishCoalesce(chainIdInput, () => ( cofheChainId));
|
|
5199
|
-
const enabled = !!publicClient && !!chainId && enabledInput && hashes !== void 0 && _optionalChain([hashes, 'optionalAccess',
|
|
5262
|
+
const enabled = !!publicClient && !!chainId && enabledInput && hashes !== void 0 && _optionalChain([hashes, 'optionalAccess', _187 => _187.size]) > 0;
|
|
5200
5263
|
const queries = _react.useMemo.call(void 0, () => {
|
|
5201
5264
|
if (!hashes) return [];
|
|
5202
5265
|
return Array.from(hashes).map((hash) => {
|
|
@@ -5223,7 +5286,7 @@ function useTransactionReceiptsByHash({ hashes, chainId: chainIdInput, enabled:
|
|
|
5223
5286
|
cofheLogger.log("useTransactionReceiptsByHash - receiptsByHash recalculated");
|
|
5224
5287
|
if (!hashes) return {};
|
|
5225
5288
|
return Array.from(hashes).reduce((acc, hash, i) => {
|
|
5226
|
-
if (!_optionalChain([queriesResults, 'access',
|
|
5289
|
+
if (!_optionalChain([queriesResults, 'access', _188 => _188[i], 'optionalAccess', _189 => _189.data])) return acc;
|
|
5227
5290
|
acc[hash] = queriesResults[i].data;
|
|
5228
5291
|
return acc;
|
|
5229
5292
|
}, {});
|
|
@@ -5278,8 +5341,8 @@ function useCoingeckoContractMarketChartRange({
|
|
|
5278
5341
|
return null;
|
|
5279
5342
|
}
|
|
5280
5343
|
},
|
|
5281
|
-
staleTime: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
5282
|
-
refetchOnWindowFocus: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess',
|
|
5344
|
+
staleTime: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _190 => _190.staleTime]), () => ( 6e4)),
|
|
5345
|
+
refetchOnWindowFocus: _nullishCoalesce(_optionalChain([queryOptions, 'optionalAccess', _191 => _191.refetchOnWindowFocus]), () => ( false)),
|
|
5283
5346
|
...queryOptions
|
|
5284
5347
|
});
|
|
5285
5348
|
}
|
|
@@ -5297,9 +5360,9 @@ function constructTokenAllowanceQueryKey({
|
|
|
5297
5360
|
return [
|
|
5298
5361
|
"tokenAllowance",
|
|
5299
5362
|
chainId,
|
|
5300
|
-
_optionalChain([tokenAddress, 'optionalAccess',
|
|
5301
|
-
_optionalChain([ownerAddress, 'optionalAccess',
|
|
5302
|
-
_optionalChain([spenderAddress, 'optionalAccess',
|
|
5363
|
+
_optionalChain([tokenAddress, 'optionalAccess', _192 => _192.toLowerCase, 'call', _193 => _193()]),
|
|
5364
|
+
_optionalChain([ownerAddress, 'optionalAccess', _194 => _194.toLowerCase, 'call', _195 => _195()]),
|
|
5365
|
+
_optionalChain([spenderAddress, 'optionalAccess', _196 => _196.toLowerCase, 'call', _197 => _197()])
|
|
5303
5366
|
];
|
|
5304
5367
|
}
|
|
5305
5368
|
function constructTokenAllowanceQueryKeyForInvalidation({
|
|
@@ -5321,7 +5384,7 @@ function createTokenAllowanceQueryOptions(params) {
|
|
|
5321
5384
|
const baseEnabled = !!publicClient && !!tokenAddress && !!ownerAddress && !!spenderAddress;
|
|
5322
5385
|
const enabled = baseEnabled && (_nullishCoalesce(userEnabled, () => ( true)));
|
|
5323
5386
|
const queryKey = constructTokenAllowanceQueryKey({
|
|
5324
|
-
chainId: _optionalChain([publicClient, 'optionalAccess',
|
|
5387
|
+
chainId: _optionalChain([publicClient, 'optionalAccess', _198 => _198.chain, 'optionalAccess', _199 => _199.id]),
|
|
5325
5388
|
tokenAddress,
|
|
5326
5389
|
ownerAddress,
|
|
5327
5390
|
spenderAddress
|
|
@@ -5338,7 +5401,7 @@ function createTokenAllowanceQueryOptions(params) {
|
|
|
5338
5401
|
const allowance = await maybeWaitUntilRpcAwareAndReadContract(
|
|
5339
5402
|
publicClient,
|
|
5340
5403
|
{
|
|
5341
|
-
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess',
|
|
5404
|
+
blockHashToBeAwareOf: _optionalChain([invalidationContext, 'optionalAccess', _200 => _200.blockHashToBeAwareOf]),
|
|
5342
5405
|
address: tokenAddress,
|
|
5343
5406
|
abi: allowanceContract.abi,
|
|
5344
5407
|
functionName: allowanceContract.functionName,
|
|
@@ -5484,7 +5547,7 @@ function usePermitForm(options = {}) {
|
|
|
5484
5547
|
setNameError(null);
|
|
5485
5548
|
setReceiverError(null);
|
|
5486
5549
|
} catch (e) {
|
|
5487
|
-
setError(_nullishCoalesce(_optionalChain([e, 'optionalAccess',
|
|
5550
|
+
setError(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _201 => _201.message]), () => ( "Failed to create permit")));
|
|
5488
5551
|
}
|
|
5489
5552
|
}, [isPermitCreationPending, permitName, isDelegate, receiver, durationSeconds, createPermitMutateAsync]);
|
|
5490
5553
|
const reset = _react.useCallback.call(void 0, () => {
|
|
@@ -5524,8 +5587,8 @@ var usePermitsList = () => {
|
|
|
5524
5587
|
const { navigateTo } = usePortalNavigation();
|
|
5525
5588
|
const { openModal } = usePortalModals();
|
|
5526
5589
|
const activePermitHash = _react.useMemo.call(void 0, () => {
|
|
5527
|
-
return _optionalChain([activePermit, 'optionalAccess',
|
|
5528
|
-
}, [_optionalChain([activePermit, 'optionalAccess',
|
|
5590
|
+
return _optionalChain([activePermit, 'optionalAccess', _202 => _202.permit, 'access', _203 => _203.hash]);
|
|
5591
|
+
}, [_optionalChain([activePermit, 'optionalAccess', _204 => _204.permit, 'access', _205 => _205.hash])]);
|
|
5529
5592
|
const selfPermits = _react.useMemo.call(void 0, () => {
|
|
5530
5593
|
return allPermits.filter((permit) => permit.type === "self");
|
|
5531
5594
|
}, [allPermits]);
|
|
@@ -5601,11 +5664,11 @@ function useReceivePermit({ onSuccess, onError } = {}) {
|
|
|
5601
5664
|
}
|
|
5602
5665
|
await client.permits.importShared(importArg);
|
|
5603
5666
|
setSuccessMsg("Permit received and set active.");
|
|
5604
|
-
_optionalChain([onSuccess, 'optionalCall',
|
|
5667
|
+
_optionalChain([onSuccess, 'optionalCall', _206 => _206()]);
|
|
5605
5668
|
} catch (err) {
|
|
5606
|
-
const message = _nullishCoalesce(_optionalChain([err, 'optionalAccess',
|
|
5669
|
+
const message = _nullishCoalesce(_optionalChain([err, 'optionalAccess', _207 => _207.message]), () => ( "Failed to import permit"));
|
|
5607
5670
|
setErrorMsg(message);
|
|
5608
|
-
_optionalChain([onError, 'optionalCall',
|
|
5671
|
+
_optionalChain([onError, 'optionalCall', _208 => _208(new Error(message))]);
|
|
5609
5672
|
} finally {
|
|
5610
5673
|
setIsSubmitting(false);
|
|
5611
5674
|
}
|
|
@@ -5729,16 +5792,16 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5729
5792
|
});
|
|
5730
5793
|
}
|
|
5731
5794
|
});
|
|
5732
|
-
const isActivePermit = permit != null && _optionalChain([activePermit, 'optionalAccess',
|
|
5795
|
+
const isActivePermit = permit != null && _optionalChain([activePermit, 'optionalAccess', _209 => _209.permit, 'access', _210 => _210.hash]) === permitHash;
|
|
5733
5796
|
const expirationDate = permit != null ? new Date(permit.expiration * 1e3).toLocaleString() : void 0;
|
|
5734
|
-
const isShareablePermit = _optionalChain([permit, 'optionalAccess',
|
|
5797
|
+
const isShareablePermit = _optionalChain([permit, 'optionalAccess', _211 => _211.type]) === "sharing";
|
|
5735
5798
|
const permitLabel = _react.useMemo.call(void 0, () => {
|
|
5736
5799
|
if (!permit) return void 0;
|
|
5737
|
-
if (_optionalChain([permit, 'access',
|
|
5800
|
+
if (_optionalChain([permit, 'access', _212 => _212.name, 'optionalAccess', _213 => _213.trim, 'call', _214 => _214()])) return permit.name;
|
|
5738
5801
|
const fallbackAddress = permit.recipient && permit.recipient !== _viem.zeroAddress ? permit.recipient : permit.issuer || _viem.zeroAddress;
|
|
5739
5802
|
return _nullishCoalesce(truncateAddress(fallbackAddress, 4, 4), () => ( fallbackAddress));
|
|
5740
5803
|
}, [permit]);
|
|
5741
|
-
const expirationInfo = _react.useMemo.call(void 0, () => formatExpirationLabel(_optionalChain([permit, 'optionalAccess',
|
|
5804
|
+
const expirationInfo = _react.useMemo.call(void 0, () => formatExpirationLabel(_optionalChain([permit, 'optionalAccess', _215 => _215.expiration])), [_optionalChain([permit, 'optionalAccess', _216 => _216.expiration])]);
|
|
5742
5805
|
const permitJson = _react.useMemo.call(void 0, () => {
|
|
5743
5806
|
if (!permit) return void 0;
|
|
5744
5807
|
return _permits.PermitUtils.export(permit);
|
|
@@ -5778,32 +5841,6 @@ var usePermitDetailsAndActions = (permitHash) => {
|
|
|
5778
5841
|
};
|
|
5779
5842
|
};
|
|
5780
5843
|
|
|
5781
|
-
// src/hooks/useCofheTokenApprove.ts
|
|
5782
|
-
function useCofheTokenApprove(writeMutationOptions) {
|
|
5783
|
-
const { onSuccess: passedOnSuccess, onError: passedOnError, ...restOfOptions } = writeMutationOptions || {};
|
|
5784
|
-
const { onTransactionSubmitError } = useTransactionGlobalLifecycle();
|
|
5785
|
-
return useCofheWriteContract({
|
|
5786
|
-
...restOfOptions,
|
|
5787
|
-
onError: (error, variables, onMutateResult, context) => {
|
|
5788
|
-
if (passedOnError) passedOnError(error, variables, onMutateResult, context);
|
|
5789
|
-
onTransactionSubmitError(error, "approve" /* Approve */);
|
|
5790
|
-
},
|
|
5791
|
-
onSuccess: (hash, variables, onMutateResult, context) => {
|
|
5792
|
-
if (passedOnSuccess) passedOnSuccess(hash, variables, onMutateResult, context);
|
|
5793
|
-
if (!hasExtras(variables)) return;
|
|
5794
|
-
const { token, tokenAmount, account } = variables.extras;
|
|
5795
|
-
useTransactionStore.getState().addTransaction({
|
|
5796
|
-
hash,
|
|
5797
|
-
token,
|
|
5798
|
-
tokenAmount,
|
|
5799
|
-
chainId: token.chainId,
|
|
5800
|
-
actionType: "approve" /* Approve */,
|
|
5801
|
-
account
|
|
5802
|
-
});
|
|
5803
|
-
}
|
|
5804
|
-
});
|
|
5805
|
-
}
|
|
5806
|
-
|
|
5807
5844
|
// src/hooks/useReschedulableTimeout.ts
|
|
5808
5845
|
|
|
5809
5846
|
function useReschedulableTimeout(callback, defaultTimeout) {
|
|
@@ -5898,7 +5935,7 @@ var CofheEncryptInput = ({
|
|
|
5898
5935
|
onEncryptError
|
|
5899
5936
|
}) => {
|
|
5900
5937
|
const [textValue, setTextValue] = _react.useState.call(void 0, initialValue);
|
|
5901
|
-
const [selectedType, setSelectedType] = _react.useState.call(void 0, _optionalChain([options, 'access',
|
|
5938
|
+
const [selectedType, setSelectedType] = _react.useState.call(void 0, _optionalChain([options, 'access', _217 => _217[0], 'optionalAccess', _218 => _218.value]) || "uint32");
|
|
5902
5939
|
const [isDropdownOpen, setIsDropdownOpen] = _react.useState.call(void 0, false);
|
|
5903
5940
|
const [showProgress, setShowProgress] = _react.useState.call(void 0, false);
|
|
5904
5941
|
const [encryptedResult, setEncryptedResult] = _react.useState.call(void 0, null);
|
|
@@ -5930,7 +5967,7 @@ var CofheEncryptInput = ({
|
|
|
5930
5967
|
}, [showProgressBar, isEncrypting]);
|
|
5931
5968
|
_react.useEffect.call(void 0, () => {
|
|
5932
5969
|
if (isEncrypting && lastEncryptionStep && encryptionProgress && encryptionProgressLabel) {
|
|
5933
|
-
_optionalChain([onEncryptProgress, 'optionalCall',
|
|
5970
|
+
_optionalChain([onEncryptProgress, 'optionalCall', _219 => _219({
|
|
5934
5971
|
step: lastEncryptionStep.step,
|
|
5935
5972
|
progress: encryptionProgress,
|
|
5936
5973
|
label: encryptionProgressLabel
|
|
@@ -6021,7 +6058,7 @@ var CofheEncryptInput = ({
|
|
|
6021
6058
|
const handleTextChange = (e) => {
|
|
6022
6059
|
const value = e.target.value;
|
|
6023
6060
|
setTextValue(value);
|
|
6024
|
-
_optionalChain([onTextChange, 'optionalCall',
|
|
6061
|
+
_optionalChain([onTextChange, 'optionalCall', _220 => _220(value)]);
|
|
6025
6062
|
setEncryptedResult(null);
|
|
6026
6063
|
setCopySuccess(false);
|
|
6027
6064
|
debouncedValidation(value);
|
|
@@ -6052,27 +6089,27 @@ var CofheEncryptInput = ({
|
|
|
6052
6089
|
const handleTypeSelect = async (type) => {
|
|
6053
6090
|
setSelectedType(type);
|
|
6054
6091
|
setIsDropdownOpen(false);
|
|
6055
|
-
_optionalChain([onTypeChange, 'optionalCall',
|
|
6092
|
+
_optionalChain([onTypeChange, 'optionalCall', _221 => _221(type)]);
|
|
6056
6093
|
if (textValue.trim() !== "") {
|
|
6057
6094
|
try {
|
|
6058
6095
|
cofheLogger.log("Auto-encrypting value:", textValue, "as type:", type);
|
|
6059
|
-
_optionalChain([onEncryptStart, 'optionalCall',
|
|
6096
|
+
_optionalChain([onEncryptStart, 'optionalCall', _222 => _222({ value: textValue, type })]);
|
|
6060
6097
|
(async () => {
|
|
6061
6098
|
try {
|
|
6062
6099
|
const [encryptionResult] = await encrypt([_sdk.Encryptable.create(type, textValue)]);
|
|
6063
6100
|
setEncryptedResult(encryptionResult);
|
|
6064
6101
|
const data = { value: textValue, encrypted: encryptionResult };
|
|
6065
|
-
_optionalChain([onEncryptComplete, 'optionalCall',
|
|
6102
|
+
_optionalChain([onEncryptComplete, 'optionalCall', _223 => _223(data)]);
|
|
6066
6103
|
} catch (error) {
|
|
6067
6104
|
const errorMessage2 = error instanceof Error ? error.message : "Encryption failed";
|
|
6068
6105
|
cofheLogger.error("Encryption failed:", error);
|
|
6069
|
-
_optionalChain([onEncryptError, 'optionalCall',
|
|
6106
|
+
_optionalChain([onEncryptError, 'optionalCall', _224 => _224(errorMessage2)]);
|
|
6070
6107
|
}
|
|
6071
6108
|
})();
|
|
6072
6109
|
} catch (error) {
|
|
6073
6110
|
const errorMessage2 = error instanceof Error ? error.message : "Encryption setup failed";
|
|
6074
6111
|
cofheLogger.error("Encryption setup failed:", error);
|
|
6075
|
-
_optionalChain([onEncryptError, 'optionalCall',
|
|
6112
|
+
_optionalChain([onEncryptError, 'optionalCall', _225 => _225(errorMessage2)]);
|
|
6076
6113
|
}
|
|
6077
6114
|
}
|
|
6078
6115
|
};
|
|
@@ -6214,7 +6251,7 @@ function abortError2(message = "Aborted") {
|
|
|
6214
6251
|
}
|
|
6215
6252
|
async function sleep2(ms, signal) {
|
|
6216
6253
|
if (ms <= 0) return;
|
|
6217
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
6254
|
+
if (_optionalChain([signal, 'optionalAccess', _226 => _226.aborted])) throw abortError2();
|
|
6218
6255
|
await new Promise((resolve, reject) => {
|
|
6219
6256
|
const cleanup = () => {
|
|
6220
6257
|
if (signal) signal.removeEventListener("abort", onAbort);
|
|
@@ -6240,7 +6277,7 @@ async function resolveReceiptBlockHash(receipt, publicClient, signal) {
|
|
|
6240
6277
|
});
|
|
6241
6278
|
let attempt = 0;
|
|
6242
6279
|
while (true) {
|
|
6243
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
6280
|
+
if (_optionalChain([signal, 'optionalAccess', _227 => _227.aborted])) throw abortError2();
|
|
6244
6281
|
attempt += 1;
|
|
6245
6282
|
try {
|
|
6246
6283
|
const block = await publicClient.getBlock({
|
|
@@ -6412,10 +6449,10 @@ function useTrackPendingTransactionsBase({
|
|
|
6412
6449
|
receipt: normalizedReceipt
|
|
6413
6450
|
});
|
|
6414
6451
|
if (status === "confirmed" /* Confirmed */) onReceiptSuccess(tx, normalizedReceipt);
|
|
6415
|
-
else _optionalChain([onReceiptFail, 'optionalCall',
|
|
6452
|
+
else _optionalChain([onReceiptFail, 'optionalCall', _228 => _228(tx, normalizedReceipt)]);
|
|
6416
6453
|
return normalizedReceipt;
|
|
6417
6454
|
} catch (e) {
|
|
6418
|
-
_optionalChain([onFetchFailure, 'optionalCall',
|
|
6455
|
+
_optionalChain([onFetchFailure, 'optionalCall', _229 => _229(e, tx)]);
|
|
6419
6456
|
useTransactionStore.getState().updateTransactionStatus(tx.chainId, tx.hash, "failed" /* Failed */);
|
|
6420
6457
|
throw e;
|
|
6421
6458
|
}
|
|
@@ -6431,7 +6468,7 @@ function useTrackPendingTransactionsBase({
|
|
|
6431
6468
|
function useHandleInvalidations() {
|
|
6432
6469
|
const queryClient = useInternalQueryClient();
|
|
6433
6470
|
const handleInvalidations = (tx, receipt) => {
|
|
6434
|
-
const blockHashToBeAwareOf = _nullishCoalesce(_optionalChain([receipt, 'optionalAccess',
|
|
6471
|
+
const blockHashToBeAwareOf = _nullishCoalesce(_optionalChain([receipt, 'optionalAccess', _230 => _230.blockHash]), () => ( _optionalChain([tx, 'access', _231 => _231.receipt, 'optionalAccess', _232 => _232.blockHash])));
|
|
6435
6472
|
invalidatePublicTokenBalanceQueries(
|
|
6436
6473
|
{
|
|
6437
6474
|
tokenAddress: ETH_ADDRESS_LOWERCASE,
|
|
@@ -6441,11 +6478,11 @@ function useHandleInvalidations() {
|
|
|
6441
6478
|
queryClient,
|
|
6442
6479
|
blockHashToBeAwareOf
|
|
6443
6480
|
);
|
|
6444
|
-
if (tx.actionType ===
|
|
6481
|
+
if (tx.actionType === TransactionActionType.ShieldSend) {
|
|
6445
6482
|
invalidateConfidentialTokenBalanceQueries(tx.token, queryClient, blockHashToBeAwareOf);
|
|
6446
|
-
} else if (tx.actionType ===
|
|
6483
|
+
} else if (tx.actionType === TransactionActionType.Shield) {
|
|
6447
6484
|
invalidatePublicAndConfidentialTokenBalanceQueries(tx.token, tx.account, queryClient, blockHashToBeAwareOf);
|
|
6448
|
-
} else if (tx.actionType ===
|
|
6485
|
+
} else if (tx.actionType === TransactionActionType.Unshield) {
|
|
6449
6486
|
invalidateConfidentialTokenBalanceQueries(tx.token, queryClient, blockHashToBeAwareOf);
|
|
6450
6487
|
if (isTokenOperationSupported(tx.token.extensions.fhenix.confidentialityType, "claimable")) {
|
|
6451
6488
|
invalidateClaimableQueries({
|
|
@@ -6455,7 +6492,7 @@ function useHandleInvalidations() {
|
|
|
6455
6492
|
blockHashToBeAwareOf
|
|
6456
6493
|
});
|
|
6457
6494
|
}
|
|
6458
|
-
} else if (tx.actionType ===
|
|
6495
|
+
} else if (tx.actionType === TransactionActionType.Claim) {
|
|
6459
6496
|
const publicBalanceSource = getPublicTokenBalanceSource(tx.token);
|
|
6460
6497
|
if (publicBalanceSource) {
|
|
6461
6498
|
invalidatePublicTokenBalanceQueries(
|
|
@@ -6474,7 +6511,7 @@ function useHandleInvalidations() {
|
|
|
6474
6511
|
queryClient,
|
|
6475
6512
|
blockHashToBeAwareOf
|
|
6476
6513
|
});
|
|
6477
|
-
} else if (tx.actionType ===
|
|
6514
|
+
} else if (tx.actionType === TransactionActionType.Approve) {
|
|
6478
6515
|
const publicBalanceSource = getPublicTokenBalanceSource(tx.token);
|
|
6479
6516
|
if (publicBalanceSource && publicBalanceSource.address.toLowerCase() !== ETH_ADDRESS_LOWERCASE) {
|
|
6480
6517
|
invalidateTokenAllowanceQueries(
|
|
@@ -6488,6 +6525,7 @@ function useHandleInvalidations() {
|
|
|
6488
6525
|
blockHashToBeAwareOf
|
|
6489
6526
|
);
|
|
6490
6527
|
}
|
|
6528
|
+
} else if (isCustomTransactionActionType(tx.actionType)) {
|
|
6491
6529
|
} else {
|
|
6492
6530
|
cofheLogger.warn("No invalidation logic for transaction action type:", tx.actionType);
|
|
6493
6531
|
}
|
|
@@ -6640,9 +6678,9 @@ var useWatchPermitStatus = () => {
|
|
|
6640
6678
|
hidePermitSharedStatus();
|
|
6641
6679
|
}
|
|
6642
6680
|
};
|
|
6643
|
-
updateStatuses(_optionalChain([activePermit, 'optionalAccess',
|
|
6681
|
+
updateStatuses(_optionalChain([activePermit, 'optionalAccess', _233 => _233.permit]));
|
|
6644
6682
|
intervalRef.current = setInterval(() => {
|
|
6645
|
-
updateStatuses(_optionalChain([activePermit, 'optionalAccess',
|
|
6683
|
+
updateStatuses(_optionalChain([activePermit, 'optionalAccess', _234 => _234.permit]));
|
|
6646
6684
|
}, 2e3);
|
|
6647
6685
|
return () => {
|
|
6648
6686
|
if (intervalRef.current) {
|
|
@@ -7006,7 +7044,7 @@ var ChainIcon = ({ chainId, className }) => {
|
|
|
7006
7044
|
var ConnectedChainIndicator = () => {
|
|
7007
7045
|
const chainId = useCofheChainId();
|
|
7008
7046
|
const chain = chainId ? _chains.getChainById.call(void 0, chainId) : void 0;
|
|
7009
|
-
const currentNetwork = _optionalChain([chain, 'optionalAccess',
|
|
7047
|
+
const currentNetwork = _optionalChain([chain, 'optionalAccess', _235 => _235.name]) || "Eth";
|
|
7010
7048
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7011
7049
|
"div",
|
|
7012
7050
|
{
|
|
@@ -7165,7 +7203,7 @@ var CofheTokenConfidentialBalance = ({
|
|
|
7165
7203
|
hidden: disabledDueToMissingValidPermit,
|
|
7166
7204
|
isFetching: isFetchingConfidential,
|
|
7167
7205
|
formattedBalance: confidentialBalanceFormatted,
|
|
7168
|
-
symbol: showSymbol ? _optionalChain([token, 'optionalAccess',
|
|
7206
|
+
symbol: showSymbol ? _optionalChain([token, 'optionalAccess', _236 => _236.symbol]) : void 0
|
|
7169
7207
|
}
|
|
7170
7208
|
);
|
|
7171
7209
|
};
|
|
@@ -7189,7 +7227,7 @@ var CofheTokenPublicBalance = ({
|
|
|
7189
7227
|
size,
|
|
7190
7228
|
isFetching: isFetchingPublic,
|
|
7191
7229
|
formattedBalance: publicBalanceFormatted,
|
|
7192
|
-
symbol: showSymbol ? _optionalChain([token, 'optionalAccess',
|
|
7230
|
+
symbol: showSymbol ? _optionalChain([token, 'optionalAccess', _237 => _237.symbol]) : void 0
|
|
7193
7231
|
}
|
|
7194
7232
|
);
|
|
7195
7233
|
};
|
|
@@ -7198,7 +7236,7 @@ var CofheTokenPublicBalance = ({
|
|
|
7198
7236
|
function useCofhePinnedTokenAddress() {
|
|
7199
7237
|
const widgetConfig = useCofheContext().client.config.react;
|
|
7200
7238
|
const chainId = useCofheChainId();
|
|
7201
|
-
const pinnedTokenAddress = chainId ? _optionalChain([widgetConfig, 'access',
|
|
7239
|
+
const pinnedTokenAddress = chainId ? _optionalChain([widgetConfig, 'access', _238 => _238.pinnedTokens, 'optionalAccess', _239 => _239[_optionalChain([chainId, 'optionalAccess', _240 => _240.toString, 'call', _241 => _241()])]]) : void 0;
|
|
7202
7240
|
return pinnedTokenAddress;
|
|
7203
7241
|
}
|
|
7204
7242
|
|
|
@@ -7265,8 +7303,8 @@ var AssetCard = () => {
|
|
|
7265
7303
|
),
|
|
7266
7304
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
|
|
7267
7305
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-3 flex-1", children: [
|
|
7268
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenIcon, { logoURI: _optionalChain([token, 'optionalAccess',
|
|
7269
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-lg font-bold cofhe-text-primary", children: _optionalChain([token, 'optionalAccess',
|
|
7306
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TokenIcon, { logoURI: _optionalChain([token, 'optionalAccess', _242 => _242.logoURI]), alt: _optionalChain([token, 'optionalAccess', _243 => _243.symbol]), size: "md" }),
|
|
7307
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-lg font-bold cofhe-text-primary", children: _optionalChain([token, 'optionalAccess', _244 => _244.symbol]) }) })
|
|
7270
7308
|
] }),
|
|
7271
7309
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
7272
7310
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-col items-end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -7481,8 +7519,8 @@ var formatUsd = (n) => n.toLocaleString(void 0, {
|
|
|
7481
7519
|
maximumFractionDigits: 0
|
|
7482
7520
|
});
|
|
7483
7521
|
var CustomTooltip = ({ active, payload, label }) => {
|
|
7484
|
-
if (!active || !_optionalChain([payload, 'optionalAccess',
|
|
7485
|
-
const v = _optionalChain([payload, 'access',
|
|
7522
|
+
if (!active || !_optionalChain([payload, 'optionalAccess', _245 => _245.length])) return null;
|
|
7523
|
+
const v = _optionalChain([payload, 'access', _246 => _246[0], 'optionalAccess', _247 => _247.value]);
|
|
7486
7524
|
if (typeof v !== "number") return null;
|
|
7487
7525
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rounded-md border cofhe-card-border cofhe-card-bg px-2 py-1 shadow-sm", children: [
|
|
7488
7526
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-xxxs opacity-70", children: typeof label === "number" ? formatTime(label) : "" }),
|
|
@@ -7570,40 +7608,66 @@ var PageContainer = ({ isModal, header, content, footer }) => {
|
|
|
7570
7608
|
|
|
7571
7609
|
|
|
7572
7610
|
|
|
7611
|
+
|
|
7612
|
+
var warnedMissingCustomRendererActionTypes = /* @__PURE__ */ new Set();
|
|
7573
7613
|
var ActionIcon = ({ actionType }) => {
|
|
7574
7614
|
const iconClassName2 = "w-5 h-5";
|
|
7575
7615
|
switch (actionType) {
|
|
7576
|
-
case
|
|
7616
|
+
case TransactionActionType.ShieldSend:
|
|
7577
7617
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _go.GoArrowUpRight, { className: iconClassName2 });
|
|
7578
|
-
case
|
|
7618
|
+
case TransactionActionType.Shield:
|
|
7579
7619
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _tb.TbShieldPlus, { className: iconClassName2 });
|
|
7580
|
-
case
|
|
7620
|
+
case TransactionActionType.Unshield:
|
|
7581
7621
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _tb.TbShieldMinus, { className: iconClassName2 });
|
|
7582
|
-
case
|
|
7622
|
+
case TransactionActionType.Claim:
|
|
7583
7623
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _tb.TbShieldCheck, { className: iconClassName2 });
|
|
7584
|
-
case
|
|
7624
|
+
case TransactionActionType.Approve:
|
|
7585
7625
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _go.GoArrowUpRight, { className: iconClassName2 });
|
|
7586
7626
|
default:
|
|
7587
7627
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _go.GoArrowUpRight, { className: iconClassName2 });
|
|
7588
7628
|
}
|
|
7589
7629
|
};
|
|
7630
|
+
function stringifyPayload(payload) {
|
|
7631
|
+
try {
|
|
7632
|
+
return JSON.stringify(payload, null, 2);
|
|
7633
|
+
} catch (e6) {
|
|
7634
|
+
return String(payload);
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7590
7637
|
var TransactionItem = ({ transaction }) => {
|
|
7638
|
+
const { transactionRenderers } = useCofheContext();
|
|
7639
|
+
const Renderer = _optionalChain([transactionRenderers, 'optionalAccess', _248 => _248[transaction.actionType]]);
|
|
7640
|
+
_react.useEffect.call(void 0, () => {
|
|
7641
|
+
if (Renderer || !isCustomTransactionActionType(transaction.actionType)) return;
|
|
7642
|
+
if (warnedMissingCustomRendererActionTypes.has(transaction.actionType)) return;
|
|
7643
|
+
warnedMissingCustomRendererActionTypes.add(transaction.actionType);
|
|
7644
|
+
cofheLogger.warn(
|
|
7645
|
+
`No custom transaction renderer registered for "${transaction.actionType}". The SDK is using the fallback JSON renderer. Register a renderer by passing transactionRenderers to CofheProvider, for example: `,
|
|
7646
|
+
{
|
|
7647
|
+
transactionRenderers: {
|
|
7648
|
+
[transaction.actionType]: "YourTransactionRenderer"
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
);
|
|
7652
|
+
}, [Renderer, transaction.actionType]);
|
|
7653
|
+
if (Renderer) {
|
|
7654
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Renderer, { transaction });
|
|
7655
|
+
}
|
|
7656
|
+
const amountLabel = "token" in transaction ? `${_viem.formatUnits.call(void 0, transaction.tokenAmount, transaction.token.decimals)} ${transaction.token.symbol}` : null;
|
|
7591
7657
|
const statusColorClass = transaction.status === "pending" /* Pending */ ? "text-yellow-600 dark:text-yellow-400" : transaction.status === "confirmed" /* Confirmed */ ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400";
|
|
7592
7658
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "cofhe-card-bg p-3 rounded-lg border cofhe-dropdown-border", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start gap-3", children: [
|
|
7593
7659
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-full cofhe-icon-bg flex items-center justify-center flex-shrink-0 cofhe-text-primary", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ActionIcon, { actionType: transaction.actionType }) }),
|
|
7594
7660
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 min-w-0", children: [
|
|
7595
7661
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2", children: [
|
|
7596
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-semibold cofhe-text-primary", children: actionToString(transaction.actionType) }),
|
|
7597
|
-
/* @__PURE__ */ _jsxruntime.
|
|
7598
|
-
_viem.formatUnits.call(void 0, transaction.tokenAmount, transaction.token.decimals),
|
|
7599
|
-
" ",
|
|
7600
|
-
transaction.token.symbol
|
|
7601
|
-
] })
|
|
7662
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-semibold cofhe-text-primary", children: actionToString(transaction.actionType, transaction.title) }),
|
|
7663
|
+
amountLabel ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-semibold cofhe-text-primary", children: amountLabel }) : null
|
|
7602
7664
|
] }),
|
|
7603
7665
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-2 mt-1", children: [
|
|
7604
7666
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cn("text-xs font-medium", statusColorClass), children: statusToString(transaction.status) }),
|
|
7605
7667
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs cofhe-text-primary opacity-60", children: formatRelativeTime(transaction.timestamp) })
|
|
7606
7668
|
] }),
|
|
7669
|
+
transaction.description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-1 text-xs cofhe-text-primary opacity-70", children: transaction.description }) : null,
|
|
7670
|
+
isCustomTransactionActionType(transaction.actionType) && transaction.payload !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "pre", { className: "mt-2 max-h-24 overflow-auto rounded cofhe-card-bg p-2 text-[10px] cofhe-text-primary opacity-80", children: stringifyPayload(transaction.payload) }) : null,
|
|
7607
7671
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, HashLink, { type: "tx", hash: transaction.hash, chainId: transaction.chainId, copyable: true }) })
|
|
7608
7672
|
] })
|
|
7609
7673
|
] }) });
|
|
@@ -7611,7 +7675,7 @@ var TransactionItem = ({ transaction }) => {
|
|
|
7611
7675
|
|
|
7612
7676
|
// src/utils/isProduction.ts
|
|
7613
7677
|
var isProduction = () => {
|
|
7614
|
-
if (typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
7678
|
+
if (typeof process !== "undefined" && _optionalChain([process, 'access', _249 => _249.env, 'optionalAccess', _250 => _250.NODE_ENV]) === "development") {
|
|
7615
7679
|
return false;
|
|
7616
7680
|
}
|
|
7617
7681
|
if (typeof import.meta !== "undefined") {
|
|
@@ -7885,7 +7949,7 @@ var PermitItem = ({ permit, onClick, activePermitHash }) => {
|
|
|
7885
7949
|
{
|
|
7886
7950
|
variant: "ghost",
|
|
7887
7951
|
className: "flex flex-row w-full items-centera !justify-start gap-3 p-0.5",
|
|
7888
|
-
onClick: () => _optionalChain([onClick, 'optionalCall',
|
|
7952
|
+
onClick: () => _optionalChain([onClick, 'optionalCall', _251 => _251(permit.hash)]),
|
|
7889
7953
|
children: [
|
|
7890
7954
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7891
7955
|
"span",
|
|
@@ -8109,7 +8173,7 @@ var permitActions = [
|
|
|
8109
8173
|
{ id: "import", label: "Import", icon: _fa.FaDownload }
|
|
8110
8174
|
];
|
|
8111
8175
|
function computeDefaultActiveAccordionId({ activePermit }) {
|
|
8112
|
-
if (_optionalChain([activePermit, 'optionalAccess',
|
|
8176
|
+
if (_optionalChain([activePermit, 'optionalAccess', _252 => _252.type]) === "recipient") {
|
|
8113
8177
|
return "received";
|
|
8114
8178
|
}
|
|
8115
8179
|
return "self";
|
|
@@ -8604,7 +8668,7 @@ var money = (n) => n.toLocaleString(void 0, {
|
|
|
8604
8668
|
});
|
|
8605
8669
|
var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
8606
8670
|
const account = useCofheAccount();
|
|
8607
|
-
const publicSymbol = _nullishCoalesce(_optionalChain([token, 'access',
|
|
8671
|
+
const publicSymbol = _nullishCoalesce(_optionalChain([token, 'access', _253 => _253.extensions, 'access', _254 => _254.fhenix, 'access', _255 => _255.erc20Pair, 'optionalAccess', _256 => _256.symbol]), () => ( token.symbol));
|
|
8608
8672
|
const { data: publicBalance, isFetching: isFetchingPublicBalance } = useCofheTokenPublicBalance({ token });
|
|
8609
8673
|
const { data: confidentialBalance, isFetching: isFetchingConfidentialBalance } = useCofheTokenDecryptedBalance({
|
|
8610
8674
|
accountAddress: account,
|
|
@@ -8613,9 +8677,9 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
8613
8677
|
const isFetchingBalances = isFetchingConfidentialBalance || isFetchingPublicBalance;
|
|
8614
8678
|
const balancePercents = _react.useMemo.call(void 0, () => {
|
|
8615
8679
|
if (!confidentialBalance && !publicBalance) return;
|
|
8616
|
-
const confidentialUnit = _nullishCoalesce(_optionalChain([confidentialBalance, 'optionalAccess',
|
|
8617
|
-
const publicUnit = _nullishCoalesce(_optionalChain([publicBalance, 'optionalAccess',
|
|
8618
|
-
const totalUnit = _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([confidentialUnit, 'optionalAccess',
|
|
8680
|
+
const confidentialUnit = _nullishCoalesce(_optionalChain([confidentialBalance, 'optionalAccess', _257 => _257.unit]), () => ( null));
|
|
8681
|
+
const publicUnit = _nullishCoalesce(_optionalChain([publicBalance, 'optionalAccess', _258 => _258.unit]), () => ( null));
|
|
8682
|
+
const totalUnit = _nullishCoalesce(_optionalChain([(_nullishCoalesce(_optionalChain([confidentialUnit, 'optionalAccess', _259 => _259.plus, 'call', _260 => _260(_nullishCoalesce(publicUnit, () => ( 0)))]), () => ( publicUnit))), 'optionalAccess', _261 => _261.toNumber, 'call', _262 => _262()]), () => ( 0));
|
|
8619
8683
|
const confidentialPct = totalUnit && totalUnit > 0 && confidentialUnit ? parseInt(confidentialUnit.div(totalUnit).times(100).toFixed(2)) : 0;
|
|
8620
8684
|
const publicPct = 100 - confidentialPct;
|
|
8621
8685
|
return {
|
|
@@ -8624,8 +8688,8 @@ var TokenInfoBalanceChart = ({ token, chartPoints }) => {
|
|
|
8624
8688
|
};
|
|
8625
8689
|
}, [confidentialBalance, publicBalance]);
|
|
8626
8690
|
const price = _react.useMemo.call(void 0, () => {
|
|
8627
|
-
const lastPoint = _optionalChain([chartPoints, 'optionalAccess',
|
|
8628
|
-
const firstPoint = _optionalChain([chartPoints, 'optionalAccess',
|
|
8691
|
+
const lastPoint = _optionalChain([chartPoints, 'optionalAccess', _263 => _263[chartPoints.length - 1]]);
|
|
8692
|
+
const firstPoint = _optionalChain([chartPoints, 'optionalAccess', _264 => _264[0]]);
|
|
8629
8693
|
if (!lastPoint || !firstPoint) return;
|
|
8630
8694
|
return {
|
|
8631
8695
|
valueUsd: lastPoint.value,
|
|
@@ -8705,7 +8769,7 @@ var TokenInfoTransactionHistoryHeader = ({ token }) => {
|
|
|
8705
8769
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
|
|
8706
8770
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-bold cofhe-text-primary", children: "Activity" }),
|
|
8707
8771
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, HashLink, { type: "token", hash: token.address, chainId: token.chainId, extraShort: true }),
|
|
8708
|
-
_optionalChain([token, 'access',
|
|
8772
|
+
_optionalChain([token, 'access', _265 => _265.extensions, 'access', _266 => _266.fhenix, 'access', _267 => _267.erc20Pair, 'optionalAccess', _268 => _268.address]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, HashLink, { type: "token", hash: token.extensions.fhenix.erc20Pair.address, chainId: token.chainId, extraShort: true })
|
|
8709
8773
|
] });
|
|
8710
8774
|
};
|
|
8711
8775
|
var money2 = (n) => n.toLocaleString(void 0, {
|
|
@@ -8719,14 +8783,25 @@ var TokenInfoTransactionHistory = ({ token, priceUsd }) => {
|
|
|
8719
8783
|
const { filteredTxs: tokenTxs } = useStoredTransactions({
|
|
8720
8784
|
chainId: token.chainId,
|
|
8721
8785
|
account,
|
|
8722
|
-
filter: (tx) =>
|
|
8786
|
+
filter: (tx) => {
|
|
8787
|
+
const tokenAddress = token.address.toLowerCase();
|
|
8788
|
+
if ("token" in tx && tx.token.address.toLowerCase() === tokenAddress) return true;
|
|
8789
|
+
return _nullishCoalesce(_optionalChain([tx, 'access', _269 => _269.tokenTags, 'optionalAccess', _270 => _270.some, 'call', _271 => _271((tag) => tag.toLowerCase() === tokenAddress)]), () => ( false));
|
|
8790
|
+
}
|
|
8723
8791
|
});
|
|
8724
8792
|
const activity = _react.useMemo.call(void 0, () => {
|
|
8725
8793
|
return tokenTxs.slice().sort((a, b) => b.timestamp - a.timestamp).map((tx) => {
|
|
8794
|
+
if (!("token" in tx)) {
|
|
8795
|
+
return {
|
|
8796
|
+
kind: actionToString(tx.actionType, tx.title),
|
|
8797
|
+
description: tx.description
|
|
8798
|
+
};
|
|
8799
|
+
}
|
|
8726
8800
|
const amountToken = parseFloat(_viem.formatUnits.call(void 0, tx.tokenAmount, tx.token.decimals));
|
|
8727
8801
|
const amountUsd = typeof priceUsd === "number" && Number.isFinite(amountToken) ? amountToken * priceUsd : void 0;
|
|
8728
8802
|
return {
|
|
8729
|
-
kind: actionToString(tx.actionType),
|
|
8803
|
+
kind: actionToString(tx.actionType, tx.title),
|
|
8804
|
+
description: tx.description,
|
|
8730
8805
|
amountUsd,
|
|
8731
8806
|
amountToken: Number.isFinite(amountToken) ? amountToken : 0
|
|
8732
8807
|
};
|
|
@@ -8745,16 +8820,19 @@ var TokenInfoTransactionHistory = ({ token, priceUsd }) => {
|
|
|
8745
8820
|
)
|
|
8746
8821
|
}
|
|
8747
8822
|
),
|
|
8748
|
-
/* @__PURE__ */ _jsxruntime.
|
|
8823
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
8824
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-bold cofhe-text-primary", children: item.kind }),
|
|
8825
|
+
item.description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs opacity-70", children: item.description }) : null
|
|
8826
|
+
] })
|
|
8749
8827
|
] }),
|
|
8750
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-end", children: [
|
|
8828
|
+
"amountToken" in item ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col items-end", children: [
|
|
8751
8829
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-bold cofhe-text-primary", children: typeof item.amountUsd === "number" ? money2(item.amountUsd) : "--" }),
|
|
8752
8830
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-xxxs opacity-70", children: [
|
|
8753
8831
|
item.amountToken,
|
|
8754
8832
|
" ",
|
|
8755
8833
|
token.symbol
|
|
8756
8834
|
] })
|
|
8757
|
-
] })
|
|
8835
|
+
] }) : null
|
|
8758
8836
|
] }, idx);
|
|
8759
8837
|
}) }) }) });
|
|
8760
8838
|
};
|
|
@@ -8769,13 +8847,13 @@ var TokenInfoPage = ({ token }) => {
|
|
|
8769
8847
|
contractAddress: TMP_WBTC_ON_MAINNET.address
|
|
8770
8848
|
} : {
|
|
8771
8849
|
chainId: token.chainId,
|
|
8772
|
-
contractAddress: _nullishCoalesce(_optionalChain([token, 'access',
|
|
8850
|
+
contractAddress: _nullishCoalesce(_optionalChain([token, 'access', _272 => _272.extensions, 'access', _273 => _273.fhenix, 'access', _274 => _274.erc20Pair, 'optionalAccess', _275 => _275.address]), () => ( token.address))
|
|
8773
8851
|
},
|
|
8774
8852
|
rangeMs: 24 * 36e5
|
|
8775
8853
|
});
|
|
8776
8854
|
const priceUsd = _react.useMemo.call(void 0, () => {
|
|
8777
|
-
const lastPoint = _optionalChain([chartPoints, 'optionalAccess',
|
|
8778
|
-
return _optionalChain([lastPoint, 'optionalAccess',
|
|
8855
|
+
const lastPoint = _optionalChain([chartPoints, 'optionalAccess', _276 => _276[chartPoints.length - 1]]);
|
|
8856
|
+
return _optionalChain([lastPoint, 'optionalAccess', _277 => _277.value]);
|
|
8779
8857
|
}, [chartPoints]);
|
|
8780
8858
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8781
8859
|
PageContainer,
|
|
@@ -8876,7 +8954,7 @@ var SendPage = ({ token: _token }) => {
|
|
|
8876
8954
|
token,
|
|
8877
8955
|
accountAddress: account
|
|
8878
8956
|
});
|
|
8879
|
-
const encryptionProgressLabel = _react.useMemo.call(void 0, () => _optionalChain([lastStep, 'optionalAccess',
|
|
8957
|
+
const encryptionProgressLabel = _react.useMemo.call(void 0, () => _optionalChain([lastStep, 'optionalAccess', _278 => _278.step]) && getStepConfig(lastStep).label, [lastStep]);
|
|
8880
8958
|
const [amount, setAmount] = _react.useState.call(void 0, "");
|
|
8881
8959
|
const [recipientAddress, setRecipientAddress] = _react.useState.call(void 0, "");
|
|
8882
8960
|
const [error, setError] = _react.useState.call(void 0, null);
|
|
@@ -9037,7 +9115,7 @@ function useIsUnshieldingMining(token) {
|
|
|
9037
9115
|
const account = useCofheAccount();
|
|
9038
9116
|
const filter2 = _react.useCallback.call(void 0,
|
|
9039
9117
|
(tx) => {
|
|
9040
|
-
return tx.token.address === token.address && tx.actionType ===
|
|
9118
|
+
return "token" in tx && tx.token.address === token.address && tx.actionType === TransactionActionType.Unshield && tx.status === "pending" /* Pending */;
|
|
9041
9119
|
},
|
|
9042
9120
|
[token.address]
|
|
9043
9121
|
);
|
|
@@ -9158,7 +9236,7 @@ function useShieldWithLifecycle(token) {
|
|
|
9158
9236
|
const account = useCofheAccount();
|
|
9159
9237
|
const chainId = useCofheChainId();
|
|
9160
9238
|
const [shieldAmount, setShieldAmount] = _react.useState.call(void 0, "");
|
|
9161
|
-
const shieldSourceDecimals = _nullishCoalesce(_optionalChain([token, 'access',
|
|
9239
|
+
const shieldSourceDecimals = _nullishCoalesce(_optionalChain([token, 'access', _279 => _279.extensions, 'access', _280 => _280.fhenix, 'access', _281 => _281.erc20Pair, 'optionalAccess', _282 => _282.decimals]), () => ( token.decimals));
|
|
9162
9240
|
const { setError, setStatus, error, status } = useLifecycleStore();
|
|
9163
9241
|
const { schedule: scheduleStatusClear } = useReschedulableTimeout(() => setStatus(null), AUTOCLEAR_TX_STATUS_TIMEOUT);
|
|
9164
9242
|
const tokenShield = useCofheTokenShield({
|
|
@@ -9238,12 +9316,12 @@ function useShieldWithLifecycle(token) {
|
|
|
9238
9316
|
const handleShieldMax = () => {
|
|
9239
9317
|
if (publicBalanceUnit) setShieldAmount(publicBalanceUnit.toFixed());
|
|
9240
9318
|
};
|
|
9241
|
-
const isValidShieldAmount = _nullishCoalesce((shieldAmount.length > 0 && _optionalChain([publicBalanceUnit, 'optionalAccess',
|
|
9319
|
+
const isValidShieldAmount = _nullishCoalesce((shieldAmount.length > 0 && _optionalChain([publicBalanceUnit, 'optionalAccess', _283 => _283.gte, 'call', _284 => _284(shieldAmount)])), () => ( false));
|
|
9242
9320
|
const shieldAmountWei = _react.useMemo.call(void 0, () => {
|
|
9243
9321
|
if (!isValidShieldAmount) return void 0;
|
|
9244
9322
|
try {
|
|
9245
9323
|
return unitToWei(shieldAmount, shieldSourceDecimals);
|
|
9246
|
-
} catch (
|
|
9324
|
+
} catch (e7) {
|
|
9247
9325
|
return void 0;
|
|
9248
9326
|
}
|
|
9249
9327
|
}, [isValidShieldAmount, shieldAmount, shieldSourceDecimals]);
|
|
@@ -9251,12 +9329,12 @@ function useShieldWithLifecycle(token) {
|
|
|
9251
9329
|
if (!account || !shieldAmountWei) return void 0;
|
|
9252
9330
|
return getCofheTokenShieldCallArgs({ token, amount: shieldAmountWei, account });
|
|
9253
9331
|
}, [account, shieldAmountWei, token]);
|
|
9254
|
-
const shieldCallArgs = _optionalChain([shieldTxCallArgs, 'optionalAccess',
|
|
9255
|
-
const approvalCallArgs = _optionalChain([shieldTxCallArgs, 'optionalAccess',
|
|
9256
|
-
const approvalSpender = _nullishCoalesce(_optionalChain([approvalCallArgs, 'optionalAccess',
|
|
9332
|
+
const shieldCallArgs = _optionalChain([shieldTxCallArgs, 'optionalAccess', _285 => _285.main]);
|
|
9333
|
+
const approvalCallArgs = _optionalChain([shieldTxCallArgs, 'optionalAccess', _286 => _286.approval]);
|
|
9334
|
+
const approvalSpender = _nullishCoalesce(_optionalChain([approvalCallArgs, 'optionalAccess', _287 => _287.args, 'optionalAccess', _288 => _288[0]]), () => ( void 0));
|
|
9257
9335
|
const { data: allowanceWei, isFetching: isFetchingAllowance } = useTokenAllowance(
|
|
9258
9336
|
{
|
|
9259
|
-
tokenAddress: _optionalChain([approvalCallArgs, 'optionalAccess',
|
|
9337
|
+
tokenAddress: _optionalChain([approvalCallArgs, 'optionalAccess', _289 => _289.address]),
|
|
9260
9338
|
ownerAddress: account,
|
|
9261
9339
|
spenderAddress: approvalSpender
|
|
9262
9340
|
},
|
|
@@ -9293,9 +9371,9 @@ function useShieldWithLifecycle(token) {
|
|
|
9293
9371
|
setInputAmount: setShieldAmount,
|
|
9294
9372
|
onMaxClick: handleShieldMax,
|
|
9295
9373
|
canWriteContract: canWrite,
|
|
9296
|
-
sourceSymbol: _nullishCoalesce(_optionalChain([token, 'access',
|
|
9374
|
+
sourceSymbol: _nullishCoalesce(_optionalChain([token, 'access', _290 => _290.extensions, 'access', _291 => _291.fhenix, 'access', _292 => _292.erc20Pair, 'optionalAccess', _293 => _293.symbol]), () => ( token.symbol)),
|
|
9297
9375
|
destSymbol: token.symbol,
|
|
9298
|
-
sourceLogoURI: _nullishCoalesce(_optionalChain([token, 'access',
|
|
9376
|
+
sourceLogoURI: _nullishCoalesce(_optionalChain([token, 'access', _294 => _294.extensions, 'access', _295 => _295.fhenix, 'access', _296 => _296.erc20Pair, 'optionalAccess', _297 => _297.logoURI]), () => ( token.logoURI)),
|
|
9299
9377
|
destLogoURI: token.logoURI,
|
|
9300
9378
|
handlePrimaryAction: shouldApprove ? handleApprove : handleShield,
|
|
9301
9379
|
primaryLabel: shouldApprove ? "Approve" : "Shield",
|
|
@@ -9365,7 +9443,7 @@ function useUnshieldWithLifecycle(token) {
|
|
|
9365
9443
|
const handleUnshieldMax = () => {
|
|
9366
9444
|
if (confidentialBalanceUnit) setUnshieldAmount(confidentialBalanceUnit.toFixed());
|
|
9367
9445
|
};
|
|
9368
|
-
const isValidUnshieldAmount = _nullishCoalesce((unshieldAmount.length > 0 && _optionalChain([confidentialBalanceUnit, 'optionalAccess',
|
|
9446
|
+
const isValidUnshieldAmount = _nullishCoalesce((unshieldAmount.length > 0 && _optionalChain([confidentialBalanceUnit, 'optionalAccess', _298 => _298.gte, 'call', _299 => _299(unshieldAmount)])), () => ( false));
|
|
9369
9447
|
const unshieldCallArgs = _react.useMemo.call(void 0, () => {
|
|
9370
9448
|
if (!account || !isValidUnshieldAmount) return void 0;
|
|
9371
9449
|
const amountWei = _viem.parseUnits.call(void 0, unshieldAmount, token.decimals);
|
|
@@ -9388,9 +9466,9 @@ function useUnshieldWithLifecycle(token) {
|
|
|
9388
9466
|
onMaxClick: handleUnshieldMax,
|
|
9389
9467
|
canWriteContract: canUnshield,
|
|
9390
9468
|
sourceSymbol: token.symbol,
|
|
9391
|
-
destSymbol: _nullishCoalesce(_optionalChain([token, 'access',
|
|
9469
|
+
destSymbol: _nullishCoalesce(_optionalChain([token, 'access', _300 => _300.extensions, 'access', _301 => _301.fhenix, 'access', _302 => _302.erc20Pair, 'optionalAccess', _303 => _303.symbol]), () => ( token.symbol)),
|
|
9392
9470
|
sourceLogoURI: token.logoURI,
|
|
9393
|
-
destLogoURI: _nullishCoalesce(_optionalChain([token, 'access',
|
|
9471
|
+
destLogoURI: _nullishCoalesce(_optionalChain([token, 'access', _304 => _304.extensions, 'access', _305 => _305.fhenix, 'access', _306 => _306.erc20Pair, 'optionalAccess', _307 => _307.logoURI]), () => ( token.logoURI)),
|
|
9394
9472
|
handlePrimaryAction: handleUnshield,
|
|
9395
9473
|
primaryLabel: "Unshield",
|
|
9396
9474
|
primaryIcon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _tb.TbShieldMinus, { className: "w-3 h-3" })
|
|
@@ -9433,7 +9511,7 @@ function ClaimingSection({ token }) {
|
|
|
9433
9511
|
status: claimingStatus,
|
|
9434
9512
|
isClaimingMining
|
|
9435
9513
|
} = useClaimUnshieldedWithLifecycle();
|
|
9436
|
-
const pairedSymbol = _nullishCoalesce(_optionalChain([token, 'access',
|
|
9514
|
+
const pairedSymbol = _nullishCoalesce(_optionalChain([token, 'access', _308 => _308.extensions, 'access', _309 => _309.fhenix, 'access', _310 => _310.erc20Pair, 'optionalAccess', _311 => _311.symbol]), () => ( token.symbol));
|
|
9437
9515
|
const handleClaim = async () => {
|
|
9438
9516
|
(0, import_ts_essentials23.assert)(unshieldedClaims, "Unshield claims data is required to claim unshielded tokens");
|
|
9439
9517
|
claimUnshield.mutateAsync({
|
|
@@ -9443,9 +9521,9 @@ function ClaimingSection({ token }) {
|
|
|
9443
9521
|
};
|
|
9444
9522
|
const isUnshieldingMining = useIsUnshieldingMining(token);
|
|
9445
9523
|
const claimCallArgs = _react.useMemo.call(void 0, () => {
|
|
9446
|
-
if (isDualToken || !account || !_optionalChain([unshieldedClaims, 'optionalAccess',
|
|
9524
|
+
if (isDualToken || !account || !_optionalChain([unshieldedClaims, 'optionalAccess', _312 => _312.hasClaimable])) return void 0;
|
|
9447
9525
|
return void 0;
|
|
9448
|
-
}, [account, isDualToken, token, _optionalChain([unshieldedClaims, 'optionalAccess',
|
|
9526
|
+
}, [account, isDualToken, token, _optionalChain([unshieldedClaims, 'optionalAccess', _313 => _313.hasClaimable])]);
|
|
9449
9527
|
const claimSimulation = useCofheSimulateWriteContract(claimCallArgs, {
|
|
9450
9528
|
enabled: !!claimCallArgs
|
|
9451
9529
|
});
|
|
@@ -9455,16 +9533,16 @@ function ClaimingSection({ token }) {
|
|
|
9455
9533
|
);
|
|
9456
9534
|
const shouldSimulateClaim = !!claimCallArgs;
|
|
9457
9535
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
9458
|
-
_optionalChain([unshieldedClaims, 'optionalAccess',
|
|
9536
|
+
_optionalChain([unshieldedClaims, 'optionalAccess', _314 => _314.hasClaimable]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
9459
9537
|
ActionButton,
|
|
9460
9538
|
{
|
|
9461
9539
|
onClick: handleClaim,
|
|
9462
9540
|
disabled: claimUnshield.isPending || isClaimingMining || isFetchingClaims || isUnshieldingMining || shouldSimulateClaim && claimSimulation.isFetching || shouldSimulateClaim && !!claimSimulation.error,
|
|
9463
|
-
label: claimUnshield.isPending ? "Claiming..." : `Claim ${isFetchingClaims ? "..." : formatTokenAmount(_nullishCoalesce(_optionalChain([unshieldedClaims, 'optionalAccess',
|
|
9541
|
+
label: claimUnshield.isPending ? "Claiming..." : `Claim ${isFetchingClaims ? "..." : formatTokenAmount(_nullishCoalesce(_optionalChain([unshieldedClaims, 'optionalAccess', _315 => _315.claimableAmount]), () => ( 0n)), token.decimals, 5).formatted} ${pairedSymbol}`,
|
|
9464
9542
|
className: "mt-1"
|
|
9465
9543
|
}
|
|
9466
9544
|
),
|
|
9467
|
-
_optionalChain([unshieldedClaims, 'optionalAccess',
|
|
9545
|
+
_optionalChain([unshieldedClaims, 'optionalAccess', _316 => _316.hasPending]) && token && !unshieldedClaims.hasClaimable && !isDualToken && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-xxs text-yellow-600 dark:text-yellow-400 text-center", children: [
|
|
9468
9546
|
"Pending: ",
|
|
9469
9547
|
formatTokenAmount(unshieldedClaims.pendingAmount, token.decimals).formatted,
|
|
9470
9548
|
" ",
|
|
@@ -10149,7 +10227,7 @@ var FloatingButtonComponent = ({ onClick }) => {
|
|
|
10149
10227
|
const { theme } = useCofheFloatingButtonContext();
|
|
10150
10228
|
const { statuses } = usePortalStatuses();
|
|
10151
10229
|
const { portalOpen } = usePortalUI();
|
|
10152
|
-
const topStatusVariant = _optionalChain([statuses, 'access',
|
|
10230
|
+
const topStatusVariant = _optionalChain([statuses, 'access', _317 => _317[statuses.length - 1], 'optionalAccess', _318 => _318.variant]);
|
|
10153
10231
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10154
10232
|
"button",
|
|
10155
10233
|
{
|
|
@@ -10196,7 +10274,7 @@ var StatusBarSection = ({ children }) => {
|
|
|
10196
10274
|
|
|
10197
10275
|
|
|
10198
10276
|
var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
|
|
10199
|
-
const publicSymbol = _nullishCoalesce(_optionalChain([token, 'access',
|
|
10277
|
+
const publicSymbol = _nullishCoalesce(_optionalChain([token, 'access', _319 => _319.extensions, 'access', _320 => _320.fhenix, 'access', _321 => _321.erc20Pair, 'optionalAccess', _322 => _322.symbol]), () => ( token.symbol));
|
|
10200
10278
|
const destinationSymbol = token.symbol;
|
|
10201
10279
|
const showDestination = balanceType === "public" /* Public */ && !!publicSymbol && !!destinationSymbol && publicSymbol !== destinationSymbol;
|
|
10202
10280
|
const account = useCofheAccount();
|
|
@@ -10216,7 +10294,7 @@ var TokenRow = ({ token, onClick, topLabel, balanceType }) => {
|
|
|
10216
10294
|
tokenAddress: TMP_WBTC_ON_MAINNET.address
|
|
10217
10295
|
} : {
|
|
10218
10296
|
chainId: token.chainId,
|
|
10219
|
-
tokenAddress: _nullishCoalesce(_optionalChain([token, 'access',
|
|
10297
|
+
tokenAddress: _nullishCoalesce(_optionalChain([token, 'access', _323 => _323.extensions, 'access', _324 => _324.fhenix, 'access', _325 => _325.erc20Pair, 'optionalAccess', _326 => _326.address]), () => ( token.address))
|
|
10220
10298
|
}
|
|
10221
10299
|
);
|
|
10222
10300
|
const usdValue = balanceType === "confidential" /* Confidential */ ? confidentialBalance && price && formatUsdAmount(confidentialBalance.unit.multipliedBy(price)) : publicBalance && price && formatUsdAmount(publicBalance.unit.multipliedBy(price));
|
|
@@ -10322,7 +10400,7 @@ var TokenListModal = ({
|
|
|
10322
10400
|
};
|
|
10323
10401
|
var TokenListContent = ({ tokens, onSelectToken, balanceType }) => {
|
|
10324
10402
|
const pinnedTokenAddress = useCofhePinnedTokenAddress();
|
|
10325
|
-
const normalizedPinnedAddress = _optionalChain([pinnedTokenAddress, 'optionalAccess',
|
|
10403
|
+
const normalizedPinnedAddress = _optionalChain([pinnedTokenAddress, 'optionalAccess', _327 => _327.toLowerCase, 'call', _328 => _328()]);
|
|
10326
10404
|
const pinnedToken = normalizedPinnedAddress ? tokens.find((t) => t.address.toLowerCase() === normalizedPinnedAddress) : void 0;
|
|
10327
10405
|
const nonPinnedTokens = pinnedToken ? tokens.filter((t) => t.address.toLowerCase() !== normalizedPinnedAddress) : tokens;
|
|
10328
10406
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "cofhe-token-list-container", children: tokens.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs opacity-70 py-4 text-center", children: "No tokens found" }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -10459,9 +10537,9 @@ function ClaimableTokens() {
|
|
|
10459
10537
|
] }),
|
|
10460
10538
|
content: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-4 pr-1", children: [
|
|
10461
10539
|
rows.map(({ token, claimableAmount }) => {
|
|
10462
|
-
const isUnshielding = _nullishCoalesce(_optionalChain([unshieldingInProgressByTokenAddress, 'optionalAccess',
|
|
10540
|
+
const isUnshielding = _nullishCoalesce(_optionalChain([unshieldingInProgressByTokenAddress, 'optionalAccess', _329 => _329[token.address.toLowerCase()]]), () => ( false));
|
|
10463
10541
|
const formatted = formatTokenAmount(claimableAmount, token.decimals, 5).formatted;
|
|
10464
|
-
const isClaimingThis = _nullishCoalesce(_optionalChain([isClaimingByTokenAddress, 'optionalAccess',
|
|
10542
|
+
const isClaimingThis = _nullishCoalesce(_optionalChain([isClaimingByTokenAddress, 'optionalAccess', _330 => _330[token.address.toLowerCase()]]), () => ( false));
|
|
10465
10543
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-[1fr,auto,auto] items-center gap-4", children: [
|
|
10466
10544
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
10467
10545
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -10871,7 +10949,7 @@ var ImportCustomTokenCard = ({ tokens, onSelectToken, balanceType }) => {
|
|
|
10871
10949
|
chainId: token.chainId,
|
|
10872
10950
|
address: token.address
|
|
10873
10951
|
});
|
|
10874
|
-
if (_optionalChain([normalizedAddress, 'optionalAccess',
|
|
10952
|
+
if (_optionalChain([normalizedAddress, 'optionalAccess', _331 => _331.toLowerCase, 'call', _332 => _332()]) === token.address.toLowerCase()) {
|
|
10875
10953
|
setAddressInput("");
|
|
10876
10954
|
}
|
|
10877
10955
|
}
|
|
@@ -10937,7 +11015,7 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
|
|
|
10937
11015
|
if (!contentRef.current) return;
|
|
10938
11016
|
const observer = new ResizeObserver((entries) => {
|
|
10939
11017
|
for (const entry of entries) {
|
|
10940
|
-
const height = _nullishCoalesce(_optionalChain([entry, 'access',
|
|
11018
|
+
const height = _nullishCoalesce(_optionalChain([entry, 'access', _333 => _333.borderBoxSize, 'optionalAccess', _334 => _334[0], 'optionalAccess', _335 => _335.blockSize]), () => ( entry.target.getBoundingClientRect().height));
|
|
10941
11019
|
setContentHeight(id, height);
|
|
10942
11020
|
}
|
|
10943
11021
|
});
|
|
@@ -10954,7 +11032,7 @@ var MeasuredContentRenderer = ({ children, id, isModal, onModalOverlayClick }) =
|
|
|
10954
11032
|
onClick: (e) => {
|
|
10955
11033
|
e.preventDefault();
|
|
10956
11034
|
e.stopPropagation();
|
|
10957
|
-
_optionalChain([onModalOverlayClick, 'optionalCall',
|
|
11035
|
+
_optionalChain([onModalOverlayClick, 'optionalCall', _336 => _336()]);
|
|
10958
11036
|
},
|
|
10959
11037
|
className: "absolute flex w-full h-full bg-[#0E2F3F]/30 origin-top translate-y-[-8px] scale-[0.95]"
|
|
10960
11038
|
}
|
|
@@ -11207,5 +11285,10 @@ var CofheFloatingButtonWithProvider = (props) => {
|
|
|
11207
11285
|
|
|
11208
11286
|
|
|
11209
11287
|
|
|
11210
|
-
|
|
11211
|
-
|
|
11288
|
+
|
|
11289
|
+
|
|
11290
|
+
|
|
11291
|
+
|
|
11292
|
+
|
|
11293
|
+
exports.useInternalQueryClient = useInternalQueryClient; exports.asCofhePublicClient = asCofhePublicClient; exports.asCofheWalletClient = asCofheWalletClient; exports.useCofheClient = useCofheClient; exports.useCofheAutoConnect = useCofheAutoConnect; exports.createCofheConfig = createCofheConfig; exports.CofheProvider = CofheProvider; exports.useCofheContext = useCofheContext; exports.useCofheCreatePermit = useCofheCreatePermit; exports.ETH_ADDRESS_LOWERCASE = ETH_ADDRESS_LOWERCASE; exports.getBlockExplorerUrl = getBlockExplorerUrl; exports.getBlockExplorerTxUrl = getBlockExplorerTxUrl; exports.getBlockExplorerAddressUrl = getBlockExplorerAddressUrl; exports.getBlockExplorerTokenUrl = getBlockExplorerTokenUrl; exports.isEthPair = isEthPair; exports.isWrappedEthToken = isWrappedEthToken; exports.FheTypesList = FheTypesList; exports.truncateHash = truncateHash; exports.formatRelativeTime = formatRelativeTime; exports.useCofheConnection = useCofheConnection; exports.useCofhePublicClient = useCofhePublicClient; exports.useCofheWalletClient = useCofheWalletClient; exports.useCofheActivePermit = useCofheActivePermit; exports.useCofheAllPermits = useCofheAllPermits; exports.useCofheRemovePermit = useCofheRemovePermit; exports.useCofheSelectPermit = useCofheSelectPermit; exports.useCofheNavigateToCreatePermit = useCofheNavigateToCreatePermit; exports.useCofheEnabled = useCofheEnabled; exports.useCofheEncrypt = useCofheEncrypt; exports.useCofheSimulateWriteContract = useCofheSimulateWriteContract; exports.useCofheStatuses = useCofheStatuses; exports.TransactionStatus = TransactionStatus; exports.TransactionActionType = TransactionActionType; exports.actionToString = actionToString; exports.isCustomTransactionActionType = isCustomTransactionActionType; exports.statusToString = statusToString; exports.useTransactionStore = useTransactionStore; exports.useCofheWriteContract = useCofheWriteContract; exports.useCofheTokenApprove = useCofheTokenApprove; exports.useCofheTokenLists = useCofheTokenLists; exports.useCofheTokens = useCofheTokens; exports.useCofheTokenClaimable = useCofheTokenClaimable; exports.getCofheTokenClaimUnshieldedCallArgs = getCofheTokenClaimUnshieldedCallArgs; exports.useCofheTokenClaimUnshielded = useCofheTokenClaimUnshielded; exports.useCofheReadContractAndDecrypt = useCofheReadContractAndDecrypt; exports.useCofheTokenDecryptedBalance = useCofheTokenDecryptedBalance; exports.useCofheTokenPublicBalance = useCofheTokenPublicBalance; exports.useCofheTokensClaimable = useCofheTokensClaimable; exports.getCofheTokenShieldCallArgs = getCofheTokenShieldCallArgs; exports.useCofheTokenShield = useCofheTokenShield; exports.useCofheTokensWithExistingEncryptedBalances = useCofheTokensWithExistingEncryptedBalances; exports.useCofheEncryptAndWriteContract = useCofheEncryptAndWriteContract; exports.useCofheTokenTransfer = useCofheTokenTransfer; exports.addCofheTransaction = addCofheTransaction; exports.useCofheTransactions = useCofheTransactions; exports.getCofheTokenUnshieldCallArgs = getCofheTokenUnshieldCallArgs; exports.useCofheTokenUnshield = useCofheTokenUnshield; exports.useCoingeckoUsdPrice = useCoingeckoUsdPrice; exports.useTokensWithPublicBalances = useTokensWithPublicBalances; exports.useTransactionReceiptsByHash = useTransactionReceiptsByHash; exports.useCoingeckoContractMarketChartRange = useCoingeckoContractMarketChartRange; exports.useTokenAllowance = useTokenAllowance; exports.CofheEncryptInput = CofheEncryptInput; exports.CofheStatusActionIntents = CofheStatusActionIntents; exports.COFHE_STATUS_IDS = COFHE_STATUS_IDS; exports.CofheFloatingButtonProvider = CofheFloatingButtonProvider; exports.sortCofheStatuses = sortCofheStatuses; exports.MainPage = MainPage; exports.SettingsPage = SettingsPage; exports.CofheFloatingButtonWithProvider = CofheFloatingButtonWithProvider;
|
|
11294
|
+
//# sourceMappingURL=chunk-4FH4QHHA.cjs.map
|