nns

package
v0.105.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package nns provide some RPC wrappers for the non-native NNS contract.

It's not yet a complete interface because there are different NNS versions available, yet it provides the most widely used ones that were available from the old RPC client API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContractReader added in v0.99.3

type ContractReader struct {
	nep11.NonDivisibleReader
	// contains filtered or unexported fields
}

ContractReader provides an interface to call read-only NNS contract methods.

func NewReader added in v0.99.3

func NewReader(invoker Invoker, hash util.Uint160) *ContractReader

NewReader creates an instance of ContractReader that can be used to read data from the contract.

func (*ContractReader) GetAllRecords added in v0.99.3

func (c *ContractReader) GetAllRecords(name string) (*RecordIterator, error)

GetAllRecords returns an iterator that allows to retrieve all RecordState items for the given domain name. It depends on the server to provide proper session-based iterator, but can also work with expanded one.

func (*ContractReader) GetAllRecordsExpanded added in v0.99.3

func (c *ContractReader) GetAllRecordsExpanded(name string, num int) ([]RecordState, error)

GetAllRecordsExpanded is similar to GetAllRecords (uses the same NNS method), but can be useful if the server used doesn't support sessions and doesn't expand iterators. It creates a script that will get num of result items from the iterator right in the VM and return them to you. It's only limited by VM stack and GAS available for RPC invocations.

func (*ContractReader) GetPrice added in v0.99.3

func (c *ContractReader) GetPrice() (int64, error)

GetPrice returns current domain registration price in GAS.

func (*ContractReader) IsAvailable added in v0.99.3

func (c *ContractReader) IsAvailable(name string) (bool, error)

IsAvailable checks whether the domain given is available for registration.

func (*ContractReader) Resolve added in v0.99.3

func (c *ContractReader) Resolve(name string, typ RecordType) (string, error)

Resolve resolves the given record type for the given domain (with no more than three redirects).

type Invoker added in v0.99.3

type Invoker interface {
	nep11.Invoker
}

Invoker is used by ContractReader to call various methods.

type RecordIterator added in v0.99.3

type RecordIterator struct {
	// contains filtered or unexported fields
}

RecordIterator is used for iterating over GetAllRecords results.

func (*RecordIterator) Next added in v0.99.3

func (r *RecordIterator) Next(num int) ([]RecordState, error)

Next returns the next set of elements from the iterator (up to num of them). It can return less than num elements in case iterator doesn't have that many or zero elements if the iterator has no more elements or the session is expired.

func (*RecordIterator) Terminate added in v0.99.3

func (r *RecordIterator) Terminate() error

Terminate closes the iterator session used by RecordIterator (if it's session-based).

type RecordState

type RecordState struct {
	Name string
	Type RecordType
	Data string
}

RecordState is a type that registered entities are saved as.

func (*RecordState) FromStackItem added in v0.99.3

func (r *RecordState) FromStackItem(itm stackitem.Item) error

FromStackItem fills RecordState with data from the given stack item if it can be correctly converted to RecordState.

type RecordType

type RecordType byte

RecordType is domain name service record types.

const (
	// A represents address record type.
	A RecordType = 1
	// CNAME represents canonical name record type.
	CNAME RecordType = 5
	// TXT represents text record type.
	TXT RecordType = 16
)

Record types are defined in [RFC 1035](https://tools.ietf.org/html/rfc1035)

const (
	// AAAA represents IPv6 address record type.
	AAAA RecordType = 28
)

Record types are defined in [RFC 3596](https://tools.ietf.org/html/rfc3596)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL