Skip to content

Commit 49e8c82

Browse files
authored
WIP: 3a1a3cd refactor: update token decimals handling and improve input validation in payment forms (#3200)
1 parent 7c1b969 commit 49e8c82

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

packages/apps/job-launcher/client/src/components/Jobs/Table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export const JobTable = ({
6262
{
6363
id: 'fundAmount',
6464
label: 'Fund Amount',
65-
render: ({ fundAmount }) => `${fundAmount} HMT`,
65+
render: ({ fundAmount, currency }) =>
66+
`${Number(fundAmount)} ${currency.toUpperCase()}`,
6667
},
6768
{ id: 'status', label: 'Status' },
6869
{

packages/apps/job-launcher/client/src/pages/Job/JobDetail/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ export default function JobDetail() {
133133
/>
134134
<CardTextRow
135135
label="Balance"
136-
value={`${data.details.balance} HMT`}
136+
value={`${data.details.balance} ${(data.details.currency ?? '').toUpperCase()}`}
137137
/>
138138
<CardTextRow
139-
label="Paid Out HMT"
140-
value={`${data.details.paidOut.toString()} HMT`}
139+
label="Paid Out"
140+
value={`${data.details.paidOut.toString()} ${data.details.currency ?? ''.toUpperCase()}`}
141141
/>
142142
</Stack>
143143
</CardContainer>
@@ -180,7 +180,7 @@ export default function JobDetail() {
180180
/>
181181
<CardTextRow
182182
label="Fund Amount"
183-
value={`${data.manifest.fundAmount.toString()} HMT`}
183+
value={`${data.manifest.fundAmount.toString()} ${data.details.currency ?? ''.toUpperCase()}`}
184184
/>
185185
</Stack>
186186
</Grid>

packages/apps/job-launcher/client/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export type JobDetailsResponse = {
263263
manifestHash: string;
264264
balance: number;
265265
paidOut: number;
266+
currency?: string;
266267
status: string;
267268
};
268269
manifest: {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ export class CommonDetails {
328328
@Min(0)
329329
public paidOut: number;
330330

331+
@ApiProperty({
332+
description: 'Currency of the job',
333+
})
334+
@IsEnumCaseInsensitive(EscrowFundToken)
335+
public currency?: EscrowFundToken;
336+
331337
@ApiProperty({
332338
description: 'Number of tasks (optional)',
333339
name: 'amount_of_tasks',
@@ -477,6 +483,9 @@ export class JobListDto {
477483
@ApiProperty({ name: 'fund_amount' })
478484
public fundAmount: number;
479485

486+
@ApiProperty()
487+
public currency: EscrowFundToken;
488+
480489
@ApiProperty()
481490
public status: JobStatus;
482491
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ export class JobService {
12831283
escrowAddress: job.escrowAddress,
12841284
network: NETWORKS[job.chainId as ChainId]!.title,
12851285
fundAmount: job.fundAmount,
1286+
currency: job.token as EscrowFundToken,
12861287
status: job.status,
12871288
};
12881289
});
@@ -1615,6 +1616,7 @@ export class JobService {
16151616
manifestHash,
16161617
balance: Number(ethers.formatEther(escrow?.balance || 0)),
16171618
paidOut: Number(ethers.formatEther(escrow?.amountPaid || 0)),
1619+
currency: jobEntity.token as EscrowFundToken,
16181620
status: jobEntity.status,
16191621
failedReason: jobEntity.failedReason,
16201622
},

0 commit comments

Comments
 (0)