Skip to content

Golang events are not parsed at all.  #45

Open
@coinsandsteeldev

Description

@coinsandsteeldev

This is Contract.cs method which is used to pre-process event before emitting it to listeners.

protected override ChainEventArgs TransformChainEvent(RawChainEventArgs e) {
    string jsonRpcEventString = Encoding.UTF8.GetString(e.Data);
    JsonRpcEvent jsonRpcEvent = JsonConvert.DeserializeObject<JsonRpcEvent>(jsonRpcEventString);
    byte[] eventData = Encoding.UTF8.GetBytes(jsonRpcEvent.Data);

    return new ChainEventArgs(
         e.ContractAddress,
         e.CallerAddress,
         e.BlockHeight,
         eventData,
         jsonRpcEvent.Method
    );
}

When i emit event in Go either using ctx.Emit() or ctx.EmitTopics() i have same result:

jsonRpcEventString has serialized json from Emit for instance

type AccountCreatedEvt struct {
	Test  string
	Test2 int
}

Will result as {"Test": "test", "Test2": 1488}. So the next line fails to deserialize
JsonRpcEvent jsonRpcEvent = JsonConvert.DeserializeObject<JsonRpcEvent>(jsonRpcEventString);

Resulting in converting null to byte[]

I wonder whether it is problem of Loom Node emitting event in the wrong format or something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions