loomnetwork / unity-sdk

Loom DAppChain SDK for Unity3d
Other
121 stars 34 forks source link

Implement CreateFilterAsync and GetFilterChanges #50

Closed abeldantas closed 5 years ago

abeldantas commented 5 years ago

It would be very helpful to be able to query the logs of past events. Possibly duplicated issue with https://github.com/loomnetwork/unity-sdk/issues/12

Would love something like this:

var event = contract.GetEvent("EventName");

 // Make some filters
var grabAll = await multiplyEvent.CreateFilterAsync();
var filter = await multiplyEvent.CreateFilterAsync(indexedEventFieldValue);

// Get the logs
var allLogs = await multiplyEvent.GetFilterChanges<EventType>(grabAll);
var logs = await multiplyEvent.GetFilterChanges<EventType>(filter);`

Which is exactly as it is in here: https://nethereum.readthedocs.io/en/latest/contracts/calling-transactions-events/ Under the 'Events, filters and topics' section.

It would be great if we could at least grab the logs without filtering.

Thanks!

ZimM-LostPolygon commented 5 years ago

CreateFilterAsync and GetFilterChanges are not mandatory for getting past events. Actually implementing them would require a revamp of events API in the SDK. Instead, a simpler API is added, that allows to construct a filter and get logs that match that filter.

Part of https://github.com/loomnetwork/unity-sdk/pull/51

futouyiba commented 5 years ago

So how do we get past events, exactly?