diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts index 488f786e1c..3edae07d70 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts @@ -101,15 +101,6 @@ export class DkgRound1Command extends IronfishCommand { minSigners: number, ): Promise { const ledger = new LedgerMultiSigner() - try { - await ledger.connect() - } catch (e) { - if (e instanceof Error) { - this.error(e.message) - } else { - throw e - } - } const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName }) const identity = identityResponse.content.identity @@ -118,8 +109,12 @@ export class DkgRound1Command extends IronfishCommand { identities.push(identity) } - // TODO(hughy): determine how to handle multiple identities using index - const { publicPackage, secretPackage } = await ledger.dkgRound1(0, identities, minSigners) + const { publicPackage, secretPackage } = await ui.ledger({ + ledger, + message: 'Round1 on Ledger', + approval: true, + action: () => ledger.dkgRound1(0, identities, minSigners), + }) this.log('\nRound 1 Encrypted Secret Package:\n') this.log(secretPackage.toString('hex')) diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/round2.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/round2.ts index a09afdb7aa..d51b9582dc 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/round2.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/round2.ts @@ -98,22 +98,13 @@ export class DkgRound2Command extends IronfishCommand { round1SecretPackage: string, ): Promise { const ledger = new LedgerMultiSigner() - try { - await ledger.connect() - } catch (e) { - if (e instanceof Error) { - this.error(e.message) - } else { - throw e - } - } - // TODO(hughy): determine how to handle multiple identities using index - const { publicPackage, secretPackage } = await ledger.dkgRound2( - 0, - round1PublicPackages, - round1SecretPackage, - ) + const { publicPackage, secretPackage } = await ui.ledger({ + ledger, + message: 'Round2 on Ledger', + approval: true, + action: () => ledger.dkgRound2(0, round1PublicPackages, round1SecretPackage), + }) this.log('\nRound 2 Encrypted Secret Package:\n') this.log(secretPackage.toString('hex')) diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/round3.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/round3.ts index 02541ef461..15794f71c6 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/round3.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/round3.ts @@ -163,15 +163,6 @@ export class DkgRound3Command extends IronfishCommand { accountCreatedAt?: number, ): Promise { const ledger = new LedgerMultiSigner() - try { - await ledger.connect() - } catch (e) { - if (e instanceof Error) { - this.error(e.message) - } else { - throw e - } - } const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName }) const identity = identityResponse.content.identity @@ -192,9 +183,9 @@ export class DkgRound3Command extends IronfishCommand { .sort((a, b) => a.senderIdentity.localeCompare(b.senderIdentity)) // Extract raw parts from round1 and round2 public packages - const participants = [] - const round1FrostPackages = [] - const gskBytes = [] + const participants: string[] = [] + const round1FrostPackages: string[] = [] + const gskBytes: string[] = [] for (const pkg of round1PublicPackages) { // Exclude participant's own identity and round1 public package if (pkg.identity !== identity) { @@ -208,19 +199,33 @@ export class DkgRound3Command extends IronfishCommand { const round2FrostPackages = round2PublicPackages.map((pkg) => pkg.frostPackage) // Perform round3 with Ledger - await ledger.dkgRound3( - 0, - participants, - round1FrostPackages, - round2FrostPackages, - round2SecretPackage, - gskBytes, - ) + await ui.ledger({ + ledger, + message: 'Round3 on Ledger', + approval: true, + action: () => + ledger.dkgRound3( + 0, + participants, + round1FrostPackages, + round2FrostPackages, + round2SecretPackage, + gskBytes, + ), + }) // Retrieve all multisig account keys and publicKeyPackage - const dkgKeys = await ledger.dkgRetrieveKeys() + const dkgKeys = await ui.ledger({ + ledger, + message: 'Getting Ledger DKG keys', + action: () => ledger.dkgRetrieveKeys(), + }) - const publicKeyPackage = await ledger.dkgGetPublicPackage() + const publicKeyPackage = await ui.ledger({ + ledger, + message: 'Getting Ledger Public Package', + action: () => ledger.dkgGetPublicPackage(), + }) const accountImport = { ...dkgKeys, @@ -250,7 +255,12 @@ export class DkgRound3Command extends IronfishCommand { this.log('Creating an encrypted backup of multisig keys from your Ledger device...') this.log() - const encryptedKeys = await ledger.dkgBackupKeys() + const encryptedKeys = await ui.ledger({ + ledger, + message: 'Backup DKG Keys', + approval: true, + action: () => ledger.dkgBackupKeys(), + }) this.log() this.log('Encrypted Ledger Multisig Backup:') diff --git a/ironfish-cli/src/commands/wallet/multisig/participant/create.ts b/ironfish-cli/src/commands/wallet/multisig/participant/create.ts index d9e7df0f66..06c1e43055 100644 --- a/ironfish-cli/src/commands/wallet/multisig/participant/create.ts +++ b/ironfish-cli/src/commands/wallet/multisig/participant/create.ts @@ -72,17 +72,11 @@ export class MultisigIdentityCreate extends IronfishCommand { async getIdentityFromLedger(): Promise { const ledger = new LedgerMultiSigner() - try { - await ledger.connect() - } catch (e) { - if (e instanceof Error) { - this.error(e.message) - } else { - throw e - } - } - // TODO(hughy): support multiple identities using index - return ledger.dkgGetIdentity(0) + return ui.ledger({ + ledger, + message: 'Getting Ledger Identity', + action: () => ledger.dkgGetIdentity(0), + }) } }