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

Fix bug in Go RPC client when unmarshaling contract events #496

Merged
merged 2 commits into from Nov 5, 2019

Conversation

@albrow
Copy link
Member

albrow commented Nov 5, 2019

This PR fixes a bug in the GO RPC client that was most likely introduced in 5.0.0-beta. The bug occurred when subscribing to order events and receiving one with one or more contract events:

json: cannot unmarshal object into Go struct field ContractEvent.Parameters of type zeroex.ContractEventParameters

This PR fixes the bug by adding an UnmarshalJSON event for each type of contract event.

@albrow albrow force-pushed the fix/unmarshal-contract-event-parameters branch from 1e6933b to d9b73e9 Nov 5, 2019
@@ -88,7 +84,18 @@ type ContractEvent struct {
IsRemoved bool
Address common.Address
Kind string
Parameters ContractEventParameters
Parameters interface{}

This comment has been minimized.

Copy link
@albrow

albrow Nov 5, 2019

Author Member

@fabioberger changed this back to interface{} because for some event types, we just use the default json.Marshal behavior (which is more efficient and saves us some lines of code).

@@ -58,7 +59,22 @@ func TestMarshalUnmarshalOrderEvent(t *testing.T) {
SignedOrder: signedOrder,
EndState: ESOrderAdded,
FillableTakerAssetAmount: big.NewInt(2000),
ContractEvents: []*ContractEvent{},
ContractEvents: []*ContractEvent{

This comment has been minimized.

Copy link
@albrow

albrow Nov 5, 2019

Author Member

@fabioberger we didn't catch this bug because we never tried marshaling/unmarshaling an OrderEvent with a non-empty ContractEvents field.

@albrow albrow merged commit 572ab83 into development Nov 5, 2019
1 check passed
1 check passed
ci/circleci: build Your tests passed on CircleCI!
Details
@albrow albrow deleted the fix/unmarshal-contract-event-parameters branch Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.