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

fix: build devnet amplifier #477

Merged
merged 29 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cd06c21
chore: init fix decimals
npty Dec 4, 2024
c6aa428
chore: prevent token decimals issue for sui
npty Dec 5, 2024
c1917db
chore: update sui imports
npty Dec 12, 2024
aa597f1
chore: update hooks build
npty Dec 12, 2024
4c6f379
chore: update chain types
npty Dec 12, 2024
bb7815f
chore: remove unused var
npty Dec 12, 2024
c824d61
fix: some build errors
npty Dec 12, 2024
a4dcc44
chore: fix more errors
npty Dec 12, 2024
eb63872
chore: fix more build errors
npty Dec 13, 2024
3590b0f
chore: fix all compile errors
npty Dec 17, 2024
d94b9fe
chore: update pnpm-lock
npty Dec 17, 2024
4c3aafe
chore: fix unnecessary cast
npty Dec 17, 2024
e1ef786
chore: make contract_0_path optional
npty Dec 17, 2024
c54663c
chore: fix deployment
npty Dec 17, 2024
69b2633
chore: remove log
npty Dec 17, 2024
99bedbe
chore: fix build error
npty Dec 17, 2024
024ea0a
chore: add token address
SGiaccobasso Dec 17, 2024
6ad4fd3
chore: add tx index to deployment message id
SGiaccobasso Dec 18, 2024
3517b04
chore: fix minter address type for evm
npty Dec 19, 2024
180b157
chore: fix deploymentMessageId type string | undefined
npty Dec 19, 2024
2c5ab36
chore: fix more errors
npty Dec 19, 2024
46c4444
chore: fix remainning errors
npty Dec 19, 2024
e837dd5
chore: few more build errors
npty Dec 19, 2024
81b24b0
chore: add todo
npty Dec 19, 2024
960dd23
chore: add todo to handle register type
npty Dec 19, 2024
98ce408
Merge branch 'env/devnet-amplifier' into fix/build-devnet-amplifier
npty Dec 19, 2024
66a88a8
chore: add comment
npty Dec 19, 2024
53ee75c
chore: fix some errors
npty Dec 19, 2024
1a5f67f
chore: fix build errors
npty Dec 19, 2024
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
3 changes: 1 addition & 2 deletions apps/maestro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
"@axelarjs/utils": "workspace:*",
"@hookform/resolvers": "^3.3.4",
"@mysten/bcs": "^1.1.0",
"@mysten/dapp-kit": "^0.14.39",
"@mysten/dapp-kit": "^0.14.43",
"@mysten/sui": "^1.11.0",
"@mysten/sui.js": "^0.54.1",
"@sentry/nextjs": "^7.108.0",
"@tanstack/react-query": "^5.28.6",
"@trpc/client": "11.0.0-next.320",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export type DeployAndRegisterTransactionState =
}
| {
type: "deploying";
txHash: `0x${string}`;
txHash: string;
}
| {
type: "deployed";
txHash: `0x${string}`;
tokenAddress: `0x${string}`;
txHash: string;
tokenAddress: string;
};

