Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support flow chain config for its #487

Merged
merged 40 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cc44c6d
feat: support chain type vm for flow
npty Jan 8, 2025
ab04633
feat: add VMChainConfigs
npty Jan 8, 2025
9c49e67
feat: refactor EVMChainsDropdown to support all chains
npty Jan 8, 2025
01fd7de
feat: support vm chains in deploy and register state
npty Jan 9, 2025
fcdf3bb
feat: support vm chains in multiplle components
npty Jan 9, 2025
a41ab6c
chore: bump axelarjs-sdk to latest to fix gas estimation for flow
npty Jan 9, 2025
3c658fd
feat: support vm chains in recordInterchainTokenDeployment
npty Jan 9, 2025
acddf36
feat: support vm chains for chain picker and tx status monitor
npty Jan 9, 2025
5614260
chore: fix rpc urls for sepolia testnet
npty Jan 10, 2025
738e3d5
chore: remove console.log
npty Jan 10, 2025
57865bb
chore: bump axelarjs-sdk
npty Jan 10, 2025
9cbbfdd
chore: update lock file
npty Jan 10, 2025
02b66d2
chore: add callback type to search gmp api
npty Jan 10, 2025
7a3d0a3
chore: remove log
npty Jan 10, 2025
6f9811f
feat: support vm chains for record interchain token deployment
npty Jan 10, 2025
0d35f0f
chore: fix the its-hub destination chain
npty Jan 10, 2025
e44ac57
fix: Review component
npty Jan 10, 2025
2292766
fix: CanonicalTokenDeployment
npty Jan 10, 2025
9a6fab4
fix: getInterchainTokenDetails
npty Jan 10, 2025
b36c9c7
chore: fix getInterchainTokenRolesForAcction
npty Jan 10, 2025
05f9ea0
chore: fix gmp hooks
npty Jan 10, 2025
a9d1759
chore: fix GMPTxStatusMonitor edge case
npty Jan 10, 2025
eb44a45
fix: support vm chain for SendInterchainToken
npty Jan 10, 2025
af75380
fix: recordRemoteTokensDeployment
npty Jan 10, 2025
e9b1b6b
fix: wagmiConfig in hooks
npty Jan 10, 2025
ad8414a
chore: support vm chain configs in Transactions
npty Jan 10, 2025
973c25d
chore: fix GMPTxStatusMonitor when chain not found
npty Jan 10, 2025
f8d1aa6
chore: fix vm chain overrides evm chain
npty Jan 10, 2025
70a1986
chore: fix vm computes overrides
npty Jan 10, 2025
ad05b00
chore: fix chain not found error in tx monitor
npty Jan 10, 2025
c3483b6
chore: fix lint
npty Jan 13, 2025
68b2eda
chore: support vm chain in connected interchain token page
npty Jan 13, 2025
ebeb77b
chore: fix remaining evm chain config query
npty Jan 13, 2025
10695d7
chore: fix import
npty Jan 13, 2025
fc1a86c
refactor: useAllChainConfigsQuery
npty Jan 14, 2025
61513d7
refactor: add chains array to useAllChainConfigsQuery
npty Jan 14, 2025
29241b4
chore: revert its contract addresses
npty Jan 14, 2025
2ce05b0
chore: remove web-streams-polyfill
npty Jan 14, 2025
155ab44
chore: fix eligible chains and chain name
npty Jan 14, 2025
d95cba0
chore: remove logs and commented code
npty Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/maestro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"release": "tsx scripts/release.ts"
},
"dependencies": {
"@axelar-network/axelarjs-sdk": "0.15.0",
"@axelar-network/axelarjs-sdk": "0.17.1-alpha.12",
"@axelarjs/api": "workspace:*",
"@axelarjs/core": "workspace:*",
"@axelarjs/evm": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions apps/maestro/src/config/evm-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export const ALL_CHAINS: ExtendedWagmiChainConfig[] = [
},
{
...sepolia,
rpcUrls: {
default: { http: ["https://endpoints.omniatech.io/v1/eth/sepolia/public", "https://1rpc.io/sepolia"] }, // Temporarily using this url
public: { http: ["https://endpoints.omniatech.io/v1/eth/sepolia/public", "https://1rpc.io/sepolia"] },
},
axelarChainId: "ethereum-sepolia",
axelarChainName: "ethereum-sepolia",
environment: ENVIRONMENTS.testnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { trpc } from "~/lib/trpc";
import { isValidEVMAddress } from "~/lib/utils/validation";
import { RecordInterchainTokenDeploymentInput } from "~/server/routers/interchainToken/recordInterchainTokenDeployment";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useAllChainConfigsQuery } from "~/services/axelarscan/hooks";
import type { DeployAndRegisterTransactionState } from "../CanonicalTokenDeployment.state";

export interface UseDeployAndRegisterCanonicalTokenInput {
Expand All @@ -43,7 +43,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
const { address: deployerAddress } = useAccount();
const chainId = useChainId();

const { computed } = useEVMChainConfigsQuery();
const { combinedComputed } = useAllChainConfigsQuery();

const { mutateAsync: recordDeploymentAsync } =
trpc.interchainToken.recordInterchainTokenDeployment.useMutation();
Expand All @@ -64,7 +64,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
});

