Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
🐛 No transaction fee entries for shared reward entries
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Feb 6, 2024
1 parent 1118863 commit 31e3ab8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion services/export/shared/excelFieldMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const metadataMappings = [
{ header: 'Chain ID', key: 'chainID' },
{ header: 'Chain Name', key: 'chainName' },
{ header: 'Note', key: 'note' },
{ header: 'Opening Balance Amount', key: 'openingBalanceAmount' },
{ header: 'v4 Opening Balance', key: 'openingBalanceAmount' },
{ header: 'Token ID', key: 'tokenID' },
];

Expand Down
6 changes: 5 additions & 1 deletion services/export/shared/helpers/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ const resolveChainIDs = (tx, currentChainID) => {
receivingChainID,
};
}
return {};

return {
sendingChainID: currentChainID,
receivingChainID: currentChainID,
};
};

const getBlocks = async params => requestIndexer('blocks', params);
Expand Down
14 changes: 6 additions & 8 deletions services/export/shared/transactionsExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ const getMessageFeeEntries = async (

const getSharedRewardsAssignedEntries = async (
addressFromParams,
isStaker,
rewardsAssignedEvent,
tx,
block,
Expand All @@ -364,22 +363,23 @@ const getSharedRewardsAssignedEntries = async (
const recipientPublicKey = tx.sender.publicKey;
if (recipientPublicKey) cachePublicKey(recipientPublicKey);

const isStaker = addressFromParams === rewardsAssignedEvent.data.stakerAddress;
entries.push({
date: dateFromTimestamp(block.timestamp),
time: timeFromTimestamp(block.timestamp),
blockHeight: block.height,
transactionID: tx.id,
moduleCommand: tx.moduleCommand,
fee: normalizeTransactionFee(addressFromParams, tx),
txFeeTokenID: await getFeeTokenID(),
moduleCommand: null,
fee: null,
txFeeTokenID: null,
// because amount increases the staker balance and reduces the validator balance
amount: (BigInt(isStaker ? '1' : '-1') * BigInt(rewardsAssignedEvent.data.amount)).toString(),
amountTokenID: await getPosTokenID(),
senderAddress: rewardsAssignedEvent.data.validatorAddress,
senderPublicKey: await getPublicKeyByAddress(rewardsAssignedEvent.data.validatorAddress),
recipientAddress: rewardsAssignedEvent.data.stakerAddress,
recipientPublicKey,
note: 'Shared custodial reward transfer',
note: 'Custodial shared rewards transfer to the staker',
sendingChainID: await getCurrentChainID(),
receivingChainID: await getCurrentChainID(),
});
Expand Down Expand Up @@ -427,7 +427,7 @@ const getBlockRewardEntries = async (
entries.push({
...commonEntryProperties,
amount: sharedReward.toString(),
note: 'Block generation reward (Shared custodial reward locking)',
note: 'Block generation reward (custodial shared rewards locked)',
});
}

Expand Down Expand Up @@ -639,10 +639,8 @@ const getEntriesByChronology = async (params, sortedBlocks, sortedTransactions,

// Shared custodial reward received/sent
if (e.module === MODULE.POS && e.name === EVENT.REWARDS_ASSIGNED) {
const isStaker = addressFromParams === e.data.stakerAddress;
const rewardAssignedEntries = await getSharedRewardsAssignedEntries(
addressFromParams,
isStaker,
e,
tx,
block,
Expand Down

0 comments on commit 31e3ab8

Please sign in to comment.