Skip to content

Commit b62347f

Browse files
committed
Refactor data types in EscrowData, OperatorData, and StakerData to use string instead of int and parse values inside constructor; improve nullability handling in various models.
1 parent ce94c9c commit b62347f

File tree

8 files changed

+150
-275
lines changed

8 files changed

+150
-275
lines changed

packages/apps/human-app/server/src/modules/oracle-discovery/model/oracle-discovery.model.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ type DiscoveredOracleCreateProps = {
1414
withdrawnAmount: bigint | null;
1515
slashedAmount: bigint | null;
1616
amountJobsProcessed: bigint | null;
17-
role: string | null;
17+
role: string;
1818
fee: bigint | null;
1919
publicKey: string | null;
2020
webhookUrl: string | null;
2121
website: string | null;
22-
url: string | null;
22+
url: string;
2323
jobTypes: string[] | null;
2424
registrationNeeded: boolean | null;
2525
registrationInstructions: string | null;
2626
reputationNetworks: string[];
27-
name: string | null;
27+
name: string;
2828
category: string | null;
2929
};
3030

@@ -76,11 +76,11 @@ export class DiscoveredOracle {
7676
@ApiPropertyOptional({ description: 'Website of the operator' })
7777
website?: string;
7878

79-
@ApiPropertyOptional({ description: 'URL of the oracle operator' })
80-
url?: string;
79+
@ApiProperty({ description: 'URL of the oracle operator' })
80+
url: string;
8181

82-
@ApiPropertyOptional({ description: 'Role of the oracle operator' })
83-
role?: string;
82+
@ApiProperty({ description: 'Role of the oracle operator' })
83+
role: string;
8484

8585
@ApiPropertyOptional({
8686
type: [String],
@@ -102,8 +102,8 @@ export class DiscoveredOracle {
102102
})
103103
reputationNetworks?: string[];
104104

105-
@ApiPropertyOptional({ description: 'Name of the operator' })
106-
name?: string;
105+
@ApiProperty({ description: 'Name of the operator' })
106+
name: string;
107107

108108
@ApiPropertyOptional({ description: 'Category of the operator' })
109109
category?: string;
@@ -119,9 +119,9 @@ export class DiscoveredOracle {
119119
this.address = props.address;
120120
this.chainId = props.chainId;
121121
this.registrationNeeded = props.registrationNeeded ?? undefined;
122-
this.role = props.role ?? undefined;
123-
this.url = props.url ?? undefined;
124-
this.name = props.name ?? undefined;
122+
this.role = props.role;
123+
this.url = props.url;
124+
this.name = props.name;
125125
this.fee = props.fee ?? undefined;
126126
this.publicKey = props.publicKey ?? undefined;
127127
this.webhookUrl = props.webhookUrl ?? undefined;

packages/apps/human-app/server/src/modules/oracle-discovery/oracle-discovery.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export class OracleDiscoveryService {
9393
new DiscoveredOracle({
9494
id: exchangeOracle.id,
9595
address: exchangeOracle.address,
96-
name: exchangeOracle.name,
97-
role: exchangeOracle.role,
96+
name: exchangeOracle.name as string,
97+
role: exchangeOracle.role as string,
9898
url: exchangeOracle.url as string,
9999
jobTypes: exchangeOracle.jobTypes as string[],
100100
registrationNeeded: exchangeOracle.registrationNeeded,

packages/sdk/python/human-protocol-sdk/human_protocol_sdk/escrow/escrow_utils.py

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ def __init__(
5252
chain_id: ChainId,
5353
id: str,
5454
address: str,
55-
amount_paid: int,
56-
balance: int,
57-
count: int,
55+
amount_paid: str,
56+
balance: str,
57+
count: str,
5858
factory_address: str,
5959
launcher: str,
6060
job_requester_id: Optional[str],
6161
status: str,
6262
token: str,
63-
total_funded_amount: int,
64-
created_at: int,
63+
total_funded_amount: str,
64+
created_at: str,
6565
final_results_url: Optional[str] = None,
6666
final_results_hash: Optional[str] = None,
6767
intermediate_results_url: Optional[str] = None,
@@ -71,9 +71,9 @@ def __init__(
7171
recording_oracle: Optional[str] = None,
7272
reputation_oracle: Optional[str] = None,
7373
exchange_oracle: Optional[str] = None,
74-
recording_oracle_fee: Optional[int] = None,
75-
reputation_oracle_fee: Optional[int] = None,
76-
exchange_oracle_fee: Optional[int] = None,
74+
recording_oracle_fee: Optional[str] = None,
75+
reputation_oracle_fee: Optional[str] = None,
76+
exchange_oracle_fee: Optional[str] = None,
7777
):
7878
"""
7979
Initializes an EscrowData instance.
@@ -107,9 +107,9 @@ def __init__(
107107

108108
self.id = id
109109
self.address = address
110-
self.amount_paid = amount_paid
111-
self.balance = balance
112-
self.count = count
110+
self.amount_paid = int(amount_paid)
111+
self.balance = int(balance)
112+
self.count = int(count)
113113
self.factory_address = factory_address
114114
self.final_results_url = final_results_url
115115
self.final_results_hash = final_results_hash
@@ -122,13 +122,19 @@ def __init__(
122122
self.recording_oracle = recording_oracle
123123
self.reputation_oracle = reputation_oracle
124124
self.exchange_oracle = exchange_oracle
125-
self.recording_oracle_fee = recording_oracle_fee
126-
self.reputation_oracle_fee = reputation_oracle_fee
127-
self.exchange_oracle_fee = exchange_oracle_fee
125+
self.recording_oracle_fee = (
126+
int(recording_oracle_fee) if recording_oracle_fee is not None else None
127+
)
128+
self.reputation_oracle_fee = (
129+
int(reputation_oracle_fee) if reputation_oracle_fee is not None else None
130+
)
131+
self.exchange_oracle_fee = (
132+
int(exchange_oracle_fee) if exchange_oracle_fee is not None else None
133+
)
128134
self.status = status
129135
self.token = token
130-
self.total_funded_amount = total_funded_amount
131-
self.created_at = created_at * 1000
136+
self.total_funded_amount = int(total_funded_amount)
137+
self.created_at = int(created_at) * 1000
132138
self.chain_id = chain_id
133139

134140

@@ -295,16 +301,16 @@ def get_escrows(
295301
chain_id=chain_id,
296302
id=escrow.get("id"),
297303
address=escrow.get("address"),
298-
amount_paid=int(escrow.get("amountPaid")),
299-
balance=int(escrow.get("balance")),
300-
count=int(escrow.get("count")),
304+
amount_paid=escrow.get("amountPaid"),
305+
balance=escrow.get("balance"),
306+
count=escrow.get("count"),
301307
factory_address=escrow.get("factoryAddress"),
302308
launcher=escrow.get("launcher"),
303309
job_requester_id=escrow.get("jobRequesterId"),
304310
status=escrow.get("status"),
305311
token=escrow.get("token"),
306-
total_funded_amount=int(escrow.get("totalFundedAmount")),
307-
created_at=int(escrow.get("createdAt")),
312+
total_funded_amount=escrow.get("totalFundedAmount"),
313+
created_at=escrow.get("createdAt"),
308314
final_results_url=escrow.get("finalResultsUrl"),
309315
final_results_hash=escrow.get("finalResultsHash"),
310316
intermediate_results_url=escrow.get("intermediateResultsUrl"),
@@ -314,21 +320,9 @@ def get_escrows(
314320
recording_oracle=escrow.get("recordingOracle"),
315321
reputation_oracle=escrow.get("reputationOracle"),
316322
exchange_oracle=escrow.get("exchangeOracle"),
317-
recording_oracle_fee=(
318-
int(escrow.get("recordingOracleFee"))
319-
if escrow.get("recordingOracleFee")
320-
else None
321-
),
322-
reputation_oracle_fee=(
323-
int(escrow.get("reputationOracleFee"))
324-
if escrow.get("reputationOracleFee")
325-
else None
326-
),
327-
exchange_oracle_fee=(
328-
int(escrow.get("exchangeOracleFee"))
329-
if escrow.get("exchangeOracleFee")
330-
else None
331-
),
323+
recording_oracle_fee=escrow.get("recordingOracleFee"),
324+
reputation_oracle_fee=escrow.get("reputationOracleFee"),
325+
exchange_oracle_fee=escrow.get("exchangeOracleFee"),
332326
)
333327
for escrow in escrows_raw
334328
]
@@ -395,16 +389,16 @@ def get_escrow(
395389
chain_id=chain_id,
396390
id=escrow.get("id"),
397391
address=escrow.get("address"),
398-
amount_paid=int(escrow.get("amountPaid")),
399-
balance=int(escrow.get("balance")),
400-
count=int(escrow.get("count")),
392+
amount_paid=escrow.get("amountPaid"),
393+
balance=escrow.get("balance"),
394+
count=escrow.get("count"),
401395
factory_address=escrow.get("factoryAddress"),
402396
launcher=escrow.get("launcher"),
403397
job_requester_id=escrow.get("jobRequesterId"),
404398
status=escrow.get("status"),
405399
token=escrow.get("token"),
406-
total_funded_amount=int(escrow.get("totalFundedAmount")),
407-
created_at=int(escrow.get("createdAt")),
400+
total_funded_amount=escrow.get("totalFundedAmount"),
401+
created_at=escrow.get("createdAt"),
408402
final_results_url=escrow.get("finalResultsUrl"),
409403
final_results_hash=escrow.get("finalResultsHash"),
410404
intermediate_results_url=escrow.get("intermediateResultsUrl"),
@@ -414,21 +408,9 @@ def get_escrow(
414408
recording_oracle=escrow.get("recordingOracle"),
415409
reputation_oracle=escrow.get("reputationOracle"),
416410
exchange_oracle=escrow.get("exchangeOracle"),
417-
recording_oracle_fee=(
418-
int(escrow.get("recordingOracleFee"))
419-
if escrow.get("recordingOracleFee")
420-
else None
421-
),
422-
reputation_oracle_fee=(
423-
int(escrow.get("reputationOracleFee"))
424-
if escrow.get("reputationOracleFee")
425-
else None
426-
),
427-
exchange_oracle_fee=(
428-
int(escrow.get("exchangeOracleFee"))
429-
if escrow.get("exchangeOracleFee")
430-
else None
431-
),
411+
recording_oracle_fee=escrow.get("recordingOracleFee"),
412+
reputation_oracle_fee=escrow.get("reputationOracleFee"),
413+
exchange_oracle_fee=escrow.get("exchangeOracleFee"),
432414
)
433415

434416
@staticmethod

0 commit comments

Comments
 (0)