mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-05 15:13:07 +00:00
- rewrite ABI encoding to properly handle dynamic tuples - surround Nitro types with extra tuples to match javascript - test with examples of encoding extracted from javascript
21 lines
446 B
Nim
21 lines
446 B
Nim
import pkg/nimcrypto
|
|
import ./abi
|
|
import ./types
|
|
|
|
export types
|
|
|
|
type
|
|
Channel* = object
|
|
nonce*: UInt48
|
|
participants*: seq[EthAddress]
|
|
chainId*: UInt256
|
|
|
|
proc getChannelId*(channel: Channel): array[32, byte] =
|
|
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
|