Repository navigation
fix(common): mOption returns None for 0, 0n and empty byte string - #882
Open
takinanton wants to merge 1 commit into
Open
takinanton wants to merge 1 commit into
takinanton wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
mOptionchecks the value with a plain truthiness test somOption(0),mOption(0n)andmOption("")all come back asmNone(). Those are valid Plutus data. AnOption<Int>holding zero or an empty byte string ends up on chain as None which is a different datum.mOption(0)serializes tod87a80whileoption(integer(0))givesd8799f00ff.It now returns None only when the value is missing. The JSON
optionhelper is not affected because it always gets an object.Affect components
@meshsdk/common@meshsdk/contract@meshsdk/core@meshsdk/core-cst@meshsdk/hydra@meshsdk/provider@meshsdk/react@meshsdk/svelte@meshsdk/transaction@meshsdk/walletType of Change
Related Issues
Did not find one.
Checklist
npm run test)npm run build)Additional Information
There were no tests for
mOptionso I added five to the mesh aliases test that compare its CBOR with the JSONoption. Three of them fail on main and all pass with the change. I built only@meshsdk/commonand@meshsdk/core-cstand ran the common jest suite. 23 suites pass.time.test.tsandtx-tester.test.tscould not load because they import@meshsdk/corewhich I did not build. I did not run the fullnpm run testornpm run buildso I left those two boxes unticked.🤖 Generated with Claude Code