Complete Tutus rebranding - remove all Neo dependencies

External dependencies replaced:
- nspcc-dev/dbft -> tutus-one/tutus-consensus
- nspcc-dev/bbolt -> tutus-one/tutus-bolt
- nspcc-dev/go-ordered-json -> tutus-one/tutus-ordered-json
- nspcc-dev/rfc6979 -> tutus-one/tutus-rfc6979

Internal packages renamed:
- pkg/neotest -> pkg/tutustest
- pkg/neorpc -> pkg/tutusrpc
- pkg/interop/neogointernal -> pkg/interop/tutusinternal
- pkg/rpcclient/neo -> pkg/rpcclient/tutus

CLI branding updated to Tutus throughout.
This commit is contained in:
Tutus Development 2025-12-21 06:25:15 -05:00
parent cdae21d5a2
commit aee2d44325
222 changed files with 7795 additions and 7790 deletions

View File

@ -17,9 +17,9 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/encoding/fixedn" "github.com/tutus-one/tutus-chain/pkg/encoding/fixedn"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/invoker" "github.com/tutus-one/tutus-chain/pkg/rpcclient/invoker"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/neo" "github.com/tutus-one/tutus-chain/pkg/rpcclient/tutus"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm" "github.com/tutus-one/tutus-chain/pkg/vm"
"github.com/tutus-one/tutus-chain/pkg/vm/vmstate" "github.com/tutus-one/tutus-chain/pkg/vm/vmstate"
@ -315,7 +315,7 @@ func queryVoter(ctx *cli.Context) error {
return exitErr return exitErr
} }
neoToken := neo.NewReader(invoker.New(c, nil)) neoToken := tutus.NewReader(invoker.New(c, nil))
st, err := neoToken.GetAccountState(addr) st, err := neoToken.GetAccountState(addr)
if err != nil { if err != nil {

View File

@ -6,13 +6,13 @@ import (
var neogoVersion = prometheus.NewGaugeVec( var neogoVersion = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Help: "NeoGo version", Help: "Tutus version",
Name: "version", Name: "version",
Namespace: "neogo", Namespace: "neogo",
}, },
[]string{"version"}) []string{"version"})
func setNeoGoVersion(nodeVer string) { func setTutusVersion(nodeVer string) {
neogoVersion.WithLabelValues(nodeVer).Add(1) neogoVersion.WithLabelValues(nodeVer).Add(1)
} }

View File

