@@ -341,12 +341,12 @@ export class Transaction extends BaseTransaction {
341341 if ( action . functionCall . methodName === 'ft_transfer' ) {
342342 const parsedArgs = JSON . parse ( Buffer . from ( action . functionCall . args ) . toString ( ) ) ;
343343 inputs . push ( {
344- address : parsedArgs . receiver_id ,
344+ address : this . _nearTransaction . signerId ,
345345 value : parsedArgs . amount ,
346346 coin : this . _coinConfig . name ,
347347 } ) ;
348348 outputs . push ( {
349- address : this . _nearTransaction . signerId ,
349+ address : parsedArgs . receiver_id ,
350350 value : parsedArgs . amount ,
351351 coin : this . _coinConfig . name ,
352352 } ) ;
@@ -355,15 +355,15 @@ export class Transaction extends BaseTransaction {
355355 const parsedArgs = JSON . parse ( Buffer . from ( action . functionCall . args ) . toString ( ) ) ;
356356 const receiverId = parsedArgs . account_id ? parsedArgs . account_id : this . _nearTransaction . signerId ;
357357 inputs . push ( {
358- address : receiverId ,
358+ address : this . _nearTransaction . signerId ,
359359 value : action . functionCall . deposit . toString ( ) ,
360360 coin :
361361 this . _coinConfig . network . type === NetworkType . TESTNET
362362 ? `t${ this . _coinConfig . family } `
363363 : this . _coinConfig . family ,
364364 } ) ;
365365 outputs . push ( {
366- address : this . _nearTransaction . signerId ,
366+ address : receiverId ,
367367 value : action . functionCall . deposit . toString ( ) ,
368368 coin :
369369 this . _coinConfig . network . type === NetworkType . TESTNET
@@ -408,15 +408,15 @@ export class Transaction extends BaseTransaction {
408408 const parsedArgs = JSON . parse ( Buffer . from ( action . functionCall . args ) . toString ( ) ) ;
409409 const receiverId = parsedArgs . account_id ? parsedArgs . account_id : this . _nearTransaction . signerId ;
410410 inputs . push ( {
411- address : receiverId ,
411+ address : this . _nearTransaction . signerId ,
412412 value : action . functionCall . deposit . toString ( ) ,
413413 coin :
414414 this . _coinConfig . network . type === NetworkType . TESTNET
415415 ? `t${ this . _coinConfig . family } `
416416 : this . _coinConfig . family ,
417417 } ) ;
418418 outputs . push ( {
419- address : this . _nearTransaction . signerId ,
419+ address : receiverId ,
420420 value : action . functionCall . deposit . toString ( ) ,
421421 coin :
422422 this . _coinConfig . network . type === NetworkType . TESTNET
@@ -522,9 +522,9 @@ export class Transaction extends BaseTransaction {
522522 }
523523 }
524524 }
525- if ( hasFtTransfer && hasStorageDeposit ) {
525+ if ( hasFtTransfer ) {
526526 return totalTokenAmount . toString ( ) ;
527- } else if ( ! hasFtTransfer && hasStorageDeposit ) {
527+ } else if ( hasStorageDeposit ) {
528528 return totalNearDeposit . toString ( ) ;
529529 }
530530 return '' ;
@@ -545,10 +545,17 @@ export class Transaction extends BaseTransaction {
545545 const functionCall = action . functionCall ;
546546 if ( functionCall . methodName === FT_TRANSFER ) {
547547 const amountStr = functionCall . args [ 'amount' ] as string ;
548- outputs . push ( {
549- address : json . receiverId ,
548+ const receiverId = functionCall . args [ 'receiver_id' ] as string ;
549+ // in ft transfer, the outer receiver id will be contract address of the token
550+ const tokenName = utils . findTokenNameFromContractAddress ( json . receiverId ) ;
551+ const output : ITransactionRecipient = {
552+ address : receiverId ,
550553 amount : amountStr ,
551- } ) ;
554+ } ;
555+ if ( tokenName ) {
556+ output . tokenName = tokenName ;
557+ }
558+ outputs . push ( output ) ;
552559 }
553560 }
554561 } ) ;
@@ -573,10 +580,20 @@ export class Transaction extends BaseTransaction {
573580 if ( action . functionCall ) {
574581 const functionCall = action . functionCall ;
575582 if ( functionCall . methodName === STORAGE_DEPOSIT ) {
576- outputs . push ( {
577- address : json . receiverId ,
583+ const receiverId =
584+ functionCall . args && functionCall . args [ 'account_id' ]
585+ ? ( functionCall . args [ 'account_id' ] as string )
586+ : json . signerId ;
587+ // in storage deposit, the outer receiver id will be contract address of the token
588+ const tokenName = utils . findTokenNameFromContractAddress ( json . receiverId ) ;
589+ const output : ITransactionRecipient = {
590+ address : receiverId ,
578591 amount : functionCall . deposit ,
579- } ) ;
592+ } ;
593+ if ( tokenName ) {
594+ output . tokenName = tokenName ;
595+ }
596+ outputs . push ( output ) ;
580597 }
581598 }
582599 } ) ;
0 commit comments