diff --git a/api/openapi.yml b/api/openapi.yml index 9e98613..5b8f596 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -35,14 +35,7 @@ paths: tags: - Blockchain parameters: - - name: masterchain_seqno - in: path - required: true - description: "masterchain block seqno" - schema: - type: integer - format: int32 - example: 123456 + - $ref: '#/components/parameters/masterchainSeqno' responses: '200': description: blockchain block shards @@ -52,31 +45,31 @@ paths: $ref: '#/components/schemas/BlockchainBlockShards' 'default': $ref: '#/components/responses/Error' - /v2/blockchain/blocks/{block_id}/transactions: + /v2/blockchain/masterchain/{masterchain_seqno}/config: get: - description: Get transactions from block - operationId: getBlockchainBlockTransactions + description: Get blockchain config from a specific block, if present. + operationId: getBlockchainConfigFromBlock tags: - Blockchain parameters: - - $ref: '#/components/parameters/blockchainBlockIDParameter' + - $ref: '#/components/parameters/masterchainSeqno' responses: '200': - description: blockchain block transactions + description: blockchain config content: application/json: schema: - $ref: '#/components/schemas/Transactions' + $ref: '#/components/schemas/BlockchainConfig' 'default': $ref: '#/components/responses/Error' - /v2/blockchain/blocks/{block_id}/config/raw: + /v2/blockchain/masterchain/{masterchain_seqno}/config/raw: get: description: Get raw blockchain config from a specific block, if present. operationId: getRawBlockchainConfigFromBlock tags: - Blockchain parameters: - - $ref: '#/components/parameters/blockchainBlockIDParameter' + - $ref: '#/components/parameters/masterchainSeqno' responses: '200': description: blockchain config @@ -86,6 +79,23 @@ paths: $ref: '#/components/schemas/RawBlockchainConfig' 'default': $ref: '#/components/responses/Error' + /v2/blockchain/blocks/{block_id}/transactions: + get: + description: Get transactions from block + operationId: getBlockchainBlockTransactions + tags: + - Blockchain + parameters: + - $ref: '#/components/parameters/blockchainBlockIDParameter' + responses: + '200': + description: blockchain block transactions + content: + application/json: + schema: + $ref: '#/components/schemas/Transactions' + 'default': + $ref: '#/components/responses/Error' /v2/blockchain/transactions/{transaction_id}: get: description: Get transaction data @@ -356,6 +366,11 @@ paths: - Emulation parameters: - $ref: '#/components/parameters/i18n' + - name: ignore_signature_check + in: query + required: false + schema: + type: boolean requestBody: $ref: "#/components/requestBodies/Boc" responses: @@ -373,6 +388,12 @@ paths: operationId: emulateMessageToTrace tags: - Emulation + parameters: + - name: ignore_signature_check + in: query + required: false + schema: + type: boolean requestBody: $ref: "#/components/requestBodies/Boc" responses: @@ -393,7 +414,7 @@ paths: parameters: - $ref: '#/components/parameters/i18n' requestBody: - $ref: "#/components/requestBodies/Boc" + $ref: "#/components/requestBodies/EmulationBoc" responses: '200': description: emulated message @@ -2205,6 +2226,15 @@ paths: $ref: '#/components/responses/Error' components: parameters: + masterchainSeqno: + in: path + name: masterchain_seqno + required: true + description: "masterchain block seqno" + schema: + type: integer + format: int32 + example: 123456 blockchainBlockIDParameter: in: path name: block_id @@ -2486,6 +2516,34 @@ components: items: type: string example: te6ccgECBQEAARUAAkWIAWTtae+KgtbrX26Bep8JSq8lFLfGOoyGR/xwdjfvpvEaHg + EmulationBoc: + description: bag-of-cells serialized to base64 and additional parameters to configure emulation + required: true + content: + application/json: + schema: + type: object + required: + - boc + properties: + boc: + type: string + example: te6ccgECBQEAARUAAkWIAWTtae+KgtbrX26Bep8JSq8lFLfGOoyGR/xwdjfvpvEaHg + params: + type: array + description: additional per account configuration + items: + type: object + required: + - address + properties: + address: + type: string + example: "0:97146a46acc2654y27947f14c4a4b14273e954f78bc017790b41208b0043200b" + balance: + type: integer + format: int64 + example: 10000000000 Boc: description: bag-of-cells serialized to base64 required: true @@ -4497,6 +4555,7 @@ components: - SmartContractExec - ElectionsRecoverStake - ElectionsDepositStake + - DomainRenew - Unknown status: type: string @@ -4538,6 +4597,8 @@ components: $ref: '#/components/schemas/JettonSwapAction' SmartContractExec: $ref: '#/components/schemas/SmartContractAction' + DomainRenew: + $ref: '#/components/schemas/DomainRenewAction' simple_preview: $ref: '#/components/schemas/ActionSimplePreview' TonTransferAction: @@ -4587,6 +4648,21 @@ components: type: string refund: $ref: '#/components/schemas/Refund' + DomainRenewAction: + type: object + required: + - domain + - contract_address + - renewer + properties: + domain: + type: string + example: "vasya.ton" + contract_address: + type: string + example: "0:da6b1b6663a0e4d18cc8574ccd9db5296e367dd9324706f3bbd9eb1cd2caf0bf" + renewer: + $ref: '#/components/schemas/AccountAddress' NftItemTransferAction: type: object required: diff --git a/oas_client_gen.go b/oas_client_gen.go index 5b7e91a..8f88eff 100644 --- a/oas_client_gen.go +++ b/oas_client_gen.go @@ -64,7 +64,7 @@ type Invoker interface { // Emulate sending message to blockchain. // // POST /v2/traces/emulate - EmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq) (*Trace, error) + EmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq, params EmulateMessageToTraceParams) (*Trace, error) // EmulateMessageToWallet invokes emulateMessageToWallet operation. // // Emulate sending message to blockchain. @@ -219,6 +219,12 @@ type Invoker interface { // // GET /v2/blockchain/config GetBlockchainConfig(ctx context.Context) (*BlockchainConfig, error) + // GetBlockchainConfigFromBlock invokes getBlockchainConfigFromBlock operation. + // + // Get blockchain config from a specific block, if present. + // + // GET /v2/blockchain/masterchain/{masterchain_seqno}/config + GetBlockchainConfigFromBlock(ctx context.Context, params GetBlockchainConfigFromBlockParams) (*BlockchainConfig, error) // GetBlockchainMasterchainHead invokes getBlockchainMasterchainHead operation. // // Get last known masterchain block. @@ -390,7 +396,7 @@ type Invoker interface { // // Get raw blockchain config from a specific block, if present. // - // GET /v2/blockchain/blocks/{block_id}/config/raw + // GET /v2/blockchain/masterchain/{masterchain_seqno}/config/raw GetRawBlockchainConfigFromBlock(ctx context.Context, params GetRawBlockchainConfigFromBlockParams) (*RawBlockchainConfig, error) // GetRawConfig invokes getRawConfig operation. // @@ -1095,6 +1101,27 @@ func (c *Client) sendEmulateMessageToEvent(ctx context.Context, request *Emulate pathParts[0] = "/v2/events/emulate" uri.AddPathParts(u, pathParts[:]...) + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() + { + // Encode "ignore_signature_check" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "ignore_signature_check", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.IgnoreSignatureCheck.Get(); ok { + return e.EncodeValue(conv.BoolToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + u.RawQuery = q.Values().Encode() + stage = "EncodeRequest" r, err := ht.NewRequest(ctx, "POST", u) if err != nil { @@ -1142,12 +1169,12 @@ func (c *Client) sendEmulateMessageToEvent(ctx context.Context, request *Emulate // Emulate sending message to blockchain. // // POST /v2/traces/emulate -func (c *Client) EmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq) (*Trace, error) { - res, err := c.sendEmulateMessageToTrace(ctx, request) +func (c *Client) EmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq, params EmulateMessageToTraceParams) (*Trace, error) { + res, err := c.sendEmulateMessageToTrace(ctx, request, params) return res, err } -func (c *Client) sendEmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq) (res *Trace, err error) { +func (c *Client) sendEmulateMessageToTrace(ctx context.Context, request *EmulateMessageToTraceReq, params EmulateMessageToTraceParams) (res *Trace, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("emulateMessageToTrace"), semconv.HTTPMethodKey.String("POST"), @@ -1187,6 +1214,27 @@ func (c *Client) sendEmulateMessageToTrace(ctx context.Context, request *Emulate pathParts[0] = "/v2/traces/emulate" uri.AddPathParts(u, pathParts[:]...) + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() + { + // Encode "ignore_signature_check" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "ignore_signature_check", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.IgnoreSignatureCheck.Get(); ok { + return e.EncodeValue(conv.BoolToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + u.RawQuery = q.Values().Encode() + stage = "EncodeRequest" r, err := ht.NewRequest(ctx, "POST", u) if err != nil { @@ -4176,6 +4224,97 @@ func (c *Client) sendGetBlockchainConfig(ctx context.Context) (res *BlockchainCo return result, nil } +// GetBlockchainConfigFromBlock invokes getBlockchainConfigFromBlock operation. +// +// Get blockchain config from a specific block, if present. +// +// GET /v2/blockchain/masterchain/{masterchain_seqno}/config +func (c *Client) GetBlockchainConfigFromBlock(ctx context.Context, params GetBlockchainConfigFromBlockParams) (*BlockchainConfig, error) { + res, err := c.sendGetBlockchainConfigFromBlock(ctx, params) + return res, err +} + +func (c *Client) sendGetBlockchainConfigFromBlock(ctx context.Context, params GetBlockchainConfigFromBlockParams) (res *BlockchainConfig, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("getBlockchainConfigFromBlock"), + semconv.HTTPMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/v2/blockchain/masterchain/{masterchain_seqno}/config"), + } + + // 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, "GetBlockchainConfigFromBlock", + 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 [3]string + pathParts[0] = "/v2/blockchain/masterchain/" + { + // Encode "masterchain_seqno" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "masterchain_seqno", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.Int32ToString(params.MasterchainSeqno)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[1] = encoded + } + pathParts[2] = "/config" + uri.AddPathParts(u, pathParts[:]...) + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "GET", u) + if err != nil { + return res, errors.Wrap(err, "create request") + } + + 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 := decodeGetBlockchainConfigFromBlockResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // GetBlockchainMasterchainHead invokes getBlockchainMasterchainHead operation. // // Get last known masterchain block. @@ -6940,7 +7079,7 @@ func (c *Client) sendGetRawBlockchainConfig(ctx context.Context) (res *RawBlockc // // Get raw blockchain config from a specific block, if present. // -// GET /v2/blockchain/blocks/{block_id}/config/raw +// GET /v2/blockchain/masterchain/{masterchain_seqno}/config/raw func (c *Client) GetRawBlockchainConfigFromBlock(ctx context.Context, params GetRawBlockchainConfigFromBlockParams) (*RawBlockchainConfig, error) { res, err := c.sendGetRawBlockchainConfigFromBlock(ctx, params) return res, err @@ -6950,7 +7089,7 @@ func (c *Client) sendGetRawBlockchainConfigFromBlock(ctx context.Context, params otelAttrs := []attribute.KeyValue{ otelogen.OperationID("getRawBlockchainConfigFromBlock"), semconv.HTTPMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/v2/blockchain/blocks/{block_id}/config/raw"), + semconv.HTTPRouteKey.String("/v2/blockchain/masterchain/{masterchain_seqno}/config/raw"), } // Run stopwatch. @@ -6983,16 +7122,16 @@ func (c *Client) sendGetRawBlockchainConfigFromBlock(ctx context.Context, params stage = "BuildURL" u := uri.Clone(c.requestURL(ctx)) var pathParts [3]string - pathParts[0] = "/v2/blockchain/blocks/" + pathParts[0] = "/v2/blockchain/masterchain/" { - // Encode "block_id" parameter. + // Encode "masterchain_seqno" parameter. e := uri.NewPathEncoder(uri.PathEncoderConfig{ - Param: "block_id", + Param: "masterchain_seqno", Style: uri.PathStyleSimple, Explode: false, }) if err := func() error { - return e.EncodeValue(conv.StringToString(params.BlockID)) + return e.EncodeValue(conv.Int32ToString(params.MasterchainSeqno)) }(); err != nil { return res, errors.Wrap(err, "encode path") } diff --git a/oas_json_gen.go b/oas_json_gen.go index 36c4a96..7030a87 100644 --- a/oas_json_gen.go +++ b/oas_json_gen.go @@ -1689,13 +1689,19 @@ func (s *Action) encodeFields(e *jx.Encoder) { s.SmartContractExec.Encode(e) } } + { + if s.DomainRenew.Set { + e.FieldStart("DomainRenew") + s.DomainRenew.Encode(e) + } + } { e.FieldStart("simple_preview") s.SimplePreview.Encode(e) } } -var jsonFieldsNameOfAction = [20]string{ +var jsonFieldsNameOfAction = [21]string{ 0: "type", 1: "status", 2: "TonTransfer", @@ -1715,7 +1721,8 @@ var jsonFieldsNameOfAction = [20]string{ 16: "ElectionsRecoverStake", 17: "JettonSwap", 18: "SmartContractExec", - 19: "simple_preview", + 19: "DomainRenew", + 20: "simple_preview", } // Decode decodes Action from json. @@ -1917,8 +1924,18 @@ func (s *Action) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"SmartContractExec\"") } + case "DomainRenew": + if err := func() error { + s.DomainRenew.Reset() + if err := s.DomainRenew.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"DomainRenew\"") + } case "simple_preview": - requiredBitSet[2] |= 1 << 3 + requiredBitSet[2] |= 1 << 4 if err := func() error { if err := s.SimplePreview.Decode(d); err != nil { return err @@ -1939,7 +1956,7 @@ func (s *Action) Decode(d *jx.Decoder) error { for i, mask := range [3]uint8{ 0b00000011, 0b00000000, - 0b00001000, + 0b00010000, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -2430,6 +2447,8 @@ func (s *ActionType) Decode(d *jx.Decoder) error { *s = ActionTypeElectionsRecoverStake case ActionTypeElectionsDepositStake: *s = ActionTypeElectionsDepositStake + case ActionTypeDomainRenew: + *s = ActionTypeDomainRenew case ActionTypeUnknown: *s = ActionTypeUnknown default: @@ -11770,6 +11789,134 @@ func (s *DomainNames) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *DomainRenewAction) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *DomainRenewAction) encodeFields(e *jx.Encoder) { + { + e.FieldStart("domain") + e.Str(s.Domain) + } + { + e.FieldStart("contract_address") + e.Str(s.ContractAddress) + } + { + e.FieldStart("renewer") + s.Renewer.Encode(e) + } +} + +var jsonFieldsNameOfDomainRenewAction = [3]string{ + 0: "domain", + 1: "contract_address", + 2: "renewer", +} + +// Decode decodes DomainRenewAction from json. +func (s *DomainRenewAction) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode DomainRenewAction to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "domain": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Domain = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"domain\"") + } + case "contract_address": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.ContractAddress = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"contract_address\"") + } + case "renewer": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Renewer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"renewer\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode DomainRenewAction") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + 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(jsonFieldsNameOfDomainRenewAction) { + name = jsonFieldsNameOfDomainRenewAction[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 *DomainRenewAction) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *DomainRenewAction) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *ElectionsDepositStakeAction) Encode(e *jx.Encoder) { e.ObjStart() @@ -12293,10 +12440,21 @@ func (s *EmulateMessageToWalletReq) encodeFields(e *jx.Encoder) { e.FieldStart("boc") e.Str(s.Boc) } + { + if s.Params != nil { + e.FieldStart("params") + e.ArrStart() + for _, elem := range s.Params { + elem.Encode(e) + } + e.ArrEnd() + } + } } -var jsonFieldsNameOfEmulateMessageToWalletReq = [1]string{ +var jsonFieldsNameOfEmulateMessageToWalletReq = [2]string{ 0: "boc", + 1: "params", } // Decode decodes EmulateMessageToWalletReq from json. @@ -12320,6 +12478,23 @@ func (s *EmulateMessageToWalletReq) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"boc\"") } + case "params": + if err := func() error { + s.Params = make([]EmulateMessageToWalletReqParamsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem EmulateMessageToWalletReqParamsItem + if err := elem.Decode(d); err != nil { + return err + } + s.Params = append(s.Params, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"params\"") + } default: return d.Skip() } @@ -12376,6 +12551,119 @@ func (s *EmulateMessageToWalletReq) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *EmulateMessageToWalletReqParamsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *EmulateMessageToWalletReqParamsItem) encodeFields(e *jx.Encoder) { + { + e.FieldStart("address") + e.Str(s.Address) + } + { + if s.Balance.Set { + e.FieldStart("balance") + s.Balance.Encode(e) + } + } +} + +var jsonFieldsNameOfEmulateMessageToWalletReqParamsItem = [2]string{ + 0: "address", + 1: "balance", +} + +// Decode decodes EmulateMessageToWalletReqParamsItem from json. +func (s *EmulateMessageToWalletReqParamsItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode EmulateMessageToWalletReqParamsItem to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "address": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Address = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"address\"") + } + case "balance": + if err := func() error { + s.Balance.Reset() + if err := s.Balance.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"balance\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode EmulateMessageToWalletReqParamsItem") + } + // 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(jsonFieldsNameOfEmulateMessageToWalletReqParamsItem) { + name = jsonFieldsNameOfEmulateMessageToWalletReqParamsItem[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 *EmulateMessageToWalletReqParamsItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *EmulateMessageToWalletReqParamsItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *EncryptedComment) Encode(e *jx.Encoder) { e.ObjStart() @@ -24343,6 +24631,39 @@ func (s *OptDepositStakeAction) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes DomainRenewAction as json. +func (o OptDomainRenewAction) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes DomainRenewAction from json. +func (o *OptDomainRenewAction) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptDomainRenewAction to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptDomainRenewAction) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptDomainRenewAction) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes ElectionsDepositStakeAction as json. func (o OptElectionsDepositStakeAction) Encode(e *jx.Encoder) { if !o.Set { diff --git a/oas_parameters_gen.go b/oas_parameters_gen.go index e9f5c0d..059322d 100644 --- a/oas_parameters_gen.go +++ b/oas_parameters_gen.go @@ -35,7 +35,13 @@ type EmulateMessageToAccountEventParams struct { // EmulateMessageToEventParams is parameters of emulateMessageToEvent operation. type EmulateMessageToEventParams struct { - AcceptLanguage OptString + AcceptLanguage OptString + IgnoreSignatureCheck OptBool +} + +// EmulateMessageToTraceParams is parameters of emulateMessageToTrace operation. +type EmulateMessageToTraceParams struct { + IgnoreSignatureCheck OptBool } // EmulateMessageToWalletParams is parameters of emulateMessageToWallet operation. @@ -226,6 +232,12 @@ type GetBlockchainBlockTransactionsParams struct { BlockID string } +// GetBlockchainConfigFromBlockParams is parameters of getBlockchainConfigFromBlock operation. +type GetBlockchainConfigFromBlockParams struct { + // Masterchain block seqno. + MasterchainSeqno int32 +} + // GetBlockchainMasterchainShardsParams is parameters of getBlockchainMasterchainShards operation. type GetBlockchainMasterchainShardsParams struct { // Masterchain block seqno. @@ -391,8 +403,8 @@ type GetRawBlockchainBlockStateParams struct { // GetRawBlockchainConfigFromBlockParams is parameters of getRawBlockchainConfigFromBlock operation. type GetRawBlockchainConfigFromBlockParams struct { - // Block ID. - BlockID string + // Masterchain block seqno. + MasterchainSeqno int32 } // GetRawConfigParams is parameters of getRawConfig operation. diff --git a/oas_response_decoders_gen.go b/oas_response_decoders_gen.go index 2e36a9e..7df9340 100644 --- a/oas_response_decoders_gen.go +++ b/oas_response_decoders_gen.go @@ -2670,6 +2670,89 @@ func decodeGetBlockchainConfigResponse(resp *http.Response) (res *BlockchainConf return res, errors.Wrap(defRes, "error") } +func decodeGetBlockchainConfigFromBlockResponse(resp *http.Response) (res *BlockchainConfig, _ 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 BlockchainConfig + 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 decodeGetBlockchainMasterchainHeadResponse(resp *http.Response) (res *BlockchainBlock, _ error) { switch resp.StatusCode { case 200: diff --git a/oas_schemas_gen.go b/oas_schemas_gen.go index 8761057..1f37b23 100644 --- a/oas_schemas_gen.go +++ b/oas_schemas_gen.go @@ -639,6 +639,7 @@ type Action struct { ElectionsRecoverStake OptElectionsRecoverStakeAction `json:"ElectionsRecoverStake"` JettonSwap OptJettonSwapAction `json:"JettonSwap"` SmartContractExec OptSmartContractAction `json:"SmartContractExec"` + DomainRenew OptDomainRenewAction `json:"DomainRenew"` SimplePreview ActionSimplePreview `json:"simple_preview"` } @@ -737,6 +738,11 @@ func (s *Action) GetSmartContractExec() OptSmartContractAction { return s.SmartContractExec } +// GetDomainRenew returns the value of DomainRenew. +func (s *Action) GetDomainRenew() OptDomainRenewAction { + return s.DomainRenew +} + // GetSimplePreview returns the value of SimplePreview. func (s *Action) GetSimplePreview() ActionSimplePreview { return s.SimplePreview @@ -837,6 +843,11 @@ func (s *Action) SetSmartContractExec(val OptSmartContractAction) { s.SmartContractExec = val } +// SetDomainRenew sets the value of DomainRenew. +func (s *Action) SetDomainRenew(val OptDomainRenewAction) { + s.DomainRenew = val +} + // SetSimplePreview sets the value of SimplePreview. func (s *Action) SetSimplePreview(val ActionSimplePreview) { s.SimplePreview = val @@ -1035,6 +1046,7 @@ const ( ActionTypeSmartContractExec ActionType = "SmartContractExec" ActionTypeElectionsRecoverStake ActionType = "ElectionsRecoverStake" ActionTypeElectionsDepositStake ActionType = "ElectionsDepositStake" + ActionTypeDomainRenew ActionType = "DomainRenew" ActionTypeUnknown ActionType = "Unknown" ) @@ -1058,6 +1070,7 @@ func (ActionType) AllValues() []ActionType { ActionTypeSmartContractExec, ActionTypeElectionsRecoverStake, ActionTypeElectionsDepositStake, + ActionTypeDomainRenew, ActionTypeUnknown, } } @@ -1099,6 +1112,8 @@ func (s ActionType) MarshalText() ([]byte, error) { return []byte(s), nil case ActionTypeElectionsDepositStake: return []byte(s), nil + case ActionTypeDomainRenew: + return []byte(s), nil case ActionTypeUnknown: return []byte(s), nil default: @@ -1160,6 +1175,9 @@ func (s *ActionType) UnmarshalText(data []byte) error { case ActionTypeElectionsDepositStake: *s = ActionTypeElectionsDepositStake return nil + case ActionTypeDomainRenew: + *s = ActionTypeDomainRenew + return nil case ActionTypeUnknown: *s = ActionTypeUnknown return nil @@ -4248,6 +4266,43 @@ func (s *DomainNames) SetDomains(val []string) { s.Domains = val } +// Ref: #/components/schemas/DomainRenewAction +type DomainRenewAction struct { + Domain string `json:"domain"` + ContractAddress string `json:"contract_address"` + Renewer AccountAddress `json:"renewer"` +} + +// GetDomain returns the value of Domain. +func (s *DomainRenewAction) GetDomain() string { + return s.Domain +} + +// GetContractAddress returns the value of ContractAddress. +func (s *DomainRenewAction) GetContractAddress() string { + return s.ContractAddress +} + +// GetRenewer returns the value of Renewer. +func (s *DomainRenewAction) GetRenewer() AccountAddress { + return s.Renewer +} + +// SetDomain sets the value of Domain. +func (s *DomainRenewAction) SetDomain(val string) { + s.Domain = val +} + +// SetContractAddress sets the value of ContractAddress. +func (s *DomainRenewAction) SetContractAddress(val string) { + s.ContractAddress = val +} + +// SetRenewer sets the value of Renewer. +func (s *DomainRenewAction) SetRenewer(val AccountAddress) { + s.Renewer = val +} + // Ref: #/components/schemas/ElectionsDepositStakeAction type ElectionsDepositStakeAction struct { Amount int64 `json:"amount"` @@ -4344,6 +4399,8 @@ func (s *EmulateMessageToTraceReq) SetBoc(val string) { type EmulateMessageToWalletReq struct { Boc string `json:"boc"` + // Additional per account configuration. + Params []EmulateMessageToWalletReqParamsItem `json:"params"` } // GetBoc returns the value of Boc. @@ -4351,11 +4408,46 @@ func (s *EmulateMessageToWalletReq) GetBoc() string { return s.Boc } +// GetParams returns the value of Params. +func (s *EmulateMessageToWalletReq) GetParams() []EmulateMessageToWalletReqParamsItem { + return s.Params +} + // SetBoc sets the value of Boc. func (s *EmulateMessageToWalletReq) SetBoc(val string) { s.Boc = val } +// SetParams sets the value of Params. +func (s *EmulateMessageToWalletReq) SetParams(val []EmulateMessageToWalletReqParamsItem) { + s.Params = val +} + +type EmulateMessageToWalletReqParamsItem struct { + Address string `json:"address"` + Balance OptInt64 `json:"balance"` +} + +// GetAddress returns the value of Address. +func (s *EmulateMessageToWalletReqParamsItem) GetAddress() string { + return s.Address +} + +// GetBalance returns the value of Balance. +func (s *EmulateMessageToWalletReqParamsItem) GetBalance() OptInt64 { + return s.Balance +} + +// SetAddress sets the value of Address. +func (s *EmulateMessageToWalletReqParamsItem) SetAddress(val string) { + s.Address = val +} + +// SetBalance sets the value of Balance. +func (s *EmulateMessageToWalletReqParamsItem) SetBalance(val OptInt64) { + s.Balance = val +} + // Ref: #/components/schemas/EncryptedComment type EncryptedComment struct { EncryptionType string `json:"encryption_type"` @@ -9749,6 +9841,52 @@ func (o OptDepositStakeAction) Or(d DepositStakeAction) DepositStakeAction { return d } +// NewOptDomainRenewAction returns new OptDomainRenewAction with value set to v. +func NewOptDomainRenewAction(v DomainRenewAction) OptDomainRenewAction { + return OptDomainRenewAction{ + Value: v, + Set: true, + } +} + +// OptDomainRenewAction is optional DomainRenewAction. +type OptDomainRenewAction struct { + Value DomainRenewAction + Set bool +} + +// IsSet returns true if OptDomainRenewAction was set. +func (o OptDomainRenewAction) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptDomainRenewAction) Reset() { + var v DomainRenewAction + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptDomainRenewAction) SetTo(v DomainRenewAction) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptDomainRenewAction) Get() (v DomainRenewAction, 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 OptDomainRenewAction) Or(d DomainRenewAction) DomainRenewAction { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptElectionsDepositStakeAction returns new OptElectionsDepositStakeAction with value set to v. func NewOptElectionsDepositStakeAction(v ElectionsDepositStakeAction) OptElectionsDepositStakeAction { return OptElectionsDepositStakeAction{ diff --git a/oas_validators_gen.go b/oas_validators_gen.go index cdede75..8de057d 100644 --- a/oas_validators_gen.go +++ b/oas_validators_gen.go @@ -525,6 +525,8 @@ func (s ActionType) Validate() error { return nil case "ElectionsDepositStake": return nil + case "DomainRenew": + return nil case "Unknown": return nil default: