forked from TrueCloudLab/neoneo-go
Merge pull request #1174 from nspcc-dev/neo3/interop/getscriptcontainer
core, compiler: return tx from GetScriptContainer interop
This commit is contained in:
commit
4c23aa1d7c
3 changed files with 14 additions and 5 deletions
|
@ -7,7 +7,7 @@ import (
|
||||||
// Main is that famous Main() function, you know.
|
// Main is that famous Main() function, you know.
|
||||||
func Main() bool {
|
func Main() bool {
|
||||||
tx := runtime.GetScriptContainer()
|
tx := runtime.GetScriptContainer()
|
||||||
runtime.Notify(tx)
|
runtime.Notify(tx.Hash)
|
||||||
|
|
||||||
callingScriptHash := runtime.GetCallingScriptHash()
|
callingScriptHash := runtime.GetCallingScriptHash()
|
||||||
runtime.Notify(callingScriptHash)
|
runtime.Notify(callingScriptHash)
|
||||||
|
|
|
@ -1146,7 +1146,7 @@ func (c *codegen) convertSyscall(expr *ast.CallExpr, api, name string) {
|
||||||
}
|
}
|
||||||
emit.Syscall(c.prog.BinWriter, api)
|
emit.Syscall(c.prog.BinWriter, api)
|
||||||
switch name {
|
switch name {
|
||||||
case "GetTransaction", "GetBlock":
|
case "GetTransaction", "GetBlock", "GetScriptContainer":
|
||||||
c.emitConvert(stackitem.StructT)
|
c.emitConvert(stackitem.StructT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,10 +179,19 @@ func bcGetTransactionHeight(ic *interop.Context, v *vm.VM) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// engineGetScriptContainer returns transaction that contains the script being
|
// engineGetScriptContainer returns transaction or block that contains the script
|
||||||
// run.
|
// being run.
|
||||||
func engineGetScriptContainer(ic *interop.Context, v *vm.VM) error {
|
func engineGetScriptContainer(ic *interop.Context, v *vm.VM) error {
|
||||||
v.Estack().PushVal(stackitem.NewInterop(ic.Container))
|
var item stackitem.Item
|
||||||
|
switch t := ic.Container.(type) {
|
||||||
|
case *transaction.Transaction:
|
||||||
|
item = transactionToStackItem(t)
|
||||||
|
case *block.Block:
|
||||||
|
item = blockToStackItem(t)
|
||||||
|
default:
|
||||||
|
return errors.New("unknown script container")
|
||||||
|
}
|
||||||
|
v.Estack().PushVal(item)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue