Skip to content

Commit

Permalink
creates ui prompt to select multisig account (#5719)
Browse files Browse the repository at this point in the history
uses 'wallet/getAccounts' RPC to fetch the list of all account names

next uses 'wallet/multisig/getAccountIdentity' to filter accounts that are not
multisig accounts (if an account is not a multisig account then it will not have
an identity)

replaces 'accountPrompt' prompt with 'multisigAccountPrompt' in
'wallet:multisig:sign' command
  • Loading branch information
hughy authored Feb 6, 2025
1 parent abb861f commit 76d47a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/wallet/multisig/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class SignMultisigTransactionCommand extends IronfishCommand {

let multisigAccountName: string
if (!flags.account) {
multisigAccountName = await ui.accountPrompt(client)
multisigAccountName = await ui.multisigAccountPrompt(client)
} else {
multisigAccountName = flags.account
const account = (await client.wallet.getAccounts()).content.accounts.find(
Expand Down
19 changes: 19 additions & 0 deletions ironfish-cli/src/ui/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ export async function accountPrompt(
return listPrompt(message, accountsResponse.content.accounts, (a) => a)
}

export async function multisigAccountPrompt(
client: Pick<RpcClient, 'wallet'>,
message: string = 'Select multisig account',
): Promise<string> {
const accountsResponse = await client.wallet.getAccounts()

const accountIdentityPromises = accountsResponse.content.accounts.map((accountName) =>
client.wallet.multisig
.getAccountIdentity({ account: accountName })
.then(() => accountName)
.catch(() => undefined),
)

const multisigAccounts = (await Promise.all(accountIdentityPromises)).filter(
(accountName): accountName is string => accountName !== undefined,
)
return listPrompt(message, multisigAccounts, (a) => a)
}

export async function multisigSecretPrompt(client: Pick<RpcClient, 'wallet'>): Promise<string> {
const identitiesResponse = await client.wallet.multisig.getIdentities()

Expand Down

0 comments on commit 76d47a5

Please sign in to comment.