Skip to content

Conversation

@mitinarseny
Copy link
Contributor

@mitinarseny mitinarseny commented Oct 16, 2025

This PR lets contracts to use serde_with crate by automatically adding #[serde_as] attribute when json serializer 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 build to work due to manual features activation via cli for near-sdk.

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.61%. Comparing base (5cc4fcf) to head (61322a8).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frol
Copy link
Collaborator

frol commented Oct 20, 2025

/compare

@github-actions
Copy link

Contract size report

Sizes are given in bytes.

contract master this branch difference
adder.wasm 66347 66347 +0%
approval_receiver.wasm 83957 84097 +0%
callback_results.wasm 80667 80667 +0%
cross_contract_high_level.wasm 71618 71618 +0%
cross_contract_low_level.wasm 67378 67378 +0%
defi.wasm 87540 87691 +0%
factory_contract_high_level.wasm 161720 161712 -0%
factory_contract_low_level.wasm 157182 157174 -0%
fungible_token.wasm 143922 144026 +0%
lockable_fungible_token.wasm 107021 107024 +0%
mission_control.wasm 108324 108324 +0%
mpc_contract.wasm 101052 101052 +0%
non_fungible_token.wasm 198488 198436 -0%
status_message.wasm 81766 81758 -0%
test_contract.wasm 20490 20490 +0%
token_receiver.wasm 83773 83894 +0%
versioned.wasm 89567 89567 +0%

Copy link
Collaborator

@PolyProgrammist PolyProgrammist left a 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

@mitinarseny
Copy link
Contributor Author

@PolyProgrammist Sure! I've added to #[near] macro docs along with doctests

@PolyProgrammist
Copy link
Collaborator

Looks good to me. @frol do you have anything to add?

@PolyProgrammist PolyProgrammist merged commit 5e1e9b7 into near:master Nov 1, 2025
42 of 43 checks passed
@github-project-automation github-project-automation bot moved this from NEW❗ to Shipped 🚀 in DevTools Nov 1, 2025
@frol frol mentioned this pull request Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Shipped 🚀

Development

Successfully merging this pull request may close these issues.

3 participants