-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add discriminator to the account and allow encoding/decoding of non-account types #672
Conversation
fe9bc90
to
9a44563
Compare
9a44563
to
fc974f2
Compare
13cfae3
to
0f5ebb4
Compare
0f5ebb4
to
ea5f04f
Compare
ea5f04f
to
4585c2f
Compare
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.
overall looks good to me, just one small concern
if includeDiscriminator { | ||
desLen = 1 | ||
} | ||
named := make([]encodings.NamedTypeCodec, len(*def.Type.Fields)+desLen) |
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 there a nil pointer concern for dereferencing?
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.
I didn't add it in this PR, but I don't think so. The call only gets made if the type is a struct so I expect the fields would be present but empty if there are no fields.
There are a few derefs later on as well.
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.
lgtm for the solana specifics!
ideally someone from the chainreader side can also approve
4585c2f
to
d6720af
Compare
d6720af
to
558dbd8
Compare
Quality Gate passedIssues Measures |
When an account is stored from an Anchor contract on Solana, a discriminator is added as the first 8 bytes to ensure that the right data is being loaded. This was missed when decoding the account.
Additionally, users can define types and should be able to encode them to either sign or write to chain. This PR adds that ability as well.