Skip to content

Commit

Permalink
Merge branch 'main' into feat/admin-panel-manage-global-message
Browse files Browse the repository at this point in the history
  • Loading branch information
canhtrinh authored Jan 18, 2024
2 parents d35bf65 + 40ed265 commit 2f46113
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ManageInterchainToken: FC<Props> = (props) => {
label: "Transfer Mintership",
value: "transferMintership",
icon: <GiftIcon className="h-7 w-7 md:h-8 md:w-8" />,
isVisible: () => false,
isVisible: (props) => props.isTokenMinter,
},
{
label: "Ownnership Pending Approval",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCallback, useMemo, type FC } from "react";
import { useForm, type SubmitHandler } from "react-hook-form";

import { isAddress, TransactionExecutionError } from "viem";
import { useChainId, useWaitForTransaction } from "wagmi";
import { useAccount, useChainId, useWaitForTransaction } from "wagmi";

import { useInterchainTokenTransferMintership } from "~/lib/contracts/InterchainToken.hooks";
import { useTransactionState } from "~/lib/hooks/useTransactionState";
Expand All @@ -27,8 +27,9 @@ export const TransferInterchainTokenMintership: FC = () => {
const [txState, setTxState] = useTransactionState();
const [state] = useManageInterchainTokenContainer();
const chainId = useChainId();
const account = useAccount();

const { register, handleSubmit, formState, getValues } = useForm<FormState>({
const { register, handleSubmit, formState } = useForm<FormState>({
defaultValues: {
recipientAddress: undefined,
},
Expand All @@ -42,7 +43,7 @@ export const TransferInterchainTokenMintership: FC = () => {
data: transferResult,
} = useInterchainTokenTransferMintership({
address: state.tokenAddress,
account: getValues("recipientAddress"),
account: account.address,
});

const trpcContext = trpc.useUtils();
Expand Down Expand Up @@ -139,8 +140,7 @@ export const TransferInterchainTokenMintership: FC = () => {
</Dialog.Title>
{txState.status === "confirmed" ? (
<Alert status="success">
Token mintership has been successfully transferred. The recipient now
must accept the mintership transfer.
Token mintership has been successfully transferred.
</Alert>
) : (
<form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCallback, useMemo, type FC } from "react";
import { useForm, type SubmitHandler } from "react-hook-form";

import { isAddress, TransactionExecutionError } from "viem";
import { useChainId, useWaitForTransaction } from "wagmi";
import { useAccount, useChainId, useWaitForTransaction } from "wagmi";

import { useInterchainTokenServiceTransferOperatorship } from "~/lib/contracts/InterchainTokenService.hooks";
import { useTransactionState } from "~/lib/hooks/useTransactionState";
Expand All @@ -27,8 +27,9 @@ export const TransferInterchainTokenOperatorship: FC = () => {
const [txState, setTxState] = useTransactionState();
const [state] = useManageInterchainTokenContainer();
const chainId = useChainId();
const account = useAccount();

const { register, handleSubmit, formState, getValues } = useForm<FormState>({
const { register, handleSubmit, formState } = useForm<FormState>({
defaultValues: {
recipientAddress: undefined,
},
Expand All @@ -42,7 +43,7 @@ export const TransferInterchainTokenOperatorship: FC = () => {
data: transferResult,
} = useInterchainTokenServiceTransferOperatorship({
address: state.tokenAddress,
account: getValues("recipientAddress"),
account: account.address,
});

const trpcContext = trpc.useUtils();
Expand Down Expand Up @@ -70,7 +71,7 @@ export const TransferInterchainTokenOperatorship: FC = () => {
receipt,
});

toast.success("Successfully transferred token ownership");
toast.success("Successfully transferred token operatorship");
},
});

Expand All @@ -97,10 +98,10 @@ export const TransferInterchainTokenOperatorship: FC = () => {
} catch (error) {
if (error instanceof TransactionExecutionError) {
toast.error(
`Failed to transfer rate limit manager: ${error.cause.shortMessage}`
`Failed to transfer token operatorship: ${error.cause.shortMessage}`
);
logger.error(
`Failed to transfer rate limit manager: ${error.cause.message}`
`Failed to transfer token operatorship: ${error.cause.message}`
);

setTxState({
Expand All @@ -122,25 +123,24 @@ export const TransferInterchainTokenOperatorship: FC = () => {
switch (txState.status) {
case "idle":
case "confirmed":
return "Transfer rate limit manager";
return "Transfer token operatorship";
case "awaiting_approval":
return "Confirm on wallet";
case "submitted":
return "Transfering token ownership";
return "Transfering token operatorship";
case "reverted":
return "Failed to transfer ownership";
return "Failed to transfer operatorship";
}
}, [txState]);

return (
<>
<Dialog.Title className="flex">
<span>Transfer rate limit manager</span>
<span>Transfer rate-limit manager</span>
</Dialog.Title>
{txState.status === "confirmed" ? (
<Alert status="success">
Token ownership has been successfully transferred. The recipient now
must accept the ownership transfer.
Token operatorship has been successfully transferred.
</Alert>
) : (
<form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ export const getERC20TokenBalanceForOwner = publicProcedure
chainConfig,
input.tokenAddress
);
const isTokenMinter = await itClient.reads
.isMinter({
addr: input.owner,
})
.catch(always(false));
const [isTokenMinter] = await Promise.all([
itClient.reads
.isMinter({
addr: input.owner,
})
.catch(always(false)),
]);

return {
isTokenMinter,
Expand Down

0 comments on commit 2f46113

Please sign in to comment.