Closed as not planned
Description
- https://github.com/thirdweb-dev/js/blob/main/packages/thirdweb/src/adapters/viem.ts#L308
WalletClient
's result is not particularly usable withgetContract()
fromviem
as Viem'sWalletClient
is parameterized on the type, and your implementation does not preserve the relationship between the input chain and the outputtedWalletClient
.- The implementation also seems odd.. I feel like most people would use viem's toAccount as opposed to intercepting the RPC call and inspecting which operation to perform. Can probably slim the code down if you do this instead.
Overall this library wasn't usable for me, probably going to rip thirdweb out. Once a connection is established to one of the walletProviders, I'd rather use Viem
directly than deal with duplicate abstractions everywhere.
Is there any easier way to do any of this?
const activeWallet = useActiveWallet();
if (activeWallet) {
const walletClient = viemAdapter.wallet.toViem({
wallet: activeWallet, // see: https://portal.thirdweb.com/typescript/v5/wallets
client: client,
chain: baseSepolia,
});
const contract = getContract({client: walletClient, address: Addresses.MyContract as `0x${string}`, abi: MyContractAbi});
}
// <--- results in an error on the typing of Client that is incredibly long.
// Type 'Chain' is not assignable to type 'Chain | undefined'. is the core of it