Skip to content

Commit b94aca6

Browse files
authored
feat(entrykit): loosen min gas balance (#3689)
1 parent 582f718 commit b94aca6

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/entrykit": patch
3+
---
4+
5+
Loosened minimum gas balance requirement in onboarding to allow for any gas balance above zero.

‎.github/actions/setup-prerequisites/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ runs:
1616
- name: Setup foundry
1717
uses: foundry-rs/foundry-toolchain@v1
1818
with:
19-
version: nightly
19+
version: v1.1.0

‎packages/entrykit/src/onboarding/GasBalance.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Hex } from "viem";
1+
import { Hex, parseEther } from "viem";
22
import { PendingIcon } from "../icons/PendingIcon";
33
import { Button } from "../ui/Button";
44
import { Balance } from "../ui/Balance";
55
import { useBalance, useWatchBlockNumber } from "wagmi";
66
import { useEntryKitConfig } from "../EntryKitConfigProvider";
77
import relayChains from "../data/relayChains.json";
88
import { useSetBalance } from "./useSetBalance";
9-
import { RelayChains, minGasBalance } from "./common";
9+
import { RelayChains } from "./common";
1010
import { TruncatedHex } from "../ui/TruncatedHex";
1111
import { useShowMutationError } from "../errors/useShowMutationError";
1212
import { useShowQueryError } from "../errors/useShowQueryError";
@@ -46,7 +46,7 @@ export function GasBalance({ isActive, isExpanded, sessionAddress }: Props) {
4646
onClick={() =>
4747
setBalance.mutate({
4848
address: sessionAddress,
49-
value: minGasBalance + (balance.data?.value ?? 0n),
49+
value: parseEther("0.01") + (balance.data?.value ?? 0n),
5050
})
5151
}
5252
>
@@ -55,7 +55,7 @@ export function GasBalance({ isActive, isExpanded, sessionAddress }: Props) {
5555
) : relayChain != null ? (
5656
// TODO: convert this to a <ButtonLink>
5757
<a
58-
href={`${relayChain.bridgeUrl}?${new URLSearchParams({ toAddress: sessionAddress })}`}
58+
href={`${relayChain.bridgeUrl}?${new URLSearchParams({ toAddress: sessionAddress, amount: "0.01" })}`}
5959
target="_blank"
6060
rel="noopener noreferrer"
6161
>

‎packages/entrykit/src/onboarding/common.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { ReactNode } from "react";
2-
import { parseEther } from "viem";
32

43
export type Step = {
54
id: string;
65
isComplete: boolean;
76
content: (props: { isActive: boolean; isExpanded: boolean }) => ReactNode;
87
};
98

10-
// TODO: move to chain config?
11-
export const minGasBalance = parseEther("0.01");
12-
139
export type RelayChain = {
1410
bridgeUrl: string;
1511
};

‎packages/entrykit/src/onboarding/quarry/Allowance.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Hex } from "viem";
1+
import { Hex, parseEther } from "viem";
22
import { useAllowance } from "./useAllowance";
33
import { PendingIcon } from "../../icons/PendingIcon";
44
import { useClaimGasPass } from "./useClaimGasPass";
55
import { Button } from "../../ui/Button";
66
import { Balance } from "../../ui/Balance";
77
import { useEffect } from "react";
8-
import { minGasBalance } from "../common";
98
import { useShowQueryError } from "../../errors/useShowQueryError";
109
import { useShowMutationError } from "../../errors/useShowMutationError";
1110

@@ -30,7 +29,7 @@ export function Allowance({ isActive, isExpanded, userAddress }: Props) {
3029
claimGasPass.status === "idle" &&
3130
allowance.isSuccess &&
3231
allowance.data != null &&
33-
allowance.data < minGasBalance
32+
allowance.data < parseEther("0.01")
3433
) {
3534
claimGasPass.mutate(userAddress);
3635
}

‎packages/entrykit/src/onboarding/usePrerequisites.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { minGasBalance } from "./common";
21
import { getAllowanceQueryOptions } from "./quarry/useAllowance";
32
import { getSpenderQueryOptions } from "./quarry/useSpender";
43
import { getDelegationQueryOptions } from "./useDelegation";
@@ -48,9 +47,9 @@ export function getPrequisitesQueryOptions({
4847
queryClient.fetchQuery(getDelegationQueryOptions({ client, worldAddress, userAddress, sessionAddress })),
4948
]);
5049
// TODO: figure out better approach than null for allowance/spender when no quarry paymaster
51-
const hasAllowance = allowance == null || allowance >= minGasBalance;
50+
const hasAllowance = allowance == null || allowance >= 0n;
5251
const isSpender = spender == null ? true : spender;
53-
const hasGasBalance = sessionBalance == null || sessionBalance.value >= minGasBalance;
52+
const hasGasBalance = sessionBalance == null || sessionBalance.value >= 0n;
5453
return {
5554
sessionAddress,
5655
hasAllowance,

0 commit comments

Comments
 (0)