Skip to content

Commit

Permalink
Handle sponsor introduced on Bellecour for the PoCo v5.5.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjams committed Feb 7, 2025
1 parent e993a3c commit cb18748
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Modules/IexecPoco.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH <[email protected]>
// SPDX-License-Identifier: Apache-2.0

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

import {
AccurateContribution as AccurateContributionEvent,
Expand Down Expand Up @@ -127,11 +128,16 @@ export function handleMatchOrders(call: MatchOrdersCall): void {
export function handleOrdersMatched(event: OrdersMatchedEvent): void {
let contract = IexecInterfaceTokenContract.bind(event.address);
let viewedDeal = contract.viewDeal(event.params.dealid);

// The `sponsor` has been introduced on Bellecour for the PoCo v5.5.0 release:
// https://blockscout.bellecour.iex.ec/tx/0x71b904f526a9be218d35748f57d74ef6da20d12c88f94cfa1ec5ae2de187cb98
const sponsor =
chainName == 'bellecour' && event.block.number < BigInt.fromI32(30277938)
? Address.zero().toHexString()
: viewedDeal.sponsor.toHex();
fetchAccount(viewedDeal.requester.toHex()).save();
fetchAccount(viewedDeal.beneficiary.toHex()).save();
fetchAccount(viewedDeal.callback.toHex()).save();
fetchAccount(viewedDeal.sponsor.toHex()).save();
fetchAccount(sponsor).save();

let deal = fetchDeal(event.params.dealid.toHex());
deal.app = viewedDeal.app.pointer.toHex();
Expand All @@ -155,7 +161,7 @@ export function handleOrdersMatched(event: OrdersMatchedEvent): void {
deal.botSize = viewedDeal.botSize;
deal.workerStake = viewedDeal.workerStake;
deal.schedulerRewardRatio = viewedDeal.schedulerRewardRatio;
deal.sponsor = viewedDeal.sponsor.toHex();
deal.sponsor = sponsor;
deal.apporder = event.params.appHash.toHex();
deal.datasetorder = event.params.datasetHash.toHex();
deal.workerpoolorder = event.params.workerpoolHash.toHex();
Expand Down

0 comments on commit cb18748

Please sign in to comment.