Skip to content

ts: Add program.coder.types for encoding/decoding user-defined types - #1931

Merged
armaniferrante merged 2 commits into
otter-sec:masterfrom
vovacodes:feature/add-coder-types
May 29, 2022
Merged

ts: Add program.coder.types for encoding/decoding user-defined types#1931
armaniferrante merged 2 commits into
otter-sec:masterfrom
vovacodes:feature/add-coder-types

Conversation

@vovacodes

Copy link
Copy Markdown
Contributor

fixes #1930

Comment thread ts/src/coder/index.ts
/**
* Coder for user-defined types.
*/
readonly types: TypesCoder<T>;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@vovacodes
vovacodes force-pushed the feature/add-coder-types branch from aa071c5 to d6ec864 Compare May 29, 2022 18:20
@vovacodes
vovacodes force-pushed the feature/add-coder-types branch from d6ec864 to 9e52562 Compare May 29, 2022 18:21
@vovacodes
vovacodes requested a review from armaniferrante May 29, 2022 18:21
@armaniferrante
armaniferrante merged commit d83fcbf into otter-sec:master May 29, 2022
@armaniferrante

Copy link
Copy Markdown
Contributor

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)];
});

@snawaz snawaz Jun 8, 2023

Copy link
Copy Markdown
Contributor

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.

@snawaz snawaz Jun 8, 2023

Copy link
Copy Markdown
Contributor

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

@jamie-osec jamie-osec added this to the Pre-1.0 milestone Jun 24, 2026
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.

4 participants