2021-02-22 15:32:48 +01:00
|
|
|
import pkg/nimcrypto
|
2021-03-04 11:30:32 +01:00
|
|
|
import ../types
|
2021-02-22 15:32:48 +01:00
|
|
|
import ./abi
|
|
|
|
|
|
2021-03-09 09:37:27 +01:00
|
|
|
include questionable/errorban
|
2021-03-03 10:30:07 +01:00
|
|
|
|
2021-02-22 15:32:48 +01:00
|
|
|
export types
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
Channel* = object
|
|
|
|
|
nonce*: UInt48
|
|
|
|
|
participants*: seq[EthAddress]
|
|
|
|
|
chainId*: UInt256
|
|
|
|
|
|
|
|
|
|
proc getChannelId*(channel: Channel): array[32, byte] =
|
2021-02-25 09:11:46 +01:00
|
|
|
var encoder= AbiEncoder.init()
|
|
|
|
|
encoder.startTuple()
|
|
|
|
|
encoder.write(channel.chainId)
|
|
|
|
|
encoder.write(channel.participants)
|
|
|
|
|
encoder.write(channel.nonce)
|
|
|
|
|
encoder.finishTuple()
|
|
|
|
|
keccak256.digest(encoder.finish()).data
|