Skip to content

Commit 76d47a5

Browse files
authored
creates ui prompt to select multisig account (#5719)
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
1 parent abb861f commit 76d47a5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ironfish-cli/src/commands/wallet/multisig/sign.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class SignMultisigTransactionCommand extends IronfishCommand {
8686

8787
let multisigAccountName: string
8888
if (!flags.account) {
89-
multisigAccountName = await ui.accountPrompt(client)
89+
multisigAccountName = await ui.multisigAccountPrompt(client)
9090
} else {
9191
multisigAccountName = flags.account
9292
const account = (await client.wallet.getAccounts()).content.accounts.find(

ironfish-cli/src/ui/prompts.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ export async function accountPrompt(
1616
return listPrompt(message, accountsResponse.content.accounts, (a) => a)
1717
}
1818

19+
export async function multisigAccountPrompt(
20+
client: Pick<RpcClient, 'wallet'>,
21+
message: string = 'Select multisig account',
22+
): Promise<string> {
23+
const accountsResponse = await client.wallet.getAccounts()
24+
25+
const accountIdentityPromises = accountsResponse.content.accounts.map((accountName) =>
26+
client.wallet.multisig
27+
.getAccountIdentity({ account: accountName })
28+
.then(() => accountName)
29+
.catch(() => undefined),
30+
)
31+
32+
const multisigAccounts = (await Promise.all(accountIdentityPromises)).filter(
33+
(accountName): accountName is string => accountName !== undefined,
34+
)
35+
return listPrompt(message, multisigAccounts, (a) => a)
36+
}
37+
1938
export async function multisigSecretPrompt(client: Pick<RpcClient, 'wallet'>): Promise<string> {
2039
const identitiesResponse = await client.wallet.multisig.getIdentities()
2140

0 commit comments

Comments
 (0)