Open mustermeiszer opened 2 years ago
Note: Error originates from macro in jsonrpc
here https://github.com/paritytech/jsonrpc/blob/0a2702595b8831a9a30dec7dc476157c648c361c/derive/src/to_delegate.rs#L285.
I also hard-coded the balance as u128
to check whether I mixed the final types in the runtime-api impl. But all compiles fine.
There are bugs around serde-json and u128
serialized as a serde_json::Value
or something. I don't remember all the details, sorry! But now as we have jsonrpsee, this is maybe solved? Maybe @niklasad1 can help here.
I think this particular usecase should work in jsonrpsee as long plain u128/i128
are used and not in a type with serde flatten/untagged attributes
. This will only work in the servers, the clients still have this issue.
with serde flatten/untagged
it is pretty much the same story you can find more information in https://github.com/paritytech/jsonrpsee/issues/480
but the jsonrpc crate
supports arbitrary precision
which jsonrpsee doesn't but nothing that prevents folks from enabling that feature on serde_json
themselves but then you will run in weird bugs with tagged enums (such as Id::Number(u64)
) will not work.
It is known issue u128 doesn't play nicely with RPC. See my fix in Substrate https://github.com/paritytech/substrate/pull/4898
I am getting this error when querying a custom rpc-endpoint.
Code
RPC- API implementation:
Runtime-api implementation:
where
Balance
is atype Balance = u128
Version
polkadot-v0.9.17
polkadot-v0.9.17
release-v0.9.17