mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
rpcbinding: exclude onNEPXXPayment methods from wrappers
They make no sense there.
This commit is contained in:
parent
130608ac67
commit
69d8905ad9
4 changed files with 88 additions and 24 deletions
|
@ -357,7 +357,7 @@ func TestGenerateRPCBindings(t *testing.T) {
|
||||||
checkBinding(filepath.Join("testdata", "gas", "gas.manifest.json"),
|
checkBinding(filepath.Join("testdata", "gas", "gas.manifest.json"),
|
||||||
"0xd2a4cff31913016155e38e474a2c06d08be276cf",
|
"0xd2a4cff31913016155e38e474a2c06d08be276cf",
|
||||||
filepath.Join("testdata", "gas", "gas.go"))
|
filepath.Join("testdata", "gas", "gas.go"))
|
||||||
checkBinding(filepath.Join("testdata", "verify.manifest.json"),
|
checkBinding(filepath.Join("testdata", "verifyrpc", "verify.manifest.json"),
|
||||||
"0x00112233445566778899aabbccddeeff00112233",
|
"0x00112233445566778899aabbccddeeff00112233",
|
||||||
filepath.Join("testdata", "verifyrpc", "verify.go"))
|
filepath.Join("testdata", "verifyrpc", "verify.go"))
|
||||||
}
|
}
|
||||||
|
|
23
cli/smartcontract/testdata/verifyrpc/verify.go
vendored
23
cli/smartcontract/testdata/verifyrpc/verify.go
vendored
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"math/big"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hash contains contract hash.
|
// Hash contains contract hash.
|
||||||
|
@ -69,25 +68,3 @@ func (c *Contract) VerifyUnsigned() (*transaction.Transaction, error) {
|
||||||
}
|
}
|
||||||
return c.actor.MakeUnsignedRun(script, nil)
|
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)
|
|
||||||
}
|
|
||||||
|
|
79
cli/smartcontract/testdata/verifyrpc/verify.manifest.json
vendored
Executable file
79
cli/smartcontract/testdata/verifyrpc/verify.manifest.json
vendored
Executable file
|
@ -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!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -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)
|
bctr, err := binding.TemplateFromManifest(cfg, scTypeToGo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue