Skip to content

Fix u128 RPC serialization/deserialization#307

Merged
koushiro merged 9 commits intodevelop-2.0from
koushiro/fix-u128-rpc-serialization
Oct 23, 2020
Merged

Fix u128 RPC serialization/deserialization#307
koushiro merged 9 commits intodevelop-2.0from
koushiro/fix-u128-rpc-serialization

Conversation

@koushiro
Copy link
Contributor

@koushiro koushiro commented Oct 23, 2020

Previously, the Balance, Price and Weight were serialized directly into u128 numbers
in #238, but polkadot.js could not parse them successfully.

Therefore, it is necessary to serialize Balance, Price, and Weight back to String.
Unlike before, the serialization conversion of Balance and Price only occurs at the RPC layer and does not involve the types in the pallet (because the Weight is an type alias of u128, so we use serde derive directly on the type to complete the serialization conversion).

Signed-off-by: koushiro koushiro.cqx@gmail.com

Previously, the `Balance`, `Price` and `Weight` were serialized directly into u128 numbers
in #238, but polkadot.js could not parse them successfully.

Therefore, it is necessary to serialize `Balance`, `Price`, and `Weight` back to String.
Unlike before, the serialization conversion of `Balance` and `Price` only occurs at the RPC layer
and does not involve the types in the pallet (because the `Weight` is an alias of u128,
so we use serde derive directly on the type to complete the serialization conversion).

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro koushiro requested review from atenjin and liuchengxu and removed request for liuchengxu October 23, 2020 02:15
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Copy link
Contributor

@liuchengxu liuchengxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Rust code looks good to me except the unnecessary trait renamings. Furthermore, chainx_types should be updated accordingly.

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro koushiro force-pushed the koushiro/fix-u128-rpc-serialization branch from 04947a3 to 2d08164 Compare October 23, 2020 08:35
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro koushiro requested a review from liuchengxu October 23, 2020 09:01
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
@koushiro koushiro merged commit 43a33fb into develop-2.0 Oct 23, 2020
@koushiro koushiro deleted the koushiro/fix-u128-rpc-serialization branch October 23, 2020 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants