forked from TrueCloudLab/neoneo-go
Merge pull request #1521 from nspcc-dev/oracle-events
native: add events to oracle contract
This commit is contained in:
commit
4cb4aa994a
1 changed files with 26 additions and 0 deletions
|
@ -131,6 +131,13 @@ func newOracle() *Oracle {
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(pp), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(pp), 0, smartcontract.AllowModifyStates)
|
||||||
o.AddMethod(md, desc, false)
|
o.AddMethod(md, desc, false)
|
||||||
|
|
||||||
|
o.AddEvent("OracleRequest", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||||
|
manifest.NewParameter("RequestContract", smartcontract.Hash160Type),
|
||||||
|
manifest.NewParameter("Url", smartcontract.StringType),
|
||||||
|
manifest.NewParameter("Filter", smartcontract.StringType))
|
||||||
|
o.AddEvent("OracleResponse", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||||
|
manifest.NewParameter("OriginalTx", smartcontract.Hash256Type))
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +242,15 @@ func (o *Oracle) FinishInternal(ic *interop.Context) error {
|
||||||
return ErrRequestNotFound
|
return ErrRequestNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ic.Notifications = append(ic.Notifications, state.NotificationEvent{
|
||||||
|
ScriptHash: o.Hash,
|
||||||
|
Name: "OracleResponse",
|
||||||
|
Item: stackitem.NewArray([]stackitem.Item{
|
||||||
|
stackitem.Make(resp.ID),
|
||||||
|
stackitem.Make(req.OriginalTxID.BytesBE()),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
r := io.NewBinReaderFromBuf(req.UserData)
|
r := io.NewBinReaderFromBuf(req.UserData)
|
||||||
userData := stackitem.DecodeBinaryStackItem(r)
|
userData := stackitem.DecodeBinaryStackItem(r)
|
||||||
args := stackitem.NewArray([]stackitem.Item{
|
args := stackitem.NewArray([]stackitem.Item{
|
||||||
|
@ -306,6 +322,16 @@ func (o *Oracle) RequestInternal(ic *interop.Context, url, filter, cb string, us
|
||||||
return ErrBigArgument
|
return ErrBigArgument
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ic.Notifications = append(ic.Notifications, state.NotificationEvent{
|
||||||
|
ScriptHash: o.Hash,
|
||||||
|
Name: "OracleRequest",
|
||||||
|
Item: stackitem.NewArray([]stackitem.Item{
|
||||||
|
stackitem.Make(id),
|
||||||
|
stackitem.Make(ic.VM.GetCallingScriptHash().BytesBE()),
|
||||||
|
stackitem.Make(url),
|
||||||
|
stackitem.Make(filter),
|
||||||
|
}),
|
||||||
|
})
|
||||||
req := &state.OracleRequest{
|
req := &state.OracleRequest{
|
||||||
OriginalTxID: o.getOriginalTxID(ic.DAO, ic.Tx),
|
OriginalTxID: o.getOriginalTxID(ic.DAO, ic.Tx),
|
||||||
GasForResponse: gas.Uint64(),
|
GasForResponse: gas.Uint64(),
|
||||||
|
|
Loading…
Reference in a new issue