@@ -32,7 +32,7 @@ class AcpJob {
3232 public phase : AcpJobPhases ,
3333 public context : Record < string , any > ,
3434 public contractAddress : Address ,
35- public netPayableAmount ?: number
35+ public deliverable ?: DeliverablePayload
3636 ) {
3737 const content = this . memos . find (
3838 ( m ) => m . nextPhase === AcpJobPhases . NEGOTIATION
@@ -85,11 +85,6 @@ class AcpJob {
8585 return this . acpContractClient . config . baseFare ;
8686 }
8787
88- public get deliverable ( ) {
89- return this . memos . find ( ( m ) => m . nextPhase === AcpJobPhases . COMPLETED )
90- ?. content ;
91- }
92-
9388 public get rejectionReason ( ) {
9489 const rejectedMemo = this . memos . find (
9590 ( m ) =>
@@ -125,6 +120,35 @@ class AcpJob {
125120 return this . memos [ this . memos . length - 1 ] ;
126121 }
127122
123+ public get netPayableAmount ( ) : number | undefined {
124+ const payableMemo = this . memos . find (
125+ ( m ) =>
126+ m . nextPhase === AcpJobPhases . TRANSACTION &&
127+ m . type === MemoType . PAYABLE_REQUEST &&
128+ m . payableDetails
129+ ) ;
130+
131+ if ( ! payableMemo || ! payableMemo . payableDetails ) {
132+ return undefined ;
133+ }
134+
135+ const payableAmount = Number (
136+ formatUnits (
137+ payableMemo . payableDetails . amount ,
138+ payableMemo . payableDetails . token . toLowerCase ( ) ===
139+ this . baseFare . contractAddress . toLowerCase ( )
140+ ? this . baseFare . decimals
141+ : 18
142+ )
143+ ) ;
144+
145+ if ( this . priceType === PriceType . PERCENTAGE ) {
146+ return payableAmount * ( 1 - this . priceValue ) ;
147+ }
148+
149+ return payableAmount ;
150+ }
151+
128152 async createRequirement ( content : string ) {
129153 const operations : OperationPayload [ ] = [ ] ;
130154
0 commit comments