You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds an explicit borsh.some(value) helper so TypeScript clients can serialize nested options where the outer option is Some and the inner option is None.
Previously, null always encoded as None, so Option<Option<T>> could encode:
None
Some(Some(value))
but could not represent:
Some(None)
With this change, callers can now encode Some(None) using:
borsh.some(null)
Testing
yarn build in ts/packages/borsh
yarn jest tests/coder-instructions.spec.ts --runInBand
I'm not super happy with this approach, as the decode change means a small breaking change and it just papers over an API design issue. I'm going to close this for now, but consider a PR to anchor-next which makes this API more intuitive
I'm not super happy with this approach, as the decode change means a small breaking change and it just papers over an API design issue. I'm going to close this for now, but consider a PR to anchor-next which makes this API more intuitive
thanks, that makes sense... i agree this is better handled as an API design change rather than trying to patch the current v1 behavior with a wrapper...
i will leave this PR closed and, if i pick this back up, i will target anchor-next with a cleaner nested option API instead of changing decode semantics in v1...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2435
Summary
Adds an explicit
borsh.some(value)helper so TypeScript clients can serialize nested options where the outer option isSomeand the inner option isNone.Previously,
nullalways encoded asNone, soOption<Option<T>>could encode:NoneSome(Some(value))but could not represent:
Some(None)With this change, callers can now encode
Some(None)using:Testing