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

Accounts updated subscription #302

Merged
merged 7 commits into from
Dec 3, 2024

Conversation

Victor-N-Suadicani
Copy link
Contributor

Purpose

I'm honestly not sure where this is used in the frontend.

Changes

Added the AccountsUpdatedSubscriptionItem and the appropriate methods to Subscription, which are largely inspired by the already-existing block_added subscription.

What's missing is actually sending the notifications when the appropriate event happens - this is left for future work.

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

@DOBEN
Copy link
Member

DOBEN commented Nov 21, 2024

The AccountsUpdatedSubscription is used as part of the web socket connection when the accounts page view is open e.g.
https://testnet.ccdscan.io/?dcount=1&dentity=account&daddress=4dT5vPrnnpwVrXZgmYLtHrDLvBYhtzheaK4fDWbJewqRCGQKWz

You can open the network tab and click on the ws tab to explore the web socket connections in the DevTools in the browser.

@DOBEN
Copy link
Member

DOBEN commented Nov 28, 2024

Remaining logic to be added:

Whenever a new row is added to the affected_accounts table emit a trigger account_updated_notify_trigger_function() returning the account_affected as the address field in the notification type (similar to block_added_notify_trigger_function()).

https://github.com/Concordium/concordium-scan/blob/main/backend-rust/migrations/0001_initialize.up.sql#L376

Update: this is implemented now.

@DOBEN DOBEN force-pushed the vs/ccd-89-implement-subscriptionaccountsupdated branch from 84d29b2 to 6da72cd Compare November 29, 2024 10:56
@DOBEN
Copy link
Member

DOBEN commented Nov 29, 2024

How to test:

  • Open http://localhost:8000/ in browser
  • Add subscription:
subscription accountsUpdatedSubscription($accountAddress: String) {
  accountsUpdated(accountAddress: $accountAddress) {
    address
  }
}
  • Add variable (optional): e.g.
{
  "accountAddress": "4Y1c27ZRpRut9av69n3i1uhfeDp4XGuvsm9fkEjFvgpoxXWxQB"
}

  • Press Play button:
  • Observe Subscriptions coming in on the right side.

Screenshot from 2024-11-29 18-02-24

@DOBEN DOBEN requested review from soerenbf and lassemand November 29, 2024 11:05
Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Still need to test it, but here are some initial observations

backend-rust/migrations/0001_initialize.up.sql Outdated Show resolved Hide resolved
backend-rust/src/graphql_api.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Managed to subscribe and receive an update 🎉

@DOBEN DOBEN force-pushed the vs/ccd-89-implement-subscriptionaccountsupdated branch from 2e53191 to 7e467f2 Compare December 2, 2024 16:41
@DOBEN DOBEN merged commit 2f45ce4 into main Dec 3, 2024
3 checks passed
@DOBEN DOBEN deleted the vs/ccd-89-implement-subscriptionaccountsupdated branch December 3, 2024 09:30
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.

3 participants