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/encoding/address"
"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/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/vm"
"github.com/tutus-one/tutus-chain/pkg/vm/vmstate"
@ -315,7 +315,7 @@ func queryVoter(ctx *cli.Context) error {
return exitErr
}
neoToken := neo.NewReader(invoker.New(c, nil))
neoToken := tutus.NewReader(invoker.New(c, nil))
st, err := neoToken.GetAccountState(addr)
if err != nil {

View File

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

View File

@ -83,7 +83,7 @@ func NewCommands() []*cli.Command {
return []*cli.Command{
{
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]",
Action: startServer,
Flags: cfgFlags,
@ -526,7 +526,7 @@ func startServer(ctx *cli.Context) error {
errChan := make(chan error)
rpcServer := rpcsrv.New(chain, cfg.ApplicationConfiguration.RPC, serv, oracleSrv, log, errChan)
serv.AddService(rpcServer)
setNeoGoVersion(config.Version)
setTutusVersion(config.Version)
serv.Start()
if !cfg.ApplicationConfiguration.RPC.StartWhenSynchronized {
// 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
}
// Logo returns NeoGo logo.
// Logo returns Tutus logo.
func Logo() string {
return `
_ ____________ __________

View File

@ -24,7 +24,7 @@ import (
"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/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/nef"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/trigger"
@ -176,7 +176,7 @@ package testcontract
import (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
"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.
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.
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.
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.
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))
}

View File

@ -161,7 +161,7 @@ import (
"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/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"
)
@ -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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 (
"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.
@ -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.
func Get() int {
return neogointernal.CallWithToken(Hash, "get", int(contract.ReadOnly)).(int)
return tutusinternal.CallWithToken(Hash, "get", int(contract.ReadOnly)).(int)
}
`, string(data))
e.Run(t, []string{"", "contract", "generate-rpcwrapper",
@ -390,7 +390,7 @@ func Get() int {
package myspacecontract
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/util"
"math/big"

View File

@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"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/vm/stackitem"
"unicode/utf8"

View File

@ -8,7 +8,7 @@ import (
"errors"
"fmt"
"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/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"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/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"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/util"
"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/core/state"
"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/invoker"
"github.com/tutus-one/tutus-chain/pkg/rpcclient/management"

View File

@ -8,7 +8,7 @@ import (
"fmt"
"github.com/google/uuid"
"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/unwrap"
"github.com/tutus-one/tutus-chain/pkg/smartcontract"

View File

@ -8,7 +8,7 @@ import (
"fmt"
"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/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/unwrap"
"github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -5,7 +5,7 @@ package nonnepxxcontractwithiterators
import (
"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/util"
"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/pkg/core/state"
"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/waiter"
"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.ErrWriter = l.Stderr()
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.
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/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/util"
"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/keys"
"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/context"
"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/pkg/config"
"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/nep11"
"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/encoding/address"
"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/actor"
"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/nep17"
"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.
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") {
h = gas.Hash
} else {

View File

@ -12,7 +12,7 @@ import (
"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/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/util"
"github.com/tutus-one/tutus-chain/pkg/wallet"
@ -102,11 +102,11 @@ func newValidatorCommands() []*cli.Command {
func handleRegister(ctx *cli.Context) error {
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 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()
if err != nil {
return nil, err
@ -121,24 +121,24 @@ func handleRegister(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())
})
}
func handleNeoAction(ctx *cli.Context, mkTx func(*neo.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) {
func handleNeoAction(ctx *cli.Context, mkTx func(*tutus.Contract, util.Uint160, *wallet.Account) (*transaction.Transaction, error)) error {
return handleTokenAction(ctx, func(nc *tutus.Contract, _ *nep17.Token, addr util.Uint160, acc *wallet.Account) (*transaction.Transaction, error) {
return mkTx(nc, addr, acc)
}, 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)
}
func handleTokenAction(
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,
) error {
if err := cmdargs.EnsureNone(ctx); err != nil {
@ -169,7 +169,7 @@ func handleTokenAction(
return exitErr
}
neoT := neo.New(act)
neoT := tutus.New(act)
gasT := gas.New(act)
tx, err := mkTx(neoT, gasT, addr, acc)
if err != nil {
@ -179,7 +179,7 @@ func handleTokenAction(
}
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 (
err error
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/crypto/keys"
"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/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/scparser"
@ -121,7 +121,7 @@ func NewCommands() []*cli.Command {
signFlags = append(signFlags, options.RPC[1:]...)
return []*cli.Command{{
Name: "wallet",
Usage: "Create, open and manage a Neo wallet",
Usage: "Create, open and manage a Tutus wallet",
Subcommands: []*cli.Command{
{
Name: "claim",
@ -188,7 +188,7 @@ func NewCommands() []*cli.Command {
},
{
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]",
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
@ -375,7 +375,7 @@ func NewCommands() []*cli.Command {
}
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)
})
}

View File

@ -7,8 +7,8 @@ import (
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/core/interop/storage"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
"github.com/stretchr/testify/require"

View File

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

7
go.mod
View File

@ -14,17 +14,17 @@ require (
github.com/holiman/uint256 v1.3.2
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
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/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/prometheus/client_golang v1.23.2
github.com/stretchr/testify v1.11.1
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-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/urfave/cli/v2 v2.27.7
go.uber.org/zap v1.27.0
@ -51,6 +51,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // 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/rfc6979 v0.2.4 // indirect
github.com/nspcc-dev/tzhash v1.8.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // 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/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/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/go.mod h1:CHwf1nwquA6ecSfxmNF0YuemOPHAnRGoLuZUv/WPjeY=
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/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
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/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/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
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/encoding/fixedn"
"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/util"
"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/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/base58"
cinterop "github.com/tutus-one/tutus-chain/pkg/interop"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/manifest"
@ -555,39 +555,39 @@ func TestLenForNil(t *testing.T) {
func TestCallTConversionErrors(t *testing.T) {
t.Run("variable hash", func(t *testing.T) {
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 {
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))
require.Error(t, err)
})
t.Run("bad hash", func(t *testing.T) {
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 {
return neogointernal.CallWithToken("badstring", "method", 0).(int)
return tutusinternal.CallWithToken("badstring", "method", 0).(int)
}`
_, err := compiler.Compile("foo.go", strings.NewReader(src))
require.Error(t, err)
})
t.Run("variable method", func(t *testing.T) {
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 {
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))
require.Error(t, err)
})
t.Run("variable flags", func(t *testing.T) {
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() {
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))
require.Error(t, err)

View File

@ -253,9 +253,9 @@ func TestSyscallInGlobalInit(t *testing.T) {
func TestOpcode(t *testing.T) {
t.Run("1 argument", func(t *testing.T) {
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 {
return neogointernal.Opcode1("ABS", a).(int)
return tutusinternal.Opcode1("ABS", a).(int)
}
func Main() int {
return abs(-42)
@ -264,10 +264,10 @@ func TestOpcode(t *testing.T) {
})
t.Run("2 arguments", func(t *testing.T) {
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 {
return neogointernal.Opcode2("SUB", a,
neogointernal.Opcode2("SUB", b, c).(int)).(int)
return tutusinternal.Opcode2("SUB", a,
tutusinternal.Opcode2("SUB", b, c).(int)).(int)
}
func Main() int {
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/pkg/core/chaindump"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/wallet"
"github.com/stretchr/testify/require"

View File

@ -13,7 +13,7 @@ import (
"time"
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/limits"
"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/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/chaindump"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/smartcontract"
"github.com/tutus-one/tutus-chain/pkg/util"
"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/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/transaction"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/encoding/address"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/manifest"
"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/state"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/trigger"
"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/core/native/nativenames"
"github.com/tutus-one/tutus-chain/pkg/core/state"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/manifest"
"github.com/tutus-one/tutus-chain/pkg/smartcontract/nef"

View File

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
)

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/vm/emit"
"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/nativenames"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/vm/emit"
"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/keys"
"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/util"
"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/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/util"
"github.com/tutus-one/tutus-chain/pkg/vm/emit"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
)

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"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/stackitem"

View File

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

View File

@ -10,8 +10,8 @@ import (
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"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/stackitem"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
)

View File

@ -8,7 +8,7 @@ import (
"strings"
"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/pkg/compiler"
"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/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/keys"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/callflag"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/crypto/keys"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/smartcontract/manifest"
"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/stretchr/testify/require"
"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"
)

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/transaction"
"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/vm/stackitem"
"github.com/stretchr/testify/require"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/transaction"
"github.com/tutus-one/tutus-chain/pkg/io"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"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/manifest"
"github.com/tutus-one/tutus-chain/pkg/util"

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/vm/stackitem"
)

View File

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

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require"
"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"
)

View File

@ -7,7 +7,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/stretchr/testify/require"
"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"
)

View File

@ -7,8 +7,8 @@ import (
"github.com/tutus-one/tutus-chain/pkg/compiler"
"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/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"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/core/native/nativehashes"
"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/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
)
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/stretchr/testify/require"
"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"
)

View File

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

View File

@ -3,7 +3,7 @@ package state
import (
"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/pkg/util"
"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/mpt"
"github.com/tutus-one/tutus-chain/pkg/core/storage"
"github.com/tutus-one/tutus-chain/pkg/neotest"
"github.com/tutus-one/tutus-chain/pkg/neotest/chain"
"github.com/tutus-one/tutus-chain/pkg/tutustest"
"github.com/tutus-one/tutus-chain/pkg/tutustest/chain"
"github.com/tutus-one/tutus-chain/pkg/util"
"github.com/stretchr/testify/require"
)

View File

@ -7,7 +7,7 @@ import (
"os"
"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/io"
)

View File

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

View File

@ -13,7 +13,7 @@ import (
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/tutus-one/tutus-chain/pkg/crypto/hash"
"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

View File

@ -5,7 +5,7 @@ package contract
import (
"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.
@ -28,19 +28,19 @@ const (
// script using the given m and a set of public keys bytes. This function uses
// `System.Contract.CreateMultisigAccount` syscall.
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.
// This function uses `System.Contract.CreateStandardAccount` syscall.
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.
// This function uses `System.Contract.GetCallFlags` syscall.
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
@ -48,5 +48,5 @@ func GetCallFlags() CallFlag {
// It returns whatever this contract returns. This function uses
// `System.Contract.Call` syscall.
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
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.
func ToInteger(v any) int {
@ -40,7 +40,7 @@ func BytesToUint8(data []byte) uint8 {
func Uint16ToBytesBE(n uint16) []byte {
var res = make([]byte, 2)
copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res
}
@ -51,7 +51,7 @@ func BytesBEToUint16(data []byte) uint16 {
}
src := make([]byte, 2)
copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint16(ToInteger(src))
}
@ -77,7 +77,7 @@ func BytesLEToUint16(data []byte) uint16 {
func Uint32ToBytesBE(n uint32) []byte {
var res = make([]byte, 4)
copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res
}
@ -88,7 +88,7 @@ func BytesBEToUint32(data []byte) uint32 {
}
src := make([]byte, 4)
copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint32(ToInteger(src))
}
@ -114,7 +114,7 @@ func BytesLEToUint32(data []byte) uint32 {
func Uint64ToBytesBE(n uint64) []byte {
var res = make([]byte, 8)
copy(res, ToBytes(n))
neogointernal.Opcode1NoReturn("REVERSEITEMS", res)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", res)
return res
}
@ -125,7 +125,7 @@ func BytesBEToUint64(data []byte) uint64 {
}
src := make([]byte, 8)
copy(src, data)
neogointernal.Opcode1NoReturn("REVERSEITEMS", src)
tutusinternal.Opcode1NoReturn("REVERSEITEMS", src)
src = append(src, 0) // preserve compatibility with bigint.FromBytes.
return uint64(ToInteger(src))
}

View File

@ -5,18 +5,18 @@ package crypto
import (
"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
// ECDSA keys at once. It uses `System.Crypto.CheckMultisig` syscall.
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
// (transaction) for the given pub (serialized public key). It uses
// `System.Crypto.CheckSig` syscall.
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
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
// 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
// uses `System.Iterator.Next` syscall.
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
@ -27,5 +27,5 @@ func Next(it Iterator) bool {
// If the iterator is configured to return key-value pairs, the result can be
// directly type-asserted to [storage.KeyValue] type.
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
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.
// b must be >= 0 and <= 2^31-1.
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.
func Sqrt(x int) int {
return neogointernal.Opcode1("SQRT", x).(int)
return tutusinternal.Opcode1("SQRT", x).(int)
}
// Sign returns:
@ -22,26 +22,26 @@ func Sqrt(x int) int {
// 0 if x == 0
// +1 if x > 0
func Sign(a int) int {
return neogointernal.Opcode1("SIGN", a).(int)
return tutusinternal.Opcode1("SIGN", a).(int)
}
// Abs returns an absolute value of a.
func Abs(a int) int {
return neogointernal.Opcode1("ABS", a).(int)
return tutusinternal.Opcode1("ABS", a).(int)
}
// Within returns true if a <= x < b.
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.
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,
// it returns the modular inverse of a.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// Hash represents CryptoLib contract hash.
@ -26,31 +26,31 @@ const (
// Sha256 calls `sha256` method of native CryptoLib contract and computes SHA256 hash of b.
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.
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
// using the given seed.
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
// 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 {
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
// a correct msg's signature for the given pub. Note that this method is available starting from
// [config.HFEchidna] hardfork.
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
@ -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
// starting from [config.HFEchidna] hardfork.
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
@ -73,25 +73,25 @@ type Bls12381Point struct{}
// Bls12381Serialize calls `bls12381Serialize` method of native CryptoLib contract
// and serializes given BLS12-381 point into byte array.
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
// contract and deserializes given BLS12-381 point from byte array.
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
// checks whether two BLS12-381 points are equal.
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
// performs addition operation over two BLS12-381 points.
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
@ -100,18 +100,18 @@ func Bls12381Add(x, y Bls12381Point) Bls12381Point {
// field element stored on 4 words (uint64) with 32-bytes length. The last
// argument denotes whether the multiplicator should be negative.
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
// 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.
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
// computes Keccak256 hash of b.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// Hash represents Ledger contract hash.
@ -30,42 +30,42 @@ const (
// CurrentHash represents `currentHash` method of Ledger native contract.
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.
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.
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.
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.
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.
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)
}
// GetTransactionSigners represents `getTransactionSigners` method of Ledger native contract.
func GetTransactionSigners(hash interop.Hash256) []TransactionSigner {
return neogointernal.CallWithToken(Hash, "getTransactionSigners", int(contract.ReadStates),
return tutusinternal.CallWithToken(Hash, "getTransactionSigners", int(contract.ReadStates),
hash).([]TransactionSigner)
}
// GetTransactionVMState represents `getTransactionVMState` method of Ledger native contract.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// 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.
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.
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.
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.
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.
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)
}

View File

@ -8,7 +8,7 @@ import (
"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/iterator"
"github.com/tutus-one/tutus-chain/pkg/interop/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// Hash represents Management contract hash.
@ -24,29 +24,29 @@ type IDHash struct {
// Deploy represents `deploy` method of Management native contract.
func Deploy(script, manifest []byte) *Contract {
return neogointernal.CallWithToken(Hash, "deploy",
return tutusinternal.CallWithToken(Hash, "deploy",
int(contract.All), script, manifest).(*Contract)
}
// DeployWithData represents `deploy` method of Management native 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)
}
// Destroy represents `destroy` method of Management native contract.
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.
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.
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
@ -54,34 +54,34 @@ func GetContractByID(id int) *Contract {
// hashes. Each iterator value can be cast to IDHash. Use [iterator] interop
// package to work with the returned 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.
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
// 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 {
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.
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.
func Update(script, manifest []byte) {
neogointernal.CallWithTokenNoRet(Hash, "update",
tutusinternal.CallWithTokenNoRet(Hash, "update",
int(contract.All), script, manifest)
}
// UpdateWithData represents `update` method of Management native contract.
func UpdateWithData(script, manifest []byte, data any) {
neogointernal.CallWithTokenNoRet(Hash, "update",
tutusinternal.CallWithTokenNoRet(Hash, "update",
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
// from [config.HFEchidna] hardfork.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// 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.
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)
}
// Withdraw represents `withdraw` method of Notary native contract.
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)
}
// BalanceOf represents `balanceOf` method of Notary native contract.
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.
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.
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.
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 (
"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
@ -65,18 +65,18 @@ const MinimumResponseGas = 10_000_000
// so it should be enough to pay for reply data as well as
// its processing.
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),
url, filter, cb, userData, gasForResponse)
}
// GetPrice returns the current oracle request price.
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
// successfully invoked by the committee.
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/contract"
"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.
@ -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.
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.
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.
// It returns the execution fee factor in Datoshi units.
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.
// It returns the execution fee factor in picoGAS units. Note that this method is available
// starting from [config.HFFaun] hardfork.
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.
// Note that starting from [config.HFFaun] hardfork this method accepts the value
// in picoGAS units instead of Datoshi units.
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.
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.
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.
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.
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.
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.
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.
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.
// Note that this method is available starting from [config.HFEchidna] hardfork.
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.
// Note that this method is available starting from [config.HFEchidna] hardfork.
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.
// Note that this method is available starting from [config.HFEchidna] hardfork.
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.
// Note that this method is available starting from [config.HFEchidna] hardfork.
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.
// Note that this method is available starting from [config.HFFaun] hardfork.
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.
// Note that this method is available starting from [config.HFFaun] hardfork.
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)
}
// RemoveWhitelistFeeContract represents the `removeWhitelistFeeContract` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork.
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)
}
// GetWhitelistFeeContracts represents the `getWhitelistFeeContracts` method of Policy native contract.
// Note that this method is available starting from [config.HFFaun] hardfork.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// Hash represents RoleManagement contract hash.
@ -27,12 +27,12 @@ const (
// GetDesignatedByRole represents `getDesignatedByRole` method of RoleManagement native contract.
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)
}
// DesignateAsRole represents `designateAsRole` method of RoleManagement native contract.
func DesignateAsRole(r Role, pubs []interop.PublicKey) {
neogointernal.CallWithTokenNoRet(Hash, "designateAsRole",
tutusinternal.CallWithTokenNoRet(Hash, "designateAsRole",
int(contract.States|contract.AllowNotify), r, pubs)
}

View File

@ -6,7 +6,7 @@ package std
import (
"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.
@ -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
// and then Deserialize them on the next run or in the external event receiver.
func Serialize(item any) []byte {
return neogointernal.CallWithToken(Hash, "serialize", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "serialize", int(contract.NoneFlag),
item).([]byte)
}
// Deserialize calls `deserialize` method of StdLib native contract and unpacks
// a previously serialized value from a byte slice, it's the opposite of Serialize.
func Deserialize(b []byte) any {
return neogointernal.CallWithToken(Hash, "deserialize", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "deserialize", int(contract.NoneFlag),
b)
}
@ -40,7 +40,7 @@ func Deserialize(b []byte) any {
// []any -> json array
// map[type1]type2 -> json object with string keys marshaled as strings (not base64).
func JSONSerialize(item any) []byte {
return neogointernal.CallWithToken(Hash, "jsonSerialize", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "jsonSerialize", int(contract.NoneFlag),
item).([]byte)
}
@ -54,7 +54,7 @@ func JSONSerialize(item any) []byte {
// arrays -> []interface{}
// maps -> map[string]interface{}
func JSONDeserialize(data []byte) any {
return neogointernal.CallWithToken(Hash, "jsonDeserialize", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "jsonDeserialize", int(contract.NoneFlag),
data)
}
@ -62,14 +62,14 @@ func JSONDeserialize(data []byte) any {
// the given byte slice into a base64 string and returns byte representation of this
// string.
func Base64Encode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base64Encode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base64Encode", int(contract.NoneFlag),
b).(string)
}
// Base64Decode calls `base64Decode` method of StdLib native contract and decodes
// the given base64 string represented as a byte slice into byte slice.
func Base64Decode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base64Decode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base64Decode", int(contract.NoneFlag),
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
// string.
func Base58Encode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base58Encode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base58Encode", int(contract.NoneFlag),
b).(string)
}
// Base58Decode calls `base58Decode` method of StdLib native contract and decodes
// the given base58 string represented as a byte slice into a new byte slice.
func Base58Decode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base58Decode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base58Decode", int(contract.NoneFlag),
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
// string.
func Base58CheckEncode(b []byte) string {
return neogointernal.CallWithToken(Hash, "base58CheckEncode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base58CheckEncode", int(contract.NoneFlag),
b).(string)
}
// 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.
func Base58CheckDecode(b []byte) []byte {
return neogointernal.CallWithToken(Hash, "base58CheckDecode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "base58CheckDecode", int(contract.NoneFlag),
b).([]byte)
}
// 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.
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)
}
// Itoa10 converts num in base 10 to a string.
// It uses `itoa` method of StdLib native contract.
func Itoa10(num int) string {
return neogointernal.CallWithToken(Hash, "itoa", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "itoa", int(contract.NoneFlag),
num).(string)
}
// 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.
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)
}
// Atoi10 converts a string to a number in base 10.
// It uses `atoi` method of StdLib native contract.
func Atoi10(s string) int {
return neogointernal.CallWithToken(Hash, "atoi", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "atoi", int(contract.NoneFlag),
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.
// It uses `memoryCompare` method of StdLib native contract.
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)
}
// 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.
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)
}
// 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.
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)
}
// 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.
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)
}
// StringSplit splits s by occurrences of the sep.
// It uses `stringSplit` method of StdLib native contract.
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)
}
// StringSplitNonEmpty splits s by occurrences of the sep and returns a list of non-empty items.
// It uses `stringSplit` method of StdLib native contract.
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)
}
// StrLen returns length of the string in Utf- characters.
// It uses `strLen` method of StdLib native contract.
func StrLen(s string) int {
return neogointernal.CallWithToken(Hash, "strLen", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "strLen", int(contract.NoneFlag),
s).(int)
}
@ -185,7 +185,7 @@ func StrLen(s string) int {
// It uses `hexEncode` method of StdLib native contract. Note that this method is
// available starting from [config.HFFaun] hardfork.
func HexEncode(b []byte) string {
return neogointernal.CallWithToken(Hash, "hexEncode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "hexEncode", int(contract.NoneFlag),
b).(string)
}
@ -193,6 +193,6 @@ func HexEncode(b []byte) string {
// It uses `hexDecode` method of StdLib native contract. Note that this method is
// available starting from [config.HFFaun] hardfork.
func HexDecode(s string) []byte {
return neogointernal.CallWithToken(Hash, "hexDecode", int(contract.NoneFlag),
return tutusinternal.CallWithToken(Hash, "hexDecode", int(contract.NoneFlag),
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/contract"
"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.
@ -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.
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.
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.
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.
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.
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)
}
// GetCommittee represents `getCommittee` method of Tutus native contract.
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
// returns up to 256 candidates. Use GetAllCandidates in case if you need the
// whole set of candidates.
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.
@ -67,67 +67,67 @@ func GetCandidates() []Candidate {
// bytes. Each iterator value can be cast to Candidate. Use iterator interop
// package to work with the returned 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.
// It returns -1 if the candidate hasn't been registered or voted for and the
// overall candidate votes otherwise.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 (
"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/neogointernal"
"github.com/tutus-one/tutus-chain/pkg/interop/tutusinternal"
)
// GetScriptContainer returns the transaction that initially triggered current
@ -11,7 +11,7 @@ import (
// this execution goes. This function uses
// `System.Runtime.GetScriptContainer` syscall.
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
@ -20,7 +20,7 @@ func GetScriptContainer() *ledger.Transaction {
// different contract. This function uses
// `System.Runtime.GetExecutingScriptHash` syscall.
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
@ -29,7 +29,7 @@ func GetExecutingScriptHash() interop.Hash160 {
// above the GetExecutingScriptHash in the call stack. It uses
// `System.Runtime.GetCallingScriptHash` syscall.
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
@ -38,5 +38,5 @@ func GetCallingScriptHash() interop.Hash160 {
// GetScriptContainer) execution from the start. This function uses
// `System.Runtime.GetEntryScriptHash` syscall.
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/contract"
"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.
@ -21,21 +21,21 @@ const (
// BurnGas burns provided amount of GAS. It uses `System.Runtime.BurnGas` syscall.
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
// slice) or key (compressed serialized 33-byte form) is one of the signers of
// this invocation. It uses `System.Runtime.CheckWitness` syscall.
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
// executing script container is not a transaction. It uses
// `System.Runtime.CurrentSigners` syscall.
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
@ -50,14 +50,14 @@ func CurrentSigners() []ledger.TransactionSigner {
// appropriately handle exceptions if bytecode comes from untrusted source.
// This function uses `System.Runtime.LoadScript` syscall.
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
// 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.
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
@ -67,7 +67,7 @@ func Log(message string) {
// from outside and act upon accordingly. This function uses
// `System.Runtime.Notify` syscall.
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
@ -75,13 +75,13 @@ func Notify(name string, args ...any) {
// encoding them. The default value for Neo3 is 53 (0x35). This function uses
// `System.Runtime.GetAddressVersion` syscall.
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
// `System.Runtime.GetNetwork` syscall.
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
@ -90,7 +90,7 @@ func GetNetwork() int {
// time of this (currently being processed) block. This function uses
// `System.Runtime.GetTime` syscall.
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
@ -100,13 +100,13 @@ func GetTime() int {
// not available when running with verification trigger. This function uses
// `System.Runtime.GetTrigger` syscall.
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.
// This function uses `System.Runtime.GasLeft` syscall.
func GasLeft() int {
return neogointernal.Syscall0("System.Runtime.GasLeft").(int)
return tutusinternal.Syscall0("System.Runtime.GasLeft").(int)
}
// GetNotifications returns notifications emitted by contract h.
@ -114,24 +114,24 @@ func GasLeft() int {
// [ scripthash of notification's contract , emitted item ].
// This function uses `System.Runtime.GetNotifications` syscall.
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.
// This function uses `System.Runtime.GetInvocationCounter` syscall.
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
// `System.Runtime.Platform` syscall.
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.
// Each invocation will return a different number. This function uses
// `System.Runtime.GetRandom` syscall.
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 (
"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
@ -52,13 +52,13 @@ const (
// using this new Context. If Context is already read-only this function is a
// no-op. It uses `System.Storage.AsReadOnly` syscall.
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
// context. It uses `System.Storage.GetContext` syscall.
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)
@ -66,7 +66,7 @@ func GetContext() Context {
// functions, but using it for Put and Delete will fail. It uses
// `System.Storage.GetReadOnlyContext` syscall.
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.
@ -75,36 +75,36 @@ func GetReadOnlyContext() Context {
// slices of more complex types). To put more complex types there serialize them
// first using runtime.Serialize. This function uses `System.Storage.Put` syscall.
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.
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
// 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.
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.
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
// Context. See Put documentation on possible key types. This function uses
// `System.Storage.Delete` syscall.
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.
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
@ -112,10 +112,10 @@ func LocalDelete(key []byte) {
// possible key types and iterator package documentation on how to use the
// returned value. This function uses `System.Storage.Find` syscall.
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.
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
// for static script hashes and methods, requiring additional metadata compared to

View File

@ -2,4 +2,4 @@
Package neogointernal contains definitions of compiler intrinsics.
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