Skip to content

Commit 7f98db6

Browse files
committed
Add flags for minSigners and totalParticipants for dkg:create
1 parent 7958f26 commit 7f98db6

File tree

1 file changed

+30
-11
lines changed
  • ironfish-cli/src/commands/wallet/multisig/dkg

1 file changed

+30
-11
lines changed

ironfish-cli/src/commands/wallet/multisig/dkg/create.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ export class DkgCreateCommand extends IronfishCommand {
6060
dependsOn: ['server'],
6161
allowNo: true,
6262
}),
63+
minSigners: Flags.integer({
64+
description: 'Minimum signers required to sign a transaction',
65+
exclusive: ['sessionId'],
66+
}),
67+
totalParticipants: Flags.integer({
68+
description: 'The total number of participants for the multisig account',
69+
exclusive: ['sessionId'],
70+
}),
6371
}
6472

6573
async start(): Promise<void> {
@@ -123,7 +131,12 @@ export class DkgCreateCommand extends IronfishCommand {
123131

124132
const { totalParticipants, minSigners } = await ui.retryStep(
125133
async () => {
126-
return this.getDkgConfig(multisigClient, !!ledger)
134+
return this.getDkgConfig(
135+
multisigClient,
136+
!!ledger,
137+
flags.minSigners,
138+
flags.totalParticipants,
139+
)
127140
},
128141
this.logger,
129142
true,
@@ -263,6 +276,8 @@ export class DkgCreateCommand extends IronfishCommand {
263276
async getDkgConfig(
264277
multisigClient: MultisigClient | null,
265278
ledger: boolean,
279+
minSigners?: number,
280+
totalParticipants?: number,
266281
): Promise<{ totalParticipants: number; minSigners: number }> {
267282
if (multisigClient?.sessionId) {
268283
let totalParticipants = 0
@@ -285,11 +300,13 @@ export class DkgCreateCommand extends IronfishCommand {
285300
return { totalParticipants, minSigners }
286301
}
287302

288-
const totalParticipants = await ui.inputNumberPrompt(
289-
this.logger,
290-
'Enter the total number of participants',
291-
{ required: true, integer: true },
292-
)
303+
if (!totalParticipants) {
304+
totalParticipants = await ui.inputNumberPrompt(
305+
this.logger,
306+
'Enter the total number of participants',
307+
{ required: true, integer: true },
308+
)
309+
}
293310

294311
if (totalParticipants < 2) {
295312
throw new Error('Total number of participants must be at least 2')
@@ -299,11 +316,13 @@ export class DkgCreateCommand extends IronfishCommand {
299316
throw new Error('DKG with Ledger supports a maximum of 4 participants')
300317
}
301318

302-
const minSigners = await ui.inputNumberPrompt(
303-
this.logger,
304-
'Enter the number of minimum signers',
305-
{ required: true, integer: true },
306-
)
319+
if (!minSigners) {
320+
minSigners = await ui.inputNumberPrompt(
321+
this.logger,
322+
'Enter the number of minimum signers',
323+
{ required: true, integer: true },
324+
)
325+
}
307326

308327
if (minSigners < 2 || minSigners > totalParticipants) {
309328
throw new Error(

0 commit comments

Comments
 (0)