Skip to content

Commit

Permalink
fix: approve tx to (#1573)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Sinclair <[email protected]>
  • Loading branch information
estebanmino and DanielSinclair authored Jun 17, 2024
1 parent fd60ceb commit 87cac2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/core/types/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 7 additions & 8 deletions src/core/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 87cac2e

Please sign in to comment.