Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions subgraph/core-neo/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ dataSources:
language: wasm/assemblyscript
entities:
- JurorTokensPerCourt
- StakeSet
abis:
- name: SortitionModule
file: ../../contracts/deployments/arbitrum/SortitionModuleNeo.json
Expand Down
1 change: 1 addition & 0 deletions subgraph/core-university/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ dataSources:
language: wasm/assemblyscript
entities:
- JurorTokensPerCourt
- StakeSet
abis:
- name: SortitionModule
file: ../../contracts/deployments/arbitrumSepoliaDevnet/SortitionModuleUniversity.json
Expand Down
11 changes: 11 additions & 0 deletions subgraph/core/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ type ClassicContribution implements Contribution @entity {
rewardWithdrawn: Boolean!
}

type StakeSet @entity {
id: ID! # event.transaction.hash.toHex() + - + event.logIndex.toString()
address: Bytes!
courtID: BigInt!
stake: BigInt!
newTotalStake: BigInt!
blocknumber: BigInt!
timestamp: BigInt!
logIndex: BigInt!
}

type _Schema_
@fulltext(
name: "evidenceSearch"
Expand Down
18 changes: 16 additions & 2 deletions subgraph/core/src/SortitionModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
StakeDelayedAlreadyTransferredWithdrawn,
StakeDelayedNotTransferred,
StakeLocked,
StakeSet,
StakeSet as StakeSetEvent,
} from "../generated/SortitionModule/SortitionModule";
import { Court, StakeSet as StakeSetEntity } from "../generated/schema";

import { updateJurorDelayedStake, updateJurorStake } from "./entities/JurorTokensPerCourt";
import { ensureUser } from "./entities/User";
Expand All @@ -23,13 +24,26 @@ export function handleStakeDelayedNotTransferred(event: StakeDelayedNotTransferr
updateJurorDelayedStake(event.params._address.toHexString(), event.params._courtID.toString(), event.params._amount);
}

export function handleStakeSet(event: StakeSet): void {
export function handleStakeSet(event: StakeSetEvent): void {
const jurorAddress = event.params._address.toHexString();
ensureUser(jurorAddress);
const courtID = event.params._courtID.toString();

updateJurorStake(jurorAddress, courtID.toString(), SortitionModule.bind(event.address), event.block.timestamp);
//stake is updated instantly so no delayed amount, set delay amount to zero
updateJurorDelayedStake(jurorAddress, courtID, ZERO);

const generalCourt = Court.load("1");
if (!generalCourt) return;
const stakeSet = new StakeSetEntity(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
stakeSet.address = event.params._address;
stakeSet.courtID = event.params._courtID;
stakeSet.stake = event.params._amount;
stakeSet.newTotalStake = generalCourt.effectiveStake;
stakeSet.blocknumber = event.block.number;
stakeSet.timestamp = event.block.timestamp;
stakeSet.logIndex = event.logIndex;
stakeSet.save();
}

export function handleStakeLocked(event: StakeLocked): void {}
1 change: 1 addition & 0 deletions subgraph/core/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ dataSources:
language: wasm/assemblyscript
entities:
- JurorTokensPerCourt
- StakeSet
abis:
- name: SortitionModule
file: ../../contracts/deployments/arbitrumSepoliaDevnet/SortitionModule.json
Expand Down