Skip to content

Commit

Permalink
Merge pull request #3488 from superhero-com/feature/adjust-transactio…
Browse files Browse the repository at this point in the history
…n-list

Adjust transaction list
  • Loading branch information
CedrikNikita authored Feb 6, 2025
2 parents 0d91c01 + 34ed221 commit c8fbef8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/popup/components/Tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default defineComponent({
* Array of tokens that is returned by the transactionTokenInfoResolvers
*/
tokens: { type: Array as PropType<ITokenResolved[]>, required: true },
symbolLength: { type: Number, default: 11 },
symbolLength: { type: Number, default: 10 },
doubleSymbolLength: { type: Number, default: 5 },
/**
* TODO if protocol is not set, assume AE, but this should be set correctly
Expand Down
2 changes: 2 additions & 0 deletions src/popup/components/TransactionAssetRows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export default defineComponent({
.amount {
@extend %face-sans-18-regular;
font-size: var(--font-size);
}
}
}
Expand Down
39 changes: 32 additions & 7 deletions src/protocols/aeternity/helpers/transactionTokenInfoResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,40 @@ const sell: TransactionResolver = (transaction, tokens = null, tokenAddressMappe
const createCommunity: TransactionResolver = (
transaction,
tokens = null,
tokenAddressMapper = undefined,
) => {
const isConfirm = !transaction.tx.return;
const token = {
amount: transaction.tx.arguments?.[2]?.value,
const { internalEvents } = transaction.tx;
const additionalTokenEvents = internalEvents?.filter(({ type, payload: { recipientId } }) => (
ACTIVITIES_TYPES.aex9TransferEvent === type
&& transaction.tx.callerId === recipientId
));

let receivedTokens = additionalTokenEvents?.map(({
payload: {
tokenSymbol, amount, contractId,
},
}) => ({
amount,
...defaultToken,
symbol: transaction.tx.arguments?.[1]?.value,
...(isConfirm ? {} : tokens?.[transaction.tx.log?.[2]?.address]),
symbol: tokenSymbol,
...(tokens?.[contractId] || {}),
isReceived: true,
};
}));

const tokenAddress: string | undefined = tokenAddressMapper?.(
transaction.tx.return?.value[1]?.value,
);

if (!receivedTokens?.length) {
receivedTokens = [{
amount: transaction.tx.arguments?.[2]?.value,
...defaultToken,
symbol: transaction.tx.arguments?.[1]?.value,
...(tokenAddress ? tokens?.[tokenAddress] : {}),
isReceived: true,
}];
}

const aeToken = {
...defaultToken,
assetType: ASSET_TYPES.coin,
Expand All @@ -456,7 +481,7 @@ const createCommunity: TransactionResolver = (
isReceived: false,
};
return {
tokens: [token, aeToken],
tokens: [...(receivedTokens || []), aeToken],
};
};

Expand Down
7 changes: 6 additions & 1 deletion src/protocols/aeternity/views/TransactionDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ import {
import {
useAccounts,
useFungibleTokens,
useLatestTransactionList,
useMultisigAccounts,
useTransactionData,
useTransactionList,
Expand Down Expand Up @@ -247,6 +248,7 @@ export default defineComponent({
const { activeAccount, isLocalAccountAddress } = useAccounts();
const { setLoaderVisible } = useUi();
const { getTxAmountTotal, tokenBalances } = useFungibleTokens();
const { allLatestTransactions } = useLatestTransactionList();
const hash = route.params.hash as string;
const transactionOwner = route.params.transactionOwner as Encoded.AccountAddress;
Expand Down Expand Up @@ -342,7 +344,10 @@ export default defineComponent({
});
onMounted(async () => {
let rawTransaction: ITransaction | undefined = transactionsLoaded.value
let rawTransaction: ITransaction | undefined = [
...transactionsLoaded.value,
...allLatestTransactions.value,
]
.find((tx) => tx.hash === hash) as ITransaction;
// Claim transactions have missing data that needs to be fetched from the middleware
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function calculateFontSize(amountValue: BigNumber | number | string) {
return '16px';
}
if (amountLength <= 14) {
return '14px';
return '13px';
}
return '12px';
}
Expand Down

0 comments on commit c8fbef8

Please sign in to comment.