rpcbinding: fix wrappers for Any type, fix #2898
This commit is contained in:
parent
1bdd62702c
commit
b1e7f40226
4 changed files with 16 additions and 2 deletions
2
cli/smartcontract/testdata/types/config.yml
vendored
2
cli/smartcontract/testdata/types/config.yml
vendored
|
@ -1,3 +1,3 @@
|
|||
name: "Types"
|
||||
sourceurl: https://github.com/nspcc-dev/neo-go/
|
||||
safemethods: ["bool", "int", "bytes", "string", "hash160", "hash256", "publicKey", "signature", "bools", "ints", "bytess", "strings", "hash160s", "hash256s", "publicKeys", "signatures", "aAAStrings", "maps", "crazyMaps"]
|
||||
safemethods: ["bool", "int", "bytes", "string", "any", "hash160", "hash256", "publicKey", "signature", "bools", "ints", "bytess", "strings", "hash160s", "hash256s", "publicKeys", "signatures", "aAAStrings", "maps", "crazyMaps"]
|
||||
|
|
10
cli/smartcontract/testdata/types/rpcbindings.out
vendored
10
cli/smartcontract/testdata/types/rpcbindings.out
vendored
|
@ -90,6 +90,16 @@ func (c *ContractReader) AAAStrings(s [][][]string) ([][][]string, error) {
|
|||
} (unwrap.Item(c.invoker.Call(Hash, "aAAStrings", s)))
|
||||
}
|
||||
|
||||
// Any invokes `any` method of contract.
|
||||
func (c *ContractReader) Any(a interface{}) (interface{}, error) {
|
||||
return func (item stackitem.Item, err error) (interface{}, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return item.Value(), nil
|
||||
} (unwrap.Item(c.invoker.Call(Hash, "any", a)))
|
||||
}
|
||||
|
||||
// Bool invokes `bool` method of contract.
|
||||
func (c *ContractReader) Bool(b bool) (bool, error) {
|
||||
return unwrap.Bool(c.invoker.Call(Hash, "bool", b))
|
||||
|
|
4
cli/smartcontract/testdata/types/types.go
vendored
4
cli/smartcontract/testdata/types/types.go
vendored
|
@ -20,6 +20,10 @@ func String(s string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func Any(a interface{}) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Hash160(h interop.Hash160) interop.Hash160 {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ func scTemplateToRPC(cfg binding.Config, ctr ContractTmpl, imports map[string]st
|
|||
ctr.HasIterator = true
|
||||
} else {
|
||||
imports["github.com/nspcc-dev/neo-go/pkg/vm/stackitem"] = struct{}{}
|
||||
ctr.SafeMethods[i].ReturnType = "stackitem.Item"
|
||||
ctr.SafeMethods[i].ReturnType = "interface{}"
|
||||
ctr.SafeMethods[i].Unwrapper = "Item"
|
||||
}
|
||||
case "bool":
|
||||
|
|
Loading…
Reference in a new issue