forked from ethereum/hive
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mapper.jq
61 lines (58 loc) · 1.93 KB
/
mapper.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Removes all empty keys and values in input.
def remove_empty:
. | walk(
if type == "object" then
with_entries(
select(
.value != null and
.value != "" and
.value != [] and
.key != null and
.key != ""
)
)
else .
end
)
;
# Converts decimal string to number.
def to_int:
if . == null then . else .|tonumber end
;
# Converts "1" / "0" to boolean.
def to_bool:
if . == null then . else
if . == "1" then true else false end
end
;
# Replace config in input.
. + {
"config": {
"ethash": (if env.HIVE_CLIQUE_PERIOD then null else {} end),
"clique": (if env.HIVE_CLIQUE_PERIOD == null then null else {
"period": env.HIVE_CLIQUE_PERIOD|to_int,
} end),
"chainId": env.HIVE_CHAIN_ID|to_int,
"homesteadBlock": env.HIVE_FORK_HOMESTEAD|to_int,
"daoForkBlock": env.HIVE_FORK_DAO_BLOCK|to_int,
"daoForkSupport": env.HIVE_FORK_DAO_VOTE|to_bool,
"eip150Block": env.HIVE_FORK_TANGERINE|to_int,
"eip150Hash": env.HIVE_FORK_TANGERINE_HASH,
"eip155Block": env.HIVE_FORK_SPURIOUS|to_int,
"eip158Block": env.HIVE_FORK_SPURIOUS|to_int,
"byzantiumBlock": env.HIVE_FORK_BYZANTIUM|to_int,
"constantinopleBlock": env.HIVE_FORK_CONSTANTINOPLE|to_int,
"petersburgBlock": env.HIVE_FORK_PETERSBURG|to_int,
"istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int,
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeNetsplitBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
"cancunTime": env.HIVE_CANCUN_TIMESTAMP|to_int,
"terminalTotalDifficultyPassed": true,
}|remove_empty
}