I'm trying to fetch a PDA account and use one of it's properties as a seed for another PDA account. Here's what the implementation looks like:
const [ registryPDA, registryBump ] = PublicKey.findProgramAddressSync([Buffer.from('REGISTRY')], PROGRAM_KEY);
const registry = await program.account["registry"].fetch(registryPDA);
const company_id = registry.totalCompanies.toArrayLike(Buffer, "be", 8);
const [ companyPDA, companyBump ] = PublicKey.findProgramAddressSync([Buffer.from('COMPANY'), company_id], PROGRAM_KEY);
but it gives an error for registry.totalCompanies
: 'registry.totalCompanies' is of type 'unknown'
It seems like since registry variable is type of unknown, it can't figure out how to turn it into Buffer. How can I specify it's account type?