const { originalChainName, destinationChainNames } = useMemo(() => {
const index = computed.indexedById;
const index = combinedComputed.indexedById;
const originalChainName =
index[input?.sourceChainId ?? chainId]?.chain_name ?? "Unknown";

Expand All @@ -80,7 +80,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
};
}, [
chainId,
computed.indexedById,
combinedComputed.indexedById,
input?.destinationChainIds,
input?.sourceChainId,
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EVMChainConfig } from "@axelarjs/api/axelarscan";
import type { EVMChainConfig, VMChainConfig } from "@axelarjs/api/axelarscan";
import { useEffect, useState } from "react";

import { formatEther } from "viem";
Expand All @@ -9,21 +9,24 @@ import {
NEXT_PUBLIC_INTERCHAIN_DEPLOYMENT_GAS_LIMIT,
} from "~/config/env";
import { useEstimateGasFeeMultipleChainsQuery } from "~/services/axelarjsSDK/hooks";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useAllChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useCanonicalTokenDeploymentStateContainer } from "../../CanonicalTokenDeployment.state";

export type UseStep3ChainSelectionStateProps = {
selectedChains: Set<string>;
};

export function useStep3ChainSelectionState() {
const { data: evmChains } = useEVMChainConfigsQuery();
const { allChains } = useAllChainConfigsQuery();
const chainId = useChainId();
const [isDeploying, setIsDeploying] = useState(false);
const [totalGasFee, $setTotalGasFee] = useState(formatEther(0n));
const [sourceChainId, setSourceChainId] = useState(
evmChains?.find((evmChain: EVMChainConfig) => evmChain.chain_id === chainId)
?.id as string

// Find source chain from both EVM and VM chains
const currentChain = allChains?.find((chain: EVMChainConfig | VMChainConfig) => chain.chain_id === chainId);

const [sourceChainId, setSourceChainId] = useState<string>(
currentChain?.id || ""
);

const { state: rootState } = useCanonicalTokenDeploymentStateContainer();
Expand Down Expand Up @@ -58,20 +61,17 @@ export function useStep3ChainSelectionState() {
};

useEffect(() => {
const candidateChain = evmChains?.find(
(evmChain) => evmChain.chain_id === chainId
);
if (!candidateChain || candidateChain.chain_name === sourceChainId) return;
if (!currentChain || currentChain.chain_name === sourceChainId) return;

setSourceChainId(candidateChain.chain_name);
}, [evmChains, chainId, sourceChainId]);
setSourceChainId(currentChain.chain_name);
}, [currentChain, chainId, sourceChainId]);

