Skip to content

Commit

Permalink
feat: show full createCommunity contract call info
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Feb 6, 2025
1 parent 621f082 commit 34ed221
Showing 1 changed file with 32 additions and 7 deletions.
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

0 comments on commit 34ed221

Please sign in to comment.