Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Jan 13, 2025
1 parent ad05b00 commit c3483b6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ExternalLinkIcon,
LinkButton,
} from "@axelarjs/ui";
import { maskAddress, Maybe } from "@axelarjs/utils";
import { maskAddress } from "@axelarjs/utils";
import { useCallback, useEffect, useState, useMemo, type FC } from "react";
import { useRouter } from "next/router";
import { useAccount } from "wagmi";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EVMChainConfig } from "@axelarjs/api";
import { EVMChainConfig, VMChainConfig } from "@axelarjs/api";
import { Alert, Button } from "@axelarjs/ui";
import { toast } from "@axelarjs/ui/toaster";
import { useCallback, useEffect, useMemo, type FC } from "react";
Expand All @@ -14,15 +14,18 @@ import {
import { logger } from "~/lib/logger";
import { handleTransactionResult } from "~/lib/transactions/handlers";
import { trpc } from "~/lib/trpc";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import {
useEVMChainConfigsQuery,
useVMChainConfigsQuery,
} from "~/services/axelarscan/hooks";
import useRegisterRemoteCanonicalTokens from "./hooks/useRegisterRemoteCanonicalTokens";
import useRegisterRemoteInterchainTokens from "./hooks/useRegisterRemoteInterchainTokens";

export type RegisterRemoteTokensProps = {
tokenAddress: `0x${string}`;
chainIds: number[];
originChainId?: number;
originChain?: EVMChainConfig;
originChain?: EVMChainConfig | VMChainConfig;
userGasBalance: GetBalanceReturnType | undefined;
gasFees: bigint[] | undefined;
onTxStateChange?: (status: TransactionState) => void;
Expand All @@ -36,15 +39,31 @@ export const RegisterRemoteTokens: FC<RegisterRemoteTokensProps> = (props) => {
const { mutateAsync: recordRemoteTokenDeployment } =
trpc.interchainToken.recordRemoteTokensDeployment.useMutation();

const { computed } = useEVMChainConfigsQuery();
const { computed: evmComputed } = useEVMChainConfigsQuery();
const { computed: vmComputed } = useVMChainConfigsQuery();

const combinedComputed = useMemo(
() => ({
indexedById: {
...evmComputed.indexedById,
...vmComputed.indexedById,
},
indexedByChainId: {
...evmComputed.indexedByChainId,
...vmComputed.indexedByChainId,
},
wagmiChains: evmComputed.wagmiChains,
}),
[evmComputed, vmComputed]
);

const baseRemoteTokens = props.chainIds.map((chainId) => ({
chainId,
address: props.tokenAddress,
tokenAddress: props.tokenAddress,
deploymentStatus: "pending",
deploymentTxHash: "0x",
axelarChainId: computed.indexedByChainId[chainId].id,
axelarChainId: combinedComputed.indexedByChainId[chainId].id,
}));

const onReceipt = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { isAddress } from "viem";
import { useAccount } from "wagmi";

import useQueryStringState from "~/lib/hooks/useQueryStringStyate";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useEVMChainConfigsQuery, useVMChainConfigsQuery} from "~/services/axelarscan/hooks";
import { useERC20TokenDetailsQuery } from "~/services/erc20";
import { useInterchainTokensQuery } from "~/services/gmp/hooks";
import ChainsDropdown, {
ChainIcon,
ChainIconComponent,
} from "~/ui/components/ChainsDropdown";

export type TokenFoundResult = {
Expand All @@ -35,15 +35,25 @@ const SearchInterchainToken: FC<SearchInterchainTokenProps> = (props) => {

const { chain: connectedChain } = useAccount();

const { computed } = useEVMChainConfigsQuery();
const { computed: evmComputed } = useEVMChainConfigsQuery();
const { computed: vmComputed } = useVMChainConfigsQuery();

// Combine computed data
const combinedComputed = useMemo(() => ({
indexedByChainId: {
...evmComputed.indexedByChainId,
...vmComputed.indexedByChainId,
}
}), [evmComputed, vmComputed]);

const [selectedChainId, setSelectedChainId] = useSessionStorageState(
"@maestro/SearchInterchainToken.selectedChainId",
connectedChain?.id ?? -1
);

const defaultChain = useMemo(
() => computed.indexedByChainId[selectedChainId],
[computed.indexedByChainId, selectedChainId]
() => combinedComputed.indexedByChainId[selectedChainId],
[combinedComputed.indexedByChainId, selectedChainId]
);

const isValidAddress = isAddress(search as `0x${string}`);
Expand Down Expand Up @@ -157,7 +167,7 @@ const SearchInterchainToken: FC<SearchInterchainTokenProps> = (props) => {
operate in controlled mode
*/}
<div className="flex items-center">
<ChainIcon
<ChainIconComponent
size="md"
hideLabel
selectedChain={defaultChain}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const recordInterchainTokenDeploymentInput = newInterchainTokenSchema
tokenManagerAddress: true,
});

export type RecordInterchainTokenDeploymentInput = z.infer<
typeof recordInterchainTokenDeploymentInput
>;

export const recordInterchainTokenDeployment = protectedProcedure
.input(recordInterchainTokenDeploymentInput)
.mutation(async ({ ctx, input }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EVMChainConfig } from "@axelarjs/api";
import type { EVMChainConfig, VMChainConfig } from "@axelarjs/api";
import {
Alert,
Badge,
Expand Down Expand Up @@ -35,7 +35,7 @@ import { ChainIcon } from "~/ui/components/ChainsDropdown";
export type TokenDetailsSectionProps = {
name: string;
symbol: string;
chain: EVMChainConfig;
chain: EVMChainConfig | VMChainConfig;
tokenAddress: `0x${string}`;
wasDeployedByAccount?: boolean;
decimals: number;
Expand Down

0 comments on commit c3483b6

Please sign in to comment.