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

Added an accessor to PendingEvent to be able to get back typed data #28

Merged

Conversation

CliffCawley
Copy link
Contributor

Added an accessor to PendingEvent to be able to get back typed data, instead of just a JsonElement.

It's not fully populated and someone with some more knowledge about the events and their data would be able to better fill it out, but I think it's a great start and can easily be expanded upon.

I.e.

Now you can do the following:

foreach (var edge in response.Result.Data.Result.Edges)
{
    if (edge.Node.DataTyped is PendingEventDataTransfer eventDataTransfer)
    {
        Console.WriteLine($"From: {eventDataTransfer.From}");
        Console.WriteLine($"To: {eventDataTransfer.To}");
        Console.WriteLine($"Amount: {eventDataTransfer.Amount}");
    }
}

Instead of:

foreach (var edge in response.Result.Data.Result.Edges)
{
    var root = edge.Node.Data.Value;
    if (root.ValueKind == JsonValueKind.Object)
    {
        foreach (JsonProperty prop in root.EnumerateObject())
        {
            Console.WriteLine($"Key: {prop.Name}, Value: {prop.Value}");
        }
    }
}

@v16Studios
Copy link
Contributor

Looks good :) Would you mind going through and adding some summary blocks for the properties? Just to keep everything consistent. Cheers!

@CliffCawley
Copy link
Contributor Author

@v16Studios I've added some, although I had to guess what their purpose was, since I don't actually know. Some of the events I added, I just did so because I saw their data in the returned data from the call.

Like I said, it's also incomplete, I'm not sure what other events are possible, or even what all of their properties mean.

For example, I'm not sure what the Deposit or Withdraw events are actually for, I just made an assumption about what the properties might be.

@leonardocustodio leonardocustodio force-pushed the AddedTypedDataForPendingEvents branch from 7fd2ba5 to 4bc0f39 Compare April 25, 2024 16:51
@leonardocustodio leonardocustodio self-requested a review April 26, 2024 15:15
@leonardocustodio leonardocustodio merged commit b1abfd4 into enjin:master Apr 26, 2024
1 check passed
@CliffCawley CliffCawley deleted the AddedTypedDataForPendingEvents branch April 27, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants