core: move Oracle response script creation to a separate function
This commit is contained in:
parent
35590f0c96
commit
35ef58a47e
1 changed files with 12 additions and 3 deletions
|
@ -86,9 +86,7 @@ func newOracle() *Oracle {
|
||||||
o := &Oracle{ContractMD: *interop.NewContractMD(nativenames.Oracle, oracleContractID)}
|
o := &Oracle{ContractMD: *interop.NewContractMD(nativenames.Oracle, oracleContractID)}
|
||||||
defer o.UpdateHash()
|
defer o.UpdateHash()
|
||||||
|
|
||||||
w := io.NewBufBinWriter()
|
o.oracleScript = CreateOracleResponseScript(o.Hash)
|
||||||
emit.AppCall(w.BinWriter, o.Hash, "finish", callflag.All)
|
|
||||||
o.oracleScript = w.Bytes()
|
|
||||||
|
|
||||||
desc := newDescriptor("request", smartcontract.VoidType,
|
desc := newDescriptor("request", smartcontract.VoidType,
|
||||||
manifest.NewParameter("url", smartcontract.StringType),
|
manifest.NewParameter("url", smartcontract.StringType),
|
||||||
|
@ -526,3 +524,14 @@ func (o *Oracle) updateCache(d *dao.Simple) error {
|
||||||
orc.AddRequests(reqs)
|
orc.AddRequests(reqs)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateOracleResponseScript returns script that is used to create native Oracle
|
||||||
|
// response.
|
||||||
|
func CreateOracleResponseScript(nativeOracleHash util.Uint160) []byte {
|
||||||
|
w := io.NewBufBinWriter()
|
||||||
|
emit.AppCall(w.BinWriter, nativeOracleHash, "finish", callflag.All)
|
||||||
|
if w.Err != nil {
|
||||||
|
panic(fmt.Errorf("failed to create Oracle response script: %w", w.Err))
|
||||||
|
}
|
||||||
|
return w.Bytes()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue