@@ -114,8 +114,16 @@ func ParseBlocksArguments(arguments models.Arguments) (BlocksArguments, error) {
114114 return args , fmt .Errorf ("'block_status' must be provided" )
115115 }
116116
117+ startBlockIDIn , hasStartBlockID := arguments ["start_block_id" ]
118+ startBlockHeightIn , hasStartBlockHeight := arguments ["start_block_height" ]
119+
120+ // Ensure only one of start_block_id or start_block_height is provided
121+ if hasStartBlockID && hasStartBlockHeight {
122+ return args , fmt .Errorf ("can only provide either 'start_block_id' or 'start_block_height'" )
123+ }
124+
117125 // Parse 'start_block_id' if provided
118- if startBlockIDIn , ok := arguments [ "start_block_id" ]; ok {
126+ if hasStartBlockID {
119127 var startBlockID parser.ID
120128 err := startBlockID .Parse (startBlockIDIn )
121129 if err != nil {
@@ -125,7 +133,7 @@ func ParseBlocksArguments(arguments models.Arguments) (BlocksArguments, error) {
125133 }
126134
127135 // Parse 'start_block_height' if provided
128- if startBlockHeightIn , ok := arguments [ "start_block_height" ]; ok {
136+ if hasStartBlockHeight {
129137 var err error
130138 args .StartBlockHeight , err = util .ToUint64 (startBlockHeightIn )
131139 if err != nil {
@@ -135,10 +143,5 @@ func ParseBlocksArguments(arguments models.Arguments) (BlocksArguments, error) {
135143 args .StartBlockHeight = request .EmptyHeight
136144 }
137145
138- // Ensure only one of start_block_id or start_block_height is provided
139- if args .StartBlockID != flow .ZeroID && args .StartBlockHeight != request .EmptyHeight {
140- return args , fmt .Errorf ("can only provide either 'start_block_id' or 'start_block_height'" )
141- }
142-
143146 return args , nil
144147}
0 commit comments