Skip to content

Commit 986dfb0

Browse files
committed
Fixed issues due to new WASM version.
1 parent e37b5df commit 986dfb0

6 files changed

+40
-34
lines changed

package-lock.json

+14-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"dependencies": {
1313
"@graphprotocol/graph-cli": "0.21.0",
14-
"@graphprotocol/graph-ts": "0.20.0"
14+
"@graphprotocol/graph-ts": "^0.22.0"
1515
}
1616
}

schema.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type RocketPoolProtocol @entity {
44
id: ID!
55

66
# All stakers (addresses holding rETH) associated with the RocketPool protocol.
7-
stakers: [Staker]!
7+
stakers: [Staker!]!
88

99
# Last known staker network balance checkpoint.
1010
lastNetworkStakerBalanceCheckPoint: NetworkStakerBalanceCheckpoint

src/entityutilities.ts

+19-13
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ class RocketEntityUtilities {
2121
* Extracts the ID that is commonly used to identify an entity based on the given event.
2222
*/
2323
public extractIdForEntity(event: ethereum.Event): string {
24-
return !!event && !!event.transaction && !!event.logIndex
25-
? event.transaction.hash.toHex() + '-' + event.logIndex.toString()
26-
: null
24+
return event.transaction.hash.toHex() + '-' + event.logIndex.toString();
2725
}
2826

2927
/**
3028
* Attempts to create a new Staker.
3129
*/
3230
public extractStakerId(address: Address): string {
33-
return !!address ? address.toHexString() : null
31+
return address.toHexString();
3432
}
3533

3634
/**
@@ -62,15 +60,13 @@ class RocketEntityUtilities {
6260
blockNumber: BigInt,
6361
blockTimeStamp: BigInt,
6462
): TransactionStakers {
65-
let transactionStakers = new TransactionStakers()
66-
6763
/*
6864
* Load or attempt to create the (new) staker from whom the rETH is being transferred.
6965
*/
7066
let fromId = this.extractStakerId(from)
71-
transactionStakers.fromStaker = <Staker>Staker.load(fromId)
72-
if (transactionStakers.fromStaker === null) {
73-
transactionStakers.fromStaker = <Staker>(
67+
let fromStaker : Staker | null = <Staker | null>Staker.load(fromId);
68+
if (fromStaker === null) {
69+
fromStaker = <Staker>(
7470
rocketPoolEntityFactory.createStaker(
7571
fromId,
7672
blockNumber,
@@ -83,14 +79,14 @@ class RocketEntityUtilities {
8379
* Load or attempt to create the (new) staker to whom the rETH is being transferred.
8480
*/
8581
let toId = this.extractStakerId(to)
86-
transactionStakers.toStaker = <Staker>Staker.load(toId)
87-
if (transactionStakers.toStaker === null) {
88-
transactionStakers.toStaker = <Staker>(
82+
let toStaker: Staker | null = <Staker | null>Staker.load(toId);
83+
if (toStaker === null) {
84+
toStaker = <Staker>(
8985
rocketPoolEntityFactory.createStaker(toId, blockNumber, blockTimeStamp)
9086
)
9187
}
9288

93-
return transactionStakers
89+
return new TransactionStakers(<Staker>fromStaker, <Staker>toStaker);
9490
}
9591

9692
/**
@@ -188,11 +184,21 @@ class RocketEntityUtilities {
188184
export class TransactionStakers {
189185
fromStaker: Staker
190186
toStaker: Staker
187+
188+
constructor(from: Staker, to: Staker) {
189+
this.fromStaker = from;
190+
this.toStaker = to;
191+
}
191192
}
192193

193194
export class NetworkStakerRewardCheckpointSummary {
194195
totalStakerETHRewardsSincePreviousCheckpoint: BigInt
195196
totalStakerETHRewardsUpToThisCheckpoint: BigInt
197+
198+
constructor(totalStakerETHRewardsSincePreviousCheckpoint: BigInt, totalStakerETHRewardsUpToThisCheckpoint: BigInt) {
199+
this.totalStakerETHRewardsSincePreviousCheckpoint = totalStakerETHRewardsSincePreviousCheckpoint;
200+
this.totalStakerETHRewardsUpToThisCheckpoint = totalStakerETHRewardsUpToThisCheckpoint;
201+
}
196202
}
197203

198204
export let rocketEntityUtilities = new RocketEntityUtilities()

src/mappings/rocketNetworkBalancesMapping.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ export function handleBalancesUpdated(event: BalancesUpdated): void {
5959
// Retrieve exchange rate.
6060
let previousNetworkBalanceCheckpointId = protocol.lastNetworkStakerBalanceCheckPoint;
6161
let previousNetworkBalanceCheckpointExchangeRate = BigInt.fromI32(1);
62-
let previousNetworkBalanceCheckpoint = NetworkStakerBalanceCheckpoint.load(previousNetworkBalanceCheckpointId);
62+
let previousNetworkBalanceCheckpoint = NetworkStakerBalanceCheckpoint.load(<string>previousNetworkBalanceCheckpointId);
6363
if(previousNetworkBalanceCheckpoint !== null) {
6464
previousNetworkBalanceCheckpointExchangeRate = previousNetworkBalanceCheckpoint.rETHExchangeRate;
6565
}
6666

6767
// We will use this to store the reward summary data for all staker checkpoints.
68-
let summary = new NetworkStakerRewardCheckpointSummary();
69-
summary.totalStakerETHRewardsSincePreviousCheckpoint = BigInt.fromI32(0)
70-
summary.totalStakerETHRewardsUpToThisCheckpoint = BigInt.fromI32(0)
68+
let summary = new NetworkStakerRewardCheckpointSummary(BigInt.fromI32(0), BigInt.fromI32(0));
7169

7270
// Handle the staker impact.
7371
generateStakerBalanceCheckpoints(
@@ -163,7 +161,7 @@ function generateStakerBalanceCheckpoints(
163161
// If we had a previous staker balance checkpoint, then use the balances from that link.
164162
if (staker.lastBalanceCheckpoint !== null) {
165163
let previousStakerBalanceCheckpoint = StakerBalanceCheckpoint.load(
166-
staker.lastBalanceCheckpoint,
164+
<string>staker.lastBalanceCheckpoint,
167165
)
168166
if (previousStakerBalanceCheckpoint !== null) {
169167
previousRETHBalance = previousStakerBalanceCheckpoint.rETHBalance

subgraph.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dataSources:
1111
startBlock: 5200000
1212
mapping:
1313
kind: ethereum/events
14-
apiVersion: 0.0.4
14+
apiVersion: 0.0.5
1515
language: wasm/assemblyscript
1616
entities:
1717
- Staker
@@ -33,7 +33,7 @@ dataSources:
3333
startBlock: 5200000
3434
mapping:
3535
kind: ethereum/events
36-
apiVersion: 0.0.4
36+
apiVersion: 0.0.5
3737
language: wasm/assemblyscript
3838
entities:
3939
- Staker

0 commit comments

Comments
 (0)