diff --git a/codegenerator/cli/src/hbs_templating/contract_import_templates.rs b/codegenerator/cli/src/hbs_templating/contract_import_templates.rs index c28e8969..9aeb9160 100644 --- a/codegenerator/cli/src/hbs_templating/contract_import_templates.rs +++ b/codegenerator/cli/src/hbs_templating/contract_import_templates.rs @@ -281,13 +281,13 @@ impl Event { } .to_string(); - let second_part = match is_fuel { - true => format!("${{{event_var_name}.transaction.id}}"), - false => format!("${{{event_var_name}.block.number}}"), + let block_number_field = match is_fuel { + true => "height", + false => "number", }; format!( - "`${{{event_var_name}.chainId}}_{second_part}_${{{event_var_name}.logIndex{}}}`", + "`${{{event_var_name}.chainId}}_${{{event_var_name}.block.{block_number_field}}}_${{{event_var_name}.logIndex{}}}`", to_string_code ) } diff --git a/codegenerator/cli/templates/static/codegen/src/eventFetching/hyperfuel/HyperFuel.res b/codegenerator/cli/templates/static/codegen/src/eventFetching/hyperfuel/HyperFuel.res index c26852f4..4d9c27d7 100644 --- a/codegenerator/cli/templates/static/codegen/src/eventFetching/hyperfuel/HyperFuel.res +++ b/codegenerator/cli/templates/static/codegen/src/eventFetching/hyperfuel/HyperFuel.res @@ -294,7 +294,7 @@ module HeightQuery = { //height to be set in loop let height = ref(0) - //Retry if the heigth is 0 (expect height to be greater) + //Retry if the height is 0 (expect height to be greater) while height.contents <= 0 { let res = await HyperFuelJsonApi.getArchiveHeight(~serverUrl) Logging.debug({"msg": "querying height", "response": res}) diff --git a/codegenerator/cli/templates/static/codegen/src/eventFetching/hypersync/HyperSync.res b/codegenerator/cli/templates/static/codegen/src/eventFetching/hypersync/HyperSync.res index b00b0b06..5e0f8c24 100644 --- a/codegenerator/cli/templates/static/codegen/src/eventFetching/hypersync/HyperSync.res +++ b/codegenerator/cli/templates/static/codegen/src/eventFetching/hypersync/HyperSync.res @@ -109,14 +109,18 @@ module LogsQuery = { switch returnedObj ->(Utils.magic: 'a => Js.Dict.t) ->Utils.Dict.dangerouslyGetNonOption(fieldName) { - | Some(_) => () - | None => acc->Array.push(prefix ++ "." ++ fieldName)->ignore + | Some(_) => () + | None => acc->Array.push(prefix ++ "." ++ fieldName)->ignore } }) } //Note this function can throw an error - let convertEvent = (event: HyperSyncClient.ResponseTypes.event, ~nonOptionalBlockFieldNames, ~nonOptionalTransactionFieldNames): logsQueryPageItem => { + let convertEvent = ( + event: HyperSyncClient.ResponseTypes.event, + ~nonOptionalBlockFieldNames, + ~nonOptionalTransactionFieldNames, + ): logsQueryPageItem => { let missingParams = [] missingParams->addMissingParams(Types.Log.fieldNames, event.log, ~prefix="log") missingParams->addMissingParams(nonOptionalBlockFieldNames, event.block, ~prefix="block") @@ -150,12 +154,17 @@ module LogsQuery = { } } - let convertResponse = (res: HyperSyncClient.ResponseTypes.eventResponse, ~nonOptionalBlockFieldNames, ~nonOptionalTransactionFieldNames): queryResponse< - logsQueryPage, - > => { + let convertResponse = ( + res: HyperSyncClient.ResponseTypes.eventResponse, + ~nonOptionalBlockFieldNames, + ~nonOptionalTransactionFieldNames, + ): queryResponse => { try { let {nextBlock, archiveHeight, rollbackGuard} = res - let items = res.data->Array.map(item => item->convertEvent(~nonOptionalBlockFieldNames, ~nonOptionalTransactionFieldNames)) + let items = + res.data->Array.map(item => + item->convertEvent(~nonOptionalBlockFieldNames, ~nonOptionalTransactionFieldNames) + ) let page: logsQueryPage = { items, nextBlock, @@ -191,7 +200,12 @@ module LogsQuery = { }) ) - let query = makeRequestBody(~fromBlock, ~toBlockInclusive=toBlock, ~addressesWithTopics, ~fieldSelection) + let query = makeRequestBody( + ~fromBlock, + ~toBlockInclusive=toBlock, + ~addressesWithTopics, + ~fieldSelection, + ) let hyperSyncClient = CachedClients.getClient(serverUrl) @@ -216,7 +230,7 @@ module HeightQuery = { //height to be set in loop let height = ref(0) - //Retry if the heigth is 0 (expect height to be greater) + //Retry if the height is 0 (expect height to be greater) while height.contents <= 0 { let res = await HyperSyncJsonApi.getArchiveHeight(~serverUrl) switch res {