Skip to content

Commit

Permalink
chore: fix the phantom token details page that appears for unsubmitte…
Browse files Browse the repository at this point in the history
…d txs (#357)

* fix: server not passes executeData

* chore: update drizzle-studio package version

* chore: move schema md to docs folder

* chore: prevent showing token details when the tx not submitted
  • Loading branch information
npty authored May 24, 2024
1 parent bf08058 commit 6ee29ad
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 154 deletions.
2 changes: 1 addition & 1 deletion apps/maestro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.4.1",
"drizzle-kit": "^0.20.14",
"drizzle-kit": "^0.20.17",
"drizzle-zod": "^0.5.1",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.4",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion apps/maestro/src/services/axelarjsSDK/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ async function estimateGasFee(params: EstimateGasFeeInput): Promise<bigint> {
params.gasLimit,
params.gasMultiplier,
params.sourceChainTokenSymbol,
params.minGasPrice
params.minGasPrice,
params.executeData as `0x${string}` | undefined
);

const rawFee =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type ConnectedInterchainTokensPageProps = {
tokenSymbol: string;
decimals: number;
tokenId?: `0x${string}` | null;
deploymentMessageId: string | undefined;
};

type InterchainTokenDetailsPageSessionStorageProps = {
Expand Down Expand Up @@ -407,7 +408,7 @@ const ConnectedInterchainTokensPage: FC<ConnectedInterchainTokensPageProps> = (
{interchainTokenError && tokenDetailsError && (
<Alert $status="error">{tokenDetailsError.message}</Alert>
)}
{interchainTokenError && tokenDetails && (
{(interchainTokenError || !props.deploymentMessageId) && tokenDetails && (
<div className="mx-auto w-full max-w-md">
{address ? (
<CanonicalTokenDeployment
Expand All @@ -425,38 +426,41 @@ const ConnectedInterchainTokensPage: FC<ConnectedInterchainTokensPageProps> = (
)}
</div>
)}
<Alert $status={"success"} className="mb-5">
Anyone can send tokens to/from any of your deployed chains using the
link of this portal. Share with your community!
</Alert>
<InterchainTokenList title="Registered Chains" tokens={registered} />
{pendingUnregisteredTokens.length > 0 && (
<InterchainTokenList
title="Pending Chains"
listClassName="grid-cols-2 sm:grid-cols-3"
tokens={pendingUnregisteredTokens}
/>
)}
{idleUnregisteredTokens.length > 0 && (
<InterchainTokenList
title="Unregistered Chains"
listClassName="grid-cols-2 sm:grid-cols-3"
tokens={idleUnregisteredTokens}
onToggleSelection={
isReadOnly
? undefined
: (chainId) => {
setSessionState((draft) => {
draft.selectedChainIds = draft.selectedChainIds.includes(
chainId
)
? without([chainId], draft.selectedChainIds)
: draft.selectedChainIds.concat(chainId);
});
}
}
footer={footerContent}
/>
{props.deploymentMessageId && (
<>
<Alert $status={"success"} className="mb-5">
Anyone can send tokens to/from any of your deployed chains using the
link of this portal. Share with your community!
</Alert>
<InterchainTokenList title="Registered Chains" tokens={registered} />
{pendingUnregisteredTokens.length > 0 && (
<InterchainTokenList
title="Pending Chains"
listClassName="grid-cols-2 sm:grid-cols-3"
tokens={pendingUnregisteredTokens}
/>
)}
{idleUnregisteredTokens.length > 0 && (
<InterchainTokenList
title="Unregistered Chains"
listClassName="grid-cols-2 sm:grid-cols-3"
tokens={idleUnregisteredTokens}
onToggleSelection={
isReadOnly
? undefined
: (chainId) => {
setSessionState((draft) => {
draft.selectedChainIds =
draft.selectedChainIds.includes(chainId)
? without([chainId], draft.selectedChainIds)
: draft.selectedChainIds.concat(chainId);
});
}
}
footer={footerContent}
/>
)}
</>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type TokenDetailsSectionProps = {
wasDeployedByAccount?: boolean;
decimals: number;
tokenId?: `0x${string}` | null | undefined;
deploymentMessageId?: string | undefined;
tokenManagerAddress?: `0x${string}` | null;
kind?: "canonical" | "interchain" | "custom";
claimOwnershipFormLink?: string;
Expand All @@ -59,96 +60,112 @@ const TokenDetailsSection: FC<TokenDetailsSectionProps> = (props) => {
{maskAddress(props.tokenAddress)}
</CopyToClipboardButton>,
],
...Maybe.of(props.tokenManagerAddress).mapOr([], (tokenManagerAddress) => [
[
"Token Manager",
<CopyToClipboardButton
key="token-manager"
$size="sm"
$variant="ghost"
copyText={tokenManagerAddress}
>
{maskAddress(tokenManagerAddress)}
</CopyToClipboardButton>,
],
]),
...Maybe.of(props.tokenId).mapOr([], (tokenId) => [
[
"Token ID",
<div key="token-id" className="flex items-center">
<CopyToClipboardButton $size="sm" $variant="ghost" copyText={tokenId}>
{maskAddress(tokenId)}
</CopyToClipboardButton>
<Tooltip
tip="TokenId is a common key used to identify an interchain token across all chains"
$variant="info"
$position="bottom"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>,
],
[
"Token Ownership Claim Request",
props.wasDeployedByAccount && props.claimOwnershipFormLink && (
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href={props.claimOwnershipFormLink}
>
Link
</LinkButton>
),
],
[
"Add Your Token on Squid",
props.wasDeployedByAccount && (
<div className="flex items-center">
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href="https://github.com/axelarnetwork/axelar-configs "
>
Link
</LinkButton>
<Tooltip
$as={Indicator}
$variant={"info"}
$position="right"
tip="Squid is a platform that allows any token to be swapped between blockchains, and unlocks access to apps across chains in a single click. Create a PR there to request your token to be listed on Squid"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>
),
],
]),
...Maybe.of(props.tokenManagerAddress).mapOr([], () => [
[
"Apply for coordinated marketing with Axelar",
props.wasDeployedByAccount && (
<div className="flex items-center">
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href="https://haz8ao8c4f2.typeform.com/to/pqm6CTC3"
>
Link
</LinkButton>
<Tooltip
tip="If you want to jointly market your newly created token with us, reach out to us via this form, and we will reach out"
$variant="info"
$position="bottom"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>
),
],
]),
...Maybe.of(props.tokenManagerAddress).mapOr([], (tokenManagerAddress) =>
!props.deploymentMessageId
? [[]]
: [
[
"Token Manager",
<CopyToClipboardButton
key="token-manager"
$size="sm"
$variant="ghost"
copyText={tokenManagerAddress}
>
{maskAddress(tokenManagerAddress)}
</CopyToClipboardButton>,
],
]
),
...Maybe.of(props.tokenId).mapOr([], (tokenId) =>
!props.deploymentMessageId
? [[]]
: [
[
"Token ID",
<div key="token-id" className="flex items-center">
<CopyToClipboardButton
$size="sm"
$variant="ghost"
copyText={tokenId}
>
{maskAddress(tokenId)}
</CopyToClipboardButton>
<Tooltip
tip="TokenId is a common key used to identify an interchain token across all chains"
$variant="info"
$position="bottom"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>,
],
[
"Token Ownership Claim Request",
props.wasDeployedByAccount && props.claimOwnershipFormLink && (
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href={props.claimOwnershipFormLink}
>
Link
</LinkButton>
),
],
[
"Add Your Token on Squid",
props.wasDeployedByAccount && (
<div className="flex items-center">
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href="https://github.com/axelarnetwork/axelar-configs "
>
Link
</LinkButton>
<Tooltip
$as={Indicator}
$variant={"info"}
$position="right"
tip="Squid is a platform that allows any token to be swapped between blockchains, and unlocks access to apps across chains in a single click. Create a PR there to request your token to be listed on Squid"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>
),
],
]
),
...Maybe.of(props.tokenManagerAddress).mapOr([], () =>
!props.deploymentMessageId
? [[]]
: [
[
"Apply for coordinated marketing with Axelar",
props.wasDeployedByAccount && (
<div className="flex items-center">
<LinkButton
target="_blank"
className="ml-[-10px]"
$variant="link"
href="https://haz8ao8c4f2.typeform.com/to/pqm6CTC3"
>
Link
</LinkButton>
<Tooltip
tip="If you want to jointly market your newly created token with us, reach out to us via this form, and we will reach out"
$variant="info"
$position="bottom"
>
<InfoIcon className="text-info h-[1em] w-[1em]" />
</Tooltip>
</div>
),
],
]
),
];

const sanitizedTokenDetails = tokenDetails.filter(([, value]) =>
Expand All @@ -159,7 +176,7 @@ const TokenDetailsSection: FC<TokenDetailsSectionProps> = (props) => {
<section className="grid gap-6">
<div className="flex items-center justify-between">
<div className="flex flex-wrap items-center gap-2 text-2xl font-bold md:gap-3">
{props.tokenId && (
{props.tokenId && props.deploymentMessageId && (
<ManageTokenIcon
tokenId={props.tokenId}
wasDeployedByAccount={props.wasDeployedByAccount}
Expand Down Expand Up @@ -189,7 +206,7 @@ const TokenDetailsSection: FC<TokenDetailsSectionProps> = (props) => {
</LinkButton>
</div>

{props.kind === "canonical" && (
{props.deploymentMessageId && props.kind === "canonical" && (
<div className="italic">
This is a pre-existing token on {props.chain.name} that was registered
on ITS, powered by Axelar
Expand Down Expand Up @@ -419,8 +436,9 @@ const UpdateTokenIcon: FC<UpdateTokenIconProps> = ({
/>
<span className="mt-4 flex">
<p>
The uploaded image will only be displayed on this
Interchain Token Service Portal, but will not carry through to any external services
The uploaded image will only be displayed on this Interchain
Token Service Portal, but will not carry through to any external
services
</p>
</span>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useChainFromRoute } from "~/lib/hooks";
import { getPrefilledClaimOwnershipFormLink } from "~/lib/utils/gform";
import { useERC20TokenDetailsQuery } from "~/services/erc20/hooks";
import { useInterchainTokensQuery } from "~/services/gmp/hooks";
import { useInterchainTokenDetailsQuery } from "~/services/interchainToken/hooks";
import Page from "~/ui/layouts/Page";
import ConnectedInterchainTokensPage from "./ConnectedInterchainTokensPage";
import TokenDetailsSection from "./TokenDetailsSection";
Expand All @@ -29,6 +30,11 @@ const InterchainTokensPage: FC = () => {
tokenAddress,
});

const { data: interchainTokenDetails } = useInterchainTokenDetailsQuery({
chainId: routeChain?.id,
tokenAddress,
});

const { data: tokenDetails } = useERC20TokenDetailsQuery({
chainId: routeChain?.id,
tokenAddress,
Expand Down Expand Up @@ -61,6 +67,7 @@ const InterchainTokensPage: FC = () => {
decimals={tokenDetails.decimals}
name={tokenDetails.name}
symbol={tokenDetails.symbol}
deploymentMessageId={interchainTokenDetails?.deploymentMessageId}
wasDeployedByAccount={interchainToken.wasDeployedByAccount}
tokenId={interchainToken?.tokenId}
tokenManagerAddress={interchainToken?.tokenManagerAddress}
Expand All @@ -83,6 +90,7 @@ const InterchainTokensPage: FC = () => {
<>
<ConnectedInterchainTokensPage
chainId={routeChain?.id}
deploymentMessageId={interchainTokenDetails?.deploymentMessageId}
tokenAddress={tokenAddress}
tokenName={tokenDetails.name}
tokenSymbol={tokenDetails.symbol}
Expand Down
Loading

0 comments on commit 6ee29ad

Please sign in to comment.