I have a situation where I believe I followed along the documentation and online information to make it work, but I haven't managed to do so yet.
I have migrated from Viem 0.8.x towards 1.4.1. This is the function I try 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 export my ABI as a const, in a TS file:
import { Abi } from 'viem';
export const abiTest: Abi = [...] as const;
This is my ReadContract implementation:
const resultRead = await client.readContract({
abi: abiCfaPeriphery,
address: '...' as Address,
functionName: 'getTreasuryAndPhilantrophyBalanceInUSD',
});
console.log('Result Read: ', resultRead);
My console log appears as:
Result Read: [ 902828817075004553524n, 0n ]
Before, I used to get:
Result Read: [ 902828817075004553524n, 0n, treasuryBalance:xxxx, philantrophyBalance:xxxxx ]
So in my TypeScript implementation I could do:
console.log(resultRead.treasuryBalance);
console.log(resultRead.philantrophyBalance);
But somehow I have lost this ability, which has broken all my implementation. Is there's something I'm missing?
I have read all the information here:
Viem Type Inference Explanation
Thanks