package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type WalletNftItem struct {
Flags bin .Fields
CollectionAddress string
Address string
OwnerAddress string
Index string
Name string
Description string
Image WebDocumentClass
ImageSmall WebDocumentClass
ContentURL WebDocumentClass
Lottie WebDocumentClass
Attributes []WalletNftAttribute
Extra DataJSON
Gift StarGiftClass
}
const WalletNftItemTypeID = 0x173dfaf3
var (
_ bin .Encoder = &WalletNftItem {}
_ bin .Decoder = &WalletNftItem {}
_ bin .BareEncoder = &WalletNftItem {}
_ bin .BareDecoder = &WalletNftItem {}
)
func (n *WalletNftItem ) Zero () bool {
if n == nil {
return true
}
if !(n .Flags .Zero ()) {
return false
}
if !(n .CollectionAddress == "" ) {
return false
}
if !(n .Address == "" ) {
return false
}
if !(n .OwnerAddress == "" ) {
return false
}
if !(n .Index == "" ) {
return false
}
if !(n .Name == "" ) {
return false
}
if !(n .Description == "" ) {
return false
}
if !(n .Image == nil ) {
return false
}
if !(n .ImageSmall == nil ) {
return false
}
if !(n .ContentURL == nil ) {
return false
}
if !(n .Lottie == nil ) {
return false
}
if !(n .Attributes == nil ) {
return false
}
if !(n .Extra .Zero ()) {
return false
}
if !(n .Gift == nil ) {
return false
}
return true
}
func (n *WalletNftItem ) String () string {
if n == nil {
return "WalletNftItem(nil)"
}
type Alias WalletNftItem
return fmt .Sprintf ("WalletNftItem%+v" , Alias (*n ))
}
func (n *WalletNftItem ) FillFrom (from interface {
GetCollectionAddress () (value string , ok bool )
GetAddress () (value string )
GetOwnerAddress () (value string )
GetIndex () (value string )
GetName () (value string , ok bool )
GetDescription () (value string , ok bool )
GetImage () (value WebDocumentClass , ok bool )
GetImageSmall () (value WebDocumentClass , ok bool )
GetContentURL () (value WebDocumentClass , ok bool )
GetLottie () (value WebDocumentClass , ok bool )
GetAttributes () (value []WalletNftAttribute , ok bool )
GetExtra () (value DataJSON , ok bool )
GetGift () (value StarGiftClass , ok bool )
}) {
if val , ok := from .GetCollectionAddress (); ok {
n .CollectionAddress = val
}
n .Address = from .GetAddress ()
n .OwnerAddress = from .GetOwnerAddress ()
n .Index = from .GetIndex ()
if val , ok := from .GetName (); ok {
n .Name = val
}
if val , ok := from .GetDescription (); ok {
n .Description = val
}
if val , ok := from .GetImage (); ok {
n .Image = val
}
if val , ok := from .GetImageSmall (); ok {
n .ImageSmall = val
}
if val , ok := from .GetContentURL (); ok {
n .ContentURL = val
}
if val , ok := from .GetLottie (); ok {
n .Lottie = val
}
if val , ok := from .GetAttributes (); ok {
n .Attributes = val
}
if val , ok := from .GetExtra (); ok {
n .Extra = val
}
if val , ok := from .GetGift (); ok {
n .Gift = val
}
}
func (*WalletNftItem ) TypeID () uint32 {
return WalletNftItemTypeID
}
func (*WalletNftItem ) TypeName () string {
return "wallet.nftItem"
}
func (n *WalletNftItem ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallet.nftItem" ,
ID : WalletNftItemTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CollectionAddress" ,
SchemaName : "collection_address" ,
Null : !n .Flags .Has (0 ),
},
{
Name : "Address" ,
SchemaName : "address" ,
},
{
Name : "OwnerAddress" ,
SchemaName : "owner_address" ,
},
{
Name : "Index" ,
SchemaName : "index" ,
},
{
Name : "Name" ,
SchemaName : "name" ,
Null : !n .Flags .Has (1 ),
},
{
Name : "Description" ,
SchemaName : "description" ,
Null : !n .Flags .Has (2 ),
},
{
Name : "Image" ,
SchemaName : "image" ,
Null : !n .Flags .Has (3 ),
},
{
Name : "ImageSmall" ,
SchemaName : "image_small" ,
Null : !n .Flags .Has (4 ),
},
{
Name : "ContentURL" ,
SchemaName : "content_url" ,
Null : !n .Flags .Has (5 ),
},
{
Name : "Lottie" ,
SchemaName : "lottie" ,
Null : !n .Flags .Has (6 ),
},
{
Name : "Attributes" ,
SchemaName : "attributes" ,
Null : !n .Flags .Has (7 ),
},
{
Name : "Extra" ,
SchemaName : "extra" ,
Null : !n .Flags .Has (8 ),
},
{
Name : "Gift" ,
SchemaName : "gift" ,
Null : !n .Flags .Has (9 ),
},
}
return typ
}
func (n *WalletNftItem ) SetFlags () {
if !(n .CollectionAddress == "" ) {
n .Flags .Set (0 )
}
if !(n .Name == "" ) {
n .Flags .Set (1 )
}
if !(n .Description == "" ) {
n .Flags .Set (2 )
}
if !(n .Image == nil ) {
n .Flags .Set (3 )
}
if !(n .ImageSmall == nil ) {
n .Flags .Set (4 )
}
if !(n .ContentURL == nil ) {
n .Flags .Set (5 )
}
if !(n .Lottie == nil ) {
n .Flags .Set (6 )
}
if !(n .Attributes == nil ) {
n .Flags .Set (7 )
}
if !(n .Extra .Zero ()) {
n .Flags .Set (8 )
}
if !(n .Gift == nil ) {
n .Flags .Set (9 )
}
}
func (n *WalletNftItem ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode wallet.nftItem#173dfaf3 as nil" )
}
b .PutID (WalletNftItemTypeID )
return n .EncodeBare (b )
}
func (n *WalletNftItem ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode wallet.nftItem#173dfaf3 as nil" )
}
n .SetFlags ()
if err := n .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field flags: %w" , err )
}
if n .Flags .Has (0 ) {
b .PutString (n .CollectionAddress )
}
b .PutString (n .Address )
b .PutString (n .OwnerAddress )
b .PutString (n .Index )
if n .Flags .Has (1 ) {
b .PutString (n .Name )
}
if n .Flags .Has (2 ) {
b .PutString (n .Description )
}
if n .Flags .Has (3 ) {
if n .Image == nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field image is nil" )
}
if err := n .Image .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field image: %w" , err )
}
}
if n .Flags .Has (4 ) {
if n .ImageSmall == nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field image_small is nil" )
}
if err := n .ImageSmall .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field image_small: %w" , err )
}
}
if n .Flags .Has (5 ) {
if n .ContentURL == nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field content_url is nil" )
}
if err := n .ContentURL .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field content_url: %w" , err )
}
}
if n .Flags .Has (6 ) {
if n .Lottie == nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field lottie is nil" )
}
if err := n .Lottie .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field lottie: %w" , err )
}
}
if n .Flags .Has (7 ) {
b .PutVectorHeader (len (n .Attributes ))
for idx , v := range n .Attributes {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field attributes element with index %d: %w" , idx , err )
}
}
}
if n .Flags .Has (8 ) {
if err := n .Extra .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field extra: %w" , err )
}
}
if n .Flags .Has (9 ) {
if n .Gift == nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field gift is nil" )
}
if err := n .Gift .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.nftItem#173dfaf3: field gift: %w" , err )
}
}
return nil
}
func (n *WalletNftItem ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode wallet.nftItem#173dfaf3 to nil" )
}
if err := b .ConsumeID (WalletNftItemTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: %w" , err )
}
return n .DecodeBare (b )
}
func (n *WalletNftItem ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode wallet.nftItem#173dfaf3 to nil" )
}
{
if err := n .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field flags: %w" , err )
}
}
if n .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field collection_address: %w" , err )
}
n .CollectionAddress = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field address: %w" , err )
}
n .Address = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field owner_address: %w" , err )
}
n .OwnerAddress = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field index: %w" , err )
}
n .Index = value
}
if n .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field name: %w" , err )
}
n .Name = value
}
if n .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field description: %w" , err )
}
n .Description = value
}
if n .Flags .Has (3 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field image: %w" , err )
}
n .Image = value
}
if n .Flags .Has (4 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field image_small: %w" , err )
}
n .ImageSmall = value
}
if n .Flags .Has (5 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field content_url: %w" , err )
}
n .ContentURL = value
}
if n .Flags .Has (6 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field lottie: %w" , err )
}
n .Lottie = value
}
if n .Flags .Has (7 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field attributes: %w" , err )
}
if headerLen > 0 {
n .Attributes = make ([]WalletNftAttribute , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value WalletNftAttribute
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field attributes: %w" , err )
}
n .Attributes = append (n .Attributes , value )
}
}
if n .Flags .Has (8 ) {
if err := n .Extra .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field extra: %w" , err )
}
}
if n .Flags .Has (9 ) {
value , err := DecodeStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.nftItem#173dfaf3: field gift: %w" , err )
}
n .Gift = value
}
return nil
}
func (n *WalletNftItem ) SetCollectionAddress (value string ) {
n .Flags .Set (0 )
n .CollectionAddress = value
}
func (n *WalletNftItem ) GetCollectionAddress () (value string , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (0 ) {
return value , false
}
return n .CollectionAddress , true
}
func (n *WalletNftItem ) GetAddress () (value string ) {
if n == nil {
return
}
return n .Address
}
func (n *WalletNftItem ) GetOwnerAddress () (value string ) {
if n == nil {
return
}
return n .OwnerAddress
}
func (n *WalletNftItem ) GetIndex () (value string ) {
if n == nil {
return
}
return n .Index
}
func (n *WalletNftItem ) SetName (value string ) {
n .Flags .Set (1 )
n .Name = value
}
func (n *WalletNftItem ) GetName () (value string , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (1 ) {
return value , false
}
return n .Name , true
}
func (n *WalletNftItem ) SetDescription (value string ) {
n .Flags .Set (2 )
n .Description = value
}
func (n *WalletNftItem ) GetDescription () (value string , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (2 ) {
return value , false
}
return n .Description , true
}
func (n *WalletNftItem ) SetImage (value WebDocumentClass ) {
n .Flags .Set (3 )
n .Image = value
}
func (n *WalletNftItem ) GetImage () (value WebDocumentClass , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (3 ) {
return value , false
}
return n .Image , true
}
func (n *WalletNftItem ) SetImageSmall (value WebDocumentClass ) {
n .Flags .Set (4 )
n .ImageSmall = value
}
func (n *WalletNftItem ) GetImageSmall () (value WebDocumentClass , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (4 ) {
return value , false
}
return n .ImageSmall , true
}
func (n *WalletNftItem ) SetContentURL (value WebDocumentClass ) {
n .Flags .Set (5 )
n .ContentURL = value
}
func (n *WalletNftItem ) GetContentURL () (value WebDocumentClass , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (5 ) {
return value , false
}
return n .ContentURL , true
}
func (n *WalletNftItem ) SetLottie (value WebDocumentClass ) {
n .Flags .Set (6 )
n .Lottie = value
}
func (n *WalletNftItem ) GetLottie () (value WebDocumentClass , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (6 ) {
return value , false
}
return n .Lottie , true
}
func (n *WalletNftItem ) SetAttributes (value []WalletNftAttribute ) {
n .Flags .Set (7 )
n .Attributes = value
}
func (n *WalletNftItem ) GetAttributes () (value []WalletNftAttribute , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (7 ) {
return value , false
}
return n .Attributes , true
}
func (n *WalletNftItem ) SetExtra (value DataJSON ) {
n .Flags .Set (8 )
n .Extra = value
}
func (n *WalletNftItem ) GetExtra () (value DataJSON , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (8 ) {
return value , false
}
return n .Extra , true
}
func (n *WalletNftItem ) SetGift (value StarGiftClass ) {
n .Flags .Set (9 )
n .Gift = value
}
func (n *WalletNftItem ) GetGift () (value StarGiftClass , ok bool ) {
if n == nil {
return
}
if !n .Flags .Has (9 ) {
return value , false
}
return n .Gift , true
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .