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

conditionally formats cli transactions output #3708

Merged
merged 3 commits into from
Mar 30, 2023

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Mar 28, 2023

Summary

we've added a lot of logic to the 'wallet:transactions' command to format the table to make it easier to read in the CLI. however, this formatting logic removes data from the table that might be useful when outputting transaction data with the '--csv' or '--output' flags.

  • refactors logic for assigning 'group' string to table rows for the same transaction into 'getRowGroup' method
  • only includes the 'group' column in output if formatting the table for the CLI
  • includes all transaction details (hash, fee, assetId, assetName, etc.) in each row if using '--csv' or '--output' flags

Testing Plan

Manual testing:

I modified the send command to send multiple outputs in a single transaction to test formatting with multiple assets.

  • Table output:
    image

  • CSV output:

Timestamp,Status,Type,Hash,Expiration,Fee Paid ($IRON),Asset ID,Asset Name,Net Amount
3/28/2023 3:07:03 PM PDT,confirmed,send,ab0bbc4bc6b3c0fbcfd759a02f6ec2855454cc222060fb9c45678622ced04410,35325,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,-0.00000001
3/28/2023 3:07:03 PM PDT,confirmed,send,ab0bbc4bc6b3c0fbcfd759a02f6ec2855454cc222060fb9c45678622ced04410,35325,0.00000001,2d293899b8e7c0a79d80d3f9c02fbe67fe1a06b6ba363dcddd2cc0c4940d5214,abcdefghijklmnopqrstuvwxyz012345,-1.23456789
3/28/2023 3:07:03 PM PDT,confirmed,send,ab0bbc4bc6b3c0fbcfd759a02f6ec2855454cc222060fb9c45678622ced04410,35325,0.00000001,89457ddefaab4d02ba8e1363248549662790c6cb4518406b55ea9d797f1befb5,hughy-if,-0.00000042
3/28/2023 2:53:35 PM PDT,confirmed,send,8ca51a12977524aba1e6291b2c88e82a348d48aa55ed44ce89141dd83cf2e35b,35310,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,-0.00000001
3/28/2023 2:53:35 PM PDT,confirmed,send,8ca51a12977524aba1e6291b2c88e82a348d48aa55ed44ce89141dd83cf2e35b,35310,0.00000001,89457ddefaab4d02ba8e1363248549662790c6cb4518406b55ea9d797f1befb5,hughy-if,-0.00000042
3/28/2023 2:47:59 PM PDT,confirmed,send,e9bffe6136a41cdf8b96567746a862ee7eb58da661d99f48b10edc4ea7dee4d3,35300,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,0.00000000
3/28/2023 2:47:59 PM PDT,confirmed,send,e9bffe6136a41cdf8b96567746a862ee7eb58da661d99f48b10edc4ea7dee4d3,35300,0.00000001,2d293899b8e7c0a79d80d3f9c02fbe67fe1a06b6ba363dcddd2cc0c4940d5214,abcdefghijklmnopqrstuvwxyz012345,123456789.00000000
3/28/2023 2:39:26 PM PDT,expired,send,f7571421b0981a40e9267267607d2384236b38099cf889ad4560ee0251249d52,35282,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,-0.00000001
3/28/2023 2:39:26 PM PDT,expired,send,f7571421b0981a40e9267267607d2384236b38099cf889ad4560ee0251249d52,35282,0.00000001,89457ddefaab4d02ba8e1363248549662790c6cb4518406b55ea9d797f1befb5,hughy-if,-0.00000042
3/28/2023 2:24:28 PM PDT,confirmed,send,ec444ec72ba1d5f13fc1b434ff3c4a8fa635ac63dac9bf3c656fc9c5f7c12b5a,35277,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,0.00000000
3/28/2023 2:24:28 PM PDT,confirmed,send,ec444ec72ba1d5f13fc1b434ff3c4a8fa635ac63dac9bf3c656fc9c5f7c12b5a,35277,0.00000001,89457ddefaab4d02ba8e1363248549662790c6cb4518406b55ea9d797f1befb5,hughy-if,42.00000000
3/28/2023 2:23:48 PM PDT,confirmed,send,60724c7bd60ef2e8598e4bdae9f0552d7e3581e930230ec5ba73961637dd252c,35276,0.00000001,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,-0.00000001
3/24/2023 1:38:54 PM PDT,confirmed,receive,4d520099c75ea5901d3f09a4d7236c32ae9ff2362ce750c74660563c4354b0dc,29156,,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,0.00000005
3/24/2023 12:21:45 PM PDT,confirmed,receive,527c7716a375c45dac05b724d323202461217be0c67473cf2ce74f13911e5227,29071,,d7c86706f5817aa718cd1cfad03233bcd64a7789fd9422d3b17af6823a7e6ac6,$IRON,0.00000005

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

we've added a lot of logic to the 'wallet:transactions' command to format the
table to make it easier to read in the CLI. however, this formatting logic
removes data from the table that might be useful when outputting transaction
data with the '--csv' or '--output' flags.

- refactors logic for assigning 'group' string to table rows for the same
  transaction into 'getRowGroup' method
- only includes the 'group' column in output if formatting the table for the CLI
- includes all transaction details (hash, fee, assetId, assetName, etc.) in each
  row if using '--csv' or '--output' flags
@hughy hughy requested a review from a team as a code owner March 28, 2023 22:22
@@ -76,78 +78,65 @@ export class TransactionsCommand extends IronfishCommand {

getTransactionRows(
transaction: GetAccountTransactionsResponse,
formatted = true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like we use this default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I'll remove the default

format can be cli, csv, json, or yaml

the latter three correspond to the three possible values of the '--output' oclif
table flag

uses Format enum instead of boolean 'formatted' to indicate whether to format
table for cli output
@hughy hughy merged commit 324cd55 into staging Mar 30, 2023
@hughy hughy deleted the feature/ifl-268/transactions-csv branch March 30, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants