-
Notifications
You must be signed in to change notification settings - Fork 378
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
[BlockchainApi] Fix exchange transactions #3565
Conversation
- make logic work if fees are paid in the utility token (cGLD) - throw when any assertion is wrong
…ockchain-api-exchanges
Codecov Report
@@ Coverage Diff @@
## master #3565 +/- ##
==========================================
+ Coverage 74.79% 74.87% +0.07%
==========================================
Files 622 622
Lines 15848 15828 -20
Branches 1739 2055 +316
==========================================
- Hits 11854 11851 -3
+ Misses 3618 3604 -14
+ Partials 376 373 -3
Continue to review full report at Codecov.
|
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.
LGTM, two optional comments below
} | ||
break | ||
|
||
case 2: // Exchange events have two corresponding transfers (in and out) |
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.
Could this large function be broken apart? I'm not sure having a big chunk of code in a switch case is best for readability
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.
Yep done 👍
}) | ||
default: | ||
// Warn if anything else happens | ||
console.warn(`Unhandled transfers for tx ${transferTx.transactionHash}`) |
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.
Nit: maybe error here? We should probably set up alerts for this. Having an error code enum defined somewhere would help with that
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.
Yes!
### Description The notification service was picking the wrong address for the transfer, because of the events which changed at the transaction layer, similar to what we had to fix in `blockchain-api` in #3565. Each transaction contains the actual transfer and also fee transfers. The previous code was only considering the last transfer emitted for the transaction, which was a fee transfer. Note: we could also filter out fee transfers like we did for `blockchain-api`, but there's no harm leaving them for now (they won't have any matching fcm token). ### Other changes - Don't create a Sentry event when a notification is received while in background. There is nothing that needs to be done. (Example: https://sentry.io/organizations/celo/issues/1648609728/?project=1250733&query=is%3Aunresolved) ### Tested - Deployed on Alfajores: - Push notifications are sent again to the correct user address when sending money. ### Related issues - Fixes #1339 ### Backwards compatibility Yes.
Description
This PR restores functionality for the wallet activity feed regarding exchange transactions.
The existing API we used broke because there are now events emitted when paying for fees in cUSD. See discussion in https://celo-org.slack.com/archives/CMX4JFMQW/p1586526953169900
A new API has been added to blockscout in order to get all cUSD and cGLD transfers happening in transactions.
This work has been done by @mrsmkl in celo-org/blockscout#102 which has already been deployed on alfajores.
For transactions paying for fees in cUSD we try to detect transfers related to fees (validator, gateway fee recipient, community fund).
This has risks of breaking, so I've put assertions so we can detect if it happens in the future.
Other changes
Tested
Deployed on alfajores and tested successfully.
Related issues
events
query #2509Backwards compatibility
Yes