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: contract function calls on testnet #481

Merged
merged 14 commits into from
Dec 26, 2024
6 changes: 6 additions & 0 deletions .changeset/kind-ways-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@axelarjs/maestro": patch
"@axelarjs/evm": patch
---

updated its and factory contract functions
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const CanonicalTokenRecovery = () => {
.map(([key, value]) => (
<li key={key}>
<span className="mr-1 font-semibold opacity-85">{key} </span>
<span>{value}</span>
<span>{value as React.ReactNode}</span>
</li>
))}
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { INTERCHAIN_TOKEN_FACTORY_ENCODERS } from "@axelarjs/evm";
import {
INTERCHAIN_TOKEN_FACTORY_ENCODERS,
INTERCHAIN_TOKEN_SERVICE_ENCODERS,
} from "@axelarjs/evm";
import { invariant, throttle } from "@axelarjs/utils";
import { useCallback, useEffect, useMemo, useState } from "react";

import { zeroAddress, type TransactionReceipt } from "viem";
import { useAccount, useChainId, useWaitForTransactionReceipt } from "wagmi";

import {
useReadInterchainTokenFactoryInterchainTokenAddress,
useReadInterchainTokenFactoryInterchainTokenId,
useSimulateInterchainTokenFactoryMulticall,
useWriteInterchainTokenFactoryMulticall,
} from "~/lib/contracts/InterchainTokenFactory.hooks";
import { useReadInterchainTokenServiceInterchainTokenAddress } from "~/lib/contracts/InterchainTokenService.hooks";
import {
decodeDeploymentMessageId,
type DeploymentMessageId,
Expand Down Expand Up @@ -68,35 +71,26 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
});

const { data: tokenAddress } =
useReadInterchainTokenFactoryInterchainTokenAddress({
args: INTERCHAIN_TOKEN_FACTORY_ENCODERS.interchainTokenAddress.args({
salt: input?.salt as `0x${string}`,
deployer: deployerAddress as `0x${string}`,
useReadInterchainTokenServiceInterchainTokenAddress({
args: INTERCHAIN_TOKEN_SERVICE_ENCODERS.interchainTokenAddress.args({
tokenId: tokenId as `0x${string}`,
}),
query: {
enabled: Boolean(tokenId && input?.salt && deployerAddress),
enabled: Boolean(tokenId),
},
});

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

return {
originalChainName,
destinationChainNames:
input?.destinationChainIds.map(
(destinationChainId) =>
index[destinationChainId]?.chain_name ?? "Unknown"
) ?? [],
};
}, [
chainId,
computed.indexedById,
input?.destinationChainIds,
input?.sourceChainId,
]);
}, [computed.indexedById, input?.destinationChainIds]);

const multicallArgs = useMemo(() => {
if (!input || !tokenId) {
Expand Down Expand Up @@ -125,14 +119,14 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
const registerTxData = destinationChainNames.map((destinationChain, i) =>
INTERCHAIN_TOKEN_FACTORY_ENCODERS.deployRemoteInterchainToken.data({
...commonArgs,
originalChainName,
originalChainName: "",
destinationChain,
gasValue: input.remoteDeploymentGasFees?.gasFees?.[i].fee ?? 0n,
})
);

return [deployTxData, ...registerTxData];
}, [input, tokenId, destinationChainNames, originalChainName]);
}, [input, tokenId, destinationChainNames]);

const totalGasFee = input?.remoteDeploymentGasFees?.totalGasFee ?? 0n;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const RegisteredInterchainTokenCard: FC<Props> = (props) => {
balance={BigInt(balance.tokenBalance)}
isTokenOwner={balance.isTokenOwner}
isTokenPendingOnwer={balance.isTokenPendingOwner}
isTokenMinter={balance.isTokenMinter}
isTokenMinter={balance.isTokenMinter as boolean}
hasPendingOwner={balance.hasPendingOwner}
tokenId={props.tokenId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,13 @@ export default function useRegisterRemoteInterchainTokens(
return destinationChainIds.map((chainId, i) =>
INTERCHAIN_TOKEN_FACTORY_ENCODERS.deployRemoteInterchainToken.data({
salt: tokenDeployment.salt,
originalChainName: sourceChain?.chain_name ?? "",
originalChainName: "",
minter: tokenDeployment.originalMinterAddress ?? zeroAddress,
destinationChain: chainId,
gasValue: gasFeesData.gasFees[i].fee,
})
);
}, [
destinationChainIds,
gasFeesData,
sourceChain?.chain_name,
tokenDeployment,
]);
}, [destinationChainIds, gasFeesData, tokenDeployment]);

const totalGasFee = gasFeesData?.totalGasFee ?? 0n;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import {

export const ierc20MintableBurnableAbi = [
{
stateMutability: "nonpayable",
type: "function",
inputs: [
{ name: "from", internalType: "address", type: "address" },
{ name: "amount", internalType: "uint256", type: "uint256" },
],
name: "burn",
outputs: [],
stateMutability: "nonpayable",
},
{
stateMutability: "nonpayable",
type: "function",
inputs: [
{ name: "to", internalType: "address", type: "address" },
{ name: "amount", internalType: "uint256", type: "uint256" },
],
name: "mint",
outputs: [],
stateMutability: "nonpayable",
},
] as const;

Expand Down
Loading
Loading