You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a client working with a contract, I can only trust the data field to come from the contract that I am calling. Events are unstructured data and may originate from a subcall so that I need to check for the origin of the event. To parse data from a wasm event, I would have to do in tgrade:
// parse events for unboundTimefor_, e:=rangeem.Events() {
ife.Type!=wasmtypes.WasmModuleEventType {
continue
}
vartrustedboolfor_, a:=rangee.Attributes {
ifstring(a.Key) !=wasmtypes.AttributeKeyContractAddr||string(a.Value) !=contractAddr.String() {
continue
}
trusted=truebreak
}
if!trusted {// filter out other eventscontinue
}
for_, a:=rangee.Attributes {
ifstring(a.Key) !="completion_time" {
continue
}
// here I parse the data from the raw string representationnanos, err:=strconv.ParseInt(string(a.Value), 10, 64)
iferr!=nil {
returnnil, err
}
completionTime:=time.Unix(0, nanos).UTC()
return&completionTime, nil
}
}
returnnil, types.ErrInvalid.Wrap("completion_time not found")
compared to unmarshaling structured json data from the response data field this is quite some overhead
We have this model of structured response data already for queries/ responses and it works well for me.
Note: with submessages the data field could also be overwritten but I would consider the contract to be in charge and taking care as it is orchestrating the workflow.
The text was updated successfully, but these errors were encountered:
Background: simple way to access the completion time in confio/tgrade-contracts#152
As a client working with a contract, I can only trust the
data
field to come from the contract that I am calling. Events are unstructured data and may originate from a subcall so that I need to check for the origin of the event. To parse data from a wasm event, I would have to do in tgrade:compared to unmarshaling structured json data from the response
data
field this is quite some overheadWe have this model of structured response data already for queries/ responses and it works well for me.
Note: with submessages the
data
field could also be overwritten but I would consider the contract to be in charge and taking care as it is orchestrating the workflow.The text was updated successfully, but these errors were encountered: