Commit 11fe8c6f authored by tom goriunov's avatar tom goriunov Committed by GitHub

Contract `Write` method returns a checksum error (#2021)

Fixes #2018
parent c3420f6d
import React from 'react';
import type { Abi } from 'viem';
import { getAddress, type Abi } from 'viem';
import { useAccount, useWalletClient, useSwitchChain } from 'wagmi';
import type { ContractAbiItem, FormSubmitResult } from './types';
......@@ -32,10 +32,12 @@ export default function useCallMethodWalletClient(): (params: Params) => Promise
await switchChainAsync?.({ chainId: Number(config.chain.id) });
}
const address = getAddress(addressHash);
if (item.type === 'receive' || item.type === 'fallback') {
const value = getNativeCoinValue(args[0]);
const hash = await walletClient.sendTransaction({
to: addressHash as `0x${ string }` | undefined,
to: address,
value,
});
return { source: 'wallet_client', result: { hash } };
......@@ -61,7 +63,7 @@ export default function useCallMethodWalletClient(): (params: Params) => Promise
// - https://github.com/blockscout/frontend/issues/1327
abi: [ item ] as Abi,
functionName: methodName,
address: addressHash as `0x${ string }`,
address,
value,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment