1
1
/* global __dirname process */
2
2
import { Command } from 'commander' ;
3
3
4
- import { assert , details as X } from '@agoric/assert' ;
4
+ import { assert , details as X , quote as q } from '@agoric/assert' ;
5
+ import { Nat } from '@agoric/nat' ;
5
6
import cosmosMain from './cosmos' ;
6
7
import deployMain from './deploy' ;
7
8
import initMain from './init' ;
@@ -32,6 +33,15 @@ const main = async (progname, rawArgs, powers) => {
32
33
return true ;
33
34
}
34
35
36
+ const makeParseNatValue = flag => value => {
37
+ try {
38
+ const bi = BigInt ( value ) ;
39
+ return Nat ( bi ) ;
40
+ } catch ( e ) {
41
+ assert . fail ( X `${ q ( flag ) } must be a natural number, not ${ value } ; ${ e } ` ) ;
42
+ }
43
+ } ;
44
+
35
45
function subMain ( fn , args , options ) {
36
46
return fn ( progname , args , powers , options ) . then (
37
47
// This seems to be the only way to propagate the exit code.
@@ -111,6 +121,28 @@ const main = async (progname, rawArgs, powers) => {
111
121
program
112
122
. command ( 'set-defaults <program> <config-dir>' )
113
123
. description ( 'update the configuration files for <program> in <config-dir>' )
124
+ . option (
125
+ '--bootstrap-address <bech32>' ,
126
+ 'the chain address which should receive urun' ,
127
+ '' ,
128
+ )
129
+ . option (
130
+ '--bootstrap-value <number>' ,
131
+ 'the amount of urun to give to bootstrap-address' ,
132
+ makeParseNatValue ( 'bootstrap-value' ) ,
133
+ 0n ,
134
+ )
135
+ . option (
136
+ '--donation-value <number>' ,
137
+ 'the amount of urun to transfer from bootsrtap-address to each client' ,
138
+ makeParseNatValue ( 'donation-value' ) ,
139
+ 0n ,
140
+ )
141
+ . option (
142
+ '--export-metrics' ,
143
+ 'open ports to export Prometheus metrics' ,
144
+ false ,
145
+ )
114
146
. option (
115
147
'--import-from <dir>' ,
116
148
'import the exported configuration from <dir>' ,
@@ -126,11 +158,6 @@ const main = async (progname, rawArgs, powers) => {
126
158
'set the config.toml p2p.unconditional_peer_ids value' ,
127
159
'' ,
128
160
)
129
- . option (
130
- '--export-metrics' ,
131
- 'open ports to export Prometheus metrics' ,
132
- false ,
133
- )
134
161
. action ( async ( prog , configDir , cmd ) => {
135
162
const opts = { ...program . opts ( ) , ...cmd . opts ( ) } ;
136
163
return subMain ( setDefaultsMain , [ 'set-defaults' , prog , configDir ] , opts ) ;
0 commit comments