@@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js';
22import crypto from 'crypto' ;
33
44import { BaseUtils , isValidEd25519PublicKey , TransactionType } from '@bitgo/sdk-core' ;
5- import { coins , CantonToken } from '@bitgo/statics' ;
5+ import { CantonToken , coins } from '@bitgo/statics' ;
66
77import { computePreparedTransaction } from '../../resources/hash/hash.js' ;
88import { PreparedTransaction } from '../../resources/proto/preparedTransaction.js' ;
@@ -100,6 +100,7 @@ export class Utils implements BaseUtils {
100100 let preApprovalNode : RecordField [ ] = [ ] ;
101101 let transferNode : RecordField [ ] = [ ] ;
102102 let transferAcceptRejectNode : RecordField [ ] = [ ] ;
103+ let tokenTransferAcceptRejectNode : RecordField [ ] = [ ] ;
103104 const nodes = decodedData . transaction ?. nodes ;
104105
105106 nodes ?. forEach ( ( node ) => {
@@ -128,6 +129,17 @@ export class Utils implements BaseUtils {
128129 ) {
129130 transferAcceptRejectNode = fields ;
130131 }
132+ if (
133+ ( template ?. entityName === 'ExecutedTransfer' || template ?. entityName === 'RejectedTransfer' ) &&
134+ ! tokenTransferAcceptRejectNode . length &&
135+ ( txType === TransactionType . TransferAccept || txType === TransactionType . TransferReject )
136+ ) {
137+ const transferField = fields . find ( ( f ) => f . label === 'transfer' ) ;
138+ const transferSum = transferField ?. value ?. sum ;
139+ if ( transferSum ?. oneofKind === 'record' ) {
140+ tokenTransferAcceptRejectNode = transferSum . record ?. fields ?? [ ] ;
141+ }
142+ }
131143 } ) ;
132144
133145 nodes ?. forEach ( ( node ) => {
@@ -216,6 +228,25 @@ export class Utils implements BaseUtils {
216228 if ( initialAmountData ?. oneofKind === 'numeric' ) amount = initialAmountData . numeric ?? '' ;
217229 }
218230 }
231+ } else if ( tokenTransferAcceptRejectNode . length ) {
232+ const senderData = getField ( tokenTransferAcceptRejectNode , 'sender' ) ;
233+ if ( senderData ?. oneofKind === 'party' ) sender = senderData . party ?? '' ;
234+ const receiverData = getField ( tokenTransferAcceptRejectNode , 'receiver' ) ;
235+ if ( receiverData ?. oneofKind === 'party' ) receiver = receiverData . party ?? '' ;
236+ const amountData = getField ( tokenTransferAcceptRejectNode , 'amount' ) ;
237+ if ( amountData ?. oneofKind === 'numeric' ) amount = amountData . numeric ?? '' ;
238+ const instrumentSum = getField ( tokenTransferAcceptRejectNode , 'instrumentIdentifier' ) ;
239+ if ( instrumentSum ?. oneofKind === 'record' ) {
240+ const instrumentFields = instrumentSum . record ?. fields ?? [ ] ;
241+ const adminData = getField ( instrumentFields , 'source' ) ;
242+ if ( adminData ?. oneofKind === 'party' ) {
243+ instrumentAdmin = adminData . party ?? '' ;
244+ }
245+ const idData = getField ( instrumentFields , 'id' ) ;
246+ if ( idData ?. oneofKind === 'text' ) {
247+ instrumentId = idData . text ?? '' ;
248+ }
249+ }
219250 }
220251 if ( ! sender || ! receiver || ! amount ) {
221252 const missingFields : string [ ] = [ ] ;
0 commit comments