-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3560 from nspcc-dev/nep24
manifest: support NEP-24
- Loading branch information
Showing
25 changed files
with
1,750 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
cli/smartcontract/testdata/rpcbindings/nft-d/rpcbindings.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT. | ||
|
||
// Package nft contains RPC wrappers for NeoFS Object NFT contract. | ||
package nft | ||
|
||
import ( | ||
"github.com/nspcc-dev/neo-go/pkg/core/transaction" | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11" | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep24" | ||
"github.com/nspcc-dev/neo-go/pkg/smartcontract" | ||
"github.com/nspcc-dev/neo-go/pkg/util" | ||
) | ||
|
||
// Hash contains contract hash. | ||
var Hash = util.Uint160{0x33, 0x22, 0x11, 0x0, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x0} | ||
|
||
// Invoker is used by ContractReader to call various safe methods. | ||
type Invoker interface { | ||
nep11.Invoker | ||
} | ||
|
||
// Actor is used by Contract to call state-changing methods. | ||
type Actor interface { | ||
Invoker | ||
|
||
nep11.Actor | ||
|
||
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error) | ||
MakeRun(script []byte) (*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) | ||
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error) | ||
SendRun(script []byte) (util.Uint256, uint32, error) | ||
} | ||
|
||
// ContractReader implements safe contract methods. | ||
type ContractReader struct { | ||
nep11.DivisibleReader | ||
nep24.RoyaltyReader | ||
invoker Invoker | ||
hash util.Uint160 | ||
} | ||
|
||
// Contract implements all contract methods. | ||
type Contract struct { | ||
ContractReader | ||
nep11.DivisibleWriter | ||
actor Actor | ||
hash util.Uint160 | ||
} | ||
|
||
// NewReader creates an instance of ContractReader using Hash and the given Invoker. | ||
func NewReader(invoker Invoker) *ContractReader { | ||
var hash = Hash | ||
return &ContractReader{*nep11.NewDivisibleReader(invoker, hash), *nep24.NewRoyaltyReader(invoker, hash), invoker, hash} | ||
} | ||
|
||
// New creates an instance of Contract using Hash and the given Actor. | ||
func New(actor Actor) *Contract { | ||
var hash = Hash | ||
var nep11dt = nep11.NewDivisible(actor, hash) | ||
var nep24t = nep24.NewRoyaltyReader(actor, hash) | ||
return &Contract{ContractReader{nep11dt.DivisibleReader, *nep24t, actor, hash}, nep11dt.DivisibleWriter, actor, hash} | ||
} | ||
|
||
// Destroy creates a transaction invoking `destroy` 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) Destroy() (util.Uint256, uint32, error) { | ||
return c.actor.SendCall(c.hash, "destroy") | ||
} | ||
|
||
// DestroyTransaction creates a transaction invoking `destroy` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) DestroyTransaction() (*transaction.Transaction, error) { | ||
return c.actor.MakeCall(c.hash, "destroy") | ||
} | ||
|
||
// DestroyUnsigned creates a transaction invoking `destroy` 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) DestroyUnsigned() (*transaction.Transaction, error) { | ||
return c.actor.MakeUnsignedCall(c.hash, "destroy", nil) | ||
} | ||
|
||
// Update creates a transaction invoking `update` 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) Update(nef []byte, manifest []byte) (util.Uint256, uint32, error) { | ||
return c.actor.SendCall(c.hash, "update", nef, manifest) | ||
} | ||
|
||
// UpdateTransaction creates a transaction invoking `update` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) UpdateTransaction(nef []byte, manifest []byte) (*transaction.Transaction, error) { | ||
return c.actor.MakeCall(c.hash, "update", nef, manifest) | ||
} | ||
|
||
// UpdateUnsigned creates a transaction invoking `update` 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) UpdateUnsigned(nef []byte, manifest []byte) (*transaction.Transaction, error) { | ||
return c.actor.MakeUnsignedCall(c.hash, "update", nil, nef, manifest) | ||
} | ||
|
||
func (c *Contract) scriptForVerify() ([]byte, error) { | ||
return smartcontract.CreateCallWithAssertScript(c.hash, "verify") | ||
} | ||
|
||
// Verify creates a transaction invoking `verify` 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) Verify() (util.Uint256, uint32, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return util.Uint256{}, 0, err | ||
} | ||
return c.actor.SendRun(script) | ||
} | ||
|
||
// VerifyTransaction creates a transaction invoking `verify` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) VerifyTransaction() (*transaction.Transaction, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c.actor.MakeRun(script) | ||
} | ||
|
||
// VerifyUnsigned creates a transaction invoking `verify` 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) VerifyUnsigned() (*transaction.Transaction, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c.actor.MakeUnsignedRun(script, nil) | ||
} |
141 changes: 141 additions & 0 deletions
141
cli/smartcontract/testdata/rpcbindings/nft-d/rpcbindings_dynamic_hash.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT. | ||
|
||
// Package nft contains RPC wrappers for NeoFS Object NFT contract. | ||
package nft | ||
|
||
import ( | ||
"github.com/nspcc-dev/neo-go/pkg/core/transaction" | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11" | ||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep24" | ||
"github.com/nspcc-dev/neo-go/pkg/smartcontract" | ||
"github.com/nspcc-dev/neo-go/pkg/util" | ||
) | ||
|
||
// Invoker is used by ContractReader to call various safe methods. | ||
type Invoker interface { | ||
nep11.Invoker | ||
} | ||
|
||
// Actor is used by Contract to call state-changing methods. | ||
type Actor interface { | ||
Invoker | ||
|
||
nep11.Actor | ||
|
||
MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error) | ||
MakeRun(script []byte) (*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) | ||
SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error) | ||
SendRun(script []byte) (util.Uint256, uint32, error) | ||
} | ||
|
||
// ContractReader implements safe contract methods. | ||
type ContractReader struct { | ||
nep11.DivisibleReader | ||
nep24.RoyaltyReader | ||
invoker Invoker | ||
hash util.Uint160 | ||
} | ||
|
||
// Contract implements all contract methods. | ||
type Contract struct { | ||
ContractReader | ||
nep11.DivisibleWriter | ||
actor Actor | ||
hash util.Uint160 | ||
} | ||
|
||
// NewReader creates an instance of ContractReader using provided contract hash and the given Invoker. | ||
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader { | ||
return &ContractReader{*nep11.NewDivisibleReader(invoker, hash), *nep24.NewRoyaltyReader(invoker, hash), invoker, hash} | ||
} | ||
|
||
// New creates an instance of Contract using provided contract hash and the given Actor. | ||
func New(actor Actor, hash util.Uint160) *Contract { | ||
var nep11dt = nep11.NewDivisible(actor, hash) | ||
var nep24t = nep24.NewRoyaltyReader(actor, hash) | ||
return &Contract{ContractReader{nep11dt.DivisibleReader, *nep24t, actor, hash}, nep11dt.DivisibleWriter, actor, hash} | ||
} | ||
|
||
// Destroy creates a transaction invoking `destroy` 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) Destroy() (util.Uint256, uint32, error) { | ||
return c.actor.SendCall(c.hash, "destroy") | ||
} | ||
|
||
// DestroyTransaction creates a transaction invoking `destroy` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) DestroyTransaction() (*transaction.Transaction, error) { | ||
return c.actor.MakeCall(c.hash, "destroy") | ||
} | ||
|
||
// DestroyUnsigned creates a transaction invoking `destroy` 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) DestroyUnsigned() (*transaction.Transaction, error) { | ||
return c.actor.MakeUnsignedCall(c.hash, "destroy", nil) | ||
} | ||
|
||
// Update creates a transaction invoking `update` 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) Update(nef []byte, manifest []byte) (util.Uint256, uint32, error) { | ||
return c.actor.SendCall(c.hash, "update", nef, manifest) | ||
} | ||
|
||
// UpdateTransaction creates a transaction invoking `update` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) UpdateTransaction(nef []byte, manifest []byte) (*transaction.Transaction, error) { | ||
return c.actor.MakeCall(c.hash, "update", nef, manifest) | ||
} | ||
|
||
// UpdateUnsigned creates a transaction invoking `update` 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) UpdateUnsigned(nef []byte, manifest []byte) (*transaction.Transaction, error) { | ||
return c.actor.MakeUnsignedCall(c.hash, "update", nil, nef, manifest) | ||
} | ||
|
||
func (c *Contract) scriptForVerify() ([]byte, error) { | ||
return smartcontract.CreateCallWithAssertScript(c.hash, "verify") | ||
} | ||
|
||
// Verify creates a transaction invoking `verify` 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) Verify() (util.Uint256, uint32, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return util.Uint256{}, 0, err | ||
} | ||
return c.actor.SendRun(script) | ||
} | ||
|
||
// VerifyTransaction creates a transaction invoking `verify` method of the contract. | ||
// This transaction is signed, but not sent to the network, instead it's | ||
// returned to the caller. | ||
func (c *Contract) VerifyTransaction() (*transaction.Transaction, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c.actor.MakeRun(script) | ||
} | ||
|
||
// VerifyUnsigned creates a transaction invoking `verify` 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) VerifyUnsigned() (*transaction.Transaction, error) { | ||
script, err := c.scriptForVerify() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return c.actor.MakeUnsignedRun(script, nil) | ||
} |
Oops, something went wrong.