-
Notifications
You must be signed in to change notification settings - Fork 4
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
Remove overloaded UInt256.fromJson #74
Conversation
Rely instead on UInt256.fromJson from nim-serde, which deserializes an empty string for ?UInt256 into UInt256.none. Previously, empty strings were deserialized into 0.u256. BlockNumber was using this deserialization, and it appears that deserializing a missing block number from a TransactionReceipt into 0 might actually cause some issues when waiting on block confirmations.
Awesome, one small observation:
While you are right that this would also be an issue, in our case the serde calls are actually in scope as well (conversions.nim exports serde). The problem is that the conversion for UInt256 is less specific in serde as it uses |
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.
LGTM!
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.
I like it. It removes code 😁
Please address the comment, then I think it's good to go!
ethers.nimble
Outdated
requires "serde >= 0.1.1 & < 0.2.0" | ||
requires "serde#e889b76dda0636421484dcda1535aa0911345244" |
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.
I don't want ethers to be pinned to a specific git hash of serde. Can't you make a release of serde instead?
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.
Yes, good catch. This was meant to be changed when the serde PR was merged and a release cut. Updated.
Rely instead on
UInt256.fromJson
fromnim-serde
to avoid overload symbol collisions.Bump nim-serde to version that contains a workaround for the following:
When calling
createRpcSigs
fromnim-json-rpc
, thereadValue
mixin is called, which captures allreadValue
overloads in scope. The issue is that thereadValue
overload in ethers calls a genericfromJson
, and only thefromJson
generic overloads defined in ethers are in scope. However, implementing applications, egnim-codex
defined otherfromJson
generic overloads that are not in scope at the time of thereadValue
mixin call. The important part of this issue is that bothnim-codex
andethers
overload the samefromJson
(UInt256
). The result, is that whennim-codex
callsUInt256.fromJson
, it will not know about the overload innim-codex
, and instead always call theethers
overload, which is not correct.This PR removes the ethers
UInt256.fromJson
overload as a partial solution to the issue. This overload is not necessary as theUInt256.fromJson
achieves mostly the same result. The difference is that empty strings were deserialized into0.u256
. This could possibly affect:BlockTag
from being deserialized when there's an empty string: fixed in fix: deserialize BlockTag from empty string #73.blockNumber
(UInt256) from being deserialized when there's an empty string. It appears that deserializing a missing block number from a TransactionReceipt into 0 might have actually caused some issues when waiting on block confirmations, and this change should alleviate any of those issues.are not all yet in scope at the time of the
readValue
mixin call (some are, but others are defined in an implementing application, egnim-codex
). This basically forcesreadValue
to use thefromJson
from ethers which get muddled up in thereadValue
mixin scope (), which deserializes an empty string for?UInt256
intoUInt256.none
. Previously, .