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
feat: new cli commands accounts:notes
and accounts:transactions
#1086
feat: new cli commands accounts:notes
and accounts:transactions
#1086
Conversation
new cli command - accounts:transactions
Going to assign this to @NullSoldier because I think he wanted to give it a review next week before it merges. This looks useful! |
I think that this command must be able to work with both accountName and account address whichever type was written for better usability. |
for consistency, I'm using the same format as |
Very good project |
@dguenther @NullSoldier still interested in merging this? If so, i can update the code for latest version.. lmk! |
I'd still like to merge this, I think it's definitely useful especially in the latest testnet phase. Nobody on our side has been directly involved in reviewing + merging it, so sorry for the delay! I'd like to get one other person than myself to take a look at it, then it should be good to go, if you don't mind updating the code to fix conflicts. |
ironfish/src/account/accounts.ts
Outdated
memo: decryptedNote.memo().replace(/\x00/g, ''), | ||
}) | ||
|
||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this continue
needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, removed.
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { expect as expectCli, test } from '@oclif/test' | ||
import { GetTransactionsResponse } from 'ironfish' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import didn't work for me, I had to change the path to ../../../../ironfish/src/rpc/routes/transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, this needs updating for the latest version. I just pushed an update.
@dguenther updated for the latest version, can review now. |
Hey @wd021, I'm starting to dig into this PR, sorry for the delay. I wanted to clarify which direction to look at this from. What's the intended goal of this CLI command? I think there's a few different things technically happening here so I wanted to make sure we're on the same page on expectations of what questions this command should answer. For example, are you expecting this to show a complete list of all transactions this account has participated in? A complete list of notes, spent and unspent? A list of transactions containing unspent notes? etc. Looking at this right now, it feels a little bit awkward in that it is kind of a view into transactions, and also kind of a view into notes, and I think we can improve that together |
@mat-if no worries. The motivation for adding this command was to help debug account balances & faucet errors during phase 1. I wanted an easy way to output the spent notes associated with a given account. I agree that the wording is probably unclear. Would also be interested in expanding the scope of this into filtering by txs/notes/unspent notes. |
Ok, so I've thought about this a bit now. As I've mentioned, this feels a little bit like a view into both transactions and notes and feels a little confusing because of that. I think this could go a couple different directions, let me know what you think.
I think all 3 are very useful on their own, but to be clear, I don't expect you to implement all 3 in this PR. I think one is sufficient, and we can iterate from there. Let me know what you think! If you want to continue on one of these, great! If not, let me know and I can take over the PR if you prefer. |
yea, 1 and 2 were exactly where my mind was at. let's have 2 separate methods, i don't mind taking a crack at all 3 in this PR, will have some time later in the week 👨💻 |
@mat-if PR updated. here's the latest👇
|
accounts:transactions
accounts:notes
and accounts:transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! A few comments, but overall this looks pretty good.
ironfish/src/account/accounts.ts
Outdated
let transactionInfo = null | ||
const transactionNotes = [] | ||
|
||
for (const transactionMapValue of this.transactionMap.values()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function is for a specific transaction, instead of looping over this.transactionMap.values()
, you can lookup on the hash directly: const transactionMapValue = this.transactionMap.get(Buffer.from(hash, 'hex'))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, good catch.
ironfish/src/account/accounts.ts
Outdated
@@ -603,6 +603,46 @@ export class Accounts { | |||
this.scan = null | |||
} | |||
|
|||
getNotesFor(account: Account): { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about renaming this to getNotes
to be more inline with the other function names in here?
getNotesFor(account: Account): { | |
getNotes(account: Account): { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense 👌
ironfish/src/account/accounts.ts
Outdated
@@ -921,6 +961,125 @@ export class Accounts { | |||
await this.scanTransactions() | |||
} | |||
|
|||
getTransactionsFor(account: Account): { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like above, what do you think about getTransactions
getTransactionsFor(account: Account): { | |
getTransactions(account: Account): { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense 👌
ironfish/src/account/accounts.ts
Outdated
} | ||
} | ||
|
||
if (transactionCreator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm understanding this correctly, this check makes it so we only add transactions if we were a spender of a note. I would expect to also see transactions in which I only received IRON as well. Or more specifically, I would expect to see a transaction in which I have any decryptable notes.
To show what I mean, I set up a test where this account has exactly 1 note, which was IRON I sent from a different account. You'll see the note, and it references a transaction, but when I do accounts:transactions
it doesn't show anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. I updated this method to include notes where one is the receiver of iron in a transaction. but i also think its valuable to be able to detect the transactions created by the account, so there's now an extra creator
column for the table.
|
||
if (transactionInfo !== null) { | ||
this.log( | ||
`Transaction: ${transactionHash}, Status: ${transactionInfo.status}, Miner Fee: ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making each of these on a new line? I think it makes it a little easier to parse the info.
Transaction: fdaf29274587c8f58ac6214f42642fd610a222cea8e5e39ff4e11d58d379c194
Status: completed
Miner Fee: x
Fee ($ORE): 1
Spends: 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to this
ironfish/src/account/accounts.ts
Outdated
} | ||
} | ||
|
||
if (transactionCreator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, removed this.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…ron-fish#1086) * new cli command - accounts:transactions new cli command - accounts:transactions * fix linting * add assertHasAccount() in getTransactionNotes * use variable 'account' instead of 'accountName' * update code to latest version * fix linting * refactor: convert accounts:transactions -> accounts:notes * refactor: getNotes type change * feat: new accounts:transactions command * fix: linting on test files * make review changes * fix test fail * fix lint
…ron-fish#1086) * new cli command - accounts:transactions new cli command - accounts:transactions * fix linting * add assertHasAccount() in getTransactionNotes * use variable 'account' instead of 'accountName' * update code to latest version * fix linting * refactor: convert accounts:transactions -> accounts:notes * refactor: getNotes type change * feat: new accounts:transactions command * fix: linting on test files * make review changes * fix test fail * fix lint
Proposing to add an
accounts:transactions
command to display transaction notes for an account. I've been debugging some account balance issues lately and found this to be quite helpful. Here's what it looks likeIf we add this, I'll open a PR to update docs on the website repo.
Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.