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