export const INITIAL_STATE = {
Expand All @@ -28,11 +28,11 @@ export const INITIAL_STATE = {
tokenName: "",
tokenSymbol: "",
tokenDecimals: 18,
tokenAddress: "0x" as `0x${string}`,
tokenAddress: "0x",
},
txState: { type: "idle" } as DeployAndRegisterTransactionState,
selectedChains: [] as string[],
onDeployTxHash: (txHash: `0x${string}`) => {
onDeployTxHash: (txHash: string) => {
logger.log("onDeployTxHash", txHash);
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface UseDeployAndRegisterCanonicalTokenInput {
sourceChainId: string;
tokenName: string;
tokenSymbol: string;
tokenAddress: `0x${string}`;
tokenAddress: string;
decimals: number;
destinationChainIds: string[];
remoteDeploymentGasFees: bigint[];
Expand Down Expand Up @@ -93,7 +93,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(

const deployTxData =
INTERCHAIN_TOKEN_FACTORY_ENCODERS.registerCanonicalInterchainToken.data({
tokenAddress: input.tokenAddress,
tokenAddress: input.tokenAddress as `0x${string}`,
});

if (!input.destinationChainIds.length) {
Expand All @@ -106,7 +106,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(

const args = {
originalChain: originalChainName,
originalTokenAddress: input.tokenAddress,
originalTokenAddress: input.tokenAddress as `0x${string}`,
destinationChain,
gasValue,
};
Expand Down Expand Up @@ -166,6 +166,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
tokenSymbol: input.tokenSymbol,
tokenDecimals: input.decimals,
axelarChainId: input.sourceChainId,
tokenManagerAddress: "",
destinationAxelarChainIds: input.destinationChainIds,
});
},
Expand Down Expand Up @@ -195,7 +196,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
onStatusUpdate({
type: "deployed",
tokenAddress: recordDeploymentArgs.tokenAddress as `0x${string}`,
txHash: tx.hash,
txHash: tx.hash as `0x${string}`,
});
})
.catch((e) => {
Expand Down Expand Up @@ -226,6 +227,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
tokenDecimals: input.decimals,
axelarChainId: input.sourceChainId,
tokenAddress: input.tokenAddress,
tokenManagerAddress: "",
destinationAxelarChainIds: input.destinationChainIds,
deploymentMessageId: "",
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { EVMChainConfig } from "@axelarjs/api/axelarscan";
import { useEffect, useState } from "react";

import { formatEther } from "viem";
Expand All @@ -22,8 +21,7 @@ export function useStep3ChainSelectionState() {
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
evmChains?.find((evmChain) => evmChain.chain_id === chainId)?.id as string
);

const { state: rootState } = useCanonicalTokenDeploymentStateContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const Step3: FC = () => {
);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,20 @@ import { z } from "zod";

import { SUI_CHAIN_ID, useAccount, useChainId } from "~/lib/hooks";
import { logger } from "~/lib/logger";
import {
hex64Literal,
numericString,
optionalHex40Literal,
} from "~/lib/utils/validation";
import { hex64Literal, numericString } from "~/lib/utils/validation";
import { DeployTokenResult } from "../suiHooks/useDeployToken";

const TOKEN_DETAILS_FORM_SCHEMA = z.object({
tokenName: z.string().min(1).max(32),
tokenSymbol: z.string().min(1).max(11),
tokenDecimals: z.coerce.number().min(0).max(18),
initialSupply: numericString(),
isMintable: z.boolean(),
minter: optionalHex40Literal(),
minter: z.string().optional(),
salt: hex64Literal(),
});

export type TokenDetailsFormState = z.infer<typeof TOKEN_DETAILS_FORM_SCHEMA>;
const MAX_UINT64 = BigInt(2) ** BigInt(64) - BigInt(1);

export type DeployAndRegisterTransactionState =
| {
Expand All @@ -37,12 +33,13 @@ export type DeployAndRegisterTransactionState =
}
| {
type: "deploying";
txHash: `0x${string}`;
txHash: string;
}
| {
type: "deployed";
txHash: `0x${string}`;
tokenAddress: `0x${string}`;
suiTx?: DeployTokenResult;
txHash: string;
tokenAddress: string;
};

export const INITIAL_STATE = {
Expand All @@ -51,15 +48,15 @@ export const INITIAL_STATE = {
tokenName: "",
tokenSymbol: "",
tokenDecimals: 18,
tokenAddress: undefined as `0x${string}` | undefined,
tokenAddress: undefined as string | undefined,
initialSupply: "0",
isMintable: false,
minter: "" as `0x${string}` | undefined,
minter: "" as string | undefined,
salt: undefined as `0x${string}` | undefined,
},
txState: { type: "idle" } as DeployAndRegisterTransactionState,
selectedChains: [] as string[],
onDeployTxHash(txHash: `0x${string}`) {
onDeployTxHash(txHash: string) {
logger.log("onDeployTxHash", txHash);
},
};
Expand Down Expand Up @@ -228,8 +225,8 @@ function useInterchainTokenDeploymentState(
},
resetMinter: () => {
setState((draft) => {
draft.tokenDetails.minter = "" as `0x${string}`;
tokenDetailsForm.setValue("minter", "" as `0x${string}`);
draft.tokenDetails.minter = "" as string;
tokenDetailsForm.setValue("minter", "" as string);
});
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface UseDeployAndRegisterInterchainTokenInput {
remoteDeploymentGasFees?: EstimateGasFeeMultipleChainsOutput;
initialSupply?: bigint;
salt: `0x${string}`;
minterAddress?: `0x${string}`;
minterAddress?: string;
}

export interface UseDeployAndRegisterRemoteInterchainTokenConfig {
Expand Down Expand Up @@ -278,7 +278,7 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
environment: NEXT_PUBLIC_NETWORK_ENV,
},
],
};
} as const;

const { mutateAsync: recordDeploymentAsync } =
trpc.interchainToken.recordInterchainTokenDeployment.useMutation();
Expand Down Expand Up @@ -311,15 +311,17 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
});
const { destinationChainNames } = useMemo(() => {
const index = updatedComputed.indexedById;
const originalChainName =
index[input?.sourceChainId ?? chainId]?.chain_name ?? "Unknown";
type IndexedChainId = keyof typeof index;
const originalChain =
index[(input?.sourceChainId ?? chainId) as IndexedChainId];
const originalChainName = originalChain?.chain_name ?? "Unknown";

return {
originalChainName,
destinationChainNames:
input?.destinationChainIds.map(
(destinationChainId) =>
index[destinationChainId]?.chain_name ?? "Unknown"
index[destinationChainId as IndexedChainId]?.chain_name ?? "Unknown"
) ?? [],
};
}, [
Expand All @@ -334,8 +336,9 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
return [];
}

const minter = input?.minterAddress ?? zeroAddress;
const commonArgs = {
minter: input?.minterAddress ?? zeroAddress,
minter: minter as `0x${string}`,
salt: input.salt,
};

Expand Down Expand Up @@ -499,13 +502,14 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
decimals: input.decimals,
destinationChainIds: input.destinationChainIds,
});
if (result?.digest) {
if (result?.digest && result.deploymentMessageId) {
const token: any = result?.events?.[0]?.parsedJson;
setRecordDeploymentArgs({
kind: "interchain",
deploymentMessageId: `${result?.digest}-${0}`,
tokenId: result?.events?.[0]?.parsedJson?.token_id?.id,
tokenAddress: result?.tokenAddress,
tokenManagerAddress: result?.tokenManagerAddress,
deploymentMessageId: result.deploymentMessageId,
tokenId: token.token_id?.id,
tokenAddress: result.tokenAddress,
tokenManagerAddress: result.tokenManagerAddress,
deployerAddress,
salt: input.salt,
tokenName: input.tokenName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { EVMChainConfig } from "@axelarjs/api/axelarscan";
import { Maybe } from "@axelarjs/utils";
import { useEffect, useState } from "react";

Expand All @@ -24,8 +23,7 @@ export function useStep2ChainSelectionState() {
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
evmChains?.find((evmChain) => evmChain.chain_id === chainId)?.id as string
);

const { state: rootState } = useInterchainTokenDeploymentStateContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import React, {
} from "react";

import { parseUnits } from "viem";
import { WriteContractData } from "wagmi/query";

import { NEXT_PUBLIC_NETWORK_ENV } from "~/config/env";
import { DeployTokenResult } from "~/features/suiHooks/useDeployToken";
import { useTransactionsContainer } from "~/features/Transactions";
import { useBalance, useChainId } from "~/lib/hooks";
import { handleTransactionResult } from "~/lib/transactions/handlers";
Expand Down Expand Up @@ -105,14 +107,15 @@ export const Step2: FC = () => {
// Sui will return a digest equivalent to the txHash
const SUI_CHAIN_ID = NEXT_PUBLIC_NETWORK_ENV === "mainnet" ? 101 : 103;
if (sourceChain.chain_id === SUI_CHAIN_ID) {
const result = await txPromise;
const result = (await txPromise) as DeployTokenResult;
// if tx is successful, we will get a digest
if (result?.digest) {
if (result) {
rootActions.setTxState({
status: "submitted",
type: "deployed",
suiTx: result,
txHash: result.digest,
chainId: sourceChain.chain_id,
tokenAddress: result.tokenAddress,
// chainId: sourceChain.chain_id,
});
if (rootState.selectedChains.length > 0) {
addTransaction({
Expand All @@ -131,7 +134,7 @@ export const Step2: FC = () => {
}
}

await handleTransactionResult(txPromise, {
await handleTransactionResult(txPromise as Promise<WriteContractData>, {
onSuccess(txHash) {
rootActions.setTxState({
type: "deploying",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ export type Props = TokenInfo & {
export const RegisteredInterchainTokenCard: FC<Props> = (props) => {
const { address } = useAccount();
const chainId = useChainId();
const { data: balance } = useInterchainTokenBalanceForOwnerQuery({
const result = useInterchainTokenBalanceForOwnerQuery({
chainId: props.chainId,
tokenAddress: props.isRegistered ? props.tokenAddress : undefined,
owner: address,
});
// TODO: remove any
const balance = (result as any).data.balance;

const { explorerUrl, explorerName } = useMemo(() => {
if (!props.tokenAddress || !props.chain) {
Expand Down
Loading
Loading