2021-02-22 15:32:48 +01:00
|
|
|
import pkg/nimcrypto
|
2021-03-09 11:07:35 +01:00
|
|
|
import ../basics
|
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-03-09 11:07:35 +01:00
|
|
|
export basics
|
2021-02-22 15:32:48 +01:00
|
|
|
|
|
|
|
|
type
|
2021-03-09 12:41:51 +01:00
|
|
|
ChannelDefinition* = object
|
2021-02-22 15:32:48 +01:00
|
|
|
nonce*: UInt48
|
|
|
|
|
participants*: seq[EthAddress]
|
|
|
|
|
chainId*: UInt256
|
|
|
|
|
|
2021-03-17 12:22:00 +01:00
|
|
|
func getChannelId*(channel: ChannelDefinition): Destination =
|
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()
|
2021-03-09 14:02:01 +01:00
|
|
|
Destination(keccak256.digest(encoder.finish()).data)
|