mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-29 19:27:36 +00:00
194933a5cc
Unfortunately Go doesn't allow to easily reuse readers in full packages, still we can have this wrapper with a little overhead (the alternative is to move specific methods into types of their own, but I'm not sure how it's going to be accepted user-side).
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package nep11
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
)
|
|
|
|
// NonDivisibleReader is a reader interface for non-divisble NEP-11 contract.
|
|
type NonDivisibleReader struct {
|
|
BaseReader
|
|
}
|
|
|
|
// NonDivisible is a state-changing interface for non-divisble NEP-11 contract.
|
|
type NonDivisible struct {
|
|
Base
|
|
}
|
|
|
|
// NewNonDivisibleReader creates an instance of NonDivisibleReader for a contract
|
|
// with the given hash using the given invoker.
|
|
func NewNonDivisibleReader(invoker Invoker, hash util.Uint160) *NonDivisibleReader {
|
|
return &NonDivisibleReader{*NewBaseReader(invoker, hash)}
|
|
}
|
|
|
|
// NewNonDivisible creates an instance of NonDivisible for a contract
|
|
// with the given hash using the given actor.
|
|
func NewNonDivisible(actor Actor, hash util.Uint160) *NonDivisible {
|
|
return &NonDivisible{*NewBase(actor, hash)}
|
|
}
|
|
|
|
// OwnerOf returns the owner of the given NFT.
|
|
func (t *NonDivisibleReader) OwnerOf(token []byte) (util.Uint160, error) {
|
|
return unwrap.Uint160(t.invoker.Call(t.hash, "ownerOf", token))
|
|
}
|
|
|
|
// OwnerOf is the same as (*NonDivisibleReader).OwnerOf.
|
|
func (t *NonDivisible) OwnerOf(token []byte) (util.Uint160, error) {
|
|
r := NonDivisibleReader{t.BaseReader}
|
|
return r.OwnerOf(token)
|
|
}
|