forked from TrueCloudLab/neoneo-go
*: replace interface{}
with any
keyword
Everywhere including examples, external interop APIs, bindings generators code and in other valuable places. A couple of `interface{}` usages are intentionally left in the CHANGELOG.md, documentation and tests.
This commit is contained in:
parent
83545b8451
commit
6b21ad9922
199 changed files with 1256 additions and 1231 deletions
|
@ -230,9 +230,9 @@ func parseCosigner(c string) (transaction.Signer, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDataFromContext returns data parameter from context args.
|
// GetDataFromContext returns data parameter from context args.
|
||||||
func GetDataFromContext(ctx *cli.Context) (int, interface{}, *cli.ExitError) {
|
func GetDataFromContext(ctx *cli.Context) (int, any, *cli.ExitError) {
|
||||||
var (
|
var (
|
||||||
data interface{}
|
data any
|
||||||
offset int
|
offset int
|
||||||
params []smartcontract.Parameter
|
params []smartcontract.Parameter
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -662,7 +662,7 @@ func initBlockChain(cfg config.Config, log *zap.Logger) (*core.Blockchain, stora
|
||||||
chain, err := core.NewBlockchain(store, cfg.Blockchain(), log)
|
chain, err := core.NewBlockchain(store, cfg.Blockchain(), log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errText := "could not initialize blockchain: %w"
|
errText := "could not initialize blockchain: %w"
|
||||||
errArgs := []interface{}{err}
|
errArgs := []any{err}
|
||||||
closeErr := store.Close()
|
closeErr := store.Close()
|
||||||
if closeErr != nil {
|
if closeErr != nil {
|
||||||
errText += "; failed to close the DB: %w"
|
errText += "; failed to close the DB: %w"
|
||||||
|
|
|
@ -187,7 +187,7 @@ func Zum(typev int, typev_ int, funcv int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// JustExecute invokes ` + "`justExecute`" + ` method of contract.
|
// JustExecute invokes ` + "`justExecute`" + ` method of contract.
|
||||||
func JustExecute(arr []interface{}) {
|
func JustExecute(arr []any) {
|
||||||
neogointernal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr)
|
neogointernal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ func GetPublicKey() interop.PublicKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OtherTypes invokes ` + "`otherTypes`" + ` method of contract.
|
// OtherTypes invokes ` + "`otherTypes`" + ` method of contract.
|
||||||
func OtherTypes(ctr interop.Hash160, tx interop.Hash256, sig interop.Signature, data interface{}) bool {
|
func OtherTypes(ctr interop.Hash160, tx interop.Hash256, sig interop.Signature, data any) bool {
|
||||||
return neogointernal.CallWithToken(Hash, "otherTypes", int(contract.All), ctr, tx, sig, data).(bool)
|
return neogointernal.CallWithToken(Hash, "otherTypes", int(contract.All), ctr, tx, sig, data).(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ func GetFromMap(intMap map[string]int, indices []string) []int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoSomething invokes ` + "`doSomething`" + ` method of contract.
|
// DoSomething invokes ` + "`doSomething`" + ` method of contract.
|
||||||
func DoSomething(bytes []byte, str string) interface{} {
|
func DoSomething(bytes []byte, str string) any {
|
||||||
return neogointernal.CallWithToken(Hash, "doSomething", int(contract.ReadStates), bytes, str).(interface{})
|
return neogointernal.CallWithToken(Hash, "doSomething", int(contract.ReadStates), bytes, str).(any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockWrapper invokes ` + "`getBlockWrapper`" + ` method of contract.
|
// GetBlockWrapper invokes ` + "`getBlockWrapper`" + ` method of contract.
|
||||||
|
@ -303,7 +303,7 @@ var Hash = util.Uint160{0x4, 0x8, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x0, 0x1,
|
||||||
|
|
||||||
// Invoker is used by ContractReader to call various safe methods.
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
type Invoker interface {
|
type Invoker interface {
|
||||||
Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractReader implements safe contract methods.
|
// ContractReader implements safe contract methods.
|
||||||
|
|
|
@ -19,7 +19,7 @@ const (
|
||||||
permMethodKey = "methods"
|
permMethodKey = "methods"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p permission) MarshalYAML() (interface{}, error) {
|
func (p permission) MarshalYAML() (any, error) {
|
||||||
m := yaml.Node{Kind: yaml.MappingNode}
|
m := yaml.Node{Kind: yaml.MappingNode}
|
||||||
switch p.Contract.Type {
|
switch p.Contract.Type {
|
||||||
case manifest.PermissionWildcard:
|
case manifest.PermissionWildcard:
|
||||||
|
@ -36,7 +36,7 @@ func (p permission) MarshalYAML() (interface{}, error) {
|
||||||
return nil, fmt.Errorf("invalid permission type: %d", p.Contract.Type)
|
return nil, fmt.Errorf("invalid permission type: %d", p.Contract.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
var val interface{} = "*"
|
var val any = "*"
|
||||||
if !p.Methods.IsWildcard() {
|
if !p.Methods.IsWildcard() {
|
||||||
val = p.Methods.Value
|
val = p.Methods.Value
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ func (p permission) MarshalYAML() (interface{}, error) {
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *permission) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (p *permission) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
var m map[string]interface{}
|
var m map[string]any
|
||||||
if err := unmarshal(&m); err != nil {
|
if err := unmarshal(&m); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func (p *permission) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
return p.fillMethods(m)
|
return p.fillMethods(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *permission) fillType(m map[string]interface{}) error {
|
func (p *permission) fillType(m map[string]any) error {
|
||||||
vh, ok1 := m[permHashKey]
|
vh, ok1 := m[permHashKey]
|
||||||
vg, ok2 := m[permGroupKey]
|
vg, ok2 := m[permGroupKey]
|
||||||
switch {
|
switch {
|
||||||
|
@ -104,7 +104,7 @@ func (p *permission) fillType(m map[string]interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *permission) fillMethods(m map[string]interface{}) error {
|
func (p *permission) fillMethods(m map[string]any) error {
|
||||||
methods, ok := m[permMethodKey]
|
methods, ok := m[permMethodKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("'methods' field is missing from permission")
|
return errors.New("'methods' field is missing from permission")
|
||||||
|
@ -116,7 +116,7 @@ func (p *permission) fillMethods(m map[string]interface{}) error {
|
||||||
p.Methods.Value = nil
|
p.Methods.Value = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case []interface{}:
|
case []any:
|
||||||
ms := make([]string, len(mt))
|
ms := make([]string, len(mt))
|
||||||
for i := range mt {
|
for i := range mt {
|
||||||
ms[i], ok = mt[i].(string)
|
ms[i], ok = mt[i].(string)
|
||||||
|
|
|
@ -81,7 +81,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RuntimeNotify sends runtime notification with "Hello world!" name
|
// RuntimeNotify sends runtime notification with "Hello world!" name
|
||||||
func RuntimeNotify(args []interface{}) {
|
func RuntimeNotify(args []any) {
|
||||||
runtime.Notify(notificationName, args)
|
runtime.Notify(notificationName, args)
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
@ -495,7 +495,7 @@ func invokeInternal(ctx *cli.Context, signAndPush bool) error {
|
||||||
err error
|
err error
|
||||||
exitErr *cli.ExitError
|
exitErr *cli.ExitError
|
||||||
operation string
|
operation string
|
||||||
params []interface{}
|
params []any
|
||||||
paramsStart = 1
|
paramsStart = 1
|
||||||
scParams []smartcontract.Parameter
|
scParams []smartcontract.Parameter
|
||||||
cosigners []transaction.Signer
|
cosigners []transaction.Signer
|
||||||
|
@ -521,7 +521,7 @@ func invokeInternal(ctx *cli.Context, signAndPush bool) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
params = make([]interface{}, len(scParams))
|
params = make([]any, len(scParams))
|
||||||
for i := range scParams {
|
for i := range scParams {
|
||||||
params[i] = scParams[i]
|
params[i] = scParams[i]
|
||||||
}
|
}
|
||||||
|
@ -548,7 +548,7 @@ func invokeInternal(ctx *cli.Context, signAndPush bool) error {
|
||||||
return invokeWithArgs(ctx, acc, w, script, operation, params, cosigners)
|
return invokeWithArgs(ctx, acc, w, script, operation, params, cosigners)
|
||||||
}
|
}
|
||||||
|
|
||||||
func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, script util.Uint160, operation string, params []interface{}, cosigners []transaction.Signer) error {
|
func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, script util.Uint160, operation string, params []any, cosigners []transaction.Signer) error {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
signersAccounts []actor.SignerAccount
|
signersAccounts []actor.SignerAccount
|
||||||
|
@ -787,7 +787,7 @@ func contractDeploy(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var appCallParams = []interface{}{f, manifestBytes}
|
var appCallParams = []any{f, manifestBytes}
|
||||||
|
|
||||||
signOffset, data, err := cmdargs.ParseParams(ctx.Args(), true)
|
signOffset, data, err := cmdargs.ParseParams(ctx.Args(), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -51,7 +51,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RuntimeNotify sends runtime notification with "Hello world!" name
|
// RuntimeNotify sends runtime notification with "Hello world!" name
|
||||||
func RuntimeNotify(args []interface{}) {
|
func RuntimeNotify(args []any) {
|
||||||
runtime.Notify(notificationName, args)
|
runtime.Notify(notificationName, args)
|
||||||
}`, string(main))
|
}`, string(main))
|
||||||
|
|
||||||
|
|
8
cli/smartcontract/testdata/deploy/main.go
vendored
8
cli/smartcontract/testdata/deploy/main.go
vendored
|
@ -13,7 +13,7 @@ var key = "key"
|
||||||
|
|
||||||
const mgmtKey = "mgmt"
|
const mgmtKey = "mgmt"
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
var value string
|
var value string
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
@ -25,7 +25,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
storage.Put(ctx, mgmtKey, sh)
|
storage.Put(ctx, mgmtKey, sh)
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
arr := data.([]interface{})
|
arr := data.([]any)
|
||||||
for i := 0; i < len(arr)-1; i += 2 {
|
for i := 0; i < len(arr)-1; i += 2 {
|
||||||
storage.Put(ctx, arr[i], arr[i+1])
|
storage.Put(ctx, arr[i], arr[i+1])
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,12 @@ func GetValueWithKey(key string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFind finds items with the specified prefix.
|
// TestFind finds items with the specified prefix.
|
||||||
func TestFind(f storage.FindFlags) []interface{} {
|
func TestFind(f storage.FindFlags) []any {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
storage.Put(ctx, "findkey1", "value1")
|
storage.Put(ctx, "findkey1", "value1")
|
||||||
storage.Put(ctx, "findkey2", "value2")
|
storage.Put(ctx, "findkey2", "value2")
|
||||||
|
|
||||||
var result []interface{}
|
var result []any
|
||||||
iter := storage.Find(ctx, "findkey", f)
|
iter := storage.Find(ctx, "findkey", f)
|
||||||
for iterator.Next(iter) {
|
for iterator.Next(iter) {
|
||||||
result = append(result, iterator.Value(iter))
|
result = append(result, iterator.Value(iter))
|
||||||
|
|
2
cli/smartcontract/testdata/deploy/sub/put.go
vendored
2
cli/smartcontract/testdata/deploy/sub/put.go
vendored
|
@ -4,7 +4,7 @@ import "github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
|
|
||||||
var Key = "sub"
|
var Key = "sub"
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
value := "sub create"
|
value := "sub create"
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
|
|
12
cli/smartcontract/testdata/nameservice/nns.go
vendored
12
cli/smartcontract/testdata/nameservice/nns.go
vendored
|
@ -27,11 +27,11 @@ type Actor interface {
|
||||||
|
|
||||||
nep11.Actor
|
nep11.Actor
|
||||||
|
|
||||||
MakeCall(contract util.Uint160, method string, params ...interface{}) (*transaction.Transaction, error)
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
MakeRun(script []byte) (*transaction.Transaction, error)
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...interface{}) (*transaction.Transaction, error)
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
SendCall(contract util.Uint160, method string, params ...interface{}) (util.Uint256, uint32, error)
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
SendRun(script []byte) (util.Uint256, uint32, error)
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,14 +155,14 @@ func (c *Contract) AddRootUnsigned(root string) (*transaction.Transaction, error
|
||||||
// SetPrice creates a transaction invoking `setPrice` method of the contract.
|
// SetPrice creates a transaction invoking `setPrice` method of the contract.
|
||||||
// This transaction is signed and immediately sent to the network.
|
// This transaction is signed and immediately sent to the network.
|
||||||
// The values returned are its hash, ValidUntilBlock value and error if any.
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
func (c *Contract) SetPrice(priceList []interface{}) (util.Uint256, uint32, error) {
|
func (c *Contract) SetPrice(priceList []any) (util.Uint256, uint32, error) {
|
||||||
return c.actor.SendCall(Hash, "setPrice", priceList)
|
return c.actor.SendCall(Hash, "setPrice", priceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPriceTransaction creates a transaction invoking `setPrice` method of the contract.
|
// SetPriceTransaction creates a transaction invoking `setPrice` method of the contract.
|
||||||
// This transaction is signed, but not sent to the network, instead it's
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
// returned to the caller.
|
// returned to the caller.
|
||||||
func (c *Contract) SetPriceTransaction(priceList []interface{}) (*transaction.Transaction, error) {
|
func (c *Contract) SetPriceTransaction(priceList []any) (*transaction.Transaction, error) {
|
||||||
return c.actor.MakeCall(Hash, "setPrice", priceList)
|
return c.actor.MakeCall(Hash, "setPrice", priceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ func (c *Contract) SetPriceTransaction(priceList []interface{}) (*transaction.Tr
|
||||||
// This transaction is not signed, it's simply returned to the caller.
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
func (c *Contract) SetPriceUnsigned(priceList []interface{}) (*transaction.Transaction, error) {
|
func (c *Contract) SetPriceUnsigned(priceList []any) (*transaction.Transaction, error) {
|
||||||
return c.actor.MakeUnsignedCall(Hash, "setPrice", nil, priceList)
|
return c.actor.MakeUnsignedCall(Hash, "setPrice", nil, priceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
cli/smartcontract/testdata/nex/nex.go
vendored
12
cli/smartcontract/testdata/nex/nex.go
vendored
|
@ -24,11 +24,11 @@ type Actor interface {
|
||||||
|
|
||||||
nep17.Actor
|
nep17.Actor
|
||||||
|
|
||||||
MakeCall(contract util.Uint160, method string, params ...interface{}) (*transaction.Transaction, error)
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
MakeRun(script []byte) (*transaction.Transaction, error)
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...interface{}) (*transaction.Transaction, error)
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
SendCall(contract util.Uint160, method string, params ...interface{}) (util.Uint256, uint32, error)
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
SendRun(script []byte) (util.Uint256, uint32, error)
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,14 +168,14 @@ func (c *Contract) MaxSupplyUnsigned() (*transaction.Transaction, error) {
|
||||||
// Mint creates a transaction invoking `mint` method of the contract.
|
// Mint creates a transaction invoking `mint` method of the contract.
|
||||||
// This transaction is signed and immediately sent to the network.
|
// This transaction is signed and immediately sent to the network.
|
||||||
// The values returned are its hash, ValidUntilBlock value and error if any.
|
// The values returned are its hash, ValidUntilBlock value and error if any.
|
||||||
func (c *Contract) Mint(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data interface{}) (util.Uint256, uint32, error) {
|
func (c *Contract) Mint(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data any) (util.Uint256, uint32, error) {
|
||||||
return c.actor.SendCall(Hash, "mint", from, to, amount, swapId, signature, data)
|
return c.actor.SendCall(Hash, "mint", from, to, amount, swapId, signature, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MintTransaction creates a transaction invoking `mint` method of the contract.
|
// MintTransaction creates a transaction invoking `mint` method of the contract.
|
||||||
// This transaction is signed, but not sent to the network, instead it's
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
// returned to the caller.
|
// returned to the caller.
|
||||||
func (c *Contract) MintTransaction(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data interface{}) (*transaction.Transaction, error) {
|
func (c *Contract) MintTransaction(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data any) (*transaction.Transaction, error) {
|
||||||
return c.actor.MakeCall(Hash, "mint", from, to, amount, swapId, signature, data)
|
return c.actor.MakeCall(Hash, "mint", from, to, amount, swapId, signature, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ func (c *Contract) MintTransaction(from util.Uint160, to util.Uint160, amount *b
|
||||||
// This transaction is not signed, it's simply returned to the caller.
|
// This transaction is not signed, it's simply returned to the caller.
|
||||||
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
||||||
func (c *Contract) MintUnsigned(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data interface{}) (*transaction.Transaction, error) {
|
func (c *Contract) MintUnsigned(from util.Uint160, to util.Uint160, amount *big.Int, swapId *big.Int, signature []byte, data any) (*transaction.Transaction, error) {
|
||||||
return c.actor.MakeUnsignedCall(Hash, "mint", nil, from, to, amount, swapId, signature, data)
|
return c.actor.MakeUnsignedCall(Hash, "mint", nil, from, to, amount, swapId, signature, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
cli/smartcontract/testdata/nonepiter/iter.go
vendored
4
cli/smartcontract/testdata/nonepiter/iter.go
vendored
|
@ -14,8 +14,8 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa
|
||||||
|
|
||||||
// Invoker is used by ContractReader to call various safe methods.
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
type Invoker interface {
|
type Invoker interface {
|
||||||
Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...interface{}) (*result.Invoke, error)
|
CallAndExpandIterator(contract util.Uint160, method string, maxItems int, params ...any) (*result.Invoke, error)
|
||||||
TerminateSession(sessionID uuid.UUID) error
|
TerminateSession(sessionID uuid.UUID) error
|
||||||
TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
|
TraverseIterator(sessionID uuid.UUID, iterator *result.Iterator, num int) ([]stackitem.Item, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ type LedgerTransactionSigner struct {
|
||||||
// LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods.
|
// LedgerWitnessCondition is a contract-specific ledger.WitnessCondition type used by its methods.
|
||||||
type LedgerWitnessCondition struct {
|
type LedgerWitnessCondition struct {
|
||||||
Type *big.Int
|
Type *big.Int
|
||||||
Value interface{}
|
Value any
|
||||||
}
|
}
|
||||||
|
|
||||||
// LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods.
|
// LedgerWitnessRule is a contract-specific ledger.WitnessRule type used by its methods.
|
||||||
|
@ -114,7 +114,7 @@ type ManagementManifest struct {
|
||||||
ABI *ManagementABI
|
ABI *ManagementABI
|
||||||
Permissions []*ManagementPermission
|
Permissions []*ManagementPermission
|
||||||
Trusts []util.Uint160
|
Trusts []util.Uint160
|
||||||
Extra interface{}
|
Extra any
|
||||||
}
|
}
|
||||||
|
|
||||||
// ManagementMethod is a contract-specific management.Method type used by its methods.
|
// ManagementMethod is a contract-specific management.Method type used by its methods.
|
||||||
|
@ -156,7 +156,7 @@ type StructsInternal struct {
|
||||||
}
|
}
|
||||||
// Invoker is used by ContractReader to call various safe methods.
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
type Invoker interface {
|
type Invoker interface {
|
||||||
Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractReader implements safe contract methods.
|
// ContractReader implements safe contract methods.
|
||||||
|
|
|
@ -18,7 +18,7 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa
|
||||||
|
|
||||||
// Invoker is used by ContractReader to call various safe methods.
|
// Invoker is used by ContractReader to call various safe methods.
|
||||||
type Invoker interface {
|
type Invoker interface {
|
||||||
Call(contract util.Uint160, operation string, params ...interface{}) (*result.Invoke, error)
|
Call(contract util.Uint160, operation string, params ...any) (*result.Invoke, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractReader implements safe contract methods.
|
// ContractReader implements safe contract methods.
|
||||||
|
@ -91,8 +91,8 @@ func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any invokes `any` method of contract.
|
// Any invokes `any` method of contract.
|
||||||
func (c *ContractReader) Any(a interface{}) (interface{}, error) {
|
func (c *ContractReader) Any(a any) (any, error) {
|
||||||
return func (item stackitem.Item, err error) (interface{}, error) {
|
return func (item stackitem.Item, err error) (any, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
2
cli/smartcontract/testdata/types/types.go
vendored
2
cli/smartcontract/testdata/types/types.go
vendored
|
@ -20,7 +20,7 @@ func String(s string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func Any(a interface{}) interface{} {
|
func Any(a any) any {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
cli/smartcontract/testdata/verify.go
vendored
4
cli/smartcontract/testdata/verify.go
vendored
|
@ -9,12 +9,12 @@ func Verify() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnNEP11Payment notifies about NEP-11 payment. You don't call this method directly,
|
// OnNEP11Payment notifies about NEP-11 payment. You don't call this method directly,
|
||||||
// instead it's called by NEP-11 contract when you transfer funds from your address
|
// instead it's called by NEP-11 contract when you transfer funds from your address
|
||||||
// to the address of this NFT contract.
|
// to the address of this NFT contract.
|
||||||
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data interface{}) {
|
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data any) {
|
||||||
runtime.Notify("OnNEP11Payment", from, amount, token, data)
|
runtime.Notify("OnNEP11Payment", from, amount, token, data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xa
|
||||||
|
|
||||||
// Actor is used by Contract to call state-changing methods.
|
// Actor is used by Contract to call state-changing methods.
|
||||||
type Actor interface {
|
type Actor interface {
|
||||||
MakeCall(contract util.Uint160, method string, params ...interface{}) (*transaction.Transaction, error)
|
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error)
|
||||||
MakeRun(script []byte) (*transaction.Transaction, error)
|
MakeRun(script []byte) (*transaction.Transaction, error)
|
||||||
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...interface{}) (*transaction.Transaction, error)
|
MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error)
|
||||||
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error)
|
||||||
SendCall(contract util.Uint160, method string, params ...interface{}) (util.Uint256, uint32, error)
|
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error)
|
||||||
SendRun(script []byte) (util.Uint256, uint32, error)
|
SendRun(script []byte) (util.Uint256, uint32, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ func NewWithConfig(printLogotype bool, onExit func(int), c *readline.Config, cfg
|
||||||
shell: ctl,
|
shell: ctl,
|
||||||
}
|
}
|
||||||
|
|
||||||
vmcli.shell.Metadata = map[string]interface{}{
|
vmcli.shell.Metadata = map[string]any{
|
||||||
chainKey: chain,
|
chainKey: chain,
|
||||||
chainCfgKey: cfg,
|
chainCfgKey: cfg,
|
||||||
icKey: ic,
|
icKey: ic,
|
||||||
|
|
|
@ -180,9 +180,9 @@ func (e *executor) checkError(t *testing.T, expectedErr error) {
|
||||||
require.True(t, strings.HasPrefix(line, expected), fmt.Errorf("expected `%s`, got `%s`", expected, line))
|
require.True(t, strings.HasPrefix(line, expected), fmt.Errorf("expected `%s`, got `%s`", expected, line))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *executor) checkStack(t *testing.T, items ...interface{}) {
|
func (e *executor) checkStack(t *testing.T, items ...any) {
|
||||||
d := json.NewDecoder(e.out)
|
d := json.NewDecoder(e.out)
|
||||||
var actual interface{}
|
var actual any
|
||||||
require.NoError(t, d.Decode(&actual))
|
require.NoError(t, d.Decode(&actual))
|
||||||
rawActual, err := json.Marshal(actual)
|
rawActual, err := json.Marshal(actual)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -210,7 +210,7 @@ func (e *executor) checkEvents(t *testing.T, isKeywordExpected bool, events ...s
|
||||||
e.checkNextLine(t, "Events:")
|
e.checkNextLine(t, "Events:")
|
||||||
}
|
}
|
||||||
d := json.NewDecoder(e.out)
|
d := json.NewDecoder(e.out)
|
||||||
var actual interface{}
|
var actual any
|
||||||
require.NoError(t, d.Decode(&actual))
|
require.NoError(t, d.Decode(&actual))
|
||||||
rawActual, err := json.Marshal(actual)
|
rawActual, err := json.Marshal(actual)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -249,9 +249,9 @@ func (e *executor) checkChange(t *testing.T, c storageChange) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *executor) checkSlot(t *testing.T, items ...interface{}) {
|
func (e *executor) checkSlot(t *testing.T, items ...any) {
|
||||||
d := json.NewDecoder(e.out)
|
d := json.NewDecoder(e.out)
|
||||||
var actual interface{}
|
var actual any
|
||||||
require.NoError(t, d.Decode(&actual))
|
require.NoError(t, d.Decode(&actual))
|
||||||
rawActual, err := json.Marshal(actual)
|
rawActual, err := json.Marshal(actual)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -532,7 +532,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
|
||||||
func GetString(arg string) string {
|
func GetString(arg string) string {
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
func GetArr(arg []interface{}) []interface{}{
|
func GetArr(arg []any) []any{
|
||||||
return arg
|
return arg
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
@ -933,7 +933,7 @@ func TestEvents(t *testing.T) {
|
||||||
script := io.NewBufBinWriter()
|
script := io.NewBufBinWriter()
|
||||||
h, err := e.cli.chain.GetContractScriptHash(2) // examples/runtime/runtime.go
|
h, err := e.cli.chain.GetContractScriptHash(2) // examples/runtime/runtime.go
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
emit.AppCall(script.BinWriter, h, "notify", callflag.All, []interface{}{true, 5})
|
emit.AppCall(script.BinWriter, h, "notify", callflag.All, []any{true, 5})
|
||||||
e.runProg(t,
|
e.runProg(t,
|
||||||
"loadhex "+hex.EncodeToString(script.Bytes()),
|
"loadhex "+hex.EncodeToString(script.Bytes()),
|
||||||
"run",
|
"run",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// _deploy primes contract's storage with some data to be used later.
|
// _deploy primes contract's storage with some data to be used later.
|
||||||
func _deploy(_ interface{}, _ bool) {
|
func _deploy(_ any, _ bool) {
|
||||||
ctx := storage.GetContext() // RW context.
|
ctx := storage.GetContext() // RW context.
|
||||||
storage.Put(ctx, "foo1", "1")
|
storage.Put(ctx, "foo1", "1")
|
||||||
storage.Put(ctx, "foo2", "2")
|
storage.Put(ctx, "foo2", "2")
|
||||||
|
|
|
@ -172,7 +172,7 @@ func tokensOf(ctx storage.Context, holder interop.Hash160) iterator.Iterator {
|
||||||
|
|
||||||
// Transfer token from its owner to another user, if there's one owner of the token.
|
// Transfer token from its owner to another user, if there's one owner of the token.
|
||||||
// It will return false if token is shared between multiple owners.
|
// It will return false if token is shared between multiple owners.
|
||||||
func Transfer(to interop.Hash160, token []byte, data interface{}) bool {
|
func Transfer(to interop.Hash160, token []byte, data any) bool {
|
||||||
if len(to) != interop.Hash160Len {
|
if len(to) != interop.Hash160Len {
|
||||||
panic("invalid 'to' address")
|
panic("invalid 'to' address")
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ func Transfer(to interop.Hash160, token []byte, data interface{}) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// postTransfer emits Transfer event and calls onNEP11Payment if needed.
|
// postTransfer emits Transfer event and calls onNEP11Payment if needed.
|
||||||
func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, amount int, data interface{}) {
|
func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, amount int, data any) {
|
||||||
runtime.Notify("Transfer", from, to, amount, token)
|
runtime.Notify("Transfer", from, to, amount, token)
|
||||||
if management.GetContract(to) != nil {
|
if management.GetContract(to) != nil {
|
||||||
contract.Call(to, "onNEP11Payment", contract.All, from, amount, token, data)
|
contract.Call(to, "onNEP11Payment", contract.All, from, amount, token, data)
|
||||||
|
@ -263,7 +263,7 @@ func isTokenValid(ctx storage.Context, tokenID []byte) bool {
|
||||||
|
|
||||||
// TransferDivisible token from its owner to another user, notice that it only has three
|
// TransferDivisible token from its owner to another user, notice that it only has three
|
||||||
// parameters because token owner can be deduced from token ID itself.
|
// parameters because token owner can be deduced from token ID itself.
|
||||||
func TransferDivisible(from, to interop.Hash160, amount int, token []byte, data interface{}) bool {
|
func TransferDivisible(from, to interop.Hash160, amount int, token []byte, data any) bool {
|
||||||
if len(from) != interop.Hash160Len {
|
if len(from) != interop.Hash160Len {
|
||||||
panic("invalid 'from' address")
|
panic("invalid 'from' address")
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ func removeOwner(ctx storage.Context, token []byte, holder interop.Hash160) {
|
||||||
// OnNEP17Payment mints tokens if at least 10 GAS is provided. You don't call
|
// OnNEP17Payment mints tokens if at least 10 GAS is provided. You don't call
|
||||||
// this method directly, instead it's called by GAS contract when you transfer
|
// this method directly, instead it's called by GAS contract when you transfer
|
||||||
// GAS from your address to the address of this NFT contract.
|
// GAS from your address to the address of this NFT contract.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
runtime.Log(r.(string))
|
runtime.Log(r.(string))
|
||||||
|
@ -364,7 +364,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
||||||
if amount < 10_00000000 {
|
if amount < 10_00000000 {
|
||||||
panic("minting NFSO costs at least 10 GAS")
|
panic("minting NFSO costs at least 10 GAS")
|
||||||
}
|
}
|
||||||
tokenInfo := data.([]interface{})
|
tokenInfo := data.([]any)
|
||||||
if len(tokenInfo) != 2 {
|
if len(tokenInfo) != 2 {
|
||||||
panic("invalid 'data'")
|
panic("invalid 'data'")
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func Update(nef []byte, manifest string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
// _deploy initializes defaults (total supply and registration price) on contract deploy.
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ func OwnerOf(tokenID []byte) interop.Hash160 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties returns domain name and expiration date of the specified domain.
|
// Properties returns domain name and expiration date of the specified domain.
|
||||||
func Properties(tokenID []byte) map[string]interface{} {
|
func Properties(tokenID []byte) map[string]any {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
ns := getNameState(ctx, tokenID)
|
ns := getNameState(ctx, tokenID)
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"name": ns.Name,
|
"name": ns.Name,
|
||||||
"expiration": ns.Expiration,
|
"expiration": ns.Expiration,
|
||||||
"admin": ns.Admin,
|
"admin": ns.Admin,
|
||||||
|
@ -151,7 +151,7 @@ func TokensOf(owner interop.Hash160) iterator.Iterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer transfers domain with the specified name to new owner.
|
// Transfer transfers domain with the specified name to new owner.
|
||||||
func Transfer(to interop.Hash160, tokenID []byte, data interface{}) bool {
|
func Transfer(to interop.Hash160, tokenID []byte, data any) bool {
|
||||||
if !isValid(to) {
|
if !isValid(to) {
|
||||||
panic(`invalid receiver`)
|
panic(`invalid receiver`)
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ func updateBalance(ctx storage.Context, tokenId []byte, acc interop.Hash160, dif
|
||||||
|
|
||||||
// postTransfer sends Transfer notification to the network and calls onNEP11Payment
|
// postTransfer sends Transfer notification to the network and calls onNEP11Payment
|
||||||
// method.
|
// method.
|
||||||
func postTransfer(from, to interop.Hash160, tokenID []byte, data interface{}) {
|
func postTransfer(from, to interop.Hash160, tokenID []byte, data any) {
|
||||||
runtime.Notify("Transfer", from, to, 1, tokenID)
|
runtime.Notify("Transfer", from, to, 1, tokenID)
|
||||||
if management.GetContract(to) != nil {
|
if management.GetContract(to) != nil {
|
||||||
contract.Call(to, "onNEP11Payment", contract.All, from, 1, tokenID, data)
|
contract.Call(to, "onNEP11Payment", contract.All, from, 1, tokenID, data)
|
||||||
|
|
|
@ -190,8 +190,8 @@ func TestRegisterAndRenew(t *testing.T) {
|
||||||
t.Run("invalid token ID", func(t *testing.T) {
|
t.Run("invalid token ID", func(t *testing.T) {
|
||||||
c.InvokeFail(t, "token not found", "properties", "not.exists")
|
c.InvokeFail(t, "token not found", "properties", "not.exists")
|
||||||
c.InvokeFail(t, "token not found", "ownerOf", "not.exists")
|
c.InvokeFail(t, "token not found", "ownerOf", "not.exists")
|
||||||
c.InvokeFail(t, "invalid conversion", "properties", []interface{}{})
|
c.InvokeFail(t, "invalid conversion", "properties", []any{})
|
||||||
c.InvokeFail(t, "invalid conversion", "ownerOf", []interface{}{})
|
c.InvokeFail(t, "invalid conversion", "ownerOf", []any{})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Renew
|
// Renew
|
||||||
|
@ -294,7 +294,7 @@ func TestSetGetRecord(t *testing.T) {
|
||||||
{Type: nns.AAAA, Name: "2001::13.1.68.3", ShouldFail: true},
|
{Type: nns.AAAA, Name: "2001::13.1.68.3", ShouldFail: true},
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
args := []interface{}{"neo.com", int64(testCase.Type), testCase.Name}
|
args := []any{"neo.com", int64(testCase.Type), testCase.Name}
|
||||||
t.Run(testCase.Name, func(t *testing.T) {
|
t.Run(testCase.Name, func(t *testing.T) {
|
||||||
if testCase.ShouldFail {
|
if testCase.ShouldFail {
|
||||||
c.InvokeFail(t, "", "setRecord", args...)
|
c.InvokeFail(t, "", "setRecord", args...)
|
||||||
|
@ -377,7 +377,7 @@ func TestTransfer(t *testing.T) {
|
||||||
ctr = neotest.CompileSource(t, e.CommitteeHash,
|
ctr = neotest.CompileSource(t, e.CommitteeHash,
|
||||||
strings.NewReader(`package foo
|
strings.NewReader(`package foo
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data interface{}) {}`),
|
func OnNEP11Payment(from interop.Hash160, amount int, token []byte, data any) {}`),
|
||||||
&compiler.Options{Name: "foo"})
|
&compiler.Options{Name: "foo"})
|
||||||
e.DeployContract(t, ctr, nil)
|
e.DeployContract(t, ctr, nil)
|
||||||
cTo.Invoke(t, true, "transfer", ctr.Hash, []byte("neo.com"), nil)
|
cTo.Invoke(t, true, "transfer", ctr.Hash, []byte("neo.com"), nil)
|
||||||
|
@ -404,7 +404,7 @@ func TestTokensOf(t *testing.T) {
|
||||||
testTokensOf(t, c, [][]byte{}, util.Uint160{}.BytesBE()) // empty hash is a valid hash still
|
testTokensOf(t, c, [][]byte{}, util.Uint160{}.BytesBE()) // empty hash is a valid hash still
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTokensOf(t *testing.T, c *neotest.ContractInvoker, result [][]byte, args ...interface{}) {
|
func testTokensOf(t *testing.T, c *neotest.ContractInvoker, result [][]byte, args ...any) {
|
||||||
method := "tokensOf"
|
method := "tokensOf"
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
method = "tokens"
|
method = "tokens"
|
||||||
|
|
|
@ -173,7 +173,7 @@ func OwnerOf(token []byte) interop.Hash160 {
|
||||||
|
|
||||||
// Transfer token from its owner to another user, notice that it only has three
|
// Transfer token from its owner to another user, notice that it only has three
|
||||||
// parameters because token owner can be deduced from token ID itself.
|
// parameters because token owner can be deduced from token ID itself.
|
||||||
func Transfer(to interop.Hash160, token []byte, data interface{}) bool {
|
func Transfer(to interop.Hash160, token []byte, data any) bool {
|
||||||
if len(to) != 20 {
|
if len(to) != 20 {
|
||||||
panic("invalid 'to' address")
|
panic("invalid 'to' address")
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ func Transfer(to interop.Hash160, token []byte, data interface{}) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// postTransfer emits Transfer event and calls onNEP11Payment if needed.
|
// postTransfer emits Transfer event and calls onNEP11Payment if needed.
|
||||||
func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, data interface{}) {
|
func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, data any) {
|
||||||
runtime.Notify("Transfer", from, to, 1, token)
|
runtime.Notify("Transfer", from, to, 1, token)
|
||||||
if management.GetContract(to) != nil {
|
if management.GetContract(to) != nil {
|
||||||
contract.Call(to, "onNEP11Payment", contract.All, from, 1, token, data)
|
contract.Call(to, "onNEP11Payment", contract.All, from, 1, token, data)
|
||||||
|
@ -209,7 +209,7 @@ func postTransfer(from interop.Hash160, to interop.Hash160, token []byte, data i
|
||||||
// OnNEP17Payment mints tokens if at least 10 GAS is provided. You don't call
|
// OnNEP17Payment mints tokens if at least 10 GAS is provided. You don't call
|
||||||
// this method directly, instead it's called by GAS contract when you transfer
|
// this method directly, instead it's called by GAS contract when you transfer
|
||||||
// GAS from your address to the address of this NFT contract.
|
// GAS from your address to the address of this NFT contract.
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
runtime.Log(r.(string))
|
runtime.Log(r.(string))
|
||||||
|
|
|
@ -23,7 +23,7 @@ func FilteredRequest(url string, filter []byte) {
|
||||||
// OracleCallback is called by Oracle native contract when request is finished.
|
// OracleCallback is called by Oracle native contract when request is finished.
|
||||||
// It either throws an error (if the result is not successful) or logs the data
|
// It either throws an error (if the result is not successful) or logs the data
|
||||||
// got as a result.
|
// got as a result.
|
||||||
func OracleCallback(url string, data interface{}, code int, res []byte) {
|
func OracleCallback(url string, data any, code int, res []byte) {
|
||||||
// This function shouldn't be called directly, we only expect oracle native
|
// This function shouldn't be called directly, we only expect oracle native
|
||||||
// contract to be calling it.
|
// contract to be calling it.
|
||||||
callingHash := runtime.GetCallingScriptHash()
|
callingHash := runtime.GetCallingScriptHash()
|
||||||
|
|
|
@ -22,7 +22,7 @@ func init() {
|
||||||
|
|
||||||
// _deploy is called after contract deployment or update, it'll be called
|
// _deploy is called after contract deployment or update, it'll be called
|
||||||
// in deployment transaction and if call update method of this contract.
|
// in deployment transaction and if call update method of this contract.
|
||||||
func _deploy(_ interface{}, isUpdate bool) {
|
func _deploy(_ any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
Log("_deploy method called after contract update")
|
Log("_deploy method called after contract update")
|
||||||
return
|
return
|
||||||
|
@ -46,7 +46,7 @@ func Log(message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify emits an event with the specified data.
|
// Notify emits an event with the specified data.
|
||||||
func Notify(event interface{}) {
|
func Notify(event any) {
|
||||||
runtime.Notify("Event", event)
|
runtime.Notify("Event", event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,12 @@ func PutDefault(value []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the value at the passed key.
|
// Get returns the value at the passed key.
|
||||||
func Get(key []byte) interface{} {
|
func Get(key []byte) any {
|
||||||
return storage.Get(ctx, key)
|
return storage.Get(ctx, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefault returns the value at the default key.
|
// GetDefault returns the value at the default key.
|
||||||
func GetDefault() interface{} {
|
func GetDefault() any {
|
||||||
return storage.Get(ctx, defaultKey)
|
return storage.Get(ctx, defaultKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
||||||
ctx = storage.GetContext()
|
ctx = storage.GetContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
func _deploy(_ interface{}, isUpdate bool) {
|
func _deploy(_ any, isUpdate bool) {
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
ticksLeft := storage.Get(ctx, ticksKey).(int) + 1
|
ticksLeft := storage.Get(ctx, ticksKey).(int) + 1
|
||||||
storage.Put(ctx, ticksKey, ticksLeft)
|
storage.Put(ctx, ticksKey, ticksLeft)
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (t Token) BalanceOf(ctx storage.Context, holder []byte) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer token from one user to another
|
// Transfer token from one user to another
|
||||||
func (t Token) Transfer(ctx storage.Context, from, to interop.Hash160, amount int, data interface{}) bool {
|
func (t Token) Transfer(ctx storage.Context, from, to interop.Hash160, amount int, data any) bool {
|
||||||
amountFrom := t.CanTransfer(ctx, from, to, amount)
|
amountFrom := t.CanTransfer(ctx, from, to, amount)
|
||||||
if amountFrom == -1 {
|
if amountFrom == -1 {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -53,7 +53,7 @@ func BalanceOf(holder interop.Hash160) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer token from one user to another
|
// Transfer token from one user to another
|
||||||
func Transfer(from interop.Hash160, to interop.Hash160, amount int, data interface{}) bool {
|
func Transfer(from interop.Hash160, to interop.Hash160, amount int, data any) bool {
|
||||||
return token.Transfer(ctx, from, to, amount, data)
|
return token.Transfer(ctx, from, to, amount, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ func Init(t *testing.T, rootpath string, e *neotest.Executor) {
|
||||||
_, _, _ = deployContractFromPriv0(t, verifyPath, "Verify", verifyCfg, VerifyContractID)
|
_, _, _ = deployContractFromPriv0(t, verifyPath, "Verify", verifyCfg, VerifyContractID)
|
||||||
|
|
||||||
// Block #8: deposit some GAS to notary contract for priv0.
|
// Block #8: deposit some GAS to notary contract for priv0.
|
||||||
transferTxH = gasPriv0Invoker.Invoke(t, true, "transfer", priv0ScriptHash, notaryHash, 10_0000_0000, []interface{}{priv0ScriptHash, int64(e.Chain.BlockHeight() + 1000)})
|
transferTxH = gasPriv0Invoker.Invoke(t, true, "transfer", priv0ScriptHash, notaryHash, 10_0000_0000, []any{priv0ScriptHash, int64(e.Chain.BlockHeight() + 1000)})
|
||||||
t.Logf("notaryDepositTxPriv0: %v", transferTxH.StringLE())
|
t.Logf("notaryDepositTxPriv0: %v", transferTxH.StringLE())
|
||||||
|
|
||||||
// Block #9: designate new Notary node.
|
// Block #9: designate new Notary node.
|
||||||
|
@ -195,7 +195,7 @@ func Init(t *testing.T, rootpath string, e *neotest.Executor) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ntr.Accounts[0].Decrypt("one", ntr.Scrypt))
|
require.NoError(t, ntr.Accounts[0].Decrypt("one", ntr.Scrypt))
|
||||||
designateSuperInvoker.Invoke(t, stackitem.Null{}, "designateAsRole",
|
designateSuperInvoker.Invoke(t, stackitem.Null{}, "designateAsRole",
|
||||||
int64(noderoles.P2PNotary), []interface{}{ntr.Accounts[0].PublicKey().Bytes()})
|
int64(noderoles.P2PNotary), []any{ntr.Accounts[0].PublicKey().Bytes()})
|
||||||
t.Logf("Designated Notary node: %s", hex.EncodeToString(ntr.Accounts[0].PublicKey().Bytes()))
|
t.Logf("Designated Notary node: %s", hex.EncodeToString(ntr.Accounts[0].PublicKey().Bytes()))
|
||||||
|
|
||||||
// Block #10: push verification contract with arguments into the chain.
|
// Block #10: push verification contract with arguments into the chain.
|
||||||
|
@ -252,7 +252,7 @@ func Init(t *testing.T, rootpath string, e *neotest.Executor) {
|
||||||
containerID := util.Uint256{1, 2, 3}
|
containerID := util.Uint256{1, 2, 3}
|
||||||
objectID := util.Uint256{4, 5, 6}
|
objectID := util.Uint256{4, 5, 6}
|
||||||
txGas0toNFSH := gasPriv0Invoker.Invoke(t, true, "transfer",
|
txGas0toNFSH := gasPriv0Invoker.Invoke(t, true, "transfer",
|
||||||
priv0ScriptHash, nfsHash, 10_0000_0000, []interface{}{containerID.BytesBE(), objectID.BytesBE()}) // block #18
|
priv0ScriptHash, nfsHash, 10_0000_0000, []any{containerID.BytesBE(), objectID.BytesBE()}) // block #18
|
||||||
res = e.GetTxExecResult(t, txGas0toNFSH)
|
res = e.GetTxExecResult(t, txGas0toNFSH)
|
||||||
require.Equal(t, 2, len(res.Events)) // GAS transfer + NFSO transfer
|
require.Equal(t, 2, len(res.Events)) // GAS transfer + NFSO transfer
|
||||||
tokenID, err = res.Events[1].Item.Value().([]stackitem.Item)[3].TryBytes()
|
tokenID, err = res.Events[1].Item.Value().([]stackitem.Item)[3].TryBytes()
|
||||||
|
|
|
@ -16,7 +16,7 @@ const valuesCount = 255
|
||||||
// valuesPrefix is the prefix values are stored by.
|
// valuesPrefix is the prefix values are stored by.
|
||||||
var valuesPrefix = []byte{0x01}
|
var valuesPrefix = []byte{0x01}
|
||||||
|
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data any, isUpdate bool) {
|
||||||
if !isUpdate {
|
if !isUpdate {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
for i := 0; i < valuesCount; i++ {
|
for i := 0; i < valuesCount; i++ {
|
||||||
|
|
|
@ -27,7 +27,7 @@ func Init() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {
|
||||||
curr := runtime.GetExecutingScriptHash()
|
curr := runtime.GetExecutingScriptHash()
|
||||||
balance := neo.BalanceOf(curr)
|
balance := neo.BalanceOf(curr)
|
||||||
if ledger.CurrentIndex() >= 100 {
|
if ledger.CurrentIndex() >= 100 {
|
||||||
|
@ -47,7 +47,7 @@ func Verify() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
func Transfer(from, to interop.Hash160, amount int, data any) bool {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
if len(from) != 20 {
|
if len(from) != 20 {
|
||||||
runtime.Log("invalid 'from' address")
|
runtime.Log("invalid 'from' address")
|
||||||
|
|
|
@ -12,22 +12,22 @@ import (
|
||||||
|
|
||||||
// RequestURL accepts a complete set of parameters to make an oracle request and
|
// RequestURL accepts a complete set of parameters to make an oracle request and
|
||||||
// performs it.
|
// performs it.
|
||||||
func RequestURL(url string, filter []byte, callback string, userData interface{}, gasForResponse int) {
|
func RequestURL(url string, filter []byte, callback string, userData any, gasForResponse int) {
|
||||||
oracle.Request(url, filter, callback, userData, gasForResponse)
|
oracle.Request(url, filter, callback, userData, gasForResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle is a response handler that writes response data to the storage.
|
// Handle is a response handler that writes response data to the storage.
|
||||||
func Handle(url string, data interface{}, code int, res []byte) {
|
func Handle(url string, data any, code int, res []byte) {
|
||||||
// ABORT if len(data) == 2, some tests use this feature.
|
// ABORT if len(data) == 2, some tests use this feature.
|
||||||
if data != nil && len(data.(string)) == 2 {
|
if data != nil && len(data.(string)) == 2 {
|
||||||
util.Abort()
|
util.Abort()
|
||||||
}
|
}
|
||||||
params := []interface{}{url, data, code, res}
|
params := []any{url, data, code, res}
|
||||||
storage.Put(storage.GetContext(), "lastOracleResponse", std.Serialize(params))
|
storage.Put(storage.GetContext(), "lastOracleResponse", std.Serialize(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleRecursive invokes oracle.finish again to test Oracle reentrance.
|
// HandleRecursive invokes oracle.finish again to test Oracle reentrance.
|
||||||
func HandleRecursive(url string, data interface{}, code int, res []byte) {
|
func HandleRecursive(url string, data any, code int, res []byte) {
|
||||||
// Regular safety check.
|
// Regular safety check.
|
||||||
callingHash := runtime.GetCallingScriptHash()
|
callingHash := runtime.GetCallingScriptHash()
|
||||||
if !callingHash.Equals(oracle.Hash) {
|
if !callingHash.Equals(oracle.Hash) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ type FakeChain struct {
|
||||||
blocksCh []chan *block.Block
|
blocksCh []chan *block.Block
|
||||||
Blockheight uint32
|
Blockheight uint32
|
||||||
PoolTxF func(*transaction.Transaction) error
|
PoolTxF func(*transaction.Transaction) error
|
||||||
poolTxWithData func(*transaction.Transaction, interface{}, *mempool.Pool) error
|
poolTxWithData func(*transaction.Transaction, any, *mempool.Pool) error
|
||||||
blocks map[util.Uint256]*block.Block
|
blocks map[util.Uint256]*block.Block
|
||||||
hdrHashes map[uint32]util.Uint256
|
hdrHashes map[uint32]util.Uint256
|
||||||
txs map[util.Uint256]*transaction.Transaction
|
txs map[util.Uint256]*transaction.Transaction
|
||||||
|
@ -64,7 +64,7 @@ func NewFakeChainWithCustomCfg(protocolCfg func(c *config.Blockchain)) *FakeChai
|
||||||
return &FakeChain{
|
return &FakeChain{
|
||||||
Pool: mempool.New(10, 0, false),
|
Pool: mempool.New(10, 0, false),
|
||||||
PoolTxF: func(*transaction.Transaction) error { return nil },
|
PoolTxF: func(*transaction.Transaction) error { return nil },
|
||||||
poolTxWithData: func(*transaction.Transaction, interface{}, *mempool.Pool) error { return nil },
|
poolTxWithData: func(*transaction.Transaction, any, *mempool.Pool) error { return nil },
|
||||||
blocks: make(map[util.Uint256]*block.Block),
|
blocks: make(map[util.Uint256]*block.Block),
|
||||||
hdrHashes: make(map[uint32]util.Uint256),
|
hdrHashes: make(map[uint32]util.Uint256),
|
||||||
txs: make(map[util.Uint256]*transaction.Transaction),
|
txs: make(map[util.Uint256]*transaction.Transaction),
|
||||||
|
@ -149,7 +149,7 @@ func (chain *FakeChain) GetMaxVerificationGAS() int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PoolTxWithData implements the Blockchainer interface.
|
// PoolTxWithData implements the Blockchainer interface.
|
||||||
func (chain *FakeChain) PoolTxWithData(t *transaction.Transaction, data interface{}, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(t *transaction.Transaction, data interface{}) error) error {
|
func (chain *FakeChain) PoolTxWithData(t *transaction.Transaction, data any, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(t *transaction.Transaction, data any) error) error {
|
||||||
return chain.poolTxWithData(t, data, mp)
|
return chain.poolTxWithData(t, data, mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
// MarshalUnmarshalJSON checks if the expected stays the same after
|
// MarshalUnmarshalJSON checks if the expected stays the same after
|
||||||
// marshal/unmarshal via JSON.
|
// marshal/unmarshal via JSON.
|
||||||
func MarshalUnmarshalJSON(t *testing.T, expected, actual interface{}) {
|
func MarshalUnmarshalJSON(t *testing.T, expected, actual any) {
|
||||||
data, err := json.Marshal(expected)
|
data, err := json.Marshal(expected)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, json.Unmarshal(data, actual))
|
require.NoError(t, json.Unmarshal(data, actual))
|
||||||
|
@ -21,7 +21,7 @@ func MarshalUnmarshalJSON(t *testing.T, expected, actual interface{}) {
|
||||||
|
|
||||||
// MarshalUnmarshalYAML checks if the expected stays the same after
|
// MarshalUnmarshalYAML checks if the expected stays the same after
|
||||||
// marshal/unmarshal via YAML.
|
// marshal/unmarshal via YAML.
|
||||||
func MarshalUnmarshalYAML(t *testing.T, expected, actual interface{}) {
|
func MarshalUnmarshalYAML(t *testing.T, expected, actual any) {
|
||||||
data, err := yaml.Marshal(expected)
|
data, err := yaml.Marshal(expected)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, yaml.Unmarshal(data, actual))
|
require.NoError(t, yaml.Unmarshal(data, actual))
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (c *codegen) fillImportMap(f *ast.File, pkg *packages.Package) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
func getBuildInfo(name string, src any) (*buildInfo, error) {
|
||||||
dir, err := filepath.Abs(name)
|
dir, err := filepath.Abs(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -102,25 +102,25 @@ func TestOnPayableChecks(t *testing.T) {
|
||||||
t.Run("NEP-11, good", func(t *testing.T) {
|
t.Run("NEP-11, good", func(t *testing.T) {
|
||||||
src := `package payable
|
src := `package payable
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
func OnNEP11Payment(from interop.Hash160, amount int, tokenID []byte, data interface{}) {}`
|
func OnNEP11Payment(from interop.Hash160, amount int, tokenID []byte, data any) {}`
|
||||||
require.NoError(t, compileAndCheck(t, src))
|
require.NoError(t, compileAndCheck(t, src))
|
||||||
})
|
})
|
||||||
t.Run("NEP-11, bad", func(t *testing.T) {
|
t.Run("NEP-11, bad", func(t *testing.T) {
|
||||||
src := `package payable
|
src := `package payable
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
func OnNEP11Payment(from interop.Hash160, amount int, oldParam string, tokenID []byte, data interface{}) {}`
|
func OnNEP11Payment(from interop.Hash160, amount int, oldParam string, tokenID []byte, data any) {}`
|
||||||
require.Error(t, compileAndCheck(t, src))
|
require.Error(t, compileAndCheck(t, src))
|
||||||
})
|
})
|
||||||
t.Run("NEP-17, good", func(t *testing.T) {
|
t.Run("NEP-17, good", func(t *testing.T) {
|
||||||
src := `package payable
|
src := `package payable
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {}`
|
func OnNEP17Payment(from interop.Hash160, amount int, data any) {}`
|
||||||
require.NoError(t, compileAndCheck(t, src))
|
require.NoError(t, compileAndCheck(t, src))
|
||||||
})
|
})
|
||||||
t.Run("NEP-17, bad", func(t *testing.T) {
|
t.Run("NEP-17, bad", func(t *testing.T) {
|
||||||
src := `package payable
|
src := `package payable
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}, extra int) {}`
|
func OnNEP17Payment(from interop.Hash160, amount int, data any, extra int) {}`
|
||||||
require.Error(t, compileAndCheck(t, src))
|
require.Error(t, compileAndCheck(t, src))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ func TestEventWarnings(t *testing.T) {
|
||||||
src := `package payable
|
src := `package payable
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
func Main() {
|
func Main() {
|
||||||
runtime.Notify("Event", []interface{}{1}...)
|
runtime.Notify("Event", []any{1}...)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src), nil)
|
_, di, err := compiler.CompileWithOptions("eventTest.go", strings.NewReader(src), nil)
|
||||||
|
@ -407,7 +407,7 @@ func TestUnnamedParameterCheck(t *testing.T) {
|
||||||
t.Run("interface", func(t *testing.T) {
|
t.Run("interface", func(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package testcase
|
package testcase
|
||||||
func OnNEP17Payment(h string, i int, _ interface{}){}
|
func OnNEP17Payment(h string, i int, _ any){}
|
||||||
`
|
`
|
||||||
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
@ -416,7 +416,7 @@ func TestUnnamedParameterCheck(t *testing.T) {
|
||||||
t.Run("a set of unnamed params", func(t *testing.T) {
|
t.Run("a set of unnamed params", func(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package testcase
|
package testcase
|
||||||
func OnNEP17Payment(_ string, _ int, _ interface{}){}
|
func OnNEP17Payment(_ string, _ int, _ any){}
|
||||||
`
|
`
|
||||||
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
@ -447,11 +447,19 @@ func TestUnnamedParameterCheck(t *testing.T) {
|
||||||
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
t.Run("good, use any keyword", func(t *testing.T) {
|
||||||
|
src := `
|
||||||
|
package testcase
|
||||||
|
func OnNEP17Payment(s string, i int, iface any){}
|
||||||
|
`
|
||||||
|
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
})
|
||||||
t.Run("method with unnamed params", func(t *testing.T) {
|
t.Run("method with unnamed params", func(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package testcase
|
package testcase
|
||||||
type A int
|
type A int
|
||||||
func (rsv A) OnNEP17Payment(_ string, _ int, iface interface{}){}
|
func (rsv A) OnNEP17Payment(_ string, _ int, iface any){}
|
||||||
`
|
`
|
||||||
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
_, _, err := compiler.CompileWithOptions("test.go", strings.NewReader(src), nil)
|
||||||
require.NoError(t, err) // it's OK for exported method to have unnamed params as it won't be included into manifest
|
require.NoError(t, err) // it's OK for exported method to have unnamed params as it won't be included into manifest
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
type convertTestCase struct {
|
type convertTestCase struct {
|
||||||
returnType string
|
returnType string
|
||||||
argValue string
|
argValue string
|
||||||
result interface{}
|
result any
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFunctionName(typ string) string {
|
func getFunctionName(typ string) string {
|
||||||
|
@ -85,7 +85,7 @@ func TestTypeAssertion(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
a := []byte{1}
|
a := []byte{1}
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
return u.(int)
|
return u.(int)
|
||||||
}`
|
}`
|
||||||
|
@ -95,7 +95,7 @@ func TestTypeAssertion(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
a := []byte{1}
|
a := []byte{1}
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
var ret = u.(int)
|
var ret = u.(int)
|
||||||
return ret
|
return ret
|
||||||
|
@ -106,7 +106,7 @@ func TestTypeAssertion(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
a := []byte{1}
|
a := []byte{1}
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
var ret int
|
var ret int
|
||||||
ret = u.(int)
|
ret = u.(int)
|
||||||
|
@ -118,7 +118,7 @@ func TestTypeAssertion(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
a := []byte{1}
|
a := []byte{1}
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
ret := u.(int)
|
ret := u.(int)
|
||||||
return ret
|
return ret
|
||||||
|
@ -132,7 +132,7 @@ func TestTypeAssertionWithOK(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() bool {
|
func Main() bool {
|
||||||
a := 1
|
a := 1
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
var _, ok = u.(int) // *ast.GenDecl
|
var _, ok = u.(int) // *ast.GenDecl
|
||||||
return ok
|
return ok
|
||||||
|
@ -145,7 +145,7 @@ func TestTypeAssertionWithOK(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() bool {
|
func Main() bool {
|
||||||
a := 1
|
a := 1
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
var ok bool
|
var ok bool
|
||||||
_, ok = u.(int) // *ast.AssignStmt
|
_, ok = u.(int) // *ast.AssignStmt
|
||||||
|
@ -159,7 +159,7 @@ func TestTypeAssertionWithOK(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() bool {
|
func Main() bool {
|
||||||
a := 1
|
a := 1
|
||||||
var u interface{}
|
var u any
|
||||||
u = a
|
u = a
|
||||||
_, ok := u.(int) // *ast.AssignStmt
|
_, ok := u.(int) // *ast.AssignStmt
|
||||||
return ok
|
return ok
|
||||||
|
@ -231,7 +231,7 @@ func TestInterfaceTypeConversion(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
a := 1
|
a := 1
|
||||||
b := interface{}(a).(int)
|
b := any(a).(int)
|
||||||
return b
|
return b
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1))
|
eval(t, src, big.NewInt(1))
|
||||||
|
|
|
@ -308,7 +308,7 @@ func scAndVMInteropTypeFromExpr(named *types.Named, isPointer bool) (smartcontra
|
||||||
}
|
}
|
||||||
return smartcontract.InteropInterfaceType,
|
return smartcontract.InteropInterfaceType,
|
||||||
stackitem.InteropT,
|
stackitem.InteropT,
|
||||||
binding.Override{TypeName: "interface{}"},
|
binding.Override{TypeName: "any"},
|
||||||
&binding.ExtendedType{Base: smartcontract.InteropInterfaceType, Interface: "iterator"} // Temporarily all interops are iterators.
|
&binding.ExtendedType{Base: smartcontract.InteropInterfaceType, Interface: "iterator"} // Temporarily all interops are iterators.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ func (c *codegen) scAndVMTypeFromExpr(typ ast.Expr, exts map[string]binding.Exte
|
||||||
|
|
||||||
func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.ExtendedType) (smartcontract.ParamType, stackitem.Type, binding.Override, *binding.ExtendedType) {
|
func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.ExtendedType) (smartcontract.ParamType, stackitem.Type, binding.Override, *binding.ExtendedType) {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
return smartcontract.AnyType, stackitem.AnyT, binding.Override{TypeName: "interface{}"}, nil
|
return smartcontract.AnyType, stackitem.AnyT, binding.Override{TypeName: "any"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPtr bool
|
var isPtr bool
|
||||||
|
@ -357,7 +357,7 @@ func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.Exte
|
||||||
over.TypeName = "string"
|
over.TypeName = "string"
|
||||||
return smartcontract.StringType, stackitem.ByteArrayT, over, nil
|
return smartcontract.StringType, stackitem.ByteArrayT, over, nil
|
||||||
default:
|
default:
|
||||||
over.TypeName = "interface{}"
|
over.TypeName = "any"
|
||||||
return smartcontract.AnyType, stackitem.AnyT, over, nil
|
return smartcontract.AnyType, stackitem.AnyT, over, nil
|
||||||
}
|
}
|
||||||
case *types.Map:
|
case *types.Map:
|
||||||
|
@ -412,7 +412,7 @@ func (c *codegen) scAndVMTypeFromType(t types.Type, exts map[string]binding.Exte
|
||||||
}
|
}
|
||||||
return smartcontract.ArrayType, stackitem.ArrayT, over, et
|
return smartcontract.ArrayType, stackitem.ArrayT, over, et
|
||||||
default:
|
default:
|
||||||
over.TypeName = "interface{}"
|
over.TypeName = "any"
|
||||||
return smartcontract.AnyType, stackitem.AnyT, over, nil
|
return smartcontract.AnyType, stackitem.AnyT, over, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ func MethodParams(addr interop.Hash160, h interop.Hash256,
|
||||||
type MyStruct struct {}
|
type MyStruct struct {}
|
||||||
func (ms MyStruct) MethodOnStruct() { }
|
func (ms MyStruct) MethodOnStruct() { }
|
||||||
func (ms *MyStruct) MethodOnPointerToStruct() { }
|
func (ms *MyStruct) MethodOnPointerToStruct() { }
|
||||||
func _deploy(data interface{}, isUpdate bool) { x := 1; _ = x }
|
func _deploy(data any, isUpdate bool) { x := 1; _ = x }
|
||||||
`
|
`
|
||||||
|
|
||||||
ne, d, err := CompileWithOptions("foo.go", strings.NewReader(src), nil)
|
ne, d, err := CompileWithOptions("foo.go", strings.NewReader(src), nil)
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestEntryPointWithArgs(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
func Main(args []interface{}) int {
|
func Main(args []any) int {
|
||||||
return 2 + args[1].(int)
|
return 2 + args[1].(int)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -44,7 +44,7 @@ func TestEntryPointWithMethodAndArgs(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
func Main(method string, args []interface{}) int {
|
func Main(method string, args []any) int {
|
||||||
if method == "foobar" {
|
if method == "foobar" {
|
||||||
return 2 + args[1].(int)
|
return 2 + args[1].(int)
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,21 @@ func TestFunctionCallWithInterfaceType(t *testing.T) {
|
||||||
eval(t, src, big.NewInt(10))
|
eval(t, src, big.NewInt(10))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFunctionCallWithAnyKeywordType(t *testing.T) {
|
||||||
|
src := `
|
||||||
|
package testcase
|
||||||
|
func Main() any {
|
||||||
|
x := getSomeInteger(10)
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSomeInteger(x any) any {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
`
|
||||||
|
eval(t, src, big.NewInt(10))
|
||||||
|
}
|
||||||
|
|
||||||
func TestFunctionCallMultiArg(t *testing.T) {
|
func TestFunctionCallMultiArg(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package testcase
|
package testcase
|
||||||
|
@ -312,7 +327,7 @@ func TestJumpOptimize(t *testing.T) {
|
||||||
var a int
|
var a int
|
||||||
_ = a
|
_ = a
|
||||||
}
|
}
|
||||||
func _deploy(_ interface{}, upd bool) {
|
func _deploy(_ any, upd bool) {
|
||||||
if true {} else {}
|
if true {} else {}
|
||||||
t := upd
|
t := upd
|
||||||
_ = t
|
_ = t
|
||||||
|
|
|
@ -137,9 +137,9 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() int {
|
func f() int {
|
||||||
return 4
|
return 4
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(4), []interface{}{opcode.INITSSLOT, []byte{2}}, // sslot for A and C
|
eval(t, src, big.NewInt(4), []any{opcode.INITSSLOT, []byte{2}}, // sslot for A and C
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
[]interface{}{opcode.CALL, []byte{10}}, opcode.DROP, // evaluate B and drop
|
[]any{opcode.CALL, []byte{10}}, opcode.DROP, // evaluate B and drop
|
||||||
opcode.PUSH3, opcode.STSFLD1, opcode.RET, // store C
|
opcode.PUSH3, opcode.STSFLD1, opcode.RET, // store C
|
||||||
opcode.LDSFLD0, opcode.LDSFLD1, opcode.ADD, opcode.RET, // Main
|
opcode.LDSFLD0, opcode.LDSFLD1, opcode.ADD, opcode.RET, // Main
|
||||||
opcode.PUSH4, opcode.RET) // f
|
opcode.PUSH4, opcode.RET) // f
|
||||||
|
@ -166,7 +166,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func Main() int {
|
func Main() int {
|
||||||
return A
|
return A
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
||||||
opcode.LDSFLD0, opcode.RET) // Main
|
opcode.LDSFLD0, opcode.RET) // Main
|
||||||
})
|
})
|
||||||
|
@ -176,7 +176,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func Main() int {
|
func Main() int {
|
||||||
return A + B
|
return A + B
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(4), []interface{}{opcode.INITSSLOT, []byte{2}}, // sslot for A and B
|
eval(t, src, big.NewInt(4), []any{opcode.INITSSLOT, []byte{2}}, // sslot for A and B
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
opcode.PUSH3, opcode.STSFLD1, opcode.RET, // store B
|
opcode.PUSH3, opcode.STSFLD1, opcode.RET, // store B
|
||||||
opcode.LDSFLD0, opcode.LDSFLD1, opcode.ADD, opcode.RET) // Main
|
opcode.LDSFLD0, opcode.LDSFLD1, opcode.ADD, opcode.RET) // Main
|
||||||
|
@ -190,7 +190,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func Main() int {
|
func Main() int {
|
||||||
return A + B + C
|
return A + B + C
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(4), []interface{}{opcode.INITSSLOT, []byte{3}}, // sslot for A, B, C
|
eval(t, src, big.NewInt(4), []any{opcode.INITSSLOT, []byte{3}}, // sslot for A, B, C
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
opcode.PUSH3, opcode.STSFLD1, // store B
|
opcode.PUSH3, opcode.STSFLD1, // store B
|
||||||
opcode.PUSH0, opcode.STSFLD2, opcode.RET, // store C
|
opcode.PUSH0, opcode.STSFLD2, opcode.RET, // store C
|
||||||
|
@ -205,9 +205,9 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() int {
|
func f() int {
|
||||||
return 2
|
return 2
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
[]interface{}{opcode.CALL, []byte{6}}, opcode.DROP, opcode.RET, // evaluate Unused1 (call to f) and drop its value
|
[]any{opcode.CALL, []byte{6}}, opcode.DROP, opcode.RET, // evaluate Unused1 (call to f) and drop its value
|
||||||
opcode.LDSFLD0, opcode.RET, // Main
|
opcode.LDSFLD0, opcode.RET, // Main
|
||||||
opcode.PUSH2, opcode.RET) // f
|
opcode.PUSH2, opcode.RET) // f
|
||||||
})
|
})
|
||||||
|
@ -221,7 +221,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() int {
|
func f() int {
|
||||||
return 2
|
return 2
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.CALL, []byte{8}}, opcode.PUSH1, opcode.PACKSTRUCT, opcode.DROP, opcode.RET, // evaluate struct val
|
eval(t, src, big.NewInt(1), []any{opcode.CALL, []byte{8}}, opcode.PUSH1, opcode.PACKSTRUCT, opcode.DROP, opcode.RET, // evaluate struct val
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
opcode.PUSH2, opcode.RET) // f
|
opcode.PUSH2, opcode.RET) // f
|
||||||
})
|
})
|
||||||
|
@ -319,11 +319,11 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() int {
|
func f() int {
|
||||||
return 2
|
return 2
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{3}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{3}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
opcode.LDSFLD0, opcode.PUSH1, opcode.ADD, opcode.STSFLD1, // store B
|
opcode.LDSFLD0, opcode.PUSH1, opcode.ADD, opcode.STSFLD1, // store B
|
||||||
opcode.PUSH3, opcode.STSFLD2, // store C
|
opcode.PUSH3, opcode.STSFLD2, // store C
|
||||||
opcode.LDSFLD1, []interface{}{opcode.CALL, []byte{9}}, opcode.ADD, opcode.LDSFLD2, opcode.ADD, opcode.DROP, opcode.RET, // evaluate D and drop
|
opcode.LDSFLD1, []any{opcode.CALL, []byte{9}}, opcode.ADD, opcode.LDSFLD2, opcode.ADD, opcode.DROP, opcode.RET, // evaluate D and drop
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
opcode.PUSH2, opcode.RET) // f
|
opcode.PUSH2, opcode.RET) // f
|
||||||
})
|
})
|
||||||
|
@ -337,11 +337,11 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f(a int) int {
|
func f(a int) int {
|
||||||
return a
|
return a
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, // store A
|
opcode.PUSH1, opcode.STSFLD0, // store A
|
||||||
opcode.LDSFLD0, []interface{}{opcode.CALL, []byte{6}}, opcode.DROP, opcode.RET, // evaluate B and drop
|
opcode.LDSFLD0, []any{opcode.CALL, []byte{6}}, opcode.DROP, opcode.RET, // evaluate B and drop
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f
|
[]any{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f
|
||||||
})
|
})
|
||||||
t.Run("named, inside multi-specs and multi-vals var declaration", func(t *testing.T) {
|
t.Run("named, inside multi-specs and multi-vals var declaration", func(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
|
@ -355,7 +355,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() int {
|
func f() int {
|
||||||
return 5
|
return 5
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), opcode.PUSH3, []interface{}{opcode.CALL, []byte{7}}, opcode.ADD, opcode.DROP, opcode.RET, // evaluate and drop A
|
eval(t, src, big.NewInt(1), opcode.PUSH3, []any{opcode.CALL, []byte{7}}, opcode.ADD, opcode.DROP, opcode.RET, // evaluate and drop A
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
opcode.PUSH5, opcode.RET) // f
|
opcode.PUSH5, opcode.RET) // f
|
||||||
})
|
})
|
||||||
|
@ -367,7 +367,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func Main() int {
|
func Main() int {
|
||||||
return A
|
return A
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
||||||
opcode.LDSFLD0, opcode.RET) // Main
|
opcode.LDSFLD0, opcode.RET) // Main
|
||||||
})
|
})
|
||||||
|
@ -395,8 +395,8 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f() (int, int) {
|
func f() (int, int) {
|
||||||
return 3, 4
|
return 3, 4
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(3), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(3), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
[]interface{}{opcode.CALL, []byte{7}}, opcode.STSFLD0, opcode.DROP, opcode.RET, // evaluate and store A, drop B
|
[]any{opcode.CALL, []byte{7}}, opcode.STSFLD0, opcode.DROP, opcode.RET, // evaluate and store A, drop B
|
||||||
opcode.LDSFLD0, opcode.RET, // Main
|
opcode.LDSFLD0, opcode.RET, // Main
|
||||||
opcode.PUSH4, opcode.PUSH3, opcode.RET) // f
|
opcode.PUSH4, opcode.PUSH3, opcode.RET) // f
|
||||||
})
|
})
|
||||||
|
@ -460,12 +460,12 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f(a int) int {
|
func f(a int) int {
|
||||||
return a
|
return a
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{2}}, // sslot for A, B
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{2}}, // sslot for A, B
|
||||||
opcode.PUSH2, opcode.STSFLD0, // store A
|
opcode.PUSH2, opcode.STSFLD0, // store A
|
||||||
opcode.PUSH3, opcode.LDSFLD0, opcode.PUSH1, opcode.PUSH3, opcode.PACK, opcode.PUSH1, opcode.PICKITEM, opcode.STSFLD1, // evaluate B
|
opcode.PUSH3, opcode.LDSFLD0, opcode.PUSH1, opcode.PUSH3, opcode.PACK, opcode.PUSH1, opcode.PICKITEM, opcode.STSFLD1, // evaluate B
|
||||||
opcode.PUSH1, []interface{}{opcode.CALL, []byte{8}}, opcode.LDSFLD1, opcode.ADD, opcode.DROP, opcode.RET, // evalute C and drop
|
opcode.PUSH1, []any{opcode.CALL, []byte{8}}, opcode.LDSFLD1, opcode.ADD, opcode.DROP, opcode.RET, // evalute C and drop
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f
|
[]any{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f
|
||||||
})
|
})
|
||||||
t.Run("index expression", func(t *testing.T) {
|
t.Run("index expression", func(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
|
@ -477,13 +477,13 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func f(a int) int {
|
func f(a int) int {
|
||||||
return a
|
return a
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for Unused
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for Unused
|
||||||
opcode.PUSH2, opcode.STSFLD0, // store Unused
|
opcode.PUSH2, opcode.STSFLD0, // store Unused
|
||||||
opcode.PUSH1, []interface{}{opcode.CALL, []byte{14}}, // call f(1)
|
opcode.PUSH1, []any{opcode.CALL, []byte{14}}, // call f(1)
|
||||||
opcode.PUSH3, opcode.PUSH2, opcode.PUSH1, opcode.PUSH3, opcode.PACK, opcode.LDSFLD0, opcode.PICKITEM, // eval index expression
|
opcode.PUSH3, opcode.PUSH2, opcode.PUSH1, opcode.PUSH3, opcode.PACK, opcode.LDSFLD0, opcode.PICKITEM, // eval index expression
|
||||||
opcode.ADD, opcode.DROP, opcode.RET, // eval and drop A
|
opcode.ADD, opcode.DROP, opcode.RET, // eval and drop A
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f(a)
|
[]any{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.RET) // f(a)
|
||||||
})
|
})
|
||||||
t.Run("used via nested function calls", func(t *testing.T) {
|
t.Run("used via nested function calls", func(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
|
@ -497,10 +497,10 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func g() int {
|
func g() int {
|
||||||
return A
|
return A
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{1}}, // sslot for A
|
||||||
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
opcode.PUSH1, opcode.STSFLD0, opcode.RET, // store A
|
||||||
[]interface{}{opcode.CALL, []byte{3}}, opcode.RET, // Main
|
[]any{opcode.CALL, []byte{3}}, opcode.RET, // Main
|
||||||
[]interface{}{opcode.CALL, []byte{3}}, opcode.RET, // f
|
[]any{opcode.CALL, []byte{3}}, opcode.RET, // f
|
||||||
opcode.LDSFLD0, opcode.RET) // g
|
opcode.LDSFLD0, opcode.RET) // g
|
||||||
})
|
})
|
||||||
t.Run("struct field name matches global var name", func(t *testing.T) {
|
t.Run("struct field name matches global var name", func(t *testing.T) {
|
||||||
|
@ -511,7 +511,7 @@ func TestUnusedOptimizedGlobalVar(t *testing.T) {
|
||||||
func Main() int {
|
func Main() int {
|
||||||
return str.Int
|
return str.Int
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(2), []interface{}{opcode.INITSSLOT, []byte{1}}, // sslot for str
|
eval(t, src, big.NewInt(2), []any{opcode.INITSSLOT, []byte{1}}, // sslot for str
|
||||||
opcode.PUSH2, opcode.PUSH1, opcode.PACKSTRUCT, opcode.STSFLD0, opcode.RET, // store str
|
opcode.PUSH2, opcode.PUSH1, opcode.PACKSTRUCT, opcode.STSFLD0, opcode.RET, // store str
|
||||||
opcode.LDSFLD0, opcode.PUSH0, opcode.PICKITEM, opcode.RET) // Main
|
opcode.LDSFLD0, opcode.PUSH0, opcode.PICKITEM, opcode.RET) // Main
|
||||||
})
|
})
|
||||||
|
@ -929,11 +929,11 @@ func TestUnderscoreGlobalVarDontEmitCode(t *testing.T) {
|
||||||
func f(a, b int) (int, int, int) {
|
func f(a, b int) (int, int, int) {
|
||||||
return 8, 9, 10
|
return 8, 9, 10
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(1), []interface{}{opcode.INITSSLOT, []byte{2}}, // sslot for A, B
|
eval(t, src, big.NewInt(1), []any{opcode.INITSSLOT, []byte{2}}, // sslot for A, B
|
||||||
opcode.PUSH2, opcode.STSFLD0, // store A
|
opcode.PUSH2, opcode.STSFLD0, // store A
|
||||||
opcode.PUSH5, opcode.STSFLD1, // store B
|
opcode.PUSH5, opcode.STSFLD1, // store B
|
||||||
opcode.LDSFLD0, opcode.LDSFLD1, opcode.SWAP, []interface{}{opcode.CALL, []byte{8}}, // evaluate f(A,B)
|
opcode.LDSFLD0, opcode.LDSFLD1, opcode.SWAP, []any{opcode.CALL, []byte{8}}, // evaluate f(A,B)
|
||||||
opcode.DROP, opcode.DROP, opcode.DROP, opcode.RET, // drop result of f(A,B)
|
opcode.DROP, opcode.DROP, opcode.DROP, opcode.RET, // drop result of f(A,B)
|
||||||
opcode.PUSH1, opcode.RET, // Main
|
opcode.PUSH1, opcode.RET, // Main
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 2}}, opcode.PUSH10, opcode.PUSH9, opcode.PUSH8, opcode.RET) // f
|
[]any{opcode.INITSLOT, []byte{0, 2}}, opcode.PUSH10, opcode.PUSH9, opcode.PUSH8, opcode.RET) // f
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestTypeConstantSize(t *testing.T) {
|
||||||
src := `package foo
|
src := `package foo
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
import "github.com/nspcc-dev/neo-go/pkg/interop"
|
||||||
var a %T // type declaration is always ok
|
var a %T // type declaration is always ok
|
||||||
func Main() interface{} {
|
func Main() any {
|
||||||
return %#v
|
return %#v
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ func TestCallWithVersion(t *testing.T) {
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
util "github.com/nspcc-dev/neo-go/pkg/interop/lib/contract"
|
util "github.com/nspcc-dev/neo-go/pkg/interop/lib/contract"
|
||||||
)
|
)
|
||||||
func CallWithVersion(hash interop.Hash160, version int, method string) interface{} {
|
func CallWithVersion(hash interop.Hash160, version int, method string) any {
|
||||||
return util.CallWithVersion(hash, version, method, contract.All)
|
return util.CallWithVersion(hash, version, method, contract.All)
|
||||||
}`
|
}`
|
||||||
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
|
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
|
||||||
|
@ -569,7 +569,7 @@ func TestForcedNotifyArgumentsConversion(t *testing.T) {
|
||||||
runtime.Notify("withoutEllipsis", arg0, arg1, arg2, arg3, arg4, 5, f(6)) // The fifth argument is basic literal.
|
runtime.Notify("withoutEllipsis", arg0, arg1, arg2, arg3, arg4, 5, f(6)) // The fifth argument is basic literal.
|
||||||
}
|
}
|
||||||
func WithEllipsis() {
|
func WithEllipsis() {
|
||||||
arg := []interface{}{0, 1, f(2), 3, 4, 5, 6}
|
arg := []any{0, 1, f(2), 3, 4, 5, 6}
|
||||||
runtime.Notify("withEllipsis", arg...)
|
runtime.Notify("withEllipsis", arg...)
|
||||||
}
|
}
|
||||||
func f(i int) int {
|
func f(i int) int {
|
||||||
|
|
|
@ -295,7 +295,7 @@ func addNativeTestCase(t *testing.T, srcBuilder *bytes.Buffer, ctr interop.Contr
|
||||||
isVoid := md.MD.ReturnType == smartcontract.VoidType
|
isVoid := md.MD.ReturnType == smartcontract.VoidType
|
||||||
srcBuilder.WriteString("func F" + strconv.Itoa(i) + "() ")
|
srcBuilder.WriteString("func F" + strconv.Itoa(i) + "() ")
|
||||||
if !isVoid {
|
if !isVoid {
|
||||||
srcBuilder.WriteString("interface{} { return ")
|
srcBuilder.WriteString("any { return ")
|
||||||
} else {
|
} else {
|
||||||
srcBuilder.WriteString("{ ")
|
srcBuilder.WriteString("{ ")
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ var nilTestCases = []testCase{
|
||||||
`
|
`
|
||||||
package foo
|
package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
var t interface{}
|
var t any
|
||||||
if t == nil {
|
if t == nil {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ var nilTestCases = []testCase{
|
||||||
`
|
`
|
||||||
package foo
|
package foo
|
||||||
func Main() int {
|
func Main() int {
|
||||||
var t interface{}
|
var t any
|
||||||
if nil == t {
|
if nil == t {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ func TestTypeAssertReturn(t *testing.T) {
|
||||||
src := `
|
src := `
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func foo() interface{} {
|
func foo() any {
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ func TestSyscallExecution(t *testing.T) {
|
||||||
if tc.isVoid {
|
if tc.isVoid {
|
||||||
tmpl = "func %s() { %s(%s) }\n"
|
tmpl = "func %s() { %s(%s) }\n"
|
||||||
} else {
|
} else {
|
||||||
tmpl = "func %s() interface{} { return %s(%s) }\n"
|
tmpl = "func %s() any { return %s(%s) }\n"
|
||||||
}
|
}
|
||||||
srcBuilder.WriteString(fmt.Sprintf(tmpl, realName, goName, strings.Join(tc.params, ", ")))
|
srcBuilder.WriteString(fmt.Sprintf(tmpl, realName, goName, strings.Join(tc.params, ", ")))
|
||||||
}
|
}
|
||||||
|
|
2
pkg/compiler/testdata/util/equals.go
vendored
2
pkg/compiler/testdata/util/equals.go
vendored
|
@ -1,6 +1,6 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
// Equals is a mirror of `Equals` builtin.
|
// Equals is a mirror of `Equals` builtin.
|
||||||
func Equals(a, b interface{}) bool {
|
func Equals(a, b any) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,18 +59,18 @@ func TestUnderscoreLocalVarDontEmitCode(t *testing.T) {
|
||||||
func (fo Foo) GetInt() int {
|
func (fo Foo) GetInt() int {
|
||||||
return fo.Int
|
return fo.Int
|
||||||
}`
|
}`
|
||||||
eval(t, src, big.NewInt(9), []interface{}{opcode.INITSLOT, []byte{5, 0}}, // local slot for A, B, C, D, fo
|
eval(t, src, big.NewInt(9), []any{opcode.INITSLOT, []byte{5, 0}}, // local slot for A, B, C, D, fo
|
||||||
opcode.PUSH2, opcode.STLOC0, // store A
|
opcode.PUSH2, opcode.STLOC0, // store A
|
||||||
opcode.PUSH5, opcode.STLOC1, // store B
|
opcode.PUSH5, opcode.STLOC1, // store B
|
||||||
opcode.LDLOC0, opcode.LDLOC1, opcode.SWAP, []interface{}{opcode.CALL, []byte{27}}, // evaluate f() first time
|
opcode.LDLOC0, opcode.LDLOC1, opcode.SWAP, []any{opcode.CALL, []byte{27}}, // evaluate f() first time
|
||||||
opcode.DROP, opcode.DROP, opcode.DROP, // drop all values from f
|
opcode.DROP, opcode.DROP, opcode.DROP, // drop all values from f
|
||||||
opcode.LDLOC0, opcode.LDLOC1, opcode.SWAP, []interface{}{opcode.CALL, []byte{19}}, // evaluate f() second time
|
opcode.LDLOC0, opcode.LDLOC1, opcode.SWAP, []any{opcode.CALL, []byte{19}}, // evaluate f() second time
|
||||||
opcode.DROP, opcode.STLOC2, opcode.DROP, // store C
|
opcode.DROP, opcode.STLOC2, opcode.DROP, // store C
|
||||||
opcode.PUSH7, opcode.STLOC3, // store D
|
opcode.PUSH7, opcode.STLOC3, // store D
|
||||||
opcode.LDLOC3, opcode.DROP, // empty assignment
|
opcode.LDLOC3, opcode.DROP, // empty assignment
|
||||||
opcode.PUSH3, opcode.PUSH1, opcode.PACKSTRUCT, opcode.STLOC4, // fo decl
|
opcode.PUSH3, opcode.PUSH1, opcode.PACKSTRUCT, opcode.STLOC4, // fo decl
|
||||||
opcode.LDLOC4, []interface{}{opcode.CALL, []byte{12}}, opcode.DROP, // fo.GetInt()
|
opcode.LDLOC4, []any{opcode.CALL, []byte{12}}, opcode.DROP, // fo.GetInt()
|
||||||
opcode.LDLOC2, opcode.RET, // return C
|
opcode.LDLOC2, opcode.RET, // return C
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 2}}, opcode.PUSH10, opcode.PUSH9, opcode.PUSH8, opcode.RET, // f
|
[]any{opcode.INITSLOT, []byte{0, 2}}, opcode.PUSH10, opcode.PUSH9, opcode.PUSH8, opcode.RET, // f
|
||||||
[]interface{}{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.PUSH0, opcode.PICKITEM, opcode.RET) // (fo Foo) GetInt() int
|
[]any{opcode.INITSLOT, []byte{0, 1}}, opcode.LDARG0, opcode.PUSH0, opcode.PICKITEM, opcode.RET) // (fo Foo) GetInt() int
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
name string
|
name string
|
||||||
src string
|
src string
|
||||||
result interface{}
|
result any
|
||||||
}
|
}
|
||||||
|
|
||||||
// testMainIdent is a method invoked in tests by default.
|
// testMainIdent is a method invoked in tests by default.
|
||||||
|
@ -35,7 +35,7 @@ func runTestCases(t *testing.T, tcases []testCase) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func eval(t *testing.T, src string, result interface{}, expectedOps ...interface{}) []byte {
|
func eval(t *testing.T, src string, result any, expectedOps ...any) []byte {
|
||||||
vm, _, script := vmAndCompileInterop(t, src)
|
vm, _, script := vmAndCompileInterop(t, src)
|
||||||
if len(expectedOps) != 0 {
|
if len(expectedOps) != 0 {
|
||||||
expected := io.NewBufBinWriter()
|
expected := io.NewBufBinWriter()
|
||||||
|
@ -43,7 +43,7 @@ func eval(t *testing.T, src string, result interface{}, expectedOps ...interface
|
||||||
switch typ := op.(type) {
|
switch typ := op.(type) {
|
||||||
case opcode.Opcode:
|
case opcode.Opcode:
|
||||||
emit.Opcodes(expected.BinWriter, typ)
|
emit.Opcodes(expected.BinWriter, typ)
|
||||||
case []interface{}:
|
case []any:
|
||||||
emit.Instruction(expected.BinWriter, typ[0].(opcode.Opcode), typ[1].([]byte))
|
emit.Instruction(expected.BinWriter, typ[0].(opcode.Opcode), typ[1].([]byte))
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected evaluation operation: %v", typ)
|
t.Fatalf("unexpected evaluation operation: %v", typ)
|
||||||
|
@ -64,14 +64,14 @@ func evalWithError(t *testing.T, src string, e string) []byte {
|
||||||
return prog
|
return prog
|
||||||
}
|
}
|
||||||
|
|
||||||
func runAndCheck(t *testing.T, v *vm.VM, result interface{}) {
|
func runAndCheck(t *testing.T, v *vm.VM, result any) {
|
||||||
err := v.Run()
|
err := v.Run()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, 1, v.Estack().Len(), "stack contains unexpected items")
|
assert.Equal(t, 1, v.Estack().Len(), "stack contains unexpected items")
|
||||||
assertResult(t, v, result)
|
assertResult(t, v, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func evalWithArgs(t *testing.T, src string, op []byte, args []stackitem.Item, result interface{}) {
|
func evalWithArgs(t *testing.T, src string, op []byte, args []stackitem.Item, result any) {
|
||||||
vm := vmAndCompile(t, src)
|
vm := vmAndCompile(t, src)
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
vm.Estack().PushVal(args)
|
vm.Estack().PushVal(args)
|
||||||
|
@ -82,7 +82,7 @@ func evalWithArgs(t *testing.T, src string, op []byte, args []stackitem.Item, re
|
||||||
runAndCheck(t, vm, result)
|
runAndCheck(t, vm, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertResult(t *testing.T, vm *vm.VM, result interface{}) {
|
func assertResult(t *testing.T, vm *vm.VM, result any) {
|
||||||
assert.Equal(t, result, vm.PopResult())
|
assert.Equal(t, result, vm.PopResult())
|
||||||
assert.Nil(t, vm.Context())
|
assert.Nil(t, vm.Context())
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ func NewPayload(m netmode.Magic, stateRootEnabled bool) *Payload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) newPayload(c *dbft.Context, t payload.MessageType, msg interface{}) payload.ConsensusPayload {
|
func (s *service) newPayload(c *dbft.Context, t payload.MessageType, msg any) payload.ConsensusPayload {
|
||||||
cp := NewPayload(s.ProtocolConfiguration.Magic, s.ProtocolConfiguration.StateRootInHeader)
|
cp := NewPayload(s.ProtocolConfiguration.Magic, s.ProtocolConfiguration.StateRootInHeader)
|
||||||
cp.SetHeight(c.BlockIndex)
|
cp.SetHeight(c.BlockIndex)
|
||||||
cp.SetValidatorIndex(uint16(c.MyIndex))
|
cp.SetValidatorIndex(uint16(c.MyIndex))
|
||||||
|
|
|
@ -65,12 +65,12 @@ func (p *Payload) SetType(t payload.MessageType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Payload implements the payload.ConsensusPayload interface.
|
// Payload implements the payload.ConsensusPayload interface.
|
||||||
func (p Payload) Payload() interface{} {
|
func (p Payload) Payload() any {
|
||||||
return p.payload
|
return p.payload
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPayload implements the payload.ConsensusPayload interface.
|
// SetPayload implements the payload.ConsensusPayload interface.
|
||||||
func (p *Payload) SetPayload(pl interface{}) {
|
func (p *Payload) SetPayload(pl any) {
|
||||||
p.payload = pl.(io.Serializable)
|
p.payload = pl.(io.Serializable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func trim0x(value interface{}) string {
|
func trim0x(value any) string {
|
||||||
s := value.(string)
|
s := value.(string)
|
||||||
return strings.TrimPrefix(s, "0x")
|
return strings.TrimPrefix(s, "0x")
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,15 @@ func TestDecodeBlock1(t *testing.T) {
|
||||||
assert.Equal(t, trim0x(data["merkleroot"]), block.MerkleRoot.StringLE())
|
assert.Equal(t, trim0x(data["merkleroot"]), block.MerkleRoot.StringLE())
|
||||||
assert.Equal(t, trim0x(data["nextconsensus"]), address.Uint160ToString(block.NextConsensus))
|
assert.Equal(t, trim0x(data["nextconsensus"]), address.Uint160ToString(block.NextConsensus))
|
||||||
|
|
||||||
scripts := data["witnesses"].([]interface{})
|
scripts := data["witnesses"].([]any)
|
||||||
script := scripts[0].(map[string]interface{})
|
script := scripts[0].(map[string]any)
|
||||||
assert.Equal(t, script["invocation"].(string), base64.StdEncoding.EncodeToString(block.Script.InvocationScript))
|
assert.Equal(t, script["invocation"].(string), base64.StdEncoding.EncodeToString(block.Script.InvocationScript))
|
||||||
assert.Equal(t, script["verification"].(string), base64.StdEncoding.EncodeToString(block.Script.VerificationScript))
|
assert.Equal(t, script["verification"].(string), base64.StdEncoding.EncodeToString(block.Script.VerificationScript))
|
||||||
|
|
||||||
tx := data["tx"].([]interface{})
|
tx := data["tx"].([]any)
|
||||||
tx0 := tx[0].(map[string]interface{})
|
tx0 := tx[0].(map[string]any)
|
||||||
assert.Equal(t, len(tx), len(block.Transactions))
|
assert.Equal(t, len(tx), len(block.Transactions))
|
||||||
assert.Equal(t, len(tx0["attributes"].([]interface{})), len(block.Transactions[0].Attributes))
|
assert.Equal(t, len(tx0["attributes"].([]any)), len(block.Transactions[0].Attributes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTrimmedBlock(t *testing.T) {
|
func TestTrimmedBlock(t *testing.T) {
|
||||||
|
|
|
@ -24,12 +24,12 @@ func getDecodedBlock(t *testing.T, i int) *Block {
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBlockData(i int) (map[string]interface{}, error) {
|
func getBlockData(i int) (map[string]any, error) {
|
||||||
b, err := os.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
|
b, err := os.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var data map[string]interface{}
|
var data map[string]any
|
||||||
if err := json.Unmarshal(b, &data); err != nil {
|
if err := json.Unmarshal(b, &data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,8 +183,8 @@ type Blockchain struct {
|
||||||
|
|
||||||
// Notification subsystem.
|
// Notification subsystem.
|
||||||
events chan bcEvent
|
events chan bcEvent
|
||||||
subCh chan interface{}
|
subCh chan any
|
||||||
unsubCh chan interface{}
|
unsubCh chan any
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateRoot represents local state root module.
|
// StateRoot represents local state root module.
|
||||||
|
@ -312,8 +312,8 @@ func NewBlockchain(s storage.Store, cfg config.Blockchain, log *zap.Logger) (*Bl
|
||||||
memPool: mempool.New(cfg.MemPoolSize, 0, false),
|
memPool: mempool.New(cfg.MemPoolSize, 0, false),
|
||||||
log: log,
|
log: log,
|
||||||
events: make(chan bcEvent),
|
events: make(chan bcEvent),
|
||||||
subCh: make(chan interface{}),
|
subCh: make(chan any),
|
||||||
unsubCh: make(chan interface{}),
|
unsubCh: make(chan any),
|
||||||
contracts: *native.NewContracts(cfg.ProtocolConfiguration),
|
contracts: *native.NewContracts(cfg.ProtocolConfiguration),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2334,7 +2334,7 @@ var (
|
||||||
|
|
||||||
// verifyAndPoolTx verifies whether a transaction is bonafide or not and tries
|
// verifyAndPoolTx verifies whether a transaction is bonafide or not and tries
|
||||||
// to add it to the mempool given.
|
// to add it to the mempool given.
|
||||||
func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool.Pool, feer mempool.Feer, data ...interface{}) error {
|
func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool.Pool, feer mempool.Feer, data ...any) error {
|
||||||
// This code can technically be moved out of here, because it doesn't
|
// This code can technically be moved out of here, because it doesn't
|
||||||
// really require a chain lock.
|
// really require a chain lock.
|
||||||
err := vm.IsScriptCorrect(t.Script, nil)
|
err := vm.IsScriptCorrect(t.Script, nil)
|
||||||
|
@ -2552,7 +2552,7 @@ func (bc *Blockchain) PoolTx(t *transaction.Transaction, pools ...*mempool.Pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PoolTxWithData verifies and tries to add given transaction with additional data into the mempool.
|
// PoolTxWithData verifies and tries to add given transaction with additional data into the mempool.
|
||||||
func (bc *Blockchain) PoolTxWithData(t *transaction.Transaction, data interface{}, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(tx *transaction.Transaction, data interface{}) error) error {
|
func (bc *Blockchain) PoolTxWithData(t *transaction.Transaction, data any, mp *mempool.Pool, feer mempool.Feer, verificationFunction func(tx *transaction.Transaction, data any) error) error {
|
||||||
bc.lock.RLock()
|
bc.lock.RLock()
|
||||||
defer bc.lock.RUnlock()
|
defer bc.lock.RUnlock()
|
||||||
|
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ func TestBlockchain_MPTDeleteNoKey(t *testing.T) {
|
||||||
// native contract.
|
// native contract.
|
||||||
func TestConfigNativeUpdateHistory(t *testing.T) {
|
func TestConfigNativeUpdateHistory(t *testing.T) {
|
||||||
var prefixPath = filepath.Join("..", "..", "config")
|
var prefixPath = filepath.Join("..", "..", "config")
|
||||||
check := func(t *testing.T, cfgFileSuffix interface{}) {
|
check := func(t *testing.T, cfgFileSuffix any) {
|
||||||
cfgPath := filepath.Join(prefixPath, fmt.Sprintf("protocol.%s.yml", cfgFileSuffix))
|
cfgPath := filepath.Join(prefixPath, fmt.Sprintf("protocol.%s.yml", cfgFileSuffix))
|
||||||
cfg, err := config.LoadFile(cfgPath)
|
cfg, err := config.LoadFile(cfgPath)
|
||||||
require.NoError(t, err, fmt.Errorf("failed to load %s", cfgPath))
|
require.NoError(t, err, fmt.Errorf("failed to load %s", cfgPath))
|
||||||
|
@ -1038,7 +1038,7 @@ func TestConfigNativeUpdateHistory(t *testing.T) {
|
||||||
"edit the test if the contract should be disabled", cfgPath, c.Metadata().Name))
|
"edit the test if the contract should be disabled", cfgPath, c.Metadata().Name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
testCases := []interface{}{
|
testCases := []any{
|
||||||
netmode.MainNet,
|
netmode.MainNet,
|
||||||
netmode.PrivNet,
|
netmode.PrivNet,
|
||||||
netmode.TestNet,
|
netmode.TestNet,
|
||||||
|
@ -1390,7 +1390,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
checkErr(t, core.ErrInvalidAttribute, tx)
|
checkErr(t, core.ErrInvalidAttribute, tx)
|
||||||
})
|
})
|
||||||
|
|
||||||
keys := make([]interface{}, 0, len(oraclePubs))
|
keys := make([]any, 0, len(oraclePubs))
|
||||||
for _, p := range oraclePubs {
|
for _, p := range oraclePubs {
|
||||||
keys = append(keys, p.Bytes())
|
keys = append(keys, p.Bytes())
|
||||||
}
|
}
|
||||||
|
@ -1612,7 +1612,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
notary, err := wallet.NewAccount()
|
notary, err := wallet.NewAccount()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
designateSuperInvoker.Invoke(t, stackitem.Null{}, "designateAsRole",
|
designateSuperInvoker.Invoke(t, stackitem.Null{}, "designateAsRole",
|
||||||
int64(noderoles.P2PNotary), []interface{}{notary.PublicKey().Bytes()})
|
int64(noderoles.P2PNotary), []any{notary.PublicKey().Bytes()})
|
||||||
txSetNotary := transaction.New([]byte{byte(opcode.RET)}, 0)
|
txSetNotary := transaction.New([]byte{byte(opcode.RET)}, 0)
|
||||||
txSetNotary.Signers = []transaction.Signer{
|
txSetNotary.Signers = []transaction.Signer{
|
||||||
{
|
{
|
||||||
|
@ -1861,7 +1861,7 @@ func TestBlockchain_VerifyTx(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mp := mempool.New(10, 1, false)
|
mp := mempool.New(10, 1, false)
|
||||||
verificationF := func(tx *transaction.Transaction, data interface{}) error {
|
verificationF := func(tx *transaction.Transaction, data any) error {
|
||||||
if data.(int) > 5 {
|
if data.(int) > 5 {
|
||||||
return errors.New("bad data")
|
return errors.New("bad data")
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1909,7 @@ func TestBlockchain_Bug1728(t *testing.T) {
|
||||||
src := `package example
|
src := `package example
|
||||||
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
func init() { if true { } else { } }
|
func init() { if true { } else { } }
|
||||||
func _deploy(_ interface{}, isUpdate bool) {
|
func _deploy(_ any, isUpdate bool) {
|
||||||
runtime.Log("Deploy")
|
runtime.Log("Deploy")
|
||||||
}`
|
}`
|
||||||
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{Name: "TestContract"})
|
c := neotest.CompileSource(t, acc.ScriptHash(), strings.NewReader(src), &compiler.Options{Name: "TestContract"})
|
||||||
|
|
|
@ -63,7 +63,7 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
e := neotest.NewExecutor(t, bc, acc, acc)
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
createScript := func(t *testing.T, pubs []interface{}, m int) []byte {
|
createScript := func(t *testing.T, pubs []any, m int) []byte {
|
||||||
w.Reset()
|
w.Reset()
|
||||||
emit.Array(w.BinWriter, pubs...)
|
emit.Array(w.BinWriter, pubs...)
|
||||||
emit.Int(w.BinWriter, int64(m))
|
emit.Int(w.BinWriter, int64(m))
|
||||||
|
@ -74,7 +74,7 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
t.Run("Good", func(t *testing.T) {
|
t.Run("Good", func(t *testing.T) {
|
||||||
m, n := 3, 5
|
m, n := 3, 5
|
||||||
pubs := make(keys.PublicKeys, n)
|
pubs := make(keys.PublicKeys, n)
|
||||||
arr := make([]interface{}, n)
|
arr := make([]any, n)
|
||||||
for i := range pubs {
|
for i := range pubs {
|
||||||
pk, err := keys.NewPrivateKey()
|
pk, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -94,13 +94,13 @@ func TestCreateMultisigAccount(t *testing.T) {
|
||||||
require.Equal(t, hash.Hash160(expected), u)
|
require.Equal(t, hash.Hash160(expected), u)
|
||||||
})
|
})
|
||||||
t.Run("InvalidKey", func(t *testing.T) {
|
t.Run("InvalidKey", func(t *testing.T) {
|
||||||
script := createScript(t, []interface{}{[]byte{1, 2, 3}}, 1)
|
script := createScript(t, []any{[]byte{1, 2, 3}}, 1)
|
||||||
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "invalid prefix 1")
|
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "invalid prefix 1")
|
||||||
})
|
})
|
||||||
t.Run("Invalid m", func(t *testing.T) {
|
t.Run("Invalid m", func(t *testing.T) {
|
||||||
pk, err := keys.NewPrivateKey()
|
pk, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
script := createScript(t, []interface{}{pk.PublicKey().Bytes()}, 2)
|
script := createScript(t, []any{pk.PublicKey().Bytes()}, 2)
|
||||||
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "length of the signatures (2) is higher then the number of public keys")
|
e.InvokeScriptCheckFAULT(t, script, []neotest.Signer{acc}, "length of the signatures (2) is higher then the number of public keys")
|
||||||
})
|
})
|
||||||
t.Run("m overflows int32", func(t *testing.T) {
|
t.Run("m overflows int32", func(t *testing.T) {
|
||||||
|
@ -131,7 +131,7 @@ func TestCreateAccount_Hardfork(t *testing.T) {
|
||||||
pub := priv.PublicKey()
|
pub := priv.PublicKey()
|
||||||
|
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.Array(w.BinWriter, []interface{}{pub.Bytes(), pub.Bytes(), pub.Bytes()}...)
|
emit.Array(w.BinWriter, []any{pub.Bytes(), pub.Bytes(), pub.Bytes()}...)
|
||||||
emit.Int(w.BinWriter, int64(2))
|
emit.Int(w.BinWriter, int64(2))
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
|
emit.Syscall(w.BinWriter, interopnames.SystemContractCreateMultisigAccount)
|
||||||
require.NoError(t, w.Err)
|
require.NoError(t, w.Err)
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestCall(t *testing.T) {
|
||||||
require.Error(t, contract.Call(ic))
|
require.Error(t, contract.Call(ic))
|
||||||
})
|
})
|
||||||
|
|
||||||
runInvalid := func(args ...interface{}) func(t *testing.T) {
|
runInvalid := func(args ...any) func(t *testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
loadScriptWithHashAndFlags(ic, currScript, h, callflag.All, 42)
|
loadScriptWithHashAndFlags(ic, currScript, h, callflag.All, 42)
|
||||||
for i := range args {
|
for i := range args {
|
||||||
|
@ -591,7 +591,7 @@ func TestCALLL_from_VoidContext(t *testing.T) {
|
||||||
ctrInvoker.Invoke(t, stackitem.Null{}, "callHasRet")
|
ctrInvoker.Invoke(t, stackitem.Null{}, "callHasRet")
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadScript(ic *interop.Context, script []byte, args ...interface{}) {
|
func loadScript(ic *interop.Context, script []byte, args ...any) {
|
||||||
ic.SpawnVM()
|
ic.SpawnVM()
|
||||||
ic.VM.LoadScriptWithFlags(script, callflag.AllowCall)
|
ic.VM.LoadScriptWithFlags(script, callflag.AllowCall)
|
||||||
for i := range args {
|
for i := range args {
|
||||||
|
@ -600,7 +600,7 @@ func loadScript(ic *interop.Context, script []byte, args ...interface{}) {
|
||||||
ic.VM.GasLimit = -1
|
ic.VM.GasLimit = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadScriptWithHashAndFlags(ic *interop.Context, script []byte, hash util.Uint160, f callflag.CallFlag, args ...interface{}) {
|
func loadScriptWithHashAndFlags(ic *interop.Context, script []byte, hash util.Uint160, f callflag.CallFlag, args ...any) {
|
||||||
ic.SpawnVM()
|
ic.SpawnVM()
|
||||||
ic.VM.LoadScriptWithHash(script, hash, f)
|
ic.VM.LoadScriptWithHash(script, hash, f)
|
||||||
for i := range args {
|
for i := range args {
|
||||||
|
|
|
@ -180,7 +180,7 @@ func TestCheckSig(t *testing.T) {
|
||||||
verifyFunc := ECDSASecp256r1CheckSig
|
verifyFunc := ECDSASecp256r1CheckSig
|
||||||
d := dao.NewSimple(storage.NewMemoryStore(), false, false)
|
d := dao.NewSimple(storage.NewMemoryStore(), false, false)
|
||||||
ic := &interop.Context{Network: uint32(netmode.UnitTestNet), DAO: d}
|
ic := &interop.Context{Network: uint32(netmode.UnitTestNet), DAO: d}
|
||||||
runCase := func(t *testing.T, isErr bool, result interface{}, args ...interface{}) {
|
runCase := func(t *testing.T, isErr bool, result any, args ...any) {
|
||||||
ic.SpawnVM()
|
ic.SpawnVM()
|
||||||
for i := range args {
|
for i := range args {
|
||||||
ic.VM.Estack().PushVal(args[i])
|
ic.VM.Estack().PushVal(args[i])
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"go.uber.org/zap/zaptest"
|
"go.uber.org/zap/zaptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkStack(t *testing.T, v *vm.VM, args ...interface{}) {
|
func checkStack(t *testing.T, v *vm.VM, args ...any) {
|
||||||
require.Equal(t, len(args), v.Estack().Len())
|
require.Equal(t, len(args), v.Estack().Len())
|
||||||
for i := range args {
|
for i := range args {
|
||||||
require.Equal(t, stackitem.Make(args[i]), v.Estack().Pop().Item(), "%d", i)
|
require.Equal(t, stackitem.Make(args[i]), v.Estack().Pop().Item(), "%d", i)
|
||||||
|
@ -122,7 +122,7 @@ func TestLog(t *testing.T) {
|
||||||
ls := buf.Lines()
|
ls := buf.Lines()
|
||||||
require.Equal(t, 1, len(ls))
|
require.Equal(t, 1, len(ls))
|
||||||
|
|
||||||
var logMsg map[string]interface{}
|
var logMsg map[string]any
|
||||||
require.NoError(t, json.Unmarshal([]byte(ls[0]), &logMsg))
|
require.NoError(t, json.Unmarshal([]byte(ls[0]), &logMsg))
|
||||||
require.Equal(t, "info", logMsg["level"])
|
require.Equal(t, "info", logMsg["level"])
|
||||||
require.Equal(t, "hello", logMsg["msg"])
|
require.Equal(t, "hello", logMsg["msg"])
|
||||||
|
|
|
@ -71,7 +71,7 @@ func createVM(t testing.TB) (*vm.VM, *interop.Context, *core.Blockchain) {
|
||||||
return v, ic, chain
|
return v, ic, chain
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadScriptWithHashAndFlags(ic *interop.Context, script []byte, hash util.Uint160, f callflag.CallFlag, args ...interface{}) {
|
func loadScriptWithHashAndFlags(ic *interop.Context, script []byte, hash util.Uint160, f callflag.CallFlag, args ...any) {
|
||||||
ic.SpawnVM()
|
ic.SpawnVM()
|
||||||
ic.VM.LoadScriptWithHash(script, hash, f)
|
ic.VM.LoadScriptWithHash(script, hash, f)
|
||||||
for i := range args {
|
for i := range args {
|
||||||
|
@ -80,7 +80,7 @@ func loadScriptWithHashAndFlags(ic *interop.Context, script []byte, hash util.Ui
|
||||||
ic.VM.GasLimit = -1
|
ic.VM.GasLimit = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrapDynamicScript(t *testing.T, script []byte, flags callflag.CallFlag, args ...interface{}) []byte {
|
func wrapDynamicScript(t *testing.T, script []byte, flags callflag.CallFlag, args ...any) []byte {
|
||||||
b := io.NewBufBinWriter()
|
b := io.NewBufBinWriter()
|
||||||
|
|
||||||
// Params.
|
// Params.
|
||||||
|
@ -150,7 +150,7 @@ func TestCheckWitness(t *testing.T) {
|
||||||
|
|
||||||
script := []byte{byte(opcode.RET)}
|
script := []byte{byte(opcode.RET)}
|
||||||
scriptHash := hash.Hash160(script)
|
scriptHash := hash.Hash160(script)
|
||||||
check := func(t *testing.T, ic *interop.Context, arg interface{}, shouldFail bool, expected ...bool) {
|
check := func(t *testing.T, ic *interop.Context, arg any, shouldFail bool, expected ...bool) {
|
||||||
ic.VM.Estack().PushVal(arg)
|
ic.VM.Estack().PushVal(arg)
|
||||||
err := runtime.CheckWitness(ic)
|
err := runtime.CheckWitness(ic)
|
||||||
if shouldFail {
|
if shouldFail {
|
||||||
|
@ -632,7 +632,7 @@ func TestGetRandomCompatibility(t *testing.T) {
|
||||||
|
|
||||||
func TestNotify(t *testing.T) {
|
func TestNotify(t *testing.T) {
|
||||||
caller := random.Uint160()
|
caller := random.Uint160()
|
||||||
newIC := func(name string, args interface{}) *interop.Context {
|
newIC := func(name string, args any) *interop.Context {
|
||||||
_, _, bc, cs := getDeployedInternal(t)
|
_, _, bc, cs := getDeployedInternal(t)
|
||||||
ic, err := bc.GetTestVM(trigger.Application, nil, nil)
|
ic, err := bc.GetTestVM(trigger.Application, nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUnexpectedNonInterops(t *testing.T) {
|
func TestUnexpectedNonInterops(t *testing.T) {
|
||||||
vals := map[string]interface{}{
|
vals := map[string]any{
|
||||||
"int": 1,
|
"int": 1,
|
||||||
"bool": false,
|
"bool": false,
|
||||||
"string": "smth",
|
"string": "smth",
|
||||||
|
|
|
@ -41,7 +41,7 @@ var (
|
||||||
type item struct {
|
type item struct {
|
||||||
txn *transaction.Transaction
|
txn *transaction.Transaction
|
||||||
blockStamp uint32
|
blockStamp uint32
|
||||||
data interface{}
|
data any
|
||||||
}
|
}
|
||||||
|
|
||||||
// items is a slice of an item.
|
// items is a slice of an item.
|
||||||
|
@ -70,7 +70,7 @@ type Pool struct {
|
||||||
payerIndex int
|
payerIndex int
|
||||||
|
|
||||||
resendThreshold uint32
|
resendThreshold uint32
|
||||||
resendFunc func(*transaction.Transaction, interface{})
|
resendFunc func(*transaction.Transaction, any)
|
||||||
|
|
||||||
// subscriptions for mempool events
|
// subscriptions for mempool events
|
||||||
subscriptionsEnabled bool
|
subscriptionsEnabled bool
|
||||||
|
@ -197,7 +197,7 @@ func checkBalance(tx *transaction.Transaction, balance utilityBalanceAndFees) (u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add tries to add the given transaction to the Pool.
|
// Add tries to add the given transaction to the Pool.
|
||||||
func (mp *Pool) Add(t *transaction.Transaction, fee Feer, data ...interface{}) error {
|
func (mp *Pool) Add(t *transaction.Transaction, fee Feer, data ...any) error {
|
||||||
var pItem = item{
|
var pItem = item{
|
||||||
txn: t,
|
txn: t,
|
||||||
blockStamp: fee.BlockHeight(),
|
blockStamp: fee.BlockHeight(),
|
||||||
|
@ -441,7 +441,7 @@ func New(capacity int, payerIndex int, enableSubscriptions bool) *Pool {
|
||||||
|
|
||||||
// SetResendThreshold sets a threshold after which the transaction will be considered stale
|
// SetResendThreshold sets a threshold after which the transaction will be considered stale
|
||||||
// and returned for retransmission by `GetStaleTransactions`.
|
// and returned for retransmission by `GetStaleTransactions`.
|
||||||
func (mp *Pool) SetResendThreshold(h uint32, f func(*transaction.Transaction, interface{})) {
|
func (mp *Pool) SetResendThreshold(h uint32, f func(*transaction.Transaction, any)) {
|
||||||
mp.lock.Lock()
|
mp.lock.Lock()
|
||||||
defer mp.lock.Unlock()
|
defer mp.lock.Unlock()
|
||||||
mp.resendThreshold = h
|
mp.resendThreshold = h
|
||||||
|
@ -466,7 +466,7 @@ func (mp *Pool) TryGetValue(hash util.Uint256) (*transaction.Transaction, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TryGetData returns data associated with the specified transaction if it exists in the memory pool.
|
// TryGetData returns data associated with the specified transaction if it exists in the memory pool.
|
||||||
func (mp *Pool) TryGetData(hash util.Uint256) (interface{}, bool) {
|
func (mp *Pool) TryGetData(hash util.Uint256) (any, bool) {
|
||||||
mp.lock.RLock()
|
mp.lock.RLock()
|
||||||
defer mp.lock.RUnlock()
|
defer mp.lock.RUnlock()
|
||||||
if tx, ok := mp.verifiedMap[hash]; ok {
|
if tx, ok := mp.verifiedMap[hash]; ok {
|
||||||
|
|
|
@ -76,7 +76,7 @@ func TestMemPoolRemoveStale(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
staleTxs := make(chan *transaction.Transaction, 5)
|
staleTxs := make(chan *transaction.Transaction, 5)
|
||||||
f := func(tx *transaction.Transaction, _ interface{}) {
|
f := func(tx *transaction.Transaction, _ any) {
|
||||||
staleTxs <- tx
|
staleTxs <- tx
|
||||||
}
|
}
|
||||||
mp.SetResendThreshold(5, f)
|
mp.SetResendThreshold(5, f)
|
||||||
|
|
|
@ -21,7 +21,7 @@ const (
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Type Type
|
Type Type
|
||||||
Tx *transaction.Transaction
|
Tx *transaction.Transaction
|
||||||
Data interface{}
|
Data any
|
||||||
}
|
}
|
||||||
|
|
||||||
// String is a Stringer implementation.
|
// String is a Stringer implementation.
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (e EmptyNode) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalJSON implements Node interface.
|
// UnmarshalJSON implements Node interface.
|
||||||
func (e EmptyNode) UnmarshalJSON(bytes []byte) error {
|
func (e EmptyNode) UnmarshalJSON(bytes []byte) error {
|
||||||
var m map[string]interface{}
|
var m map[string]any
|
||||||
err := json.Unmarshal(bytes, &m)
|
err := json.Unmarshal(bytes, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (e *ExtensionNode) Size() int {
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler.
|
// MarshalJSON implements the json.Marshaler.
|
||||||
func (e *ExtensionNode) MarshalJSON() ([]byte, error) {
|
func (e *ExtensionNode) MarshalJSON() ([]byte, error) {
|
||||||
m := map[string]interface{}{
|
m := map[string]any{
|
||||||
"key": hex.EncodeToString(e.key),
|
"key": hex.EncodeToString(e.key),
|
||||||
"next": e.next,
|
"next": e.next,
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func testECDSAVerify(t *testing.T, curve NamedCurve) {
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
runCase := func(t *testing.T, isErr bool, result interface{}, args ...interface{}) {
|
runCase := func(t *testing.T, isErr bool, result any, args ...any) {
|
||||||
argsArr := make([]stackitem.Item, len(args))
|
argsArr := make([]stackitem.Item, len(args))
|
||||||
for i := range args {
|
for i := range args {
|
||||||
argsArr[i] = stackitem.Make(args[i])
|
argsArr[i] = stackitem.Make(args[i])
|
||||||
|
|
|
@ -113,7 +113,7 @@ func testGetSetCache(t *testing.T, c *neotest.ContractInvoker, name string, defa
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNodesByRole(t *testing.T, designateInvoker *neotest.ContractInvoker, ok bool, r noderoles.Role, nodes keys.PublicKeys) {
|
func setNodesByRole(t *testing.T, designateInvoker *neotest.ContractInvoker, ok bool, r noderoles.Role, nodes keys.PublicKeys) {
|
||||||
pubs := make([]interface{}, len(nodes))
|
pubs := make([]any, len(nodes))
|
||||||
for i := range nodes {
|
for i := range nodes {
|
||||||
pubs[i] = nodes[i].Bytes()
|
pubs[i] = nodes[i].Bytes()
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,11 +106,11 @@ func TestDesignate_Cache(t *testing.T) {
|
||||||
}
|
}
|
||||||
privGood, err := keys.NewPrivateKey()
|
privGood, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
pubsGood := []interface{}{privGood.PublicKey().Bytes()}
|
pubsGood := []any{privGood.PublicKey().Bytes()}
|
||||||
|
|
||||||
privBad, err := keys.NewPrivateKey()
|
privBad, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
pubsBad := []interface{}{privBad.PublicKey().Bytes()}
|
pubsBad := []any{privBad.PublicKey().Bytes()}
|
||||||
|
|
||||||
// Firstly, designate good Oracle node and check that OracleService callback was called during PostPersist.
|
// Firstly, designate good Oracle node and check that OracleService callback was called during PostPersist.
|
||||||
e.Chain.SetOracle(oracleServ)
|
e.Chain.SetOracle(oracleServ)
|
||||||
|
|
|
@ -78,7 +78,7 @@ func TestGAS_RewardWithP2PSigExtensionsEnabled(t *testing.T) {
|
||||||
|
|
||||||
// set Notary nodes and check their balance
|
// set Notary nodes and check their balance
|
||||||
notaryNodes := make([]*keys.PrivateKey, nNotaries)
|
notaryNodes := make([]*keys.PrivateKey, nNotaries)
|
||||||
notaryNodesPublicKeys := make([]interface{}, nNotaries)
|
notaryNodesPublicKeys := make([]any, nNotaries)
|
||||||
var err error
|
var err error
|
||||||
for i := range notaryNodes {
|
for i := range notaryNodes {
|
||||||
notaryNodes[i], err = keys.NewPrivateKey()
|
notaryNodes[i], err = keys.NewPrivateKey()
|
||||||
|
@ -92,7 +92,7 @@ func TestGAS_RewardWithP2PSigExtensionsEnabled(t *testing.T) {
|
||||||
|
|
||||||
// deposit GAS for `signer` with lock until the next block
|
// deposit GAS for `signer` with lock until the next block
|
||||||
depositAmount := 100_0000 + (2+int64(nKeys))*notaryServiceFeePerKey // sysfee + netfee of the next transaction
|
depositAmount := 100_0000 + (2+int64(nKeys))*notaryServiceFeePerKey // sysfee + netfee of the next transaction
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", e.CommitteeHash, notaryHash, depositAmount, []interface{}{e.CommitteeHash, e.Chain.BlockHeight() + 1})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", e.CommitteeHash, notaryHash, depositAmount, []any{e.CommitteeHash, e.Chain.BlockHeight() + 1})
|
||||||
|
|
||||||
// save initial GAS total supply
|
// save initial GAS total supply
|
||||||
getGASTS := func(t *testing.T) int64 {
|
getGASTS := func(t *testing.T) int64 {
|
||||||
|
|
|
@ -98,7 +98,7 @@ func TestManagement_ContractDeploy(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid NEF file", "deploy", []byte{}, manifestBytes)
|
managementInvoker.InvokeFail(t, "invalid NEF file", "deploy", []byte{}, manifestBytes)
|
||||||
})
|
})
|
||||||
t.Run("array for NEF", func(t *testing.T) {
|
t.Run("array for NEF", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid NEF file", "deploy", []interface{}{int64(1)}, manifestBytes)
|
managementInvoker.InvokeFail(t, "invalid NEF file", "deploy", []any{int64(1)}, manifestBytes)
|
||||||
})
|
})
|
||||||
t.Run("bad script in NEF", func(t *testing.T) {
|
t.Run("bad script in NEF", func(t *testing.T) {
|
||||||
nf, err := nef.FileFromBytes(nefBytes) // make a full copy
|
nf, err := nef.FileFromBytes(nefBytes) // make a full copy
|
||||||
|
@ -116,7 +116,7 @@ func TestManagement_ContractDeploy(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid manifest", "deploy", nefBytes, []byte{})
|
managementInvoker.InvokeFail(t, "invalid manifest", "deploy", nefBytes, []byte{})
|
||||||
})
|
})
|
||||||
t.Run("array for manifest", func(t *testing.T) {
|
t.Run("array for manifest", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid manifest", "deploy", nefBytes, []interface{}{int64(1)})
|
managementInvoker.InvokeFail(t, "invalid manifest", "deploy", nefBytes, []any{int64(1)})
|
||||||
})
|
})
|
||||||
t.Run("non-utf8 manifest", func(t *testing.T) {
|
t.Run("non-utf8 manifest", func(t *testing.T) {
|
||||||
manifestBad := bytes.Replace(manifestBytes, []byte("TestMain"), []byte("\xff\xfe\xfd"), 1) // Replace name.
|
manifestBad := bytes.Replace(manifestBytes, []byte("TestMain"), []byte("\xff\xfe\xfd"), 1) // Replace name.
|
||||||
|
@ -549,7 +549,7 @@ func TestManagement_GetContract(t *testing.T) {
|
||||||
managementInvoker.Invoke(t, si, "deploy", nefBytes, manifestBytes)
|
managementInvoker.Invoke(t, si, "deploy", nefBytes, manifestBytes)
|
||||||
|
|
||||||
t.Run("bad parameter type", func(t *testing.T) {
|
t.Run("bad parameter type", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid conversion: Array/ByteString", "getContract", []interface{}{int64(1)})
|
managementInvoker.InvokeFail(t, "invalid conversion: Array/ByteString", "getContract", []any{int64(1)})
|
||||||
})
|
})
|
||||||
t.Run("not a hash", func(t *testing.T) {
|
t.Run("not a hash", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "expected byte size of 20 got 3", "getContract", []byte{1, 2, 3})
|
managementInvoker.InvokeFail(t, "expected byte size of 20 got 3", "getContract", []byte{1, 2, 3})
|
||||||
|
@ -558,7 +558,7 @@ func TestManagement_GetContract(t *testing.T) {
|
||||||
managementInvoker.Invoke(t, si, "getContract", cs1.Hash.BytesBE())
|
managementInvoker.Invoke(t, si, "getContract", cs1.Hash.BytesBE())
|
||||||
})
|
})
|
||||||
t.Run("by ID, bad parameter type", func(t *testing.T) {
|
t.Run("by ID, bad parameter type", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "invalid conversion: Array/Integer", "getContractById", []interface{}{int64(1)})
|
managementInvoker.InvokeFail(t, "invalid conversion: Array/Integer", "getContractById", []any{int64(1)})
|
||||||
})
|
})
|
||||||
t.Run("by ID, bad num", func(t *testing.T) {
|
t.Run("by ID, bad num", func(t *testing.T) {
|
||||||
managementInvoker.InvokeFail(t, "id is not a correct int32", "getContractById", []byte{1, 2, 3, 4, 5})
|
managementInvoker.InvokeFail(t, "id is not a correct int32", "getContractById", []byte{1, 2, 3, 4, 5})
|
||||||
|
|
|
@ -75,19 +75,19 @@ func TestNotary_Pipeline(t *testing.T) {
|
||||||
notaryCommitteeInvoker.Invoke(t, false, "lockDepositUntil", multisigHash, int64(depositLock+1))
|
notaryCommitteeInvoker.Invoke(t, false, "lockDepositUntil", multisigHash, int64(depositLock+1))
|
||||||
|
|
||||||
// `onPayment`: bad token
|
// `onPayment`: bad token
|
||||||
neoCommitteeInvoker.InvokeFail(t, "only GAS can be accepted for deposit", "transfer", multisigHash, notaryHash, int64(1), []interface{}{nil, int64(depositLock)})
|
neoCommitteeInvoker.InvokeFail(t, "only GAS can be accepted for deposit", "transfer", multisigHash, notaryHash, int64(1), []any{nil, int64(depositLock)})
|
||||||
|
|
||||||
// `onPayment`: insufficient first deposit
|
// `onPayment`: insufficient first deposit
|
||||||
gasCommitteeInvoker.InvokeFail(t, "first deposit can not be less then", "transfer", multisigHash, notaryHash, int64(2*feePerKey-1), []interface{}{nil, int64(depositLock)})
|
gasCommitteeInvoker.InvokeFail(t, "first deposit can not be less then", "transfer", multisigHash, notaryHash, int64(2*feePerKey-1), []any{nil, int64(depositLock)})
|
||||||
|
|
||||||
// `onPayment`: invalid `data` (missing `till` parameter)
|
// `onPayment`: invalid `data` (missing `till` parameter)
|
||||||
gasCommitteeInvoker.InvokeFail(t, "`data` parameter should be an array of 2 elements", "transfer", multisigHash, notaryHash, 2*feePerKey, []interface{}{nil})
|
gasCommitteeInvoker.InvokeFail(t, "`data` parameter should be an array of 2 elements", "transfer", multisigHash, notaryHash, 2*feePerKey, []any{nil})
|
||||||
|
|
||||||
// `onPayment`: invalid `data` (outdated `till` parameter)
|
// `onPayment`: invalid `data` (outdated `till` parameter)
|
||||||
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the chain's height", "transfer", multisigHash, notaryHash, 2*feePerKey, []interface{}{nil, int64(0)})
|
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the chain's height", "transfer", multisigHash, notaryHash, 2*feePerKey, []any{nil, int64(0)})
|
||||||
|
|
||||||
// `onPayment`: good
|
// `onPayment`: good
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, 2*feePerKey, []interface{}{nil, int64(depositLock)})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, 2*feePerKey, []any{nil, int64(depositLock)})
|
||||||
checkBalanceOf(t, notaryHash, 2*feePerKey)
|
checkBalanceOf(t, notaryHash, 2*feePerKey)
|
||||||
|
|
||||||
// `expirationOf`: check `till` was set
|
// `expirationOf`: check `till` was set
|
||||||
|
@ -97,7 +97,7 @@ func TestNotary_Pipeline(t *testing.T) {
|
||||||
notaryCommitteeInvoker.Invoke(t, 2*feePerKey, "balanceOf", multisigHash)
|
notaryCommitteeInvoker.Invoke(t, 2*feePerKey, "balanceOf", multisigHash)
|
||||||
|
|
||||||
// `onPayment`: good second deposit and explicit `to` paramenter
|
// `onPayment`: good second deposit and explicit `to` paramenter
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, feePerKey, []interface{}{multisigHash, int64(depositLock + 1)})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, feePerKey, []any{multisigHash, int64(depositLock + 1)})
|
||||||
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
||||||
|
|
||||||
// `balanceOf`: check deposited amount for the multisig account
|
// `balanceOf`: check deposited amount for the multisig account
|
||||||
|
@ -107,17 +107,17 @@ func TestNotary_Pipeline(t *testing.T) {
|
||||||
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
||||||
|
|
||||||
// `onPayment`: empty payment, should fail because `till` less then the previous one
|
// `onPayment`: empty payment, should fail because `till` less then the previous one
|
||||||
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the previous value", "transfer", multisigHash, notaryHash, int64(0), []interface{}{multisigHash, int64(depositLock)})
|
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the previous value", "transfer", multisigHash, notaryHash, int64(0), []any{multisigHash, int64(depositLock)})
|
||||||
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
||||||
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
||||||
|
|
||||||
// `onPayment`: empty payment, should fail because `till` less then the chain height
|
// `onPayment`: empty payment, should fail because `till` less then the chain height
|
||||||
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the chain's height", "transfer", multisigHash, notaryHash, int64(0), []interface{}{multisigHash, int64(1)})
|
gasCommitteeInvoker.InvokeFail(t, "`till` shouldn't be less then the chain's height", "transfer", multisigHash, notaryHash, int64(0), []any{multisigHash, int64(1)})
|
||||||
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
||||||
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
notaryCommitteeInvoker.Invoke(t, depositLock+1, "expirationOf", multisigHash)
|
||||||
|
|
||||||
// `onPayment`: empty payment, should successfully update `till`
|
// `onPayment`: empty payment, should successfully update `till`
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, int64(0), []interface{}{multisigHash, int64(depositLock + 2)})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, int64(0), []any{multisigHash, int64(depositLock + 2)})
|
||||||
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
||||||
notaryCommitteeInvoker.Invoke(t, depositLock+2, "expirationOf", multisigHash)
|
notaryCommitteeInvoker.Invoke(t, depositLock+2, "expirationOf", multisigHash)
|
||||||
|
|
||||||
|
@ -159,12 +159,12 @@ func TestNotary_Pipeline(t *testing.T) {
|
||||||
notaryCommitteeInvoker.Invoke(t, false, "withdraw", multisigHash, accHash)
|
notaryCommitteeInvoker.Invoke(t, false, "withdraw", multisigHash, accHash)
|
||||||
|
|
||||||
// `onPayment`: good first deposit to other account, should set default `till` even if other `till` value is provided
|
// `onPayment`: good first deposit to other account, should set default `till` even if other `till` value is provided
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, 2*feePerKey, []interface{}{accHash, int64(math.MaxUint32 - 1)})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, 2*feePerKey, []any{accHash, int64(math.MaxUint32 - 1)})
|
||||||
checkBalanceOf(t, notaryHash, 2*feePerKey)
|
checkBalanceOf(t, notaryHash, 2*feePerKey)
|
||||||
notaryCommitteeInvoker.Invoke(t, 5760+e.Chain.BlockHeight()-1, "expirationOf", accHash)
|
notaryCommitteeInvoker.Invoke(t, 5760+e.Chain.BlockHeight()-1, "expirationOf", accHash)
|
||||||
|
|
||||||
// `onPayment`: good second deposit to other account, shouldn't update `till` even if other `till` value is provided
|
// `onPayment`: good second deposit to other account, shouldn't update `till` even if other `till` value is provided
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, feePerKey, []interface{}{accHash, int64(math.MaxUint32 - 1)})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, feePerKey, []any{accHash, int64(math.MaxUint32 - 1)})
|
||||||
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
checkBalanceOf(t, notaryHash, 3*feePerKey)
|
||||||
notaryCommitteeInvoker.Invoke(t, 5760+e.Chain.BlockHeight()-3, "expirationOf", accHash)
|
notaryCommitteeInvoker.Invoke(t, 5760+e.Chain.BlockHeight()-3, "expirationOf", accHash)
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ func TestNotary_NotaryNodesReward(t *testing.T) {
|
||||||
|
|
||||||
// set Notary nodes and check their balance
|
// set Notary nodes and check their balance
|
||||||
notaryNodes := make([]*keys.PrivateKey, nNotaryNodes)
|
notaryNodes := make([]*keys.PrivateKey, nNotaryNodes)
|
||||||
notaryNodesPublicKeys := make([]interface{}, nNotaryNodes)
|
notaryNodesPublicKeys := make([]any, nNotaryNodes)
|
||||||
for i := range notaryNodes {
|
for i := range notaryNodes {
|
||||||
notaryNodes[i], err = keys.NewPrivateKey()
|
notaryNodes[i], err = keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -201,7 +201,7 @@ func TestNotary_NotaryNodesReward(t *testing.T) {
|
||||||
if !spendFullDeposit {
|
if !spendFullDeposit {
|
||||||
depositAmount += 1_0000
|
depositAmount += 1_0000
|
||||||
}
|
}
|
||||||
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, depositAmount, []interface{}{multisigHash, e.Chain.BlockHeight() + 1})
|
gasCommitteeInvoker.Invoke(t, true, "transfer", multisigHash, notaryHash, depositAmount, []any{multisigHash, e.Chain.BlockHeight() + 1})
|
||||||
|
|
||||||
// send transaction with Notary contract as a sender
|
// send transaction with Notary contract as a sender
|
||||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1_000_000)
|
||||||
|
|
|
@ -36,7 +36,7 @@ func TestOracle_GetSetPriceCache(t *testing.T) {
|
||||||
|
|
||||||
func putOracleRequest(t *testing.T, oracleInvoker *neotest.ContractInvoker,
|
func putOracleRequest(t *testing.T, oracleInvoker *neotest.ContractInvoker,
|
||||||
url string, filter *string, cb string, userData []byte, gas int64, errStr ...string) {
|
url string, filter *string, cb string, userData []byte, gas int64, errStr ...string) {
|
||||||
var filtItem interface{}
|
var filtItem any
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
filtItem = *filter
|
filtItem = *filter
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func TestOracle_Request(t *testing.T) {
|
||||||
|
|
||||||
// Designate single Oracle node.
|
// Designate single Oracle node.
|
||||||
oracleNode := e.NewAccount(t)
|
oracleNode := e.NewAccount(t)
|
||||||
designationCommitteeInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int(noderoles.Oracle), []interface{}{oracleNode.(neotest.SingleSigner).Account().PublicKey().Bytes()})
|
designationCommitteeInvoker.Invoke(t, stackitem.Null{}, "designateAsRole", int(noderoles.Oracle), []any{oracleNode.(neotest.SingleSigner).Account().PublicKey().Bytes()})
|
||||||
err = oracleNode.(neotest.SingleSigner).Account().ConvertMultisig(1, []*keys.PublicKey{oracleNode.(neotest.SingleSigner).Account().PublicKey()})
|
err = oracleNode.(neotest.SingleSigner).Account().ConvertMultisig(1, []*keys.PublicKey{oracleNode.(neotest.SingleSigner).Account().PublicKey()})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
oracleNodeMulti := neotest.NewMultiSigner(oracleNode.(neotest.SingleSigner).Account())
|
oracleNodeMulti := neotest.NewMultiSigner(oracleNode.(neotest.SingleSigner).Account())
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getInvalidTestFunc(actual stackitem.Convertible, value interface{}) func(t *testing.T) {
|
func getInvalidTestFunc(actual stackitem.Convertible, value any) func(t *testing.T) {
|
||||||
return func(t *testing.T) {
|
return func(t *testing.T) {
|
||||||
it := stackitem.Make(value)
|
it := stackitem.Make(value)
|
||||||
require.Error(t, actual.FromStackItem(it))
|
require.Error(t, actual.FromStackItem(it))
|
||||||
|
|
|
@ -306,7 +306,7 @@ func TestStdLibSerializeDeserialize(t *testing.T) {
|
||||||
ic := &interop.Context{VM: vm.New(), DAO: &dao.Simple{}}
|
ic := &interop.Context{VM: vm.New(), DAO: &dao.Simple{}}
|
||||||
var actual stackitem.Item
|
var actual stackitem.Item
|
||||||
|
|
||||||
checkSerializeDeserialize := func(t *testing.T, value interface{}, expected stackitem.Item) {
|
checkSerializeDeserialize := func(t *testing.T, value any, expected stackitem.Item) {
|
||||||
require.NotPanics(t, func() {
|
require.NotPanics(t, func() {
|
||||||
actual = s.serialize(ic, []stackitem.Item{stackitem.Make(value)})
|
actual = s.serialize(ic, []stackitem.Item{stackitem.Make(value)})
|
||||||
})
|
})
|
||||||
|
@ -427,7 +427,7 @@ func TestMemorySearch(t *testing.T) {
|
||||||
s := newStd()
|
s := newStd()
|
||||||
ic := &interop.Context{VM: vm.New()}
|
ic := &interop.Context{VM: vm.New()}
|
||||||
|
|
||||||
check := func(t *testing.T, result int64, args ...interface{}) {
|
check := func(t *testing.T, result int64, args ...any) {
|
||||||
items := make([]stackitem.Item, len(args))
|
items := make([]stackitem.Item, len(args))
|
||||||
for i := range args {
|
for i := range args {
|
||||||
items[i] = stackitem.Make(args[i])
|
items[i] = stackitem.Make(args[i])
|
||||||
|
@ -519,7 +519,7 @@ func TestStringSplit(t *testing.T) {
|
||||||
s := newStd()
|
s := newStd()
|
||||||
ic := &interop.Context{VM: vm.New()}
|
ic := &interop.Context{VM: vm.New()}
|
||||||
|
|
||||||
check := func(t *testing.T, result []string, str, sep string, remove interface{}) {
|
check := func(t *testing.T, result []string, str, sep string, remove any) {
|
||||||
args := []stackitem.Item{stackitem.Make(str), stackitem.Make(sep)}
|
args := []stackitem.Item{stackitem.Make(str), stackitem.Make(sep)}
|
||||||
var actual stackitem.Item
|
var actual stackitem.Item
|
||||||
if remove == nil {
|
if remove == nil {
|
||||||
|
|
|
@ -17,7 +17,7 @@ type Attribute struct {
|
||||||
// Anonymous interface fields are not considered anonymous by
|
// Anonymous interface fields are not considered anonymous by
|
||||||
// json lib and marshaling Value together with type makes code
|
// json lib and marshaling Value together with type makes code
|
||||||
// harder to follow.
|
// harder to follow.
|
||||||
toJSONMap(map[string]interface{})
|
toJSONMap(map[string]any)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (attr *Attribute) EncodeBinary(bw *io.BinWriter) {
|
||||||
|
|
||||||
// MarshalJSON implements the json Marshaller interface.
|
// MarshalJSON implements the json Marshaller interface.
|
||||||
func (attr *Attribute) MarshalJSON() ([]byte, error) {
|
func (attr *Attribute) MarshalJSON() ([]byte, error) {
|
||||||
m := map[string]interface{}{"type": attr.Type.String()}
|
m := map[string]any{"type": attr.Type.String()}
|
||||||
if attr.Value != nil {
|
if attr.Value != nil {
|
||||||
attr.Value.toJSONMap(m)
|
attr.Value.toJSONMap(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ func (c *Conflicts) EncodeBinary(w *io.BinWriter) {
|
||||||
c.Hash.EncodeBinary(w)
|
c.Hash.EncodeBinary(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conflicts) toJSONMap(m map[string]interface{}) {
|
func (c *Conflicts) toJSONMap(m map[string]any) {
|
||||||
m["hash"] = c.Hash
|
m["hash"] = c.Hash
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@ func (n *NotValidBefore) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteU32LE(n.Height)
|
w.WriteU32LE(n.Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NotValidBefore) toJSONMap(m map[string]interface{}) {
|
func (n *NotValidBefore) toJSONMap(m map[string]any) {
|
||||||
m["height"] = n.Height
|
m["height"] = n.Height
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@ func (n *NotaryAssisted) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteB(n.NKeys)
|
w.WriteB(n.NKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NotaryAssisted) toJSONMap(m map[string]interface{}) {
|
func (n *NotaryAssisted) toJSONMap(m map[string]any) {
|
||||||
m["nkeys"] = n.NKeys
|
m["nkeys"] = n.NKeys
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ func (r *OracleResponse) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteVarBytes(r.Result)
|
w.WriteVarBytes(r.Result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OracleResponse) toJSONMap(m map[string]interface{}) {
|
func (r *OracleResponse) toJSONMap(m map[string]any) {
|
||||||
m["id"] = r.ID
|
m["id"] = r.ID
|
||||||
m["code"] = r.Code
|
m["code"] = r.Code
|
||||||
m["result"] = r.Result
|
m["result"] = r.Result
|
||||||
|
|
|
@ -68,7 +68,7 @@ func TestOracleResponse_toJSONMap(t *testing.T) {
|
||||||
b1, err := json.Marshal(r)
|
b1, err := json.Marshal(r)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
m := map[string]interface{}{}
|
m := map[string]any{}
|
||||||
r.toJSONMap(m)
|
r.toJSONMap(m)
|
||||||
b2, err := json.Marshal(m)
|
b2, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -19,6 +19,6 @@ func (e *Reserved) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteVarBytes(e.Value)
|
w.WriteVarBytes(e.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Reserved) toJSONMap(m map[string]interface{}) {
|
func (e *Reserved) toJSONMap(m map[string]any) {
|
||||||
m["value"] = e.Value
|
m["value"] = e.Value
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,7 +631,7 @@ func unmarshalConditionJSON(data []byte, maxDepth int) (WitnessCondition, error)
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func condToStackItem(typ WitnessConditionType, c interface{}) stackitem.Item {
|
func condToStackItem(typ WitnessConditionType, c any) stackitem.Item {
|
||||||
res := make([]stackitem.Item, 0, 2)
|
res := make([]stackitem.Item, 0, 2)
|
||||||
res = append(res, stackitem.NewBigInteger(big.NewInt(int64(typ))))
|
res = append(res, stackitem.NewBigInteger(big.NewInt(int64(typ))))
|
||||||
switch typ {
|
switch typ {
|
||||||
|
|
|
@ -181,7 +181,7 @@ func (p *PublicKey) UncompressedBytes() []byte {
|
||||||
func NewPublicKeyFromASN1(data []byte) (*PublicKey, error) {
|
func NewPublicKeyFromASN1(data []byte) (*PublicKey, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
pubkey interface{}
|
pubkey any
|
||||||
)
|
)
|
||||||
if pubkey, err = x509.ParsePKIXPublicKey(data); err != nil {
|
if pubkey, err = x509.ParsePKIXPublicKey(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (f *Fixed8) UnmarshalJSON(data []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML implements the yaml unmarshaler interface.
|
// UnmarshalYAML implements the yaml unmarshaler interface.
|
||||||
func (f *Fixed8) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (f *Fixed8) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
var s string
|
var s string
|
||||||
err := unmarshal(&s)
|
err := unmarshal(&s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -109,7 +109,7 @@ func (f Fixed8) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalYAML implements the yaml marshaller interface.
|
// MarshalYAML implements the yaml marshaller interface.
|
||||||
func (f Fixed8) MarshalYAML() (interface{}, error) {
|
func (f Fixed8) MarshalYAML() (any, error) {
|
||||||
return f.String(), nil
|
return f.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,6 @@ func GetCallFlags() CallFlag {
|
||||||
// (20 bytes in BE form) using the provided arguments and call flags.
|
// (20 bytes in BE form) using the provided arguments and call flags.
|
||||||
// It returns whatever this contract returns. This function uses
|
// It returns whatever this contract returns. This function uses
|
||||||
// `System.Contract.Call` syscall.
|
// `System.Contract.Call` syscall.
|
||||||
func Call(scriptHash interop.Hash160, method string, f CallFlag, args ...interface{}) interface{} {
|
func Call(scriptHash interop.Hash160, method string, f CallFlag, args ...any) any {
|
||||||
return neogointernal.Syscall4("System.Contract.Call", scriptHash, method, f, args)
|
return neogointernal.Syscall4("System.Contract.Call", scriptHash, method, f, args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
package convert
|
package convert
|
||||||
|
|
||||||
// ToInteger converts it's argument to an Integer.
|
// ToInteger converts it's argument to an Integer.
|
||||||
func ToInteger(v interface{}) int {
|
func ToInteger(v any) int {
|
||||||
return v.(int)
|
return v.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToBytes converts it's argument to a Buffer VM type.
|
// ToBytes converts it's argument to a Buffer VM type.
|
||||||
func ToBytes(v interface{}) []byte {
|
func ToBytes(v any) []byte {
|
||||||
return v.([]byte)
|
return v.([]byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToString converts it's argument to a ByteString VM type.
|
// ToString converts it's argument to a ByteString VM type.
|
||||||
func ToString(v interface{}) string {
|
func ToString(v any) string {
|
||||||
return v.(string)
|
return v.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToBool converts it's argument to a Boolean.
|
// ToBool converts it's argument to a Boolean.
|
||||||
func ToBool(v interface{}) bool {
|
func ToBool(v any) bool {
|
||||||
return v.(bool)
|
return v.(bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ correspond to smartcontract and VM types:
|
||||||
[]byte - ByteArray (Buffer in VM)
|
[]byte - ByteArray (Buffer in VM)
|
||||||
string - String (ByteString in VM)
|
string - String (ByteString in VM)
|
||||||
(interface{})(nil) - Any
|
(interface{})(nil) - Any
|
||||||
|
(any)(nil) - Any
|
||||||
non-byte slice - Array
|
non-byte slice - Array
|
||||||
map[K]V - map
|
map[K]V - map
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,6 @@ func Next(it Iterator) bool {
|
||||||
// For slices, the result is just value.
|
// For slices, the result is just value.
|
||||||
// For maps, the result can be cast to a slice of 2 elements: a key and a value.
|
// For maps, the result can be cast to a slice of 2 elements: a key and a value.
|
||||||
// For storage iterators, refer to `storage.FindFlags` documentation.
|
// For storage iterators, refer to `storage.FindFlags` documentation.
|
||||||
func Value(it Iterator) interface{} {
|
func Value(it Iterator) any {
|
||||||
return neogointernal.Syscall1("System.Iterator.Value", it)
|
return neogointernal.Syscall1("System.Iterator.Value", it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
// (20 bytes in BE form) using the provided arguments and call flags. It fails
|
// (20 bytes in BE form) using the provided arguments and call flags. It fails
|
||||||
// if the contract has version mismatch. It returns whatever this contract
|
// if the contract has version mismatch. It returns whatever this contract
|
||||||
// returns. This function uses `System.Contract.Call` syscall.
|
// returns. This function uses `System.Contract.Call` syscall.
|
||||||
func CallWithVersion(scriptHash interop.Hash160, version int, method string, f contract.CallFlag, args ...interface{}) interface{} {
|
func CallWithVersion(scriptHash interop.Hash160, version int, method string, f contract.CallFlag, args ...any) any {
|
||||||
cs := management.GetContract(scriptHash)
|
cs := management.GetContract(scriptHash)
|
||||||
if cs == nil {
|
if cs == nil {
|
||||||
panic("unknown contract")
|
panic("unknown contract")
|
||||||
|
|
|
@ -34,7 +34,7 @@ func BalanceOf(addr interop.Hash160) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer represents `transfer` method of GAS native contract.
|
// Transfer represents `transfer` method of GAS native contract.
|
||||||
func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
func Transfer(from, to interop.Hash160, amount int, data any) bool {
|
||||||
return neogointernal.CallWithToken(Hash, "transfer",
|
return neogointernal.CallWithToken(Hash, "transfer",
|
||||||
int(contract.All), from, to, amount, data).(bool)
|
int(contract.All), from, to, amount, data).(bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,5 +51,5 @@ type BlockSR struct {
|
||||||
|
|
||||||
// ToBlockSR converts Block into BlockSR for chains with StateRootInHeader option.
|
// ToBlockSR converts Block into BlockSR for chains with StateRootInHeader option.
|
||||||
func (b *Block) ToBlockSR() *BlockSR {
|
func (b *Block) ToBlockSR() *BlockSR {
|
||||||
return interface{}(b).(*BlockSR)
|
return any(b).(*BlockSR)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func CurrentIndex() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlock represents `getBlock` method of Ledger native contract.
|
// GetBlock represents `getBlock` method of Ledger native contract.
|
||||||
func GetBlock(indexOrHash interface{}) *Block {
|
func GetBlock(indexOrHash any) *Block {
|
||||||
return neogointernal.CallWithToken(Hash, "getBlock", int(contract.ReadStates), indexOrHash).(*Block)
|
return neogointernal.CallWithToken(Hash, "getBlock", int(contract.ReadStates), indexOrHash).(*Block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func GetTransactionHeight(hash interop.Hash256) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTransactionFromBlock represents `getTransactionFromBlock` method of Ledger native contract.
|
// GetTransactionFromBlock represents `getTransactionFromBlock` method of Ledger native contract.
|
||||||
func GetTransactionFromBlock(indexOrHash interface{}, txIndex int) *Transaction {
|
func GetTransactionFromBlock(indexOrHash any, txIndex int) *Transaction {
|
||||||
return neogointernal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates),
|
return neogointernal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates),
|
||||||
indexOrHash, txIndex).(*Transaction)
|
indexOrHash, txIndex).(*Transaction)
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ type WitnessCondition struct {
|
||||||
// WitnessCalledByContract -> interop.Hash160
|
// WitnessCalledByContract -> interop.Hash160
|
||||||
// WitnessCalledByGroup -> interop.PublicKey
|
// WitnessCalledByGroup -> interop.PublicKey
|
||||||
// WitnessCalledByEntry -> doesn't have value, thus, an attempt to access the Value leads to runtime exception.
|
// WitnessCalledByEntry -> doesn't have value, thus, an attempt to access the Value leads to runtime exception.
|
||||||
Value interface{}
|
Value any
|
||||||
}
|
}
|
||||||
|
|
||||||
// WitnessConditionType represents the type of rule-based witness condition.
|
// WitnessConditionType represents the type of rule-based witness condition.
|
||||||
|
|
|
@ -40,7 +40,7 @@ type Manifest struct {
|
||||||
ABI ABI
|
ABI ABI
|
||||||
Permissions []Permission
|
Permissions []Permission
|
||||||
Trusts []interop.Hash160
|
Trusts []interop.Hash160
|
||||||
Extra interface{}
|
Extra any
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABI represents contract's ABI.
|
// ABI represents contract's ABI.
|
||||||
|
|
|
@ -29,7 +29,7 @@ func Deploy(script, manifest []byte) *Contract {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeployWithData represents `deploy` method of Management native contract.
|
// DeployWithData represents `deploy` method of Management native contract.
|
||||||
func DeployWithData(script, manifest []byte, data interface{}) *Contract {
|
func DeployWithData(script, manifest []byte, data any) *Contract {
|
||||||
return neogointernal.CallWithToken(Hash, "deploy",
|
return neogointernal.CallWithToken(Hash, "deploy",
|
||||||
int(contract.All), script, manifest, data).(*Contract)
|
int(contract.All), script, manifest, data).(*Contract)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func Update(script, manifest []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateWithData represents `update` method of Management native contract.
|
// UpdateWithData represents `update` method of Management native contract.
|
||||||
func UpdateWithData(script, manifest []byte, data interface{}) {
|
func UpdateWithData(script, manifest []byte, data any) {
|
||||||
neogointernal.CallWithTokenNoRet(Hash, "update",
|
neogointernal.CallWithTokenNoRet(Hash, "update",
|
||||||
int(contract.All), script, manifest, data)
|
int(contract.All), script, manifest, data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func BalanceOf(addr interop.Hash160) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer represents `transfer` method of NEO native contract.
|
// Transfer represents `transfer` method of NEO native contract.
|
||||||
func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
func Transfer(from, to interop.Hash160, amount int, data any) bool {
|
||||||
return neogointernal.CallWithToken(Hash, "transfer",
|
return neogointernal.CallWithToken(Hash, "transfer",
|
||||||
int(contract.All), from, to, amount, data).(bool)
|
int(contract.All), from, to, amount, data).(bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ const MinimumResponseGas = 10_000_000
|
||||||
// of the same contract that invokes Request and it must have the following
|
// of the same contract that invokes Request and it must have the following
|
||||||
// signature for correct invocation:
|
// signature for correct invocation:
|
||||||
//
|
//
|
||||||
// - Method(url string, userData interface{}, code int, result []byte)
|
// - Method(url string, userData any, code int, result []byte)
|
||||||
// where url is the same url specified for Request, userData is anything
|
// where url is the same url specified for Request, userData is anything
|
||||||
// passed in the next parameter, code is the status of the reply and
|
// passed in the next parameter, code is the status of the reply and
|
||||||
// result is the data returned from the request if any.
|
// result is the data returned from the request if any.
|
||||||
|
@ -64,7 +64,7 @@ const MinimumResponseGas = 10_000_000
|
||||||
// GAS is used for oracle transaction's network and system fees,
|
// GAS is used for oracle transaction's network and system fees,
|
||||||
// so it should be enough to pay for reply data as well as
|
// so it should be enough to pay for reply data as well as
|
||||||
// its processing.
|
// its processing.
|
||||||
func Request(url string, filter []byte, cb string, userData interface{}, gasForResponse int) {
|
func Request(url string, filter []byte, cb string, userData any, gasForResponse int) {
|
||||||
neogointernal.CallWithTokenNoRet(Hash, "request",
|
neogointernal.CallWithTokenNoRet(Hash, "request",
|
||||||
int(contract.States|contract.AllowNotify),
|
int(contract.States|contract.AllowNotify),
|
||||||
url, filter, cb, userData, gasForResponse)
|
url, filter, cb, userData, gasForResponse)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue