Closed matisalimbene closed 5 months ago
The issue is that you are constructing the account id incorrectly:
const getTxLog = async (accountId) => {
// ...
const [accName, accDomainId] = accountId.split('@');
const account = AccountId({
name: accName,
domain_id: accDomainId,
// ^^^^^^^^^^^ - got `string`, expected `DomainId`
});
// ...
}
When codec tries to encode the domain_id
field, it passes the domain_id.name
field into a String codec, which looks up for a .length
field, and that's where you get the
Cannot read properties of undefined (reading 'length')
error.
So, the fix would be to construct a proper DomainId
:
const account = AccountId({
name: accName,
domain_id: datamodel.DomainId({ name: accDomainId })
})
Once again, I strongly recommend you using TypeScript, because this error can be easily caught using its diagnostics. For example, if you annotate the accountId
argument with string
type, TypeScript highlights the error:
const getTxLog = async (accountId: string) => {
// ^^^^^^^^ add this
// ...
const account = AccountId({
name: accName,
domain_id: accDomainId,
// ^^^^^^^^^ TS2322: Type string is not assignable to type DomainId
});
// ...
}
I'm unable to execute the
FindTransactionsByAccountId
query. I wasn't able to find any similar example for follow on how to construct the query. (Tests use the sugar library).Right now this is the err I'm getting:
These are the documentation Links I followed: