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

Implement deserialization of list of changes in Transaction response converter #13

Open
kPatch opened this issue Feb 7, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@kPatch
Copy link
Contributor

kPatch commented Feb 7, 2023

Parse through list of event changes from transaction response.
Below is the outline of the code.

TransactionConverter.cs

if (item["changes"] != null)
{
List<Change> changes = new List<Change>();

// TODO: Complete TransactionConverter deserialization of Changes array
JArray jChanges = new JArray(item["changes"]);
foreach (var change in jChanges)
{
    // TODO: onChage
    //JObject oChange = change.ToObject<JObject>();
    //string typeStr = oChange["type"].ToString();

    //if (typeStr.Equals("write_resource"))
    //{
    //    ChangeWriteResource changeWResource = new ChangeWriteResource();
    //    changeWResource.Type = (string)change["type"];
    //    changeWResource.StateKeyHash = (string)change["state_key_hash"];
    //    changeWResource.Address = (string)change["Address"];

    //    changes.Add(changeWResource);
    //}
    //else if (change["type"].Equals("write_table_item"))
    //{
    //    ChangeWriteResourceWriteTableItem changeWRWRT = new ChangeWriteResourceWriteTableItem();
    //    changeWRWRT.Type = (string)change["type"];
    //    changeWRWRT.StateKeyHash = (string)change["state_key_hash"];
    //    changeWRWRT.Handle = (string)change["handle"];
    //    changeWRWRT.Key = (string)change["key"];
    //    changeWRWRT.Value = (string)change["value"];
    //    changeWRWRT.Data = (string)change["data"];

    //    changes.Add(changeWRWRT);
    //}
}

transaction.Changes = changes.ToArray();
}
@kPatch kPatch added the enhancement New feature or request label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant