-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ts: Add program.coder.types for encoding/decoding user-defined types #1931
ts: Add program.coder.types for encoding/decoding user-defined types #1931
Conversation
/** | ||
* Coder for user-defined types. | ||
*/ | ||
readonly types: TypesCoder<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a CHANGELOG.md entry for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
aa071c5
to
d6ec864
Compare
d6ec864
to
9e52562
Compare
Thank you! |
const layouts: [N, Layout][] = idl.types.map((acc) => { | ||
return [acc.name as N, IdlCoder.typeDefLayout(acc, idl.types)]; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that a typo on line 26
? I believe types must included both idl.types
and idl.accounts
, after all idl.accounts
are types as well, and they can be used in all places, such as #[event]
and return value in view
functions.
const layouts: [N, Layout][] = idl.accounts.map((acc) => { // changed: types -> accounts
return [acc.name as N, IdlCoder.typeDefLayout(acc, idl.types)];
});
Also, the name of the closure argument is acc
, so I believe it was meant to be iteration over accounts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OR, we have a problem in event.js
as it does not use accounts
. Events could use accounts as well(especially the smaller ones).
fixes #1930