@@ -98,6 +98,7 @@ 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 [ ] = [ ] ;
@@ -124,6 +125,13 @@ export class Utils implements BaseUtils {
124125 ) {
125126 preApprovalNode = fields ;
126127 }
128+ if (
129+ template ?. entityName === 'TransferPreapproval' &&
130+ ! tokenPreApprovalNode . length &&
131+ txType === TransactionType . OneStepPreApproval
132+ ) {
133+ tokenPreApprovalNode = fields ;
134+ }
127135 if (
128136 template ?. entityName === 'Amulet' &&
129137 ! transferAcceptRejectNode . length &&
@@ -182,6 +190,27 @@ export class Utils implements BaseUtils {
182190 const providerData = getField ( preApprovalNode , 'provider' ) ;
183191 if ( providerData ?. oneofKind === 'party' ) sender = providerData . party ?? '' ;
184192 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+ }
185214 } else if ( transferNode . length ) {
186215 const transferField = transferNode . find ( ( f ) => f . label === 'transfer' ) ;
187216 const transferSum = transferField ?. value ?. sum ;
0 commit comments