From 90c1f300d2833637215d98adc127eaa243d219d1 Mon Sep 17 00:00:00 2001 From: Marcin Czenko Date: Tue, 10 Dec 2024 15:57:08 +0100 Subject: [PATCH] adds number getter for BlockTags with number --- ethers/blocktag.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethers/blocktag.nim b/ethers/blocktag.nim index 0de99c9..3f31b5c 100644 --- a/ethers/blocktag.nim +++ b/ethers/blocktag.nim @@ -1,4 +1,5 @@ import pkg/stint +import pkg/questionable {.push raises:[].} @@ -41,3 +42,10 @@ func `==`*(a, b: BlockTag): bool = a.stringValue == b.stringValue of numberBlockTag: a.numberValue == b.numberValue + +func number*(blockTag: BlockTag): ?UInt256 = + case blockTag.kind + of stringBlockTag: + UInt256.none + of numberBlockTag: + blockTag.numberValue.some