From 871e739f7cde81b83d9c8371f20d3259facd004c Mon Sep 17 00:00:00 2001 From: johnnyd-eth Date: Fri, 27 Sep 2024 13:37:16 +1000 Subject: [PATCH] fix: v4 launch erc20 tx --- .../buttons/AddTokenToMetamaskButton.tsx | 4 ++-- .../v4/hooks/useV4IssueErc20TokenTx.ts | 20 +++++++++++-------- .../CreateErc20TokenSettingsPage.tsx | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/components/buttons/AddTokenToMetamaskButton.tsx b/src/components/buttons/AddTokenToMetamaskButton.tsx index f21a780758..f6a0a7e3ef 100644 --- a/src/components/buttons/AddTokenToMetamaskButton.tsx +++ b/src/components/buttons/AddTokenToMetamaskButton.tsx @@ -2,7 +2,7 @@ import { Trans } from '@lingui/macro' import type { MetaMaskInpageProvider } from '@metamask/providers' import { Button } from 'antd' import { providers } from 'ethers' -import useNameOfERC20 from 'hooks/ERC20/useNameOfERC20' +import useSymbolOfERC20 from 'hooks/ERC20/useSymbolOfERC20' import { twMerge } from 'tailwind-merge' import { Hash } from 'viem' @@ -28,7 +28,7 @@ const useMetamask = () => { function useAddTokenToWalletRequest({ tokenAddress }: { tokenAddress: Hash }) { const ethereum = useMetamask() - const { data: tokenSymbol } = useNameOfERC20(tokenAddress) + const { data: tokenSymbol } = useSymbolOfERC20(tokenAddress) if (!ethereum) { return diff --git a/src/packages/v4/hooks/useV4IssueErc20TokenTx.ts b/src/packages/v4/hooks/useV4IssueErc20TokenTx.ts index 237bb92a42..aff75e3842 100644 --- a/src/packages/v4/hooks/useV4IssueErc20TokenTx.ts +++ b/src/packages/v4/hooks/useV4IssueErc20TokenTx.ts @@ -1,15 +1,15 @@ import { useCallback, useContext } from 'react' import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext' -import { useJBContractContext, useWriteJbTokensDeployErc20For } from 'juice-sdk-react' -import { zeroAddress } from 'viem' +import { useJBContractContext, useWriteJbControllerDeployErc20For } from 'juice-sdk-react' +import { Address, zeroAddress } from 'viem' import { BaseTxOpts } from '../models/transactions' export function useV4IssueErc20TokenTx() { const { addTransaction } = useContext(TxHistoryContext) const { projectId, contracts } = useJBContractContext() - const { writeContractAsync: deployErc20 } = useWriteJbTokensDeployErc20For() + const { writeContractAsync: deployErc20Tx } = useWriteJbControllerDeployErc20For() return useCallback ( async ({ name, symbol }: { @@ -33,17 +33,20 @@ export function useV4IssueErc20TokenTx() { try { // SIMULATE TX: // const encodedData = encodeFunctionData({ - // abi: jbTokensAbi, // ABI of the contract - // functionName: 'deployErc20For', + // abi: jbControllerAbi, // ABI of the contract + // functionName: 'deployERC20For', // args, // }) + // console.log('contract', contracts.controller.data) + // console.log('encodedData', encodedData) - const hash = await deployErc20({ + const hash = await deployErc20Tx({ args, + address: contracts.controller.data as Address }) onTransactionPendingCallback(hash) - addTransaction?.('Edit Ruleset', { hash }) + addTransaction?.('Launch ERC20 Token', { hash }) // const transactionReceipt: WaitForTransactionReceiptReturnType = await waitForTransactionReceipt( // wagmiConfig, // { @@ -59,9 +62,10 @@ export function useV4IssueErc20TokenTx() { } }, [ - deployErc20, + deployErc20Tx, projectId, addTransaction, + contracts.controller.data, ], ) } diff --git a/src/packages/v4/views/V4ProjectSettings/CreateErc20TokenSettingsPage.tsx b/src/packages/v4/views/V4ProjectSettings/CreateErc20TokenSettingsPage.tsx index d2fded6190..c1dcb397af 100644 --- a/src/packages/v4/views/V4ProjectSettings/CreateErc20TokenSettingsPage.tsx +++ b/src/packages/v4/views/V4ProjectSettings/CreateErc20TokenSettingsPage.tsx @@ -24,7 +24,7 @@ const issueErc20TokenTx = useV4IssueErc20TokenTx() const canCreateErc20Token = !projectHasErc20Token && hasIssueTicketsPermission - async function onSetENSNameFormSaved(values: IssueErc20TokenTxArgs) { + async function onIssueErc20FormSaved(values: IssueErc20TokenTxArgs) { await form.validateFields() if (!issueErc20TokenTx) { @@ -78,7 +78,7 @@ const issueErc20TokenTx = useV4IssueErc20TokenTx()