11import consola from 'consola' ;
22import { Types } from 'mongoose' ;
33
4- import * as executeDCASwapJobDef from './executeDCASwap' ;
54import { getAgenda } from '../agendaClient' ;
5+ import { jobName } from './executeDCASwap' ;
6+ import { JobParams , JobType } from './executeDCASwap/types' ;
67
78interface FindSpecificScheduledJobParams {
89 ethAddress : string ;
@@ -18,26 +19,22 @@ export async function listJobsByEthAddress({ ethAddress }: { ethAddress: string
1819
1920 return ( await agendaClient . jobs ( {
2021 'data.pkpInfo.ethAddress' : ethAddress ,
21- } ) ) as executeDCASwapJobDef . JobType [ ] ;
22+ } ) ) as JobType [ ] ;
2223}
2324
24- export async function findJob (
25- params : FindSpecificScheduledJobParams
26- ) : Promise < executeDCASwapJobDef . JobType > ;
27- export async function findJob (
28- params : FindSpecificScheduledJobParams
29- ) : Promise < executeDCASwapJobDef . JobType | undefined > ;
25+ export async function findJob ( params : FindSpecificScheduledJobParams ) : Promise < JobType > ;
26+ export async function findJob ( params : FindSpecificScheduledJobParams ) : Promise < JobType | undefined > ;
3027export async function findJob ( {
3128 ethAddress,
3229 mustExist,
3330 scheduleId,
34- } : FindSpecificScheduledJobParams ) : Promise < executeDCASwapJobDef . JobType | undefined > {
31+ } : FindSpecificScheduledJobParams ) : Promise < JobType | undefined > {
3532 const agendaClient = getAgenda ( ) ;
3633
3734 const jobs = ( await agendaClient . jobs ( {
3835 _id : new Types . ObjectId ( scheduleId ) ,
3936 'data.pkpInfo.ethAddress' : ethAddress ,
40- } ) ) as executeDCASwapJobDef . JobType [ ] ;
37+ } ) ) as JobType [ ] ;
4138
4239 logger . log ( `Found ${ jobs . length } jobs with ID ${ scheduleId } ` ) ;
4340 if ( mustExist && ! jobs . length ) {
@@ -51,7 +48,7 @@ export async function editJob({
5148 data,
5249 scheduleId,
5350} : {
54- data : Omit < executeDCASwapJobDef . JobParams , 'updatedAt' > ;
51+ data : Omit < JobParams , 'updatedAt' > ;
5552 scheduleId : string ;
5653} ) {
5754 const {
@@ -70,7 +67,7 @@ export async function editJob({
7067
7168 job . attrs . data = { ...data , updatedAt : new Date ( ) } ;
7269
73- return ( await job . save ( ) ) as unknown as executeDCASwapJobDef . JobType ;
70+ return ( await job . save ( ) ) as unknown as JobType ;
7471}
7572
7673export async function disableJob ( {
@@ -113,7 +110,7 @@ export async function cancelJob({
113110}
114111
115112export async function createJob (
116- data : Omit < executeDCASwapJobDef . JobParams , 'updatedAt' > ,
113+ data : Omit < JobParams , 'updatedAt' > ,
117114 options : {
118115 interval ?: string ;
119116 schedule ?: string ;
@@ -122,7 +119,7 @@ export async function createJob(
122119 const agenda = getAgenda ( ) ;
123120
124121 // Create a new job instance
125- const job = agenda . create < executeDCASwapJobDef . JobParams > ( executeDCASwapJobDef . jobName , {
122+ const job = agenda . create < JobParams > ( jobName , {
126123 ...data ,
127124 updatedAt : new Date ( ) ,
128125 } ) ;
0 commit comments