diff --git a/tests/helpers/utils.nim b/tests/helpers/utils.nim index 5008329..93d9816 100644 --- a/tests/helpers/utils.nim +++ b/tests/helpers/utils.nim @@ -6,9 +6,6 @@ import ../../web3/primitives proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObject] {.async.} = - let provider = web3.provider - let accounts = await provider.eth_accounts() - var code = code var tr: EthSend tr.`from` = web3.defaultAccount diff --git a/tests/test_contracts.nim b/tests/test_contracts.nim index 2507fa8..74137fe 100644 --- a/tests/test_contracts.nim +++ b/tests/test_contracts.nim @@ -211,7 +211,7 @@ suite "Contracts": fromAddr, toAddr: Address, value: UInt256) {.raises: [], gcsafe.}: try: - echo "onTransfer: ", fromAddr, " transferred ", value, " to ", toAddr + echo "onTransfer: ", fromAddr, " transferred ", value.toHex, " to ", toAddr inc notificationsReceived assert(fromAddr == web3.defaultAccount) assert((notificationsReceived == 1 and value == 50.u256) or @@ -222,12 +222,15 @@ suite "Contracts": # chronos still raises exceptions which inherit directly from Exception doAssert false, err.msg - echo "getbalance (now): ", await ns.getBalance(web3.defaultAccount).call() - echo "getbalance (after creation): ", await ns.getBalance(web3.defaultAccount).call(blockNumber = deployedAtBlock) + let balNow = await ns.getBalance(web3.defaultAccount).call() + echo "getbalance (now): ", balNow.toHex + let balNew = await ns.getBalance(web3.defaultAccount).call(blockNumber = deployedAtBlock) + echo "getbalance (after creation): ", balNew.toHex # Let's try to get the balance at a point in time where the contract was not deployed yet: try: - echo "getbalance (first block): ", await ns.getBalance(web3.defaultAccount).call(blockNumber = 1'u64) + let balFirst = await ns.getBalance(web3.defaultAccount).call(blockNumber = 1'u64) + echo "getbalance (first block): ", balFirst.toHex except CatchableError as err: echo "getbalance (first block): ", err.msg diff --git a/tests/test_logs.nim b/tests/test_logs.nim index 97084de..0475de5 100644 --- a/tests/test_logs.nim +++ b/tests/test_logs.nim @@ -79,7 +79,7 @@ suite "Logs": sender: Address, value: UInt256) {.raises: [], gcsafe.}: try: - echo "onEvent: ", sender, " value ", value + echo "onEvent: ", sender, " value ", value.toHex inc notificationsReceived if notificationsReceived == invocationsBefore + invocationsAfter: diff --git a/web3.nim b/web3.nim index 67e5056..77aeac7 100644 --- a/web3.nim +++ b/web3.nim @@ -196,7 +196,7 @@ proc unsubscribe*(s: Subscription): Future[void] {.async.} = discard await s.web3.provider.eth_unsubscribe(s.id) proc getJsonLogs(s: Web3SenderImpl, topic: openarray[byte], - fromBlock, toBlock = none(RtBlockIdentifier), + fromBlock = none(RtBlockIdentifier), toBlock = none(RtBlockIdentifier), blockHash = none(BlockHash)): Future[JsonNode] = var options = newJObject() options["address"] = %s.contractAddress @@ -216,7 +216,7 @@ proc getJsonLogs(s: Web3SenderImpl, topic: openarray[byte], proc getJsonLogs*[TContract](s: Sender[TContract], EventName: type, - fromBlock, toBlock = none(RtBlockIdentifier), + fromBlock= none(RtBlockIdentifier), toBlock = none(RtBlockIdentifier), blockHash = none(BlockHash)): Future[JsonNode] {.inline.} = mixin eventTopic getJsonLogs(s.sender, eventTopic(EventName)) diff --git a/web3.nimble b/web3.nimble index 719bdec..5233a47 100644 --- a/web3.nimble +++ b/web3.nimble @@ -16,7 +16,8 @@ license = "MIT or Apache License 2.0" ### Dependencies requires "nim >= 1.6.0" requires "chronicles" -requires "chronos" +requires "chronos#head" +requires "bearssl#head" requires "eth" requires "faststreams" requires "json_rpc" diff --git a/web3/contract_dsl.nim b/web3/contract_dsl.nim index a64f1c0..d49c3ca 100644 --- a/web3/contract_dsl.nim +++ b/web3/contract_dsl.nim @@ -295,7 +295,7 @@ macro contract*(cname: untyped, body: untyped): untyped = options: JsonNode, `callbackIdent`: `procTy`, errorHandler: SubscriptionErrorHandler, - withHistoricEvents = true): Future[Subscription] = + withHistoricEvents = true): Future[Subscription] {.used.} = proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} = try: `argParseBody` @@ -310,7 +310,7 @@ macro contract*(cname: untyped, body: untyped): untyped = options: JsonNode, `callbackIdent`: `procTyWithRawData`, errorHandler: SubscriptionErrorHandler, - withHistoricEvents = true): Future[Subscription] = + withHistoricEvents = true): Future[Subscription] {.used.} = proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} = try: `argParseBody`