diff --git a/engine/access/rest/common/models/block.go b/engine/access/rest/common/models/block.go index b94412929fa..6716c2c3be4 100644 --- a/engine/access/rest/common/models/block.go +++ b/engine/access/rest/common/models/block.go @@ -63,10 +63,27 @@ func (b *Block) Build( } b.Links = self - b.BlockStatus = blockStatus.String() + + var status BlockStatus + status.Build(blockStatus) + b.BlockStatus = &status + return nil } +func (b *BlockStatus) Build(status flow.BlockStatus) { + switch status { + case flow.BlockStatusUnknown: + *b = BLOCK_UNKNOWN + case flow.BlockStatusFinalized: + *b = BLOCK_FINALIZED + case flow.BlockStatusSealed: + *b = BLOCK_SEALED + default: + *b = "" + } +} + func (b *BlockPayload) Build(payload *flow.Payload) error { var blockSeal BlockSeals err := blockSeal.Build(payload.Seals) diff --git a/engine/access/rest/common/models/enums.go b/engine/access/rest/common/models/enums.go index 6d9b0d33b10..375aefdc6b1 100644 --- a/engine/access/rest/common/models/enums.go +++ b/engine/access/rest/common/models/enums.go @@ -15,3 +15,9 @@ const ( SUCCESS_RESULT = SUCCESS_TransactionExecution FAILURE_RESULT = FAILURE_TransactionExecution ) + +const ( + BLOCK_UNKNOWN = UNKNOWN_BlockStatus + BLOCK_FINALIZED = FINALIZED_BlockStatus + BLOCK_SEALED = SEALED_BlockStatus +) diff --git a/engine/access/rest/common/models/model_block.go b/engine/access/rest/common/models/model_block.go index ded5008bcdc..f30836ea1e4 100644 --- a/engine/access/rest/common/models/model_block.go +++ b/engine/access/rest/common/models/model_block.go @@ -12,7 +12,7 @@ type Block struct { Header *BlockHeader `json:"header"` Payload *BlockPayload `json:"payload,omitempty"` ExecutionResult *ExecutionResult `json:"execution_result,omitempty"` - Expandable *BlockExpandable `json:"_expandable"` + Expandable *BlockExpandable `json:"_expandable,omitempty"` Links *Links `json:"_links,omitempty"` - BlockStatus string `json:"block_status"` + BlockStatus *BlockStatus `json:"block_status"` } diff --git a/engine/access/rest/common/models/model_block_status.go b/engine/access/rest/common/models/model_block_status.go new file mode 100644 index 00000000000..66e04825a42 --- /dev/null +++ b/engine/access/rest/common/models/model_block_status.go @@ -0,0 +1,19 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package models + +// BlockStatus : This value indicates the status of a block. +type BlockStatus string + +// List of BlockStatus +const ( + UNKNOWN_BlockStatus BlockStatus = "BLOCK_UNKNOWN" + FINALIZED_BlockStatus BlockStatus = "BLOCK_FINALIZED" + SEALED_BlockStatus BlockStatus = "BLOCK_SEALED" +) diff --git a/go.mod b/go.mod index 1da27c5159d..d7fb0d1c454 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 github.com/onflow/flow-go-sdk v1.3.1 - github.com/onflow/flow/protobuf/go/flow v0.4.7 + github.com/onflow/flow/protobuf/go/flow v0.4.9 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pierrec/lz4 v2.6.1+incompatible github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 775f632189f..cf57b54c3b9 100644 --- a/go.sum +++ b/go.sum @@ -928,8 +928,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc= diff --git a/insecure/go.mod b/insecure/go.mod index 52225f858bf..740c5488022 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -211,7 +211,7 @@ require ( github.com/onflow/flow-go-sdk v1.3.1 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect - github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect + github.com/onflow/flow/protobuf/go/flow v0.4.9 // indirect github.com/onflow/go-ethereum v1.14.7 // indirect github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect github.com/onflow/sdks v0.6.0-preview.1 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 80498590904..22dac274285 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -869,8 +869,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc= diff --git a/integration/go.mod b/integration/go.mod index 2da5a385f16..8cdd7313488 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -27,7 +27,7 @@ require ( github.com/onflow/flow-go v0.38.0-preview.0.0.20241021221952-af9cd6e99de1 github.com/onflow/flow-go-sdk v1.3.1 github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000 - github.com/onflow/flow/protobuf/go/flow v0.4.7 + github.com/onflow/flow/protobuf/go/flow v0.4.9 github.com/onflow/go-ethereum v1.14.7 github.com/prometheus/client_golang v1.18.0 github.com/prometheus/client_model v0.5.0 diff --git a/integration/go.sum b/integration/go.sum index 4ee196fb161..04bbbf963f6 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -747,8 +747,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=