From ad3d137d66d498e1a369b6f80dbd36718028d5f6 Mon Sep 17 00:00:00 2001 From: Eduard Voiculescu Date: Wed, 14 Aug 2024 09:40:36 -0400 Subject: [PATCH] adding firehose-gear well known types --- cmd/tools/mergeblock/tools_merge_blocks.go | 2 -- launcher/app_enum.go | 17 +++++++++++++---- proto/generator/generator.go | 1 + proto/well_known.go | 1 - proto/well_known_types.go | 10 +++++++++- types/block_range_enum.go | 17 +++++++++++++---- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/cmd/tools/mergeblock/tools_merge_blocks.go b/cmd/tools/mergeblock/tools_merge_blocks.go index 29a2965..95d1aa4 100644 --- a/cmd/tools/mergeblock/tools_merge_blocks.go +++ b/cmd/tools/mergeblock/tools_merge_blocks.go @@ -24,8 +24,6 @@ func NewToolsMergeBlocksCmd[B firecore.Block](chain *firecore.Chain[B], zlog *za RunE: runMergeBlocksE(zlog), } - cmd.Flags().String("force-block-type", "", "When set, will force the block type to the given value.") - return cmd } diff --git a/launcher/app_enum.go b/launcher/app_enum.go index 2a626f1..7715609 100644 --- a/launcher/app_enum.go +++ b/launcher/app_enum.go @@ -24,6 +24,8 @@ const ( AppStatusStopped ) +var ErrInvalidAppStatus = fmt.Errorf("not a valid AppStatus, try [%s]", strings.Join(_AppStatusNames, ", ")) + const _AppStatusName = "NotFoundCreatedRunningWarningStopped" var _AppStatusNames = []string{ @@ -57,6 +59,13 @@ func (x AppStatus) String() string { return fmt.Sprintf("AppStatus(%d)", x) } +// IsValid provides a quick way to determine if the typed value is +// part of the allowed enumerated values +func (x AppStatus) IsValid() bool { + _, ok := _AppStatusMap[x] + return ok +} + var _AppStatusValue = map[string]AppStatus{ _AppStatusName[0:8]: AppStatusNotFound, _AppStatusName[8:15]: AppStatusCreated, @@ -65,20 +74,20 @@ var _AppStatusValue = map[string]AppStatus{ _AppStatusName[29:36]: AppStatusStopped, } -// ParseAppStatus attempts to convert a string to a AppStatus +// ParseAppStatus attempts to convert a string to a AppStatus. func ParseAppStatus(name string) (AppStatus, error) { if x, ok := _AppStatusValue[name]; ok { return x, nil } - return AppStatus(0), fmt.Errorf("%s is not a valid AppStatus, try [%s]", name, strings.Join(_AppStatusNames, ", ")) + return AppStatus(0), fmt.Errorf("%s is %w", name, ErrInvalidAppStatus) } -// MarshalText implements the text marshaller method +// MarshalText implements the text marshaller method. func (x AppStatus) MarshalText() ([]byte, error) { return []byte(x.String()), nil } -// UnmarshalText implements the text unmarshaller method +// UnmarshalText implements the text unmarshaller method. func (x *AppStatus) UnmarshalText(text []byte) error { name := string(text) tmp, err := ParseAppStatus(name) diff --git a/proto/generator/generator.go b/proto/generator/generator.go index 9de2a2c..c96d51f 100644 --- a/proto/generator/generator.go +++ b/proto/generator/generator.go @@ -36,6 +36,7 @@ var wellKnownProtoRepos = []string{ "buf.build/pinax/firehose-beacon", "buf.build/streamingfast/firehose-starknet", "buf.build/streamingfast/firehose-cosmos", + "buf.build/streamingfast/firehose-gear", } func main() { diff --git a/proto/well_known.go b/proto/well_known.go index 53f5952..fc7075a 100644 --- a/proto/well_known.go +++ b/proto/well_known.go @@ -16,7 +16,6 @@ type WellKnownType struct { } func RegisterWellKnownFileDescriptors(registry *Registry) error { - for _, wt := range wellKnownTypes { fd, err := protoToFileDescriptor(registry, wt.proto) if err != nil { diff --git a/proto/well_known_types.go b/proto/well_known_types.go index f96d362..66dd870 100644 --- a/proto/well_known_types.go +++ b/proto/well_known_types.go @@ -85,5 +85,13 @@ func init() { // sf/cosmos/type/v2/block.proto (https://buf.build/streamingfast/firehose-cosmos/docs/453eb75cabe64abcb4a559f47bcb7e9a:sf.cosmos.type.v2) proto: "0a1d73662f636f736d6f732f747970652f76322f626c6f636b2e70726f746f121173662e636f736d6f732e747970652e76321a1f676f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f1a1e676f6f676c652f70726f746f6275662f6475726174696f6e2e70726f746f2298040a05426c6f636b12120a046861736818012001280c52046861736812160a066865696768741802200128035206686569676874122e0a0474696d6518032001280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d70520474696d6512310a0668656164657218042001280b32192e73662e636f736d6f732e747970652e76322e486561646572520668656164657212400a0b6d69736265686176696f7218062003280b321e2e73662e636f736d6f732e747970652e76322e4d69736265686176696f72520b6d69736265686176696f7212300a066576656e747318072003280b32182e73662e636f736d6f732e747970652e76322e4576656e7452066576656e747312100a0374787318082003280c5203747873123b0a0a74785f726573756c747318092003280b321c2e73662e636f736d6f732e747970652e76322e5478526573756c747352097478526573756c7473124f0a1176616c696461746f725f75706461746573180a2003280b32222e73662e636f736d6f732e747970652e76322e56616c696461746f72557064617465521076616c696461746f7255706461746573125a0a17636f6e73656e7375735f706172616d5f75706461746573180b2001280b32222e73662e636f736d6f732e747970652e76322e436f6e73656e737573506172616d735215636f6e73656e737573506172616d557064617465734a04080c100d4a04080d100e4a04080e100f22c3040a0648656164657212360a0776657273696f6e18012001280b321c2e73662e636f736d6f732e747970652e76322e436f6e73656e737573520776657273696f6e12190a08636861696e5f69641802200128095207636861696e496412160a066865696768741803200128035206686569676874122e0a0474696d6518042001280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d70520474696d65123e0a0d6c6173745f626c6f636b5f696418052001280b321a2e73662e636f736d6f732e747970652e76322e426c6f636b4944520b6c617374426c6f636b496412280a106c6173745f636f6d6d69745f6861736818062001280c520e6c617374436f6d6d697448617368121b0a09646174615f6861736818072001280c5208646174614861736812270a0f76616c696461746f72735f6861736818082001280c520e76616c696461746f72734861736812300a146e6578745f76616c696461746f72735f6861736818092001280c52126e65787456616c696461746f72734861736812250a0e636f6e73656e7375735f68617368180a2001280c520d636f6e73656e7375734861736812190a086170705f68617368180b2001280c520761707048617368122a0a116c6173745f726573756c74735f68617368180c2001280c520f6c617374526573756c74734861736812230a0d65766964656e63655f68617368180d2001280c520c65766964656e63654861736812290a1070726f706f7365725f61646472657373180e2001280c520f70726f706f7365724164647265737322330a09436f6e73656e73757312140a05626c6f636b1801200128045205626c6f636b12100a03617070180220012804520361707022670a07426c6f636b494412120a046861736818012001280c52046861736812480a0f706172745f7365745f68656164657218022001280b32202e73662e636f736d6f732e747970652e76322e50617274536574486561646572520d7061727453657448656164657222390a0d5061727453657448656164657212140a05746f74616c18012001280d5205746f74616c12120a046861736818022001280c52046861736822f7010a0b4d69736265686176696f7212360a047479706518012001280e32222e73662e636f736d6f732e747970652e76322e4d69736265686176696f7254797065520474797065123a0a0976616c696461746f7218022001280b321c2e73662e636f736d6f732e747970652e76322e56616c696461746f72520976616c696461746f7212160a066865696768741803200128035206686569676874122e0a0474696d6518042001280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d70520474696d65122c0a12746f74616c5f766f74696e675f706f7765721805200128035210746f74616c566f74696e67506f776572223b0a0956616c696461746f7212180a076164647265737318012001280c52076164647265737312140a05706f7765721803200128035205706f776572225e0a054576656e7412120a047479706518012001280952047479706512410a0a6174747269627574657318022003280b32212e73662e636f736d6f732e747970652e76322e4576656e74417474726962757465520a6174747269627574657322380a0e4576656e7441747472696275746512100a036b657918012001280952036b657912140a0576616c7565180220012809520576616c756522680a0a4576656e74427974657312120a047479706518012001280952047479706512460a0a6174747269627574657318022003280b32262e73662e636f736d6f732e747970652e76322e4576656e744174747269627574654279746573520a61747472696275746573223d0a134576656e74417474726962757465427974657312100a036b657918012001280c52036b657912140a0576616c756518022001280c520576616c756522e3010a095478526573756c747312120a04636f646518012001280d5204636f646512120a046461746118022001280c52046461746112100a036c6f6718032001280952036c6f6712120a04696e666f1804200128095204696e666f121d0a0a6761735f77616e746564180520012803520967617357616e74656412190a086761735f7573656418062001280352076761735573656412300a066576656e747318072003280b32182e73662e636f736d6f732e747970652e76322e4576656e7452066576656e7473121c0a09636f646573706163651808200128095209636f64657370616365225e0a0f56616c696461746f7255706461746512350a077075625f6b657918012001280b321c2e73662e636f736d6f732e747970652e76322e5075626c69634b657952067075624b657912140a05706f7765721802200128035205706f776572224e0a095075626c69634b6579121a0a076564323535313918012001280c4800520765643235353139121e0a09736563703235366b3118022001280c48005209736563703235366b3142050a0373756d2284020a0f436f6e73656e737573506172616d7312340a05626c6f636b18012001280b321e2e73662e636f736d6f732e747970652e76322e426c6f636b506172616d735205626c6f636b123d0a0865766964656e636518022001280b32212e73662e636f736d6f732e747970652e76322e45766964656e6365506172616d73520865766964656e636512400a0976616c696461746f7218032001280b32222e73662e636f736d6f732e747970652e76322e56616c696461746f72506172616d73520976616c696461746f72123a0a0776657273696f6e18042001280b32202e73662e636f736d6f732e747970652e76322e56657273696f6e506172616d73520776657273696f6e22490a0b426c6f636b506172616d73121b0a096d61785f627974657318012001280352086d6178427974657312170a076d61785f67617318022001280352066d61784761734a0408031004229f010a0e45766964656e6365506172616d73122b0a126d61785f6167655f6e756d5f626c6f636b73180120012803520f6d61784167654e756d426c6f636b7312430a106d61785f6167655f6475726174696f6e18022001280b32192e676f6f676c652e70726f746f6275662e4475726174696f6e520e6d61784167654475726174696f6e121b0a096d61785f627974657318032001280352086d6178427974657322350a0f56616c696461746f72506172616d7312220a0d7075625f6b65795f7479706573180120032809520b7075624b6579547970657322210a0d56657273696f6e506172616d7312100a036170701801200128045203617070225a0a0c486173686564506172616d7312260a0f626c6f636b5f6d61785f6279746573180120012803520d626c6f636b4d6178427974657312220a0d626c6f636b5f6d61785f676173180220012803520b626c6f636b4d61784761732a4b0a0f4d69736265686176696f7254797065120b0a07554e4b4e4f574e100012120a0e4455504c49434154455f564f5445100112170a134c494748545f434c49454e545f41545441434b1002424e5a4c6769746875622e636f6d2f73747265616d696e67666173742f66697265686f73652d636f736d6f732f636f736d6f732f70622f73662f636f736d6f732f747970652f76323b7062636f6d6f73620670726f746f33", }, + { + // google/protobuf/timestamp.proto (https://buf.build/streamingfast/firehose-gear/docs/5eb3cd2c66a540a19505476f405cd5fa:google.protobuf) + proto: "0a1f676f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f120f676f6f676c652e70726f746f627566223b0a0954696d657374616d7012180a077365636f6e647318012001280352077365636f6e647312140a056e616e6f7318022001280552056e616e6f734285010a13636f6d2e676f6f676c652e70726f746f627566420e54696d657374616d7050726f746f50015a32676f6f676c652e676f6c616e672e6f72672f70726f746f6275662f74797065732f6b6e6f776e2f74696d657374616d707062f80101a20203475042aa021e476f6f676c652e50726f746f6275662e57656c6c4b6e6f776e5479706573620670726f746f33", + }, + { + // sf/gear/type/v1/block.proto (https://buf.build/streamingfast/firehose-gear/docs/5eb3cd2c66a540a19505476f405cd5fa:sf.gear.type.v1) + proto: "0a1b73662f676561722f747970652f76312f626c6f636b2e70726f746f120f73662e676561722e747970652e76311a1f676f6f676c652f70726f746f6275662f74696d657374616d702e70726f746f228f030a05426c6f636b12160a066e756d62657218012001280452066e756d62657212120a046861736818022001280c520468617368122f0a0668656164657218032001280b32172e73662e676561722e747970652e76312e4865616465725206686561646572123a0a0a65787472696e7369637318042003280b321a2e73662e676561722e747970652e76312e45787472696e736963520a65787472696e73696373122e0a066576656e747318052003280b32162e73662e676561722e747970652e76312e4576656e7452066576656e7473123e0a0c6469676573745f6974656d7318062003280b321b2e73662e676561722e747970652e76312e4469676573744974656d520b6469676573744974656d7312240a0d6a757374696669636174696f6e18072001280c520d6a757374696669636174696f6e121d0a0a7261775f6576656e747318082001280c52097261774576656e747312380a0974696d657374616d7018092001280b321a2e676f6f676c652e70726f746f6275662e54696d657374616d70520974696d657374616d7022bf010a06486561646572121f0a0b706172656e745f6861736818012001280c520a706172656e7448617368121d0a0a73746174655f726f6f7418022001280c52097374617465526f6f7412270a0f65787472696e736963735f726f6f7418032001280c520e65787472696e73696373526f6f7412210a0c737065635f76657273696f6e18042001280d520b7370656356657273696f6e12290a10757064617465645f6d6574616461746118052001280c520f757064617465644d6574616461746122f7020a0a4469676573744974656d12310a1461735f6368616e6765735f747269655f726f6f7418012001280c4800521161734368616e67657354726965526f6f7412430a0e61735f7072655f72756e74696d6518022001280b321b2e73662e676561722e747970652e76312e50726552756e74696d654800520c617350726552756e74696d65123f0a0c61735f636f6e73656e73757318032001280b321a2e73662e676561722e747970652e76312e436f6e73656e7375734800520b6173436f6e73656e73757312300a0761735f7365616c18042001280b32152e73662e676561722e747970652e76312e5365616c4800520661735365616c12590a1661735f6368616e6765735f747269655f7369676e616c18052001280b32222e73662e676561722e747970652e76312e4368616e676573547269655369676e616c4800521361734368616e676573547269655369676e616c121b0a0861735f6f7468657218062001280c4800520761734f7468657242060a044974656d22520a0a50726552756e74696d65122e0a13636f6e73656e7375735f656e67696e655f696418012001280d5211636f6e73656e737573456e67696e65496412140a05627974657318022001280c5205627974657322510a09436f6e73656e737573122e0a13636f6e73656e7375735f656e67696e655f696418012001280d5211636f6e73656e737573456e67696e65496412140a05627974657318022001280c52056279746573224c0a045365616c122e0a13636f6e73656e7375735f656e67696e655f696418012001280d5211636f6e73656e737573456e67696e65496412140a05627974657318022001280c5205627974657322770a114368616e676573547269655369676e616c12300a1469735f6e65775f636f6e66696775726174696f6e180120012808521269734e6577436f6e66696775726174696f6e12300a1461735f6e65775f636f6e66696775726174696f6e18022001280c521261734e6577436f6e66696775726174696f6e228e010a0945787472696e73696312180a0776657273696f6e18012001280d520776657273696f6e12380a097369676e617475726518022001280b321a2e73662e676561722e747970652e76312e5369676e617475726552097369676e6174757265122d0a066d6574686f6418032001280b32152e73662e676561722e747970652e76312e43616c6c52066d6574686f6422da010a095369676e617475726512350a067369676e657218012001280b321d2e73662e676561722e747970652e76312e4d756c74694164647265737352067369676e6572123d0a097369676e617475726518022001280b321f2e73662e676561722e747970652e76312e4d756c74695369676e617475726552097369676e6174757265122f0a0365726118032001280b321d2e73662e676561722e747970652e76312e45787472696e736963457261520365726112140a056e6f6e636518042001280952056e6f6e636512100a03746970180520012809520374697022ac020a0c4d756c74694164647265737312130a0569735f696418012001280852046973496412130a0561735f696418022001280c52046173496412190a0869735f696e64657818032001280852076973496e64657812190a0861735f696e64657818042001280d52076173496e64657812150a0669735f7261771805200128085205697352617712150a0661735f72617718062001280c5205617352617712220a0d69735f616464726573735f3332180720012808520b697341646472657373333212220a0d61735f616464726573735f333218082001280c520b617341646472657373333212220a0d69735f616464726573735f3230180920012808520b697341646472657373323012220a0d61735f616464726573735f3230180a2001280c520b617341646472657373323022c6010a0e4d756c74695369676e6174757265121e0a0b69735f65645f32353531391801200128085209697345643235353139121e0a0b61735f65645f323535313918022001280c5209617345643235353139121e0a0b69735f73725f32353531391803200128085209697353723235353139121e0a0b61735f73725f323535313918042001280c520961735372323535313912190a0869735f656364736118052001280852076973456364736112190a0861735f656364736118062001280c520761734563647361229a010a0c45787472696e73696345726112260a0f69735f696d6d6f7274616c5f657261180120012808520d6973496d6d6f7274616c45726112220a0d69735f6d6f7274616c5f657261180220012808520b69734d6f7274616c457261123e0a0d61735f6d6f7274616c5f65726118032001280b321a2e73662e676561722e747970652e76312e4d6f7274616c457261520b61734d6f7274616c45726122550a0443616c6c12390a0a63616c6c5f696e64657818012001280b321a2e73662e676561722e747970652e76312e43616c6c496e646578520963616c6c496e64657812120a046172677318022001280c52046172677322530a0943616c6c496e64657812230a0d73656374696f6e5f696e64657818012001280d520c73656374696f6e496e64657812210a0c6d6574686f645f696e64657818022001280d520b6d6574686f64496e64657822710a054576656e7412120a046e616d6518012001280952046e616d65120e0a02696418032001280c52026964122c0a05706861736518042001280b32162e73662e676561722e747970652e76312e50686173655205706861736512160a06746f7069637318052003280c5206746f7069637322b9010a055068617365122c0a1269735f6170706c795f65787472696e736963180120012808521069734170706c7945787472696e736963122c0a1261735f6170706c795f65787472696e73696318022001280d521061734170706c7945787472696e73696312270a0f69735f66696e616c697a6174696f6e180320012808520e697346696e616c697a6174696f6e122b0a1169735f696e697469616c697a6174696f6e18042001280852106973496e697469616c697a6174696f6e22390a094d6f7274616c45726112140a05666972737418012001280d5205666972737412160a067365636f6e6418022001280d52067365636f6e6422210a0d5061796d656e744669656c647312100a03746970180120012809520374697042425a406769746875622e636f6d2f73747265616d696e67666173742f66697265686f73652d676561722f70622f73662f676561722f747970652f76313b706267656172620670726f746f33", + }, } -} +} \ No newline at end of file diff --git a/types/block_range_enum.go b/types/block_range_enum.go index 668a645..c7d4c86 100644 --- a/types/block_range_enum.go +++ b/types/block_range_enum.go @@ -18,6 +18,8 @@ const ( RangeBoundaryExclusive ) +var ErrInvalidRangeBoundary = fmt.Errorf("not a valid RangeBoundary, try [%s]", strings.Join(_RangeBoundaryNames, ", ")) + const _RangeBoundaryName = "InclusiveExclusive" var _RangeBoundaryNames = []string{ @@ -45,6 +47,13 @@ func (x RangeBoundary) String() string { return fmt.Sprintf("RangeBoundary(%d)", x) } +// IsValid provides a quick way to determine if the typed value is +// part of the allowed enumerated values +func (x RangeBoundary) IsValid() bool { + _, ok := _RangeBoundaryMap[x] + return ok +} + var _RangeBoundaryValue = map[string]RangeBoundary{ _RangeBoundaryName[0:9]: RangeBoundaryInclusive, strings.ToLower(_RangeBoundaryName[0:9]): RangeBoundaryInclusive, @@ -52,7 +61,7 @@ var _RangeBoundaryValue = map[string]RangeBoundary{ strings.ToLower(_RangeBoundaryName[9:18]): RangeBoundaryExclusive, } -// ParseRangeBoundary attempts to convert a string to a RangeBoundary +// ParseRangeBoundary attempts to convert a string to a RangeBoundary. func ParseRangeBoundary(name string) (RangeBoundary, error) { if x, ok := _RangeBoundaryValue[name]; ok { return x, nil @@ -61,15 +70,15 @@ func ParseRangeBoundary(name string) (RangeBoundary, error) { if x, ok := _RangeBoundaryValue[strings.ToLower(name)]; ok { return x, nil } - return RangeBoundary(0), fmt.Errorf("%s is not a valid RangeBoundary, try [%s]", name, strings.Join(_RangeBoundaryNames, ", ")) + return RangeBoundary(0), fmt.Errorf("%s is %w", name, ErrInvalidRangeBoundary) } -// MarshalText implements the text marshaller method +// MarshalText implements the text marshaller method. func (x RangeBoundary) MarshalText() ([]byte, error) { return []byte(x.String()), nil } -// UnmarshalText implements the text unmarshaller method +// UnmarshalText implements the text unmarshaller method. func (x *RangeBoundary) UnmarshalText(text []byte) error { name := string(text) tmp, err := ParseRangeBoundary(name)