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

Commit

Permalink
fix : update build-error(yarn polkadot-exec-tsc --build tsconfig.buil…
Browse files Browse the repository at this point in the history
…d.json)
  • Loading branch information
johnnyji-dev committed Jul 22, 2024
1 parent 77c3d69 commit 29a523f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/sdk-core/src/modules/dapp-staking/pending-rewards/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { StorageKey, Struct } from '@polkadot/types';
import { Perbill } from '@polkadot/types/interfaces';
import { ApiPromise, HttpProvider } from '@polkadot/api';
import { EventRecord, Perbill } from '@polkadot/types/interfaces';
import { ApiPromise } from '@polkadot/api';
import { ethers } from 'ethers';
import { Codec } from '@polkadot/types/types';
import { commaStrToBigInt, hasProperty, truncate } from '@astar-network/astar-sdk-core';
import { hasProperty, truncate } from '@astar-network/astar-sdk-core';

export interface RewardDistributionConfig extends Struct {
readonly baseTreasuryPercent: Perbill;
Expand Down Expand Up @@ -271,7 +271,7 @@ export const getClaimedReward = async (
const blockHash = await api.rpc.chain.getBlockHash(height);
const signedBlock = await api.rpc.chain.getBlock(blockHash);
const apiAt = await api.at(signedBlock.block.header.hash);
const allRecords = (await apiAt.query.system.events()).toArray();
const allRecords: any = await apiAt.query.system.events();

// Find the extrinsic index by matching the extrinsic hash
const extrinsicIndex = signedBlock.block.extrinsics.findIndex(
Expand All @@ -283,7 +283,7 @@ export const getClaimedReward = async (
}

// Get events associated with the extrinsic
const extrinsicEvents = allRecords.filter((record) =>
const extrinsicEvents = allRecords.filter((record: EventRecord) =>
record.phase.isApplyExtrinsic &&
record.phase.asApplyExtrinsic.eq(extrinsicIndex)
);
Expand All @@ -294,10 +294,11 @@ export const getClaimedReward = async (
const section = 'dappStaking';
let claimedReward = BigInt('0');

extrinsicEvents.map((e, idx) => {
extrinsicEvents.map((e: EventRecord) => {
if ((e.event?.method === methodRwd || e.event?.method === methodBnsRwd || e.event?.method === methodDappRwd) &&
e.event?.section === section) {
claimedReward += e.event?.data?.amount;
const eData: any = e.event?.data;
claimedReward += eData?.amount;
}
});

Expand All @@ -321,7 +322,7 @@ export const getUsedFee = async (
const blockHash = await api.rpc.chain.getBlockHash(height);
const signedBlock = await api.rpc.chain.getBlock(blockHash);
const apiAt = await api.at(signedBlock.block.header.hash);
const allRecords = (await apiAt.query.system.events()).toArray();
const allRecords: any = await apiAt.query.system.events();

// Find the extrinsic index by matching the extrinsic hash
const extrinsicIndex = signedBlock.block.extrinsics.findIndex(
Expand All @@ -333,7 +334,7 @@ export const getUsedFee = async (
}

// Get events associated with the extrinsic
const extrinsicEvents = allRecords.filter((record) =>
const extrinsicEvents = allRecords.filter((record: EventRecord) =>
record.phase.isApplyExtrinsic &&
record.phase.asApplyExtrinsic.eq(extrinsicIndex)
);
Expand All @@ -343,10 +344,10 @@ export const getUsedFee = async (

let usedFee = BigInt('0');

extrinsicEvents.map((e) => {
if (e.event?.method === method &&
e.event?.section === section) {
usedFee = e.event?.data?.actualFee;
extrinsicEvents.map((e: EventRecord) => {
if (e.event?.method === method && e.event?.section === section) {
const eData: any = e.event?.data;
usedFee += eData?.actualFee;
}
});

Expand Down

0 comments on commit 29a523f

Please sign in to comment.