Skip to content
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

Merged
merged 2 commits into from
May 29, 2022

Conversation

vovacodes
Copy link
Contributor

fixes #1930

/**
* Coder for user-defined types.
*/
readonly types: TypesCoder<T>;
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@armaniferrante armaniferrante merged commit d83fcbf into coral-xyz:master May 29, 2022
@armaniferrante
Copy link
Member

Thank you!

@vovacodes vovacodes deleted the feature/add-coder-types branch May 29, 2022 21:19
Comment on lines +26 to +28
const layouts: [N, Layout][] = idl.types.map((acc) => {
return [acc.name as N, IdlCoder.typeDefLayout(acc, idl.types)];
});
Copy link
Contributor

@snawaz snawaz Jun 8, 2023

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.

Copy link
Contributor

@snawaz snawaz Jun 8, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose coder for user defined types as program.coder.types.
3 participants