@latticexyz/entrykit 2.2.22-f6d87edb8513fd0f255ac4389a2e613a508ffab4 → 2.2.22-f7aa4c5722bf24103f4cd4ab01b5d9c55f9b2995
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.
|
@@ -548,13 +548,9 @@ function ConnectWallet() {
|
|
|
548
548
|
import { useEffect as useEffect8, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
549
549
|
import { twMerge as twMerge7 } from "tailwind-merge";
|
|
550
550
|
|
|
551
|
-
// src/onboarding/common.ts
|
|
552
|
-
import { parseEther as parseEther2 } from "viem";
|
|
553
|
-
var minGasBalance = parseEther2("0.01");
|
|
554
|
-
|
|
555
551
|
// src/onboarding/quarry/useAllowance.ts
|
|
556
552
|
import { useClient } from "wagmi";
|
|
557
|
-
import { queryOptions, useQuery as useQuery2 } from "@tanstack/react-query";
|
|
553
|
+
import { queryOptions, skipToken, useQuery as useQuery2 } from "@tanstack/react-query";
|
|
558
554
|
|
|
559
555
|
// src/quarry/getAllowance.ts
|
|
560
556
|
import { numberToHex as numberToHex2 } from "viem";
|
|
@@ -684,13 +680,10 @@ function getAllowanceQueryOptions({
|
|
|
684
680
|
client,
|
|
685
681
|
userAddress
|
|
686
682
|
}) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
client && userAddress ? {
|
|
690
|
-
|
|
691
|
-
queryFn: () => getAllowance({ client, userAddress })
|
|
692
|
-
} : { queryKey, enabled: false }
|
|
693
|
-
);
|
|
683
|
+
return queryOptions({
|
|
684
|
+
queryKey: ["getAllowance", client?.uid, userAddress],
|
|
685
|
+
queryFn: client && userAddress ? () => getAllowance({ client, userAddress }) : skipToken
|
|
686
|
+
});
|
|
694
687
|
}
|
|
695
688
|
function useAllowance(userAddress) {
|
|
696
689
|
const { chainId } = useEntryKitConfig();
|
|
@@ -700,7 +693,7 @@ function useAllowance(userAddress) {
|
|
|
700
693
|
|
|
701
694
|
// src/onboarding/quarry/useSpender.ts
|
|
702
695
|
import { useClient as useClient2 } from "wagmi";
|
|
703
|
-
import { queryOptions as queryOptions2, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
696
|
+
import { queryOptions as queryOptions2, skipToken as skipToken2, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
704
697
|
|
|
705
698
|
// src/onboarding/quarry/getSpender.ts
|
|
706
699
|
import { getRecord as getRecord2 } from "@latticexyz/store/internal";
|
|
@@ -722,18 +715,15 @@ function getSpenderQueryOptions({
|
|
|
722
715
|
userAddress,
|
|
723
716
|
sessionAddress
|
|
724
717
|
}) {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
client && userAddress && sessionAddress ? {
|
|
728
|
-
|
|
729
|
-
queryFn: () => getSpender({ client, userAddress, sessionAddress })
|
|
730
|
-
} : { queryKey, enabled: false }
|
|
731
|
-
);
|
|
718
|
+
return queryOptions2({
|
|
719
|
+
queryKey: ["getSpender", client?.uid, userAddress, sessionAddress],
|
|
720
|
+
queryFn: client && userAddress && sessionAddress ? () => getSpender({ client, userAddress, sessionAddress }) : skipToken2
|
|
721
|
+
});
|
|
732
722
|
}
|
|
733
723
|
|
|
734
724
|
// src/onboarding/useDelegation.ts
|
|
735
725
|
import { useClient as useClient3 } from "wagmi";
|
|
736
|
-
import { queryOptions as queryOptions3, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
726
|
+
import { queryOptions as queryOptions3, skipToken as skipToken3, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
737
727
|
|
|
738
728
|
// src/onboarding/getDelegation.ts
|
|
739
729
|
import { getRecord as getRecord3 } from "@latticexyz/store/internal";
|
|
@@ -776,22 +766,19 @@ function getDelegationQueryOptions({
|
|
|
776
766
|
userAddress,
|
|
777
767
|
sessionAddress
|
|
778
768
|
}) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
client && userAddress && sessionAddress ? {
|
|
782
|
-
|
|
783
|
-
queryFn: () => getDelegation({ client, worldAddress, userAddress, sessionAddress })
|
|
784
|
-
} : { queryKey, enabled: false }
|
|
785
|
-
);
|
|
769
|
+
return queryOptions3({
|
|
770
|
+
queryKey: ["getDelegation", client?.uid, worldAddress, userAddress, sessionAddress],
|
|
771
|
+
queryFn: client && userAddress && sessionAddress ? () => getDelegation({ client, worldAddress, userAddress, sessionAddress }) : skipToken3
|
|
772
|
+
});
|
|
786
773
|
}
|
|
787
774
|
|
|
788
775
|
// src/onboarding/usePrerequisites.ts
|
|
789
|
-
import { queryOptions as queryOptions5, useQuery as useQuery6, useQueryClient } from "@tanstack/react-query";
|
|
776
|
+
import { queryOptions as queryOptions5, skipToken as skipToken5, useQuery as useQuery6, useQueryClient } from "@tanstack/react-query";
|
|
790
777
|
import { useClient as useClient5, useConfig } from "wagmi";
|
|
791
778
|
|
|
792
779
|
// src/useSessionAccount.ts
|
|
793
780
|
import { useClient as useClient4 } from "wagmi";
|
|
794
|
-
import { queryOptions as queryOptions4, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
781
|
+
import { queryOptions as queryOptions4, skipToken as skipToken4, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
795
782
|
|
|
796
783
|
// src/getSessionAccount.ts
|
|
797
784
|
import { toSimpleSmartAccount } from "permissionless/accounts";
|
|
@@ -855,16 +842,13 @@ function getSessionAccountQueryOptions({
|
|
|
855
842
|
client,
|
|
856
843
|
userAddress
|
|
857
844
|
}) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
client && userAddress ? {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
retry: false
|
|
866
|
-
} : { queryKey, enabled: false }
|
|
867
|
-
);
|
|
845
|
+
return queryOptions4({
|
|
846
|
+
queryKey: ["getSessionAccount", client?.uid, userAddress],
|
|
847
|
+
queryFn: client && userAddress ? () => getSessionAccount({ client, userAddress }) : skipToken4,
|
|
848
|
+
staleTime: Infinity,
|
|
849
|
+
// TODO: replace with function to retry only connection errors
|
|
850
|
+
retry: false
|
|
851
|
+
});
|
|
868
852
|
}
|
|
869
853
|
|
|
870
854
|
// src/onboarding/usePrerequisites.ts
|
|
@@ -876,39 +860,36 @@ function getPrequisitesQueryOptions({
|
|
|
876
860
|
userAddress,
|
|
877
861
|
worldAddress
|
|
878
862
|
}) {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
client && userAddress ? {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
retry: false
|
|
910
|
-
} : { queryKey, enabled: false }
|
|
911
|
-
);
|
|
863
|
+
return queryOptions5({
|
|
864
|
+
queryKey: ["getPrerequisites", client?.uid, userAddress],
|
|
865
|
+
queryFn: client && userAddress ? async () => {
|
|
866
|
+
const paymaster = getPaymaster(client.chain);
|
|
867
|
+
const {
|
|
868
|
+
account: { address: sessionAddress }
|
|
869
|
+
} = await queryClient.fetchQuery(getSessionAccountQueryOptions({ client, userAddress }));
|
|
870
|
+
const [sessionBalance, allowance, spender, hasDelegation] = await Promise.all([
|
|
871
|
+
!paymaster ? queryClient.fetchQuery(
|
|
872
|
+
getBalanceQueryOptions(config, { chainId: client.chain.id, address: sessionAddress })
|
|
873
|
+
) : null,
|
|
874
|
+
paymaster?.type === "quarry" ? queryClient.fetchQuery(getAllowanceQueryOptions({ client, userAddress })) : null,
|
|
875
|
+
paymaster?.type === "quarry" ? queryClient.fetchQuery(getSpenderQueryOptions({ client, userAddress, sessionAddress })) : null,
|
|
876
|
+
queryClient.fetchQuery(getDelegationQueryOptions({ client, worldAddress, userAddress, sessionAddress }))
|
|
877
|
+
]);
|
|
878
|
+
const hasAllowance = allowance == null || allowance > 0n;
|
|
879
|
+
const isSpender = spender == null ? true : spender;
|
|
880
|
+
const hasGasBalance = sessionBalance == null || sessionBalance.value > 0n;
|
|
881
|
+
return {
|
|
882
|
+
sessionAddress,
|
|
883
|
+
hasAllowance,
|
|
884
|
+
isSpender,
|
|
885
|
+
hasGasBalance,
|
|
886
|
+
hasDelegation,
|
|
887
|
+
// we intentionally don't enforce an allowance/gas balance here
|
|
888
|
+
complete: isSpender && hasDelegation
|
|
889
|
+
};
|
|
890
|
+
} : skipToken5,
|
|
891
|
+
retry: false
|
|
892
|
+
});
|
|
912
893
|
}
|
|
913
894
|
function usePrerequisites(userAddress) {
|
|
914
895
|
const queryClient = useQueryClient();
|
|
@@ -1054,8 +1035,11 @@ function Wallet({ isActive, isExpanded, userAddress }) {
|
|
|
1054
1035
|
] });
|
|
1055
1036
|
}
|
|
1056
1037
|
|
|
1057
|
-
// src/onboarding/quarry/
|
|
1038
|
+
// src/onboarding/quarry/Allowance.tsx
|
|
1058
1039
|
import { parseEther as parseEther3 } from "viem";
|
|
1040
|
+
|
|
1041
|
+
// src/onboarding/quarry/useClaimGasPass.ts
|
|
1042
|
+
import { parseEther as parseEther2 } from "viem";
|
|
1059
1043
|
import { useMutation, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
1060
1044
|
|
|
1061
1045
|
// src/quarry/transports/quarryPassIssuer.ts
|
|
@@ -1097,7 +1081,7 @@ function useClaimGasPass() {
|
|
|
1097
1081
|
mutationFn: async (userAddress) => {
|
|
1098
1082
|
if (chain.id === 31337) {
|
|
1099
1083
|
if (!client) throw new Error("No client?");
|
|
1100
|
-
await setAllowanceSlot({ client, userAddress, allowance:
|
|
1084
|
+
await setAllowanceSlot({ client, userAddress, allowance: parseEther2("1") });
|
|
1101
1085
|
} else {
|
|
1102
1086
|
await claimGasPass({ chain, userAddress });
|
|
1103
1087
|
}
|
|
@@ -1172,7 +1156,7 @@ function Allowance({ isActive, isExpanded, userAddress }) {
|
|
|
1172
1156
|
const claimGasPass2 = useShowMutationError(useClaimGasPass());
|
|
1173
1157
|
useEffect6(() => {
|
|
1174
1158
|
const timer = setTimeout(() => {
|
|
1175
|
-
if (isActive && claimGasPass2.status === "idle" && allowance.isSuccess && allowance.data != null && allowance.data <
|
|
1159
|
+
if (isActive && claimGasPass2.status === "idle" && allowance.isSuccess && allowance.data != null && allowance.data < parseEther3("0.01")) {
|
|
1176
1160
|
claimGasPass2.mutate(userAddress);
|
|
1177
1161
|
}
|
|
1178
1162
|
});
|
|
@@ -1403,6 +1387,7 @@ import { useEffect as useEffect7 } from "react";
|
|
|
1403
1387
|
import { useClient as useClient8 } from "wagmi";
|
|
1404
1388
|
import {
|
|
1405
1389
|
queryOptions as queryOptions6,
|
|
1390
|
+
skipToken as skipToken6,
|
|
1406
1391
|
useQuery as useQuery8,
|
|
1407
1392
|
useQueryClient as useQueryClient4
|
|
1408
1393
|
} from "@tanstack/react-query";
|
|
@@ -1488,26 +1473,23 @@ function getSessionClientQueryOptions({
|
|
|
1488
1473
|
userAddress,
|
|
1489
1474
|
worldAddress
|
|
1490
1475
|
}) {
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
userAddress ? {
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
retry: false
|
|
1509
|
-
} : { queryKey, enabled: false }
|
|
1510
|
-
);
|
|
1476
|
+
return queryOptions6({
|
|
1477
|
+
queryKey: ["getSessionClient", client?.uid, userAddress, worldAddress],
|
|
1478
|
+
queryFn: userAddress ? async () => {
|
|
1479
|
+
const { account: sessionAccount, signer: sessionSigner } = await queryClient.fetchQuery(
|
|
1480
|
+
getSessionAccountQueryOptions({ client, userAddress })
|
|
1481
|
+
);
|
|
1482
|
+
return await getSessionClient({
|
|
1483
|
+
sessionAccount,
|
|
1484
|
+
sessionSigner,
|
|
1485
|
+
userAddress,
|
|
1486
|
+
worldAddress
|
|
1487
|
+
});
|
|
1488
|
+
} : skipToken6,
|
|
1489
|
+
staleTime: Infinity,
|
|
1490
|
+
// TODO: replace with function to retry only connection errors
|
|
1491
|
+
retry: false
|
|
1492
|
+
});
|
|
1511
1493
|
}
|
|
1512
1494
|
function useSessionClient(userAddress) {
|
|
1513
1495
|
const queryClient = useQueryClient4();
|
|
@@ -1568,6 +1550,7 @@ function Session({ isActive, isExpanded, userClient, registerSpender, registerDe
|
|
|
1568
1550
|
}
|
|
1569
1551
|
|
|
1570
1552
|
// src/onboarding/GasBalance.tsx
|
|
1553
|
+
import { parseEther as parseEther4 } from "viem";
|
|
1571
1554
|
import { useBalance, useWatchBlockNumber } from "wagmi";
|
|
1572
1555
|
|
|
1573
1556
|
// src/data/relayChains.json
|
|
@@ -1896,7 +1879,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
|
1896
1879
|
pending: balance.status === "pending" || setBalance3.status === "pending",
|
|
1897
1880
|
onClick: () => setBalance3.mutate({
|
|
1898
1881
|
address: sessionAddress,
|
|
1899
|
-
value:
|
|
1882
|
+
value: parseEther4("0.01") + (balance.data?.value ?? 0n)
|
|
1900
1883
|
}),
|
|
1901
1884
|
children: "Top up"
|
|
1902
1885
|
}
|
|
@@ -1905,7 +1888,7 @@ function GasBalance({ isActive, isExpanded, sessionAddress }) {
|
|
|
1905
1888
|
/* @__PURE__ */ jsx16(
|
|
1906
1889
|
"a",
|
|
1907
1890
|
{
|
|
1908
|
-
href: `${relayChain.bridgeUrl}?${new URLSearchParams({ toAddress: sessionAddress })}`,
|
|
1891
|
+
href: `${relayChain.bridgeUrl}?${new URLSearchParams({ toAddress: sessionAddress, amount: "0.01" })}`,
|
|
1909
1892
|
target: "_blank",
|
|
1910
1893
|
rel: "noopener noreferrer",
|
|
1911
1894
|
children: /* @__PURE__ */ jsx16(
|