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

refactor(ironfish): do not quit transaction:watch if the transaction is not found #3726

Merged
merged 2 commits into from
Apr 5, 2023

Conversation

holahula
Copy link
Contributor

@holahula holahula commented Apr 3, 2023

Summary

ironfish wallet:transactions:watch no longer quits if the transaction is not found. The NOT_FOUND state has been added as a TransactionStatus and is now integrated into the watch status loop

Closes IFL-413

Testing Plan

Successful watch:

➜  ironfish git:(holahula/fix/transaction-watch-404) ✗ fish wallet:send -d ~/.ironfish-simulator/node-e050 --watch
yarn run v1.22.19
$ yarn build && yarn start:js wallet:send -d /Users/austino/.ironfish-simulator/node-e050 --watch
$ tsc -b
$ cross-env OCLIF_TS_NODE=0 IRONFISH_DEBUG=1 node --expose-gc --inspect=:0 --inspect-publish-uid=http --enable-source-maps bin/run wallet:send -d /Users/austino/.ironfish-simulator/node-e050 --watch
Enter the amount (balance 48405.00000000): 1
Enter the public address of the recipient: beb858a08898867fa7917c45f4ff6c5c67cb590dc654204330b0b69cc647ef1f
? Select the fee you wish to use for this transaction Enter a custom fee
Enter the fee amount in $IRON (balance 48405.00000000): 1
You are about to send a transaction: $IRON 1.00000000 plus a transaction fee of $IRON 1.00000000 to beb858a08898867fa7917c45f4ff6c5c67cb590dc654204330b0b69cc647ef1f from the account default
Do you confirm (Y/N)?: Y
Sending the transaction... done
Sent $IRON 1.00000000 to beb858a08898867fa7917c45f4ff6c5c67cb590dc654204330b0b69cc647ef1f from default
Hash: 7e9ae0a153e0b6bc8375c67ee5be8f62f6a715144461656ab76b676b098a2fc4
Fee: $IRON 1.00000000

If the transaction is mined, it will appear here https://explorer.ironfish.network/transaction/7e9ae0a153e0b6bc8375c67ee5be8f62f6a715144461656ab76b676b098a2fc4

{"level":2,"tag":"wallet:send","date":"2023-04-05T17:07:23.987Z","message":"Watching transaction 7e9ae0a153e0b6bc8375c67ee5be8f62f6a715144461656ab76b676b098a2fc4"}
Current Status... pending -> unconfirmed: 20s
Current Status... unconfirmed -> confirmed: 10s
Current Status... done after 30s
✨  Done in 53.00s.

If txn not found, then watchTransaction() loop forever

➜  ironfish git:(holahula/fix/transaction-watch-404) ✗ fish wallet:transaction:watch abc -d ~/.ironfish-simulator/node-75d5
yarn run v1.22.19
$ yarn build && yarn start:js wallet:transaction:watch abc -d /Users/austino/.ironfish-simulator/node-75d5
$ tsc -b
$ cross-env OCLIF_TS_NODE=0 IRONFISH_DEBUG=1 node --expose-gc --inspect=:0 --inspect-publish-uid=http --enable-source-maps bin/run wallet:transaction:watch abc -d /Users/austino/.ironfish-simulator/node-75d5
{"level":2,"tag":"wallet:transaction:watch","date":"2023-04-05T17:11:56.931Z","message":"Watching transaction abc"}
Current Status... ⢿ not found 20s

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

@holahula holahula changed the base branch from master to staging April 3, 2023 20:49
@holahula holahula changed the title Holahula/fix/transaction watch 404 refactor: do not quit transaction:watch if the transaction is not found Apr 3, 2023
@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch 5 times, most recently from 3f4d36d to 723c886 Compare April 4, 2023 15:58
@holahula holahula marked this pull request as ready for review April 4, 2023 15:58
@holahula holahula requested a review from a team as a code owner April 4, 2023 15:58
@holahula holahula requested a review from dguenther April 4, 2023 16:14
@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch from 723c886 to 8d741ee Compare April 4, 2023 17:12
@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch from 8d741ee to 617ddb9 Compare April 4, 2023 21:29
@holahula holahula changed the title refactor: do not quit transaction:watch if the transaction is not found refactor(ironfish): do not quit transaction:watch if the transaction is not found Apr 4, 2023
@holahula holahula requested a review from dguenther April 4, 2023 21:49
Copy link
Member

@dguenther dguenther left a comment

Choose a reason for hiding this comment

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

This looks good. I think the one other UX change I'd consider making is integrating the "not found" status into the other loop, so the CLI output of both loops matched up but displays e.g. "not found" instead of "pending". This is a net improvement though so I'm good with merging it!

@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch 3 times, most recently from 6a04019 to 12db961 Compare April 4, 2023 23:45
@holahula
Copy link
Contributor Author

holahula commented Apr 4, 2023

Made the UX changes, now the spinner shows when the transaction is in the not found state, and logs a state change when it transitions from not found -> pending / unconfirmed / etc.

@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch 2 times, most recently from 2f3ef6f to a463506 Compare April 5, 2023 17:14
- add TransactionStatus.NOT_FOUND for managing the status of a
  transaction that cannot currently be retrieved
@holahula holahula force-pushed the holahula/fix/transaction-watch-404 branch from a463506 to 58da34d Compare April 5, 2023 17:16
@holahula holahula requested a review from dguenther April 5, 2023 17:18
@holahula holahula self-assigned this Apr 5, 2023
logger.log(`Tried to watch transaction ${options.hash} but it's missing.`)
return
}
let prevStatus = last?.content.transaction?.status ?? TransactionStatus.NOT_FOUND
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should add NOT_FOUND to TransactionStatus, since TransactionStatus is used for the status field of an existing transaction. In this case, we're just using it for display purposes.

Another way I think about it is that the ironfish package internally doesn't use the NOT_FOUND status, so I don't think we should change the enum just for the convenience of writing external (ironfish-cli) code.

I think you could type this as type TransactionWatchStatus = TransactionStatus | 'not found' and everything should just work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed changes to TransactionStatus

@dguenther dguenther merged commit c831cb8 into staging Apr 5, 2023
@dguenther dguenther deleted the holahula/fix/transaction-watch-404 branch April 5, 2023 20:28
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.

4 participants