Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: clean up
  • Loading branch information
xavier-brochard committed Aug 4, 2025
commit 43e9e99824703c76899e9cc922af109ee7c4eccb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import {
updateInterface,
} from '../../../utils/interface';
import baseLogger, { createPrefixedLogger } from '../../../utils/logger';
import { ScheduleBackgroundEventMethod } from './ScheduleBackgroundEventMethod';

export const refreshConfirmationEstimation: OnCronjobHandler = async () => {
const logger = createPrefixedLogger(
baseLogger,
'[refreshConfirmationEstimation]',
);

logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] Background event triggered`,
);
logger.info(`Background event triggered`);

const mapInterfaceNameToId =
(await state.getKey<UnencryptedStateValue['mapInterfaceNameToId']>(
Expand All @@ -32,9 +29,7 @@ export const refreshConfirmationEstimation: OnCronjobHandler = async () => {

// Don't do anything if the confirmation interface is not open
if (!confirmationInterfaceId) {
logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] No interface context found`,
);
logger.info(`No interface context found`);
return;
}

Expand All @@ -61,17 +56,13 @@ export const refreshConfirmationEstimation: OnCronjobHandler = async () => {
!interfaceContext.scope ||
!interfaceContext.method
) {
logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] Context is missing required fields`,
);
logger.info(`Context is missing required fields`);
return;
}

// Skip transaction simulation if the preference is disabled
if (!interfaceContext.preferences?.simulateOnChainActions) {
logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] Transaction simulation is disabled in preferences`,
);
logger.info(`Transaction simulation is disabled in preferences`);
return;
}

Expand Down Expand Up @@ -107,19 +98,15 @@ export const refreshConfirmationEstimation: OnCronjobHandler = async () => {
scan,
};

logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] New scan fetched`,
);
logger.info(`New scan fetched`);

await updateInterface(
confirmationInterfaceId,
<ConfirmTransactionRequest context={updatedInterfaceContext} />,
updatedInterfaceContext,
);

logger.info(
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] Background event suceeded`,
);
logger.info(`Background event suceeded`);
} catch (error) {
const fetchedInterfaceContext =
await getInterfaceContextOrThrow<ConfirmTransactionRequestContext>(
Expand All @@ -139,7 +126,7 @@ export const refreshConfirmationEstimation: OnCronjobHandler = async () => {

logger.info(
{ error },
`[${ScheduleBackgroundEventMethod.RefreshConfirmationEstimation}] Could not update the interface. But rolled back status to fetched.`,
`Could not update the interface. But rolled back status to fetched.`,
);
}
};
Loading