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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

tokio_stream::wrappers::BroadcastStream::new(self.block_added.resubscribe())
}

async fn accounts_updated(
Copy link
Member

Choose a reason for hiding this comment

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

The query at the front-end includes an additional accountAddress query variable:


{
    "id": "1",
    "type": "start",
    "payload": {
        "key": "...",
        "query": "subscription accountsUpdatedSubscription($accountAddress: String!) {\n  accountsUpdated(accountAddress: $accountAddress) {\n    address\n  }\n}",
        "variables": {
            "accountAddress": "4dT5vPrnnpwVrXZgmYLtHrDLvBYhtzheaK4fDWbJewqRCGQKWz"
        },
        "context": {
            "url": "https://api-ccdscan.testnet.concordium.com/graphql",
            "preferGetMethod": false,
            "suspense": false,
            "requestPolicy": "cache-first",
            "meta": {
                "cacheOutcome": "miss"
            }
        }
    }
}

Copy link
Contributor Author

@Victor-N-Suadicani Victor-N-Suadicani Nov 22, 2024

Choose a reason for hiding this comment

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

Right - but what am I supposed to do with that input string? 🤔

In the C# code, it seems it's the "topic" of the subscription? Not sure what that means.

public class Subscription
{
    [Subscribe]
    [Topic("{accountAddress}")]
    public AccountsUpdatedSubscriptionItem AccountsUpdated(
        string accountAddress, 
        [EventMessage] AccountsUpdatedSubscriptionItem message) => message;

    [Subscribe]
    public Block BlockAdded([EventMessage] Block block) => block;
}

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