Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creates ui prompt to select multisig account #5719

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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