From b5f3b0a4a157883149ac3cf51859c36341e513db Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 15:58:26 +0200 Subject: [PATCH 1/3] refactor: remove unused MatchOrdersCall structures and related hashing functions --- src/Modules/IexecPoco.ts | 76 ------------------------- src/utils.ts | 117 --------------------------------------- 2 files changed, 193 deletions(-) diff --git a/src/Modules/IexecPoco.ts b/src/Modules/IexecPoco.ts index 6fd4216..c485717 100644 --- a/src/Modules/IexecPoco.ts +++ b/src/Modules/IexecPoco.ts @@ -8,7 +8,6 @@ import { AccurateContribution as AccurateContributionEvent, FaultyContribution as FaultyContributionEvent, IexecInterfaceToken as IexecInterfaceTokenContract, - MatchOrdersCall, OrdersMatched as OrdersMatchedEvent, SchedulerNotice as SchedulerNoticeEvent, TaskClaimed as TaskClaimedEvent, @@ -35,7 +34,6 @@ import { } from '../../generated/schema'; import { - ADDRESS_ZERO, createContributionID, createEventID, fetchAccount, @@ -47,84 +45,10 @@ import { fetchRequestorder, fetchTask, fetchWorkerpoolorder, - hashApporder, - hashDatasetorder, - hashRequestorder, - hashWorkerpoolorder, logTransaction, toRLC, } from '../utils'; -export function handleMatchOrders(call: MatchOrdersCall): void { - const contract = IexecInterfaceTokenContract.bind(call.to); - const domain = contract.domain(); - - const apporderInput = call.inputs.value0; - const apporder = fetchApporder(hashApporder(domain, apporderInput).toHex()); - apporder.app = apporderInput.app.toHex(); - apporder.appprice = toRLC(apporderInput.appprice); - apporder.volume = apporderInput.volume; - apporder.tag = apporderInput.tag; - apporder.datasetrestrict = apporderInput.datasetrestrict; - apporder.workerpoolrestrict = apporderInput.workerpoolrestrict; - apporder.requesterrestrict = apporderInput.requesterrestrict; - apporder.salt = apporderInput.salt; - apporder.sign = apporderInput.sign; - apporder.save(); - - const datasetorderInput = call.inputs.value1; - if (datasetorderInput.dataset.toString() != ADDRESS_ZERO) { - const datasetorder = fetchDatasetorder(hashDatasetorder(domain, datasetorderInput).toHex()); - datasetorder.dataset = datasetorderInput.dataset.toHex(); - datasetorder.datasetprice = toRLC(datasetorderInput.datasetprice); - datasetorder.volume = datasetorderInput.volume; - datasetorder.tag = datasetorderInput.tag; - datasetorder.apprestrict = datasetorderInput.apprestrict; - datasetorder.workerpoolrestrict = datasetorderInput.workerpoolrestrict; - datasetorder.requesterrestrict = datasetorderInput.requesterrestrict; - datasetorder.salt = datasetorderInput.salt; - datasetorder.sign = datasetorderInput.sign; - datasetorder.save(); - } - - const workerpoolorderInput = call.inputs.value2; - const workerpoolorder = fetchWorkerpoolorder( - hashWorkerpoolorder(domain, workerpoolorderInput).toHex(), - ); - workerpoolorder.workerpool = workerpoolorderInput.workerpool.toHex(); - workerpoolorder.workerpoolprice = toRLC(workerpoolorderInput.workerpoolprice); - workerpoolorder.volume = workerpoolorderInput.volume; - workerpoolorder.tag = workerpoolorderInput.tag; - workerpoolorder.category = workerpoolorderInput.category.toString(); - workerpoolorder.trust = workerpoolorderInput.trust; - workerpoolorder.apprestrict = workerpoolorderInput.apprestrict; - workerpoolorder.datasetrestrict = workerpoolorderInput.datasetrestrict; - workerpoolorder.requesterrestrict = workerpoolorderInput.requesterrestrict; - workerpoolorder.salt = workerpoolorderInput.salt; - workerpoolorder.sign = workerpoolorderInput.sign; - workerpoolorder.save(); - - const requestorderInput = call.inputs.value3; - const requestorder = fetchRequestorder(hashRequestorder(domain, requestorderInput).toHex()); - requestorder.app = requestorderInput.app.toHex(); - requestorder.appmaxprice = toRLC(requestorderInput.appmaxprice); - requestorder.dataset = requestorderInput.dataset.toHex(); - requestorder.datasetmaxprice = toRLC(requestorderInput.datasetmaxprice); - requestorder.workerpool = requestorderInput.workerpool.toHex(); - requestorder.workerpoolmaxprice = toRLC(requestorderInput.workerpoolmaxprice); - requestorder.requester = requestorderInput.requester.toHex(); - requestorder.volume = requestorderInput.volume; - requestorder.tag = requestorderInput.tag; - requestorder.category = requestorderInput.category.toString(); - requestorder.trust = requestorderInput.trust; - requestorder.beneficiary = requestorderInput.beneficiary.toHex(); - requestorder.callback = requestorderInput.callback.toHex(); - requestorder.params = requestorderInput.params; - requestorder.salt = requestorderInput.salt; - requestorder.sign = requestorderInput.sign; - requestorder.save(); -} - export function handleOrdersMatched(event: OrdersMatchedEvent): void { let contract = IexecInterfaceTokenContract.bind(event.address); let viewedDeal = contract.viewDeal(event.params.dealid); diff --git a/src/utils.ts b/src/utils.ts index 002fbd8..c0b2fec 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -39,10 +39,6 @@ import { import { IexecInterfaceToken__domainResultValue0Struct as IEIP712Domain, - MatchOrdersCallValue0Struct as IAppOrder, - MatchOrdersCallValue1Struct as IDatasetOrder, - MatchOrdersCallValue2Struct as IWorkerpoolOrder, - MatchOrdersCallValue3Struct as IRequestOrder, } from "../generated/Core/IexecInterfaceToken"; export function createEventID(event: ethereum.Event): string { @@ -229,117 +225,4 @@ function hashDomain(domain: IEIP712Domain): ByteArray { ); } -export function hashApporder( - domain: IEIP712Domain, - apporder: IAppOrder -): ByteArray { - const structHash = crypto.keccak256( - ethereum.encode( - ethereum.Value.fromTuple( - changetype([ - encodeStringValue( - "AppOrder(address app,uint256 appprice,uint256 volume,bytes32 tag,address datasetrestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)" - ), - ethereum.Value.fromAddress(apporder.app), - ethereum.Value.fromUnsignedBigInt(apporder.appprice), - ethereum.Value.fromUnsignedBigInt(apporder.volume), - ethereum.Value.fromFixedBytes(apporder.tag), - ethereum.Value.fromAddress(apporder.datasetrestrict), - ethereum.Value.fromAddress(apporder.workerpoolrestrict), - ethereum.Value.fromAddress(apporder.requesterrestrict), - ethereum.Value.fromFixedBytes(apporder.salt), - ]) // Change from 'as T' to 'changetype' - ) - )! - ); - return hashEIP712(hashDomain(domain), structHash); -} - -export function hashDatasetorder( - domain: IEIP712Domain, - datasetorder: IDatasetOrder -): ByteArray { - const structHash = crypto.keccak256( - ethereum.encode( - ethereum.Value.fromTuple( - changetype([ - encodeStringValue( - "DatasetOrder(address dataset,uint256 datasetprice,uint256 volume,bytes32 tag,address apprestrict,address workerpoolrestrict,address requesterrestrict,bytes32 salt)" - ), - ethereum.Value.fromAddress(datasetorder.dataset), - ethereum.Value.fromUnsignedBigInt(datasetorder.datasetprice), - ethereum.Value.fromUnsignedBigInt(datasetorder.volume), - ethereum.Value.fromFixedBytes(datasetorder.tag), - ethereum.Value.fromAddress(datasetorder.apprestrict), - ethereum.Value.fromAddress(datasetorder.workerpoolrestrict), - ethereum.Value.fromAddress(datasetorder.requesterrestrict), - ethereum.Value.fromFixedBytes(datasetorder.salt), - ]) // Change from 'as T' to 'changetype' - ) - )! - ); - return hashEIP712(hashDomain(domain), structHash); -} - -export function hashWorkerpoolorder( - domain: IEIP712Domain, - workerpoolorder: IWorkerpoolOrder -): ByteArray { - const structHash = crypto.keccak256( - ethereum.encode( - ethereum.Value.fromTuple( - changetype([ - encodeStringValue( - "WorkerpoolOrder(address workerpool,uint256 workerpoolprice,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address apprestrict,address datasetrestrict,address requesterrestrict,bytes32 salt)" - ), - ethereum.Value.fromAddress(workerpoolorder.workerpool), - ethereum.Value.fromUnsignedBigInt(workerpoolorder.workerpoolprice), - ethereum.Value.fromUnsignedBigInt(workerpoolorder.volume), - ethereum.Value.fromFixedBytes(workerpoolorder.tag), - ethereum.Value.fromUnsignedBigInt(workerpoolorder.category), - ethereum.Value.fromUnsignedBigInt(workerpoolorder.trust), - ethereum.Value.fromAddress(workerpoolorder.apprestrict), - ethereum.Value.fromAddress(workerpoolorder.datasetrestrict), - ethereum.Value.fromAddress(workerpoolorder.requesterrestrict), - ethereum.Value.fromFixedBytes(workerpoolorder.salt), - ]) // Change from 'as T' to 'changetype' - ) - )! - ); - return hashEIP712(hashDomain(domain), structHash); -} - -export function hashRequestorder( - domain: IEIP712Domain, - requestorder: IRequestOrder -): ByteArray { - const structHash = crypto.keccak256( - ethereum.encode( - ethereum.Value.fromTuple( - changetype([ - encodeStringValue( - "RequestOrder(address app,uint256 appmaxprice,address dataset,uint256 datasetmaxprice,address workerpool,uint256 workerpoolmaxprice,address requester,uint256 volume,bytes32 tag,uint256 category,uint256 trust,address beneficiary,address callback,string params,bytes32 salt)" - ), - ethereum.Value.fromAddress(requestorder.app), - ethereum.Value.fromUnsignedBigInt(requestorder.appmaxprice), - ethereum.Value.fromAddress(requestorder.dataset), - ethereum.Value.fromUnsignedBigInt(requestorder.datasetmaxprice), - ethereum.Value.fromAddress(requestorder.workerpool), - ethereum.Value.fromUnsignedBigInt(requestorder.workerpoolmaxprice), - ethereum.Value.fromAddress(requestorder.requester), - ethereum.Value.fromUnsignedBigInt(requestorder.volume), - ethereum.Value.fromFixedBytes(requestorder.tag), - ethereum.Value.fromUnsignedBigInt(requestorder.category), - ethereum.Value.fromUnsignedBigInt(requestorder.trust), - ethereum.Value.fromAddress(requestorder.beneficiary), - ethereum.Value.fromAddress(requestorder.callback), - encodeStringValue(requestorder.params), - ethereum.Value.fromFixedBytes(requestorder.salt), - ]) // Change from 'as T' to 'changetype' - ) - )! - ); - return hashEIP712(hashDomain(domain), structHash); -} - export const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000"; From 6798805ca5ca1dd1f1f1921ac70302d0a4e3c545 Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 15:59:05 +0200 Subject: [PATCH 2/3] fix: update copyright year to 2025 in source files --- src/Modules/IexecPoco.ts | 2 +- src/utils.ts | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Modules/IexecPoco.ts b/src/Modules/IexecPoco.ts index c485717..db76a17 100644 --- a/src/Modules/IexecPoco.ts +++ b/src/Modules/IexecPoco.ts @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH +// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 import { Address, BigInt, dataSource } from '@graphprotocol/graph-ts'; diff --git a/src/utils.ts b/src/utils.ts index c0b2fec..b790708 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,18 +1,5 @@ -/****************************************************************************** - * Copyright 2020 IEXEC BLOCKCHAIN TECH * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - ******************************************************************************/ +// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 import { Address, From c65df748b20646bd73c836c747c11993238808dc Mon Sep 17 00:00:00 2001 From: Le-Caignec Date: Thu, 24 Apr 2025 16:05:51 +0200 Subject: [PATCH 3/3] refactor: remove unused handleMatchOrders export from index module --- src/Modules/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Modules/index.ts b/src/Modules/index.ts index 05689e0..990d66d 100644 --- a/src/Modules/index.ts +++ b/src/Modules/index.ts @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH +// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 export { handleCreateCategory } from './IexecCategoryManager'; @@ -8,7 +8,6 @@ export { handleLock, handleReward, handleSeize, handleTransfer, handleUnlock } f export { handleAccurateContribution, handleFaultyContribution, - handleMatchOrders, handleOrdersMatched, handleSchedulerNotice, handleTaskClaimed,