Skip to content

Commit 3a001e3

Browse files
authored
Merge pull request #3211 from humanprotocol/develop
[Job Launcher] Fix payment creation order and enable whitelist check
2 parents 631127a + 576c718 commit 3a001e3

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

packages/apps/job-launcher/server/src/common/constants/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
export enum ErrorJob {
55
NotFound = 'Job not found',
66
NotCreated = 'Job has not been created',
7-
NotActiveCard = 'Credit card not found',
7+
NotActiveCard = 'Credit card not found. Please, add a credit card to your account.',
88
ManifestNotFound = 'Manifest not found',
99
ManifestValidationFailed = 'Manifest validation failed',
1010
ResultNotFound = 'Result not found',

packages/apps/job-launcher/server/src/modules/job/job.service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,6 @@ export class JobService {
878878
});
879879
}
880880

881-
const paymentEntity = await this.paymentService.createWithdrawalPayment(
882-
user.id,
883-
totalPaymentAmount,
884-
dto.paymentCurrency,
885-
paymentCurrencyRate,
886-
);
887-
888881
const { createManifest } = this.createJobSpecificActions[requestType];
889882

890883
let jobEntity = new JobEntity();
@@ -923,6 +916,13 @@ export class JobService {
923916
jobEntity.manifestHash = hash;
924917
}
925918

919+
const paymentEntity = await this.paymentService.createWithdrawalPayment(
920+
user.id,
921+
totalPaymentAmount,
922+
dto.paymentCurrency,
923+
paymentCurrencyRate,
924+
);
925+
926926
jobEntity.chainId = chainId;
927927
jobEntity.reputationOracle = reputationOracle;
928928
jobEntity.exchangeOracle = exchangeOracle;

packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ describe('WhitelistService', () => {
3737
expect(result).toBe(true);
3838
});
3939

40-
// it('should return false if user is not whitelisted', async () => {
41-
// const userId = 2;
42-
// jest
43-
// .spyOn(whitelistRepository, 'findOneByUserId')
44-
// .mockResolvedValue(null);
40+
it('should return false if user is not whitelisted', async () => {
41+
const userId = 2;
42+
jest
43+
.spyOn(whitelistRepository, 'findOneByUserId')
44+
.mockResolvedValue(null);
4545

46-
// const result = await whitelistService.isUserWhitelisted(userId);
46+
const result = await whitelistService.isUserWhitelisted(userId);
4747

48-
// expect(whitelistRepository.findOneByUserId).toHaveBeenCalledWith(userId);
49-
// expect(result).toBe(false);
50-
// });
48+
expect(whitelistRepository.findOneByUserId).toHaveBeenCalledWith(userId);
49+
expect(result).toBe(false);
50+
});
5151
});
5252
});

packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export class WhitelistService {
66
constructor(private readonly whitelistRepository: WhitelistRepository) {}
77

88
async isUserWhitelisted(userId: number): Promise<boolean> {
9-
// TODO: Enable it when billing system is active
10-
return true;
119
const user = await this.whitelistRepository.findOneByUserId(userId);
1210
return !!user;
1311
}

0 commit comments

Comments
 (0)