diff --git a/pkg/rpcclient/nns/record.go b/pkg/rpcclient/nns/record.go index da017f9ab..17ad4b40d 100644 --- a/pkg/rpcclient/nns/record.go +++ b/pkg/rpcclient/nns/record.go @@ -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 {