Skip to content

Commit 958d7b4

Browse files
authored
Remove overloaded UInt256.fromJson (#74)
* Remove overloaded UInt256.fromJson 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. * bump version of serde * Remove "v" from version in `.nimble` * Fix nimble serde version again ¯\_(ツ)_/¯
1 parent 6393546 commit 958d7b4

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

ethers.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ requires "chronos >= 4.0.0 & < 4.1.0"
99
requires "contractabi >= 0.6.0 & < 0.7.0"
1010
requires "questionable >= 0.10.2 & < 0.11.0"
1111
requires "json_rpc >= 0.4.0 & < 0.5.0"
12-
requires "serde >= 0.1.1 & < 0.2.0"
12+
requires "serde >= 1.2.1 & < 1.3.0"
1313
requires "stint"
1414
requires "stew"
1515
requires "eth"

ethers/providers/jsonrpc/conversions.nim

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ func fromJson(_: type Address, json: JsonNode): ?!Address =
4747
func `%`*(integer: UInt256): JsonNode =
4848
%("0x" & toHex(integer))
4949
50-
func fromJson*(_: type UInt256, json: JsonNode): ?!UInt256 =
51-
without result =? UInt256.fromHex(json.getStr()).catch, error:
52-
return UInt256.failure error.msg
53-
success result
54-
5550
# Transaction
5651
5752
# TODO: add option that ignores none Option[T]

testmodule/providers/jsonrpc/testConversions.nim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ suite "JSON Conversions":
2626
json["number"] = newJString("")
2727

2828
let blk2 = !Block.fromJson(json)
29-
check blk2.number.isSome
30-
check blk2.number.get.isZero
29+
check blk2.number.isNone
3130

3231
test "missing block hash in Block isNone":
3332

@@ -78,8 +77,7 @@ suite "JSON Conversions":
7877
json["blockNumber"] = newJString("")
7978
without receipt2 =? TransactionReceipt.fromJson(json):
8079
fail
81-
check receipt2.blockNumber.isSome
82-
check receipt2.blockNumber.get.isZero
80+
check receipt2.blockNumber.isNone
8381

8482
test "missing block hash in TransactionReceipt isNone":
8583
let json = %*{

0 commit comments

Comments
 (0)