@ -83,7 +83,7 @@ func NewCommands() []*cli.Command {
return []*cli.Command{ return []*cli.Command{
{ {
Name: "node", Name: "node",
Usage: "Start a NeoGo node", Usage: "Start a Tutus node",
UsageText: "neo-go node [--config-path path] [-d] [-p/-m/-t] [--config-file file] [--force-timestamp-logs]", UsageText: "neo-go node [--config-path path] [-d] [-p/-m/-t] [--config-file file] [--force-timestamp-logs]",
Action: startServer, Action: startServer,
Flags: cfgFlags, Flags: cfgFlags,
@ -526,7 +526,7 @@ func startServer(ctx *cli.Context) error {
errChan := make(chan error) errChan := make(chan error)
rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan) rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan)
serv.AddService(rpcServer) serv.AddService(rpcServer)
setNeoGoVersion(config.Version) setTutusVersion(config.Version)
serv.Start() serv.Start()
if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized { if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized {
// Run RPC server in a separate routine. This is necessary to avoid a potential // Run RPC server in a separate routine. This is necessary to avoid a potential
@ -697,7 +697,7 @@ func initBlockChain(cfg config.Config, log *zap.Logger) (*core.Blockchain, stora
return chain, store, nil return chain, store, nil
} }
// Logo returns NeoGo logo. // Logo returns Tutus logo.
func Logo() string { func Logo() string {
return ` return `
_ ____________ __________ _ ____________ __________

View File

@ -24,7 +24,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/encoding/fixedn" "github.com/tutus-one/tutus-chain/pkg/encoding/fixedn"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/nef" "github.com/tutus-one/tutus-chain/pkg/smartcontract/nef"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger" "github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"
@ -176,7 +176,7 @@ package testcontract
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger" "github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
"myimport.com/testcontract" "myimport.com/testcontract"
) )
@ -185,22 +185,22 @@ const Hash = "\x10\x32\x54\x76\x98\x89\x67\x45\x23\x01\x10\x32\x54\x76\x98\x89\x
// Block invokes `+"`block`"+` method of contract. // Block invokes `+"`block`"+` method of contract.
func Block() *ledger.Block { func Block() *ledger.Block {
return neogointernal.CallWithToken(Hash, "block", int(contract.All)).(*ledger.Block) return tutusinternal.CallWithToken(Hash, "block", int(contract.All)).(*ledger.Block)
} }
// Blocks invokes `+"`blocks`"+` method of contract. // Blocks invokes `+"`blocks`"+` method of contract.
func Blocks() []*ledger.Block { func Blocks() []*ledger.Block {
return neogointernal.CallWithToken(Hash, "blocks", int(contract.All)).([]*ledger.Block) return tutusinternal.CallWithToken(Hash, "blocks", int(contract.All)).([]*ledger.Block)
} }
// ToArray invokes `+"`toArray`"+` method of contract. // ToArray invokes `+"`toArray`"+` method of contract.
func ToArray(m map[int]string) []testcontract.MyPair { func ToArray(m map[int]string) []testcontract.MyPair {
return neogointernal.CallWithToken(Hash, "toArray", int(contract.All), m).([]testcontract.MyPair) return tutusinternal.CallWithToken(Hash, "toArray", int(contract.All), m).([]testcontract.MyPair)
} }
// ToMap invokes `+"`toMap`"+` method of contract. // ToMap invokes `+"`toMap`"+` method of contract.
func ToMap(a []testcontract.MyPair) map[int]string { func ToMap(a []testcontract.MyPair) map[int]string {
return neogointernal.CallWithToken(Hash, "toMap", int(contract.All), a).(map[int]string) return tutusinternal.CallWithToken(Hash, "toMap", int(contract.All), a).(map[int]string)
} }
`, string(bs)) `, string(bs))
} }

View File

@ -161,7 +161,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/iterator" "github.com/tutus-one/tutus-chain/pkg/interop/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger" "github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
"github.com/tutus-one/tutus-chain/pkg/interop/storage" "github.com/tutus-one/tutus-chain/pkg/interop/storage"
) )
@ -170,62 +170,62 @@ const Hash = "\x04\x08\x15\x16\x23\x42\x43\x44\x00\x01\xca\xfe\xba\xbe\xde\xad\x
// Sum invokes ` + "`sum`" + ` method of contract. // Sum invokes ` + "`sum`" + ` method of contract.
func Sum(first int, second int) int { func Sum(first int, second int) int {
return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second).(int) return tutusinternal.CallWithToken(Hash, "sum", int(contract.All), first, second).(int)
} }
// Sum2 invokes ` + "`sum`" + ` method of contract. // Sum2 invokes ` + "`sum`" + ` method of contract.
func Sum2(first int, second int, third int) int { func Sum2(first int, second int, third int) int {
return neogointernal.CallWithToken(Hash, "sum", int(contract.All), first, second, third).(int) return tutusinternal.CallWithToken(Hash, "sum", int(contract.All), first, second, third).(int)
} }
// Sum3 invokes ` + "`sum3`" + ` method of contract. // Sum3 invokes ` + "`sum3`" + ` method of contract.
func Sum3() int { func Sum3() int {
return neogointernal.CallWithToken(Hash, "sum3", int(contract.ReadOnly)).(int) return tutusinternal.CallWithToken(Hash, "sum3", int(contract.ReadOnly)).(int)
} }
// Zum invokes ` + "`zum`" + ` method of contract. // Zum invokes ` + "`zum`" + ` method of contract.
func Zum(typev int, typev_ int, funcv int) int { func Zum(typev int, typev_ int, funcv int) int {
return neogointernal.CallWithToken(Hash, "zum", int(contract.All), typev, typev_, funcv).(int) return tutusinternal.CallWithToken(Hash, "zum", int(contract.All), typev, typev_, funcv).(int)
} }
// JustExecute invokes ` + "`justExecute`" + ` method of contract. // JustExecute invokes ` + "`justExecute`" + ` method of contract.
func JustExecute(arr []any) { func JustExecute(arr []any) {
neogointernal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr) tutusinternal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr)
} }
// GetPublicKey invokes ` + "`getPublicKey`" + ` method of contract. // GetPublicKey invokes ` + "`getPublicKey`" + ` method of contract.
func GetPublicKey() interop.PublicKey { func GetPublicKey() interop.PublicKey {
return neogointernal.CallWithToken(Hash, "getPublicKey", int(contract.All)).(interop.PublicKey) return tutusinternal.CallWithToken(Hash, "getPublicKey", int(contract.All)).(interop.PublicKey)
} }
// OtherTypes invokes ` + "`otherTypes`" + ` method of contract. // OtherTypes invokes ` + "`otherTypes`" + ` method of contract.
func OtherTypes(ctr interop.Hash160, tx interop.Hash256, sig interop.Signature, data any) bool { func OtherTypes(ctr interop.Hash160, tx interop.Hash256, sig interop.Signature, data any) bool {
return neogointernal.CallWithToken(Hash, "otherTypes", int(contract.All), ctr, tx, sig, data).(bool) return tutusinternal.CallWithToken(Hash, "otherTypes", int(contract.All), ctr, tx, sig, data).(bool)
} }
// SearchStorage invokes ` + "`searchStorage`" + ` method of contract. // SearchStorage invokes ` + "`searchStorage`" + ` method of contract.
func SearchStorage(ctx storage.Context) iterator.Iterator { func SearchStorage(ctx storage.Context) iterator.Iterator {
return neogointernal.CallWithToken(Hash, "searchStorage", int(contract.All), ctx).(iterator.Iterator) return tutusinternal.CallWithToken(Hash, "searchStorage", int(contract.All), ctx).(iterator.Iterator)
} }
// GetFromMap invokes ` + "`getFromMap`" + ` method of contract. // GetFromMap invokes ` + "`getFromMap`" + ` method of contract.
func GetFromMap(intMap map[string]int, indices []string) []int { func GetFromMap(intMap map[string]int, indices []string) []int {
return neogointernal.CallWithToken(Hash, "getFromMap", int(contract.All), intMap, indices).([]int) return tutusinternal.CallWithToken(Hash, "getFromMap", int(contract.All), intMap, indices).([]int)
} }
// DoSomething invokes ` + "`doSomething`" + ` method of contract. // DoSomething invokes ` + "`doSomething`" + ` method of contract.
func DoSomething(bytes []byte, str string) any { func DoSomething(bytes []byte, str string) any {
return neogointernal.CallWithToken(Hash, "doSomething", int(contract.ReadStates), bytes, str).(any) return tutusinternal.CallWithToken(Hash, "doSomething", int(contract.ReadStates), bytes, str).(any)
} }
// GetBlockWrapper invokes ` + "`getBlockWrapper`" + ` method of contract. // GetBlockWrapper invokes ` + "`getBlockWrapper`" + ` method of contract.
func GetBlockWrapper() ledger.Block { func GetBlockWrapper() ledger.Block {
return neogointernal.CallWithToken(Hash, "getBlockWrapper", int(contract.All)).(ledger.Block) return tutusinternal.CallWithToken(Hash, "getBlockWrapper", int(contract.All)).(ledger.Block)
} }
// MyFunc invokes ` + "`myFunc`" + ` method of contract. // MyFunc invokes ` + "`myFunc`" + ` method of contract.
func MyFunc(in map[int]mycontract.Input) []mycontract.Output { func MyFunc(in map[int]mycontract.Input) []mycontract.Output {
return neogointernal.CallWithToken(Hash, "myFunc", int(contract.All), in).([]mycontract.Output) return tutusinternal.CallWithToken(Hash, "myFunc", int(contract.All), in).([]mycontract.Output)
} }
` `
@ -365,7 +365,7 @@ package myspacecontract
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash contains contract hash in big-endian form. // Hash contains contract hash in big-endian form.
@ -373,7 +373,7 @@ const Hash = "\x04\x08\x15\x16\x23\x42\x43\x44\x00\x01\xca\xfe\xba\xbe\xde\xad\x
// Get invokes `+"`get`"+` method of contract. // Get invokes `+"`get`"+` method of contract.
func Get() int { func Get() int {
return neogointernal.CallWithToken(Hash, "get", int(contract.ReadOnly)).(int) return tutusinternal.CallWithToken(Hash, "get", int(contract.ReadOnly)).(int)
} }
`, string(data)) `, string(data))
e.Run(t, []string{"", "contract", "generate-rpcwrapper", e.Run(t, []string{"", "contract", "generate-rpcwrapper",
@ -390,7 +390,7 @@ func Get() int {
package myspacecontract package myspacecontract
import ( import (
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"math/big" "math/big"

View File

@ -7,7 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
"unicode/utf8" "unicode/utf8"

View File

@ -8,7 +8,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -7,7 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -7,7 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"

View File

@ -16,7 +16,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/compiler" "github.com/tutus-one/tutus-chain/pkg/compiler"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/actor" "github.com/tutus-one/tutus-chain/pkg/rpcclient/actor"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/invoker" "github.com/tutus-one/tutus-chain/pkg/rpcclient/invoker"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/management" "github.com/tutus-one/tutus-chain/pkg/rpcclient/management"

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -5,7 +5,7 @@ package nonnepxxcontractwithiterators
import ( import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap" "github.com/tutus-one/tutus-chain/pkg/rpcclient/unwrap"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"

View File

@ -11,7 +11,7 @@ import (
"github.com/tutus-one/tutus-chain/cli/txctx" "github.com/tutus-one/tutus-chain/cli/txctx"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/actor" "github.com/tutus-one/tutus-chain/pkg/rpcclient/actor"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/waiter" "github.com/tutus-one/tutus-chain/pkg/rpcclient/waiter"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -466,7 +466,7 @@ func NewWithConfig(printLogotype bool, onExit func(int), c *readline.Config, cfg
ctl.Writer = l.Stdout() ctl.Writer = l.Stdout()
ctl.ErrWriter = l.Stderr() ctl.ErrWriter = l.Stderr()
ctl.Version = config.Version ctl.Version = config.Version
ctl.Usage = "Official VM CLI for NeoGo" ctl.Usage = "Official VM CLI for Tutus"
// Override default error handler in order not to exit on error. // Override default error handler in order not to exit on error.
ctl.ExitErrHandler = func(context *cli.Context, err error) {} ctl.ExitErrHandler = func(context *cli.Context, err error) {}

View File

@ -34,8 +34,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/storage/dboper" "github.com/tutus-one/tutus-chain/pkg/core/storage/dboper"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm" "github.com/tutus-one/tutus-chain/pkg/vm"

View File

@ -12,7 +12,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/context" "github.com/tutus-one/tutus-chain/pkg/smartcontract/context"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -13,7 +13,7 @@ import (
"github.com/tutus-one/tutus-chain/cli/txctx" "github.com/tutus-one/tutus-chain/cli/txctx"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient" "github.com/tutus-one/tutus-chain/pkg/rpcclient"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -16,11 +16,11 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/encoding/fixedn" "github.com/tutus-one/tutus-chain/pkg/encoding/fixedn"
"github.com/tutus-one/tutus-chain/pkg/neorpc/result" "github.com/tutus-one/tutus-chain/pkg/tutusrpc/result"
"github.com/tutus-one/tutus-chain/pkg/rpcclient" "github.com/tutus-one/tutus-chain/pkg/rpcclient"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/actor" "github.com/tutus-one/tutus-chain/pkg/rpcclient/actor"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/gas" "github.com/tutus-one/tutus-chain/pkg/rpcclient/gas"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/neo" "github.com/tutus-one/tutus-chain/pkg/rpcclient/tutus"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep11"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/neptoken" "github.com/tutus-one/tutus-chain/pkg/rpcclient/neptoken"
@ -273,7 +273,7 @@ func getNEPBalance(ctx *cli.Context, standard string, accHandler func(*cli.Conte
// Well-known hardcoded names/symbols. // Well-known hardcoded names/symbols.
if standard == manifest.NEP17StandardName && (name == nativenames.Tutus || name == "NEO") { if standard == manifest.NEP17StandardName && (name == nativenames.Tutus || name == "NEO") {
h = neo.Hash h = tutus.Hash
} else if standard == manifest.NEP17StandardName && (name == nativenames.Lub || name == "GAS") { } else if standard == manifest.NEP17StandardName && (name == nativenames.Lub || name == "GAS") {
h = gas.Hash h = gas.Hash
} else { } else {

View File

@ -12,7 +12,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/gas" "github.com/tutus-one/tutus-chain/pkg/rpcclient/gas"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/neo" "github.com/tutus-one/tutus-chain/pkg/rpcclient/tutus"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nep17"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/wallet" "github.com/tutus-one/tutus-chain/pkg/wallet"
@ -102,11 +102,11 @@ func newValidatorCommands() []*cli.Command {
func handleRegister(ctx *cli.Context) error { func handleRegister(ctx *cli.Context) error {
if ctx.Bool("useRegisterCall") { if ctx.Bool("useRegisterCall") {
return handleNeoAction(ctx, func(contract *neo.Contract, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) { return handleNeoAction(ctx, func(contract *tutus.Contract, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
return contract.RegisterCandidateUnsigned(acc.PublicKey()) return contract.RegisterCandidateUnsigned(acc.PublicKey())
}) })
} }
return handleGasAction(ctx, func(nc *neo.Contract, gasT *nep17.Token, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) { return handleGasAction(ctx, func(nc *tutus.Contract, gasT *nep17.Token, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
regPrice, err := nc.GetRegisterPrice() regPrice, err := nc.GetRegisterPrice()
if err != nil { if err != nil {
return nil, err return nil, err
@ -121,24 +121,24 @@ func handleRegister(ctx *cli.Context) error {
} }
func handleUnregister(ctx *cli.Context) error { func handleUnregister(ctx *cli.Context) error {
return handleNeoAction(ctx, func(contract *neo.Contract, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) { return handleNeoAction(ctx, func(contract *tutus.Contract, _ util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
return contract.UnregisterCandidateUnsigned(acc.PublicKey()) return contract.UnregisterCandidateUnsigned(acc.PublicKey())
}) })
} }
func handleNeoAction(ctx *cli.Context, mkTx func(*neo.Contract, util.Uint160, *wallet.Account) (*transaction.Transaction, error)) error { func handleNeoAction(ctx *cli.Context, mkTx func(*tutus.Contract, util.Uint160, *wallet.Account) (*transaction.Transaction, error)) error {
return handleTokenAction(ctx, func(nc *neo.Contract, _ *nep17.Token, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) { return handleTokenAction(ctx, func(nc *tutus.Contract, _ *nep17.Token, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
return mkTx(nc, addr, acc) return mkTx(nc, addr, acc)
}, transaction.CalledByEntry) }, transaction.CalledByEntry)
} }
func handleGasAction(ctx *cli.Context, mkTx func(*neo.Contract, *nep17.Token, util.Uint160, *wallet.Account) (*transaction.Transaction, error)) error { func handleGasAction(ctx *cli.Context, mkTx func(*tutus.Contract, *nep17.Token, util.Uint160, *wallet.Account) (*transaction.Transaction, error)) error {
return handleTokenAction(ctx, mkTx, transaction.Global) return handleTokenAction(ctx, mkTx, transaction.Global)
} }
func handleTokenAction( func handleTokenAction(
ctx *cli.Context, ctx *cli.Context,
mkTx func(nc *neo.Contract, gasT *nep17.Token, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error), mkTx func(nc *tutus.Contract, gasT *nep17.Token, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error),
scope transaction.WitnessScope, scope transaction.WitnessScope,
) error { ) error {
if err := cmdargs.EnsureNone(ctx); err != nil { if err := cmdargs.EnsureNone(ctx); err != nil {
@ -169,7 +169,7 @@ func handleTokenAction(
return exitErr return exitErr
} }
neoT := neo.New(act) neoT := tutus.New(act)
gasT := gas.New(act) gasT := gas.New(act)
tx, err := mkTx(neoT, gasT, addr, acc) tx, err := mkTx(neoT, gasT, addr, acc)
if err != nil { if err != nil {
@ -179,7 +179,7 @@ func handleTokenAction(
} }
func handleVote(ctx *cli.Context) error { func handleVote(ctx *cli.Context) error {
return handleNeoAction(ctx, func(contract *neo.Contract, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) { return handleNeoAction(ctx, func(contract *tutus.Contract, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
var ( var (
err error err error
pub *keys.PublicKey pub *keys.PublicKey

View File

@ -19,7 +19,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/neo" "github.com/tutus-one/tutus-chain/pkg/rpcclient/tutus"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/scparser" "github.com/tutus-one/tutus-chain/pkg/smartcontract/scparser"
@ -121,7 +121,7 @@ func NewCommands() []*cli.Command {
signFlags = append(signFlags, options.RPC[1:]...) signFlags = append(signFlags, options.RPC[1:]...)
return []*cli.Command{{ return []*cli.Command{{
Name: "wallet", Name: "wallet",
Usage: "Create, open and manage a Neo wallet", Usage: "Create, open and manage a Tutus wallet",
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
{ {
Name: "claim", Name: "claim",
@ -188,7 +188,7 @@ func NewCommands() []*cli.Command {
}, },
{ {
Name: "dump", Name: "dump",
Usage: "Check and dump an existing Neo wallet", Usage: "Check and dump an existing Tutus wallet",
UsageText: "neo-go wallet dump -w wallet [--wallet-config path] [-d]", UsageText: "neo-go wallet dump -w wallet [--wallet-config path] [-d]",
Description: `Prints the given wallet (via -w option or via wallet configuration file) in JSON Description: `Prints the given wallet (via -w option or via wallet configuration file) in JSON
format to the standard output. If -d is given, private keys are unencrypted and format to the standard output. If -d is given, private keys are unencrypted and
@ -375,7 +375,7 @@ func NewCommands() []*cli.Command {
} }
func claimGas(ctx *cli.Context) error { func claimGas(ctx *cli.Context) error {
return handleNeoAction(ctx, func(contract *neo.Contract, shash util.Uint160, _ *wallet.Account) (*transaction.Transaction, error) { return handleNeoAction(ctx, func(contract *tutus.Contract, shash util.Uint160, _ *wallet.Account) (*transaction.Transaction, error) {
return contract.TransferUnsigned(shash, shash, big.NewInt(0), nil) return contract.TransferUnsigned(shash, shash, big.NewInt(0), nil)
}) })
} }

View File

@ -7,8 +7,8 @@ import (
nns "github.com/tutus-one/tutus-chain/examples/nft-nd-nns" nns "github.com/tutus-one/tutus-chain/examples/nft-nd-nns"
"github.com/tutus-one/tutus-chain/pkg/compiler" "github.com/tutus-one/tutus-chain/pkg/compiler"
"github.com/tutus-one/tutus-chain/pkg/core/interop/storage" "github.com/tutus-one/tutus-chain/pkg/core/interop/storage"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View File

@ -16,8 +16,8 @@ import (
"github.com/consensys/gnark/frontend" "github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/frontend/cs/r1cs" "github.com/consensys/gnark/frontend/cs/r1cs"
"github.com/consensys/gnark/test" "github.com/consensys/gnark/test"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/zkpbinding" "github.com/tutus-one/tutus-chain/pkg/smartcontract/zkpbinding"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

7
go.mod
View File

@ -14,17 +14,17 @@ require (
github.com/holiman/uint256 v1.3.2 github.com/holiman/uint256 v1.3.2
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mr-tron/base58 v1.2.0 github.com/mr-tron/base58 v1.2.0
github.com/nspcc-dev/bbolt v0.0.0-20250911202005-807225ebb0c8
github.com/nspcc-dev/go-ordered-json v0.0.0-20250911084817-6fb4472993d1
github.com/nspcc-dev/neo-go v0.113.0 github.com/nspcc-dev/neo-go v0.113.0
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.16 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.16
github.com/nspcc-dev/rfc6979 v0.2.4
github.com/pierrec/lz4 v2.6.1+incompatible github.com/pierrec/lz4 v2.6.1+incompatible
github.com/prometheus/client_golang v1.23.2 github.com/prometheus/client_golang v1.23.2
github.com/stretchr/testify v1.11.1 github.com/stretchr/testify v1.11.1
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
github.com/tutus-one/tutus-bolt v1.0.0
github.com/tutus-one/tutus-chain/pkg/interop v0.0.0-20251217090505-857f951d81a9 github.com/tutus-one/tutus-chain/pkg/interop v0.0.0-20251217090505-857f951d81a9
github.com/tutus-one/tutus-consensus v1.0.0 github.com/tutus-one/tutus-consensus v1.0.0
github.com/tutus-one/tutus-ordered-json v1.0.0
github.com/tutus-one/tutus-rfc6979 v1.0.0
github.com/twmb/murmur3 v1.1.8 github.com/twmb/murmur3 v1.1.8
github.com/urfave/cli/v2 v2.27.7 github.com/urfave/cli/v2 v2.27.7
go.uber.org/zap v1.27.0 go.uber.org/zap v1.27.0
@ -51,6 +51,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nspcc-dev/hrw/v2 v2.0.4 // indirect github.com/nspcc-dev/hrw/v2 v2.0.4 // indirect
github.com/nspcc-dev/rfc6979 v0.2.4 // indirect
github.com/nspcc-dev/tzhash v1.8.3 // indirect github.com/nspcc-dev/tzhash v1.8.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/client_model v0.6.2 // indirect

8
go.sum
View File

@ -145,8 +145,6 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nspcc-dev/bbolt v0.0.0-20250911202005-807225ebb0c8 h1:lYMHisGPtL70vqCe/M+cU27HMZcV2PTYTaRmO7qxhMQ=
github.com/nspcc-dev/bbolt v0.0.0-20250911202005-807225ebb0c8/go.mod h1:iYl+DCkSLXgVCeQWyC+kqS9V1fAQCA74JZtptwjNYpc=
github.com/nspcc-dev/go-ordered-json v0.0.0-20250911084817-6fb4472993d1 h1:U3wvYzJi07NzN4I0fwt1Uznp92xKkfkTcAyC+TsxP9E= github.com/nspcc-dev/go-ordered-json v0.0.0-20250911084817-6fb4472993d1 h1:U3wvYzJi07NzN4I0fwt1Uznp92xKkfkTcAyC+TsxP9E=
github.com/nspcc-dev/go-ordered-json v0.0.0-20250911084817-6fb4472993d1/go.mod h1:CHwf1nwquA6ecSfxmNF0YuemOPHAnRGoLuZUv/WPjeY= github.com/nspcc-dev/go-ordered-json v0.0.0-20250911084817-6fb4472993d1/go.mod h1:CHwf1nwquA6ecSfxmNF0YuemOPHAnRGoLuZUv/WPjeY=
github.com/nspcc-dev/hrw/v2 v2.0.4 h1:o3Zh/2aF+IgGpvt414f46Ya20WG9u9vWxVd16ErFI8w= github.com/nspcc-dev/hrw/v2 v2.0.4 h1:o3Zh/2aF+IgGpvt414f46Ya20WG9u9vWxVd16ErFI8w=
@ -211,8 +209,14 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
github.com/tutus-one/tutus-bolt v1.0.0 h1:+O167MPPixi8254zWs1lYwsZ6QBhJCaIJQf9Qc4u4q0=
github.com/tutus-one/tutus-bolt v1.0.0/go.mod h1:v5z98B9Ao/zkKsG8S9cwTovD1UsdN8mmdQTXiaBbPVo=
github.com/tutus-one/tutus-consensus v1.0.0 h1:PFMXSSSYjTnbymoIjU2L30ckf92j2kVwrmtRnkuGlnY= github.com/tutus-one/tutus-consensus v1.0.0 h1:PFMXSSSYjTnbymoIjU2L30ckf92j2kVwrmtRnkuGlnY=
github.com/tutus-one/tutus-consensus v1.0.0/go.mod h1:hpA/0rPM0Frdh9cowAp//vQTMN8j6Q0GYq1BFlpCLVM= github.com/tutus-one/tutus-consensus v1.0.0/go.mod h1:hpA/0rPM0Frdh9cowAp//vQTMN8j6Q0GYq1BFlpCLVM=
github.com/tutus-one/tutus-ordered-json v1.0.0 h1:/wPlNUwyqs+SUO2+Ra2sGJ2FrvQjIrh2McFDQ6moR7Y=
github.com/tutus-one/tutus-ordered-json v1.0.0/go.mod h1:M58J4PCtf7JauNaz2jgi8yKUygKMSqqG6YEa2rhRfuU=
github.com/tutus-one/tutus-rfc6979 v1.0.0 h1:eFPDOMle4Wv2RmC9DLTO4R6vjQjx5c6H9+RrdoFNeLM=
github.com/tutus-one/tutus-rfc6979 v1.0.0/go.mod h1:qary3d/z/0Zwb06/wqXv1/FHuP8rBJHrP66/8wDFaTA=
github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg= github.com/twmb/murmur3 v1.1.8 h1:8Yt9taO/WN3l08xErzjeschgZU2QSrwm1kclYq+0aRg=
github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= github.com/twmb/murmur3 v1.1.8/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=

View File

@ -14,7 +14,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/noderoles" "github.com/tutus-one/tutus-chain/pkg/core/native/noderoles"
"github.com/tutus-one/tutus-chain/pkg/encoding/fixedn" "github.com/tutus-one/tutus-chain/pkg/encoding/fixedn"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/nns" "github.com/tutus-one/tutus-chain/pkg/rpcclient/nns"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/opcode" "github.com/tutus-one/tutus-chain/pkg/vm/opcode"

View File

@ -10,8 +10,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -23,8 +23,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/encoding/base58" "github.com/tutus-one/tutus-chain/pkg/encoding/base58"
cinterop "github.com/tutus-one/tutus-chain/pkg/interop" cinterop "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
@ -555,39 +555,39 @@ func TestLenForNil(t *testing.T) {
func TestCallTConversionErrors(t *testing.T) { func TestCallTConversionErrors(t *testing.T) {
t.Run("variable hash", func(t *testing.T) { t.Run("variable hash", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func Main() int { func Main() int {
var hash string var hash string
return neogointernal.CallWithToken(hash, "method", 0).(int) return tutusinternal.CallWithToken(hash, "method", 0).(int)
}` }`
_, err := compiler.Compile("foo.go", strings.NewReader(src)) _, err := compiler.Compile("foo.go", strings.NewReader(src))
require.Error(t, err) require.Error(t, err)
}) })
t.Run("bad hash", func(t *testing.T) { t.Run("bad hash", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func Main() int { func Main() int {
return neogointernal.CallWithToken("badstring", "method", 0).(int) return tutusinternal.CallWithToken("badstring", "method", 0).(int)
}` }`
_, err := compiler.Compile("foo.go", strings.NewReader(src)) _, err := compiler.Compile("foo.go", strings.NewReader(src))
require.Error(t, err) require.Error(t, err)
}) })
t.Run("variable method", func(t *testing.T) { t.Run("variable method", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func Main() int { func Main() int {
var method string var method string
return neogointernal.CallWithToken("\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef", method, 0).(int) return tutusinternal.CallWithToken("\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef", method, 0).(int)
}` }`
_, err := compiler.Compile("foo.go", strings.NewReader(src)) _, err := compiler.Compile("foo.go", strings.NewReader(src))
require.Error(t, err) require.Error(t, err)
}) })
t.Run("variable flags", func(t *testing.T) { t.Run("variable flags", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func Main() { func Main() {
var flags int var flags int
neogointernal.CallWithTokenNoRet("\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef", "method", flags) tutusinternal.CallWithTokenNoRet("\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef", "method", flags)
}` }`
_, err := compiler.Compile("foo.go", strings.NewReader(src)) _, err := compiler.Compile("foo.go", strings.NewReader(src))
require.Error(t, err) require.Error(t, err)

View File

@ -253,9 +253,9 @@ func TestSyscallInGlobalInit(t *testing.T) {
func TestOpcode(t *testing.T) { func TestOpcode(t *testing.T) {
t.Run("1 argument", func(t *testing.T) { t.Run("1 argument", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func abs(a int) int { func abs(a int) int {
return neogointernal.Opcode1("ABS", a).(int) return tutusinternal.Opcode1("ABS", a).(int)
} }
func Main() int { func Main() int {
return abs(-42) return abs(-42)
@ -264,10 +264,10 @@ func TestOpcode(t *testing.T) {
}) })
t.Run("2 arguments", func(t *testing.T) { t.Run("2 arguments", func(t *testing.T) {
src := `package foo src := `package foo
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
func add3(a, b, c int) int { func add3(a, b, c int) int {
return neogointernal.Opcode2("SUB", a, return tutusinternal.Opcode2("SUB", a,
neogointernal.Opcode2("SUB", b, c).(int)).(int) tutusinternal.Opcode2("SUB", b, c).(int)).(int)
} }
func Main() int { func Main() int {
return add3(53, 12, 1) return add3(53, 12, 1)

View File

@ -9,8 +9,8 @@ import (
"github.com/tutus-one/tutus-chain/internal/basicchain" "github.com/tutus-one/tutus-chain/internal/basicchain"
"github.com/tutus-one/tutus-chain/pkg/core/chaindump" "github.com/tutus-one/tutus-chain/pkg/core/chaindump"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -14,8 +14,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig" "github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/wallet" "github.com/tutus-one/tutus-chain/pkg/wallet"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View File

@ -13,7 +13,7 @@ import (
"time" "time"
lru "github.com/hashicorp/golang-lru/v2" lru "github.com/hashicorp/golang-lru/v2"
json "github.com/nspcc-dev/go-ordered-json" json "github.com/tutus-one/tutus-ordered-json"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/config/limits" "github.com/tutus-one/tutus-chain/pkg/config/limits"
"github.com/tutus-one/tutus-chain/pkg/core/block" "github.com/tutus-one/tutus-chain/pkg/core/block"

View File

@ -37,8 +37,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger" "github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"

View File

@ -9,8 +9,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/block" "github.com/tutus-one/tutus-chain/pkg/core/block"
"github.com/tutus-one/tutus-chain/pkg/core/chaindump" "github.com/tutus-one/tutus-chain/pkg/core/chaindump"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -13,8 +13,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -12,8 +12,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/emit" "github.com/tutus-one/tutus-chain/pkg/vm/emit"

View File

@ -18,8 +18,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native" "github.com/tutus-one/tutus-chain/pkg/core/native"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -25,8 +25,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/encoding/address" "github.com/tutus-one/tutus-chain/pkg/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -17,8 +17,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/nef" "github.com/tutus-one/tutus-chain/pkg/smartcontract/nef"

View File

@ -13,8 +13,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger" "github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -8,8 +8,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/nef" "github.com/tutus-one/tutus-chain/pkg/smartcontract/nef"

View File

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -10,8 +10,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/vm/emit" "github.com/tutus-one/tutus-chain/pkg/vm/emit"
"github.com/tutus-one/tutus-chain/pkg/vm/opcode" "github.com/tutus-one/tutus-chain/pkg/vm/opcode"

View File

@ -14,8 +14,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native" "github.com/tutus-one/tutus-chain/pkg/core/native"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/vm/emit" "github.com/tutus-one/tutus-chain/pkg/vm/emit"
"github.com/tutus-one/tutus-chain/pkg/vm/opcode" "github.com/tutus-one/tutus-chain/pkg/vm/opcode"

View File

@ -13,7 +13,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/emit" "github.com/tutus-one/tutus-chain/pkg/vm/emit"

View File

@ -10,8 +10,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/emit" "github.com/tutus-one/tutus-chain/pkg/vm/emit"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -9,8 +9,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/noderoles" "github.com/tutus-one/tutus-chain/pkg/core/native/noderoles"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/opcode" "github.com/tutus-one/tutus-chain/pkg/vm/opcode"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"

View File

@ -1,165 +1,165 @@
package native_test package native_test
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"testing" "testing"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
) )
// TestGenerateExpectedContractStates outputs the current contract states as JSON // TestGenerateExpectedContractStates outputs the current contract states as JSON
// for updating the defaultCSS, cockatriceCSS, echidnaCSS, and faunCSS maps. // for updating the defaultCSS, cockatriceCSS, echidnaCSS, and faunCSS maps.
// Run with: go test -v -run TestGenerateExpectedContractStates // Run with: go test -v -run TestGenerateExpectedContractStates
func TestGenerateExpectedContractStates(t *testing.T) { func TestGenerateExpectedContractStates(t *testing.T) {
const ( const (
cockatriceHeight = 3 cockatriceHeight = 3
domovoiHeight = 5 domovoiHeight = 5
echidnaHeight = 6 echidnaHeight = 6
faunHeight = 7 faunHeight = 7
) )
bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) { bc, acc := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
cfg.Hardforks = map[string]uint32{ cfg.Hardforks = map[string]uint32{
config.HFAspidochelone.String(): 0, config.HFAspidochelone.String(): 0,
config.HFBasilisk.String(): 0, config.HFBasilisk.String(): 0,
config.HFCockatrice.String(): cockatriceHeight, config.HFCockatrice.String(): cockatriceHeight,
config.HFDomovoi.String(): domovoiHeight, config.HFDomovoi.String(): domovoiHeight,
config.HFEchidna.String(): echidnaHeight, config.HFEchidna.String(): echidnaHeight,
config.HFFaun.String(): faunHeight, config.HFFaun.String(): faunHeight,
} }
}) })
e := neotest.NewExecutor(t, bc, acc, acc) e := neotest.NewExecutor(t, bc, acc, acc)
// Generate defaultCSS (genesis state) // Generate defaultCSS (genesis state)
fmt.Println("\n=== defaultCSS (genesis) ===") fmt.Println("\n=== defaultCSS (genesis) ===")
fmt.Println("defaultCSS = map[string]string{") fmt.Println("defaultCSS = map[string]string{")
natives := bc.GetNatives() natives := bc.GetNatives()
for _, cs := range natives { for _, cs := range natives {
csFull := state.Contract{ csFull := state.Contract{
ContractBase: cs.ContractBase, ContractBase: cs.ContractBase,
UpdateCounter: 0, UpdateCounter: 0,
} }
jBytes, err := json.Marshal(csFull) jBytes, err := json.Marshal(csFull)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes)) fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes))
} }
fmt.Println("}") fmt.Println("}")
// Generate cockatriceCSS // Generate cockatriceCSS
e.GenerateNewBlocks(t, cockatriceHeight) e.GenerateNewBlocks(t, cockatriceHeight)
fmt.Println("\n=== cockatriceCSS ===") fmt.Println("\n=== cockatriceCSS ===")
fmt.Println("cockatriceCSS = map[string]string{") fmt.Println("cockatriceCSS = map[string]string{")
natives = bc.GetNatives() natives = bc.GetNatives()
for _, cs := range natives { for _, cs := range natives {
csFull := state.Contract{ csFull := state.Contract{
ContractBase: cs.ContractBase, ContractBase: cs.ContractBase,
UpdateCounter: 0, UpdateCounter: 0,
} }
jBytes, err := json.Marshal(csFull) jBytes, err := json.Marshal(csFull)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes)) fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes))
} }
fmt.Println("}") fmt.Println("}")
// Generate echidnaCSS // Generate echidnaCSS
e.GenerateNewBlocks(t, echidnaHeight-cockatriceHeight) e.GenerateNewBlocks(t, echidnaHeight-cockatriceHeight)
fmt.Println("\n=== echidnaCSS ===") fmt.Println("\n=== echidnaCSS ===")
fmt.Println("echidnaCSS = map[string]string{") fmt.Println("echidnaCSS = map[string]string{")
natives = bc.GetNatives() natives = bc.GetNatives()
for _, cs := range natives { for _, cs := range natives {
csFull := state.Contract{ csFull := state.Contract{
ContractBase: cs.ContractBase, ContractBase: cs.ContractBase,
UpdateCounter: 0, UpdateCounter: 0,
} }
jBytes, err := json.Marshal(csFull) jBytes, err := json.Marshal(csFull)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes)) fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes))
} }
fmt.Println("}") fmt.Println("}")
// Generate faunCSS // Generate faunCSS
e.GenerateNewBlocks(t, faunHeight-echidnaHeight) e.GenerateNewBlocks(t, faunHeight-echidnaHeight)
fmt.Println("\n=== faunCSS ===") fmt.Println("\n=== faunCSS ===")
fmt.Println("faunCSS = map[string]string{") fmt.Println("faunCSS = map[string]string{")
natives = bc.GetNatives() natives = bc.GetNatives()
for _, cs := range natives { for _, cs := range natives {
csFull := state.Contract{ csFull := state.Contract{
ContractBase: cs.ContractBase, ContractBase: cs.ContractBase,
UpdateCounter: 0, UpdateCounter: 0,
} }
jBytes, err := json.Marshal(csFull) jBytes, err := json.Marshal(csFull)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes)) fmt.Printf("\tnativenames.%s: `%s`,\n", getConstName(cs.Manifest.Name), string(jBytes))
} }
fmt.Println("}") fmt.Println("}")
} }
func getConstName(name string) string { func getConstName(name string) string {
switch name { switch name {
case "ContractManagement": case "ContractManagement":
return "Management" return "Management"
case "StdLib": case "StdLib":
return "StdLib" return "StdLib"
case "CryptoLib": case "CryptoLib":
return "CryptoLib" return "CryptoLib"
case "LedgerContract": case "LedgerContract":
return "Ledger" return "Ledger"
case "TutusToken": case "TutusToken":
return "Tutus" return "Tutus"
case "LubToken": case "LubToken":
return "Lub" return "Lub"
case "PolicyContract": case "PolicyContract":
return "Policy" return "Policy"
case "OracleContract": case "OracleContract":
return "Oracle" return "Oracle"
case "RoleManagement": case "RoleManagement":
return "Designation" return "Designation"
case "Notary": case "Notary":
return "Notary" return "Notary"
case "VitaToken": case "VitaToken":
return "Vita" return "Vita"
case "VtsToken": case "VtsToken":
return "Vts" return "Vts"
case "LexContract": case "LexContract":
return "Lex" return "Lex"
case "ScireContract": case "ScireContract":
return "Scire" return "Scire"
case "SalusContract": case "SalusContract":
return "Salus" return "Salus"
case "SeseContract": case "SeseContract":
return "Sese" return "Sese"
case "TributeContract": case "TributeContract":
return "Tribute" return "Tribute"
case "EligereContract": case "EligereContract":
return "Eligere" return "Eligere"
case "OpusContract": case "OpusContract":
return "Opus" return "Opus"
case "PalamContract": case "PalamContract":
return "Palam" return "Palam"
case "PonsContract": case "PonsContract":
return "Pons" return "Pons"
case "CollocatioContract": case "CollocatioContract":
return "Collocatio" return "Collocatio"
case "AnnosContract": case "AnnosContract":
return "Annos" return "Annos"
case "RoleRegistry": case "RoleRegistry":
return "RoleRegistry" return "RoleRegistry"
case "Treasury": case "Treasury":
return "Treasury" return "Treasury"
case "Federation": case "Federation":
return "Federation" return "Federation"
default: default:
return name return name
} }
} }

View File

@ -10,8 +10,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/opcode" "github.com/tutus-one/tutus-chain/pkg/vm/opcode"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
"testing" "testing"
ojson "github.com/nspcc-dev/go-ordered-json" ojson "github.com/tutus-one/tutus-ordered-json"
"github.com/tutus-one/tutus-chain/internal/contracts" "github.com/tutus-one/tutus-chain/internal/contracts"
"github.com/tutus-one/tutus-chain/pkg/compiler" "github.com/tutus-one/tutus-chain/pkg/compiler"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
@ -23,8 +23,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"

View File

@ -22,8 +22,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract" "github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger" "github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"

View File

@ -13,8 +13,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/noderoles" "github.com/tutus-one/tutus-chain/pkg/core/native/noderoles"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/notary" "github.com/tutus-one/tutus-chain/pkg/rpcclient/notary"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -14,7 +14,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/noderoles" "github.com/tutus-one/tutus-chain/pkg/core/native/noderoles"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys" "github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger" "github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -18,8 +18,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag" "github.com/tutus-one/tutus-chain/pkg/smartcontract/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest" "github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -1,296 +1,296 @@
package native_test package native_test
import ( import (
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )
func newRoleRegistryClient(t *testing.T) *neotest.ContractInvoker { func newRoleRegistryClient(t *testing.T) *neotest.ContractInvoker {
return newNativeClient(t, nativenames.RoleRegistry) return newNativeClient(t, nativenames.RoleRegistry)
} }
// TestRoleRegistry_BuiltinRoles tests that built-in roles are created at initialization. // TestRoleRegistry_BuiltinRoles tests that built-in roles are created at initialization.
func TestRoleRegistry_BuiltinRoles(t *testing.T) { func TestRoleRegistry_BuiltinRoles(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
// Check totalRoles returns at least 4 (the built-in roles) // Check totalRoles returns at least 4 (the built-in roles)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
count, err := stack[0].TryInteger() count, err := stack[0].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.GreaterOrEqual(t, count.Int64(), int64(4)) require.GreaterOrEqual(t, count.Int64(), int64(4))
}, "totalRoles") }, "totalRoles")
// Check COMMITTEE role exists (ID=1) // Check COMMITTEE role exists (ID=1)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
// Should be an array (role struct) // Should be an array (role struct)
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
require.Equal(t, 7, len(arr)) // Role has 7 fields require.Equal(t, 7, len(arr)) // Role has 7 fields
// Check role ID is 1 // Check role ID is 1
id, err := arr[0].TryInteger() id, err := arr[0].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, int64(1), id.Int64()) require.Equal(t, int64(1), id.Int64())
// Check name is COMMITTEE // Check name is COMMITTEE
name, err := arr[1].TryBytes() name, err := arr[1].TryBytes()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "COMMITTEE", string(name)) require.Equal(t, "COMMITTEE", string(name))
// Check role is active // Check role is active
active, err := arr[6].TryBool() active, err := arr[6].TryBool()
require.NoError(t, err) require.NoError(t, err)
require.True(t, active) require.True(t, active)
}, "getRole", 1) }, "getRole", 1)
// Check REGISTRAR role exists (ID=2) // Check REGISTRAR role exists (ID=2)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
name, err := arr[1].TryBytes() name, err := arr[1].TryBytes()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "REGISTRAR", string(name)) require.Equal(t, "REGISTRAR", string(name))
}, "getRole", 2) }, "getRole", 2)
// Check ATTESTOR role exists (ID=3) // Check ATTESTOR role exists (ID=3)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
name, err := arr[1].TryBytes() name, err := arr[1].TryBytes()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "ATTESTOR", string(name)) require.Equal(t, "ATTESTOR", string(name))
}, "getRole", 3) }, "getRole", 3)
// Check OPERATOR role exists (ID=4) // Check OPERATOR role exists (ID=4)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
name, err := arr[1].TryBytes() name, err := arr[1].TryBytes()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "OPERATOR", string(name)) require.Equal(t, "OPERATOR", string(name))
}, "getRole", 4) }, "getRole", 4)
} }
// TestRoleRegistry_GetRoleByName tests looking up roles by name. // TestRoleRegistry_GetRoleByName tests looking up roles by name.
func TestRoleRegistry_GetRoleByName(t *testing.T) { func TestRoleRegistry_GetRoleByName(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
// Look up COMMITTEE by name // Look up COMMITTEE by name
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
id, err := arr[0].TryInteger() id, err := arr[0].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, int64(1), id.Int64()) require.Equal(t, int64(1), id.Int64())
}, "getRoleByName", "COMMITTEE") }, "getRoleByName", "COMMITTEE")
// Look up non-existent role by name // Look up non-existent role by name
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
require.Nil(t, stack[0].Value()) require.Nil(t, stack[0].Value())
}, "getRoleByName", "NONEXISTENT") }, "getRoleByName", "NONEXISTENT")
} }
// TestRoleRegistry_HasRole tests checking if an address has a role. // TestRoleRegistry_HasRole tests checking if an address has a role.
func TestRoleRegistry_HasRole(t *testing.T) { func TestRoleRegistry_HasRole(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
// Account should not have COMMITTEE role initially // Account should not have COMMITTEE role initially
c.Invoke(t, false, "hasRole", acc.ScriptHash(), 1) c.Invoke(t, false, "hasRole", acc.ScriptHash(), 1)
// Grant COMMITTEE role (committee only) // Grant COMMITTEE role (committee only)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), 1, 0) committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), 1, 0)
// Now account should have COMMITTEE role // Now account should have COMMITTEE role
c.Invoke(t, true, "hasRole", acc.ScriptHash(), 1) c.Invoke(t, true, "hasRole", acc.ScriptHash(), 1)
} }
// TestRoleRegistry_GrantRevokeRole tests granting and revoking roles. // TestRoleRegistry_GrantRevokeRole tests granting and revoking roles.
func TestRoleRegistry_GrantRevokeRole(t *testing.T) { func TestRoleRegistry_GrantRevokeRole(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Non-committee cannot grant roles // Non-committee cannot grant roles
userInvoker := c.WithSigners(acc) userInvoker := c.WithSigners(acc)
userInvoker.InvokeFail(t, "caller is not a committee member", "grantRole", acc.ScriptHash(), 2, 0) userInvoker.InvokeFail(t, "caller is not a committee member", "grantRole", acc.ScriptHash(), 2, 0)
// Committee can grant role // Committee can grant role
committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), 2, 0) committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), 2, 0)
// Check role is granted // Check role is granted
c.Invoke(t, true, "hasRole", acc.ScriptHash(), 2) c.Invoke(t, true, "hasRole", acc.ScriptHash(), 2)
// Get roles for address // Get roles for address
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array") require.True(t, ok, "expected array")
require.GreaterOrEqual(t, len(arr), 1) require.GreaterOrEqual(t, len(arr), 1)
}, "getRolesForAddress", acc.ScriptHash()) }, "getRolesForAddress", acc.ScriptHash())
// Non-committee cannot revoke roles // Non-committee cannot revoke roles
userInvoker.InvokeFail(t, "caller is not a committee member", "revokeRole", acc.ScriptHash(), 2) userInvoker.InvokeFail(t, "caller is not a committee member", "revokeRole", acc.ScriptHash(), 2)
// Committee can revoke role // Committee can revoke role
committeeInvoker.Invoke(t, true, "revokeRole", acc.ScriptHash(), 2) committeeInvoker.Invoke(t, true, "revokeRole", acc.ScriptHash(), 2)
// Check role is revoked // Check role is revoked
c.Invoke(t, false, "hasRole", acc.ScriptHash(), 2) c.Invoke(t, false, "hasRole", acc.ScriptHash(), 2)
} }
// TestRoleRegistry_CreateRole tests creating custom roles. // TestRoleRegistry_CreateRole tests creating custom roles.
func TestRoleRegistry_CreateRole(t *testing.T) { func TestRoleRegistry_CreateRole(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Non-committee cannot create roles // Non-committee cannot create roles
userInvoker := c.WithSigners(acc) userInvoker := c.WithSigners(acc)
userInvoker.InvokeFail(t, "caller is not a committee member", "createRole", "CUSTOM_ROLE", "A custom role", 0) userInvoker.InvokeFail(t, "caller is not a committee member", "createRole", "CUSTOM_ROLE", "A custom role", 0)
// Committee can create role // Committee can create role
committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
roleID, err := stack[0].TryInteger() roleID, err := stack[0].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.GreaterOrEqual(t, roleID.Int64(), int64(5)) // Custom roles start at 5 require.GreaterOrEqual(t, roleID.Int64(), int64(5)) // Custom roles start at 5
}, "createRole", "CUSTOM_ROLE", "A custom role", 0) }, "createRole", "CUSTOM_ROLE", "A custom role", 0)
// Verify role exists // Verify role exists
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
name, err := arr[1].TryBytes() name, err := arr[1].TryBytes()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "CUSTOM_ROLE", string(name)) require.Equal(t, "CUSTOM_ROLE", string(name))
}, "getRoleByName", "CUSTOM_ROLE") }, "getRoleByName", "CUSTOM_ROLE")
// Cannot create duplicate role name // Cannot create duplicate role name
committeeInvoker.InvokeFail(t, "role name already exists", "createRole", "CUSTOM_ROLE", "Duplicate", 0) committeeInvoker.InvokeFail(t, "role name already exists", "createRole", "CUSTOM_ROLE", "Duplicate", 0)
} }
// TestRoleRegistry_DeleteRole tests deleting (deactivating) roles. // TestRoleRegistry_DeleteRole tests deleting (deactivating) roles.
func TestRoleRegistry_DeleteRole(t *testing.T) { func TestRoleRegistry_DeleteRole(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Create a custom role first // Create a custom role first
var customRoleID int64 var customRoleID int64
committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
roleID, _ := stack[0].TryInteger() roleID, _ := stack[0].TryInteger()
customRoleID = roleID.Int64() customRoleID = roleID.Int64()
}, "createRole", "DELETE_TEST", "Role to delete", 0) }, "createRole", "DELETE_TEST", "Role to delete", 0)
// Cannot delete built-in roles // Cannot delete built-in roles
committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 1) committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 1)
committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 2) committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 2)
committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 3) committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 3)
committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 4) committeeInvoker.InvokeFail(t, "cannot modify built-in role", "deleteRole", 4)
// Can delete custom role // Can delete custom role
committeeInvoker.Invoke(t, true, "deleteRole", customRoleID) committeeInvoker.Invoke(t, true, "deleteRole", customRoleID)
// Verify role is deactivated (still exists but not active) // Verify role is deactivated (still exists but not active)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array for role") require.True(t, ok, "expected array for role")
active, err := arr[6].TryBool() active, err := arr[6].TryBool()
require.NoError(t, err) require.NoError(t, err)
require.False(t, active) require.False(t, active)
}, "getRole", customRoleID) }, "getRole", customRoleID)
} }
// TestRoleRegistry_Permissions tests assigning and checking permissions. // TestRoleRegistry_Permissions tests assigning and checking permissions.
func TestRoleRegistry_Permissions(t *testing.T) { func TestRoleRegistry_Permissions(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Create a custom role // Create a custom role
var customRoleID int64 var customRoleID int64
committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
roleID, _ := stack[0].TryInteger() roleID, _ := stack[0].TryInteger()
customRoleID = roleID.Int64() customRoleID = roleID.Int64()
}, "createRole", "PERM_TEST", "Permission test role", 0) }, "createRole", "PERM_TEST", "Permission test role", 0)
// Assign permission to role // Assign permission to role
committeeInvoker.Invoke(t, true, "assignPermission", customRoleID, "documents", "read", 0) committeeInvoker.Invoke(t, true, "assignPermission", customRoleID, "documents", "read", 0)
// Grant role to account // Grant role to account
committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), customRoleID, 0) committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), customRoleID, 0)
// Check account has permission // Check account has permission
c.Invoke(t, true, "hasPermission", acc.ScriptHash(), "documents", "read", 0) c.Invoke(t, true, "hasPermission", acc.ScriptHash(), "documents", "read", 0)
// Check account does NOT have other permission // Check account does NOT have other permission
c.Invoke(t, false, "hasPermission", acc.ScriptHash(), "documents", "write", 0) c.Invoke(t, false, "hasPermission", acc.ScriptHash(), "documents", "write", 0)
// Get permissions for role // Get permissions for role
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array") require.True(t, ok, "expected array")
require.Equal(t, 1, len(arr)) require.Equal(t, 1, len(arr))
}, "getPermissions", customRoleID) }, "getPermissions", customRoleID)
// Remove permission // Remove permission
committeeInvoker.Invoke(t, true, "removePermission", customRoleID, "documents", "read") committeeInvoker.Invoke(t, true, "removePermission", customRoleID, "documents", "read")
// Check permission is gone // Check permission is gone
c.Invoke(t, false, "hasPermission", acc.ScriptHash(), "documents", "read", 0) c.Invoke(t, false, "hasPermission", acc.ScriptHash(), "documents", "read", 0)
} }
// TestRoleRegistry_RoleHierarchy tests role hierarchy (parent roles). // TestRoleRegistry_RoleHierarchy tests role hierarchy (parent roles).
func TestRoleRegistry_RoleHierarchy(t *testing.T) { func TestRoleRegistry_RoleHierarchy(t *testing.T) {
c := newRoleRegistryClient(t) c := newRoleRegistryClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Create parent role // Create parent role
var parentRoleID int64 var parentRoleID int64
committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
roleID, _ := stack[0].TryInteger() roleID, _ := stack[0].TryInteger()
parentRoleID = roleID.Int64() parentRoleID = roleID.Int64()
}, "createRole", "PARENT_ROLE", "Parent role", 0) }, "createRole", "PARENT_ROLE", "Parent role", 0)
// Create child role with parent // Create child role with parent
var childRoleID int64 var childRoleID int64
committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { committeeInvoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
roleID, _ := stack[0].TryInteger() roleID, _ := stack[0].TryInteger()
childRoleID = roleID.Int64() childRoleID = roleID.Int64()
}, "createRole", "CHILD_ROLE", "Child role", parentRoleID) }, "createRole", "CHILD_ROLE", "Child role", parentRoleID)
// Grant child role to account // Grant child role to account
committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), childRoleID, 0) committeeInvoker.Invoke(t, true, "grantRole", acc.ScriptHash(), childRoleID, 0)
// Check account has child role // Check account has child role
c.Invoke(t, true, "hasRole", acc.ScriptHash(), childRoleID) c.Invoke(t, true, "hasRole", acc.ScriptHash(), childRoleID)
// Check account ALSO has parent role through hierarchy // Check account ALSO has parent role through hierarchy
c.Invoke(t, true, "hasRole", acc.ScriptHash(), parentRoleID) c.Invoke(t, true, "hasRole", acc.ScriptHash(), parentRoleID)
} }

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -7,8 +7,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/compiler" "github.com/tutus-one/tutus-chain/pkg/compiler"
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes" "github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -7,8 +7,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/config" "github.com/tutus-one/tutus-chain/pkg/config"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes" "github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
) )
func newTreasuryClient(t *testing.T) *neotest.ContractInvoker { func newTreasuryClient(t *testing.T) *neotest.ContractInvoker {

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )

View File

@ -1,309 +1,309 @@
package native_test package native_test
import ( import (
"testing" "testing"
"time" "time"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state" "github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
) )
func newVitaClient(t *testing.T) *neotest.ContractInvoker { func newVitaClient(t *testing.T) *neotest.ContractInvoker {
return newNativeClient(t, nativenames.Vita) return newNativeClient(t, nativenames.Vita)
} }
// registerVita is a helper to register a Vita for a signer. // registerVita is a helper to register a Vita for a signer.
// Returns the tokenID bytes. // Returns the tokenID bytes.
func registerVita(t *testing.T, c *neotest.ContractInvoker, signer neotest.Signer) []byte { func registerVita(t *testing.T, c *neotest.ContractInvoker, signer neotest.Signer) []byte {
owner := signer.ScriptHash() owner := signer.ScriptHash()
personHash := hash.Sha256(owner.BytesBE()).BytesBE() personHash := hash.Sha256(owner.BytesBE()).BytesBE()
isEntity := false isEntity := false
recoveryHash := hash.Sha256([]byte("recovery")).BytesBE() recoveryHash := hash.Sha256([]byte("recovery")).BytesBE()
birthTimestamp := time.Now().Unix() - 30*365*24*60*60 // Default: 30 years old birthTimestamp := time.Now().Unix() - 30*365*24*60*60 // Default: 30 years old
invoker := c.WithSigners(signer) invoker := c.WithSigners(signer)
// Register returns tokenID bytes, not null // Register returns tokenID bytes, not null
txHash := invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { txHash := invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
// Result is a ByteArray (tokenID) // Result is a ByteArray (tokenID)
_, ok := stack[0].Value().([]byte) _, ok := stack[0].Value().([]byte)
require.True(t, ok, "expected ByteArray result") require.True(t, ok, "expected ByteArray result")
}, "register", owner.BytesBE(), personHash, isEntity, recoveryHash, birthTimestamp) }, "register", owner.BytesBE(), personHash, isEntity, recoveryHash, birthTimestamp)
aer := c.Executor.GetTxExecResult(t, txHash) aer := c.Executor.GetTxExecResult(t, txHash)
require.Equal(t, 1, len(aer.Stack)) require.Equal(t, 1, len(aer.Stack))
tokenIDBytes := aer.Stack[0].Value().([]byte) tokenIDBytes := aer.Stack[0].Value().([]byte)
return tokenIDBytes return tokenIDBytes
} }
// TestVita_Register tests basic registration functionality. // TestVita_Register tests basic registration functionality.
func TestVita_Register(t *testing.T) { func TestVita_Register(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
owner := acc.ScriptHash() owner := acc.ScriptHash()
personHash := hash.Sha256(owner.BytesBE()).BytesBE() personHash := hash.Sha256(owner.BytesBE()).BytesBE()
isEntity := false isEntity := false
recoveryHash := hash.Sha256([]byte("recovery")).BytesBE() recoveryHash := hash.Sha256([]byte("recovery")).BytesBE()
birthTimestamp := time.Now().Unix() - 30*365*24*60*60 // 30 years old birthTimestamp := time.Now().Unix() - 30*365*24*60*60 // 30 years old
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// Register token - returns tokenID bytes // Register token - returns tokenID bytes
txHash := invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { txHash := invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
_, ok := stack[0].Value().([]byte) _, ok := stack[0].Value().([]byte)
require.True(t, ok, "expected ByteArray result") require.True(t, ok, "expected ByteArray result")
}, "register", owner.BytesBE(), personHash, isEntity, recoveryHash, birthTimestamp) }, "register", owner.BytesBE(), personHash, isEntity, recoveryHash, birthTimestamp)
// Check events were emitted (BirthRegistered from Annos + VitaCreated) // Check events were emitted (BirthRegistered from Annos + VitaCreated)
aer := e.GetTxExecResult(t, txHash) aer := e.GetTxExecResult(t, txHash)
require.Equal(t, 2, len(aer.Events)) require.Equal(t, 2, len(aer.Events))
require.Equal(t, "BirthRegistered", aer.Events[0].Name) require.Equal(t, "BirthRegistered", aer.Events[0].Name)
require.Equal(t, "VitaCreated", aer.Events[1].Name) require.Equal(t, "VitaCreated", aer.Events[1].Name)
// Check exists returns true // Check exists returns true
invoker.Invoke(t, true, "exists", owner.BytesBE()) invoker.Invoke(t, true, "exists", owner.BytesBE())
// Check getToken returns valid token // Check getToken returns valid token
invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr := stack[0].Value().([]stackitem.Item) arr := stack[0].Value().([]stackitem.Item)
require.GreaterOrEqual(t, len(arr), 5) // At least tokenID, owner, personHash, isEntity, status require.GreaterOrEqual(t, len(arr), 5) // At least tokenID, owner, personHash, isEntity, status
}, "getToken", owner.BytesBE()) }, "getToken", owner.BytesBE())
} }
// TestVita_ValidateCaller tests the validateCaller method. // TestVita_ValidateCaller tests the validateCaller method.
// Note: validateCaller uses GetCallingScriptHash() which returns the calling contract's // Note: validateCaller uses GetCallingScriptHash() which returns the calling contract's
// script hash, not the transaction signer's address. When called directly from a transaction // script hash, not the transaction signer's address. When called directly from a transaction
// (not from another contract), the caller has no token. These methods are designed for // (not from another contract), the caller has no token. These methods are designed for
// cross-contract authorization. // cross-contract authorization.
func TestVita_ValidateCaller(t *testing.T) { func TestVita_ValidateCaller(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
t.Run("no token - direct call", func(t *testing.T) { t.Run("no token - direct call", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// validateCaller uses GetCallingScriptHash() which returns the transaction script hash // validateCaller uses GetCallingScriptHash() which returns the transaction script hash
// when called directly, not the signer's account. This will always fail for direct calls. // when called directly, not the signer's account. This will always fail for direct calls.
invoker.InvokeFail(t, "caller does not have a Vita", "validateCaller") invoker.InvokeFail(t, "caller does not have a Vita", "validateCaller")
}) })
// Note: Testing validateCaller with a token requires deploying a helper contract // Note: Testing validateCaller with a token requires deploying a helper contract
// that has a Vita registered to its script hash, then calling validateCaller // that has a Vita registered to its script hash, then calling validateCaller
// from within that contract. This is the intended usage pattern for cross-contract auth. // from within that contract. This is the intended usage pattern for cross-contract auth.
} }
// TestVita_RequireRole tests the requireRole method. // TestVita_RequireRole tests the requireRole method.
// Note: requireRole uses GetCallingScriptHash() - designed for cross-contract authorization. // Note: requireRole uses GetCallingScriptHash() - designed for cross-contract authorization.
func TestVita_RequireRole(t *testing.T) { func TestVita_RequireRole(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
t.Run("no token - direct call", func(t *testing.T) { t.Run("no token - direct call", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// Direct calls always fail because GetCallingScriptHash() returns transaction script hash // Direct calls always fail because GetCallingScriptHash() returns transaction script hash
invoker.InvokeFail(t, "caller does not have a Vita", "requireRole", 0) invoker.InvokeFail(t, "caller does not have a Vita", "requireRole", 0)
}) })
// Note: Testing requireRole with actual role checks requires a deployed contract // Note: Testing requireRole with actual role checks requires a deployed contract
// with a Vita registered to its script hash. // with a Vita registered to its script hash.
} }
// TestVita_RequireCoreRole tests the requireCoreRole method. // TestVita_RequireCoreRole tests the requireCoreRole method.
// Note: requireCoreRole uses GetCallingScriptHash() - designed for cross-contract authorization. // Note: requireCoreRole uses GetCallingScriptHash() - designed for cross-contract authorization.
func TestVita_RequireCoreRole(t *testing.T) { func TestVita_RequireCoreRole(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
// CoreRole constants // CoreRole constants
const ( const (
CoreRoleNone = 0 CoreRoleNone = 0
CoreRoleRecovery = 5 CoreRoleRecovery = 5
) )
t.Run("invalid role", func(t *testing.T) { t.Run("invalid role", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// requireCoreRole with invalid role (> 5) should fail before checking token // requireCoreRole with invalid role (> 5) should fail before checking token
invoker.InvokeFail(t, "invalid core role", "requireCoreRole", 10) invoker.InvokeFail(t, "invalid core role", "requireCoreRole", 10)
}) })
t.Run("no token - direct call", func(t *testing.T) { t.Run("no token - direct call", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// Direct calls always fail because GetCallingScriptHash() returns transaction script hash // Direct calls always fail because GetCallingScriptHash() returns transaction script hash
invoker.InvokeFail(t, "caller does not have a Vita", "requireCoreRole", CoreRoleNone) invoker.InvokeFail(t, "caller does not have a Vita", "requireCoreRole", CoreRoleNone)
}) })
// Note: Testing requireCoreRole with actual role checks requires a deployed contract // Note: Testing requireCoreRole with actual role checks requires a deployed contract
// with a Vita registered to its script hash. // with a Vita registered to its script hash.
} }
// TestVita_RequirePermission tests the requirePermission method. // TestVita_RequirePermission tests the requirePermission method.
// Note: requirePermission uses GetCallingScriptHash() - designed for cross-contract authorization. // Note: requirePermission uses GetCallingScriptHash() - designed for cross-contract authorization.
func TestVita_RequirePermission(t *testing.T) { func TestVita_RequirePermission(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
t.Run("empty resource", func(t *testing.T) { t.Run("empty resource", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// requirePermission with empty resource should fail before checking token // requirePermission with empty resource should fail before checking token
invoker.InvokeFail(t, "invalid resource", "requirePermission", "", "read", "global") invoker.InvokeFail(t, "invalid resource", "requirePermission", "", "read", "global")
}) })
t.Run("empty action", func(t *testing.T) { t.Run("empty action", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// requirePermission with empty action should fail before checking token // requirePermission with empty action should fail before checking token
invoker.InvokeFail(t, "invalid action", "requirePermission", "documents", "", "global") invoker.InvokeFail(t, "invalid action", "requirePermission", "documents", "", "global")
}) })
t.Run("no token - direct call", func(t *testing.T) { t.Run("no token - direct call", func(t *testing.T) {
acc := c.Executor.NewAccount(t) acc := c.Executor.NewAccount(t)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
// Direct calls always fail because GetCallingScriptHash() returns transaction script hash // Direct calls always fail because GetCallingScriptHash() returns transaction script hash
invoker.InvokeFail(t, "caller does not have a Vita", "requirePermission", "documents", "read", "global") invoker.InvokeFail(t, "caller does not have a Vita", "requirePermission", "documents", "read", "global")
}) })
// Note: Testing requirePermission with actual permission checks requires a deployed contract // Note: Testing requirePermission with actual permission checks requires a deployed contract
// with a Vita registered to its script hash. // with a Vita registered to its script hash.
} }
// TestVita_TotalSupply tests the totalSupply method. // TestVita_TotalSupply tests the totalSupply method.
func TestVita_TotalSupply(t *testing.T) { func TestVita_TotalSupply(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
e := c.Executor e := c.Executor
// Initially, totalSupply should be 0 // Initially, totalSupply should be 0
c.Invoke(t, 0, "totalSupply") c.Invoke(t, 0, "totalSupply")
// Register a token // Register a token
acc1 := e.NewAccount(t) acc1 := e.NewAccount(t)
registerVita(t, c, acc1) registerVita(t, c, acc1)
// Now totalSupply should be 1 // Now totalSupply should be 1
c.Invoke(t, 1, "totalSupply") c.Invoke(t, 1, "totalSupply")
// Register another token // Register another token
acc2 := e.NewAccount(t) acc2 := e.NewAccount(t)
registerVita(t, c, acc2) registerVita(t, c, acc2)
// Now totalSupply should be 2 // Now totalSupply should be 2
c.Invoke(t, 2, "totalSupply") c.Invoke(t, 2, "totalSupply")
} }
// TestVita_GetTokenByID tests the getTokenByID method. // TestVita_GetTokenByID tests the getTokenByID method.
func TestVita_GetTokenByID(t *testing.T) { func TestVita_GetTokenByID(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
e := c.Executor e := c.Executor
// Register a token - the first token gets ID 0 (counter starts at 0) // Register a token - the first token gets ID 0 (counter starts at 0)
acc := e.NewAccount(t) acc := e.NewAccount(t)
registerVita(t, c, acc) registerVita(t, c, acc)
// Token ID 0 should exist (first registered token) // Token ID 0 should exist (first registered token)
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
// Check that result is an array (not null) // Check that result is an array (not null)
arr, ok := stack[0].Value().([]stackitem.Item) arr, ok := stack[0].Value().([]stackitem.Item)
require.True(t, ok, "expected array result for existing token") require.True(t, ok, "expected array result for existing token")
require.GreaterOrEqual(t, len(arr), 9) // Vita has 9 fields require.GreaterOrEqual(t, len(arr), 9) // Vita has 9 fields
// Check owner matches (owner is at index 1) // Check owner matches (owner is at index 1)
owner, ok := arr[1].Value().([]byte) owner, ok := arr[1].Value().([]byte)
require.True(t, ok, "expected owner to be bytes") require.True(t, ok, "expected owner to be bytes")
require.Equal(t, acc.ScriptHash().BytesBE(), owner) require.Equal(t, acc.ScriptHash().BytesBE(), owner)
}, "getTokenByID", 0) }, "getTokenByID", 0)
// Non-existent token should return null // Non-existent token should return null
c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { c.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
// Null returns nil from Value() // Null returns nil from Value()
require.Nil(t, stack[0].Value(), "expected null for non-existent token") require.Nil(t, stack[0].Value(), "expected null for non-existent token")
}, "getTokenByID", 999999) }, "getTokenByID", 999999)
} }
// TestVita_SuspendReinstate tests suspend and reinstate functionality. // TestVita_SuspendReinstate tests suspend and reinstate functionality.
func TestVita_SuspendReinstate(t *testing.T) { func TestVita_SuspendReinstate(t *testing.T) {
c := newVitaClient(t) c := newVitaClient(t)
e := c.Executor e := c.Executor
acc := e.NewAccount(t) acc := e.NewAccount(t)
registerVita(t, c, acc) registerVita(t, c, acc)
invoker := c.WithSigners(acc) invoker := c.WithSigners(acc)
committeeInvoker := c.WithSigners(c.Committee) committeeInvoker := c.WithSigners(c.Committee)
// Create Lex invoker using same executor for liberty restriction (required for due process) // Create Lex invoker using same executor for liberty restriction (required for due process)
lexHash := e.NativeHash(t, nativenames.Lex) lexHash := e.NativeHash(t, nativenames.Lex)
lexCommitteeInvoker := e.CommitteeInvoker(lexHash) lexCommitteeInvoker := e.CommitteeInvoker(lexHash)
// Initially token is active // Initially token is active
invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr := stack[0].Value().([]stackitem.Item) arr := stack[0].Value().([]stackitem.Item)
// Status is at index 6 (after tokenID, owner, personHash, isEntity, createdAt, updatedAt) // Status is at index 6 (after tokenID, owner, personHash, isEntity, createdAt, updatedAt)
status, err := arr[6].TryInteger() status, err := arr[6].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, int64(state.TokenStatusActive), status.Int64()) require.Equal(t, int64(state.TokenStatusActive), status.Int64())
}, "getToken", acc.ScriptHash().BytesBE()) }, "getToken", acc.ScriptHash().BytesBE())
// Non-committee cannot suspend // Non-committee cannot suspend
invoker.InvokeFail(t, "invalid committee signature", "suspend", acc.ScriptHash().BytesBE(), "test") invoker.InvokeFail(t, "invalid committee signature", "suspend", acc.ScriptHash().BytesBE(), "test")
// First, create a liberty restriction via Lex (due process requirement) // First, create a liberty restriction via Lex (due process requirement)
caseID := hash.Sha256([]byte("case-123")).BytesBE() // 32-byte case reference caseID := hash.Sha256([]byte("case-123")).BytesBE() // 32-byte case reference
lexCommitteeInvoker.Invoke(t, true, "restrictRight", lexCommitteeInvoker.Invoke(t, true, "restrictRight",
acc.ScriptHash().BytesBE(), // subject acc.ScriptHash().BytesBE(), // subject
int64(state.RightLiberty), // rightID = 2 (Liberty) int64(state.RightLiberty), // rightID = 2 (Liberty)
int64(state.RestrictionSuspend), // restrictionType = 1 (Suspend) int64(state.RestrictionSuspend), // restrictionType = 1 (Suspend)
int64(100), // duration in blocks int64(100), // duration in blocks
"judicial order", // reason "judicial order", // reason
caseID, // caseID (Hash256) caseID, // caseID (Hash256)
) )
// Committee can suspend (now with valid Lex restriction order) // Committee can suspend (now with valid Lex restriction order)
committeeInvoker.Invoke(t, true, "suspend", acc.ScriptHash().BytesBE(), "test suspension") committeeInvoker.Invoke(t, true, "suspend", acc.ScriptHash().BytesBE(), "test suspension")
// Token is now suspended // Token is now suspended
invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr := stack[0].Value().([]stackitem.Item) arr := stack[0].Value().([]stackitem.Item)
status, err := arr[6].TryInteger() status, err := arr[6].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, int64(state.TokenStatusSuspended), status.Int64()) require.Equal(t, int64(state.TokenStatusSuspended), status.Int64())
}, "getToken", acc.ScriptHash().BytesBE()) }, "getToken", acc.ScriptHash().BytesBE())
// Non-committee cannot reinstate // Non-committee cannot reinstate
invoker.InvokeFail(t, "invalid committee signature", "reinstate", acc.ScriptHash().BytesBE()) invoker.InvokeFail(t, "invalid committee signature", "reinstate", acc.ScriptHash().BytesBE())
// Committee can reinstate // Committee can reinstate
committeeInvoker.Invoke(t, true, "reinstate", acc.ScriptHash().BytesBE()) committeeInvoker.Invoke(t, true, "reinstate", acc.ScriptHash().BytesBE())
// Token is active again // Token is active again
invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) { invoker.InvokeAndCheck(t, func(t testing.TB, stack []stackitem.Item) {
require.Equal(t, 1, len(stack)) require.Equal(t, 1, len(stack))
arr := stack[0].Value().([]stackitem.Item) arr := stack[0].Value().([]stackitem.Item)
status, err := arr[6].TryInteger() status, err := arr[6].TryInteger()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, int64(state.TokenStatusActive), status.Int64()) require.Equal(t, int64(state.TokenStatusActive), status.Int64())
}, "getToken", acc.ScriptHash().BytesBE()) }, "getToken", acc.ScriptHash().BytesBE())
} }
// Note: Full cross-contract testing of validateCaller, requireRole, requireCoreRole, and // Note: Full cross-contract testing of validateCaller, requireRole, requireCoreRole, and
// requirePermission would require deploying a helper contract that: // requirePermission would require deploying a helper contract that:
// 1. Has a Vita registered to its script hash // 1. Has a Vita registered to its script hash
// 2. Calls the Vita cross-contract methods from within its own methods // 2. Calls the Vita cross-contract methods from within its own methods
// This is the intended usage pattern for these cross-contract authorization methods. // This is the intended usage pattern for these cross-contract authorization methods.

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes" "github.com/tutus-one/tutus-chain/pkg/core/native/nativehashes"
"github.com/tutus-one/tutus-chain/pkg/core/native/nativenames" "github.com/tutus-one/tutus-chain/pkg/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/transaction" "github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/vm" "github.com/tutus-one/tutus-chain/pkg/vm"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -3,7 +3,7 @@ package state
import ( import (
"testing" "testing"
json "github.com/nspcc-dev/go-ordered-json" json "github.com/tutus-one/tutus-ordered-json"
"github.com/tutus-one/tutus-chain/internal/testserdes" "github.com/tutus-one/tutus-chain/internal/testserdes"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem" "github.com/tutus-one/tutus-chain/pkg/vm/stackitem"

View File

@ -9,8 +9,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/core/block" "github.com/tutus-one/tutus-chain/pkg/core/block"
"github.com/tutus-one/tutus-chain/pkg/core/mpt" "github.com/tutus-one/tutus-chain/pkg/core/mpt"
"github.com/tutus-one/tutus-chain/pkg/core/storage" "github.com/tutus-one/tutus-chain/pkg/core/storage"
"github.com/tutus-one/tutus-chain/pkg/neotest" "github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain" "github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -7,7 +7,7 @@ import (
"os" "os"
"time" "time"
"github.com/nspcc-dev/bbolt" "github.com/tutus-one/tutus-bolt"
"github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig" "github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig"
"github.com/tutus-one/tutus-chain/pkg/io" "github.com/tutus-one/tutus-chain/pkg/io"
) )

