@@ -98,9 +98,12 @@ export class Utils implements BaseUtils {
9898 let instrumentAdmin : string | undefined ;
9999 let token : string | undefined ;
100100 let preApprovalNode : RecordField [ ] = [ ] ;
101+ let tokenPreApprovalNode : RecordField [ ] = [ ] ;
101102 let transferNode : RecordField [ ] = [ ] ;
102103 let transferAcceptRejectNode : RecordField [ ] = [ ] ;
103104 let tokenTransferAcceptRejectNode : RecordField [ ] = [ ] ;
105+ let withdrawnNode : RecordField [ ] = [ ] ;
106+ let tokenWithdrawnNode : RecordField [ ] = [ ] ;
104107 const nodes = decodedData . transaction ?. nodes ;
105108
106109 nodes ?. forEach ( ( node ) => {
@@ -122,6 +125,13 @@ export class Utils implements BaseUtils {
122125 ) {
123126 preApprovalNode = fields ;
124127 }
128+ if (
129+ template ?. entityName === 'TransferPreapproval' &&
130+ ! tokenPreApprovalNode . length &&
131+ txType === TransactionType . OneStepPreApproval
132+ ) {
133+ tokenPreApprovalNode = fields ;
134+ }
125135 if (
126136 template ?. entityName === 'Amulet' &&
127137 ! transferAcceptRejectNode . length &&
@@ -140,6 +150,20 @@ export class Utils implements BaseUtils {
140150 tokenTransferAcceptRejectNode = transferSum . record ?. fields ?? [ ] ;
141151 }
142152 }
153+ if (
154+ template ?. entityName === 'Amulet' &&
155+ ! withdrawnNode . length &&
156+ txType === TransactionType . TransferOfferWithdrawn
157+ ) {
158+ withdrawnNode = fields ;
159+ }
160+ if (
161+ template ?. entityName === 'Holding' &&
162+ ! tokenWithdrawnNode . length &&
163+ txType === TransactionType . TransferOfferWithdrawn
164+ ) {
165+ tokenWithdrawnNode = fields ;
166+ }
143167 } ) ;
144168
145169 nodes ?. forEach ( ( node ) => {
@@ -166,6 +190,27 @@ export class Utils implements BaseUtils {
166190 const providerData = getField ( preApprovalNode , 'provider' ) ;
167191 if ( providerData ?. oneofKind === 'party' ) sender = providerData . party ?? '' ;
168192 amount = '0' ;
193+ } else if ( tokenPreApprovalNode . length ) {
194+ const receiverData = getField ( tokenPreApprovalNode , 'receiver' ) ;
195+ if ( receiverData ?. oneofKind === 'party' ) receiver = receiverData . party ?? '' ;
196+ const operatorData = getField ( tokenPreApprovalNode , 'operator' ) ;
197+ if ( operatorData ?. oneofKind === 'party' ) sender = operatorData . party ?? '' ;
198+ amount = '0' ;
199+ const instrumentAdminData = getField ( tokenPreApprovalNode , 'instrumentAdmin' ) ;
200+ if ( instrumentAdminData ?. oneofKind === 'party' ) instrumentAdmin = instrumentAdminData . party ?? '' ;
201+ const allowancesData = getField ( tokenPreApprovalNode , 'instrumentAllowances' ) ;
202+ if ( allowancesData ?. oneofKind === 'list' ) {
203+ // for the same instrument admin, if multiple tokens are supported then we can enable all of them,
204+ // but we won't be doing that for now
205+ const firstAllowance = allowancesData . list ?. elements ?. [ 0 ] ?. sum ;
206+ if ( firstAllowance ?. oneofKind === 'record' ) {
207+ const allowanceFields = firstAllowance . record ?. fields ?? [ ] ;
208+ const idData = getField ( allowanceFields , 'id' ) ;
209+ if ( idData ?. oneofKind === 'text' ) {
210+ instrumentId = idData . text ?? '' ;
211+ }
212+ }
213+ }
169214 } else if ( transferNode . length ) {
170215 const transferField = transferNode . find ( ( f ) => f . label === 'transfer' ) ;
171216 const transferSum = transferField ?. value ?. sum ;
@@ -247,6 +292,42 @@ export class Utils implements BaseUtils {
247292 instrumentId = idData . text ?? '' ;
248293 }
249294 }
295+ } else if ( withdrawnNode . length ) {
296+ const ownerData = getField ( withdrawnNode , 'owner' ) ;
297+ if ( ownerData ?. oneofKind === 'party' ) {
298+ receiver = ownerData . party ?? '' ;
299+ sender = receiver ;
300+ }
301+ const amountField = getField ( withdrawnNode , 'amount' ) ;
302+ if ( amountField ?. oneofKind === 'record' ) {
303+ const amountFields = amountField . record ?. fields ?? [ ] ;
304+ const initialAmountData = getField ( amountFields , 'initialAmount' ) ;
305+ if ( initialAmountData ?. oneofKind === 'numeric' ) {
306+ amount = initialAmountData . numeric ?? '' ;
307+ }
308+ }
309+ } else if ( tokenWithdrawnNode . length ) {
310+ const ownerData = getField ( tokenWithdrawnNode , 'owner' ) ;
311+ if ( ownerData ?. oneofKind === 'party' ) {
312+ receiver = ownerData . party ?? '' ;
313+ sender = receiver ;
314+ }
315+ const amountData = getField ( tokenWithdrawnNode , 'amount' ) ;
316+ if ( amountData ?. oneofKind === 'numeric' ) {
317+ amount = amountData . numeric ?? '' ;
318+ }
319+ const instrumentData = getField ( tokenWithdrawnNode , 'instrument' ) ;
320+ if ( instrumentData ?. oneofKind === 'record' ) {
321+ const instrumentFields = instrumentData . record ?. fields ?? [ ] ;
322+ const adminData = getField ( instrumentFields , 'source' ) ;
323+ if ( adminData ?. oneofKind === 'party' ) {
324+ instrumentAdmin = adminData . party ?? '' ;
325+ }
326+ const idData = getField ( instrumentFields , 'id' ) ;
327+ if ( idData ?. oneofKind === 'text' ) {
328+ instrumentId = idData . text ?? '' ;
329+ }
330+ }
250331 }
251332 if ( ! sender || ! receiver || ! amount ) {
252333 const missingFields : string [ ] = [ ] ;
0 commit comments