Skip to content

Commit

Permalink
[ECO-2209] Make insufficient balance for market registration clearer (#…
Browse files Browse the repository at this point in the history
…263)

Co-authored-by: matt <[email protected]>
  • Loading branch information
xbtmatt and matt authored Oct 1, 2024
1 parent 76a7aa1 commit d81aa05
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useIsMarketRegistered = () => {
const length = sumBytes(emojis);
const invalidLength = length === 0 || length > 10;
// If not all of the emojis are in the symbol data map, then it can't have been registered.
if (!emojis.some((e) => SYMBOL_DATA.byEmoji(e))) {
if (!emojis.every(SYMBOL_DATA.byEmoji)) {
return {
invalid: true,
registered: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@ export const useRegisterMarket = () => {
const { data: gasResult } = useQuery({
queryKey: ["register-market-cost", numMarkets, account?.address, emojiBytes],
queryFn: async () => {
if (account === null) {
return undefined;
}
const publicKey = new Ed25519PublicKey(
typeof account!.publicKey === "string" ? account!.publicKey : account!.publicKey[0]
typeof account!.publicKey === "string" ? account.publicKey : account.publicKey[0]
);
const r = await RegisterMarket.getGasCost({
aptosConfig: aptos.config,
registrant: account!.address,
registrantPubKey: publicKey,
emojis: numMarkets === 0 ? [SYMBOL_DATA.byName("Virgo")!.bytes] : emojiBytes,
});
return r;
try {
const r = await RegisterMarket.getGasCost({
aptosConfig: aptos.config,
registrant: account.address,
registrantPubKey: publicKey,
emojis: numMarkets === 0 ? [SYMBOL_DATA.byName("Virgo")!.bytes] : emojiBytes,
});
return r;
} catch (e) {
console.error(e);
return undefined;
}
},
staleTime: 1000,
enabled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const LaunchButtonOrGoToMarketLink = ({
style={{ cursor: invalid ? "not-allowed" : "pointer" }}
scrambleProps={scrambleProps}
>
{t("Launch Emojicoin")}
{t(invalid ? "Invalid input" : "Launch Emojicoin")}
</Button>
)}
</ButtonWithConnectWalletFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ export const MemoizedLaunchAnimation = ({
</div>
</div>
<div className="flex flex-row justify-between">
<span className="mr-[2ch]">{t("Your balance")}</span>
<div className="flex flex-row">
<span>{t("Your balance")}</span>
<div className={"flex flex-row absolute mt-[2px]"}>
<span className="opacity-0 select-none">{t("Your balance")}</span>
<div className="ml-[3px] text-[12px]">{sufficientBalance ? "✅" : "❌"}</div>
</div>
</div>
<div>
<span
className={
Expand Down Expand Up @@ -175,7 +181,7 @@ export const MemoizedLaunchAnimation = ({
>
<LaunchButtonOrGoToMarketLink
geoblocked={geoblocked}
invalid={invalid || !sufficientBalance}
invalid={invalid}
registered={registered}
onWalletButtonClick={() => {
registerMarket();
Expand Down

0 comments on commit d81aa05

Please sign in to comment.