diff --git a/CHANGELOG.md b/CHANGELOG.md index 9edafd9f..7ddb8151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,3 +31,6 @@ ### 2023-10-22 - `/v2/blockchain/validators` method which returns the current validators and theirs stakes. + +### 2023-10-23 +- `/v2/blockchain/blocks/{block_id}` returns a value flow from a block. diff --git a/api/openapi.json b/api/openapi.json index 48ed629f..f2e6b6ab 100644 --- a/api/openapi.json +++ b/api/openapi.json @@ -1174,6 +1174,41 @@ ], "type": "object" }, + "BlockCurrencyCollection": { + "properties": { + "grams": { + "example": 10000000000, + "format": "int64", + "type": "integer" + }, + "other": { + "items": { + "properties": { + "id": { + "example": 13, + "format": "int64", + "type": "integer" + }, + "value": { + "example": "10000000000", + "type": "string" + } + }, + "required": [ + "id", + "value" + ], + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "grams", + "other" + ], + "type": "object" + }, "BlockLimits": { "properties": { "bytes": { @@ -1253,6 +1288,52 @@ ], "type": "object" }, + "BlockValueFlow": { + "properties": { + "burned": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "created": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "exported": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "fees_collected": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "fees_imported": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "from_prev_blk": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "imported": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "minted": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "recovered": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + }, + "to_next_blk": { + "$ref": "#/components/schemas/BlockCurrencyCollection" + } + }, + "required": [ + "from_prev_blk", + "to_next_blk", + "imported", + "exported", + "fees_collected", + "fees_imported", + "recovered", + "created", + "minted" + ], + "type": "object" + }, "BlockchainAccountInspect": { "properties": { "code": { @@ -1408,6 +1489,9 @@ "format": "int64", "type": "integer" }, + "value_flow": { + "$ref": "#/components/schemas/BlockValueFlow" + }, "version": { "example": 0, "format": "int32", @@ -1439,6 +1523,7 @@ "root_hash", "file_hash", "global_id", + "value_flow", "version", "after_merge", "before_split", diff --git a/api/openapi.yml b/api/openapi.yml index 5b8f596d..aa81a9f6 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -2680,6 +2680,65 @@ components: is_wallet: type: boolean example: true + BlockCurrencyCollection: + type: object + required: + - grams + - other + properties: + grams: + type: integer + format: int64 + example: 10000000000 + other: + type: array + items: + type: object + required: + - id + - value + properties: + id: + type: integer + format: int64 + example: 13 + value: + type: string + example: "10000000000" + BlockValueFlow: + type: object + required: + - from_prev_blk + - to_next_blk + - imported + - exported + - fees_collected + - fees_imported + - recovered + - created + - minted + properties: + from_prev_blk: + $ref: '#/components/schemas/BlockCurrencyCollection' + to_next_blk: + $ref: '#/components/schemas/BlockCurrencyCollection' + imported: + $ref: '#/components/schemas/BlockCurrencyCollection' + exported: + $ref: '#/components/schemas/BlockCurrencyCollection' + fees_collected: + $ref: '#/components/schemas/BlockCurrencyCollection' + burned: + $ref: '#/components/schemas/BlockCurrencyCollection' + fees_imported: + $ref: '#/components/schemas/BlockCurrencyCollection' + recovered: + $ref: '#/components/schemas/BlockCurrencyCollection' + created: + $ref: '#/components/schemas/BlockCurrencyCollection' + minted: + $ref: '#/components/schemas/BlockCurrencyCollection' + BlockchainBlock: type: object required: @@ -2689,7 +2748,7 @@ components: - root_hash - file_hash - global_id - # ValueFlow pgtype.JSONB + - value_flow - version - after_merge - before_split @@ -2710,6 +2769,8 @@ components: - rand_seed - created_by properties: + value_flow: + $ref: '#/components/schemas/BlockValueFlow' workchain_id: type: integer example: 0 diff --git a/pkg/api/blockchain_converters.go b/pkg/api/blockchain_converters.go index c572da93..6eb2f17c 100644 --- a/pkg/api/blockchain_converters.go +++ b/pkg/api/blockchain_converters.go @@ -37,6 +37,19 @@ func blockIdExtFromString(s string) (tongo.BlockIDExt, error) { return id, nil } +func convertValueFlow(collection core.CurrencyCollection) oas.BlockCurrencyCollection { + res := oas.BlockCurrencyCollection{ + Grams: int64(collection.Grams), + Other: make([]oas.BlockCurrencyCollectionOtherItem, 0, len(collection.Other)), + } + for _, c := range collection.Other { + res.Other = append(res.Other, oas.BlockCurrencyCollectionOtherItem{ + ID: c.ID, + Value: c.Value, + }) + } + return res +} func convertBlockHeader(b core.BlockHeader) oas.BlockchainBlock { res := oas.BlockchainBlock{ WorkchainID: b.Workchain, @@ -63,6 +76,20 @@ func convertBlockHeader(b core.BlockHeader) oas.BlockchainBlock { OutMsgDescrLength: int64(b.BlockExtra.OutMsgDescrLength), RandSeed: fmt.Sprintf("%x", b.BlockExtra.RandSeed), CreatedBy: fmt.Sprintf("%x", b.BlockExtra.CreatedBy), + ValueFlow: oas.BlockValueFlow{ + FromPrevBlk: convertValueFlow(b.ValueFlow.FromPrevBlk), + ToNextBlk: convertValueFlow(b.ValueFlow.ToNextBlk), + Imported: convertValueFlow(b.ValueFlow.Imported), + Exported: convertValueFlow(b.ValueFlow.Exported), + FeesCollected: convertValueFlow(b.ValueFlow.FeesCollected), + FeesImported: convertValueFlow(b.ValueFlow.FeesImported), + Recovered: convertValueFlow(b.ValueFlow.Recovered), + Created: convertValueFlow(b.ValueFlow.Created), + Minted: convertValueFlow(b.ValueFlow.Minted), + }, + } + if b.ValueFlow.Burned != nil { + res.ValueFlow.Burned = oas.NewOptBlockCurrencyCollection(convertValueFlow(*b.ValueFlow.Burned)) } if b.GenSoftware != nil { res.GenSoftwareVersion.SetTo(int32(b.GenSoftware.Version)) diff --git a/pkg/api/blockchain_handlers_test.go b/pkg/api/blockchain_handlers_test.go index 88de1ba6..7a78c8af 100644 --- a/pkg/api/blockchain_handlers_test.go +++ b/pkg/api/blockchain_handlers_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/tonkeeper/opentonapi/pkg/litestorage" "github.com/tonkeeper/opentonapi/pkg/oas" + pkgTesting "github.com/tonkeeper/opentonapi/pkg/testing" "github.com/tonkeeper/tongo/config" "github.com/tonkeeper/tongo/ton" "go.uber.org/zap" @@ -188,3 +189,41 @@ func TestHandler_GetBlockchainValidators(t *testing.T) { } require.Equal(t, validators.ElectAt, int64(curValidators.UtimeSince)) } + +func TestHandler_GetBlockchainBlock(t *testing.T) { + var servers []config.LiteServer + if env, ok := os.LookupEnv("LITE_SERVERS"); ok { + var err error + servers, err = config.ParseLiteServersEnvVar(env) + require.Nil(t, err) + } + tests := []struct { + name string + blockID string + filenamePrefix string + }{ + { + name: "block from masterchain, no burned", + blockID: "(-1,8000000000000000,34336028)", + filenamePrefix: "block-1-8000000000000000-34336028", + }, + { + name: "block from masterchain with value burned", + blockID: "(-1,8000000000000000,34336196)", + filenamePrefix: "block-1-8000000000000000-34336196", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + logger := zap.L() + liteStorage, err := litestorage.NewLiteStorage(logger, litestorage.WithLiteServers(servers)) + require.Nil(t, err) + h, err := NewHandler(logger, WithStorage(liteStorage), WithExecutor(liteStorage)) + require.Nil(t, err) + params := oas.GetBlockchainBlockParams{BlockID: tt.blockID} + block, err := h.GetBlockchainBlock(context.Background(), params) + require.Nil(t, err) + pkgTesting.CompareResults(t, block, tt.filenamePrefix) + }) + } +} diff --git a/pkg/api/testdata/block-1-8000000000000000-34336028.json b/pkg/api/testdata/block-1-8000000000000000-34336028.json new file mode 100644 index 00000000..99db3ad9 --- /dev/null +++ b/pkg/api/testdata/block-1-8000000000000000-34336028.json @@ -0,0 +1,87 @@ +{ + "value_flow": { + "from_prev_blk": { + "grams": 1917883300491494921, + "other": [ + { + "id": 239, + "value": "664333333334" + }, + { + "id": 4294967279, + "value": "998444444446" + } + ] + }, + "to_next_blk": { + "grams": 1917883303191494921, + "other": [ + { + "id": 239, + "value": "664333333334" + }, + { + "id": 4294967279, + "value": "998444444446" + } + ] + }, + "imported": { + "grams": 0, + "other": [] + }, + "exported": { + "grams": 0, + "other": [] + }, + "fees_collected": { + "grams": 2700000000, + "other": [] + }, + "fees_imported": { + "grams": 1000000000, + "other": [] + }, + "recovered": { + "grams": 2700000000, + "other": [] + }, + "created": { + "grams": 1700000000, + "other": [] + }, + "minted": { + "grams": 0, + "other": [] + } + }, + "workchain_id": -1, + "shard": "8000000000000000", + "seqno": 34336028, + "root_hash": "9933d579f836d4f0fd23cfd1e04baa476bcb15a7a6dd21ff9e198adf468199fb", + "file_hash": "04e5114839d6a2fd5ea239872b6a434f334998c3477b7837ad38994d32b64ed2", + "global_id": -239, + "version": 0, + "after_merge": false, + "before_split": false, + "after_split": false, + "want_split": false, + "want_merge": true, + "key_block": false, + "gen_utime": 1700756239, + "start_lt": 42747819000000, + "end_lt": 42747819000004, + "vert_seqno": 1, + "gen_catchain_seqno": 503952, + "min_ref_mc_seqno": 34336025, + "prev_key_block_seqno": 34333054, + "gen_software_version": 3, + "gen_software_capabilities": 46, + "prev_refs": [ + "(-1,8000000000000000,34336027)" + ], + "in_msg_descr_length": 1, + "out_msg_descr_length": 0, + "rand_seed": "0000000000000000b10000000000000000aeb23a857f000020eafd767d7f0000", + "created_by": "9efb2f376248f8b880c8c90b502b7939df2f3a43788ffa1c3c83706e34a87c3f" + } \ No newline at end of file diff --git a/pkg/api/testdata/block-1-8000000000000000-34336196.json b/pkg/api/testdata/block-1-8000000000000000-34336196.json new file mode 100644 index 00000000..f027f893 --- /dev/null +++ b/pkg/api/testdata/block-1-8000000000000000-34336196.json @@ -0,0 +1,91 @@ +{ + "value_flow": { + "from_prev_blk": { + "grams": 1917883763660307228, + "other": [ + { + "id": 239, + "value": "664333333334" + }, + { + "id": 4294967279, + "value": "998444444446" + } + ] + }, + "to_next_blk": { + "grams": 1917883766451994447, + "other": [ + { + "id": 239, + "value": "664333333334" + }, + { + "id": 4294967279, + "value": "998444444446" + } + ] + }, + "imported": { + "grams": 0, + "other": [] + }, + "exported": { + "grams": 0, + "other": [] + }, + "fees_collected": { + "grams": 2791687219, + "other": [] + }, + "burned": { + "grams": 91687219, + "other": [] + }, + "fees_imported": { + "grams": 1183374438, + "other": [] + }, + "recovered": { + "grams": 2791687219, + "other": [] + }, + "created": { + "grams": 1700000000, + "other": [] + }, + "minted": { + "grams": 0, + "other": [] + } + }, + "workchain_id": -1, + "shard": "8000000000000000", + "seqno": 34336196, + "root_hash": "b9f3226eea96a247db7a4de4dfad77a6a8125c91f07e5521a7cf79a58acf16ed", + "file_hash": "9cb059078d6b8419be517ca27fd15fd41b2599fe7e2a3d09bcbffb6a3d483585", + "global_id": -239, + "version": 0, + "after_merge": false, + "before_split": false, + "after_split": false, + "want_split": false, + "want_merge": true, + "key_block": false, + "gen_utime": 1700756872, + "start_lt": 42747995000000, + "end_lt": 42747995000004, + "vert_seqno": 1, + "gen_catchain_seqno": 503955, + "min_ref_mc_seqno": 34336193, + "prev_key_block_seqno": 34333054, + "gen_software_version": 3, + "gen_software_capabilities": 46, + "prev_refs": [ + "(-1,8000000000000000,34336195)" + ], + "in_msg_descr_length": 1, + "out_msg_descr_length": 0, + "rand_seed": "f01f0000000000003020000000000000c0720815c28f5cf3d881a67ed1827dae", + "created_by": "404c4a0de10800e48f6d257a84aef1b57a73db5ac8eae6cf0f7f68bcfff87400" + } \ No newline at end of file diff --git a/pkg/core/block.go b/pkg/core/block.go index 91990cfe..cc93eb75 100644 --- a/pkg/core/block.go +++ b/pkg/core/block.go @@ -29,6 +29,7 @@ type BlockHeader struct { // It is up to the software to include this piece of information. GenSoftware *GenSoftware BlockExtra BlockExtra + ValueFlow ValueFlow } // GenSoftware describes version and capabilities of software that created a blockchain block. @@ -45,3 +46,26 @@ type BlockExtra struct { // OutMsgDescrLength is a length of the outbound message queue of a block. OutMsgDescrLength int } + +type Currency struct { + ID int64 + Value string +} + +type CurrencyCollection struct { + Grams uint64 + Other []Currency +} + +type ValueFlow struct { + FromPrevBlk CurrencyCollection + ToNextBlk CurrencyCollection + Imported CurrencyCollection + Exported CurrencyCollection + FeesCollected CurrencyCollection + Burned *CurrencyCollection + FeesImported CurrencyCollection + Recovered CurrencyCollection + Created CurrencyCollection + Minted CurrencyCollection +} diff --git a/pkg/core/converters.go b/pkg/core/converters.go index 66253efd..dbdc01ee 100644 --- a/pkg/core/converters.go +++ b/pkg/core/converters.go @@ -3,6 +3,7 @@ package core import ( "fmt" "math/big" + "sort" "github.com/shopspring/decimal" "github.com/tonkeeper/tongo" @@ -39,6 +40,22 @@ func ConvertToBlockHeader(id tongo.BlockIDExt, block *tlb.Block) (*BlockHeader, InMsgDescrLength: len(block.Extra.InMsgDescr.Keys()), OutMsgDescrLength: len(block.Extra.OutMsgDescr.Keys()), }, + ValueFlow: ValueFlow{ + FromPrevBlk: ConvertToCurrencyCollection(block.ValueFlow.FromPrevBlk), + ToNextBlk: ConvertToCurrencyCollection(block.ValueFlow.ToNextBlk), + Imported: ConvertToCurrencyCollection(block.ValueFlow.Imported), + Exported: ConvertToCurrencyCollection(block.ValueFlow.Exported), + FeesCollected: ConvertToCurrencyCollection(block.ValueFlow.FeesCollected), + Burned: nil, + FeesImported: ConvertToCurrencyCollection(block.ValueFlow.FeesImported), + Recovered: ConvertToCurrencyCollection(block.ValueFlow.Recovered), + Created: ConvertToCurrencyCollection(block.ValueFlow.Created), + Minted: ConvertToCurrencyCollection(block.ValueFlow.Minted), + }, + } + if block.ValueFlow.Burned != nil { + burned := ConvertToCurrencyCollection(*block.ValueFlow.Burned) + header.ValueFlow.Burned = &burned } if info.GenSoftware != nil { header.GenSoftware = &GenSoftware{ @@ -427,3 +444,24 @@ func ExtractTransactions(id tongo.BlockIDExt, block *tlb.Block) ([]*Transaction, } return transactions, nil } + +func ConvertToCurrencyCollection(collection tlb.CurrencyCollection) CurrencyCollection { + var other []Currency + if len(collection.Other.Dict.Keys()) > 0 { + other = make([]Currency, 0, len(collection.Other.Dict.Items())) + for _, item := range collection.Other.Dict.Items() { + value := big.Int(item.Value) + other = append(other, Currency{ + ID: int64(item.Key), + Value: value.String(), + }) + } + sort.Slice(other, func(i, j int) bool { + return other[i].ID < other[j].ID + }) + } + return CurrencyCollection{ + Grams: uint64(collection.Grams), + Other: other, + } +} diff --git a/pkg/oas/oas_json_gen.go b/pkg/oas/oas_json_gen.go index 5dbf7811..edc15112 100644 --- a/pkg/oas/oas_json_gen.go +++ b/pkg/oas/oas_json_gen.go @@ -3457,6 +3457,242 @@ func (s *Auctions) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *BlockCurrencyCollection) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockCurrencyCollection) encodeFields(e *jx.Encoder) { + { + e.FieldStart("grams") + e.Int64(s.Grams) + } + { + e.FieldStart("other") + e.ArrStart() + for _, elem := range s.Other { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfBlockCurrencyCollection = [2]string{ + 0: "grams", + 1: "other", +} + +// Decode decodes BlockCurrencyCollection from json. +func (s *BlockCurrencyCollection) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockCurrencyCollection to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "grams": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int64() + s.Grams = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grams\"") + } + case "other": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.Other = make([]BlockCurrencyCollectionOtherItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem BlockCurrencyCollectionOtherItem + if err := elem.Decode(d); err != nil { + return err + } + s.Other = append(s.Other, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"other\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockCurrencyCollection") + } + // 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(jsonFieldsNameOfBlockCurrencyCollection) { + name = jsonFieldsNameOfBlockCurrencyCollection[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 *BlockCurrencyCollection) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockCurrencyCollection) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BlockCurrencyCollectionOtherItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockCurrencyCollectionOtherItem) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + e.Int64(s.ID) + } + { + e.FieldStart("value") + e.Str(s.Value) + } +} + +var jsonFieldsNameOfBlockCurrencyCollectionOtherItem = [2]string{ + 0: "id", + 1: "value", +} + +// Decode decodes BlockCurrencyCollectionOtherItem from json. +func (s *BlockCurrencyCollectionOtherItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockCurrencyCollectionOtherItem to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int64() + s.ID = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Value = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockCurrencyCollectionOtherItem") + } + // 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(jsonFieldsNameOfBlockCurrencyCollectionOtherItem) { + name = jsonFieldsNameOfBlockCurrencyCollectionOtherItem[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 *BlockCurrencyCollectionOtherItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockCurrencyCollectionOtherItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *BlockLimits) Encode(e *jx.Encoder) { e.ObjStart() @@ -3875,6 +4111,238 @@ func (s *BlockRaw) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *BlockValueFlow) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockValueFlow) encodeFields(e *jx.Encoder) { + { + e.FieldStart("from_prev_blk") + s.FromPrevBlk.Encode(e) + } + { + e.FieldStart("to_next_blk") + s.ToNextBlk.Encode(e) + } + { + e.FieldStart("imported") + s.Imported.Encode(e) + } + { + e.FieldStart("exported") + s.Exported.Encode(e) + } + { + e.FieldStart("fees_collected") + s.FeesCollected.Encode(e) + } + { + if s.Burned.Set { + e.FieldStart("burned") + s.Burned.Encode(e) + } + } + { + e.FieldStart("fees_imported") + s.FeesImported.Encode(e) + } + { + e.FieldStart("recovered") + s.Recovered.Encode(e) + } + { + e.FieldStart("created") + s.Created.Encode(e) + } + { + e.FieldStart("minted") + s.Minted.Encode(e) + } +} + +var jsonFieldsNameOfBlockValueFlow = [10]string{ + 0: "from_prev_blk", + 1: "to_next_blk", + 2: "imported", + 3: "exported", + 4: "fees_collected", + 5: "burned", + 6: "fees_imported", + 7: "recovered", + 8: "created", + 9: "minted", +} + +// Decode decodes BlockValueFlow from json. +func (s *BlockValueFlow) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockValueFlow to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "from_prev_blk": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.FromPrevBlk.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"from_prev_blk\"") + } + case "to_next_blk": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.ToNextBlk.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"to_next_blk\"") + } + case "imported": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Imported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"imported\"") + } + case "exported": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Exported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"exported\"") + } + case "fees_collected": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.FeesCollected.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fees_collected\"") + } + case "burned": + if err := func() error { + s.Burned.Reset() + if err := s.Burned.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"burned\"") + } + case "fees_imported": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + if err := s.FeesImported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fees_imported\"") + } + case "recovered": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + if err := s.Recovered.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"recovered\"") + } + case "created": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + if err := s.Created.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created\"") + } + case "minted": + requiredBitSet[1] |= 1 << 1 + if err := func() error { + if err := s.Minted.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"minted\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockValueFlow") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b11011111, + 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(jsonFieldsNameOfBlockValueFlow) { + name = jsonFieldsNameOfBlockValueFlow[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 *BlockValueFlow) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockValueFlow) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *BlockchainAccountInspect) Encode(e *jx.Encoder) { e.ObjStart() @@ -4192,6 +4660,10 @@ func (s *BlockchainBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *BlockchainBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value_flow") + s.ValueFlow.Encode(e) + } { e.FieldStart("workchain_id") e.Int32(s.WorkchainID) @@ -4316,35 +4788,36 @@ func (s *BlockchainBlock) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfBlockchainBlock = [28]string{ - 0: "workchain_id", - 1: "shard", - 2: "seqno", - 3: "root_hash", - 4: "file_hash", - 5: "global_id", - 6: "version", - 7: "after_merge", - 8: "before_split", - 9: "after_split", - 10: "want_split", - 11: "want_merge", - 12: "key_block", - 13: "gen_utime", - 14: "start_lt", - 15: "end_lt", - 16: "vert_seqno", - 17: "gen_catchain_seqno", - 18: "min_ref_mc_seqno", - 19: "prev_key_block_seqno", - 20: "gen_software_version", - 21: "gen_software_capabilities", - 22: "master_ref", - 23: "prev_refs", - 24: "in_msg_descr_length", - 25: "out_msg_descr_length", - 26: "rand_seed", - 27: "created_by", +var jsonFieldsNameOfBlockchainBlock = [29]string{ + 0: "value_flow", + 1: "workchain_id", + 2: "shard", + 3: "seqno", + 4: "root_hash", + 5: "file_hash", + 6: "global_id", + 7: "version", + 8: "after_merge", + 9: "before_split", + 10: "after_split", + 11: "want_split", + 12: "want_merge", + 13: "key_block", + 14: "gen_utime", + 15: "start_lt", + 16: "end_lt", + 17: "vert_seqno", + 18: "gen_catchain_seqno", + 19: "min_ref_mc_seqno", + 20: "prev_key_block_seqno", + 21: "gen_software_version", + 22: "gen_software_capabilities", + 23: "master_ref", + 24: "prev_refs", + 25: "in_msg_descr_length", + 26: "out_msg_descr_length", + 27: "rand_seed", + 28: "created_by", } // Decode decodes BlockchainBlock from json. @@ -4356,8 +4829,18 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "workchain_id": + case "value_flow": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.ValueFlow.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value_flow\"") + } + case "workchain_id": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Int32() s.WorkchainID = int32(v) @@ -4369,7 +4852,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"workchain_id\"") } case "shard": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() s.Shard = string(v) @@ -4381,7 +4864,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"shard\"") } case "seqno": - requiredBitSet[0] |= 1 << 2 + requiredBitSet[0] |= 1 << 3 if err := func() error { v, err := d.Int32() s.Seqno = int32(v) @@ -4393,7 +4876,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"seqno\"") } case "root_hash": - requiredBitSet[0] |= 1 << 3 + requiredBitSet[0] |= 1 << 4 if err := func() error { v, err := d.Str() s.RootHash = string(v) @@ -4405,7 +4888,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"root_hash\"") } case "file_hash": - requiredBitSet[0] |= 1 << 4 + requiredBitSet[0] |= 1 << 5 if err := func() error { v, err := d.Str() s.FileHash = string(v) @@ -4417,7 +4900,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"file_hash\"") } case "global_id": - requiredBitSet[0] |= 1 << 5 + requiredBitSet[0] |= 1 << 6 if err := func() error { v, err := d.Int32() s.GlobalID = int32(v) @@ -4429,7 +4912,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"global_id\"") } case "version": - requiredBitSet[0] |= 1 << 6 + requiredBitSet[0] |= 1 << 7 if err := func() error { v, err := d.Int32() s.Version = int32(v) @@ -4441,7 +4924,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"version\"") } case "after_merge": - requiredBitSet[0] |= 1 << 7 + requiredBitSet[1] |= 1 << 0 if err := func() error { v, err := d.Bool() s.AfterMerge = bool(v) @@ -4453,7 +4936,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"after_merge\"") } case "before_split": - requiredBitSet[1] |= 1 << 0 + requiredBitSet[1] |= 1 << 1 if err := func() error { v, err := d.Bool() s.BeforeSplit = bool(v) @@ -4465,7 +4948,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"before_split\"") } case "after_split": - requiredBitSet[1] |= 1 << 1 + requiredBitSet[1] |= 1 << 2 if err := func() error { v, err := d.Bool() s.AfterSplit = bool(v) @@ -4477,7 +4960,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"after_split\"") } case "want_split": - requiredBitSet[1] |= 1 << 2 + requiredBitSet[1] |= 1 << 3 if err := func() error { v, err := d.Bool() s.WantSplit = bool(v) @@ -4489,7 +4972,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"want_split\"") } case "want_merge": - requiredBitSet[1] |= 1 << 3 + requiredBitSet[1] |= 1 << 4 if err := func() error { v, err := d.Bool() s.WantMerge = bool(v) @@ -4501,7 +4984,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"want_merge\"") } case "key_block": - requiredBitSet[1] |= 1 << 4 + requiredBitSet[1] |= 1 << 5 if err := func() error { v, err := d.Bool() s.KeyBlock = bool(v) @@ -4513,7 +4996,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"key_block\"") } case "gen_utime": - requiredBitSet[1] |= 1 << 5 + requiredBitSet[1] |= 1 << 6 if err := func() error { v, err := d.Int64() s.GenUtime = int64(v) @@ -4525,7 +5008,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"gen_utime\"") } case "start_lt": - requiredBitSet[1] |= 1 << 6 + requiredBitSet[1] |= 1 << 7 if err := func() error { v, err := d.Int64() s.StartLt = int64(v) @@ -4537,7 +5020,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"start_lt\"") } case "end_lt": - requiredBitSet[1] |= 1 << 7 + requiredBitSet[2] |= 1 << 0 if err := func() error { v, err := d.Int64() s.EndLt = int64(v) @@ -4549,7 +5032,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"end_lt\"") } case "vert_seqno": - requiredBitSet[2] |= 1 << 0 + requiredBitSet[2] |= 1 << 1 if err := func() error { v, err := d.Int32() s.VertSeqno = int32(v) @@ -4561,7 +5044,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"vert_seqno\"") } case "gen_catchain_seqno": - requiredBitSet[2] |= 1 << 1 + requiredBitSet[2] |= 1 << 2 if err := func() error { v, err := d.Int32() s.GenCatchainSeqno = int32(v) @@ -4573,7 +5056,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"gen_catchain_seqno\"") } case "min_ref_mc_seqno": - requiredBitSet[2] |= 1 << 2 + requiredBitSet[2] |= 1 << 3 if err := func() error { v, err := d.Int32() s.MinRefMcSeqno = int32(v) @@ -4585,7 +5068,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"min_ref_mc_seqno\"") } case "prev_key_block_seqno": - requiredBitSet[2] |= 1 << 3 + requiredBitSet[2] |= 1 << 4 if err := func() error { v, err := d.Int32() s.PrevKeyBlockSeqno = int32(v) @@ -4627,7 +5110,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"master_ref\"") } case "prev_refs": - requiredBitSet[2] |= 1 << 7 + requiredBitSet[3] |= 1 << 0 if err := func() error { s.PrevRefs = make([]string, 0) if err := d.Arr(func(d *jx.Decoder) error { @@ -4647,7 +5130,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"prev_refs\"") } case "in_msg_descr_length": - requiredBitSet[3] |= 1 << 0 + requiredBitSet[3] |= 1 << 1 if err := func() error { v, err := d.Int64() s.InMsgDescrLength = int64(v) @@ -4659,7 +5142,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"in_msg_descr_length\"") } case "out_msg_descr_length": - requiredBitSet[3] |= 1 << 1 + requiredBitSet[3] |= 1 << 2 if err := func() error { v, err := d.Int64() s.OutMsgDescrLength = int64(v) @@ -4671,7 +5154,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"out_msg_descr_length\"") } case "rand_seed": - requiredBitSet[3] |= 1 << 2 + requiredBitSet[3] |= 1 << 3 if err := func() error { v, err := d.Str() s.RandSeed = string(v) @@ -4683,7 +5166,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"rand_seed\"") } case "created_by": - requiredBitSet[3] |= 1 << 3 + requiredBitSet[3] |= 1 << 4 if err := func() error { v, err := d.Str() s.CreatedBy = string(v) @@ -4706,8 +5189,8 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { for i, mask := range [4]uint8{ 0b11111111, 0b11111111, - 0b10001111, - 0b00001111, + 0b00011111, + 0b00011111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -23308,6 +23791,39 @@ func (s *OptAuctionBidAction) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes BlockCurrencyCollection as json. +func (o OptBlockCurrencyCollection) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BlockCurrencyCollection from json. +func (o *OptBlockCurrencyCollection) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBlockCurrencyCollection to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBlockCurrencyCollection) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBlockCurrencyCollection) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes BlockchainAccountInspectCompiler as json. func (o OptBlockchainAccountInspectCompiler) Encode(e *jx.Encoder) { if !o.Set { diff --git a/pkg/oas/oas_schemas_gen.go b/pkg/oas/oas_schemas_gen.go index 9c41bd38..a95646d4 100644 --- a/pkg/oas/oas_schemas_gen.go +++ b/pkg/oas/oas_schemas_gen.go @@ -1519,6 +1519,57 @@ func (s *Auctions) SetTotal(val int64) { s.Total = val } +// Ref: #/components/schemas/BlockCurrencyCollection +type BlockCurrencyCollection struct { + Grams int64 `json:"grams"` + Other []BlockCurrencyCollectionOtherItem `json:"other"` +} + +// GetGrams returns the value of Grams. +func (s *BlockCurrencyCollection) GetGrams() int64 { + return s.Grams +} + +// GetOther returns the value of Other. +func (s *BlockCurrencyCollection) GetOther() []BlockCurrencyCollectionOtherItem { + return s.Other +} + +// SetGrams sets the value of Grams. +func (s *BlockCurrencyCollection) SetGrams(val int64) { + s.Grams = val +} + +// SetOther sets the value of Other. +func (s *BlockCurrencyCollection) SetOther(val []BlockCurrencyCollectionOtherItem) { + s.Other = val +} + +type BlockCurrencyCollectionOtherItem struct { + ID int64 `json:"id"` + Value string `json:"value"` +} + +// GetID returns the value of ID. +func (s *BlockCurrencyCollectionOtherItem) GetID() int64 { + return s.ID +} + +// GetValue returns the value of Value. +func (s *BlockCurrencyCollectionOtherItem) GetValue() string { + return s.Value +} + +// SetID sets the value of ID. +func (s *BlockCurrencyCollectionOtherItem) SetID(val int64) { + s.ID = val +} + +// SetValue sets the value of Value. +func (s *BlockCurrencyCollectionOtherItem) SetValue(val string) { + s.Value = val +} + // Ref: #/components/schemas/BlockLimits type BlockLimits struct { Bytes BlockParamLimits `json:"bytes"` @@ -1652,6 +1703,120 @@ func (s *BlockRaw) SetFileHash(val string) { s.FileHash = val } +// Ref: #/components/schemas/BlockValueFlow +type BlockValueFlow struct { + FromPrevBlk BlockCurrencyCollection `json:"from_prev_blk"` + ToNextBlk BlockCurrencyCollection `json:"to_next_blk"` + Imported BlockCurrencyCollection `json:"imported"` + Exported BlockCurrencyCollection `json:"exported"` + FeesCollected BlockCurrencyCollection `json:"fees_collected"` + Burned OptBlockCurrencyCollection `json:"burned"` + FeesImported BlockCurrencyCollection `json:"fees_imported"` + Recovered BlockCurrencyCollection `json:"recovered"` + Created BlockCurrencyCollection `json:"created"` + Minted BlockCurrencyCollection `json:"minted"` +} + +// GetFromPrevBlk returns the value of FromPrevBlk. +func (s *BlockValueFlow) GetFromPrevBlk() BlockCurrencyCollection { + return s.FromPrevBlk +} + +// GetToNextBlk returns the value of ToNextBlk. +func (s *BlockValueFlow) GetToNextBlk() BlockCurrencyCollection { + return s.ToNextBlk +} + +// GetImported returns the value of Imported. +func (s *BlockValueFlow) GetImported() BlockCurrencyCollection { + return s.Imported +} + +// GetExported returns the value of Exported. +func (s *BlockValueFlow) GetExported() BlockCurrencyCollection { + return s.Exported +} + +// GetFeesCollected returns the value of FeesCollected. +func (s *BlockValueFlow) GetFeesCollected() BlockCurrencyCollection { + return s.FeesCollected +} + +// GetBurned returns the value of Burned. +func (s *BlockValueFlow) GetBurned() OptBlockCurrencyCollection { + return s.Burned +} + +// GetFeesImported returns the value of FeesImported. +func (s *BlockValueFlow) GetFeesImported() BlockCurrencyCollection { + return s.FeesImported +} + +// GetRecovered returns the value of Recovered. +func (s *BlockValueFlow) GetRecovered() BlockCurrencyCollection { + return s.Recovered +} + +// GetCreated returns the value of Created. +func (s *BlockValueFlow) GetCreated() BlockCurrencyCollection { + return s.Created +} + +// GetMinted returns the value of Minted. +func (s *BlockValueFlow) GetMinted() BlockCurrencyCollection { + return s.Minted +} + +// SetFromPrevBlk sets the value of FromPrevBlk. +func (s *BlockValueFlow) SetFromPrevBlk(val BlockCurrencyCollection) { + s.FromPrevBlk = val +} + +// SetToNextBlk sets the value of ToNextBlk. +func (s *BlockValueFlow) SetToNextBlk(val BlockCurrencyCollection) { + s.ToNextBlk = val +} + +// SetImported sets the value of Imported. +func (s *BlockValueFlow) SetImported(val BlockCurrencyCollection) { + s.Imported = val +} + +// SetExported sets the value of Exported. +func (s *BlockValueFlow) SetExported(val BlockCurrencyCollection) { + s.Exported = val +} + +// SetFeesCollected sets the value of FeesCollected. +func (s *BlockValueFlow) SetFeesCollected(val BlockCurrencyCollection) { + s.FeesCollected = val +} + +// SetBurned sets the value of Burned. +func (s *BlockValueFlow) SetBurned(val OptBlockCurrencyCollection) { + s.Burned = val +} + +// SetFeesImported sets the value of FeesImported. +func (s *BlockValueFlow) SetFeesImported(val BlockCurrencyCollection) { + s.FeesImported = val +} + +// SetRecovered sets the value of Recovered. +func (s *BlockValueFlow) SetRecovered(val BlockCurrencyCollection) { + s.Recovered = val +} + +// SetCreated sets the value of Created. +func (s *BlockValueFlow) SetCreated(val BlockCurrencyCollection) { + s.Created = val +} + +// SetMinted sets the value of Minted. +func (s *BlockValueFlow) SetMinted(val BlockCurrencyCollection) { + s.Minted = val +} + // Ref: #/components/schemas/BlockchainAccountInspect type BlockchainAccountInspect struct { Code string `json:"code"` @@ -1761,34 +1926,40 @@ func (s *BlockchainAccountInspectMethodsItem) SetMethod(val string) { // Ref: #/components/schemas/BlockchainBlock type BlockchainBlock struct { - WorkchainID int32 `json:"workchain_id"` - Shard string `json:"shard"` - Seqno int32 `json:"seqno"` - RootHash string `json:"root_hash"` - FileHash string `json:"file_hash"` - GlobalID int32 `json:"global_id"` - Version int32 `json:"version"` - AfterMerge bool `json:"after_merge"` - BeforeSplit bool `json:"before_split"` - AfterSplit bool `json:"after_split"` - WantSplit bool `json:"want_split"` - WantMerge bool `json:"want_merge"` - KeyBlock bool `json:"key_block"` - GenUtime int64 `json:"gen_utime"` - StartLt int64 `json:"start_lt"` - EndLt int64 `json:"end_lt"` - VertSeqno int32 `json:"vert_seqno"` - GenCatchainSeqno int32 `json:"gen_catchain_seqno"` - MinRefMcSeqno int32 `json:"min_ref_mc_seqno"` - PrevKeyBlockSeqno int32 `json:"prev_key_block_seqno"` - GenSoftwareVersion OptInt32 `json:"gen_software_version"` - GenSoftwareCapabilities OptInt64 `json:"gen_software_capabilities"` - MasterRef OptString `json:"master_ref"` - PrevRefs []string `json:"prev_refs"` - InMsgDescrLength int64 `json:"in_msg_descr_length"` - OutMsgDescrLength int64 `json:"out_msg_descr_length"` - RandSeed string `json:"rand_seed"` - CreatedBy string `json:"created_by"` + ValueFlow BlockValueFlow `json:"value_flow"` + WorkchainID int32 `json:"workchain_id"` + Shard string `json:"shard"` + Seqno int32 `json:"seqno"` + RootHash string `json:"root_hash"` + FileHash string `json:"file_hash"` + GlobalID int32 `json:"global_id"` + Version int32 `json:"version"` + AfterMerge bool `json:"after_merge"` + BeforeSplit bool `json:"before_split"` + AfterSplit bool `json:"after_split"` + WantSplit bool `json:"want_split"` + WantMerge bool `json:"want_merge"` + KeyBlock bool `json:"key_block"` + GenUtime int64 `json:"gen_utime"` + StartLt int64 `json:"start_lt"` + EndLt int64 `json:"end_lt"` + VertSeqno int32 `json:"vert_seqno"` + GenCatchainSeqno int32 `json:"gen_catchain_seqno"` + MinRefMcSeqno int32 `json:"min_ref_mc_seqno"` + PrevKeyBlockSeqno int32 `json:"prev_key_block_seqno"` + GenSoftwareVersion OptInt32 `json:"gen_software_version"` + GenSoftwareCapabilities OptInt64 `json:"gen_software_capabilities"` + MasterRef OptString `json:"master_ref"` + PrevRefs []string `json:"prev_refs"` + InMsgDescrLength int64 `json:"in_msg_descr_length"` + OutMsgDescrLength int64 `json:"out_msg_descr_length"` + RandSeed string `json:"rand_seed"` + CreatedBy string `json:"created_by"` +} + +// GetValueFlow returns the value of ValueFlow. +func (s *BlockchainBlock) GetValueFlow() BlockValueFlow { + return s.ValueFlow } // GetWorkchainID returns the value of WorkchainID. @@ -1931,6 +2102,11 @@ func (s *BlockchainBlock) GetCreatedBy() string { return s.CreatedBy } +// SetValueFlow sets the value of ValueFlow. +func (s *BlockchainBlock) SetValueFlow(val BlockValueFlow) { + s.ValueFlow = val +} + // SetWorkchainID sets the value of WorkchainID. func (s *BlockchainBlock) SetWorkchainID(val int32) { s.WorkchainID = val @@ -8001,6 +8177,52 @@ func (o OptAuctionBidAction) Or(d AuctionBidAction) AuctionBidAction { return d } +// NewOptBlockCurrencyCollection returns new OptBlockCurrencyCollection with value set to v. +func NewOptBlockCurrencyCollection(v BlockCurrencyCollection) OptBlockCurrencyCollection { + return OptBlockCurrencyCollection{ + Value: v, + Set: true, + } +} + +// OptBlockCurrencyCollection is optional BlockCurrencyCollection. +type OptBlockCurrencyCollection struct { + Value BlockCurrencyCollection + Set bool +} + +// IsSet returns true if OptBlockCurrencyCollection was set. +func (o OptBlockCurrencyCollection) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBlockCurrencyCollection) Reset() { + var v BlockCurrencyCollection + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBlockCurrencyCollection) SetTo(v BlockCurrencyCollection) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBlockCurrencyCollection) Get() (v BlockCurrencyCollection, 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 OptBlockCurrencyCollection) Or(d BlockCurrencyCollection) BlockCurrencyCollection { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptBlockchainAccountInspectCompiler returns new OptBlockchainAccountInspectCompiler with value set to v. func NewOptBlockchainAccountInspectCompiler(v BlockchainAccountInspectCompiler) OptBlockchainAccountInspectCompiler { return OptBlockchainAccountInspectCompiler{ diff --git a/pkg/oas/oas_validators_gen.go b/pkg/oas/oas_validators_gen.go index 9996d5a3..1ccdb2fa 100644 --- a/pkg/oas/oas_validators_gen.go +++ b/pkg/oas/oas_validators_gen.go @@ -624,6 +624,150 @@ func (s *Auctions) Validate() error { return nil } +func (s *BlockCurrencyCollection) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Other == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "other", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *BlockValueFlow) Validate() error { + var failures []validate.FieldError + if err := func() error { + if err := s.FromPrevBlk.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "from_prev_blk", + Error: err, + }) + } + if err := func() error { + if err := s.ToNextBlk.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "to_next_blk", + Error: err, + }) + } + if err := func() error { + if err := s.Imported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "imported", + Error: err, + }) + } + if err := func() error { + if err := s.Exported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "exported", + Error: err, + }) + } + if err := func() error { + if err := s.FeesCollected.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fees_collected", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Burned.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: "burned", + Error: err, + }) + } + if err := func() error { + if err := s.FeesImported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fees_imported", + Error: err, + }) + } + if err := func() error { + if err := s.Recovered.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "recovered", + Error: err, + }) + } + if err := func() error { + if err := s.Created.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "created", + Error: err, + }) + } + if err := func() error { + if err := s.Minted.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "minted", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *BlockchainAccountInspect) Validate() error { var failures []validate.FieldError if err := func() error { @@ -672,6 +816,17 @@ func (s BlockchainAccountInspectCompiler) Validate() error { func (s *BlockchainBlock) Validate() error { var failures []validate.FieldError + if err := func() error { + if err := s.ValueFlow.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value_flow", + Error: err, + }) + } if err := func() error { if s.PrevRefs == nil { return errors.New("nil is invalid value") diff --git a/tonapi/oas_json_gen.go b/tonapi/oas_json_gen.go index 7030a871..07f21044 100644 --- a/tonapi/oas_json_gen.go +++ b/tonapi/oas_json_gen.go @@ -3457,6 +3457,242 @@ func (s *Auctions) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *BlockCurrencyCollection) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockCurrencyCollection) encodeFields(e *jx.Encoder) { + { + e.FieldStart("grams") + e.Int64(s.Grams) + } + { + e.FieldStart("other") + e.ArrStart() + for _, elem := range s.Other { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfBlockCurrencyCollection = [2]string{ + 0: "grams", + 1: "other", +} + +// Decode decodes BlockCurrencyCollection from json. +func (s *BlockCurrencyCollection) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockCurrencyCollection to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "grams": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int64() + s.Grams = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"grams\"") + } + case "other": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.Other = make([]BlockCurrencyCollectionOtherItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem BlockCurrencyCollectionOtherItem + if err := elem.Decode(d); err != nil { + return err + } + s.Other = append(s.Other, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"other\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockCurrencyCollection") + } + // 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(jsonFieldsNameOfBlockCurrencyCollection) { + name = jsonFieldsNameOfBlockCurrencyCollection[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 *BlockCurrencyCollection) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockCurrencyCollection) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *BlockCurrencyCollectionOtherItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockCurrencyCollectionOtherItem) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + e.Int64(s.ID) + } + { + e.FieldStart("value") + e.Str(s.Value) + } +} + +var jsonFieldsNameOfBlockCurrencyCollectionOtherItem = [2]string{ + 0: "id", + 1: "value", +} + +// Decode decodes BlockCurrencyCollectionOtherItem from json. +func (s *BlockCurrencyCollectionOtherItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockCurrencyCollectionOtherItem to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int64() + s.ID = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "value": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Value = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockCurrencyCollectionOtherItem") + } + // 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(jsonFieldsNameOfBlockCurrencyCollectionOtherItem) { + name = jsonFieldsNameOfBlockCurrencyCollectionOtherItem[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 *BlockCurrencyCollectionOtherItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockCurrencyCollectionOtherItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *BlockLimits) Encode(e *jx.Encoder) { e.ObjStart() @@ -3875,6 +4111,238 @@ func (s *BlockRaw) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *BlockValueFlow) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *BlockValueFlow) encodeFields(e *jx.Encoder) { + { + e.FieldStart("from_prev_blk") + s.FromPrevBlk.Encode(e) + } + { + e.FieldStart("to_next_blk") + s.ToNextBlk.Encode(e) + } + { + e.FieldStart("imported") + s.Imported.Encode(e) + } + { + e.FieldStart("exported") + s.Exported.Encode(e) + } + { + e.FieldStart("fees_collected") + s.FeesCollected.Encode(e) + } + { + if s.Burned.Set { + e.FieldStart("burned") + s.Burned.Encode(e) + } + } + { + e.FieldStart("fees_imported") + s.FeesImported.Encode(e) + } + { + e.FieldStart("recovered") + s.Recovered.Encode(e) + } + { + e.FieldStart("created") + s.Created.Encode(e) + } + { + e.FieldStart("minted") + s.Minted.Encode(e) + } +} + +var jsonFieldsNameOfBlockValueFlow = [10]string{ + 0: "from_prev_blk", + 1: "to_next_blk", + 2: "imported", + 3: "exported", + 4: "fees_collected", + 5: "burned", + 6: "fees_imported", + 7: "recovered", + 8: "created", + 9: "minted", +} + +// Decode decodes BlockValueFlow from json. +func (s *BlockValueFlow) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode BlockValueFlow to nil") + } + var requiredBitSet [2]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "from_prev_blk": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.FromPrevBlk.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"from_prev_blk\"") + } + case "to_next_blk": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.ToNextBlk.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"to_next_blk\"") + } + case "imported": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Imported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"imported\"") + } + case "exported": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Exported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"exported\"") + } + case "fees_collected": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.FeesCollected.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fees_collected\"") + } + case "burned": + if err := func() error { + s.Burned.Reset() + if err := s.Burned.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"burned\"") + } + case "fees_imported": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + if err := s.FeesImported.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fees_imported\"") + } + case "recovered": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + if err := s.Recovered.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"recovered\"") + } + case "created": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + if err := s.Created.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created\"") + } + case "minted": + requiredBitSet[1] |= 1 << 1 + if err := func() error { + if err := s.Minted.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"minted\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode BlockValueFlow") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [2]uint8{ + 0b11011111, + 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(jsonFieldsNameOfBlockValueFlow) { + name = jsonFieldsNameOfBlockValueFlow[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 *BlockValueFlow) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *BlockValueFlow) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *BlockchainAccountInspect) Encode(e *jx.Encoder) { e.ObjStart() @@ -4192,6 +4660,10 @@ func (s *BlockchainBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *BlockchainBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("value_flow") + s.ValueFlow.Encode(e) + } { e.FieldStart("workchain_id") e.Int32(s.WorkchainID) @@ -4316,35 +4788,36 @@ func (s *BlockchainBlock) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfBlockchainBlock = [28]string{ - 0: "workchain_id", - 1: "shard", - 2: "seqno", - 3: "root_hash", - 4: "file_hash", - 5: "global_id", - 6: "version", - 7: "after_merge", - 8: "before_split", - 9: "after_split", - 10: "want_split", - 11: "want_merge", - 12: "key_block", - 13: "gen_utime", - 14: "start_lt", - 15: "end_lt", - 16: "vert_seqno", - 17: "gen_catchain_seqno", - 18: "min_ref_mc_seqno", - 19: "prev_key_block_seqno", - 20: "gen_software_version", - 21: "gen_software_capabilities", - 22: "master_ref", - 23: "prev_refs", - 24: "in_msg_descr_length", - 25: "out_msg_descr_length", - 26: "rand_seed", - 27: "created_by", +var jsonFieldsNameOfBlockchainBlock = [29]string{ + 0: "value_flow", + 1: "workchain_id", + 2: "shard", + 3: "seqno", + 4: "root_hash", + 5: "file_hash", + 6: "global_id", + 7: "version", + 8: "after_merge", + 9: "before_split", + 10: "after_split", + 11: "want_split", + 12: "want_merge", + 13: "key_block", + 14: "gen_utime", + 15: "start_lt", + 16: "end_lt", + 17: "vert_seqno", + 18: "gen_catchain_seqno", + 19: "min_ref_mc_seqno", + 20: "prev_key_block_seqno", + 21: "gen_software_version", + 22: "gen_software_capabilities", + 23: "master_ref", + 24: "prev_refs", + 25: "in_msg_descr_length", + 26: "out_msg_descr_length", + 27: "rand_seed", + 28: "created_by", } // Decode decodes BlockchainBlock from json. @@ -4356,8 +4829,18 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "workchain_id": + case "value_flow": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.ValueFlow.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"value_flow\"") + } + case "workchain_id": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Int32() s.WorkchainID = int32(v) @@ -4369,7 +4852,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"workchain_id\"") } case "shard": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() s.Shard = string(v) @@ -4381,7 +4864,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"shard\"") } case "seqno": - requiredBitSet[0] |= 1 << 2 + requiredBitSet[0] |= 1 << 3 if err := func() error { v, err := d.Int32() s.Seqno = int32(v) @@ -4393,7 +4876,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"seqno\"") } case "root_hash": - requiredBitSet[0] |= 1 << 3 + requiredBitSet[0] |= 1 << 4 if err := func() error { v, err := d.Str() s.RootHash = string(v) @@ -4405,7 +4888,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"root_hash\"") } case "file_hash": - requiredBitSet[0] |= 1 << 4 + requiredBitSet[0] |= 1 << 5 if err := func() error { v, err := d.Str() s.FileHash = string(v) @@ -4417,7 +4900,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"file_hash\"") } case "global_id": - requiredBitSet[0] |= 1 << 5 + requiredBitSet[0] |= 1 << 6 if err := func() error { v, err := d.Int32() s.GlobalID = int32(v) @@ -4429,7 +4912,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"global_id\"") } case "version": - requiredBitSet[0] |= 1 << 6 + requiredBitSet[0] |= 1 << 7 if err := func() error { v, err := d.Int32() s.Version = int32(v) @@ -4441,7 +4924,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"version\"") } case "after_merge": - requiredBitSet[0] |= 1 << 7 + requiredBitSet[1] |= 1 << 0 if err := func() error { v, err := d.Bool() s.AfterMerge = bool(v) @@ -4453,7 +4936,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"after_merge\"") } case "before_split": - requiredBitSet[1] |= 1 << 0 + requiredBitSet[1] |= 1 << 1 if err := func() error { v, err := d.Bool() s.BeforeSplit = bool(v) @@ -4465,7 +4948,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"before_split\"") } case "after_split": - requiredBitSet[1] |= 1 << 1 + requiredBitSet[1] |= 1 << 2 if err := func() error { v, err := d.Bool() s.AfterSplit = bool(v) @@ -4477,7 +4960,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"after_split\"") } case "want_split": - requiredBitSet[1] |= 1 << 2 + requiredBitSet[1] |= 1 << 3 if err := func() error { v, err := d.Bool() s.WantSplit = bool(v) @@ -4489,7 +4972,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"want_split\"") } case "want_merge": - requiredBitSet[1] |= 1 << 3 + requiredBitSet[1] |= 1 << 4 if err := func() error { v, err := d.Bool() s.WantMerge = bool(v) @@ -4501,7 +4984,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"want_merge\"") } case "key_block": - requiredBitSet[1] |= 1 << 4 + requiredBitSet[1] |= 1 << 5 if err := func() error { v, err := d.Bool() s.KeyBlock = bool(v) @@ -4513,7 +4996,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"key_block\"") } case "gen_utime": - requiredBitSet[1] |= 1 << 5 + requiredBitSet[1] |= 1 << 6 if err := func() error { v, err := d.Int64() s.GenUtime = int64(v) @@ -4525,7 +5008,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"gen_utime\"") } case "start_lt": - requiredBitSet[1] |= 1 << 6 + requiredBitSet[1] |= 1 << 7 if err := func() error { v, err := d.Int64() s.StartLt = int64(v) @@ -4537,7 +5020,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"start_lt\"") } case "end_lt": - requiredBitSet[1] |= 1 << 7 + requiredBitSet[2] |= 1 << 0 if err := func() error { v, err := d.Int64() s.EndLt = int64(v) @@ -4549,7 +5032,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"end_lt\"") } case "vert_seqno": - requiredBitSet[2] |= 1 << 0 + requiredBitSet[2] |= 1 << 1 if err := func() error { v, err := d.Int32() s.VertSeqno = int32(v) @@ -4561,7 +5044,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"vert_seqno\"") } case "gen_catchain_seqno": - requiredBitSet[2] |= 1 << 1 + requiredBitSet[2] |= 1 << 2 if err := func() error { v, err := d.Int32() s.GenCatchainSeqno = int32(v) @@ -4573,7 +5056,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"gen_catchain_seqno\"") } case "min_ref_mc_seqno": - requiredBitSet[2] |= 1 << 2 + requiredBitSet[2] |= 1 << 3 if err := func() error { v, err := d.Int32() s.MinRefMcSeqno = int32(v) @@ -4585,7 +5068,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"min_ref_mc_seqno\"") } case "prev_key_block_seqno": - requiredBitSet[2] |= 1 << 3 + requiredBitSet[2] |= 1 << 4 if err := func() error { v, err := d.Int32() s.PrevKeyBlockSeqno = int32(v) @@ -4627,7 +5110,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"master_ref\"") } case "prev_refs": - requiredBitSet[2] |= 1 << 7 + requiredBitSet[3] |= 1 << 0 if err := func() error { s.PrevRefs = make([]string, 0) if err := d.Arr(func(d *jx.Decoder) error { @@ -4647,7 +5130,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"prev_refs\"") } case "in_msg_descr_length": - requiredBitSet[3] |= 1 << 0 + requiredBitSet[3] |= 1 << 1 if err := func() error { v, err := d.Int64() s.InMsgDescrLength = int64(v) @@ -4659,7 +5142,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"in_msg_descr_length\"") } case "out_msg_descr_length": - requiredBitSet[3] |= 1 << 1 + requiredBitSet[3] |= 1 << 2 if err := func() error { v, err := d.Int64() s.OutMsgDescrLength = int64(v) @@ -4671,7 +5154,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"out_msg_descr_length\"") } case "rand_seed": - requiredBitSet[3] |= 1 << 2 + requiredBitSet[3] |= 1 << 3 if err := func() error { v, err := d.Str() s.RandSeed = string(v) @@ -4683,7 +5166,7 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"rand_seed\"") } case "created_by": - requiredBitSet[3] |= 1 << 3 + requiredBitSet[3] |= 1 << 4 if err := func() error { v, err := d.Str() s.CreatedBy = string(v) @@ -4706,8 +5189,8 @@ func (s *BlockchainBlock) Decode(d *jx.Decoder) error { for i, mask := range [4]uint8{ 0b11111111, 0b11111111, - 0b10001111, - 0b00001111, + 0b00011111, + 0b00011111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -23308,6 +23791,39 @@ func (s *OptAuctionBidAction) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes BlockCurrencyCollection as json. +func (o OptBlockCurrencyCollection) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes BlockCurrencyCollection from json. +func (o *OptBlockCurrencyCollection) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptBlockCurrencyCollection to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptBlockCurrencyCollection) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptBlockCurrencyCollection) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes BlockchainAccountInspectCompiler as json. func (o OptBlockchainAccountInspectCompiler) Encode(e *jx.Encoder) { if !o.Set { diff --git a/tonapi/oas_schemas_gen.go b/tonapi/oas_schemas_gen.go index 1f37b238..c7fedd50 100644 --- a/tonapi/oas_schemas_gen.go +++ b/tonapi/oas_schemas_gen.go @@ -1519,6 +1519,57 @@ func (s *Auctions) SetTotal(val int64) { s.Total = val } +// Ref: #/components/schemas/BlockCurrencyCollection +type BlockCurrencyCollection struct { + Grams int64 `json:"grams"` + Other []BlockCurrencyCollectionOtherItem `json:"other"` +} + +// GetGrams returns the value of Grams. +func (s *BlockCurrencyCollection) GetGrams() int64 { + return s.Grams +} + +// GetOther returns the value of Other. +func (s *BlockCurrencyCollection) GetOther() []BlockCurrencyCollectionOtherItem { + return s.Other +} + +// SetGrams sets the value of Grams. +func (s *BlockCurrencyCollection) SetGrams(val int64) { + s.Grams = val +} + +// SetOther sets the value of Other. +func (s *BlockCurrencyCollection) SetOther(val []BlockCurrencyCollectionOtherItem) { + s.Other = val +} + +type BlockCurrencyCollectionOtherItem struct { + ID int64 `json:"id"` + Value string `json:"value"` +} + +// GetID returns the value of ID. +func (s *BlockCurrencyCollectionOtherItem) GetID() int64 { + return s.ID +} + +// GetValue returns the value of Value. +func (s *BlockCurrencyCollectionOtherItem) GetValue() string { + return s.Value +} + +// SetID sets the value of ID. +func (s *BlockCurrencyCollectionOtherItem) SetID(val int64) { + s.ID = val +} + +// SetValue sets the value of Value. +func (s *BlockCurrencyCollectionOtherItem) SetValue(val string) { + s.Value = val +} + // Ref: #/components/schemas/BlockLimits type BlockLimits struct { Bytes BlockParamLimits `json:"bytes"` @@ -1652,6 +1703,120 @@ func (s *BlockRaw) SetFileHash(val string) { s.FileHash = val } +// Ref: #/components/schemas/BlockValueFlow +type BlockValueFlow struct { + FromPrevBlk BlockCurrencyCollection `json:"from_prev_blk"` + ToNextBlk BlockCurrencyCollection `json:"to_next_blk"` + Imported BlockCurrencyCollection `json:"imported"` + Exported BlockCurrencyCollection `json:"exported"` + FeesCollected BlockCurrencyCollection `json:"fees_collected"` + Burned OptBlockCurrencyCollection `json:"burned"` + FeesImported BlockCurrencyCollection `json:"fees_imported"` + Recovered BlockCurrencyCollection `json:"recovered"` + Created BlockCurrencyCollection `json:"created"` + Minted BlockCurrencyCollection `json:"minted"` +} + +// GetFromPrevBlk returns the value of FromPrevBlk. +func (s *BlockValueFlow) GetFromPrevBlk() BlockCurrencyCollection { + return s.FromPrevBlk +} + +// GetToNextBlk returns the value of ToNextBlk. +func (s *BlockValueFlow) GetToNextBlk() BlockCurrencyCollection { + return s.ToNextBlk +} + +// GetImported returns the value of Imported. +func (s *BlockValueFlow) GetImported() BlockCurrencyCollection { + return s.Imported +} + +// GetExported returns the value of Exported. +func (s *BlockValueFlow) GetExported() BlockCurrencyCollection { + return s.Exported +} + +// GetFeesCollected returns the value of FeesCollected. +func (s *BlockValueFlow) GetFeesCollected() BlockCurrencyCollection { + return s.FeesCollected +} + +// GetBurned returns the value of Burned. +func (s *BlockValueFlow) GetBurned() OptBlockCurrencyCollection { + return s.Burned +} + +// GetFeesImported returns the value of FeesImported. +func (s *BlockValueFlow) GetFeesImported() BlockCurrencyCollection { + return s.FeesImported +} + +// GetRecovered returns the value of Recovered. +func (s *BlockValueFlow) GetRecovered() BlockCurrencyCollection { + return s.Recovered +} + +// GetCreated returns the value of Created. +func (s *BlockValueFlow) GetCreated() BlockCurrencyCollection { + return s.Created +} + +// GetMinted returns the value of Minted. +func (s *BlockValueFlow) GetMinted() BlockCurrencyCollection { + return s.Minted +} + +// SetFromPrevBlk sets the value of FromPrevBlk. +func (s *BlockValueFlow) SetFromPrevBlk(val BlockCurrencyCollection) { + s.FromPrevBlk = val +} + +// SetToNextBlk sets the value of ToNextBlk. +func (s *BlockValueFlow) SetToNextBlk(val BlockCurrencyCollection) { + s.ToNextBlk = val +} + +// SetImported sets the value of Imported. +func (s *BlockValueFlow) SetImported(val BlockCurrencyCollection) { + s.Imported = val +} + +// SetExported sets the value of Exported. +func (s *BlockValueFlow) SetExported(val BlockCurrencyCollection) { + s.Exported = val +} + +// SetFeesCollected sets the value of FeesCollected. +func (s *BlockValueFlow) SetFeesCollected(val BlockCurrencyCollection) { + s.FeesCollected = val +} + +// SetBurned sets the value of Burned. +func (s *BlockValueFlow) SetBurned(val OptBlockCurrencyCollection) { + s.Burned = val +} + +// SetFeesImported sets the value of FeesImported. +func (s *BlockValueFlow) SetFeesImported(val BlockCurrencyCollection) { + s.FeesImported = val +} + +// SetRecovered sets the value of Recovered. +func (s *BlockValueFlow) SetRecovered(val BlockCurrencyCollection) { + s.Recovered = val +} + +// SetCreated sets the value of Created. +func (s *BlockValueFlow) SetCreated(val BlockCurrencyCollection) { + s.Created = val +} + +// SetMinted sets the value of Minted. +func (s *BlockValueFlow) SetMinted(val BlockCurrencyCollection) { + s.Minted = val +} + // Ref: #/components/schemas/BlockchainAccountInspect type BlockchainAccountInspect struct { Code string `json:"code"` @@ -1761,34 +1926,40 @@ func (s *BlockchainAccountInspectMethodsItem) SetMethod(val string) { // Ref: #/components/schemas/BlockchainBlock type BlockchainBlock struct { - WorkchainID int32 `json:"workchain_id"` - Shard string `json:"shard"` - Seqno int32 `json:"seqno"` - RootHash string `json:"root_hash"` - FileHash string `json:"file_hash"` - GlobalID int32 `json:"global_id"` - Version int32 `json:"version"` - AfterMerge bool `json:"after_merge"` - BeforeSplit bool `json:"before_split"` - AfterSplit bool `json:"after_split"` - WantSplit bool `json:"want_split"` - WantMerge bool `json:"want_merge"` - KeyBlock bool `json:"key_block"` - GenUtime int64 `json:"gen_utime"` - StartLt int64 `json:"start_lt"` - EndLt int64 `json:"end_lt"` - VertSeqno int32 `json:"vert_seqno"` - GenCatchainSeqno int32 `json:"gen_catchain_seqno"` - MinRefMcSeqno int32 `json:"min_ref_mc_seqno"` - PrevKeyBlockSeqno int32 `json:"prev_key_block_seqno"` - GenSoftwareVersion OptInt32 `json:"gen_software_version"` - GenSoftwareCapabilities OptInt64 `json:"gen_software_capabilities"` - MasterRef OptString `json:"master_ref"` - PrevRefs []string `json:"prev_refs"` - InMsgDescrLength int64 `json:"in_msg_descr_length"` - OutMsgDescrLength int64 `json:"out_msg_descr_length"` - RandSeed string `json:"rand_seed"` - CreatedBy string `json:"created_by"` + ValueFlow BlockValueFlow `json:"value_flow"` + WorkchainID int32 `json:"workchain_id"` + Shard string `json:"shard"` + Seqno int32 `json:"seqno"` + RootHash string `json:"root_hash"` + FileHash string `json:"file_hash"` + GlobalID int32 `json:"global_id"` + Version int32 `json:"version"` + AfterMerge bool `json:"after_merge"` + BeforeSplit bool `json:"before_split"` + AfterSplit bool `json:"after_split"` + WantSplit bool `json:"want_split"` + WantMerge bool `json:"want_merge"` + KeyBlock bool `json:"key_block"` + GenUtime int64 `json:"gen_utime"` + StartLt int64 `json:"start_lt"` + EndLt int64 `json:"end_lt"` + VertSeqno int32 `json:"vert_seqno"` + GenCatchainSeqno int32 `json:"gen_catchain_seqno"` + MinRefMcSeqno int32 `json:"min_ref_mc_seqno"` + PrevKeyBlockSeqno int32 `json:"prev_key_block_seqno"` + GenSoftwareVersion OptInt32 `json:"gen_software_version"` + GenSoftwareCapabilities OptInt64 `json:"gen_software_capabilities"` + MasterRef OptString `json:"master_ref"` + PrevRefs []string `json:"prev_refs"` + InMsgDescrLength int64 `json:"in_msg_descr_length"` + OutMsgDescrLength int64 `json:"out_msg_descr_length"` + RandSeed string `json:"rand_seed"` + CreatedBy string `json:"created_by"` +} + +// GetValueFlow returns the value of ValueFlow. +func (s *BlockchainBlock) GetValueFlow() BlockValueFlow { + return s.ValueFlow } // GetWorkchainID returns the value of WorkchainID. @@ -1931,6 +2102,11 @@ func (s *BlockchainBlock) GetCreatedBy() string { return s.CreatedBy } +// SetValueFlow sets the value of ValueFlow. +func (s *BlockchainBlock) SetValueFlow(val BlockValueFlow) { + s.ValueFlow = val +} + // SetWorkchainID sets the value of WorkchainID. func (s *BlockchainBlock) SetWorkchainID(val int32) { s.WorkchainID = val @@ -8001,6 +8177,52 @@ func (o OptAuctionBidAction) Or(d AuctionBidAction) AuctionBidAction { return d } +// NewOptBlockCurrencyCollection returns new OptBlockCurrencyCollection with value set to v. +func NewOptBlockCurrencyCollection(v BlockCurrencyCollection) OptBlockCurrencyCollection { + return OptBlockCurrencyCollection{ + Value: v, + Set: true, + } +} + +// OptBlockCurrencyCollection is optional BlockCurrencyCollection. +type OptBlockCurrencyCollection struct { + Value BlockCurrencyCollection + Set bool +} + +// IsSet returns true if OptBlockCurrencyCollection was set. +func (o OptBlockCurrencyCollection) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptBlockCurrencyCollection) Reset() { + var v BlockCurrencyCollection + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptBlockCurrencyCollection) SetTo(v BlockCurrencyCollection) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptBlockCurrencyCollection) Get() (v BlockCurrencyCollection, 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 OptBlockCurrencyCollection) Or(d BlockCurrencyCollection) BlockCurrencyCollection { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptBlockchainAccountInspectCompiler returns new OptBlockchainAccountInspectCompiler with value set to v. func NewOptBlockchainAccountInspectCompiler(v BlockchainAccountInspectCompiler) OptBlockchainAccountInspectCompiler { return OptBlockchainAccountInspectCompiler{ diff --git a/tonapi/oas_validators_gen.go b/tonapi/oas_validators_gen.go index 8de057da..7d5c483d 100644 --- a/tonapi/oas_validators_gen.go +++ b/tonapi/oas_validators_gen.go @@ -624,6 +624,150 @@ func (s *Auctions) Validate() error { return nil } +func (s *BlockCurrencyCollection) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Other == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "other", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *BlockValueFlow) Validate() error { + var failures []validate.FieldError + if err := func() error { + if err := s.FromPrevBlk.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "from_prev_blk", + Error: err, + }) + } + if err := func() error { + if err := s.ToNextBlk.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "to_next_blk", + Error: err, + }) + } + if err := func() error { + if err := s.Imported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "imported", + Error: err, + }) + } + if err := func() error { + if err := s.Exported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "exported", + Error: err, + }) + } + if err := func() error { + if err := s.FeesCollected.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fees_collected", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Burned.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: "burned", + Error: err, + }) + } + if err := func() error { + if err := s.FeesImported.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fees_imported", + Error: err, + }) + } + if err := func() error { + if err := s.Recovered.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "recovered", + Error: err, + }) + } + if err := func() error { + if err := s.Created.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "created", + Error: err, + }) + } + if err := func() error { + if err := s.Minted.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "minted", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *BlockchainAccountInspect) Validate() error { var failures []validate.FieldError if err := func() error { @@ -672,6 +816,17 @@ func (s BlockchainAccountInspectCompiler) Validate() error { func (s *BlockchainBlock) Validate() error { var failures []validate.FieldError + if err := func() error { + if err := s.ValueFlow.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "value_flow", + Error: err, + }) + } if err := func() error { if s.PrevRefs == nil { return errors.New("nil is invalid value")