-
Notifications
You must be signed in to change notification settings - Fork 267
feat(near-sdk): use #[serde_as] for #[near(serializers = [json])] #1393
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1393 +/- ##
==========================================
- Coverage 80.87% 80.61% -0.26%
==========================================
Files 104 104
Lines 15464 15470 +6
==========================================
- Hits 12506 12471 -35
- Misses 2958 2999 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/compare |
Contract size reportSizes are given in bytes.
|
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.
Hi! Could you please add a test that shows the benefit from the feature
|
@PolyProgrammist Sure! I've added to |
|
Looks good to me. @frol do you have anything to add? |
This PR lets contracts to use serde_with crate by automatically adding
#[serde_as]attribute whenjsonserializer is enabled in#[near]macro.serde_with leverages Rust type system and lets to avoid introducing newtypes (such as
U128) to just redefine how to serialize/deserialize the underlying type. Newtype approach is very cumbersome and inconvenient to work with, especially when dealing with nested collections.Right now smart-contract devs are forced to use some dirty hacks in order to achieve it, as well as introduce fake features that are required for
cargo near buildto work due to manual features activation via cli fornear-sdk.