From 61df75b1a12afb0257318c61e3865d15a6c3f921 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 23 Feb 2021 11:34:09 +0100 Subject: [PATCH] Fix ABI encoding of channel; should be in a tuple --- nitro/channel.nim | 2 ++ tests/nitro/testChannel.nim | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nitro/channel.nim b/nitro/channel.nim index c842cf8..5cc5809 100644 --- a/nitro/channel.nim +++ b/nitro/channel.nim @@ -12,7 +12,9 @@ type proc getChannelId*(channel: Channel): array[32, byte] = var writer: AbiWriter + writer.startTuple() writer.write(channel.chainId) writer.write(channel.participants) writer.write(channel.nonce) + writer.finishTuple() keccak256.digest(writer.finish()).data diff --git a/tests/nitro/testChannel.nim b/tests/nitro/testChannel.nim index 90f8906..29e7805 100644 --- a/tests/nitro/testChannel.nim +++ b/tests/nitro/testChannel.nim @@ -10,9 +10,11 @@ suite "channel": test "calculates channel id": var writer: AbiWriter + writer.startTuple() writer.write(channel.chainId) writer.write(channel.participants) writer.write(channel.nonce) + writer.finishTuple() let encoded = writer.finish() let hashed = keccak256.digest(encoded).data check getChannelId(channel) == hashed