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

Include account names when displaying notes #5642

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
33 changes: 30 additions & 3 deletions ironfish-cli/src/commands/wallet/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,25 @@ export class TransactionsCommand extends IronfishCommand {
const client = await this.connectRpc()
await ui.checkWalletUnlocked(client)

const allAccounts = (await client.wallet.getAccounts()).content.accounts

let accounts = flags.account
if (flags['no-account']) {
const response = await client.wallet.getAccounts()
accounts = response.content.accounts
accounts = allAccounts
} else if (!accounts) {
const account = await useAccount(client, undefined)
accounts = [account]
}

const accountsByAddress = new Map<string, string>(
await Promise.all(
allAccounts.map<Promise<[string, string]>>(async (account) => {
const response = await client.wallet.getAccountPublicKey({ account })
return [response.content.publicKey, response.content.account]
}),
),
)

const networkId = (await client.chain.getNetworkInfo()).content.networkId

const transactions = this.getTransactions(
Expand Down Expand Up @@ -120,7 +130,7 @@ export class TransactionsCommand extends IronfishCommand {
}

transactionRows = transactionRows.concat(
this.getTransactionRowsByNote(assetLookup, transaction, format),
this.getTransactionRowsByNote(assetLookup, accountsByAddress, transaction, format),
)
} else {
const assetLookup = await getAssetsByIDs(
Expand Down Expand Up @@ -235,6 +245,7 @@ export class TransactionsCommand extends IronfishCommand {

getTransactionRowsByNote(
assetLookup: { [key: string]: RpcAsset },
accountLookup: Map<string, string>,
transaction: GetAccountTransactionsResponse,
format: Format,
): PartialRecursive<TransactionRow>[] {
Expand All @@ -258,6 +269,8 @@ export class TransactionsCommand extends IronfishCommand {
const sender = note.sender
const recipient = note.owner
const memo = note.memo
const senderName = accountLookup.get(note.sender)
const recipientName = accountLookup.get(note.owner)

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

Expand All @@ -273,7 +286,9 @@ export class TransactionsCommand extends IronfishCommand {
amount,
feePaid,
sender,
senderName,
recipient,
recipientName,
memo,
})
} else {
Expand All @@ -285,7 +300,9 @@ export class TransactionsCommand extends IronfishCommand {
assetSymbol,
amount,
sender,
senderName,
recipient,
recipientName,
memo,
})
}
Expand Down Expand Up @@ -372,10 +389,18 @@ export class TransactionsCommand extends IronfishCommand {
if (notes) {
columns = {
...columns,
senderName: {
header: 'Sender',
get: (row) => row.senderName ?? '',
},
sender: {
header: 'Sender Address',
get: (row) => row.sender ?? '',
},
recipientName: {
header: 'Recipient',
get: (row) => row.recipientName ?? '',
},
recipient: {
header: 'Recipient Address',
get: (row) => row.recipient ?? '',
Expand Down Expand Up @@ -435,6 +460,8 @@ type TransactionRow = {
expiration: number
submittedSequence: number
sender: string
senderName?: string
recipient: string
recipientName?: string
memo?: string
}