return {
state: {
isDeploying,
totalGasFee,
sourceChainId,
evmChains,
allChains,
isEstimatingGasFees: isRemoteDeploymentGasFeeLoading,
hasGasFeesEstimationError: isRemoteDeploymentGasFeeError,
remoteDeploymentGasFees,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export const Step3: FC = () => {

const chainId = useChainId();

const sourceChain = state.evmChains.find((x) => x.chain_id === chainId);
// Support both EVM and VM chains
const sourceChain = state.allChains?.find((chain) => chain.chain_id === chainId);

const [validDestinationChainIds, erroredDestinationChainIds] = useMemo(
const [validDestinationChainIds, erroredDestinationChainIds] = useMemo(
() =>
(state.remoteDeploymentGasFees?.gasFees ?? []).reduce(
([succeeded, errored], x): [string[], string[]] =>
Expand Down Expand Up @@ -135,19 +136,19 @@ export const Step3: FC = () => {
addTransaction,
]
);

const eligibleChains = useMemo(
() => state.evmChains?.filter((chain) => chain.chain_id !== chainId),
[state.evmChains, chainId]
);

const eligibleChains = state.allChains.filter(chain => chain.chain_id !== chainId);
const formSubmitRef = useRef<ComponentRef<"button">>(null);

const { address } = useAccount();

const { data: balance } = useBalance({ address });

const nativeTokenSymbol = getNativeToken(state.sourceChainId);
const nativeTokenSymbol = useMemo(() => {
if (sourceChain?.chain_type === 'vm') {
return sourceChain.native_token.symbol;
}
return getNativeToken(state.sourceChainId);
}, [sourceChain, state.sourceChainId]);

const hasInsufficientGasBalance = useMemo(() => {
if (!balance || !state.remoteDeploymentGasFees) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import {
ExternalLinkIcon,
LinkButton,
} from "@axelarjs/ui";
import { maskAddress, Maybe } from "@axelarjs/utils";
import { useCallback, useEffect, useState, type FC } from "react";
import { maskAddress } from "@axelarjs/utils";
import { useCallback, useEffect, useState, useMemo, type FC } from "react";
import { useRouter } from "next/router";

import { useAccount } from "wagmi";

import { useChainFromRoute } from "~/lib/hooks";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useAllChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useInterchainTokensQuery } from "~/services/gmp/hooks";
import GMPTxStatusMonitor from "~/ui/compounds/GMPTxStatusMonitor";
import { ShareHaikuButton } from "~/ui/compounds/MultiStepForm";
Expand All @@ -26,7 +25,7 @@ const Review: FC = () => {
const { chain } = useAccount();
const routeChain = useChainFromRoute();

const { computed } = useEVMChainConfigsQuery();
const { combinedComputed } = useAllChainConfigsQuery();

const [shouldFetch, setShouldFetch] = useState(false);

Expand All @@ -47,26 +46,28 @@ const Review: FC = () => {
chain.id,
state.txState.txHash,
state.selectedChains.map(
(axelarChainId) => computed.indexedById[axelarChainId].chain_id
(axelarChainId) => combinedComputed.indexedById[axelarChainId].chain_id
)
);
}
}, [chain, computed.indexedById, state.selectedChains, state.txState]);
}, [chain, combinedComputed.indexedById, state.selectedChains, state.txState]);

const chainConfig = Maybe.of(chain).mapOrUndefined(
(chain) => computed.indexedByChainId[chain.id]
);
const chainConfig = useMemo(() => {
if (!chain) return undefined;
return combinedComputed.indexedByChainId[chain.id];
}, [chain, combinedComputed.indexedByChainId]);

const handleGoToTokenPage = useCallback(async () => {
if (chainConfig && state.txState.type === "deployed") {
actions.reset();

await router.push(
`/${chainConfig.chain_name.toLowerCase()}/${state.txState.tokenAddress}`
);
}
}, [actions, chainConfig, router, state.txState]);

const isVMChain = chainConfig?.chain_type === 'vm';

return (
<>
<div className="grid gap-4">
Expand Down Expand Up @@ -105,32 +106,32 @@ const Review: FC = () => {
{state.selectedChains.length > 0 ? (
<GMPTxStatusMonitor txHash={state.txState.txHash} />
) : (
<LinkButton
$size="sm"
href={`${chain?.blockExplorers?.default.url}/tx/${state.txState.txHash}`}
className="flex items-center gap-2"
target="_blank"
>
View transaction{" "}
<span className="hidden md:inline">
{maskAddress(state.txState.txHash ?? "")}
</span>{" "}
on {chain?.blockExplorers?.default.name}{" "}
<ExternalLinkIcon className="h-4 w-4" />
</LinkButton>
!isVMChain && chain?.blockExplorers?.default && (
<LinkButton
$size="sm"
href={`${chain.blockExplorers.default.url}/tx/${state.txState.txHash}`}
className="flex items-center gap-2"
target="_blank"
>
View transaction{" "}
<span className="hidden md:inline">
{maskAddress(state.txState.txHash ?? "")}
</span>{" "}
on {chain.blockExplorers.default.name}{" "}
<ExternalLinkIcon className="h-4 w-4" />
</LinkButton>
)
)}
</>
)}
</div>
<Dialog.Actions>
{routeChain ? (
// if the chain is not the same as the route, we need to refresh the page
<Dialog.CloseAction
$length="block"
$variant="primary"
onClick={async () => {
setShouldFetch(true);
// refresh the page to show the new token
await router.replace(router.asPath);
}}
>
Expand All @@ -140,7 +141,7 @@ const Review: FC = () => {
<Button
$length="block"
$variant="primary"
disabled={!chain?.name || state.txState.type !== "deployed"}
disabled={!chainConfig || state.txState.type !== "deployed"}
onClick={handleGoToTokenPage}
>
Go to token page!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { trpc } from "~/lib/trpc";
import { isValidEVMAddress } from "~/lib/utils/validation";
import type { EstimateGasFeeMultipleChainsOutput } from "~/server/routers/axelarjsSDK";
import { RecordInterchainTokenDeploymentInput } from "~/server/routers/interchainToken/recordInterchainTokenDeployment";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useAllChainConfigsQuery } from "~/services/axelarscan/hooks";
import type { DeployAndRegisterTransactionState } from "../InterchainTokenDeployment.state";

export interface UseDeployAndRegisterInterchainTokenInput {
Expand All @@ -49,7 +49,7 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
const { address: deployerAddress } = useAccount();
const chainId = useChainId();

const { computed } = useEVMChainConfigsQuery();
const { combinedComputed } = useAllChainConfigsQuery();

const { mutateAsync: recordDeploymentAsync } =
trpc.interchainToken.recordInterchainTokenDeployment.useMutation();
Expand Down Expand Up @@ -81,7 +81,7 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
});

const { destinationChainNames } = useMemo(() => {
const index = computed.indexedById;
const index = combinedComputed.indexedById;

return {
destinationChainNames:
Expand All @@ -90,7 +90,7 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
index[destinationChainId]?.chain_name ?? "Unknown"
) ?? [],
};
}, [computed.indexedById, input?.destinationChainIds]);
}, [combinedComputed.indexedById, input?.destinationChainIds]);

