Skip to content

Commit

Permalink
fix: parse tx to address in activity (#1567)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino authored Jun 8, 2024
1 parent 6fa84d0 commit 9d867ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lavamoat/build-webpack/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,13 @@
"define": true
},
"packages": {
"jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": true,
"webpack>terser-webpack-plugin>@jridgewell/trace-mapping>@jridgewell/resolve-uri": true
"jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator>@jridgewell/trace-mapping>@jridgewell/resolve-uri": true,
"jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": true
}
},
"jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator>@jridgewell/trace-mapping>@jridgewell/resolve-uri": {
"globals": {
"define": true
}
},
"jest>@jest/core>jest-snapshot>@babel/traverse>@babel/generator>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": {
Expand Down
19 changes: 18 additions & 1 deletion src/core/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ const getAssetFromChanges = (
return changes[0]?.asset;
};

const getAddressToFromChanges = (
changes: {
direction: TransactionDirection;
asset: ParsedUserAsset;
address_to: Address;
}[],
type: TransactionType,
) => {
if (type === 'sale')
return changes?.find((c) => c?.direction === 'out')?.address_to;
return changes[0]?.address_to;
};

const getDescription = (
asset: ParsedAsset | undefined,
type: TransactionType,
Expand Down Expand Up @@ -253,6 +266,10 @@ export function parseTransaction({
? parseAsset({ asset: meta.asset, currency })
: getAssetFromChanges(changes, type);

const addressTo = asset
? getAddressToFromChanges(changes, type)
: tx.address_to;

const direction = tx.direction || getDirection(type);

const description = getDescription(asset, type, meta);
Expand Down Expand Up @@ -285,7 +302,7 @@ export function parseTransaction({

return {
from: tx.address_from,
to: tx.address_to,
to: addressTo,
title: i18n.t(`transactions.${type}.${status}`),
description,
hash,
Expand Down

0 comments on commit 9d867ce

Please sign in to comment.