mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
rpcclient: ensure nns.RecordType can be passed as a parameter to invoker
Implement smartcontract.Convertible for nns.RecordType. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
a22a7177e3
commit
161b83fd7f
1 changed files with 14 additions and 0 deletions
|
@ -3,7 +3,9 @@ package nns
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
|
@ -17,6 +19,10 @@ type RecordState struct {
|
|||
// RecordType is domain name service record types.
|
||||
type RecordType byte
|
||||
|
||||
// Ensure RecordType implements smartcontract.Convertible for proper handling as
|
||||
// a parameter to invoker.Invoker methods.
|
||||
var _ = smartcontract.Convertible(RecordType(0))
|
||||
|
||||
// Record types are defined in [RFC 1035](https://tools.ietf.org/html/rfc1035)
|
||||
const (
|
||||
// A represents address record type.
|
||||
|
@ -33,6 +39,14 @@ const (
|
|||
AAAA RecordType = 28
|
||||
)
|
||||
|
||||
// ToSCParameter implements smartcontract.Convertible interface.
|
||||
func (r RecordType) ToSCParameter() (smartcontract.Parameter, error) {
|
||||
return smartcontract.Parameter{
|
||||
Type: smartcontract.IntegerType,
|
||||
Value: big.NewInt(int64(r)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FromStackItem fills RecordState with data from the given stack item if it can
|
||||
// be correctly converted to RecordState.
|
||||
func (r *RecordState) FromStackItem(itm stackitem.Item) error {
|
||||
|
|
Loading…
Reference in a new issue