const multicallArgs = useMemo(() => {
if (!input || !tokenId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EVMChainConfig } from "@axelarjs/api/axelarscan";
import type { EVMChainConfig, VMChainConfig } from "@axelarjs/api/axelarscan";
import { Maybe } from "@axelarjs/utils";
import { useEffect, useState } from "react";

Expand All @@ -11,22 +11,25 @@ import {
} from "~/config/env";
import { toNumericString } from "~/lib/utils/bigint";
import { useEstimateGasFeeMultipleChainsQuery } from "~/services/axelarjsSDK/hooks";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useAllChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useInterchainTokenDeploymentStateContainer } from "../../InterchainTokenDeployment.state";

type ChainConfig = EVMChainConfig | VMChainConfig;

export type UseStep2ChainSelectionStateProps = {
selectedChains: Set<string>;
};

export function useStep2ChainSelectionState() {
const { data: evmChains } = useEVMChainConfigsQuery();
const { allChains } = useAllChainConfigsQuery();
const chainId = useChainId();
const [isDeploying, setIsDeploying] = useState(false);
const [totalGasFee, setTotalGasFee] = useState(formatEther(0n));
const [sourceChainId, setSourceChainId] = useState(
evmChains?.find((evmChain: EVMChainConfig) => evmChain.chain_id === chainId)
?.id as string
);

const [sourceChainId, setSourceChainId] = useState<string>(() => {
const chain = allChains?.find((chain: ChainConfig) => chain.chain_id === chainId);
return chain?.id || "";
});

const { state: rootState } = useInterchainTokenDeploymentStateContainer();

Expand Down Expand Up @@ -54,20 +57,20 @@ export function useStep2ChainSelectionState() {
};

useEffect(() => {
const candidateChain = evmChains?.find(
(evmChain) => evmChain.chain_id === chainId
const candidateChain = allChains?.find(
(chain) => chain.chain_id === chainId
);
if (!candidateChain || candidateChain.chain_name === sourceChainId) return;

setSourceChainId(candidateChain.chain_name);
}, [evmChains, chainId, sourceChainId]);
}, [allChains, chainId, sourceChainId]);

return {
state: {
isDeploying,
totalGasFee,
sourceChainId,
evmChains,
chains: allChains,
isEstimatingGasFees: isRemoteDeploymentGasFeeLoading,
hasGasFeesEstimationError: isRemoteDeploymentGasFeeError,
remoteDeploymentGasFees,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const Step2: FC = () => {

const chainId = useChainId();

const sourceChain = state.evmChains.find((x) => x.chain_id === chainId);
// Handle both EVM and VM chains
const sourceChain = state.chains.find((chain) => chain.chain_id === chainId);

const [validDestinationChainIds, erroredDestinationChainIds] = useMemo(
() =>
Expand Down Expand Up @@ -139,10 +140,7 @@ export const Step2: FC = () => {
]
);

const eligibleChains = useMemo(
() => state.evmChains?.filter((chain) => chain.chain_id !== chainId),
[state.evmChains, chainId]
);
const eligibleChains = state.chains.filter(chain => chain.chain_id !== chainId);

const formSubmitRef = useRef<ComponentRef<"button">>(null);

Expand Down
Loading
Loading