I followed the documentation and online resources to migrate from Viem 0.8.x to 1.4.1, but I am facing difficulties making it work as intended.
Here is the function I am trying to read from my ABI:
{
inputs: [],
name: 'getTreasuryAndPhilantrophyBalanceInUSD',
outputs: [
{
internalType: 'uint256',
name: 'treasuryBalance',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'philantrophyBalance',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
I have exported my ABI as a const in a TypeScript file:
import { Abi } from 'viem';
export const abiTest: Abi = [...] as const;
This is how I implemented ReadContract:
const resultRead = await client.readContract({
abi: abiCfaPeriphery,
address: '...' as Address,
functionName: 'getTreasuryAndPhilantrophyBalanceInUSD',
});
console.log('Result Read: ', resultRead);
The console output now shows:
Result Read: [ 902828817075004553524n, 0n ]
In previous implementations, I used to get:
Result Read: [ 902828817075004553524n, 0n, treasuryBalance:xxxx, philantrophyBalance:xxxxx ]
With this change, I can no longer access individual balances like before, which has caused issues in my implementation. Is there something important that I might be overlooking?
I have thoroughly gone through the following resources:
Viem Type Inference Explanation
Thank you