From f7b46d976daf806428acc4df0013ce544fa4da2a Mon Sep 17 00:00:00 2001 From: "aleksej.paschenko" Date: Mon, 2 Dec 2024 16:03:40 +0300 Subject: [PATCH] update sdk --- api/openapi.yml | 103 ++++---- oas_client_gen.go | 187 --------------- oas_json_gen.go | 452 ++++++++++++++++++++++++++--------- oas_parameters_gen.go | 10 - oas_request_encoders_gen.go | 10 - oas_response_decoders_gen.go | 134 ----------- oas_schemas_gen.go | 176 +++++++++++--- oas_validators_gen.go | 37 +++ 8 files changed, 563 insertions(+), 546 deletions(-) diff --git a/api/openapi.yml b/api/openapi.yml index ac91fd8..a6e18d6 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -1931,51 +1931,6 @@ paths: $ref: '#/components/schemas/AccountInfoByStateInit' 'default': $ref: '#/components/responses/Error' - - /v2/wallet/backup: - get: - description: Get backup info - operationId: getWalletBackup - tags: - - Wallet - parameters: - - in: header - name: X-TonConnect-Auth - schema: - type: string - required: true - responses: - '200': - description: get wallet dump - content: - application/json: - schema: - type: object - required: - - dump - properties: - dump: - type: string - 'default': - $ref: '#/components/responses/Error' - put: - description: Set backup info - operationId: setWalletBackup - tags: - - Wallet - parameters: - - in: header - name: X-TonConnect-Auth - schema: - type: string - required: true - requestBody: - $ref: "#/components/requestBodies/Backup" - responses: - '200': - description: success - 'default': - $ref: '#/components/responses/Error' /v2/wallet/auth/proof: post: description: Account verification and token issuance @@ -3337,14 +3292,6 @@ components: state_init: type: string format: cell-base64 - Backup: - description: "Information for saving backup" - required: true - content: - application/octet-stream: - schema: - type: string - format: binary TonConnectStateInit: description: "Data that is expected" required: true @@ -5288,6 +5235,27 @@ components: example: 0:0000000000000000000000000000000000000000000000000000000000000000 suspended_until: type: integer + + "45": + type: object + description: precompiled contracts + required: + - contracts + properties: + contracts: + type: array + items: + type: object + required: + - code_hash + - gas_usage + properties: + code_hash: + type: string + format: address + gas_usage: + type: integer + format: int64 "71": type: object description: Bridge parameters for wrapping TON in other networks. @@ -6764,7 +6732,12 @@ components: type: object required: - raw_messages + - valid_until properties: + valid_until: + type: integer + format: int64 + example: 1 raw_messages: type: array items: @@ -6874,7 +6847,8 @@ components: example: "9" image: type: string - example: "https://cache.tonapi.io/images/jetton.jpg" + example: "https://bitcoincash-example.github.io/website/logo.png" + description: this field currently returns a cached image URL (e.g., "https://cache.tonapi.io/images/jetton.jpg"). In the future, this will be replaced with the original URL from the metadata. The cached image is already available in the `preview` field of `JettonInfo` and will remain there. description: type: string example: Wrapped Toncoin @@ -6946,6 +6920,7 @@ components: - metadata - verification - holders_count + - preview properties: mintable: type: boolean @@ -6958,6 +6933,9 @@ components: $ref: '#/components/schemas/AccountAddress' metadata: $ref: '#/components/schemas/JettonMetadata' + preview: + type: string + example: "https://cache.tonapi.io/images/jetton.jpg" verification: $ref: '#/components/schemas/JettonVerificationType' holders_count: @@ -7413,3 +7391,20 @@ components: properties: error: type: string + extended_code: + type: integer + format: int64 + +# enum: +# - "err-gasless-jetton-is-not-supported" +# - "err-gasless-temporary" +# - "err-gasless-signature" +# - "err-gasless-pending-messages" +# - "err-gasless-bad-request" +# - "err-gasless-operation-is-not-supported" +# - "err-gasless-user-disabled" +# - "err-gasless-estimating-commission" +# - "err-gasless-commission" +# - "err-gasless-balance" +# - "err-gasless-bootstrap-transfer-disabled" +# - "err-gasless-unknown" \ No newline at end of file diff --git a/oas_client_gen.go b/oas_client_gen.go index d1174e0..515480a 100644 --- a/oas_client_gen.go +++ b/oas_client_gen.go @@ -604,12 +604,6 @@ type Invoker interface { // // GET /v2/traces/{trace_id} GetTrace(ctx context.Context, params GetTraceParams) (*Trace, error) - // GetWalletBackup invokes getWalletBackup operation. - // - // Get backup info. - // - // GET /v2/wallet/backup - GetWalletBackup(ctx context.Context, params GetWalletBackupParams) (*GetWalletBackupOK, error) // GetWalletsByPublicKey invokes getWalletsByPublicKey operation. // // Get wallets by public key. @@ -640,12 +634,6 @@ type Invoker interface { // // POST /v2/liteserver/send_message SendRawMessage(ctx context.Context, request *SendRawMessageReq) (*SendRawMessageOK, error) - // SetWalletBackup invokes setWalletBackup operation. - // - // Set backup info. - // - // PUT /v2/wallet/backup - SetWalletBackup(ctx context.Context, request SetWalletBackupReq, params SetWalletBackupParams) error // Status invokes status operation. // // Status. @@ -10867,92 +10855,6 @@ func (c *Client) sendGetTrace(ctx context.Context, params GetTraceParams) (res * return result, nil } -// GetWalletBackup invokes getWalletBackup operation. -// -// Get backup info. -// -// GET /v2/wallet/backup -func (c *Client) GetWalletBackup(ctx context.Context, params GetWalletBackupParams) (*GetWalletBackupOK, error) { - res, err := c.sendGetWalletBackup(ctx, params) - return res, err -} - -func (c *Client) sendGetWalletBackup(ctx context.Context, params GetWalletBackupParams) (res *GetWalletBackupOK, err error) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("getWalletBackup"), - semconv.HTTPMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/v2/wallet/backup"), - } - - // Run stopwatch. - startTime := time.Now() - defer func() { - // Use floating point division here for higher precision (instead of Millisecond method). - elapsedDuration := time.Since(startTime) - c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...)) - }() - - // Increment request counter. - c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) - - // Start a span for this request. - ctx, span := c.cfg.Tracer.Start(ctx, "GetWalletBackup", - trace.WithAttributes(otelAttrs...), - clientSpanKind, - ) - // Track stage for error reporting. - var stage string - defer func() { - if err != nil { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) - } - span.End() - }() - - stage = "BuildURL" - u := uri.Clone(c.requestURL(ctx)) - var pathParts [1]string - pathParts[0] = "/v2/wallet/backup" - uri.AddPathParts(u, pathParts[:]...) - - stage = "EncodeRequest" - r, err := ht.NewRequest(ctx, "GET", u) - if err != nil { - return res, errors.Wrap(err, "create request") - } - - stage = "EncodeHeaderParams" - h := uri.NewHeaderEncoder(r.Header) - { - cfg := uri.HeaderParameterEncodingConfig{ - Name: "X-TonConnect-Auth", - Explode: false, - } - if err := h.EncodeParam(cfg, func(e uri.Encoder) error { - return e.EncodeValue(conv.StringToString(params.XTonConnectAuth)) - }); err != nil { - return res, errors.Wrap(err, "encode header") - } - } - - stage = "SendRequest" - resp, err := c.cfg.Client.Do(r) - if err != nil { - return res, errors.Wrap(err, "do request") - } - defer resp.Body.Close() - - stage = "DecodeResponse" - result, err := decodeGetWalletBackupResponse(resp) - if err != nil { - return res, errors.Wrap(err, "decode response") - } - - return result, nil -} - // GetWalletsByPublicKey invokes getWalletsByPublicKey operation. // // Get wallets by public key. @@ -11384,95 +11286,6 @@ func (c *Client) sendSendRawMessage(ctx context.Context, request *SendRawMessage return result, nil } -// SetWalletBackup invokes setWalletBackup operation. -// -// Set backup info. -// -// PUT /v2/wallet/backup -func (c *Client) SetWalletBackup(ctx context.Context, request SetWalletBackupReq, params SetWalletBackupParams) error { - _, err := c.sendSetWalletBackup(ctx, request, params) - return err -} - -func (c *Client) sendSetWalletBackup(ctx context.Context, request SetWalletBackupReq, params SetWalletBackupParams) (res *SetWalletBackupOK, err error) { - otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("setWalletBackup"), - semconv.HTTPMethodKey.String("PUT"), - semconv.HTTPRouteKey.String("/v2/wallet/backup"), - } - - // Run stopwatch. - startTime := time.Now() - defer func() { - // Use floating point division here for higher precision (instead of Millisecond method). - elapsedDuration := time.Since(startTime) - c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...)) - }() - - // Increment request counter. - c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) - - // Start a span for this request. - ctx, span := c.cfg.Tracer.Start(ctx, "SetWalletBackup", - trace.WithAttributes(otelAttrs...), - clientSpanKind, - ) - // Track stage for error reporting. - var stage string - defer func() { - if err != nil { - span.RecordError(err) - span.SetStatus(codes.Error, stage) - c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) - } - span.End() - }() - - stage = "BuildURL" - u := uri.Clone(c.requestURL(ctx)) - var pathParts [1]string - pathParts[0] = "/v2/wallet/backup" - uri.AddPathParts(u, pathParts[:]...) - - stage = "EncodeRequest" - r, err := ht.NewRequest(ctx, "PUT", u) - if err != nil { - return res, errors.Wrap(err, "create request") - } - if err := encodeSetWalletBackupRequest(request, r); err != nil { - return res, errors.Wrap(err, "encode request") - } - - stage = "EncodeHeaderParams" - h := uri.NewHeaderEncoder(r.Header) - { - cfg := uri.HeaderParameterEncodingConfig{ - Name: "X-TonConnect-Auth", - Explode: false, - } - if err := h.EncodeParam(cfg, func(e uri.Encoder) error { - return e.EncodeValue(conv.StringToString(params.XTonConnectAuth)) - }); err != nil { - return res, errors.Wrap(err, "encode header") - } - } - - stage = "SendRequest" - resp, err := c.cfg.Client.Do(r) - if err != nil { - return res, errors.Wrap(err, "do request") - } - defer resp.Body.Close() - - stage = "DecodeResponse" - result, err := decodeSetWalletBackupResponse(resp) - if err != nil { - return res, errors.Wrap(err, "decode response") - } - - return result, nil -} - // Status invokes status operation. // // Status. diff --git a/oas_json_gen.go b/oas_json_gen.go index 868c63e..785a4ed 100644 --- a/oas_json_gen.go +++ b/oas_json_gen.go @@ -5975,6 +5975,12 @@ func (s *BlockchainConfig) encodeFields(e *jx.Encoder) { e.FieldStart("44") s.R44.Encode(e) } + { + if s.R45.Set { + e.FieldStart("45") + s.R45.Encode(e) + } + } { if s.R71.Set { e.FieldStart("71") @@ -6013,7 +6019,7 @@ func (s *BlockchainConfig) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfBlockchainConfig = [44]string{ +var jsonFieldsNameOfBlockchainConfig = [45]string{ 0: "raw", 1: "0", 2: "1", @@ -6052,12 +6058,13 @@ var jsonFieldsNameOfBlockchainConfig = [44]string{ 35: "40", 36: "43", 37: "44", - 38: "71", - 39: "72", - 40: "73", - 41: "79", - 42: "81", - 43: "82", + 38: "45", + 39: "71", + 40: "72", + 41: "73", + 42: "79", + 43: "81", + 44: "82", } // Decode decodes BlockchainConfig from json. @@ -6459,6 +6466,16 @@ func (s *BlockchainConfig) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"44\"") } + case "45": + if err := func() error { + s.R45.Reset() + if err := s.R45.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"45\"") + } case "71": if err := func() error { s.R71.Reset() @@ -9290,6 +9307,225 @@ func (s *BlockchainConfig44) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *BlockchainConfig45) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockchainConfig45) encodeFields(e *jx.Encoder) { + { + e.FieldStart("contracts") + e.ArrStart() + for _, elem := range s.Contracts { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfBlockchainConfig45 = [1]string{ + 0: "contracts", +} + +// Decode decodes BlockchainConfig45 from json. +func (s *BlockchainConfig45) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockchainConfig45 to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "contracts": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Contracts = make([]BlockchainConfig45ContractsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem BlockchainConfig45ContractsItem + if err := elem.Decode(d); err != nil { + return err + } + s.Contracts = append(s.Contracts, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contracts\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockchainConfig45") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfBlockchainConfig45) { + name = jsonFieldsNameOfBlockchainConfig45[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BlockchainConfig45) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockchainConfig45) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BlockchainConfig45ContractsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockchainConfig45ContractsItem) encodeFields(e *jx.Encoder) { + { + e.FieldStart("code_hash") + e.Str(s.CodeHash) + } + { + e.FieldStart("gas_usage") + e.Int64(s.GasUsage) + } +} + +var jsonFieldsNameOfBlockchainConfig45ContractsItem = [2]string{ + 0: "code_hash", + 1: "gas_usage", +} + +// Decode decodes BlockchainConfig45ContractsItem from json. +func (s *BlockchainConfig45ContractsItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockchainConfig45ContractsItem to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code_hash": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.CodeHash = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code_hash\"") + } + case "gas_usage": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Int64() + s.GasUsage = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"gas_usage\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockchainConfig45ContractsItem") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfBlockchainConfig45ContractsItem) { + name = jsonFieldsNameOfBlockchainConfig45ContractsItem[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *BlockchainConfig45ContractsItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockchainConfig45ContractsItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *BlockchainConfig5) Encode(e *jx.Encoder) { e.ObjStart() @@ -12618,6 +12854,10 @@ func (s *DecodedMessageExtInMsgDecodedWalletV5) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *DecodedMessageExtInMsgDecodedWalletV5) encodeFields(e *jx.Encoder) { + { + e.FieldStart("valid_until") + e.Int64(s.ValidUntil) + } { e.FieldStart("raw_messages") e.ArrStart() @@ -12628,8 +12868,9 @@ func (s *DecodedMessageExtInMsgDecodedWalletV5) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfDecodedMessageExtInMsgDecodedWalletV5 = [1]string{ - 0: "raw_messages", +var jsonFieldsNameOfDecodedMessageExtInMsgDecodedWalletV5 = [2]string{ + 0: "valid_until", + 1: "raw_messages", } // Decode decodes DecodedMessageExtInMsgDecodedWalletV5 from json. @@ -12641,8 +12882,20 @@ func (s *DecodedMessageExtInMsgDecodedWalletV5) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "raw_messages": + case "valid_until": requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int64() + s.ValidUntil = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"valid_until\"") + } + case "raw_messages": + requiredBitSet[0] |= 1 << 1 if err := func() error { s.RawMessages = make([]DecodedRawMessage, 0) if err := d.Arr(func(d *jx.Decoder) error { @@ -12669,7 +12922,7 @@ func (s *DecodedMessageExtInMsgDecodedWalletV5) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -15018,10 +15271,17 @@ func (s *Error) encodeFields(e *jx.Encoder) { e.FieldStart("error") e.Str(s.Error) } + { + if s.ExtendedCode.Set { + e.FieldStart("extended_code") + s.ExtendedCode.Encode(e) + } + } } -var jsonFieldsNameOfError = [1]string{ +var jsonFieldsNameOfError = [2]string{ 0: "error", + 1: "extended_code", } // Decode decodes Error from json. @@ -15045,6 +15305,16 @@ func (s *Error) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"error\"") } + case "extended_code": + if err := func() error { + s.ExtendedCode.Reset() + if err := s.ExtendedCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"extended_code\"") + } default: return d.Skip() } @@ -21309,102 +21579,6 @@ func (s *GetTonConnectPayloadOK) UnmarshalJSON(data []byte) error { return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *GetWalletBackupOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *GetWalletBackupOK) encodeFields(e *jx.Encoder) { - { - e.FieldStart("dump") - e.Str(s.Dump) - } -} - -var jsonFieldsNameOfGetWalletBackupOK = [1]string{ - 0: "dump", -} - -// Decode decodes GetWalletBackupOK from json. -func (s *GetWalletBackupOK) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode GetWalletBackupOK to nil") - } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "dump": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.Dump = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"dump\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode GetWalletBackupOK") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfGetWalletBackupOK) { - name = jsonFieldsNameOfGetWalletBackupOK[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *GetWalletBackupOK) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetWalletBackupOK) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - // Encode implements json.Marshaler. func (s *ImagePreview) Encode(e *jx.Encoder) { e.ObjStart() @@ -23484,6 +23658,10 @@ func (s *JettonInfo) encodeFields(e *jx.Encoder) { e.FieldStart("metadata") s.Metadata.Encode(e) } + { + e.FieldStart("preview") + e.Str(s.Preview) + } { e.FieldStart("verification") s.Verification.Encode(e) @@ -23494,13 +23672,14 @@ func (s *JettonInfo) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfJettonInfo = [6]string{ +var jsonFieldsNameOfJettonInfo = [7]string{ 0: "mintable", 1: "total_supply", 2: "admin", 3: "metadata", - 4: "verification", - 5: "holders_count", + 4: "preview", + 5: "verification", + 6: "holders_count", } // Decode decodes JettonInfo from json. @@ -23556,8 +23735,20 @@ func (s *JettonInfo) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"metadata\"") } - case "verification": + case "preview": requiredBitSet[0] |= 1 << 4 + if err := func() error { + v, err := d.Str() + s.Preview = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview\"") + } + case "verification": + requiredBitSet[0] |= 1 << 5 if err := func() error { if err := s.Verification.Decode(d); err != nil { return err @@ -23567,7 +23758,7 @@ func (s *JettonInfo) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"verification\"") } case "holders_count": - requiredBitSet[0] |= 1 << 5 + requiredBitSet[0] |= 1 << 6 if err := func() error { v, err := d.Int32() s.HoldersCount = int32(v) @@ -23588,7 +23779,7 @@ func (s *JettonInfo) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00111011, + 0b01111011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -29402,6 +29593,39 @@ func (s *OptBlockchainConfig43) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes BlockchainConfig45 as json. +func (o OptBlockchainConfig45) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BlockchainConfig45 from json. +func (o *OptBlockchainConfig45) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBlockchainConfig45 to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBlockchainConfig45) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBlockchainConfig45) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes BlockchainConfig5 as json. func (o OptBlockchainConfig5) Encode(e *jx.Encoder) { if !o.Set { diff --git a/oas_parameters_gen.go b/oas_parameters_gen.go index a635ff4..614d058 100644 --- a/oas_parameters_gen.go +++ b/oas_parameters_gen.go @@ -601,11 +601,6 @@ type GetTraceParams struct { TraceID string } -// GetWalletBackupParams is parameters of getWalletBackup operation. -type GetWalletBackupParams struct { - XTonConnectAuth string -} - // GetWalletsByPublicKeyParams is parameters of getWalletsByPublicKey operation. type GetWalletsByPublicKeyParams struct { PublicKey string @@ -621,8 +616,3 @@ type ReindexAccountParams struct { type SearchAccountsParams struct { Name string } - -// SetWalletBackupParams is parameters of setWalletBackup operation. -type SetWalletBackupParams struct { - XTonConnectAuth string -} diff --git a/oas_request_encoders_gen.go b/oas_request_encoders_gen.go index 4abd80a..5883406 100644 --- a/oas_request_encoders_gen.go +++ b/oas_request_encoders_gen.go @@ -231,16 +231,6 @@ func encodeSendRawMessageRequest( return nil } -func encodeSetWalletBackupRequest( - req SetWalletBackupReq, - r *http.Request, -) error { - const contentType = "application/octet-stream" - body := req - ht.SetBody(r, body, contentType) - return nil -} - func encodeTonConnectProofRequest( req *TonConnectProofReq, r *http.Request, diff --git a/oas_response_decoders_gen.go b/oas_response_decoders_gen.go index ad40d99..45db990 100644 --- a/oas_response_decoders_gen.go +++ b/oas_response_decoders_gen.go @@ -7784,89 +7784,6 @@ func decodeGetTraceResponse(resp *http.Response) (res *Trace, _ error) { return res, errors.Wrap(defRes, "error") } -func decodeGetWalletBackupResponse(resp *http.Response) (res *GetWalletBackupOK, _ error) { - switch resp.StatusCode { - case 200: - // Code 200. - ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) - if err != nil { - return res, errors.Wrap(err, "parse media type") - } - switch { - case ct == "application/json": - buf, err := io.ReadAll(resp.Body) - if err != nil { - return res, err - } - d := jx.DecodeBytes(buf) - - var response GetWalletBackupOK - if err := func() error { - if err := response.Decode(d); err != nil { - return err - } - if err := d.Skip(); err != io.EOF { - return errors.New("unexpected trailing data") - } - return nil - }(); err != nil { - err = &ogenerrors.DecodeBodyError{ - ContentType: ct, - Body: buf, - Err: err, - } - return res, err - } - return &response, nil - default: - return res, validate.InvalidContentType(ct) - } - } - // Convenient error response. - defRes, err := func() (res *ErrorStatusCode, err error) { - ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) - if err != nil { - return res, errors.Wrap(err, "parse media type") - } - switch { - case ct == "application/json": - buf, err := io.ReadAll(resp.Body) - if err != nil { - return res, err - } - d := jx.DecodeBytes(buf) - - var response Error - if err := func() error { - if err := response.Decode(d); err != nil { - return err - } - if err := d.Skip(); err != io.EOF { - return errors.New("unexpected trailing data") - } - return nil - }(); err != nil { - err = &ogenerrors.DecodeBodyError{ - ContentType: ct, - Body: buf, - Err: err, - } - return res, err - } - return &ErrorStatusCode{ - StatusCode: resp.StatusCode, - Response: response, - }, nil - default: - return res, validate.InvalidContentType(ct) - } - }() - if err != nil { - return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode) - } - return res, errors.Wrap(defRes, "error") -} - func decodeGetWalletsByPublicKeyResponse(resp *http.Response) (res *Accounts, _ error) { switch resp.StatusCode { case 200: @@ -8218,57 +8135,6 @@ func decodeSendRawMessageResponse(resp *http.Response) (res *SendRawMessageOK, _ return res, errors.Wrap(defRes, "error") } -func decodeSetWalletBackupResponse(resp *http.Response) (res *SetWalletBackupOK, _ error) { - switch resp.StatusCode { - case 200: - // Code 200. - return &SetWalletBackupOK{}, nil - } - // Convenient error response. - defRes, err := func() (res *ErrorStatusCode, err error) { - ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) - if err != nil { - return res, errors.Wrap(err, "parse media type") - } - switch { - case ct == "application/json": - buf, err := io.ReadAll(resp.Body) - if err != nil { - return res, err - } - d := jx.DecodeBytes(buf) - - var response Error - if err := func() error { - if err := response.Decode(d); err != nil { - return err - } - if err := d.Skip(); err != io.EOF { - return errors.New("unexpected trailing data") - } - return nil - }(); err != nil { - err = &ogenerrors.DecodeBodyError{ - ContentType: ct, - Body: buf, - Err: err, - } - return res, err - } - return &ErrorStatusCode{ - StatusCode: resp.StatusCode, - Response: response, - }, nil - default: - return res, validate.InvalidContentType(ct) - } - }() - if err != nil { - return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode) - } - return res, errors.Wrap(defRes, "error") -} - func decodeStatusResponse(resp *http.Response) (res *ServiceStatus, _ error) { switch resp.StatusCode { case 200: diff --git a/oas_schemas_gen.go b/oas_schemas_gen.go index fe96b1b..665dc86 100644 --- a/oas_schemas_gen.go +++ b/oas_schemas_gen.go @@ -4,7 +4,6 @@ package tonapi import ( "fmt" - "io" "github.com/go-faster/errors" "github.com/go-faster/jx" @@ -2485,6 +2484,8 @@ type BlockchainConfig struct { R43 OptBlockchainConfig43 `json:"43"` // Suspended accounts. R44 BlockchainConfig44 `json:"44"` + // Precompiled contracts. + R45 OptBlockchainConfig45 `json:"45"` // Bridge parameters for wrapping TON in other networks. R71 OptBlockchainConfig71 `json:"71"` // Bridge parameters for wrapping TON in other networks. @@ -2689,6 +2690,11 @@ func (s *BlockchainConfig) GetR44() BlockchainConfig44 { return s.R44 } +// GetR45 returns the value of R45. +func (s *BlockchainConfig) GetR45() OptBlockchainConfig45 { + return s.R45 +} + // GetR71 returns the value of R71. func (s *BlockchainConfig) GetR71() OptBlockchainConfig71 { return s.R71 @@ -2909,6 +2915,11 @@ func (s *BlockchainConfig) SetR44(val BlockchainConfig44) { s.R44 = val } +// SetR45 sets the value of R45. +func (s *BlockchainConfig) SetR45(val OptBlockchainConfig45) { + s.R45 = val +} + // SetR71 sets the value of R71. func (s *BlockchainConfig) SetR71(val OptBlockchainConfig71) { s.R71 = val @@ -3638,6 +3649,46 @@ func (s *BlockchainConfig44) SetSuspendedUntil(val int) { s.SuspendedUntil = val } +// Precompiled contracts. +type BlockchainConfig45 struct { + Contracts []BlockchainConfig45ContractsItem `json:"contracts"` +} + +// GetContracts returns the value of Contracts. +func (s *BlockchainConfig45) GetContracts() []BlockchainConfig45ContractsItem { + return s.Contracts +} + +// SetContracts sets the value of Contracts. +func (s *BlockchainConfig45) SetContracts(val []BlockchainConfig45ContractsItem) { + s.Contracts = val +} + +type BlockchainConfig45ContractsItem struct { + CodeHash string `json:"code_hash"` + GasUsage int64 `json:"gas_usage"` +} + +// GetCodeHash returns the value of CodeHash. +func (s *BlockchainConfig45ContractsItem) GetCodeHash() string { + return s.CodeHash +} + +// GetGasUsage returns the value of GasUsage. +func (s *BlockchainConfig45ContractsItem) GetGasUsage() int64 { + return s.GasUsage +} + +// SetCodeHash sets the value of CodeHash. +func (s *BlockchainConfig45ContractsItem) SetCodeHash(val string) { + s.CodeHash = val +} + +// SetGasUsage sets the value of GasUsage. +func (s *BlockchainConfig45ContractsItem) SetGasUsage(val int64) { + s.GasUsage = val +} + type BlockchainConfig5 struct { BlackholeAddr OptString `json:"blackhole_addr"` FeeBurnNom int64 `json:"fee_burn_nom"` @@ -4632,14 +4683,25 @@ func (s *DecodedMessageExtInMsgDecodedWalletV4) SetRawMessages(val []DecodedRawM } type DecodedMessageExtInMsgDecodedWalletV5 struct { + ValidUntil int64 `json:"valid_until"` RawMessages []DecodedRawMessage `json:"raw_messages"` } +// GetValidUntil returns the value of ValidUntil. +func (s *DecodedMessageExtInMsgDecodedWalletV5) GetValidUntil() int64 { + return s.ValidUntil +} + // GetRawMessages returns the value of RawMessages. func (s *DecodedMessageExtInMsgDecodedWalletV5) GetRawMessages() []DecodedRawMessage { return s.RawMessages } +// SetValidUntil sets the value of ValidUntil. +func (s *DecodedMessageExtInMsgDecodedWalletV5) SetValidUntil(val int64) { + s.ValidUntil = val +} + // SetRawMessages sets the value of RawMessages. func (s *DecodedMessageExtInMsgDecodedWalletV5) SetRawMessages(val []DecodedRawMessage) { s.RawMessages = val @@ -5203,7 +5265,8 @@ func (s *EncryptedComment) SetCipherText(val string) { } type Error struct { - Error string `json:"error"` + Error string `json:"error"` + ExtendedCode OptInt64 `json:"extended_code"` } // GetError returns the value of Error. @@ -5211,11 +5274,21 @@ func (s *Error) GetError() string { return s.Error } +// GetExtendedCode returns the value of ExtendedCode. +func (s *Error) GetExtendedCode() OptInt64 { + return s.ExtendedCode +} + // SetError sets the value of Error. func (s *Error) SetError(val string) { s.Error = val } +// SetExtendedCode sets the value of ExtendedCode. +func (s *Error) SetExtendedCode(val OptInt64) { + s.ExtendedCode = val +} + // ErrorStatusCode wraps Error with StatusCode. type ErrorStatusCode struct { StatusCode int @@ -6934,20 +7007,6 @@ func (s *GetTonConnectPayloadOK) SetPayload(val string) { s.Payload = val } -type GetWalletBackupOK struct { - Dump string `json:"dump"` -} - -// GetDump returns the value of Dump. -func (s *GetWalletBackupOK) GetDump() string { - return s.Dump -} - -// SetDump sets the value of Dump. -func (s *GetWalletBackupOK) SetDump(val string) { - s.Dump = val -} - // Ref: #/components/schemas/ImagePreview type ImagePreview struct { Resolution string `json:"resolution"` @@ -7704,6 +7763,7 @@ type JettonInfo struct { TotalSupply string `json:"total_supply"` Admin OptAccountAddress `json:"admin"` Metadata JettonMetadata `json:"metadata"` + Preview string `json:"preview"` Verification JettonVerificationType `json:"verification"` HoldersCount int32 `json:"holders_count"` } @@ -7728,6 +7788,11 @@ func (s *JettonInfo) GetMetadata() JettonMetadata { return s.Metadata } +// GetPreview returns the value of Preview. +func (s *JettonInfo) GetPreview() string { + return s.Preview +} + // GetVerification returns the value of Verification. func (s *JettonInfo) GetVerification() JettonVerificationType { return s.Verification @@ -7758,6 +7823,11 @@ func (s *JettonInfo) SetMetadata(val JettonMetadata) { s.Metadata = val } +// SetPreview sets the value of Preview. +func (s *JettonInfo) SetPreview(val string) { + s.Preview = val +} + // SetVerification sets the value of Verification. func (s *JettonInfo) SetVerification(val JettonVerificationType) { s.Verification = val @@ -7770,10 +7840,13 @@ func (s *JettonInfo) SetHoldersCount(val int32) { // Ref: #/components/schemas/JettonMetadata type JettonMetadata struct { - Address string `json:"address"` - Name string `json:"name"` - Symbol string `json:"symbol"` - Decimals string `json:"decimals"` + Address string `json:"address"` + Name string `json:"name"` + Symbol string `json:"symbol"` + Decimals string `json:"decimals"` + // This field currently returns a cached image URL (e.g., "https://cache.tonapi.io/images/jetton. + // jpg"). In the future, this will be replaced with the original URL from the metadata. The cached + // image is already available in the `preview` field of `JettonInfo` and will remain there. Image OptString `json:"image"` Description OptString `json:"description"` Social []string `json:"social"` @@ -10921,6 +10994,52 @@ func (o OptBlockchainConfig43) Or(d BlockchainConfig43) BlockchainConfig43 { return d } +// NewOptBlockchainConfig45 returns new OptBlockchainConfig45 with value set to v. +func NewOptBlockchainConfig45(v BlockchainConfig45) OptBlockchainConfig45 { + return OptBlockchainConfig45{ + Value: v, + Set: true, + } +} + +// OptBlockchainConfig45 is optional BlockchainConfig45. +type OptBlockchainConfig45 struct { + Value BlockchainConfig45 + Set bool +} + +// IsSet returns true if OptBlockchainConfig45 was set. +func (o OptBlockchainConfig45) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBlockchainConfig45) Reset() { + var v BlockchainConfig45 + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBlockchainConfig45) SetTo(v BlockchainConfig45) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBlockchainConfig45) Get() (v BlockchainConfig45, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptBlockchainConfig45) Or(d BlockchainConfig45) BlockchainConfig45 { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptBlockchainConfig5 returns new OptBlockchainConfig5 with value set to v. func NewOptBlockchainConfig5(v BlockchainConfig5) OptBlockchainConfig5 { return OptBlockchainConfig5{ @@ -14887,23 +15006,6 @@ func (s *ServiceStatus) SetLastKnownMasterchainSeqno(val int32) { s.LastKnownMasterchainSeqno = val } -// SetWalletBackupOK is response for SetWalletBackup operation. -type SetWalletBackupOK struct{} - -type SetWalletBackupReq struct { - Data io.Reader -} - -// Read reads data from the Data reader. -// -// Kept to satisfy the io.Reader interface. -func (s SetWalletBackupReq) Read(p []byte) (n int, err error) { - if s.Data == nil { - return 0, io.EOF - } - return s.Data.Read(p) -} - // Ref: #/components/schemas/SignRawMessage type SignRawMessage struct { Address string `json:"address"` diff --git a/oas_validators_gen.go b/oas_validators_gen.go index c1b3120..3f59767 100644 --- a/oas_validators_gen.go +++ b/oas_validators_gen.go @@ -1226,6 +1226,24 @@ func (s *BlockchainConfig) Validate() error { Error: err, }) } + if err := func() error { + if value, ok := s.R45.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "45", + Error: err, + }) + } if err := func() error { if value, ok := s.R71.Get(); ok { if err := func() error { @@ -1435,6 +1453,25 @@ func (s *BlockchainConfig44) Validate() error { return nil } +func (s *BlockchainConfig45) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Contracts == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "contracts", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *BlockchainConfig7) Validate() error { var failures []validate.FieldError if err := func() error {