diff --git a/src/core/types/transactions.ts b/src/core/types/transactions.ts index 952554ceef..02139e55d0 100644 --- a/src/core/types/transactions.ts +++ b/src/core/types/transactions.ts @@ -199,6 +199,7 @@ export type TransactionApiResponse = { }; block_confirmations?: number; // also only available on the tx by hash endpoint meta: { + approval_to?: Address; contract_name?: string; contract_icon_url?: string; type?: TransactionType; diff --git a/src/core/utils/transactions.ts b/src/core/utils/transactions.ts index 9e77b688e8..88af384509 100644 --- a/src/core/utils/transactions.ts +++ b/src/core/utils/transactions.ts @@ -173,15 +173,18 @@ const getAssetFromChanges = ( return changes[0]?.asset; }; -const getAddressToFromChanges = ( +const getAddressTo = ( + meta: PaginatedTransactionsApiResponse['meta'], changes: { direction: TransactionDirection; asset: ParsedUserAsset; address_to: Address; }[], - type: TransactionType, ) => { - if (type === 'sale') + if (meta.type === 'approve') { + return meta?.approval_to; + } + if (meta.type === 'sale') return changes?.find((c) => c?.direction === 'out')?.address_to; return changes[0]?.address_to; }; @@ -266,9 +269,7 @@ export function parseTransaction({ ? parseAsset({ asset: meta.asset, currency }) : getAssetFromChanges(changes, type); - const addressTo = asset - ? getAddressToFromChanges(changes, type) - : tx.address_to; + const addressTo = asset ? getAddressTo(meta, changes) : tx.address_to; const direction = tx.direction || getDirection(type); @@ -426,9 +427,7 @@ export async function getNextNonce({ const { getNonce } = nonceStore.getState(); const localNonceData = getNonce({ address, chainId }); const localNonce = localNonceData?.currentNonce || 0; - console.log('- getNextNonce'); const provider = getProvider({ chainId }); - console.log('- getNextNonce', provider); const txCountIncludingPending = await provider.getTransactionCount( address, 'pending',