diff --git a/cli/smartcontract/generate_test.go b/cli/smartcontract/generate_test.go index df595f83f..b6a1bf253 100644 --- a/cli/smartcontract/generate_test.go +++ b/cli/smartcontract/generate_test.go @@ -357,7 +357,7 @@ func TestGenerateRPCBindings(t *testing.T) { checkBinding(filepath.Join("testdata", "gas", "gas.manifest.json"), "0xd2a4cff31913016155e38e474a2c06d08be276cf", filepath.Join("testdata", "gas", "gas.go")) - checkBinding(filepath.Join("testdata", "verify.manifest.json"), + checkBinding(filepath.Join("testdata", "verifyrpc", "verify.manifest.json"), "0x00112233445566778899aabbccddeeff00112233", filepath.Join("testdata", "verifyrpc", "verify.go")) } diff --git a/cli/smartcontract/testdata/verifyrpc/verify.go b/cli/smartcontract/testdata/verifyrpc/verify.go index 0725c3836..8b8f07961 100644 --- a/cli/smartcontract/testdata/verifyrpc/verify.go +++ b/cli/smartcontract/testdata/verifyrpc/verify.go @@ -5,7 +5,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" - "math/big" ) // Hash contains contract hash. @@ -69,25 +68,3 @@ func (c *Contract) VerifyUnsigned() (*transaction.Transaction, error) { } return c.actor.MakeUnsignedRun(script, nil) } - -// OnNEP17Payment creates a transaction invoking `onNEP17Payment` method of the contract. -// This transaction is signed and immediately sent to the network. -// The values returned are its hash, ValidUntilBlock value and error if any. -func (c *Contract) OnNEP17Payment(from []byte, amount *big.Int, data interface{}) (util.Uint256, uint32, error) { - return c.actor.SendCall(Hash, "onNEP17Payment", from, amount, data) -} - -// OnNEP17PaymentTransaction creates a transaction invoking `onNEP17Payment` method of the contract. -// This transaction is signed, but not sent to the network, instead it's -// returned to the caller. -func (c *Contract) OnNEP17PaymentTransaction(from []byte, amount *big.Int, data interface{}) (*transaction.Transaction, error) { - return c.actor.MakeCall(Hash, "onNEP17Payment", from, amount, data) -} - -// OnNEP17PaymentUnsigned creates a transaction invoking `onNEP17Payment` method of the contract. -// 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, -// Nonce), fee values (NetworkFee, SystemFee) can be increased as well. -func (c *Contract) OnNEP17PaymentUnsigned(from []byte, amount *big.Int, data interface{}) (*transaction.Transaction, error) { - return c.actor.MakeUnsignedCall(Hash, "onNEP17Payment", nil, from, amount, data) -} diff --git a/cli/smartcontract/testdata/verifyrpc/verify.manifest.json b/cli/smartcontract/testdata/verifyrpc/verify.manifest.json new file mode 100755 index 000000000..8b70f752b --- /dev/null +++ b/cli/smartcontract/testdata/verifyrpc/verify.manifest.json @@ -0,0 +1,79 @@ +{ + "groups" : [], + "extra" : null, + "supportedstandards" : [], + "name" : "verify", + "trusts" : [], + "permissions" : [ + { + "methods" : "*", + "contract" : "*" + } + ], + "abi" : { + "methods" : [ + { + "safe" : false, + "offset" : 0, + "parameters" : [], + "name" : "verify", + "returntype" : "Boolean" + }, + { + "returntype" : "Void", + "safe" : false, + "offset" : 5, + "parameters" : [ + { + "type" : "Hash160", + "name" : "from" + }, + { + "type" : "Integer", + "name" : "amount" + }, + { + "type" : "Any", + "name" : "data" + } + ], + "name" : "onNEP17Payment" + }, + { + "returntype" : "Void", + "safe" : false, + "offset" : 5, + "parameters" : [ + { + "type" : "Hash160", + "name" : "from" + }, + { + "type" : "Integer", + "name" : "amount" + }, + { + "type" : "ByteArray", + "name" : "tokenid" + }, + { + "type" : "Any", + "name" : "data" + } + ], + "name" : "onNEP11Payment" + } + ], + "events" : [ + { + "parameters" : [ + { + "type" : "Array", + "name" : "args" + } + ], + "name" : "Hello world!" + } + ] + } +} diff --git a/pkg/smartcontract/rpcbinding/binding.go b/pkg/smartcontract/rpcbinding/binding.go index 93b6266b9..d3e9bb507 100644 --- a/pkg/smartcontract/rpcbinding/binding.go +++ b/pkg/smartcontract/rpcbinding/binding.go @@ -238,6 +238,14 @@ func Generate(cfg binding.Config) error { } } + // OnNepXXPayment handlers normally can't be called directly. + if standard.ComplyABI(cfg.Manifest, standard.Nep11Payable) == nil { + mfst.ABI.Methods = dropStdMethods(mfst.ABI.Methods, standard.Nep11Payable) + } + if standard.ComplyABI(cfg.Manifest, standard.Nep17Payable) == nil { + mfst.ABI.Methods = dropStdMethods(mfst.ABI.Methods, standard.Nep17Payable) + } + bctr, err := binding.TemplateFromManifest(cfg, scTypeToGo) if err != nil { return err