View File

@ -6,8 +6,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/nspcc-dev/bbolt" "github.com/tutus-one/tutus-bolt"
"github.com/nspcc-dev/bbolt/errors" "github.com/tutus-one/tutus-bolt/errors"
"github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig" "github.com/tutus-one/tutus-chain/pkg/core/storage/dbconfig"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -13,7 +13,7 @@ import (
"github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash" "github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/util" "github.com/tutus-one/tutus-chain/pkg/util"
"github.com/nspcc-dev/rfc6979" "github.com/tutus-one/tutus-rfc6979"
) )
// PrivateKey represents a Neo private key and provides a high level API around // PrivateKey represents a Neo private key and provides a high level API around

View File

@ -5,7 +5,7 @@ package contract
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// CallFlag specifies valid call flags. // CallFlag specifies valid call flags.
@ -28,19 +28,19 @@ const (
// script using the given m and a set of public keys bytes. This function uses // script using the given m and a set of public keys bytes. This function uses
// `System.Contract.CreateMultisigAccount` syscall. // `System.Contract.CreateMultisigAccount` syscall.
func CreateMultisigAccount(m int, pubs []interop.PublicKey) []byte { func CreateMultisigAccount(m int, pubs []interop.PublicKey) []byte {
return neogointernal.Syscall2("System.Contract.CreateMultisigAccount", m, pubs).([]byte) return tutusinternal.Syscall2("System.Contract.CreateMultisigAccount", m, pubs).([]byte)
} }
// CreateStandardAccount calculates a script hash of the given public key. // CreateStandardAccount calculates a script hash of the given public key.
// This function uses `System.Contract.CreateStandardAccount` syscall. // This function uses `System.Contract.CreateStandardAccount` syscall.
func CreateStandardAccount(pub interop.PublicKey) []byte { func CreateStandardAccount(pub interop.PublicKey) []byte {
return neogointernal.Syscall1("System.Contract.CreateStandardAccount", pub).([]byte) return tutusinternal.Syscall1("System.Contract.CreateStandardAccount", pub).([]byte)
} }
// GetCallFlags returns the calling flags which execution context was created with. // GetCallFlags returns the calling flags which execution context was created with.
// This function uses `System.Contract.GetCallFlags` syscall. // This function uses `System.Contract.GetCallFlags` syscall.
func GetCallFlags() CallFlag { func GetCallFlags() CallFlag {
return neogointernal.Syscall0("System.Contract.GetCallFlags").(CallFlag) return tutusinternal.Syscall0("System.Contract.GetCallFlags").(CallFlag)
} }
// Call executes the previously deployed blockchain contract with the specified hash // Call executes the previously deployed blockchain contract with the specified hash
@ -48,5 +48,5 @@ func GetCallFlags() CallFlag {
// It returns whatever this contract returns. This function uses // It returns whatever this contract returns. This function uses
// `System.Contract.Call` syscall. // `System.Contract.Call` syscall.
func Call(scriptHash interop.Hash160, method string, f CallFlag, args ...any) any { func Call(scriptHash interop.Hash160, method string, f CallFlag, args ...any) any {
return neogointernal.Syscall4("System.Contract.Call", scriptHash, method, f, args) return tutusinternal.Syscall4("System.Contract.Call", scriptHash, method, f, args)
} }

View File

@ -1,7 +1,7 @@
// Package convert provides functions for type conversion. // Package convert provides functions for type conversion.
package convert package convert
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
// ToInteger converts it's argument to an Integer. // ToInteger converts it's argument to an Integer.
func ToInteger(v any) int { func ToInteger(v any) int {
@ -40,7 +40,7 @@ func BytesToUint8(data []byte) uint8 {
func Uint16ToBytesBE(n uint16) []byte { func Uint16ToBytesBE(n uint16) []byte {
var res = make([]byte, 2) var res = make([]byte, 2)
copy(res, ToBytes(n)) copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res) tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res return res
} }
@ -51,7 +51,7 @@ func BytesBEToUint16(data []byte) uint16 {
} }
src := make([]byte, 2) src := make([]byte, 2)
copy(src, data) copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src) tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes. src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint16(ToInteger(src)) return uint16(ToInteger(src))
} }
@ -77,7 +77,7 @@ func BytesLEToUint16(data []byte) uint16 {
func Uint32ToBytesBE(n uint32) []byte { func Uint32ToBytesBE(n uint32) []byte {
var res = make([]byte, 4) var res = make([]byte, 4)
copy(res, ToBytes(n)) copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res) tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res return res
} }
@ -88,7 +88,7 @@ func BytesBEToUint32(data []byte) uint32 {
} }
src := make([]byte, 4) src := make([]byte, 4)
copy(src, data) copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src) tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes. src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint32(ToInteger(src)) return uint32(ToInteger(src))
} }
@ -114,7 +114,7 @@ func BytesLEToUint32(data []byte) uint32 {
func Uint64ToBytesBE(n uint64) []byte { func Uint64ToBytesBE(n uint64) []byte {
var res = make([]byte, 8) var res = make([]byte, 8)
copy(res, ToBytes(n)) copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res) tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res return res
} }
@ -125,7 +125,7 @@ func BytesBEToUint64(data []byte) uint64 {
} }
src := make([]byte, 8) src := make([]byte, 8)
copy(src, data) copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src) tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes. src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint64(ToInteger(src)) return uint64(ToInteger(src))
} }

