Skip to content

Commit

Permalink
Contract Write method returns a checksum error (#2021)
Browse files Browse the repository at this point in the history
Fixes #2018
  • Loading branch information
tom2drum authored Jun 13, 2024
1 parent c3420f6 commit 11fe8c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/address/contract/ABI/useCallMethodWalletClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';
Expand Down Expand Up @@ -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 } };
Expand All @@ -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,
});

Expand Down

0 comments on commit 11fe8c6

Please sign in to comment.