2019-09-09 19:06:29 +00:00
|
|
|
import
|
2019-11-25 14:36:25 +00:00
|
|
|
confutils, os, strutils, chronicles, json_serialization,
|
2019-09-09 19:06:29 +00:00
|
|
|
nimcrypto/utils,
|
2019-10-25 10:59:56 +00:00
|
|
|
../beacon_chain/spec/[crypto, datatypes, digest],
|
2020-04-23 18:58:54 +00:00
|
|
|
../beacon_chain/ssz
|
2019-09-09 19:06:29 +00:00
|
|
|
|
|
|
|
# TODO turn into arguments
|
|
|
|
cli do(kind: string, file: string):
|
|
|
|
|
|
|
|
template printit(t: untyped) {.dirty.} =
|
|
|
|
let v =
|
|
|
|
if cmpIgnoreCase(ext, ".ssz") == 0:
|
|
|
|
SSZ.loadFile(file, t)
|
|
|
|
elif cmpIgnoreCase(ext, ".json") == 0:
|
|
|
|
JSON.loadFile(file, t)
|
|
|
|
else:
|
|
|
|
echo "Unknown file type: ", ext
|
|
|
|
quit 1
|
|
|
|
|
|
|
|
echo hash_tree_root(v).data.toHex(true)
|
|
|
|
|
|
|
|
let ext = splitFile(file).ext
|
|
|
|
|
|
|
|
case kind
|
|
|
|
of "attester_slashing": printit(AttesterSlashing)
|
|
|
|
of "attestation": printit(Attestation)
|
|
|
|
of "block": printit(BeaconBlock)
|
|
|
|
of "block_body": printit(BeaconBlockBody)
|
|
|
|
of "block_header": printit(BeaconBlockHeader)
|
|
|
|
of "deposit": printit(Deposit)
|
|
|
|
of "deposit_data": printit(DepositData)
|
|
|
|
of "eth1_data": printit(Eth1Data)
|
2020-04-23 18:58:54 +00:00
|
|
|
of "state": printit(BeaconStateRef)
|
2019-09-09 19:06:29 +00:00
|
|
|
of "proposer_slashing": printit(ProposerSlashing)
|
|
|
|
of "voluntary_exit": printit(VoluntaryExit)
|