compiler: rename engine.AppCall()
to contract.Call()
This commit is contained in:
parent
d828096cbf
commit
b807fd9e7f
5 changed files with 20 additions and 31 deletions
|
@ -3,7 +3,6 @@ package timer
|
|||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||
|
@ -54,7 +53,7 @@ func Tick() bool {
|
|||
ticksLeft = ticksLeft.(int) - 1
|
||||
if ticksLeft == 0 {
|
||||
runtime.Log("Fired!")
|
||||
return engine.AppCall(runtime.GetExecutingScriptHash(), "selfDestroy").(bool)
|
||||
return contract.Call(runtime.GetExecutingScriptHash(), "selfDestroy").(bool)
|
||||
}
|
||||
storage.Put(ctx, ticksKey, ticksLeft)
|
||||
i := binary.Itoa(ticksLeft.(int), 10)
|
||||
|
|
|
@ -132,12 +132,12 @@ func TestAppCall(t *testing.T) {
|
|||
t.Run("convert from string constant", func(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
const scriptHash = ` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `
|
||||
func Main() []byte {
|
||||
x := []byte{1, 2}
|
||||
y := []byte{3, 4}
|
||||
result := engine.AppCall([]byte(scriptHash), "append", x, y)
|
||||
result := contract.Call([]byte(scriptHash), "append", x, y)
|
||||
return result.([]byte)
|
||||
}
|
||||
`
|
||||
|
@ -151,12 +151,12 @@ func TestAppCall(t *testing.T) {
|
|||
t.Run("convert from var", func(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
func Main() []byte {
|
||||
x := []byte{1, 2}
|
||||
y := []byte{3, 4}
|
||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
||||
result := engine.AppCall(addr, "append", x, y)
|
||||
result := contract.Call(addr, "append", x, y)
|
||||
return result.([]byte)
|
||||
}
|
||||
`
|
||||
|
@ -169,10 +169,10 @@ func TestAppCall(t *testing.T) {
|
|||
|
||||
t.Run("InitializedGlobals", func(t *testing.T) {
|
||||
src := `package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
func Main() int {
|
||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
||||
result := engine.AppCall(addr, "add3", 39)
|
||||
result := contract.Call(addr, "add3", 39)
|
||||
return result.(int)
|
||||
}`
|
||||
|
||||
|
@ -184,10 +184,10 @@ func TestAppCall(t *testing.T) {
|
|||
|
||||
t.Run("AliasPackage", func(t *testing.T) {
|
||||
src := `package foo
|
||||
import ee "github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
import ee "github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
func Main() int {
|
||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
||||
result := ee.AppCall(addr, "add3", 39)
|
||||
result := ee.Call(addr, "add3", 39)
|
||||
return result.(int)
|
||||
}`
|
||||
v := spawnVM(t, ic, src)
|
||||
|
@ -199,11 +199,11 @@ func TestAppCall(t *testing.T) {
|
|||
func getAppCallScript(h string) string {
|
||||
return `
|
||||
package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
func Main() []byte {
|
||||
x := []byte{1, 2}
|
||||
y := []byte{3, 4}
|
||||
result := engine.AppCall(` + h + `, "append", x, y)
|
||||
result := contract.Call(` + h + `, "append", x, y)
|
||||
return result.([]byte)
|
||||
}
|
||||
`
|
||||
|
|
|
@ -23,6 +23,7 @@ var syscalls = map[string]map[string]string{
|
|||
"GetTransactionHeight": interopnames.SystemBlockchainGetTransactionHeight,
|
||||
},
|
||||
"contract": {
|
||||
"Call": interopnames.SystemContractCall,
|
||||
"Create": interopnames.SystemContractCreate,
|
||||
"CreateStandardAccount": interopnames.SystemContractCreateStandardAccount,
|
||||
"Destroy": interopnames.SystemContractDestroy,
|
||||
|
@ -44,9 +45,6 @@ var syscalls = map[string]map[string]string{
|
|||
"Next": interopnames.SystemEnumeratorNext,
|
||||
"Value": interopnames.SystemEnumeratorValue,
|
||||
},
|
||||
"engine": {
|
||||
"AppCall": interopnames.SystemContractCall,
|
||||
},
|
||||
"iterator": {
|
||||
"Concat": interopnames.SystemIteratorConcat,
|
||||
"Create": interopnames.SystemIteratorCreate,
|
||||
|
|
|
@ -55,3 +55,11 @@ func CreateStandardAccount(pub interop.PublicKey) []byte {
|
|||
func GetCallFlags() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Call executes previously deployed blockchain contract with specified hash
|
||||
// (20 bytes in BE form) using provided arguments.
|
||||
// It returns whatever this contract returns. This function uses
|
||||
// `System.Contract.Call` syscall.
|
||||
func Call(scriptHash interop.Hash160, method string, args ...interface{}) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
Package engine allows to make contract calls.
|
||||
It's roughly similar in function to ExecutionEngine class in the Neo .net
|
||||
framework.
|
||||
*/
|
||||
package engine
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
|
||||
// AppCall executes previously deployed blockchain contract with specified hash
|
||||
// (160 bit in BE form represented as 20-byte slice) using provided arguments.
|
||||
// It returns whatever this contract returns. This function uses
|
||||
// `System.Contract.Call` syscall.
|
||||
func AppCall(scriptHash interop.Hash160, method string, args ...interface{}) interface{} {
|
||||
return nil
|
||||
}
|
Loading…
Reference in a new issue