@@ -54,9 +54,14 @@ export class TransactionsCommand extends IronfishCommand {
54
54
description : 'Number of block confirmations needed to confirm a transaction' ,
55
55
} ) ,
56
56
notes : Flags . boolean ( {
57
- default : false ,
58
57
description : 'Include data from transaction output notes' ,
59
58
} ) ,
59
+ format : Flags . string ( {
60
+ description : 'output in a more machine friendly format' ,
61
+ exclusive : [ 'notes' ] ,
62
+ options : [ 'notes' , 'transactions' , 'transfers' ] ,
63
+ helpGroup : 'OUTPUT' ,
64
+ } ) ,
60
65
}
61
66
62
67
async start ( ) : Promise < void > {
@@ -69,6 +74,15 @@ export class TransactionsCommand extends IronfishCommand {
69
74
? Format . json
70
75
: Format . cli
71
76
77
+ const output =
78
+ flags . notes || flags . format === 'notes'
79
+ ? 'notes'
80
+ : flags . format === 'transactions'
81
+ ? 'transactions'
82
+ : flags . format === 'transfers'
83
+ ? 'transfers'
84
+ : 'transfers'
85
+
72
86
const client = await this . connectRpc ( )
73
87
await ui . checkWalletUnlocked ( client )
74
88
@@ -101,20 +115,20 @@ export class TransactionsCommand extends IronfishCommand {
101
115
flags . limit ,
102
116
flags . offset ,
103
117
flags . confirmations ,
104
- flags . notes ,
118
+ output === ' notes' || output === 'transfers' ,
105
119
)
106
120
107
- const columns = this . getColumns ( flags . extended , flags . notes , format )
108
-
109
121
let hasTransactions = false
110
122
let transactionRows : PartialRecursive < TransactionRow > [ ] = [ ]
111
123
112
124
for await ( const { account, transaction } of transactions ) {
113
125
if ( transactionRows . length >= flags . limit ) {
114
126
break
115
127
}
116
- if ( flags . notes ) {
128
+
129
+ if ( output === 'notes' || output === 'transfers' ) {
117
130
Assert . isNotUndefined ( transaction . notes )
131
+
118
132
const assetLookup = await getAssetsByIDs (
119
133
client ,
120
134
transaction . notes . map ( ( n ) => n . assetId ) || [ ] ,
@@ -130,7 +144,13 @@ export class TransactionsCommand extends IronfishCommand {
130
144
}
131
145
132
146
transactionRows = transactionRows . concat (
133
- this . getTransactionRowsByNote ( assetLookup , accountsByAddress , transaction , format ) ,
147
+ this . getTransactionRowsByNote (
148
+ assetLookup ,
149
+ accountsByAddress ,
150
+ transaction ,
151
+ format ,
152
+ output ,
153
+ ) ,
134
154
)
135
155
} else {
136
156
const assetLookup = await getAssetsByIDs (
@@ -146,6 +166,8 @@ export class TransactionsCommand extends IronfishCommand {
146
166
hasTransactions = true
147
167
}
148
168
169
+ const columns = this . getColumns ( flags . extended , output , format )
170
+
149
171
ui . table ( transactionRows , columns , {
150
172
printLine : this . log . bind ( this ) ,
151
173
...flags ,
@@ -248,6 +270,7 @@ export class TransactionsCommand extends IronfishCommand {
248
270
accountLookup : Map < string , string > ,
249
271
transaction : GetAccountTransactionsResponse ,
250
272
format : Format ,
273
+ output : 'notes' | 'transactions' | 'transfers' ,
251
274
) : PartialRecursive < TransactionRow > [ ] {
252
275
Assert . isNotUndefined ( transaction . notes )
253
276
const transactionRows = [ ]
@@ -272,7 +295,15 @@ export class TransactionsCommand extends IronfishCommand {
272
295
const senderName = accountLookup . get ( note . sender )
273
296
const recipientName = accountLookup . get ( note . owner )
274
297
275
- const group = this . getRowGroup ( index , noteCount , transactionRows . length )
298
+ let group = this . getRowGroup ( index , noteCount , transactionRows . length )
299
+
300
+ if ( output === 'transfers' ) {
301
+ if ( note . sender === note . owner && ! transaction . mints . length ) {
302
+ continue
303
+ } else {
304
+ group = ''
305
+ }
306
+ }
276
307
277
308
// include full transaction details in first row or non-cli-formatted output
278
309
if ( transactionRows . length === 0 || format !== Format . cli ) {
@@ -313,7 +344,7 @@ export class TransactionsCommand extends IronfishCommand {
313
344
314
345
getColumns (
315
346
extended : boolean ,
316
- notes : boolean ,
347
+ output : 'notes' | 'transactions' | 'transfers' ,
317
348
format : Format ,
318
349
) : ui . TableColumns < PartialRecursive < TransactionRow > > {
319
350
let columns : ui . TableColumns < PartialRecursive < TransactionRow > > = {
@@ -327,7 +358,7 @@ export class TransactionsCommand extends IronfishCommand {
327
358
} ,
328
359
type : {
329
360
header : 'Type' ,
330
- minWidth : notes ? 18 : 8 ,
361
+ minWidth : output === ' notes' || output === 'transfers' ? 18 : 8 ,
331
362
get : ( row ) => row . type ?? '' ,
332
363
} ,
333
364
hash : {
@@ -386,7 +417,7 @@ export class TransactionsCommand extends IronfishCommand {
386
417
} ,
387
418
}
388
419
389
- if ( notes ) {
420
+ if ( output === ' notes' || output === 'transfers' ) {
390
421
columns = {
391
422
...columns ,
392
423
senderName : {
0 commit comments