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

adds decrypted notes to getAccountTransactions #3731

Merged
merged 3 commits into from
Apr 3, 2023

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Apr 3, 2023

Summary

optionally decrypts transaction output notes and includes them in the response from getAccountTransactions with each transaction.

adding the decrypted notes will support adding both sender address and recipient address to the output of wallet:transactions: each note includes both the sender address and the 'owner' address, which is the recipient address.

Testing Plan

  • adds unit test

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

optionally decrypts transaction output notes and includes them in the response
from getAccountTransactions with each transaction.

adding the decrypted notes will support adding both sender address and recipient
address to the output of `wallet:transactions`: each note includes both the
sender address and the 'owner' address, which is the recipient address.
@hughy hughy requested a review from a team as a code owner April 3, 2023 22:41
@@ -72,3 +75,41 @@ export async function getAssetBalanceDeltas(

return assetBalanceDeltas
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably belongs in a different file, it isn't a type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i'll add a separate utils module and then move the other non-type declarations from this file as well

memo: note.memo(),
value: CurrencyUtils.encode(note.value()),
assetId: note.assetId().toString('hex'),
assetName: asset?.name.toString('hex') || '',
Copy link
Contributor

Choose a reason for hiding this comment

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

In what cases won't the asset be defined? Wouldn't it be a corrupt database if the asset isn't found but the note is decrypted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this logic came before assets were stored in the wallet db and looks the asset up from the chain database. if the note is from a pending mint transaction then the asset might not have been added to the chain yet.

we may be able to update this to use the wallet database instead of the chain now that it's available

@@ -33,6 +39,7 @@ export type GetAccountTransactionsResponse = {
expiration: number
timestamp: number
assetBalanceDeltas: Array<{ assetId: string; assetName: string; delta: string }>
notes?: RpcAccountDecryptedNote[]
Copy link
Contributor

Choose a reason for hiding this comment

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

I am partial to notes: RpcAccountDecryptedNote[] | undefined since it is more explicit, not sure if this is the pattern we use though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect that we're not very consistent about using one vs the other. I'll add a task to the RPC uniformity project to address this and make it consistent!

Copy link
Contributor

@jowparks jowparks left a comment

Choose a reason for hiding this comment

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

LGTM, few small comments/questions

@hughy hughy merged commit f7530f7 into staging Apr 3, 2023
@hughy hughy deleted the feature/ifl-424/account-transactions-notes branch April 3, 2023 23:27
jowparks pushed a commit that referenced this pull request Apr 5, 2023
* adds decrypted notes to getAccountTransactions

optionally decrypts transaction output notes and includes them in the response
from getAccountTransactions with each transaction.

adding the decrypted notes will support adding both sender address and recipient
address to the output of `wallet:transactions`: each note includes both the
sender address and the 'owner' address, which is the recipient address.

* moves getAccountDecryptedNotes from types to utils

* fixes lint
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