diff --git a/.tool-versions b/.tool-versions index 9ed7760..991c54c 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -nim 1.4.2 +nim 1.4.4 diff --git a/nim.cfg b/nim.cfg new file mode 100644 index 0000000..64707c7 --- /dev/null +++ b/nim.cfg @@ -0,0 +1 @@ +--warning[ObservableStores]:"off" diff --git a/nitro/abi.nim b/nitro/abi.nim index 9b5c1bd..02f256e 100644 --- a/nitro/abi.nim +++ b/nitro/abi.nim @@ -2,6 +2,8 @@ import pkg/stew/endians2 import pkg/stint import ./types +include ./noerrors + type AbiEncoder* = object stack: seq[Tuple] @@ -13,8 +15,6 @@ type head: Slice[int] tail: seq[byte] -{.push raises:[].} - proc write*[T](encoder: var AbiEncoder, value: T) proc encode*[T](_: type AbiEncoder, value: T): seq[byte] diff --git a/nitro/channel.nim b/nitro/channel.nim index c8fa443..a2354ef 100644 --- a/nitro/channel.nim +++ b/nitro/channel.nim @@ -2,6 +2,8 @@ import pkg/nimcrypto import ./abi import ./types +include ./noerrors + export types type @@ -10,8 +12,6 @@ type participants*: seq[EthAddress] chainId*: UInt256 -{.push raises:[].} - proc getChannelId*(channel: Channel): array[32, byte] = var encoder= AbiEncoder.init() encoder.startTuple() diff --git a/nitro/helpers.nim b/nitro/helpers.nim index c1c7315..1c58b6a 100644 --- a/nitro/helpers.nim +++ b/nitro/helpers.nim @@ -1,13 +1,13 @@ import std/options import pkg/stew/results +include ./noerrors + export options export results -{.push raises:[].} - proc toOption*[T, E](res: Result[T, E]): Option[T] = if res.isOk: - res.value.some + res.unsafeGet().some else: T.none diff --git a/nitro/noerrors.nim b/nitro/noerrors.nim new file mode 100644 index 0000000..d2becfc --- /dev/null +++ b/nitro/noerrors.nim @@ -0,0 +1,8 @@ +## Include this file to indicate that your module does not raise Errors. +## Disables compiler hints about unused declarations in Nim < 1.4.0 + +when (NimMajor, NimMinor, NimPatch) >= (1, 4, 0): + {.push raises:[].} +else: + {.push raises: [Defect].} + {.hint[XDeclaredButNotUsed]: off.} diff --git a/nitro/outcome.nim b/nitro/outcome.nim index a21fa87..e1e173b 100644 --- a/nitro/outcome.nim +++ b/nitro/outcome.nim @@ -2,6 +2,8 @@ import pkg/nimcrypto import ./abi import ./types +include ./noerrors + export types export abi @@ -25,8 +27,6 @@ type targetChannelId*: array[32, byte] destinations*: seq[array[32, byte]] -{.push raises:[].} - proc encode*(encoder: var AbiEncoder, guarantee: Guarantee) = encoder.startTuple() encoder.startTuple() diff --git a/nitro/signature.nim b/nitro/signature.nim index 5fbde38..df29130 100644 --- a/nitro/signature.nim +++ b/nitro/signature.nim @@ -5,6 +5,8 @@ import pkg/stew/byteutils import ./state import ./helpers +include ./noerrors + export options export toPublicKey @@ -13,8 +15,6 @@ type PublicKey* = SkPublicKey Signature* = SkRecoverableSignature -{.push raises:[].} - proc rng(data: var openArray[byte]): bool = randomBytes(data) == data.len diff --git a/nitro/state.nim b/nitro/state.nim index 4f2aa4b..50f3736 100644 --- a/nitro/state.nim +++ b/nitro/state.nim @@ -4,6 +4,8 @@ import ./channel import ./outcome import ./abi +include ./noerrors + export types export channel export outcome @@ -27,8 +29,6 @@ type outcome*: seq[byte] appdata*: seq[byte] -{.push raises:[].} - proc fixedPart*(state: State): FixedPart = FixedPart( chainId: state.channel.chainId, diff --git a/nitro/types.nim b/nitro/types.nim index 3713816..0d6032f 100644 --- a/nitro/types.nim +++ b/nitro/types.nim @@ -3,6 +3,8 @@ import std/options import pkg/stint import pkg/stew/byteutils +include ./noerrors + export stint export options @@ -10,8 +12,6 @@ type UInt48* = range[0'u64..2'u64^48-1] EthAddress* = distinct array[20, byte] -{.push raises:[].} - proc toArray*(address: EthAddress): array[20, byte] = array[20, byte](address)