Skip to content

Commit cb18748

Browse files
Handle sponsor introduced on Bellecour for the PoCo v5.5.0 release
1 parent e993a3c commit cb18748

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Modules/IexecPoco.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { BigInt } from '@graphprotocol/graph-ts';
4+
import { Address, BigInt, dataSource } from '@graphprotocol/graph-ts';
5+
const chainName = dataSource.network();
56

67
import {
78
AccurateContribution as AccurateContributionEvent,
@@ -127,11 +128,16 @@ export function handleMatchOrders(call: MatchOrdersCall): void {
127128
export function handleOrdersMatched(event: OrdersMatchedEvent): void {
128129
let contract = IexecInterfaceTokenContract.bind(event.address);
129130
let viewedDeal = contract.viewDeal(event.params.dealid);
130-
131+
// The `sponsor` has been introduced on Bellecour for the PoCo v5.5.0 release:
132+
// https://blockscout.bellecour.iex.ec/tx/0x71b904f526a9be218d35748f57d74ef6da20d12c88f94cfa1ec5ae2de187cb98
133+
const sponsor =
134+
chainName == 'bellecour' && event.block.number < BigInt.fromI32(30277938)
135+
? Address.zero().toHexString()
136+
: viewedDeal.sponsor.toHex();
131137
fetchAccount(viewedDeal.requester.toHex()).save();
132138
fetchAccount(viewedDeal.beneficiary.toHex()).save();
133139
fetchAccount(viewedDeal.callback.toHex()).save();
134-
fetchAccount(viewedDeal.sponsor.toHex()).save();
140+
fetchAccount(sponsor).save();
135141

136142
let deal = fetchDeal(event.params.dealid.toHex());
137143
deal.app = viewedDeal.app.pointer.toHex();
@@ -155,7 +161,7 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
155161
deal.botSize = viewedDeal.botSize;
156162
deal.workerStake = viewedDeal.workerStake;
157163
deal.schedulerRewardRatio = viewedDeal.schedulerRewardRatio;
158-
deal.sponsor = viewedDeal.sponsor.toHex();
164+
deal.sponsor = sponsor;
159165
deal.apporder = event.params.appHash.toHex();
160166
deal.datasetorder = event.params.datasetHash.toHex();
161167
deal.workerpoolorder = event.params.workerpoolHash.toHex();

0 commit comments

Comments
 (0)