View File

@ -5,18 +5,18 @@ package crypto
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// CheckMultisig checks that the script container (transaction) is signed by multiple // CheckMultisig checks that the script container (transaction) is signed by multiple
// ECDSA keys at once. It uses `System.Crypto.CheckMultisig` syscall. // ECDSA keys at once. It uses `System.Crypto.CheckMultisig` syscall.
func CheckMultisig(pubs []interop.PublicKey, sigs []interop.Signature) bool { func CheckMultisig(pubs []interop.PublicKey, sigs []interop.Signature) bool {
return neogointernal.Syscall2("System.Crypto.CheckMultisig", pubs, sigs).(bool) return tutusinternal.Syscall2("System.Crypto.CheckMultisig", pubs, sigs).(bool)
} }
// CheckSig checks that sig is a correct signature of the script container // CheckSig checks that sig is a correct signature of the script container
// (transaction) for the given pub (serialized public key). It uses // (transaction) for the given pub (serialized public key). It uses
// `System.Crypto.CheckSig` syscall. // `System.Crypto.CheckSig` syscall.
func CheckSig(pub interop.PublicKey, sig interop.Signature) bool { func CheckSig(pub interop.PublicKey, sig interop.Signature) bool {
return neogointernal.Syscall2("System.Crypto.CheckSig", pub, sig).(bool) return tutusinternal.Syscall2("System.Crypto.CheckSig", pub, sig).(bool)
} }

