diff --git a/packages/chain-adapters/src/tron/TronChainAdapter.ts b/packages/chain-adapters/src/tron/TronChainAdapter.ts index 9ebb337341a..8790d6dd92f 100644 --- a/packages/chain-adapters/src/tron/TronChainAdapter.ts +++ b/packages/chain-adapters/src/tron/TronChainAdapter.ts @@ -605,8 +605,10 @@ export class ChainAdapter implements IChainAdapter { const parsedTx = this.parse(tx, pubkey) + const txInitiator = tx.raw_data?.contract?.[0]?.parameter?.value?.owner_address + const trc20Transfers = this.parseTRC20Transfers(tx, pubkey) - const internalTrxTransfers = this.parseInternalTrxTransfers(tx, pubkey) + const internalTrxTransfers = this.parseInternalTrxTransfers(tx, pubkey, txInitiator) return { ...parsedTx, @@ -695,6 +697,7 @@ export class ChainAdapter implements IChainAdapter { private parseInternalTrxTransfers( tx: unchained.tron.TronTx, pubkey: string, + txInitiator?: string, ): { assetId: AssetId from: string[] @@ -733,12 +736,11 @@ export class ChainAdapter implements IChainAdapter { const value = String(callInfo.callValue) - const isSend = caller_address === pubkey - const isReceive = transferTo_address === pubkey - - if (!isSend && !isReceive) continue + const isDirectSend = caller_address === pubkey + const isDirectReceive = transferTo_address === pubkey + const isInitiatedByUser = txInitiator === pubkey && caller_address !== pubkey - if (isSend) { + if (isDirectSend) { transfers.push({ assetId: this.assetId, from: [caller_address], @@ -746,9 +748,17 @@ export class ChainAdapter implements IChainAdapter { type: TransferType.Send, value, }) + } else if (isInitiatedByUser) { + transfers.push({ + assetId: this.assetId, + from: [txInitiator], + to: [transferTo_address], + type: TransferType.Send, + value, + }) } - if (isReceive) { + if (isDirectReceive) { transfers.push({ assetId: this.assetId, from: [caller_address],