Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
mwamedacen committed Sep 12, 2023
1 parent e2264c2 commit 11f151d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
41 changes: 23 additions & 18 deletions scripts/gas-refund-program/computeMerkleTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export async function getRefundableTransactionData(
}

export async function computeAndStoreMerkleTree(epoch: number) {
debugger;
const userRewardsOnStakingChains = await computeStakingChainsRefundedAmounts(
epoch,
);
Expand All @@ -98,8 +99,10 @@ export async function computeAndStoreMerkleTree(epoch: number) {
)
.flat()
.filter(entry => !entry.amount.eq(0));
debugger

const userRewards = composeRefundWithPIP38Refunds(epoch, _userRewards);
debugger

const userGRPChainsBreakDowns = userRewards.reduce<{
[stakeChainId: number]: AddressRewardsMapping;
Expand All @@ -110,6 +113,7 @@ export async function computeAndStoreMerkleTree(epoch: number) {
return acc;
}, {});


const merkleTreeData = await computeMerkleData({ userRewards, epoch });

return Promise.all(
Expand Down Expand Up @@ -271,29 +275,30 @@ async function startComputingMerkleTreesAllChains() {
await Database.connectAndSync();
await loadEpochMetaData();

const latestEpochRefunded = await fetchLastEpochRefunded(skipCheck);
let startEpoch = latestEpochRefunded
? latestEpochRefunded + 1
: GasRefundGenesisEpoch;
// const latestEpochRefunded = await fetchLastEpochRefunded(skipCheck);
// let startEpoch = latestEpochRefunded
// ? latestEpochRefunded + 1
// : GasRefundGenesisEpoch;

assert(
startEpoch >= GasRefundGenesisEpoch,
'cannot compute grp merkle data for epoch < genesis_epoch',
);
// assert(
// startEpoch >= GasRefundGenesisEpoch,
// 'cannot compute grp merkle data for epoch < genesis_epoch',
// );

const currentEpoch = getCurrentEpoch();
// const currentEpoch = getCurrentEpoch();

for (let epoch = startEpoch; epoch <= currentEpoch; epoch++) {
const { isEpochEnded } = await resolveEpochCalcTimeInterval(epoch);
// for (let epoch = startEpoch; epoch <= currentEpoch; epoch++) {
// const { isEpochEnded } = await resolveEpochCalcTimeInterval(epoch);

if (!skipCheck && !isEpochEnded) {
return logger.warn(
`Epoch ${epoch} has not ended or full onchain data not available yet`,
);
}
// if (!skipCheck && !isEpochEnded) {
// return logger.warn(
// `Epoch ${epoch} has not ended or full onchain data not available yet`,
// );
// }

await computeAndStoreMerkleTree(epoch);
}
// await computeAndStoreMerkleTree(epoch);
// }
await computeAndStoreMerkleTree(38);
}

startComputingMerkleTreesAllChains()
Expand Down
2 changes: 0 additions & 2 deletions src/lib/gas-refund/gas-refund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
CHAIN_ID_POLYGON,
} from '../constants';
import { isTruthy } from '../utils';
import { ChainBalanceMapping } from '../../types';
import { AddressRewardsMapping } from '../../../scripts/gas-refund-program/types';

export const isMainnetStaking = true; // TODO FIXME move to env var

Expand Down

0 comments on commit 11f151d

Please sign in to comment.