|
1 | | -import { BigInt, store, Entity, Value } from "@graphprotocol/graph-ts"; |
| 1 | +import { |
| 2 | + Address, |
| 3 | + BigInt, |
| 4 | + Entity, |
| 5 | + Value, |
| 6 | + store, |
| 7 | +} from "@graphprotocol/graph-ts"; |
2 | 8 | import { |
3 | 9 | KlerosCore, |
4 | 10 | AppealDecision, |
@@ -94,20 +100,24 @@ export function handleDraw(event: DrawEvent): void { |
94 | 100 | draw.save(); |
95 | 101 | const dispute = Dispute.load(disputeID.toString()); |
96 | 102 | if (dispute) { |
97 | | - const jurorTokens = JurorTokensPerSubcourt.load( |
98 | | - `${drawnAddress.toHexString()}-${dispute.subcourtID.toString()}` |
| 103 | + updateJurorBalance( |
| 104 | + drawnAddress.toHexString(), dispute.subcourtID.toString(), event |
99 | 105 | ); |
100 | | - if (jurorTokens) { |
101 | | - const contract = KlerosCore.bind(event.address); |
102 | | - const jurorBalance = contract.getJurorBalance( |
103 | | - drawnAddress, BigInt.fromString(dispute.subcourtID) |
104 | | - ); |
105 | | - jurorTokens.locked = jurorBalance.value1; |
106 | | - jurorTokens.save(); |
107 | | - } |
108 | 106 | } |
109 | 107 | } |
110 | 108 |
|
| 109 | +function updateJurorBalance( |
| 110 | + address: string, subcourt: string, event: DrawEvent |
| 111 | +): void { |
| 112 | + const jurorTokens = new JurorTokensPerSubcourt(`${address}-${subcourt}`); |
| 113 | + const contract = KlerosCore.bind(event.address); |
| 114 | + const jurorBalance = contract.getJurorBalance( |
| 115 | + Address.fromString(address), BigInt.fromString(subcourt) |
| 116 | + ); |
| 117 | + jurorTokens.locked = jurorBalance.value1; |
| 118 | + jurorTokens.save(); |
| 119 | +} |
| 120 | + |
111 | 121 | export function handleStakeSet(event: StakeSet): void { |
112 | 122 | const jurorAddress = event.params._address.toHexString(); |
113 | 123 | let juror = Juror.load(jurorAddress); |
|
0 commit comments