Skip to content

Remove overloaded UInt256.fromJson #74

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

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethers.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ requires "chronos >= 4.0.0 & < 4.1.0"
requires "contractabi >= 0.6.0 & < 0.7.0"
requires "questionable >= 0.10.2 & < 0.11.0"
requires "json_rpc >= 0.4.0 & < 0.5.0"
requires "serde >= 0.1.1 & < 0.2.0"
requires "serde >= 1.2.1 & < 1.3.0"
requires "stint"
requires "stew"
requires "eth"
Expand Down
5 changes: 0 additions & 5 deletions ethers/providers/jsonrpc/conversions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ func fromJson(_: type Address, json: JsonNode): ?!Address =
func `%`*(integer: UInt256): JsonNode =
%("0x" & toHex(integer))

func fromJson*(_: type UInt256, json: JsonNode): ?!UInt256 =
without result =? UInt256.fromHex(json.getStr()).catch, error:
return UInt256.failure error.msg
success result

# Transaction

# TODO: add option that ignores none Option[T]
Expand Down
6 changes: 2 additions & 4 deletions testmodule/providers/jsonrpc/testConversions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ suite "JSON Conversions":
json["number"] = newJString("")

let blk2 = !Block.fromJson(json)
check blk2.number.isSome
check blk2.number.get.isZero
check blk2.number.isNone

test "missing block hash in Block isNone":

Expand Down Expand Up @@ -78,8 +77,7 @@ suite "JSON Conversions":
json["blockNumber"] = newJString("")
without receipt2 =? TransactionReceipt.fromJson(json):
fail
check receipt2.blockNumber.isSome
check receipt2.blockNumber.get.isZero
check receipt2.blockNumber.isNone

test "missing block hash in TransactionReceipt isNone":
let json = %*{
Expand Down
Loading