View File

@ -3,7 +3,7 @@ Package iterator provides functions to work with Neo iterators.
*/ */
package iterator package iterator
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
// Iterator represents a Neo iterator, it's an opaque data structure that can // Iterator represents a Neo iterator, it's an opaque data structure that can
// be properly created by storage.Find. Iterators range over key-value pairs, // be properly created by storage.Find. Iterators range over key-value pairs,
@ -16,7 +16,7 @@ type Iterator struct{}
// otherwise (and there are no more elements in this Iterator). This function // otherwise (and there are no more elements in this Iterator). This function
// uses `System.Iterator.Next` syscall. // uses `System.Iterator.Next` syscall.
func Next(it Iterator) bool { func Next(it Iterator) bool {
return neogointernal.Syscall1("System.Iterator.Next", it).(bool) return tutusinternal.Syscall1("System.Iterator.Next", it).(bool)
} }
// Value returns iterator's current value. It's only valid to call after // Value returns iterator's current value. It's only valid to call after
@ -27,5 +27,5 @@ func Next(it Iterator) bool {
// If the iterator is configured to return key-value pairs, the result can be // If the iterator is configured to return key-value pairs, the result can be
// directly type-asserted to [storage.KeyValue] type. // directly type-asserted to [storage.KeyValue] type.
func Value(it Iterator) any { func Value(it Iterator) any {
return neogointernal.Syscall1("System.Iterator.Value", it) return tutusinternal.Syscall1("System.Iterator.Value", it)
} }

View File

@ -3,17 +3,17 @@ Package math provides access to useful numeric functions available in Neo VM.
*/ */
package math package math
import "github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" import "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
// Pow returns a^b using POW VM opcode. // Pow returns a^b using POW VM opcode.
// b must be >= 0 and <= 2^31-1. // b must be >= 0 and <= 2^31-1.
func Pow(a, b int) int { func Pow(a, b int) int {
return neogointernal.Opcode2("POW", a, b).(int) return tutusinternal.Opcode2("POW", a, b).(int)
} }
// Sqrt returns a positive square root of x rounded down. // Sqrt returns a positive square root of x rounded down.
func Sqrt(x int) int { func Sqrt(x int) int {
return neogointernal.Opcode1("SQRT", x).(int) return tutusinternal.Opcode1("SQRT", x).(int)
} }
// Sign returns: // Sign returns:
@ -22,26 +22,26 @@ func Sqrt(x int) int {
// 0 if x == 0 // 0 if x == 0
// +1 if x > 0 // +1 if x > 0
func Sign(a int) int { func Sign(a int) int {
return neogointernal.Opcode1("SIGN", a).(int) return tutusinternal.Opcode1("SIGN", a).(int)
} }
// Abs returns an absolute value of a. // Abs returns an absolute value of a.
func Abs(a int) int { func Abs(a int) int {
return neogointernal.Opcode1("ABS", a).(int) return tutusinternal.Opcode1("ABS", a).(int)
} }
// Within returns true if a <= x < b. // Within returns true if a <= x < b.
func Within(x, a, b int) bool { func Within(x, a, b int) bool {
return neogointernal.Opcode3("WITHIN", x, a, b).(bool) return tutusinternal.Opcode3("WITHIN", x, a, b).(bool)
} }
// ModMul returns the result of modulus division on a*b. // ModMul returns the result of modulus division on a*b.
func ModMul(a, b, mod int) int { func ModMul(a, b, mod int) int {
return neogointernal.Opcode3("MODMUL", a, b, mod).(int) return tutusinternal.Opcode3("MODMUL", a, b, mod).(int)
} }
// ModPow returns the result of modulus division on a^b. If b is -1, // ModPow returns the result of modulus division on a^b. If b is -1,
// it returns the modular inverse of a. // it returns the modular inverse of a.
func ModPow(a, b, mod int) int { func ModPow(a, b, mod int) int {
return neogointernal.Opcode3("MODPOW", a, b, mod).(int) return tutusinternal.Opcode3("MODPOW", a, b, mod).(int)
} }

View File

@ -7,7 +7,7 @@ package crypto
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents CryptoLib contract hash. // Hash represents CryptoLib contract hash.
@ -26,31 +26,31 @@ const (
// Sha256 calls `sha256` method of native CryptoLib contract and computes SHA256 hash of b. // Sha256 calls `sha256` method of native CryptoLib contract and computes SHA256 hash of b.
func Sha256(b []byte) interop.Hash256 { func Sha256(b []byte) interop.Hash256 {
return neogointernal.CallWithToken(Hash, "sha256", int(contract.NoneFlag), b).(interop.Hash256) return tutusinternal.CallWithToken(Hash, "sha256", int(contract.NoneFlag), b).(interop.Hash256)
} }
// Ripemd160 calls `ripemd160` method of native CryptoLib contract and computes RIPEMD160 hash of b. // Ripemd160 calls `ripemd160` method of native CryptoLib contract and computes RIPEMD160 hash of b.
func Ripemd160(b []byte) interop.Hash160 { func Ripemd160(b []byte) interop.Hash160 {
return neogointernal.CallWithToken(Hash, "ripemd160", int(contract.NoneFlag), b).(interop.Hash160) return tutusinternal.CallWithToken(Hash, "ripemd160", int(contract.NoneFlag), b).(interop.Hash160)
} }
// Murmur32 calls `murmur32` method of native CryptoLib contract and computes Murmur32 hash of b // Murmur32 calls `murmur32` method of native CryptoLib contract and computes Murmur32 hash of b
// using the given seed. // using the given seed.
func Murmur32(b []byte, seed int) []byte { func Murmur32(b []byte, seed int) []byte {
return neogointernal.CallWithToken(Hash, "murmur32", int(contract.NoneFlag), b, seed).([]byte) return tutusinternal.CallWithToken(Hash, "murmur32", int(contract.NoneFlag), b, seed).([]byte)
} }
// VerifyWithECDsa calls `verifyWithECDsa` method of native CryptoLib contract and checks that sig is // VerifyWithECDsa calls `verifyWithECDsa` method of native CryptoLib contract and checks that sig is
// a correct msg's signature for the given pub (serialized public key on the given curve). // a correct msg's signature for the given pub (serialized public key on the given curve).
func VerifyWithECDsa(msg []byte, pub interop.PublicKey, sig interop.Signature, curveHash NamedCurveHash) bool { func VerifyWithECDsa(msg []byte, pub interop.PublicKey, sig interop.Signature, curveHash NamedCurveHash) bool {
return neogointernal.CallWithToken(Hash, "verifyWithECDsa", int(contract.NoneFlag), msg, pub, sig, curveHash).(bool) return tutusinternal.CallWithToken(Hash, "verifyWithECDsa", int(contract.NoneFlag), msg, pub, sig, curveHash).(bool)
} }
// VerifyWithEd25519 calls `verifyWithEd25519` method of native CryptoLib contract and checks that sig is // VerifyWithEd25519 calls `verifyWithEd25519` method of native CryptoLib contract and checks that sig is
// a correct msg's signature for the given pub. Note that this method is available starting from // a correct msg's signature for the given pub. Note that this method is available starting from
// [config.HFEchidna] hardfork. // [config.HFEchidna] hardfork.
func VerifyWithEd25519(msg []byte, pub []byte, sig []byte) bool { func VerifyWithEd25519(msg []byte, pub []byte, sig []byte) bool {
return neogointernal.CallWithToken(Hash, "verifyWithEd25519", int(contract.NoneFlag), msg, pub, sig).(bool) return tutusinternal.CallWithToken(Hash, "verifyWithEd25519", int(contract.NoneFlag), msg, pub, sig).(bool)
} }
// RecoverSecp256K1 calls `recoverSecp256K1` method of native CryptoLib contract and returns Secp256K1 // RecoverSecp256K1 calls `recoverSecp256K1` method of native CryptoLib contract and returns Secp256K1
@ -58,7 +58,7 @@ func VerifyWithEd25519(msg []byte, pub []byte, sig []byte) bool {
// or in form of https://eips.ethereum.org/EIPS/eip-2098#specification). Note that this method is available // or in form of https://eips.ethereum.org/EIPS/eip-2098#specification). Note that this method is available
// starting from [config.HFEchidna] hardfork. // starting from [config.HFEchidna] hardfork.
func RecoverSecp256K1(msgHash []byte, sig []byte) []byte { func RecoverSecp256K1(msgHash []byte, sig []byte) []byte {
return neogointernal.CallWithToken(Hash, "recoverSecp256K1", int(contract.NoneFlag), msgHash, sig).([]byte) return tutusinternal.CallWithToken(Hash, "recoverSecp256K1", int(contract.NoneFlag), msgHash, sig).([]byte)
} }
// Bls12381Point represents BLS12-381 curve point (G1 or G2 in the Affine or // Bls12381Point represents BLS12-381 curve point (G1 or G2 in the Affine or
@ -73,25 +73,25 @@ type Bls12381Point struct{}
// Bls12381Serialize calls `bls12381Serialize` method of native CryptoLib contract // Bls12381Serialize calls `bls12381Serialize` method of native CryptoLib contract
// and serializes given BLS12-381 point into byte array. // and serializes given BLS12-381 point into byte array.
func Bls12381Serialize(g Bls12381Point) []byte { func Bls12381Serialize(g Bls12381Point) []byte {
return neogointernal.CallWithToken(Hash, "bls12381Serialize", int(contract.NoneFlag), g).([]byte) return tutusinternal.CallWithToken(Hash, "bls12381Serialize", int(contract.NoneFlag), g).([]byte)
} }
// Bls12381Deserialize calls `bls12381Deserialize` method of native CryptoLib // Bls12381Deserialize calls `bls12381Deserialize` method of native CryptoLib
// contract and deserializes given BLS12-381 point from byte array. // contract and deserializes given BLS12-381 point from byte array.
func Bls12381Deserialize(data []byte) Bls12381Point { func Bls12381Deserialize(data []byte) Bls12381Point {
return neogointernal.CallWithToken(Hash, "bls12381Deserialize", int(contract.NoneFlag), data).(Bls12381Point) return tutusinternal.CallWithToken(Hash, "bls12381Deserialize", int(contract.NoneFlag), data).(Bls12381Point)
} }
// Bls12381Equal calls `bls12381Equal` method of native CryptoLib contract and // Bls12381Equal calls `bls12381Equal` method of native CryptoLib contract and
// checks whether two BLS12-381 points are equal. // checks whether two BLS12-381 points are equal.
func Bls12381Equal(x, y Bls12381Point) bool { func Bls12381Equal(x, y Bls12381Point) bool {
return neogointernal.CallWithToken(Hash, "bls12381Equal", int(contract.NoneFlag), x, y).(bool) return tutusinternal.CallWithToken(Hash, "bls12381Equal", int(contract.NoneFlag), x, y).(bool)
} }
// Bls12381Add calls `bls12381Add` method of native CryptoLib contract and // Bls12381Add calls `bls12381Add` method of native CryptoLib contract and
// performs addition operation over two BLS12-381 points. // performs addition operation over two BLS12-381 points.
func Bls12381Add(x, y Bls12381Point) Bls12381Point { func Bls12381Add(x, y Bls12381Point) Bls12381Point {
return neogointernal.CallWithToken(Hash, "bls12381Add", int(contract.NoneFlag), x, y).(Bls12381Point) return tutusinternal.CallWithToken(Hash, "bls12381Add", int(contract.NoneFlag), x, y).(Bls12381Point)
} }
// Bls12381Mul calls `bls12381Mul` method of native CryptoLib contract and // Bls12381Mul calls `bls12381Mul` method of native CryptoLib contract and
@ -100,18 +100,18 @@ func Bls12381Add(x, y Bls12381Point) Bls12381Point {
// field element stored on 4 words (uint64) with 32-bytes length. The last // field element stored on 4 words (uint64) with 32-bytes length. The last
// argument denotes whether the multiplicator should be negative. // argument denotes whether the multiplicator should be negative.
func Bls12381Mul(x Bls12381Point, mul []byte, neg bool) Bls12381Point { func Bls12381Mul(x Bls12381Point, mul []byte, neg bool) Bls12381Point {
return neogointernal.CallWithToken(Hash, "bls12381Mul", int(contract.NoneFlag), x, mul, neg).(Bls12381Point) return tutusinternal.CallWithToken(Hash, "bls12381Mul", int(contract.NoneFlag), x, mul, neg).(Bls12381Point)
} }
// Bls12381Pairing calls `bls12381Pairing` method of native CryptoLib contract and // Bls12381Pairing calls `bls12381Pairing` method of native CryptoLib contract and
// performs pairing operation over two BLS12-381 points which must be G1 and G2 either // performs pairing operation over two BLS12-381 points which must be G1 and G2 either
// in Affine or Jacobian forms. The result of this operation is GT point. // in Affine or Jacobian forms. The result of this operation is GT point.
func Bls12381Pairing(g1, g2 Bls12381Point) Bls12381Point { func Bls12381Pairing(g1, g2 Bls12381Point) Bls12381Point {
return neogointernal.CallWithToken(Hash, "bls12381Pairing", int(contract.NoneFlag), g1, g2).(Bls12381Point) return tutusinternal.CallWithToken(Hash, "bls12381Pairing", int(contract.NoneFlag), g1, g2).(Bls12381Point)
} }
// Keccak256 calls `keccak256` method of native CryptoLib contract and // Keccak256 calls `keccak256` method of native CryptoLib contract and
// computes Keccak256 hash of b. // computes Keccak256 hash of b.
func Keccak256(b []byte) interop.Hash256 { func Keccak256(b []byte) interop.Hash256 {
return neogointernal.CallWithToken(Hash, "keccak256", int(contract.NoneFlag), b).(interop.Hash256) return tutusinternal.CallWithToken(Hash, "keccak256", int(contract.NoneFlag), b).(interop.Hash256)
} }

View File

@ -7,7 +7,7 @@ package ledger
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents Ledger contract hash. // Hash represents Ledger contract hash.
@ -30,42 +30,42 @@ const (
// CurrentHash represents `currentHash` method of Ledger native contract. // CurrentHash represents `currentHash` method of Ledger native contract.
func CurrentHash() interop.Hash256 { func CurrentHash() interop.Hash256 {
return neogointernal.CallWithToken(Hash, "currentHash", int(contract.ReadStates)).(interop.Hash256) return tutusinternal.CallWithToken(Hash, "currentHash", int(contract.ReadStates)).(interop.Hash256)
} }
// CurrentIndex represents `currentIndex` method of Ledger native contract. // CurrentIndex represents `currentIndex` method of Ledger native contract.
func CurrentIndex() int { func CurrentIndex() int {
return neogointernal.CallWithToken(Hash, "currentIndex", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "currentIndex", int(contract.ReadStates)).(int)
} }
// GetBlock represents `getBlock` method of Ledger native contract. // GetBlock represents `getBlock` method of Ledger native contract.
func GetBlock(indexOrHash any) *Block { func GetBlock(indexOrHash any) *Block {
return neogointernal.CallWithToken(Hash, "getBlock", int(contract.ReadStates), indexOrHash).(*Block) return tutusinternal.CallWithToken(Hash, "getBlock", int(contract.ReadStates), indexOrHash).(*Block)
} }
// GetTransaction represents `getTransaction` method of Ledger native contract. // GetTransaction represents `getTransaction` method of Ledger native contract.
func GetTransaction(hash interop.Hash256) *Transaction { func GetTransaction(hash interop.Hash256) *Transaction {
return neogointernal.CallWithToken(Hash, "getTransaction", int(contract.ReadStates), hash).(*Transaction) return tutusinternal.CallWithToken(Hash, "getTransaction", int(contract.ReadStates), hash).(*Transaction)
} }
// GetTransactionHeight represents `getTransactionHeight` method of Ledger native contract. // GetTransactionHeight represents `getTransactionHeight` method of Ledger native contract.
func GetTransactionHeight(hash interop.Hash256) int { func GetTransactionHeight(hash interop.Hash256) int {
return neogointernal.CallWithToken(Hash, "getTransactionHeight", int(contract.ReadStates), hash).(int) return tutusinternal.CallWithToken(Hash, "getTransactionHeight", int(contract.ReadStates), hash).(int)
} }
// GetTransactionFromBlock represents `getTransactionFromBlock` method of Ledger native contract. // GetTransactionFromBlock represents `getTransactionFromBlock` method of Ledger native contract.
func GetTransactionFromBlock(indexOrHash any, txIndex int) *Transaction { func GetTransactionFromBlock(indexOrHash any, txIndex int) *Transaction {
return neogointernal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates), return tutusinternal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates),
indexOrHash, txIndex).(*Transaction) indexOrHash, txIndex).(*Transaction)
} }
// GetTransactionSigners represents `getTransactionSigners` method of Ledger native contract. // GetTransactionSigners represents `getTransactionSigners` method of Ledger native contract.
func GetTransactionSigners(hash interop.Hash256) []TransactionSigner { func GetTransactionSigners(hash interop.Hash256) []TransactionSigner {
return neogointernal.CallWithToken(Hash, "getTransactionSigners", int(contract.ReadStates), return tutusinternal.CallWithToken(Hash, "getTransactionSigners", int(contract.ReadStates),
hash).([]TransactionSigner) hash).([]TransactionSigner)
} }
// GetTransactionVMState represents `getTransactionVMState` method of Ledger native contract. // GetTransactionVMState represents `getTransactionVMState` method of Ledger native contract.
func GetTransactionVMState(hash interop.Hash256) VMState { func GetTransactionVMState(hash interop.Hash256) VMState {
return neogointernal.CallWithToken(Hash, "getTransactionVMState", int(contract.ReadStates), hash).(VMState) return tutusinternal.CallWithToken(Hash, "getTransactionVMState", int(contract.ReadStates), hash).(VMState)
} }

View File

@ -7,7 +7,7 @@ package lub
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents Lub contract hash. // Hash represents Lub contract hash.
@ -15,26 +15,26 @@ const Hash = "\x69\xe8\x15\x86\x5e\xaa\x14\x6f\xdd\x64\x79\xd4\xa3\x57\xf0\x70\x
// Symbol represents `symbol` method of Lub native contract. // Symbol represents `symbol` method of Lub native contract.
func Symbol() string { func Symbol() string {
return neogointernal.CallWithToken(Hash, "symbol", int(contract.NoneFlag)).(string) return tutusinternal.CallWithToken(Hash, "symbol", int(contract.NoneFlag)).(string)
} }
// Decimals represents `decimals` method of Lub native contract. // Decimals represents `decimals` method of Lub native contract.
func Decimals() int { func Decimals() int {
return neogointernal.CallWithToken(Hash, "decimals", int(contract.NoneFlag)).(int) return tutusinternal.CallWithToken(Hash, "decimals", int(contract.NoneFlag)).(int)
} }
// TotalSupply represents `totalSupply` method of Lub native contract. // TotalSupply represents `totalSupply` method of Lub native contract.
func TotalSupply() int { func TotalSupply() int {
return neogointernal.CallWithToken(Hash, "totalSupply", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "totalSupply", int(contract.ReadStates)).(int)
} }
// BalanceOf represents `balanceOf` method of Lub native contract. // BalanceOf represents `balanceOf` method of Lub native contract.
func BalanceOf(addr interop.Hash160) int { func BalanceOf(addr interop.Hash160) int {
return neogointernal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int) return tutusinternal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int)
} }
// Transfer represents `transfer` method of Lub native contract. // Transfer represents `transfer` method of Lub native contract.
func Transfer(from, to interop.Hash160, amount int, data any) bool { func Transfer(from, to interop.Hash160, amount int, data any) bool {
return neogointernal.CallWithToken(Hash, "transfer", return tutusinternal.CallWithToken(Hash, "transfer",
int(contract.All), from, to, amount, data).(bool) int(contract.All), from, to, amount, data).(bool)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/iterator" "github.com/tutus-one/tutus-chain/pkg/interop/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents Management contract hash. // Hash represents Management contract hash.
@ -24,29 +24,29 @@ type IDHash struct {
// Deploy represents `deploy` method of Management native contract. // Deploy represents `deploy` method of Management native contract.
func Deploy(script, manifest []byte) *Contract { func Deploy(script, manifest []byte) *Contract {
return neogointernal.CallWithToken(Hash, "deploy", return tutusinternal.CallWithToken(Hash, "deploy",
int(contract.All), script, manifest).(*Contract) int(contract.All), script, manifest).(*Contract)
} }
// DeployWithData represents `deploy` method of Management native contract. // DeployWithData represents `deploy` method of Management native contract.
func DeployWithData(script, manifest []byte, data any) *Contract { func DeployWithData(script, manifest []byte, data any) *Contract {
return neogointernal.CallWithToken(Hash, "deploy", return tutusinternal.CallWithToken(Hash, "deploy",
int(contract.All), script, manifest, data).(*Contract) int(contract.All), script, manifest, data).(*Contract)
} }
// Destroy represents `destroy` method of Management native contract. // Destroy represents `destroy` method of Management native contract.
func Destroy() { func Destroy() {
neogointernal.CallWithTokenNoRet(Hash, "destroy", int(contract.States|contract.AllowNotify)) tutusinternal.CallWithTokenNoRet(Hash, "destroy", int(contract.States|contract.AllowNotify))
} }
// GetContract represents `getContract` method of Management native contract. // GetContract represents `getContract` method of Management native contract.
func GetContract(addr interop.Hash160) *Contract { func GetContract(addr interop.Hash160) *Contract {
return neogointernal.CallWithToken(Hash, "getContract", int(contract.ReadStates), addr).(*Contract) return tutusinternal.CallWithToken(Hash, "getContract", int(contract.ReadStates), addr).(*Contract)
} }
// GetContractByID represents `getContractById` method of the Management native contract. // GetContractByID represents `getContractById` method of the Management native contract.
func GetContractByID(id int) *Contract { func GetContractByID(id int) *Contract {
return neogointernal.CallWithToken(Hash, "getContractById", int(contract.ReadStates), id).(*Contract) return tutusinternal.CallWithToken(Hash, "getContractById", int(contract.ReadStates), id).(*Contract)
} }
// GetContractHashes represents `getContractHashes` method of the Management // GetContractHashes represents `getContractHashes` method of the Management
@ -54,34 +54,34 @@ func GetContractByID(id int) *Contract {
// hashes. Each iterator value can be cast to IDHash. Use [iterator] interop // hashes. Each iterator value can be cast to IDHash. Use [iterator] interop
// package to work with the returned Iterator. // package to work with the returned Iterator.
func GetContractHashes() iterator.Iterator { func GetContractHashes() iterator.Iterator {
return neogointernal.CallWithToken(Hash, "getContractHashes", int(contract.ReadStates)).(iterator.Iterator) return tutusinternal.CallWithToken(Hash, "getContractHashes", int(contract.ReadStates)).(iterator.Iterator)
} }
// GetMinimumDeploymentFee represents `getMinimumDeploymentFee` method of Management native contract. // GetMinimumDeploymentFee represents `getMinimumDeploymentFee` method of Management native contract.
func GetMinimumDeploymentFee() int { func GetMinimumDeploymentFee() int {
return neogointernal.CallWithToken(Hash, "getMinimumDeploymentFee", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getMinimumDeploymentFee", int(contract.ReadStates)).(int)
} }
// HasMethod represents `hasMethod` method of Management native contract. It allows to check // HasMethod represents `hasMethod` method of Management native contract. It allows to check
// if the "hash" contract has a method named "method" with parameters number equal to "pcount". // if the "hash" contract has a method named "method" with parameters number equal to "pcount".
func HasMethod(hash interop.Hash160, method string, pcount int) bool { func HasMethod(hash interop.Hash160, method string, pcount int) bool {
return neogointernal.CallWithToken(Hash, "hasMethod", int(contract.ReadStates), hash, method, pcount).(bool) return tutusinternal.CallWithToken(Hash, "hasMethod", int(contract.ReadStates), hash, method, pcount).(bool)
} }
// SetMinimumDeploymentFee represents `setMinimumDeploymentFee` method of Management native contract. // SetMinimumDeploymentFee represents `setMinimumDeploymentFee` method of Management native contract.
func SetMinimumDeploymentFee(value int) { func SetMinimumDeploymentFee(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setMinimumDeploymentFee", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setMinimumDeploymentFee", int(contract.States), value)
} }
// Update represents `update` method of Management native contract. // Update represents `update` method of Management native contract.
func Update(script, manifest []byte) { func Update(script, manifest []byte) {
neogointernal.CallWithTokenNoRet(Hash, "update", tutusinternal.CallWithTokenNoRet(Hash, "update",
int(contract.All), script, manifest) int(contract.All), script, manifest)
} }
// UpdateWithData represents `update` method of Management native contract. // UpdateWithData represents `update` method of Management native contract.
func UpdateWithData(script, manifest []byte, data any) { func UpdateWithData(script, manifest []byte, data any) {
neogointernal.CallWithTokenNoRet(Hash, "update", tutusinternal.CallWithTokenNoRet(Hash, "update",
int(contract.All), script, manifest, data) int(contract.All), script, manifest, data)
} }
@ -89,5 +89,5 @@ func UpdateWithData(script, manifest []byte, data any) {
// if contract with the specified hash is deployed. Note that this method is available starting // if contract with the specified hash is deployed. Note that this method is available starting
// from [config.HFEchidna] hardfork. // from [config.HFEchidna] hardfork.
func IsContract(hash interop.Hash160) bool { func IsContract(hash interop.Hash160) bool {
return neogointernal.CallWithToken(Hash, "isContract", int(contract.ReadStates), hash).(bool) return tutusinternal.CallWithToken(Hash, "isContract", int(contract.ReadStates), hash).(bool)
} }

View File

@ -8,7 +8,7 @@ package notary
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents Notary contract hash. // Hash represents Notary contract hash.
@ -16,32 +16,32 @@ const Hash = "\x3b\xec\x35\x31\x11\x9b\xba\xd7\x6d\xd0\x44\x92\x0b\x0d\xe6\xc3\x
// LockDepositUntil represents `lockDepositUntil` method of Notary native contract. // LockDepositUntil represents `lockDepositUntil` method of Notary native contract.
func LockDepositUntil(addr interop.Hash160, till int) bool { func LockDepositUntil(addr interop.Hash160, till int) bool {
return neogointernal.CallWithToken(Hash, "lockDepositUntil", int(contract.States), return tutusinternal.CallWithToken(Hash, "lockDepositUntil", int(contract.States),
addr, till).(bool) addr, till).(bool)
} }
// Withdraw represents `withdraw` method of Notary native contract. // Withdraw represents `withdraw` method of Notary native contract.
func Withdraw(from, to interop.Hash160) bool { func Withdraw(from, to interop.Hash160) bool {
return neogointernal.CallWithToken(Hash, "withdraw", int(contract.All), return tutusinternal.CallWithToken(Hash, "withdraw", int(contract.All),
from, to).(bool) from, to).(bool)
} }
// BalanceOf represents `balanceOf` method of Notary native contract. // BalanceOf represents `balanceOf` method of Notary native contract.
func BalanceOf(addr interop.Hash160) int { func BalanceOf(addr interop.Hash160) int {
return neogointernal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int) return tutusinternal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int)
} }
// ExpirationOf represents `expirationOf` method of Notary native contract. // ExpirationOf represents `expirationOf` method of Notary native contract.
func ExpirationOf(addr interop.Hash160) int { func ExpirationOf(addr interop.Hash160) int {
return neogointernal.CallWithToken(Hash, "expirationOf", int(contract.ReadStates), addr).(int) return tutusinternal.CallWithToken(Hash, "expirationOf", int(contract.ReadStates), addr).(int)
} }
// GetMaxNotValidBeforeDelta represents `getMaxNotValidBeforeDelta` method of Notary native contract. // GetMaxNotValidBeforeDelta represents `getMaxNotValidBeforeDelta` method of Notary native contract.
func GetMaxNotValidBeforeDelta() int { func GetMaxNotValidBeforeDelta() int {
return neogointernal.CallWithToken(Hash, "getMaxNotValidBeforeDelta", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getMaxNotValidBeforeDelta", int(contract.ReadStates)).(int)
} }
// SetMaxNotValidBeforeDelta represents `setMaxNotValidBeforeDelta` method of Notary native contract. // SetMaxNotValidBeforeDelta represents `setMaxNotValidBeforeDelta` method of Notary native contract.
func SetMaxNotValidBeforeDelta(value int) { func SetMaxNotValidBeforeDelta(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setMaxNotValidBeforeDelta", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setMaxNotValidBeforeDelta", int(contract.States), value)
} }

View File

@ -7,7 +7,7 @@ package oracle
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// These are potential response codes you get in your callback completing // These are potential response codes you get in your callback completing
@ -65,18 +65,18 @@ const MinimumResponseGas = 10_000_000
// so it should be enough to pay for reply data as well as // so it should be enough to pay for reply data as well as
// its processing. // its processing.
func Request(url string, filter []byte, cb string, userData any, gasForResponse int) { func Request(url string, filter []byte, cb string, userData any, gasForResponse int) {
neogointernal.CallWithTokenNoRet(Hash, "request", tutusinternal.CallWithTokenNoRet(Hash, "request",
int(contract.States|contract.AllowNotify), int(contract.States|contract.AllowNotify),
url, filter, cb, userData, gasForResponse) url, filter, cb, userData, gasForResponse)
} }
// GetPrice returns the current oracle request price. // GetPrice returns the current oracle request price.
func GetPrice() int { func GetPrice() int {
return neogointernal.CallWithToken(Hash, "getPrice", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getPrice", int(contract.ReadStates)).(int)
} }
// SetPrice allows to set the oracle request price. This method can only be // SetPrice allows to set the oracle request price. This method can only be
// successfully invoked by the committee. // successfully invoked by the committee.
func SetPrice(amount int) { func SetPrice(amount int) {
neogointernal.CallWithTokenNoRet(Hash, "setPrice", int(contract.States), amount) tutusinternal.CallWithTokenNoRet(Hash, "setPrice", int(contract.States), amount)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/iterator" "github.com/tutus-one/tutus-chain/pkg/interop/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents Policy contract hash. // Hash represents Policy contract hash.
@ -16,115 +16,115 @@ const Hash = "\x7b\xc6\x81\xc0\xa1\xf7\x1d\x54\x34\x57\xb6\x8b\xba\x8d\x5f\x9f\x
// GetFeePerByte represents `getFeePerByte` method of Policy native contract. // GetFeePerByte represents `getFeePerByte` method of Policy native contract.
func GetFeePerByte() int { func GetFeePerByte() int {
return neogointernal.CallWithToken(Hash, "getFeePerByte", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getFeePerByte", int(contract.ReadStates)).(int)
} }
// SetFeePerByte represents `setFeePerByte` method of Policy native contract. // SetFeePerByte represents `setFeePerByte` method of Policy native contract.
func SetFeePerByte(value int) { func SetFeePerByte(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setFeePerByte", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setFeePerByte", int(contract.States), value)
} }
// GetExecFeeFactor represents `getExecFeeFactor` method of Policy native contract. // GetExecFeeFactor represents `getExecFeeFactor` method of Policy native contract.
// It returns the execution fee factor in Datoshi units. // It returns the execution fee factor in Datoshi units.
func GetExecFeeFactor() int { func GetExecFeeFactor() int {
return neogointernal.CallWithToken(Hash, "getExecFeeFactor", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getExecFeeFactor", int(contract.ReadStates)).(int)
} }
// GetExecPicoFeeFactor represents `getExecPicoFeeFactor` method of Policy native contract. // GetExecPicoFeeFactor represents `getExecPicoFeeFactor` method of Policy native contract.
// It returns the execution fee factor in picoGAS units. Note that this method is available // It returns the execution fee factor in picoGAS units. Note that this method is available
// starting from [config.HFFaun] hardfork. // starting from [config.HFFaun] hardfork.
func GetExecPicoFeeFactor() int { func GetExecPicoFeeFactor() int {
return neogointernal.CallWithToken(Hash, "getExecPicoFeeFactor", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getExecPicoFeeFactor", int(contract.ReadStates)).(int)
} }
// SetExecFeeFactor represents `setExecFeeFactor` method of Policy native contract. // SetExecFeeFactor represents `setExecFeeFactor` method of Policy native contract.
// Note that starting from [config.HFFaun] hardfork this method accepts the value // Note that starting from [config.HFFaun] hardfork this method accepts the value
// in picoGAS units instead of Datoshi units. // in picoGAS units instead of Datoshi units.
func SetExecFeeFactor(value int) { func SetExecFeeFactor(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setExecFeeFactor", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setExecFeeFactor", int(contract.States), value)
} }
// GetStoragePrice represents `getStoragePrice` method of Policy native contract. // GetStoragePrice represents `getStoragePrice` method of Policy native contract.
func GetStoragePrice() int { func GetStoragePrice() int {
return neogointernal.CallWithToken(Hash, "getStoragePrice", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getStoragePrice", int(contract.ReadStates)).(int)
} }
// SetStoragePrice represents `setStoragePrice` method of Policy native contract. // SetStoragePrice represents `setStoragePrice` method of Policy native contract.
func SetStoragePrice(value int) { func SetStoragePrice(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setStoragePrice", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setStoragePrice", int(contract.States), value)
} }
// GetAttributeFee represents `getAttributeFee` method of Policy native contract. // GetAttributeFee represents `getAttributeFee` method of Policy native contract.
func GetAttributeFee(t AttributeType) int { func GetAttributeFee(t AttributeType) int {
return neogointernal.CallWithToken(Hash, "getAttributeFee", int(contract.ReadStates), t).(int) return tutusinternal.CallWithToken(Hash, "getAttributeFee", int(contract.ReadStates), t).(int)
} }
// SetAttributeFee represents `setAttributeFee` method of Policy native contract. // SetAttributeFee represents `setAttributeFee` method of Policy native contract.
func SetAttributeFee(t AttributeType, value int) { func SetAttributeFee(t AttributeType, value int) {
neogointernal.CallWithTokenNoRet(Hash, "setAttributeFee", int(contract.States), t, value) tutusinternal.CallWithTokenNoRet(Hash, "setAttributeFee", int(contract.States), t, value)
} }
// IsBlocked represents `isBlocked` method of Policy native contract. // IsBlocked represents `isBlocked` method of Policy native contract.
func IsBlocked(addr interop.Hash160) bool { func IsBlocked(addr interop.Hash160) bool {
return neogointernal.CallWithToken(Hash, "isBlocked", int(contract.ReadStates), addr).(bool) return tutusinternal.CallWithToken(Hash, "isBlocked", int(contract.ReadStates), addr).(bool)
} }
// BlockAccount represents `blockAccount` method of Policy native contract. // BlockAccount represents `blockAccount` method of Policy native contract.
func BlockAccount(addr interop.Hash160) bool { func BlockAccount(addr interop.Hash160) bool {
return neogointernal.CallWithToken(Hash, "blockAccount", int(contract.States|contract.AllowNotify), addr).(bool) return tutusinternal.CallWithToken(Hash, "blockAccount", int(contract.States|contract.AllowNotify), addr).(bool)
} }
// UnblockAccount represents `unblockAccount` method of Policy native contract. // UnblockAccount represents `unblockAccount` method of Policy native contract.
func UnblockAccount(addr interop.Hash160) bool { func UnblockAccount(addr interop.Hash160) bool {
return neogointernal.CallWithToken(Hash, "unblockAccount", int(contract.States), addr).(bool) return tutusinternal.CallWithToken(Hash, "unblockAccount", int(contract.States), addr).(bool)
} }
// GetMaxValidUntilBlockIncrement represents `getMaxValidUntilBlockIncrement` method of Policy native contract. // GetMaxValidUntilBlockIncrement represents `getMaxValidUntilBlockIncrement` method of Policy native contract.
// Note that this method is available starting from [config.HFEchidna] hardfork. // Note that this method is available starting from [config.HFEchidna] hardfork.
func GetMaxValidUntilBlockIncrement() int { func GetMaxValidUntilBlockIncrement() int {
return neogointernal.CallWithToken(Hash, "getMaxValidUntilBlockIncrement", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getMaxValidUntilBlockIncrement", int(contract.ReadStates)).(int)
} }
// SetMaxValidUntilBlockIncrement represents `setMaxValidUntilBlockIncrement` method of Policy native contract. // SetMaxValidUntilBlockIncrement represents `setMaxValidUntilBlockIncrement` method of Policy native contract.
// Note that this method is available starting from [config.HFEchidna] hardfork. // Note that this method is available starting from [config.HFEchidna] hardfork.
func SetMaxValidUntilBlockIncrement(value int) { func SetMaxValidUntilBlockIncrement(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setMaxValidUntilBlockIncrement", int(contract.States), value) tutusinternal.CallWithTokenNoRet(Hash, "setMaxValidUntilBlockIncrement", int(contract.States), value)
} }
// GetMillisecondsPerBlock represents `getMillisecondsPerBlock` method of Policy native contract. // GetMillisecondsPerBlock represents `getMillisecondsPerBlock` method of Policy native contract.
// Note that this method is available starting from [config.HFEchidna] hardfork. // Note that this method is available starting from [config.HFEchidna] hardfork.
func GetMillisecondsPerBlock() int { func GetMillisecondsPerBlock() int {
return neogointernal.CallWithToken(Hash, "getMillisecondsPerBlock", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getMillisecondsPerBlock", int(contract.ReadStates)).(int)
} }
// SetMillisecondsPerBlock represents `setMaxValidUntilBlockIncrement` method of Policy native contract. // SetMillisecondsPerBlock represents `setMaxValidUntilBlockIncrement` method of Policy native contract.
// Note that this method is available starting from [config.HFEchidna] hardfork. // Note that this method is available starting from [config.HFEchidna] hardfork.
func SetMillisecondsPerBlock(value int) { func SetMillisecondsPerBlock(value int) {
neogointernal.CallWithTokenNoRet(Hash, "setMillisecondsPerBlock", int(contract.States|contract.AllowNotify), value) tutusinternal.CallWithTokenNoRet(Hash, "setMillisecondsPerBlock", int(contract.States|contract.AllowNotify), value)
} }
// GetBlockedAccounts represents `getBlockedAccounts` method of Policy native contract. // GetBlockedAccounts represents `getBlockedAccounts` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork. // Note that this method is available starting from [config.HFFaun] hardfork.
func GetBlockedAccounts() iterator.Iterator { func GetBlockedAccounts() iterator.Iterator {
return neogointernal.CallWithToken(Hash, "getBlockedAccounts", int(contract.ReadStates)).(iterator.Iterator) return tutusinternal.CallWithToken(Hash, "getBlockedAccounts", int(contract.ReadStates)).(iterator.Iterator)
} }
// SetWhitelistFeeContract represents the `setWhitelistFeeContract` method of Policy native contract. // SetWhitelistFeeContract represents the `setWhitelistFeeContract` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork. // Note that this method is available starting from [config.HFFaun] hardfork.
func SetWhitelistFeeContract(hash interop.Hash160, method string, argCnt int, fixedFee int) { func SetWhitelistFeeContract(hash interop.Hash160, method string, argCnt int, fixedFee int) {
neogointernal.CallWithTokenNoRet(Hash, "setWhitelistFeeContract", int(contract.States|contract.AllowNotify), tutusinternal.CallWithTokenNoRet(Hash, "setWhitelistFeeContract", int(contract.States|contract.AllowNotify),
hash, method, argCnt, fixedFee) hash, method, argCnt, fixedFee)
} }
// RemoveWhitelistFeeContract represents the `removeWhitelistFeeContract` method of Policy native contract. // RemoveWhitelistFeeContract represents the `removeWhitelistFeeContract` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork. // Note that this method is available starting from [config.HFFaun] hardfork.
func RemoveWhitelistFeeContract(hash interop.Hash160, method string, argCnt int) { func RemoveWhitelistFeeContract(hash interop.Hash160, method string, argCnt int) {
neogointernal.CallWithTokenNoRet(Hash, "removeWhitelistFeeContract", int(contract.States|contract.AllowNotify), tutusinternal.CallWithTokenNoRet(Hash, "removeWhitelistFeeContract", int(contract.States|contract.AllowNotify),
hash, method, argCnt) hash, method, argCnt)
} }
// GetWhitelistFeeContracts represents the `getWhitelistFeeContracts` method of Policy native contract. // GetWhitelistFeeContracts represents the `getWhitelistFeeContracts` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork. // Note that this method is available starting from [config.HFFaun] hardfork.
func GetWhitelistFeeContracts() iterator.Iterator { func GetWhitelistFeeContracts() iterator.Iterator {
return neogointernal.CallWithToken(Hash, "getWhitelistFeeContracts", int(contract.ReadStates)).(iterator.Iterator) return tutusinternal.CallWithToken(Hash, "getWhitelistFeeContracts", int(contract.ReadStates)).(iterator.Iterator)
} }

View File

@ -8,7 +8,7 @@ package roles
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents RoleManagement contract hash. // Hash represents RoleManagement contract hash.
@ -27,12 +27,12 @@ const (
// GetDesignatedByRole represents `getDesignatedByRole` method of RoleManagement native contract. // GetDesignatedByRole represents `getDesignatedByRole` method of RoleManagement native contract.
func GetDesignatedByRole(r Role, height uint32) []interop.PublicKey { func GetDesignatedByRole(r Role, height uint32) []interop.PublicKey {
return neogointernal.CallWithToken(Hash, "getDesignatedByRole", return tutusinternal.CallWithToken(Hash, "getDesignatedByRole",
int(contract.ReadStates), r, height).([]interop.PublicKey) int(contract.ReadStates), r, height).([]interop.PublicKey)
} }
// DesignateAsRole represents `designateAsRole` method of RoleManagement native contract. // DesignateAsRole represents `designateAsRole` method of RoleManagement native contract.
func DesignateAsRole(r Role, pubs []interop.PublicKey) { func DesignateAsRole(r Role, pubs []interop.PublicKey) {
neogointernal.CallWithTokenNoRet(Hash, "designateAsRole", tutusinternal.CallWithTokenNoRet(Hash, "designateAsRole",
int(contract.States|contract.AllowNotify), r, pubs) int(contract.States|contract.AllowNotify), r, pubs)
} }

View File

@ -6,7 +6,7 @@ package std
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Hash represents StdLib contract hash. // Hash represents StdLib contract hash.
@ -17,14 +17,14 @@ const Hash = "\xc0\xef\x39\xce\xe0\xe4\xe9\x25\xc6\xc2\xa0\x6a\x79\xe1\x44\x0d\x
// from interop package) and allows to save them in the storage or pass them into Notify // from interop package) and allows to save them in the storage or pass them into Notify
// and then Deserialize them on the next run or in the external event receiver. // and then Deserialize them on the next run or in the external event receiver.
func Serialize(item any) []byte { func Serialize(item any) []byte {
return neogointernal.CallWithToken(Hash, "serialize", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "serialize", int(contract.NoneFlag),
item).([]byte) item).([]byte)
} }
// Deserialize calls `deserialize` method of StdLib native contract and unpacks // Deserialize calls `deserialize` method of StdLib native contract and unpacks
// a previously serialized value from a byte slice, it's the opposite of Serialize. // a previously serialized value from a byte slice, it's the opposite of Serialize.
func Deserialize(b []byte) any { func Deserialize(b []byte) any {
return neogointernal.CallWithToken(Hash, "deserialize", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "deserialize", int(contract.NoneFlag),
b) b)
} }
@ -40,7 +40,7 @@ func Deserialize(b []byte) any {
// []any -> json array // []any -> json array
// map[type1]type2 -> json object with string keys marshaled as strings (not base64). // map[type1]type2 -> json object with string keys marshaled as strings (not base64).
func JSONSerialize(item any) []byte { func JSONSerialize(item any) []byte {
return neogointernal.CallWithToken(Hash, "jsonSerialize", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "jsonSerialize", int(contract.NoneFlag),
item).([]byte) item).([]byte)
} }
@ -54,7 +54,7 @@ func JSONSerialize(item any) []byte {
// arrays -> []interface{} // arrays -> []interface{}
// maps -> map[string]interface{} // maps -> map[string]interface{}
func JSONDeserialize(data []byte) any { func JSONDeserialize(data []byte) any {
return neogointernal.CallWithToken(Hash, "jsonDeserialize", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "jsonDeserialize", int(contract.NoneFlag),
data) data)
} }
@ -62,14 +62,14 @@ func JSONDeserialize(data []byte) any {
// the given byte slice into a base64 string and returns byte representation of this // the given byte slice into a base64 string and returns byte representation of this
// string. // string.
func Base64Encode(b []byte) string { func Base64Encode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base64Encode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base64Encode", int(contract.NoneFlag),
b).(string) b).(string)
} }
// Base64Decode calls `base64Decode` method of StdLib native contract and decodes // Base64Decode calls `base64Decode` method of StdLib native contract and decodes
// the given base64 string represented as a byte slice into byte slice. // the given base64 string represented as a byte slice into byte slice.
func Base64Decode(b []byte) []byte { func Base64Decode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base64Decode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base64Decode", int(contract.NoneFlag),
b).([]byte) b).([]byte)
} }
@ -77,14 +77,14 @@ func Base64Decode(b []byte) []byte {
// the given byte slice into a base58 string and returns byte representation of this // the given byte slice into a base58 string and returns byte representation of this
// string. // string.
func Base58Encode(b []byte) string { func Base58Encode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base58Encode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base58Encode", int(contract.NoneFlag),
b).(string) b).(string)
} }
// Base58Decode calls `base58Decode` method of StdLib native contract and decodes // Base58Decode calls `base58Decode` method of StdLib native contract and decodes
// the given base58 string represented as a byte slice into a new byte slice. // the given base58 string represented as a byte slice into a new byte slice.
func Base58Decode(b []byte) []byte { func Base58Decode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base58Decode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base58Decode", int(contract.NoneFlag),
b).([]byte) b).([]byte)
} }
@ -92,42 +92,42 @@ func Base58Decode(b []byte) []byte {
// the given byte slice into a base58 string with checksum and returns byte representation of this // the given byte slice into a base58 string with checksum and returns byte representation of this
// string. // string.
func Base58CheckEncode(b []byte) string { func Base58CheckEncode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base58CheckEncode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base58CheckEncode", int(contract.NoneFlag),
b).(string) b).(string)
} }
// Base58CheckDecode calls `base58CheckDecode` method of StdLib native contract and decodes // Base58CheckDecode calls `base58CheckDecode` method of StdLib native contract and decodes
// thr given base58 string with a checksum represented as a byte slice into a new byte slice. // thr given base58 string with a checksum represented as a byte slice into a new byte slice.
func Base58CheckDecode(b []byte) []byte { func Base58CheckDecode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base58CheckDecode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "base58CheckDecode", int(contract.NoneFlag),
b).([]byte) b).([]byte)
} }
// Itoa converts num in the given base to a string. Base should be either 10 or 16. // Itoa converts num in the given base to a string. Base should be either 10 or 16.
// It uses `itoa` method of StdLib native contract. // It uses `itoa` method of StdLib native contract.
func Itoa(num int, base int) string { func Itoa(num int, base int) string {
return neogointernal.CallWithToken(Hash, "itoa", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "itoa", int(contract.NoneFlag),
num, base).(string) num, base).(string)
} }
// Itoa10 converts num in base 10 to a string. // Itoa10 converts num in base 10 to a string.
// It uses `itoa` method of StdLib native contract. // It uses `itoa` method of StdLib native contract.
func Itoa10(num int) string { func Itoa10(num int) string {
return neogointernal.CallWithToken(Hash, "itoa", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "itoa", int(contract.NoneFlag),
num).(string) num).(string)
} }
// Atoi converts a string to a number in the given base. Base should be either 10 or 16. // Atoi converts a string to a number in the given base. Base should be either 10 or 16.
// It uses `atoi` method of StdLib native contract. // It uses `atoi` method of StdLib native contract.
func Atoi(s string, base int) int { func Atoi(s string, base int) int {
return neogointernal.CallWithToken(Hash, "atoi", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "atoi", int(contract.NoneFlag),
s, base).(int) s, base).(int)
} }
// Atoi10 converts a string to a number in base 10. // Atoi10 converts a string to a number in base 10.
// It uses `atoi` method of StdLib native contract. // It uses `atoi` method of StdLib native contract.
func Atoi10(s string) int { func Atoi10(s string) int {
return neogointernal.CallWithToken(Hash, "atoi", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "atoi", int(contract.NoneFlag),
s).(int) s).(int)
} }
@ -135,49 +135,49 @@ func Atoi10(s string) int {
// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. // The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
// It uses `memoryCompare` method of StdLib native contract. // It uses `memoryCompare` method of StdLib native contract.
func MemoryCompare(s1, s2 []byte) int { func MemoryCompare(s1, s2 []byte) int {
return neogointernal.CallWithToken(Hash, "memoryCompare", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "memoryCompare", int(contract.NoneFlag),
s1, s2).(int) s1, s2).(int)
} }
// MemorySearch returns the index of the first occurrence of the val in the mem. // MemorySearch returns the index of the first occurrence of the val in the mem.
// If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract. // If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract.
func MemorySearch(mem, pattern []byte) int { func MemorySearch(mem, pattern []byte) int {
return neogointernal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag),
mem, pattern).(int) mem, pattern).(int)
} }
// MemorySearchIndex returns the index of the first occurrence of the val in the mem starting from the start. // MemorySearchIndex returns the index of the first occurrence of the val in the mem starting from the start.
// If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract. // If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract.
func MemorySearchIndex(mem, pattern []byte, start int) int { func MemorySearchIndex(mem, pattern []byte, start int) int {
return neogointernal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag),
mem, pattern, start).(int) mem, pattern, start).(int)
} }
// MemorySearchLastIndex returns the index of the last occurrence of the val in the mem ending before start. // MemorySearchLastIndex returns the index of the last occurrence of the val in the mem ending before start.
// If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract. // If not found, -1 is returned. It uses `memorySearch` method of StdLib native contract.
func MemorySearchLastIndex(mem, pattern []byte, start int) int { func MemorySearchLastIndex(mem, pattern []byte, start int) int {
return neogointernal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "memorySearch", int(contract.NoneFlag),
mem, pattern, start, true).(int) mem, pattern, start, true).(int)
} }
// StringSplit splits s by occurrences of the sep. // StringSplit splits s by occurrences of the sep.
// It uses `stringSplit` method of StdLib native contract. // It uses `stringSplit` method of StdLib native contract.
func StringSplit(s, sep string) []string { func StringSplit(s, sep string) []string {
return neogointernal.CallWithToken(Hash, "stringSplit", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "stringSplit", int(contract.NoneFlag),
s, sep).([]string) s, sep).([]string)
} }
// StringSplitNonEmpty splits s by occurrences of the sep and returns a list of non-empty items. // StringSplitNonEmpty splits s by occurrences of the sep and returns a list of non-empty items.
// It uses `stringSplit` method of StdLib native contract. // It uses `stringSplit` method of StdLib native contract.
func StringSplitNonEmpty(s, sep string) []string { func StringSplitNonEmpty(s, sep string) []string {
return neogointernal.CallWithToken(Hash, "stringSplit", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "stringSplit", int(contract.NoneFlag),
s, sep, true).([]string) s, sep, true).([]string)
} }
// StrLen returns length of the string in Utf- characters. // StrLen returns length of the string in Utf- characters.
// It uses `strLen` method of StdLib native contract. // It uses `strLen` method of StdLib native contract.
func StrLen(s string) int { func StrLen(s string) int {
return neogointernal.CallWithToken(Hash, "strLen", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "strLen", int(contract.NoneFlag),
s).(int) s).(int)
} }
@ -185,7 +185,7 @@ func StrLen(s string) int {
// It uses `hexEncode` method of StdLib native contract. Note that this method is // It uses `hexEncode` method of StdLib native contract. Note that this method is
// available starting from [config.HFFaun] hardfork. // available starting from [config.HFFaun] hardfork.
func HexEncode(b []byte) string { func HexEncode(b []byte) string {
return neogointernal.CallWithToken(Hash, "hexEncode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "hexEncode", int(contract.NoneFlag),
b).(string) b).(string)
} }
@ -193,6 +193,6 @@ func HexEncode(b []byte) string {
// It uses `hexDecode` method of StdLib native contract. Note that this method is // It uses `hexDecode` method of StdLib native contract. Note that this method is
// available starting from [config.HFFaun] hardfork. // available starting from [config.HFFaun] hardfork.
func HexDecode(s string) []byte { func HexDecode(s string) []byte {
return neogointernal.CallWithToken(Hash, "hexDecode", int(contract.NoneFlag), return tutusinternal.CallWithToken(Hash, "hexDecode", int(contract.NoneFlag),
s).([]byte) s).([]byte)
} }

View File

@ -10,7 +10,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/iterator" "github.com/tutus-one/tutus-chain/pkg/interop/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// AccountState contains info about a Tutus holder. // AccountState contains info about a Tutus holder.
@ -26,40 +26,40 @@ const Hash = "\x89\x1d\x6f\x53\x9d\xb3\x6b\x85\xd5\xcf\x6e\x3f\x79\x96\x6b\x8b\x
// Symbol represents `symbol` method of Tutus native contract. // Symbol represents `symbol` method of Tutus native contract.
func Symbol() string { func Symbol() string {
return neogointernal.CallWithToken(Hash, "symbol", int(contract.NoneFlag)).(string) return tutusinternal.CallWithToken(Hash, "symbol", int(contract.NoneFlag)).(string)
} }
// Decimals represents `decimals` method of Tutus native contract. // Decimals represents `decimals` method of Tutus native contract.
func Decimals() int { func Decimals() int {
return neogointernal.CallWithToken(Hash, "decimals", int(contract.NoneFlag)).(int) return tutusinternal.CallWithToken(Hash, "decimals", int(contract.NoneFlag)).(int)
} }
// TotalSupply represents `totalSupply` method of Tutus native contract. // TotalSupply represents `totalSupply` method of Tutus native contract.
func TotalSupply() int { func TotalSupply() int {
return neogointernal.CallWithToken(Hash, "totalSupply", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "totalSupply", int(contract.ReadStates)).(int)
} }
// BalanceOf represents `balanceOf` method of Tutus native contract. // BalanceOf represents `balanceOf` method of Tutus native contract.
func BalanceOf(addr interop.Hash160) int { func BalanceOf(addr interop.Hash160) int {
return neogointernal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int) return tutusinternal.CallWithToken(Hash, "balanceOf", int(contract.ReadStates), addr).(int)
} }
// Transfer represents `transfer` method of Tutus native contract. // Transfer represents `transfer` method of Tutus native contract.
func Transfer(from, to interop.Hash160, amount int, data any) bool { func Transfer(from, to interop.Hash160, amount int, data any) bool {
return neogointernal.CallWithToken(Hash, "transfer", return tutusinternal.CallWithToken(Hash, "transfer",
int(contract.All), from, to, amount, data).(bool) int(contract.All), from, to, amount, data).(bool)
} }
// GetCommittee represents `getCommittee` method of Tutus native contract. // GetCommittee represents `getCommittee` method of Tutus native contract.
func GetCommittee() []interop.PublicKey { func GetCommittee() []interop.PublicKey {
return neogointernal.CallWithToken(Hash, "getCommittee", int(contract.ReadStates)).([]interop.PublicKey) return tutusinternal.CallWithToken(Hash, "getCommittee", int(contract.ReadStates)).([]interop.PublicKey)
} }
// GetCandidates represents `getCandidates` method of Tutus native contract. It // GetCandidates represents `getCandidates` method of Tutus native contract. It
// returns up to 256 candidates. Use GetAllCandidates in case if you need the // returns up to 256 candidates. Use GetAllCandidates in case if you need the
// whole set of candidates. // whole set of candidates.
func GetCandidates() []Candidate { func GetCandidates() []Candidate {
return neogointernal.CallWithToken(Hash, "getCandidates", int(contract.ReadStates)).([]Candidate) return tutusinternal.CallWithToken(Hash, "getCandidates", int(contract.ReadStates)).([]Candidate)
} }
// GetAllCandidates represents `getAllCandidates` method of Tutus native contract. // GetAllCandidates represents `getAllCandidates` method of Tutus native contract.
@ -67,67 +67,67 @@ func GetCandidates() []Candidate {
// bytes. Each iterator value can be cast to Candidate. Use iterator interop // bytes. Each iterator value can be cast to Candidate. Use iterator interop
// package to work with the returned Iterator. // package to work with the returned Iterator.
func GetAllCandidates() iterator.Iterator { func GetAllCandidates() iterator.Iterator {
return neogointernal.CallWithToken(Hash, "getAllCandidates", int(contract.ReadStates)).(iterator.Iterator) return tutusinternal.CallWithToken(Hash, "getAllCandidates", int(contract.ReadStates)).(iterator.Iterator)
} }
// GetCandidateVote represents `getCandidateVote` method of Tutus native contract. // GetCandidateVote represents `getCandidateVote` method of Tutus native contract.
// It returns -1 if the candidate hasn't been registered or voted for and the // It returns -1 if the candidate hasn't been registered or voted for and the
// overall candidate votes otherwise. // overall candidate votes otherwise.
func GetCandidateVote(pub interop.PublicKey) int { func GetCandidateVote(pub interop.PublicKey) int {
return neogointernal.CallWithToken(Hash, "getCandidateVote", int(contract.ReadStates), pub).(int) return tutusinternal.CallWithToken(Hash, "getCandidateVote", int(contract.ReadStates), pub).(int)
} }
// GetNextBlockValidators represents `getNextBlockValidators` method of Tutus native contract. // GetNextBlockValidators represents `getNextBlockValidators` method of Tutus native contract.
func GetNextBlockValidators() []interop.PublicKey { func GetNextBlockValidators() []interop.PublicKey {
return neogointernal.CallWithToken(Hash, "getNextBlockValidators", int(contract.ReadStates)).([]interop.PublicKey) return tutusinternal.CallWithToken(Hash, "getNextBlockValidators", int(contract.ReadStates)).([]interop.PublicKey)
} }
// GetLubPerBlock represents `getLubPerBlock` method of Tutus native contract. // GetLubPerBlock represents `getLubPerBlock` method of Tutus native contract.
func GetLubPerBlock() int { func GetLubPerBlock() int {
return neogointernal.CallWithToken(Hash, "getLubPerBlock", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getLubPerBlock", int(contract.ReadStates)).(int)
} }
// SetLubPerBlock represents `setLubPerBlock` method of Tutus native contract. // SetLubPerBlock represents `setLubPerBlock` method of Tutus native contract.
func SetLubPerBlock(amount int) { func SetLubPerBlock(amount int) {
neogointernal.CallWithTokenNoRet(Hash, "setLubPerBlock", int(contract.States), amount) tutusinternal.CallWithTokenNoRet(Hash, "setLubPerBlock", int(contract.States), amount)
} }
// GetRegisterPrice represents `getRegisterPrice` method of Tutus native contract. // GetRegisterPrice represents `getRegisterPrice` method of Tutus native contract.
func GetRegisterPrice() int { func GetRegisterPrice() int {
return neogointernal.CallWithToken(Hash, "getRegisterPrice", int(contract.ReadStates)).(int) return tutusinternal.CallWithToken(Hash, "getRegisterPrice", int(contract.ReadStates)).(int)
} }
// SetRegisterPrice represents `setRegisterPrice` method of Tutus native contract. // SetRegisterPrice represents `setRegisterPrice` method of Tutus native contract.
func SetRegisterPrice(amount int) { func SetRegisterPrice(amount int) {
neogointernal.CallWithTokenNoRet(Hash, "setRegisterPrice", int(contract.States), amount) tutusinternal.CallWithTokenNoRet(Hash, "setRegisterPrice", int(contract.States), amount)
} }
// RegisterCandidate represents `registerCandidate` method of Tutus native contract. // RegisterCandidate represents `registerCandidate` method of Tutus native contract.
func RegisterCandidate(pub interop.PublicKey) bool { func RegisterCandidate(pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "registerCandidate", int(contract.States|contract.AllowNotify), pub).(bool) return tutusinternal.CallWithToken(Hash, "registerCandidate", int(contract.States|contract.AllowNotify), pub).(bool)
} }
// UnregisterCandidate represents `unregisterCandidate` method of Tutus native contract. // UnregisterCandidate represents `unregisterCandidate` method of Tutus native contract.
func UnregisterCandidate(pub interop.PublicKey) bool { func UnregisterCandidate(pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "unregisterCandidate", int(contract.States|contract.AllowNotify), pub).(bool) return tutusinternal.CallWithToken(Hash, "unregisterCandidate", int(contract.States|contract.AllowNotify), pub).(bool)
} }
// Vote represents `vote` method of Tutus native contract. // Vote represents `vote` method of Tutus native contract.
func Vote(addr interop.Hash160, pub interop.PublicKey) bool { func Vote(addr interop.Hash160, pub interop.PublicKey) bool {
return neogointernal.CallWithToken(Hash, "vote", int(contract.States|contract.AllowNotify), addr, pub).(bool) return tutusinternal.CallWithToken(Hash, "vote", int(contract.States|contract.AllowNotify), addr, pub).(bool)
} }
// UnclaimedLub represents `unclaimedLub` method of Tutus native contract. // UnclaimedLub represents `unclaimedLub` method of Tutus native contract.
func UnclaimedLub(addr interop.Hash160, end int) int { func UnclaimedLub(addr interop.Hash160, end int) int {
return neogointernal.CallWithToken(Hash, "unclaimedLub", int(contract.ReadStates), addr, end).(int) return tutusinternal.CallWithToken(Hash, "unclaimedLub", int(contract.ReadStates), addr, end).(int)
} }
// GetAccountState represents `getAccountState` method of Tutus native contract. // GetAccountState represents `getAccountState` method of Tutus native contract.
func GetAccountState(addr interop.Hash160) *AccountState { func GetAccountState(addr interop.Hash160) *AccountState {
return neogointernal.CallWithToken(Hash, "getAccountState", int(contract.ReadStates), addr).(*AccountState) return tutusinternal.CallWithToken(Hash, "getAccountState", int(contract.ReadStates), addr).(*AccountState)
} }
// GetCommitteeAddress represents `getCommitteeAddress` method of Tutus native contract. // GetCommitteeAddress represents `getCommitteeAddress` method of Tutus native contract.
func GetCommitteeAddress() interop.Hash160 { func GetCommitteeAddress() interop.Hash160 {
return neogointernal.CallWithToken(Hash, "getCommitteeAddress", int(contract.ReadStates)).(interop.Hash160) return tutusinternal.CallWithToken(Hash, "getCommitteeAddress", int(contract.ReadStates)).(interop.Hash160)
} }

