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 (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"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/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/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -54,7 +53,7 @@ func Tick() bool {
|
||||||
ticksLeft = ticksLeft.(int) - 1
|
ticksLeft = ticksLeft.(int) - 1
|
||||||
if ticksLeft == 0 {
|
if ticksLeft == 0 {
|
||||||
runtime.Log("Fired!")
|
runtime.Log("Fired!")
|
||||||
return engine.AppCall(runtime.GetExecutingScriptHash(), "selfDestroy").(bool)
|
return contract.Call(runtime.GetExecutingScriptHash(), "selfDestroy").(bool)
|
||||||
}
|
}
|
||||||
storage.Put(ctx, ticksKey, ticksLeft)
|
storage.Put(ctx, ticksKey, ticksLeft)
|
||||||
i := binary.Itoa(ticksLeft.(int), 10)
|
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) {
|
t.Run("convert from string constant", func(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package foo
|
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())) + `
|
const scriptHash = ` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `
|
||||||
func Main() []byte {
|
func Main() []byte {
|
||||||
x := []byte{1, 2}
|
x := []byte{1, 2}
|
||||||
y := []byte{3, 4}
|
y := []byte{3, 4}
|
||||||
result := engine.AppCall([]byte(scriptHash), "append", x, y)
|
result := contract.Call([]byte(scriptHash), "append", x, y)
|
||||||
return result.([]byte)
|
return result.([]byte)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -151,12 +151,12 @@ func TestAppCall(t *testing.T) {
|
||||||
t.Run("convert from var", func(t *testing.T) {
|
t.Run("convert from var", func(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package foo
|
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 {
|
func Main() []byte {
|
||||||
x := []byte{1, 2}
|
x := []byte{1, 2}
|
||||||
y := []byte{3, 4}
|
y := []byte{3, 4}
|
||||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
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)
|
return result.([]byte)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -169,10 +169,10 @@ func TestAppCall(t *testing.T) {
|
||||||
|
|
||||||
t.Run("InitializedGlobals", func(t *testing.T) {
|
t.Run("InitializedGlobals", func(t *testing.T) {
|
||||||
src := `package foo
|
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 {
|
func Main() int {
|
||||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
||||||
result := engine.AppCall(addr, "add3", 39)
|
result := contract.Call(addr, "add3", 39)
|
||||||
return result.(int)
|
return result.(int)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
@ -184,10 +184,10 @@ func TestAppCall(t *testing.T) {
|
||||||
|
|
||||||
t.Run("AliasPackage", func(t *testing.T) {
|
t.Run("AliasPackage", func(t *testing.T) {
|
||||||
src := `package foo
|
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 {
|
func Main() int {
|
||||||
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
var addr = []byte(` + fmt.Sprintf("%#v", string(ih.BytesBE())) + `)
|
||||||
result := ee.AppCall(addr, "add3", 39)
|
result := ee.Call(addr, "add3", 39)
|
||||||
return result.(int)
|
return result.(int)
|
||||||
}`
|
}`
|
||||||
v := spawnVM(t, ic, src)
|
v := spawnVM(t, ic, src)
|
||||||
|
@ -199,11 +199,11 @@ func TestAppCall(t *testing.T) {
|
||||||
func getAppCallScript(h string) string {
|
func getAppCallScript(h string) string {
|
||||||
return `
|
return `
|
||||||
package foo
|
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 {
|
func Main() []byte {
|
||||||
x := []byte{1, 2}
|
x := []byte{1, 2}
|
||||||
y := []byte{3, 4}
|
y := []byte{3, 4}
|
||||||
result := engine.AppCall(` + h + `, "append", x, y)
|
result := contract.Call(` + h + `, "append", x, y)
|
||||||
return result.([]byte)
|
return result.([]byte)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -23,6 +23,7 @@ var syscalls = map[string]map[string]string{
|
||||||
"GetTransactionHeight": interopnames.SystemBlockchainGetTransactionHeight,
|
"GetTransactionHeight": interopnames.SystemBlockchainGetTransactionHeight,
|
||||||
},
|
},
|
||||||
"contract": {
|
"contract": {
|
||||||
|
"Call": interopnames.SystemContractCall,
|
||||||
"Create": interopnames.SystemContractCreate,
|
"Create": interopnames.SystemContractCreate,
|
||||||
"CreateStandardAccount": interopnames.SystemContractCreateStandardAccount,
|
"CreateStandardAccount": interopnames.SystemContractCreateStandardAccount,
|
||||||
"Destroy": interopnames.SystemContractDestroy,
|
"Destroy": interopnames.SystemContractDestroy,
|
||||||
|
@ -44,9 +45,6 @@ var syscalls = map[string]map[string]string{
|
||||||
"Next": interopnames.SystemEnumeratorNext,
|
"Next": interopnames.SystemEnumeratorNext,
|
||||||
"Value": interopnames.SystemEnumeratorValue,
|
"Value": interopnames.SystemEnumeratorValue,
|
||||||
},
|
},
|
||||||
"engine": {
|
|
||||||
"AppCall": interopnames.SystemContractCall,
|
|
||||||
},
|
|
||||||
"iterator": {
|
"iterator": {
|
||||||
"Concat": interopnames.SystemIteratorConcat,
|
"Concat": interopnames.SystemIteratorConcat,
|
||||||
"Create": interopnames.SystemIteratorCreate,
|
"Create": interopnames.SystemIteratorCreate,
|
||||||
|
|
|
@ -55,3 +55,11 @@ func CreateStandardAccount(pub interop.PublicKey) []byte {
|
||||||
func GetCallFlags() int64 {
|
func GetCallFlags() int64 {
|
||||||
return 0
|
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