File tree 3 files changed +22
-0
lines changed
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Commands:
43
43
meridian set-round-reward < reward> Set the round reward
44
44
meridian tick Trigger a tick
45
45
meridian available-balance Get the balance available
46
+ meridian add-admin < admin> Add a contract admin
46
47
47
48
Options:
48
49
-a, --address Contract address (or $MERIDIAN_ADDRESS ) [string] [required]
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { setNextRoundLength } from '../commands/set-next-round-length.js'
22
22
import { setRoundReward } from '../commands/set-round-reward.js'
23
23
import { tick } from '../commands/tick.js'
24
24
import { availableBalance } from '../commands/available-balance.js'
25
+ import { addAdmin } from '../commands/add-admin.js'
25
26
26
27
const pkg = JSON . parse (
27
28
await fs . readFile (
@@ -126,6 +127,12 @@ yargs(hideBin(process.argv))
126
127
yargs => yargs ,
127
128
availableBalance
128
129
)
130
+ . command (
131
+ 'add-admin <admin>' ,
132
+ 'Add a contract admin' ,
133
+ yargs => yargs . positional ( 'admin' , { type : 'string' } ) ,
134
+ addAdmin
135
+ )
129
136
. demandCommand ( )
130
137
. version ( `${ pkg . name } : ${ pkg . version } ` )
131
138
. alias ( 'v' , 'version' )
Original file line number Diff line number Diff line change
1
+ import { createContract } from '../index.js'
2
+ import pRetry from 'p-retry'
3
+
4
+ export const addAdmin = async ( { admin, ...opts } ) => {
5
+ const { contractWithSigner } = await createContract ( opts )
6
+ console . error ( `Adding ${ admin } as admin. Please sign on your ledger...` )
7
+ const tx = await contractWithSigner . grantRole (
8
+ contractWithSigner . DEFAULT_ADMIN_ROLE ( ) ,
9
+ admin
10
+ )
11
+ console . log ( tx . hash )
12
+ console . log ( 'Awaiting confirmation...' )
13
+ await pRetry ( ( ) => tx . wait ( ) )
14
+ }
You can’t perform that action at this time.
0 commit comments