Skip to content

Commit aff3a3e

Browse files
committed
Completed lesson 4.
1 parent fffa2b6 commit aff3a3e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

staking-rewards/project.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ network:
1010
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3'
1111
dataSources:
1212
- kind: substrate/Runtime
13-
startBlock: 7000000
13+
startBlock: 6000000
1414
mapping:
1515
file: ./dist/index.js
1616
handlers:
@@ -24,4 +24,14 @@ dataSources:
2424
filter:
2525
module: staking
2626
method: Rewarded # NOTE: This method was called Reward before ~block 6,700,000
27+
- handler: handleSumReward
28+
kind: substrate/EventHandler
29+
filter:
30+
module: staking
31+
method: Reward # NOTE: This method was called Rewarded after ~block 6,700,000
32+
- handler: handleStakingReward
33+
kind: substrate/EventHandler
34+
filter:
35+
module: staking
36+
method: Reward # NOTE: This method was called Rewarded after ~block 6,700,000
2737

staking-rewards/src/mappings/mappingHandlers.ts

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ function createSumReward(accountId: string): SumReward {
88
return entity;
99
}
1010

11+
export async function handleStakingReward(event: SubstrateEvent): Promise<void> {
12+
await handleStakingRewarded(event);
13+
}
14+
1115
export async function handleStakingRewarded(event: SubstrateEvent): Promise<void> {
1216
const {event: {data: [account, newReward]}} = event;
1317
const entity = new StakingReward(`${event.block.block.header.number}-${event.idx.toString()}`);
@@ -18,6 +22,10 @@ export async function handleStakingRewarded(event: SubstrateEvent): Promise<void
1822
await entity.save();
1923
}
2024

25+
export async function handleSumReward(event: SubstrateEvent): Promise<void> {
26+
await handleSumRewarded(event);
27+
}
28+
2129
export async function handleSumRewarded(event: SubstrateEvent): Promise<void> {
2230
const {event: {data: [account, newReward]}} = event;
2331

0 commit comments

Comments
 (0)