Skip to content
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

replace {.raises: [Defect].} with {.raises: [].} (Nim 1.6) #104

Merged
merged 1 commit into from
Oct 5, 2023
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 tests/test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ suite "Contracts":

let s = await ns.subscribe(Transfer) do (
fromAddr, toAddr: Address, value: UInt256)
{.raises: [Defect], gcsafe.}:
{.raises: [], gcsafe.}:
try:
echo "onTransfer: ", fromAddr, " transferred ", value, " to ", toAddr
inc notificationsReceived
Expand Down
2 changes: 1 addition & 1 deletion tests/test_deposit_contract.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ suite "Deposit contract":

let s = await ns.subscribe(DepositEvent, %*{"fromBlock": "0x0"}) do (
pubkey: DynamicBytes[0, 48], withdrawalCredentials: DynamicBytes[0, 32], amount: DynamicBytes[0, 8], signature: DynamicBytes[0, 96], merkleTreeIndex: DynamicBytes[0, 8])
{.raises: [Defect], gcsafe.}:
{.raises: [], gcsafe.}:
try:
echo "onDeposit"
echo "pubkey: ", pubkey
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ suite "Logs":

let s = await ns.subscribe(MyEvent, %*{"fromBlock": "0x0"}) do (
sender: Address, value: UInt256)
{.raises: [Defect], gcsafe.}:
{.raises: [], gcsafe.}:
try:
echo "onEvent: ", sender, " value ", value
inc notificationsReceived
Expand Down
22 changes: 10 additions & 12 deletions web3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ type
defaultAccount*: Address
privateKey*: Option[PrivateKey]
lastKnownNonce*: Option[Nonce]
onDisconnect*: proc() {.gcsafe, raises: [Defect].}
onDisconnect*: proc() {.gcsafe, raises: [].}

Sender*[T] = ref object
web3*: Web3
contractAddress*: Address

EncodeResult* = tuple[dynamic: bool, data: string]

SubscriptionEventHandler* = proc (j: JsonNode) {.gcsafe, raises: [Defect].}
SubscriptionErrorHandler* = proc (err: CatchableError) {.gcsafe, raises: [Defect].}
SubscriptionEventHandler* = proc (j: JsonNode) {.gcsafe, raises: [].}
SubscriptionErrorHandler* = proc (err: CatchableError) {.gcsafe, raises: [].}

BlockHeaderHandler* = proc (b: BlockHeader) {.gcsafe, raises: [Defect].}
BlockHeaderHandler* = proc (b: BlockHeader) {.gcsafe, raises: [].}

Subscription* = ref object
id*: string
Expand Down Expand Up @@ -154,10 +154,10 @@ proc subscribeForLogs*(w: Web3, options: JsonNode,
result.historicalEventsProcessed = true

proc subscribeForBlockHeaders*(w: Web3,
blockHeadersCallback: proc(b: BlockHeader) {.gcsafe, raises: [Defect].},
blockHeadersCallback: proc(b: BlockHeader) {.gcsafe, raises: [].},
errorHandler: SubscriptionErrorHandler): Future[Subscription]
{.async.} =
proc eventHandler(json: JsonNode) {.gcsafe, raises: [Defect].} =
proc eventHandler(json: JsonNode) {.gcsafe, raises: [].} =
var blk: BlockHeader
try:
fromJson(json, "result", blk)
Expand Down Expand Up @@ -465,13 +465,11 @@ macro contract*(cname: untyped, body: untyped): untyped =
procTy = nnkProcTy.newTree(params, newEmptyNode())
signature = getSignature(obj.eventObject)

# generated with dumpAstGen - produces "{.raises: [Defect], gcsafe.}"
# generated with dumpAstGen - produces "{.raises: [], gcsafe.}"
let pragmas = nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("raises"),
nnkBracket.newTree(
newIdentNode("Defect")
)
nnkBracket.newTree()
),
newIdentNode("gcsafe")
)
Expand Down Expand Up @@ -502,7 +500,7 @@ macro contract*(cname: untyped, body: untyped): untyped =
withHistoricEvents = true): Future[Subscription] =
let options = addAddressAndSignatureToOptions(options, s.contractAddress, eventTopic(`cbident`))

proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [Defect].} =
proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} =
try:
`argParseBody`
`call`
Expand All @@ -519,7 +517,7 @@ macro contract*(cname: untyped, body: untyped): untyped =
withHistoricEvents = true): Future[Subscription] =
let options = addAddressAndSignatureToOptions(options, s.contractAddress, eventTopic(`cbident`))

proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [Defect].} =
proc eventHandler(`jsonIdent`: JsonNode) {.gcsafe, raises: [].} =
try:
`argParseBody`
`callWithRawData`
Expand Down
6 changes: 4 additions & 2 deletions web3/confutils_defs.nim
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{.push raises: [].}

import
ethtypes

func parseCmdArg*(T: type Address, input: TaintedString): T
{.raises: [ValueError, Defect].} =
{.raises: [ValueError].} =
fromHex(T, string input)

func completeCmdArg*(T: type Address, input: TaintedString): seq[string] =
@[]

func parseCmdArg*(T: type BlockHash, input: TaintedString): T
{.raises: [ValueError, Defect].} =
{.raises: [ValueError].} =
fromHex(T, string input)

func completeCmdArg*(T: type BlockHash, input: TaintedString): seq[string] =
Expand Down