Skip to content

Commit be1bb30

Browse files
committed
Reduce compiler warnings when using Nim v2
1 parent 23c06ca commit be1bb30

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

tests/helpers/utils.nim

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import
66
../../web3/primitives
77

88
proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObject] {.async.} =
9-
let provider = web3.provider
10-
let accounts = await provider.eth_accounts()
11-
129
var code = code
1310
var tr: EthSend
1411
tr.`from` = web3.defaultAccount

tests/test_contracts.nim

+7-4
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ suite "Contracts":
211211
fromAddr, toAddr: Address, value: UInt256)
212212
{.raises: [], gcsafe.}:
213213
try:
214-
echo "onTransfer: ", fromAddr, " transferred ", value, " to ", toAddr
214+
echo "onTransfer: ", fromAddr, " transferred ", value.toHex, " to ", toAddr
215215
inc notificationsReceived
216216
assert(fromAddr == web3.defaultAccount)
217217
assert((notificationsReceived == 1 and value == 50.u256) or
@@ -222,12 +222,15 @@ suite "Contracts":
222222
# chronos still raises exceptions which inherit directly from Exception
223223
doAssert false, err.msg
224224

225-
echo "getbalance (now): ", await ns.getBalance(web3.defaultAccount).call()
226-
echo "getbalance (after creation): ", await ns.getBalance(web3.defaultAccount).call(blockNumber = deployedAtBlock)
225+
let balNow = await ns.getBalance(web3.defaultAccount).call()
226+
echo "getbalance (now): ", balNow.toHex
227+
let balNew = await ns.getBalance(web3.defaultAccount).call(blockNumber = deployedAtBlock)
228+
echo "getbalance (after creation): ", balNew.toHex
227229

228230
# Let's try to get the balance at a point in time where the contract was not deployed yet:
229231
try:
230-
echo "getbalance (first block): ", await ns.getBalance(web3.defaultAccount).call(blockNumber = 1'u64)
232+
let balFirst = await ns.getBalance(web3.defaultAccount).call(blockNumber = 1'u64)
233+
echo "getbalance (first block): ", balFirst.toHex
231234
except CatchableError as err:
232235
echo "getbalance (first block): ", err.msg
233236

tests/test_logs.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ suite "Logs":
7979
sender: Address, value: UInt256)
8080
{.raises: [], gcsafe.}:
8181
try:
82-
echo "onEvent: ", sender, " value ", value
82+
echo "onEvent: ", sender, " value ", value.toHex
8383
inc notificationsReceived
8484

8585
if notificationsReceived == invocationsBefore + invocationsAfter:

web3.nim

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ proc unsubscribe*(s: Subscription): Future[void] {.async.} =
196196
discard await s.web3.provider.eth_unsubscribe(s.id)
197197

198198
proc getJsonLogs(s: Web3SenderImpl, topic: openarray[byte],
199-
fromBlock, toBlock = none(RtBlockIdentifier),
199+
fromBlock = none(RtBlockIdentifier), toBlock = none(RtBlockIdentifier),
200200
blockHash = none(BlockHash)): Future[JsonNode] =
201201
var options = newJObject()
202202
options["address"] = %s.contractAddress
@@ -216,7 +216,7 @@ proc getJsonLogs(s: Web3SenderImpl, topic: openarray[byte],
216216

217217
proc getJsonLogs*[TContract](s: Sender[TContract],
218218
EventName: type,
219-
fromBlock, toBlock = none(RtBlockIdentifier),
219+
fromBlock= none(RtBlockIdentifier), toBlock = none(RtBlockIdentifier),
220220
blockHash = none(BlockHash)): Future[JsonNode] {.inline.} =
221221
mixin eventTopic
222222
getJsonLogs(s.sender, eventTopic(EventName))

web3.nimble

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ license = "MIT or Apache License 2.0"
1616
### Dependencies
1717
requires "nim >= 1.6.0"
1818
requires "chronicles"
19-
requires "chronos"
19+
requires "chronos#head"
20+
requires "bearssl#head"
2021
requires "eth"
2122
requires "faststreams"
2223
requires "json_rpc"

web3/contract_dsl.nim

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ macro contract*(cname: untyped, body: untyped): untyped =
295295
options: JsonNode,
296296
`callbackIdent`: `procTy`,
297297
errorHandler: SubscriptionErrorHandler,
298-
withHistoricEvents = true): Future[Subscription] =
298+
withHistoricEvents = true): Future[Subscription] {.used.} =
299299
proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} =
300300
try:
301301
`argParseBody`
@@ -310,7 +310,7 @@ macro contract*(cname: untyped, body: untyped): untyped =
310310
options: JsonNode,
311311
`callbackIdent`: `procTyWithRawData`,
312312
errorHandler: SubscriptionErrorHandler,
313-
withHistoricEvents = true): Future[Subscription] =
313+
withHistoricEvents = true): Future[Subscription] {.used.} =
314314
proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} =
315315
try:
316316
`argParseBody`

0 commit comments

Comments
 (0)