Skip to content

Commit a243067

Browse files
authored
Include account names when displaying notes (#5642)
1 parent 6532166 commit a243067

File tree

1 file changed

+30
-3
lines changed
  • ironfish-cli/src/commands/wallet/transactions

1 file changed

+30
-3
lines changed

ironfish-cli/src/commands/wallet/transactions/index.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,25 @@ export class TransactionsCommand extends IronfishCommand {
7272
const client = await this.connectRpc()
7373
await ui.checkWalletUnlocked(client)
7474

75+
const allAccounts = (await client.wallet.getAccounts()).content.accounts
76+
7577
let accounts = flags.account
7678
if (flags['no-account']) {
77-
const response = await client.wallet.getAccounts()
78-
accounts = response.content.accounts
79+
accounts = allAccounts
7980
} else if (!accounts) {
8081
const account = await useAccount(client, undefined)
8182
accounts = [account]
8283
}
8384

85+
const accountsByAddress = new Map<string, string>(
86+
await Promise.all(
87+
allAccounts.map<Promise<[string, string]>>(async (account) => {
88+
const response = await client.wallet.getAccountPublicKey({ account })
89+
return [response.content.publicKey, response.content.account]
90+
}),
91+
),
92+
)
93+
8494
const networkId = (await client.chain.getNetworkInfo()).content.networkId
8595

8696
const transactions = this.getTransactions(
@@ -120,7 +130,7 @@ export class TransactionsCommand extends IronfishCommand {
120130
}
121131

122132
transactionRows = transactionRows.concat(
123-
this.getTransactionRowsByNote(assetLookup, transaction, format),
133+
this.getTransactionRowsByNote(assetLookup, accountsByAddress, transaction, format),
124134
)
125135
} else {
126136
const assetLookup = await getAssetsByIDs(
@@ -235,6 +245,7 @@ export class TransactionsCommand extends IronfishCommand {
235245

236246
getTransactionRowsByNote(
237247
assetLookup: { [key: string]: RpcAsset },
248+
accountLookup: Map<string, string>,
238249
transaction: GetAccountTransactionsResponse,
239250
format: Format,
240251
): PartialRecursive<TransactionRow>[] {
@@ -258,6 +269,8 @@ export class TransactionsCommand extends IronfishCommand {
258269
const sender = note.sender
259270
const recipient = note.owner
260271
const memo = note.memo
272+
const senderName = accountLookup.get(note.sender)
273+
const recipientName = accountLookup.get(note.owner)
261274

262275
const group = this.getRowGroup(index, noteCount, transactionRows.length)
263276

@@ -273,7 +286,9 @@ export class TransactionsCommand extends IronfishCommand {
273286
amount,
274287
feePaid,
275288
sender,
289+
senderName,
276290
recipient,
291+
recipientName,
277292
memo,
278293
})
279294
} else {
@@ -285,7 +300,9 @@ export class TransactionsCommand extends IronfishCommand {
285300
assetSymbol,
286301
amount,
287302
sender,
303+
senderName,
288304
recipient,
305+
recipientName,
289306
memo,
290307
})
291308
}
@@ -372,10 +389,18 @@ export class TransactionsCommand extends IronfishCommand {
372389
if (notes) {
373390
columns = {
374391
...columns,
392+
senderName: {
393+
header: 'Sender',
394+
get: (row) => row.senderName ?? '',
395+
},
375396
sender: {
376397
header: 'Sender Address',
377398
get: (row) => row.sender ?? '',
378399
},
400+
recipientName: {
401+
header: 'Recipient',
402+
get: (row) => row.recipientName ?? '',
403+
},
379404
recipient: {
380405
header: 'Recipient Address',
381406
get: (row) => row.recipient ?? '',
@@ -435,6 +460,8 @@ type TransactionRow = {
435460
expiration: number
436461
submittedSequence: number
437462
sender: string
463+
senderName?: string
438464
recipient: string
465+
recipientName?: string
439466
memo?: string
440467
}

0 commit comments

Comments
 (0)