-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat-issues-242: borsh support #361
Conversation
examples/src/status-message-borsh.js
Outdated
return borshSerializeStatusMessage(value); | ||
}, | ||
deserializer(value) { | ||
return borshDeserializeStatusMessage(value); |
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.
Nice! Not related of this PR, but to ensure @NearBindgen(... serializer)
API does work, can you try if intentionally throw error here, the test will fail due to the error?
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.
add throw Error test after new commits, test steps,
serialize throw error as expected:
pnpm run build:status-message-serialize-err
pnpm run test:status-message-serialize-err
outputs:
pnpm run test:status-message-serialize-err
> examples@1.0.0 test:status-message-serialize-err /Users/qiuyongchun/workspace/near/near-sdk-js/examples
> ava __tests__/test-status-message-serialize-err.ava.js
Contract logs from dev-13382.test.near.get_status({"account_id":"test.near"}) view call: [ 'get_status for account_id test.near' ]
✔ Root gets null status (683ms)
✔ Ali sets status (2.5s)
pnpm run build:status-message-deserialize-err
pnpm run test:status-message-deserialize-err
deserialize error outputs:
pnpm run test:status-message-deserialize-err
> examples@1.0.0 test:status-message-deserialize-err /Users/qiuyongchun/workspace/near/near-sdk-js/examples
> ava __tests__/test-status-message-deserialize-err.ava.js
Contract logs from dev-15825.test.near.get_status({"account_id":"test.near"}) view call: [ 'get_status for account_id test.near' ]
✔ Root gets null status (677ms)
Contract logs from dev-15825.test.near.set_status({"message":"hello"}) call: [ 'ali.test.near set_status with message hello' ]
✔ Ali sets then gets status (5s)
─
2 tests passed
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.
Perfect!
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.
Looks great! Let's just wait borsh make a new release and bump the version. This can be considering finished.
ci failed possibly due to this issue: ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. You can try the comment way or update ci configuration to use latest pnpm v8, and locally re-create lockfile |
for 1.0 this won't change this is a breaking change. For 2.0 we'll based on community input. At best both should be supported and unused serializer should be tree shaked |
@ailisp ok makes sense, this PR looks good to me. |
Pre-flight checklist
Motivation
Test Plan
install deps:
build and run test code:
outputs:
Related issues/PRs
#242