diff --git a/packages/apps/fortune/recording-oracle/src/modules/job/job.service.ts b/packages/apps/fortune/recording-oracle/src/modules/job/job.service.ts index fa8e8a617c..38f17ea2b3 100644 --- a/packages/apps/fortune/recording-oracle/src/modules/job/job.service.ts +++ b/packages/apps/fortune/recording-oracle/src/modules/job/job.service.ts @@ -61,8 +61,8 @@ export class JobService { }; this.storageClient = new StorageClient( - storageCredentials, this.storageParams, + storageCredentials, ); } diff --git a/packages/apps/job-launcher/server/src/modules/job/job.service.spec.ts b/packages/apps/job-launcher/server/src/modules/job/job.service.spec.ts index 68d552630c..5c73509cdc 100644 --- a/packages/apps/job-launcher/server/src/modules/job/job.service.spec.ts +++ b/packages/apps/job-launcher/server/src/modules/job/job.service.spec.ts @@ -313,13 +313,13 @@ describe('JobService', () => { describe('calculateJobBounty', () => { it('should calculate the job bounty correctly', async () => { - const fundAmount = 10; + const fundAmount = 0.013997056833333334; const result = await jobService['calculateJobBounty']( MOCK_FILE_URL, fundAmount, ); - expect(result).toEqual(2); + expect(result).toEqual('0.002332842805555555'); }); }); diff --git a/packages/apps/job-launcher/server/src/modules/job/job.service.ts b/packages/apps/job-launcher/server/src/modules/job/job.service.ts index b3b0324862..582372ae09 100644 --- a/packages/apps/job-launcher/server/src/modules/job/job.service.ts +++ b/packages/apps/job-launcher/server/src/modules/job/job.service.ts @@ -167,9 +167,7 @@ export class JobService { ), gt_url: dto.gtUrl, }, - job_bounty: ( - await this.calculateJobBounty(dto.dataUrl, fundAmount) - ).toString(), + job_bounty: await this.calculateJobBounty(dto.dataUrl, fundAmount), })); } @@ -222,7 +220,7 @@ export class JobService { private async calculateJobBounty( endpointUrl: string, fundAmount: number, - ): Promise { + ): Promise { const storageData = parseUrl(endpointUrl); const storageClient = new StorageClient({ endPoint: storageData.endpoint, @@ -234,11 +232,15 @@ export class JobService { .length; const totalJobs = Math.ceil( - totalImages / + div( + totalImages, Number(this.configService.get(ConfigNames.CVAT_JOB_SIZE)!), + ), ); - return fundAmount / totalJobs; + return ethers.utils.formatEther( + ethers.utils.parseUnits(fundAmount.toString(), 'ether').div(totalJobs), + ); } public async launchJob(jobEntity: JobEntity): Promise { diff --git a/packages/apps/job-launcher/server/test/constants.ts b/packages/apps/job-launcher/server/test/constants.ts index 9f73e825ea..3c7feb24bf 100644 --- a/packages/apps/job-launcher/server/test/constants.ts +++ b/packages/apps/job-launcher/server/test/constants.ts @@ -6,7 +6,14 @@ export const MOCK_ADDRESS = '0xCf88b3f1992458C2f5a229573c768D0E9F70C44e'; export const MOCK_FILE_URL = 'http://mockedFileUrl.test'; export const MOCK_FILE_HASH = 'mockedFileHash'; export const MOCK_FILE_KEY = 'manifest.json'; -export const MOCK_BUCKET_FILES = ['file0', 'file1', 'file2', 'file3', 'file4']; +export const MOCK_BUCKET_FILES = [ + 'file0', + 'file1', + 'file2', + 'file3', + 'file4', + 'file5', +]; export const MOCK_PRIVATE_KEY = 'd334daf65a631f40549cc7de126d5a0016f32a2d00c49f94563f9737f7135e55'; export const MOCK_BUCKET_NAME = 'bucket-name';