diff --git a/src/protocols/aeternity/helpers/transactionTokenInfoResolvers.ts b/src/protocols/aeternity/helpers/transactionTokenInfoResolvers.ts index e6daedebb..6a4f516c7 100644 --- a/src/protocols/aeternity/helpers/transactionTokenInfoResolvers.ts +++ b/src/protocols/aeternity/helpers/transactionTokenInfoResolvers.ts @@ -364,18 +364,14 @@ const withdraw: TransactionResolver = (transaction, tokens = null) => ({ * Token Sale Buy */ const buy: TransactionResolver = (transaction, tokens = null, tokenAddressMapper = undefined) => { - const isConfirm = !transaction.tx.return; - const tokenAddress: string = isConfirm && tokenAddressMapper - ? tokenAddressMapper(transaction.tx.contractId) - : transaction.tx.log?.slice(-1)[0]?.address; + const tokenAddress: string | undefined = tokenAddressMapper?.(transaction.tx.contractId); const [amount] = transaction.tx.arguments!; const token = { amount: amount?.value, ...defaultToken, - symbol: tokens?.[tokenAddress]?.symbol, - contractId: tokenAddress, - ...tokens?.[tokenAddress], + symbol: tokenAddress && tokens?.[tokenAddress]?.symbol, + ...(tokenAddress ? tokens?.[tokenAddress] : {}), isReceived: true, }; const aeToken = { @@ -396,17 +392,15 @@ const buy: TransactionResolver = (transaction, tokens = null, tokenAddressMapper */ const sell: TransactionResolver = (transaction, tokens = null, tokenAddressMapper = undefined) => { const isConfirm = !transaction.tx.return; - const tokenAddress: string = isConfirm && tokenAddressMapper - ? tokenAddressMapper(transaction.tx.contractId) - : transaction.tx.log?.slice(-1)[0]?.address; + const tokenAddress: string | undefined = tokenAddressMapper?.(transaction.tx.contractId); const amount = isConfirm ? transaction.tx.arguments?.[0]?.value : transaction.tx.arguments?.[0]!; const aeAmount = isConfirm ? transaction.tx.arguments?.[1]?.value : transaction.tx.return?.value; const token = { amount: amount?.value, ...defaultToken, - symbol: tokens?.[tokenAddress]?.symbol, - ...tokens?.[tokenAddress], + symbol: tokenAddress && tokens?.[tokenAddress]?.symbol, + ...(tokenAddress ? tokens?.[tokenAddress] : {}), isReceived: false, }; const aeToken = {