@@ -60,12 +60,12 @@ import {
6060 IStatusEventFilter ,
6161} from './interfaces' ;
6262import {
63+ CancellationRefund ,
6364 EscrowStatus ,
6465 EscrowWithdraw ,
6566 NetworkData ,
66- TransactionLikeWithNonce ,
6767 Payout ,
68- CancellationRefund ,
68+ TransactionLikeWithNonce ,
6969} from './types' ;
7070import {
7171 getSubgraphUrl ,
@@ -535,7 +535,7 @@ export class EscrowClient extends BaseEthersClient {
535535 const escrowContract = this . getEscrowContract ( escrowAddress ) ;
536536
537537 const hasFundsToReserveParam = typeof a === 'bigint' ;
538- const fundsToReserve = hasFundsToReserveParam ? ( a as bigint ) : undefined ;
538+ const fundsToReserve = hasFundsToReserveParam ? ( a as bigint ) : null ;
539539 const txOptions = ( hasFundsToReserveParam ? b : a ) || { } ;
540540 // When fundsToReserve is provided and is 0, allow empty URL.
541541 // In this situation not solutions might have been provided so the escrow can be straight cancelled.
@@ -557,7 +557,7 @@ export class EscrowClient extends BaseEthersClient {
557557 }
558558
559559 try {
560- if ( fundsToReserve !== undefined ) {
560+ if ( fundsToReserve !== null ) {
561561 await (
562562 await escrowContract [ 'storeResults(string,string,uint256)' ] (
563563 url ,
@@ -1789,24 +1789,24 @@ export class EscrowUtils {
17891789 * balance: bigint;
17901790 * count: bigint;
17911791 * factoryAddress: string;
1792- * finalResultsUrl? : string;
1793- * finalResultsHash? : string;
1794- * intermediateResultsUrl? : string;
1795- * intermediateResultsHash? : string;
1792+ * finalResultsUrl: string | null ;
1793+ * finalResultsHash: string | null ;
1794+ * intermediateResultsUrl: string | null ;
1795+ * intermediateResultsHash: string | null ;
17961796 * launcher: string;
1797- * jobRequesterId? : string;
1798- * manifestHash? : string;
1799- * manifest? : string;
1800- * recordingOracle? : string;
1801- * reputationOracle? : string;
1802- * exchangeOracle? : string;
1803- * recordingOracleFee?: bigint ;
1804- * reputationOracleFee?: bigint ;
1805- * exchangeOracleFee?: bigint ;
1797+ * jobRequesterId: string | null ;
1798+ * manifestHash: string | null ;
1799+ * manifest: string | null ;
1800+ * recordingOracle: string | null ;
1801+ * reputationOracle: string | null ;
1802+ * exchangeOracle: string | null ;
1803+ * recordingOracleFee: number | null ;
1804+ * reputationOracleFee: number | null ;
1805+ * exchangeOracleFee: number | null ;
18061806 * status: string;
18071807 * token: string;
18081808 * totalFundedAmount: bigint;
1809- * createdAt: bigint ;
1809+ * createdAt: number ;
18101810 * chainId: number;
18111811 * };
18121812 * ```
@@ -1879,24 +1879,9 @@ export class EscrowUtils {
18791879 skip : skip ,
18801880 }
18811881 ) ;
1882- const mapped : IEscrow [ ] = ( escrows || [ ] ) . map ( ( e ) => ( {
1883- ...e ,
1884- amountPaid : BigInt ( e . amountPaid || 0 ) ,
1885- balance : BigInt ( e . balance || 0 ) ,
1886- count : BigInt ( e . count || 0 ) ,
1887- recordingOracleFee : e . recordingOracleFee
1888- ? BigInt ( e . recordingOracleFee )
1889- : undefined ,
1890- reputationOracleFee : e . reputationOracleFee
1891- ? BigInt ( e . reputationOracleFee )
1892- : undefined ,
1893- exchangeOracleFee : e . exchangeOracleFee
1894- ? BigInt ( e . exchangeOracleFee )
1895- : undefined ,
1896- totalFundedAmount : BigInt ( e . totalFundedAmount || 0 ) ,
1897- createdAt : BigInt ( e . createdAt || 0 ) ,
1898- chainId : networkData . chainId ,
1899- } ) ) ;
1882+ const mapped : IEscrow [ ] = ( escrows || [ ] ) . map ( ( e ) =>
1883+ mapEscrow ( e , networkData . chainId )
1884+ ) ;
19001885
19011886 if ( ! escrows ) {
19021887 return [ ] ;
@@ -1933,24 +1918,24 @@ export class EscrowUtils {
19331918 * balance: bigint;
19341919 * count: bigint;
19351920 * factoryAddress: string;
1936- * finalResultsUrl? : string;
1937- * finalResultsHash? : string;
1938- * intermediateResultsUrl? : string;
1939- * intermediateResultsHash? : string;
1921+ * finalResultsUrl: string | null ;
1922+ * finalResultsHash: string | null ;
1923+ * intermediateResultsUrl: string | null ;
1924+ * intermediateResultsHash: string | null ;
19401925 * launcher: string;
1941- * jobRequesterId? : string;
1942- * manifestHash? : string;
1943- * manifest? : string;
1944- * recordingOracle? : string;
1945- * reputationOracle? : string;
1946- * exchangeOracle? : string;
1947- * recordingOracleFee?: bigint ;
1948- * reputationOracleFee?: bigint ;
1949- * exchangeOracleFee?: bigint ;
1926+ * jobRequesterId: string | null ;
1927+ * manifestHash: string | null ;
1928+ * manifest: string | null ;
1929+ * recordingOracle: string | null ;
1930+ * reputationOracle: string | null ;
1931+ * exchangeOracle: string | null ;
1932+ * recordingOracleFee: number | null ;
1933+ * reputationOracleFee: number | null ;
1934+ * exchangeOracleFee: number | null ;
19501935 * status: string;
19511936 * token: string;
19521937 * totalFundedAmount: bigint;
1953- * createdAt: bigint ;
1938+ * createdAt: number ;
19541939 * chainId: number;
19551940 * };
19561941 * ```
@@ -1989,24 +1974,7 @@ export class EscrowUtils {
19891974 ) ;
19901975 if ( ! escrow ) return null ;
19911976
1992- return {
1993- ...escrow ,
1994- amountPaid : BigInt ( escrow . amountPaid || 0 ) ,
1995- balance : BigInt ( escrow . balance || 0 ) ,
1996- count : BigInt ( escrow . count || 0 ) ,
1997- recordingOracleFee : escrow . recordingOracleFee
1998- ? BigInt ( escrow . recordingOracleFee )
1999- : undefined ,
2000- reputationOracleFee : escrow . reputationOracleFee
2001- ? BigInt ( escrow . reputationOracleFee )
2002- : undefined ,
2003- exchangeOracleFee : escrow . exchangeOracleFee
2004- ? BigInt ( escrow . exchangeOracleFee )
2005- : undefined ,
2006- totalFundedAmount : BigInt ( escrow . totalFundedAmount || 0 ) ,
2007- createdAt : BigInt ( escrow . createdAt || 0 ) ,
2008- chainId : networkData . chainId ,
2009- } ;
1977+ return mapEscrow ( escrow , networkData . chainId ) ;
20101978 }
20111979
20121980 /**
@@ -2344,3 +2312,37 @@ export class EscrowUtils {
23442312 return cancellationRefundEvents ?. [ 0 ] || null ;
23452313 }
23462314}
2315+
2316+ function mapEscrow ( e : EscrowData , chainId : ChainId | number ) : IEscrow {
2317+ return {
2318+ id : e . id ,
2319+ address : e . address ,
2320+ amountPaid : BigInt ( e . amountPaid || 0 ) ,
2321+ balance : BigInt ( e . balance || 0 ) ,
2322+ count : BigInt ( e . count || 0 ) ,
2323+ factoryAddress : e . factoryAddress ,
2324+ finalResultsUrl : e . finalResultsUrl ,
2325+ finalResultsHash : e . finalResultsHash ,
2326+ intermediateResultsUrl : e . intermediateResultsUrl ,
2327+ intermediateResultsHash : e . intermediateResultsHash ,
2328+ launcher : e . launcher ,
2329+ jobRequesterId : e . jobRequesterId ,
2330+ manifestHash : e . manifestHash ,
2331+ manifest : e . manifest ,
2332+ recordingOracle : e . recordingOracle ,
2333+ reputationOracle : e . reputationOracle ,
2334+ exchangeOracle : e . exchangeOracle ,
2335+ recordingOracleFee : e . recordingOracleFee
2336+ ? Number ( e . recordingOracleFee )
2337+ : null ,
2338+ reputationOracleFee : e . reputationOracleFee
2339+ ? Number ( e . reputationOracleFee )
2340+ : null ,
2341+ exchangeOracleFee : e . exchangeOracleFee ? Number ( e . exchangeOracleFee ) : null ,
2342+ status : e . status ,
2343+ token : e . token ,
2344+ totalFundedAmount : BigInt ( e . totalFundedAmount || 0 ) ,
2345+ createdAt : Number ( e . createdAt || 0 ) * 1000 ,
2346+ chainId : Number ( chainId ) ,
2347+ } ;
2348+ }
0 commit comments