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 TonConnectSession struct {
Flags bin .Fields
Pending bool
Closing bool
Closed bool
ID int64
DappClientID string
ClientID string
Nonce []byte
Manifest TonConnectManifest
ManifestError int
Date int
}
const TonConnectSessionTypeID = 0x126556c6
var (
_ bin .Encoder = &TonConnectSession {}
_ bin .Decoder = &TonConnectSession {}
_ bin .BareEncoder = &TonConnectSession {}
_ bin .BareDecoder = &TonConnectSession {}
)
func (t *TonConnectSession ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .Pending == false ) {
return false
}
if !(t .Closing == false ) {
return false
}
if !(t .Closed == false ) {
return false
}
if !(t .ID == 0 ) {
return false
}
if !(t .DappClientID == "" ) {
return false
}
if !(t .ClientID == "" ) {
return false
}
if !(t .Nonce == nil ) {
return false
}
if !(t .Manifest .Zero ()) {
return false
}
if !(t .ManifestError == 0 ) {
return false
}
if !(t .Date == 0 ) {
return false
}
return true
}
func (t *TonConnectSession ) String () string {
if t == nil {
return "TonConnectSession(nil)"
}
type Alias TonConnectSession
return fmt .Sprintf ("TonConnectSession%+v" , Alias (*t ))
}
func (t *TonConnectSession ) FillFrom (from interface {
GetPending () (value bool )
GetClosing () (value bool )
GetClosed () (value bool )
GetID () (value int64 )
GetDappClientID () (value string )
GetClientID () (value string , ok bool )
GetNonce () (value []byte )
GetManifest () (value TonConnectManifest , ok bool )
GetManifestError () (value int , ok bool )
GetDate () (value int )
}) {
t .Pending = from .GetPending ()
t .Closing = from .GetClosing ()
t .Closed = from .GetClosed ()
t .ID = from .GetID ()
t .DappClientID = from .GetDappClientID ()
if val , ok := from .GetClientID (); ok {
t .ClientID = val
}
t .Nonce = from .GetNonce ()
if val , ok := from .GetManifest (); ok {
t .Manifest = val
}
if val , ok := from .GetManifestError (); ok {
t .ManifestError = val
}
t .Date = from .GetDate ()
}
func (*TonConnectSession ) TypeID () uint32 {
return TonConnectSessionTypeID
}
func (*TonConnectSession ) TypeName () string {
return "tonConnectSession"
}
func (t *TonConnectSession ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "tonConnectSession" ,
ID : TonConnectSessionTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Pending" ,
SchemaName : "pending" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Closing" ,
SchemaName : "closing" ,
Null : !t .Flags .Has (1 ),
},
{
Name : "Closed" ,
SchemaName : "closed" ,
Null : !t .Flags .Has (2 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "DappClientID" ,
SchemaName : "dapp_client_id" ,
},
{
Name : "ClientID" ,
SchemaName : "client_id" ,
Null : !t .Flags .Has (3 ),
},
{
Name : "Nonce" ,
SchemaName : "nonce" ,
},
{
Name : "Manifest" ,
SchemaName : "manifest" ,
Null : !t .Flags .Has (4 ),
},
{
Name : "ManifestError" ,
SchemaName : "manifest_error" ,
Null : !t .Flags .Has (5 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (t *TonConnectSession ) SetFlags () {
if !(t .Pending == false ) {
t .Flags .Set (0 )
}
if !(t .Closing == false ) {
t .Flags .Set (1 )
}
if !(t .Closed == false ) {
t .Flags .Set (2 )
}
if !(t .ClientID == "" ) {
t .Flags .Set (3 )
}
if !(t .Manifest .Zero ()) {
t .Flags .Set (4 )
}
if !(t .ManifestError == 0 ) {
t .Flags .Set (5 )
}
}
func (t *TonConnectSession ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectSession#126556c6 as nil" )
}
b .PutID (TonConnectSessionTypeID )
return t .EncodeBare (b )
}
func (t *TonConnectSession ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectSession#126556c6 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode tonConnectSession#126556c6: field flags: %w" , err )
}
b .PutLong (t .ID )
b .PutString (t .DappClientID )
if t .Flags .Has (3 ) {
b .PutString (t .ClientID )
}
b .PutBytes (t .Nonce )
if t .Flags .Has (4 ) {
if err := t .Manifest .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode tonConnectSession#126556c6: field manifest: %w" , err )
}
}
if t .Flags .Has (5 ) {
b .PutInt (t .ManifestError )
}
b .PutInt (t .Date )
return nil
}
func (t *TonConnectSession ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectSession#126556c6 to nil" )
}
if err := b .ConsumeID (TonConnectSessionTypeID ); err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: %w" , err )
}
return t .DecodeBare (b )
}
func (t *TonConnectSession ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectSession#126556c6 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field flags: %w" , err )
}
}
t .Pending = t .Flags .Has (0 )
t .Closing = t .Flags .Has (1 )
t .Closed = t .Flags .Has (2 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field id: %w" , err )
}
t .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field dapp_client_id: %w" , err )
}
t .DappClientID = value
}
if t .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field client_id: %w" , err )
}
t .ClientID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field nonce: %w" , err )
}
t .Nonce = value
}
if t .Flags .Has (4 ) {
if err := t .Manifest .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field manifest: %w" , err )
}
}
if t .Flags .Has (5 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field manifest_error: %w" , err )
}
t .ManifestError = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectSession#126556c6: field date: %w" , err )
}
t .Date = value
}
return nil
}
func (t *TonConnectSession ) SetPending (value bool ) {
if value {
t .Flags .Set (0 )
t .Pending = true
} else {
t .Flags .Unset (0 )
t .Pending = false
}
}
func (t *TonConnectSession ) GetPending () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (0 )
}
func (t *TonConnectSession ) SetClosing (value bool ) {
if value {
t .Flags .Set (1 )
t .Closing = true
} else {
t .Flags .Unset (1 )
t .Closing = false
}
}
func (t *TonConnectSession ) GetClosing () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (1 )
}
func (t *TonConnectSession ) SetClosed (value bool ) {
if value {
t .Flags .Set (2 )
t .Closed = true
} else {
t .Flags .Unset (2 )
t .Closed = false
}
}
func (t *TonConnectSession ) GetClosed () (value bool ) {
if t == nil {
return
}
return t .Flags .Has (2 )
}
func (t *TonConnectSession ) GetID () (value int64 ) {
if t == nil {
return
}
return t .ID
}
func (t *TonConnectSession ) GetDappClientID () (value string ) {
if t == nil {
return
}
return t .DappClientID
}
func (t *TonConnectSession ) SetClientID (value string ) {
t .Flags .Set (3 )
t .ClientID = value
}
func (t *TonConnectSession ) GetClientID () (value string , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (3 ) {
return value , false
}
return t .ClientID , true
}
func (t *TonConnectSession ) GetNonce () (value []byte ) {
if t == nil {
return
}
return t .Nonce
}
func (t *TonConnectSession ) SetManifest (value TonConnectManifest ) {
t .Flags .Set (4 )
t .Manifest = value
}
func (t *TonConnectSession ) GetManifest () (value TonConnectManifest , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (4 ) {
return value , false
}
return t .Manifest , true
}
func (t *TonConnectSession ) SetManifestError (value int ) {
t .Flags .Set (5 )
t .ManifestError = value
}
func (t *TonConnectSession ) GetManifestError () (value int , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (5 ) {
return value , false
}
return t .ManifestError , true
}
func (t *TonConnectSession ) GetDate () (value int ) {
if t == nil {
return
}
return t .Date
}
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 .