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

Add GetContractEvent to DAppChainRPCClient #383

Merged
merged 3 commits into from
May 27, 2019

Conversation

pathornteng
Copy link
Contributor

@pathornteng pathornteng commented May 22, 2019

Add GetContractEvents method to DAppChainRPCClient. This method returns the list of events from a specified block range.

uint64 and int64 are converted to json string according to https://developers.google.com/protocol-buffers/docs/proto3#json. This causes json.Unmarshal fail to unmarshal json back to Go struct. So we need to have custom jsontag for int64/uint64 fields.

@pathornteng pathornteng changed the title Add custom jsontag to EventData and ContractEventResult Add GetContractEvent to DAppChainRPCClient May 22, 2019
func (c *DAppChainRPCClient) GetContractEvents(fromBlock, toBlock uint64) (ptypes.ContractEventsResult, error) {
params := map[string]interface{}{
"fromBlock": strconv.FormatUint(fromBlock, 10),
"toBlock": strconv.FormatUint(toBlock, 10),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we also need contract as another parameter since contractevents has it. It can be blank string if we don't want to filter by contract name.

Copy link
Contributor

Choose a reason for hiding this comment

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

We also need another method to query the block height to really get rid of those JSONRPC client that we're currently using.

func (c *DAppChainRPCClient) GetBlockHeight() (uint64, error)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

contract parameter does not work though. I think we need to have a fix for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. The name might be mapped incorrectly in loomchain.

Copy link
Contributor

@phoorichet phoorichet left a comment

Choose a reason for hiding this comment

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

LGTM

@phoorichet phoorichet merged commit 60edf7d into master May 27, 2019
@phoorichet phoorichet deleted the custom-jsontag-contract-events branch May 27, 2019 04:33
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