View File

@ -3,7 +3,7 @@ package runtime
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger" "github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// GetScriptContainer returns the transaction that initially triggered current // GetScriptContainer returns the transaction that initially triggered current
@ -11,7 +11,7 @@ import (
// this execution goes. This function uses // this execution goes. This function uses
// `System.Runtime.GetScriptContainer` syscall. // `System.Runtime.GetScriptContainer` syscall.
func GetScriptContainer() *ledger.Transaction { func GetScriptContainer() *ledger.Transaction {
return neogointernal.Syscall0("System.Runtime.GetScriptContainer").(*ledger.Transaction) return tutusinternal.Syscall0("System.Runtime.GetScriptContainer").(*ledger.Transaction)
} }
// GetExecutingScriptHash returns script hash (160 bit in BE form represented // GetExecutingScriptHash returns script hash (160 bit in BE form represented
@ -20,7 +20,7 @@ func GetScriptContainer() *ledger.Transaction {
// different contract. This function uses // different contract. This function uses
// `System.Runtime.GetExecutingScriptHash` syscall. // `System.Runtime.GetExecutingScriptHash` syscall.
func GetExecutingScriptHash() interop.Hash160 { func GetExecutingScriptHash() interop.Hash160 {
return neogointernal.Syscall0("System.Runtime.GetExecutingScriptHash").(interop.Hash160) return tutusinternal.Syscall0("System.Runtime.GetExecutingScriptHash").(interop.Hash160)
} }
// GetCallingScriptHash returns script hash (160 bit in BE form represented // GetCallingScriptHash returns script hash (160 bit in BE form represented
@ -29,7 +29,7 @@ func GetExecutingScriptHash() interop.Hash160 {
// above the GetExecutingScriptHash in the call stack. It uses // above the GetExecutingScriptHash in the call stack. It uses
// `System.Runtime.GetCallingScriptHash` syscall. // `System.Runtime.GetCallingScriptHash` syscall.
func GetCallingScriptHash() interop.Hash160 { func GetCallingScriptHash() interop.Hash160 {
return neogointernal.Syscall0("System.Runtime.GetCallingScriptHash").(interop.Hash160) return tutusinternal.Syscall0("System.Runtime.GetCallingScriptHash").(interop.Hash160)
} }
// GetEntryScriptHash returns script hash (160 bit in BE form represented // GetEntryScriptHash returns script hash (160 bit in BE form represented
@ -38,5 +38,5 @@ func GetCallingScriptHash() interop.Hash160 {
// GetScriptContainer) execution from the start. This function uses // GetScriptContainer) execution from the start. This function uses
// `System.Runtime.GetEntryScriptHash` syscall. // `System.Runtime.GetEntryScriptHash` syscall.
func GetEntryScriptHash() interop.Hash160 { func GetEntryScriptHash() interop.Hash160 {
return neogointernal.Syscall0("System.Runtime.GetEntryScriptHash").(interop.Hash160) return tutusinternal.Syscall0("System.Runtime.GetEntryScriptHash").(interop.Hash160)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/tutus-one/tutus-chain/pkg/interop" "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/interop/contract" "github.com/tutus-one/tutus-chain/pkg/interop/contract"
"github.com/tutus-one/tutus-chain/pkg/interop/native/ledger" "github.com/tutus-one/tutus-chain/pkg/interop/native/ledger"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Trigger values to compare with GetTrigger result. // Trigger values to compare with GetTrigger result.
@ -21,21 +21,21 @@ const (
// BurnGas burns provided amount of GAS. It uses `System.Runtime.BurnGas` syscall. // BurnGas burns provided amount of GAS. It uses `System.Runtime.BurnGas` syscall.
func BurnGas(gas int) { func BurnGas(gas int) {
neogointernal.Syscall1NoReturn("System.Runtime.BurnGas", gas) tutusinternal.Syscall1NoReturn("System.Runtime.BurnGas", gas)
} }
// CheckWitness verifies if the given script hash (160-bit BE value in a 20 byte // CheckWitness verifies if the given script hash (160-bit BE value in a 20 byte
// slice) or key (compressed serialized 33-byte form) is one of the signers of // slice) or key (compressed serialized 33-byte form) is one of the signers of
// this invocation. It uses `System.Runtime.CheckWitness` syscall. // this invocation. It uses `System.Runtime.CheckWitness` syscall.
func CheckWitness(hashOrKey []byte) bool { func CheckWitness(hashOrKey []byte) bool {
return neogointernal.Syscall1("System.Runtime.CheckWitness", hashOrKey).(bool) return tutusinternal.Syscall1("System.Runtime.CheckWitness", hashOrKey).(bool)
} }
// CurrentSigners returns signers of the currently loaded transaction or nil if // CurrentSigners returns signers of the currently loaded transaction or nil if
// executing script container is not a transaction. It uses // executing script container is not a transaction. It uses
// `System.Runtime.CurrentSigners` syscall. // `System.Runtime.CurrentSigners` syscall.
func CurrentSigners() []ledger.TransactionSigner { func CurrentSigners() []ledger.TransactionSigner {
return neogointernal.Syscall0("System.Runtime.CurrentSigners").([]ledger.TransactionSigner) return tutusinternal.Syscall0("System.Runtime.CurrentSigners").([]ledger.TransactionSigner)
} }
// LoadScript loads the given bytecode into the VM and executes it with the // LoadScript loads the given bytecode into the VM and executes it with the
@ -50,14 +50,14 @@ func CurrentSigners() []ledger.TransactionSigner {
// appropriately handle exceptions if bytecode comes from untrusted source. // appropriately handle exceptions if bytecode comes from untrusted source.
// This function uses `System.Runtime.LoadScript` syscall. // This function uses `System.Runtime.LoadScript` syscall.
func LoadScript(script []byte, f contract.CallFlag, args ...any) any { func LoadScript(script []byte, f contract.CallFlag, args ...any) any {
return neogointernal.Syscall3("System.Runtime.LoadScript", script, f, args) return tutusinternal.Syscall3("System.Runtime.LoadScript", script, f, args)
} }
// Log instructs VM to log the given message. It's mostly used for debugging // Log instructs VM to log the given message. It's mostly used for debugging
// purposes as these messages are not saved anywhere normally and usually are // purposes as these messages are not saved anywhere normally and usually are
// only visible in the VM logs. This function uses `System.Runtime.Log` syscall. // only visible in the VM logs. This function uses `System.Runtime.Log` syscall.
func Log(message string) { func Log(message string) {
neogointernal.Syscall1NoReturn("System.Runtime.Log", message) tutusinternal.Syscall1NoReturn("System.Runtime.Log", message)
} }
// Notify sends a notification (collecting all arguments in an array) to the // Notify sends a notification (collecting all arguments in an array) to the
@ -67,7 +67,7 @@ func Log(message string) {
// from outside and act upon accordingly. This function uses // from outside and act upon accordingly. This function uses
// `System.Runtime.Notify` syscall. // `System.Runtime.Notify` syscall.
func Notify(name string, args ...any) { func Notify(name string, args ...any) {
neogointernal.Syscall2NoReturn("System.Runtime.Notify", name, args) tutusinternal.Syscall2NoReturn("System.Runtime.Notify", name, args)
} }
// GetAddressVersion returns the address version of the current protocol. The // GetAddressVersion returns the address version of the current protocol. The
@ -75,13 +75,13 @@ func Notify(name string, args ...any) {
// encoding them. The default value for Neo3 is 53 (0x35). This function uses // encoding them. The default value for Neo3 is 53 (0x35). This function uses
// `System.Runtime.GetAddressVersion` syscall. // `System.Runtime.GetAddressVersion` syscall.
func GetAddressVersion() int { func GetAddressVersion() int {
return neogointernal.Syscall0("System.Runtime.GetAddressVersion").(int) return tutusinternal.Syscall0("System.Runtime.GetAddressVersion").(int)
} }
// GetNetwork returns network magic number. This function uses // GetNetwork returns network magic number. This function uses
// `System.Runtime.GetNetwork` syscall. // `System.Runtime.GetNetwork` syscall.
func GetNetwork() int { func GetNetwork() int {
return neogointernal.Syscall0("System.Runtime.GetNetwork").(int) return tutusinternal.Syscall0("System.Runtime.GetNetwork").(int)
} }
// GetTime returns the timestamp of the most recent block. Note that when running // GetTime returns the timestamp of the most recent block. Note that when running
@ -90,7 +90,7 @@ func GetNetwork() int {
// time of this (currently being processed) block. This function uses // time of this (currently being processed) block. This function uses
// `System.Runtime.GetTime` syscall. // `System.Runtime.GetTime` syscall.
func GetTime() int { func GetTime() int {
return neogointernal.Syscall0("System.Runtime.GetTime").(int) return tutusinternal.Syscall0("System.Runtime.GetTime").(int)
} }
// GetTrigger returns the smart contract invocation trigger which can be either // GetTrigger returns the smart contract invocation trigger which can be either
@ -100,13 +100,13 @@ func GetTime() int {
// not available when running with verification trigger. This function uses // not available when running with verification trigger. This function uses
// `System.Runtime.GetTrigger` syscall. // `System.Runtime.GetTrigger` syscall.
func GetTrigger() byte { func GetTrigger() byte {
return neogointernal.Syscall0("System.Runtime.GetTrigger").(byte) return tutusinternal.Syscall0("System.Runtime.GetTrigger").(byte)
} }
// GasLeft returns the amount of gas available for the current execution. // GasLeft returns the amount of gas available for the current execution.
// This function uses `System.Runtime.GasLeft` syscall. // This function uses `System.Runtime.GasLeft` syscall.
func GasLeft() int { func GasLeft() int {
return neogointernal.Syscall0("System.Runtime.GasLeft").(int) return tutusinternal.Syscall0("System.Runtime.GasLeft").(int)
} }
// GetNotifications returns notifications emitted by contract h. // GetNotifications returns notifications emitted by contract h.
@ -114,24 +114,24 @@ func GasLeft() int {
// [ scripthash of notification's contract , emitted item ]. // [ scripthash of notification's contract , emitted item ].
// This function uses `System.Runtime.GetNotifications` syscall. // This function uses `System.Runtime.GetNotifications` syscall.
func GetNotifications(h interop.Hash160) [][]any { func GetNotifications(h interop.Hash160) [][]any {
return neogointernal.Syscall1("System.Runtime.GetNotifications", h).([][]any) return tutusinternal.Syscall1("System.Runtime.GetNotifications", h).([][]any)
} }
// GetInvocationCounter returns how many times current contract was invoked during current tx execution. // GetInvocationCounter returns how many times current contract was invoked during current tx execution.
// This function uses `System.Runtime.GetInvocationCounter` syscall. // This function uses `System.Runtime.GetInvocationCounter` syscall.
func GetInvocationCounter() int { func GetInvocationCounter() int {
return neogointernal.Syscall0("System.Runtime.GetInvocationCounter").(int) return tutusinternal.Syscall0("System.Runtime.GetInvocationCounter").(int)
} }
// Platform returns the platform name, which is set to be `NEO`. This function uses // Platform returns the platform name, which is set to be `NEO`. This function uses
// `System.Runtime.Platform` syscall. // `System.Runtime.Platform` syscall.
func Platform() []byte { func Platform() []byte {
return neogointernal.Syscall0("System.Runtime.Platform").([]byte) return tutusinternal.Syscall0("System.Runtime.Platform").([]byte)
} }
// GetRandom returns pseudo-random number which depends on block nonce and tx hash. // GetRandom returns pseudo-random number which depends on block nonce and tx hash.
// Each invocation will return a different number. This function uses // Each invocation will return a different number. This function uses
// `System.Runtime.GetRandom` syscall. // `System.Runtime.GetRandom` syscall.
func GetRandom() int { func GetRandom() int {
return neogointernal.Syscall0("System.Runtime.GetRandom").(int) return tutusinternal.Syscall0("System.Runtime.GetRandom").(int)
} }

View File

@ -8,7 +8,7 @@ package storage
import ( import (
"github.com/tutus-one/tutus-chain/pkg/interop/iterator" "github.com/tutus-one/tutus-chain/pkg/interop/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal" "github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
) )
// Context represents storage context that is mandatory for Put/Get/Delete // Context represents storage context that is mandatory for Put/Get/Delete
@ -52,13 +52,13 @@ const (
// using this new Context. If Context is already read-only this function is a // using this new Context. If Context is already read-only this function is a
// no-op. It uses `System.Storage.AsReadOnly` syscall. // no-op. It uses `System.Storage.AsReadOnly` syscall.
func ConvertContextToReadOnly(ctx Context) Context { func ConvertContextToReadOnly(ctx Context) Context {
return neogointernal.Syscall1("System.Storage.AsReadOnly", ctx).(Context) return tutusinternal.Syscall1("System.Storage.AsReadOnly", ctx).(Context)
} }
// GetContext returns current contract's (that invokes this function) storage // GetContext returns current contract's (that invokes this function) storage
// context. It uses `System.Storage.GetContext` syscall. // context. It uses `System.Storage.GetContext` syscall.
func GetContext() Context { func GetContext() Context {
return neogointernal.Syscall0("System.Storage.GetContext").(Context) return tutusinternal.Syscall0("System.Storage.GetContext").(Context)
} }
// GetReadOnlyContext returns current contract's (that invokes this function) // GetReadOnlyContext returns current contract's (that invokes this function)
@ -66,7 +66,7 @@ func GetContext() Context {
// functions, but using it for Put and Delete will fail. It uses // functions, but using it for Put and Delete will fail. It uses
// `System.Storage.GetReadOnlyContext` syscall. // `System.Storage.GetReadOnlyContext` syscall.
func GetReadOnlyContext() Context { func GetReadOnlyContext() Context {
return neogointernal.Syscall0("System.Storage.GetReadOnlyContext").(Context) return tutusinternal.Syscall0("System.Storage.GetReadOnlyContext").(Context)
} }
// Put saves given value with given key in the storage using given Context. // Put saves given value with given key in the storage using given Context.
@ -75,36 +75,36 @@ func GetReadOnlyContext() Context {
// slices of more complex types). To put more complex types there serialize them // slices of more complex types). To put more complex types there serialize them
// first using runtime.Serialize. This function uses `System.Storage.Put` syscall. // first using runtime.Serialize. This function uses `System.Storage.Put` syscall.
func Put(ctx Context, key any, value any) { func Put(ctx Context, key any, value any) {
neogointernal.Syscall3NoReturn("System.Storage.Put", ctx, key, value) tutusinternal.Syscall3NoReturn("System.Storage.Put", ctx, key, value)
} }
// LocalPut is similar to Put, but does not require context. // LocalPut is similar to Put, but does not require context.
func LocalPut(key []byte, value []byte) { func LocalPut(key []byte, value []byte) {
neogointernal.Syscall2NoReturn("System.Storage.Local.Put", key, value) tutusinternal.Syscall2NoReturn("System.Storage.Local.Put", key, value)
} }
// Get retrieves value stored for the given key using given Context. See Put // Get retrieves value stored for the given key using given Context. See Put
// documentation on possible key and value types. If the value is not present in // documentation on possible key and value types. If the value is not present in
// the database it returns nil. This function uses `System.Storage.Get` syscall. // the database it returns nil. This function uses `System.Storage.Get` syscall.
func Get(ctx Context, key any) any { func Get(ctx Context, key any) any {
return neogointernal.Syscall2("System.Storage.Get", ctx, key) return tutusinternal.Syscall2("System.Storage.Get", ctx, key)
} }
// LocalGet is similar to Get, but does not require context. // LocalGet is similar to Get, but does not require context.
func LocalGet(key []byte) any { func LocalGet(key []byte) any {
return neogointernal.Syscall1("System.Storage.Local.Get", key) return tutusinternal.Syscall1("System.Storage.Local.Get", key)
} }
// Delete removes key-value pair from storage by the given key using given // Delete removes key-value pair from storage by the given key using given
// Context. See Put documentation on possible key types. This function uses // Context. See Put documentation on possible key types. This function uses
// `System.Storage.Delete` syscall. // `System.Storage.Delete` syscall.
func Delete(ctx Context, key any) { func Delete(ctx Context, key any) {
neogointernal.Syscall2NoReturn("System.Storage.Delete", ctx, key) tutusinternal.Syscall2NoReturn("System.Storage.Delete", ctx, key)
} }
// LocalDelete is similar to Delete, but does not require context. // LocalDelete is similar to Delete, but does not require context.
func LocalDelete(key []byte) { func LocalDelete(key []byte) {
neogointernal.Syscall1NoReturn("System.Storage.Local.Delete", key) tutusinternal.Syscall1NoReturn("System.Storage.Local.Delete", key)
} }
// Find returns an iterator.Iterator over key-value pairs in the given Context // Find returns an iterator.Iterator over key-value pairs in the given Context
@ -112,10 +112,10 @@ func LocalDelete(key []byte) {
// possible key types and iterator package documentation on how to use the // possible key types and iterator package documentation on how to use the
// returned value. This function uses `System.Storage.Find` syscall. // returned value. This function uses `System.Storage.Find` syscall.
func Find(ctx Context, key any, options FindFlags) iterator.Iterator { func Find(ctx Context, key any, options FindFlags) iterator.Iterator {
return neogointernal.Syscall3("System.Storage.Find", ctx, key, options).(iterator.Iterator) return tutusinternal.Syscall3("System.Storage.Find", ctx, key, options).(iterator.Iterator)
} }
// LocalFind is similar to Find, but does not require context. // LocalFind is similar to Find, but does not require context.
func LocalFind(key []byte, options FindFlags) iterator.Iterator { func LocalFind(key []byte, options FindFlags) iterator.Iterator {
return neogointernal.Syscall2("System.Storage.Local.Find", key, options).(iterator.Iterator) return tutusinternal.Syscall2("System.Storage.Local.Find", key, options).(iterator.Iterator)
} }

View File

@ -1,4 +1,4 @@
package neogointernal package tutusinternal
// CallWithToken performs contract call using CALLT instruction. It only works // CallWithToken performs contract call using CALLT instruction. It only works
// for static script hashes and methods, requiring additional metadata compared to // for static script hashes and methods, requiring additional metadata compared to

View File

@ -2,4 +2,4 @@
Package neogointernal contains definitions of compiler intrinsics. Package neogointernal contains definitions of compiler intrinsics.
It's not intended to be used directly by smart contracts. It's not intended to be used directly by smart contracts.
*/ */
package neogointernal package tutusinternal

Some files were not shown because too many files have changed in this diff Show More