fixes customNetPrealloc in genesis.nim: dealing with missing keys in genesis.json
This commit is contained in:
parent
2befeceeac
commit
fb7d5b5319
|
@ -35,14 +35,22 @@ func decodePrealloc(data: seq[byte]): GenesisAlloc =
|
||||||
proc customNetPrealloc(genesisBlock: JsonNode): GenesisAlloc =
|
proc customNetPrealloc(genesisBlock: JsonNode): GenesisAlloc =
|
||||||
result = newTable[EthAddress, GenesisAccount]()
|
result = newTable[EthAddress, GenesisAccount]()
|
||||||
for address, account in genesisBlock.pairs():
|
for address, account in genesisBlock.pairs():
|
||||||
|
let nonce = if "nonce" in account:
|
||||||
|
parseHexInt(account["nonce"].getStr).AccountNonce
|
||||||
|
else:
|
||||||
|
AccountNonce(0)
|
||||||
|
|
||||||
var acc = GenesisAccount(
|
var acc = GenesisAccount(
|
||||||
balance: fromHex(UInt256, account["balance"].getStr),
|
balance: fromHex(UInt256, account["balance"].getStr),
|
||||||
code: hexToSeqByte(account["code"].getStr),
|
code: hexToSeqByte(account["code"].getStr),
|
||||||
nonce: parseHexInt(account["nonce"].getStr).AccountNonce
|
nonce: nonce
|
||||||
)
|
)
|
||||||
let storage = account["storage"]
|
|
||||||
for k, v in storage:
|
if "storage" in account:
|
||||||
acc.storage[fromHex(UInt256, k)] = fromHex(UInt256, v.getStr)
|
let storage = account["storage"]
|
||||||
|
for k, v in storage:
|
||||||
|
acc.storage[fromHex(UInt256, k)] = fromHex(UInt256, v.getStr)
|
||||||
|
|
||||||
result[parseAddress(address)] = acc
|
result[parseAddress(address)] = acc
|
||||||
|
|
||||||
proc defaultGenesisBlockForNetwork*(id: PublicNetwork): Genesis =
|
proc defaultGenesisBlockForNetwork*(id: PublicNetwork): Genesis =
|
||||||
|
|
Loading…
Reference in New Issue