From 2a8133b349d6aebbac95cd43458d475a16675515 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 19 Jan 2022 09:47:29 +0100 Subject: [PATCH] Fixes for Nim 1.2.x --- contractabi/address.nim | 3 ++- contractabi/selector.nim | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/contractabi/address.nim b/contractabi/address.nim index 30fb6f6..37dd964 100644 --- a/contractabi/address.nim +++ b/contractabi/address.nim @@ -23,4 +23,5 @@ func toArray*(address: Address): array[20, byte] = func `$`*(address: Address): string = "0x" & toHex(address.toArray) -func `==`*(a, b: Address): bool {.borrow.} +func `==`*(a, b: Address): bool = + a.toArray == b.toArray diff --git a/contractabi/selector.nim b/contractabi/selector.nim index fd46540..8e18049 100644 --- a/contractabi/selector.nim +++ b/contractabi/selector.nim @@ -34,17 +34,17 @@ solidityType bool, "bool" solidityType string, "string" solidityType Address, "address" -func solidityType*[N: static int](_: type array[N, byte]): string = - "bytes" & $N - -func solidityType*(_: type seq[byte]): string = - "bytes" - -func solidityType*[T, N](_: type array[N, T]): string = - solidityType(T) & "[" & $array[N, T].default.len & "]" +func solidityType*[N: static int, T](_: type array[N, T]): string = + when T is byte: + "bytes" & $N + else: + solidityType(T) & "[" & $N & "]" func solidityType*[T](_: type seq[T]): string = - solidityType(T) & "[]" + when T is byte: + "bytes" + else: + solidityType(T) & "[]" func solidityType*(Tuple: type tuple): string = var names: seq[string]