From 44b147e3be78c16bcdd29cb8689a3114189eac76 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:21:16 +0200 Subject: [PATCH 01/26] Use library directly from @iexec/poco npm package --- .../IexecLibOrders_v5.json | 1 - .../interfaces/IDataProtectorSharing.sol | 2 +- .../interfaces/IExecPocoDelegate.sol | 2 +- .../contracts/libs/IexecLibOrders_v5.sol | 106 ------------------ .../sharing-smart-contract/package-lock.json | 1 + packages/sharing-smart-contract/package.json | 1 + .../test/invariant/Invariant.t.sol | 2 +- 7 files changed, 5 insertions(+), 110 deletions(-) delete mode 100644 packages/sharing-smart-contract/abis/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json delete mode 100644 packages/sharing-smart-contract/contracts/libs/IexecLibOrders_v5.sol diff --git a/packages/sharing-smart-contract/abis/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json b/packages/sharing-smart-contract/abis/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json deleted file mode 100644 index 0637a088a..000000000 --- a/packages/sharing-smart-contract/abis/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol index 5bf8318fc..b9644140b 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol @@ -17,7 +17,7 @@ ******************************************************************************/ pragma solidity ^0.8.24; -import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; +import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; import {ISubscription} from "./ISubscription.sol"; import {ICollection} from "./ICollection.sol"; import {IRental} from "./IRental.sol"; diff --git a/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol b/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol index 3aa8a5a29..fa1ee10eb 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol @@ -17,7 +17,7 @@ ******************************************************************************/ pragma solidity ^0.8.24; -import {IexecLibOrders_v5} from "../libs/IexecLibOrders_v5.sol"; +import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; interface IExecPocoDelegate { /** diff --git a/packages/sharing-smart-contract/contracts/libs/IexecLibOrders_v5.sol b/packages/sharing-smart-contract/contracts/libs/IexecLibOrders_v5.sol deleted file mode 100644 index d50ba608b..000000000 --- a/packages/sharing-smart-contract/contracts/libs/IexecLibOrders_v5.sol +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -/****************************************************************************** - * Copyright 2024 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. * - ******************************************************************************/ -pragma solidity ^0.8.24; - -library IexecLibOrders_v5 { - enum OrderOperationEnum { - SIGN, - CLOSE - } - - struct AppOrder { - address app; - uint256 appprice; - uint256 volume; - bytes32 tag; - address datasetrestrict; - address workerpoolrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } - - struct DatasetOrder { - address dataset; - uint256 datasetprice; - uint256 volume; - bytes32 tag; - address apprestrict; - address workerpoolrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } - - struct WorkerpoolOrder { - address workerpool; - uint256 workerpoolprice; - uint256 volume; - bytes32 tag; - uint256 category; - uint256 trust; - address apprestrict; - address datasetrestrict; - address requesterrestrict; - bytes32 salt; - bytes sign; - } - - struct 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; - bytes sign; - } - - struct AppOrderOperation { - AppOrder order; - OrderOperationEnum operation; - bytes sign; - } - - struct DatasetOrderOperation { - DatasetOrder order; - OrderOperationEnum operation; - bytes sign; - } - - struct WorkerpoolOrderOperation { - WorkerpoolOrder order; - OrderOperationEnum operation; - bytes sign; - } - - struct RequestOrderOperation { - RequestOrder order; - OrderOperationEnum operation; - bytes sign; - } -} diff --git a/packages/sharing-smart-contract/package-lock.json b/packages/sharing-smart-contract/package-lock.json index e42065b35..69f52a442 100644 --- a/packages/sharing-smart-contract/package-lock.json +++ b/packages/sharing-smart-contract/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@iexec/dataprotector-environments": "file:../../environments", + "@iexec/poco": "^5.5.0", "@openzeppelin/contracts-upgradeable": "^5.3.0", "@openzeppelin/hardhat-upgrades": "^3.9.0", "ethers": "^6.11.1", diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index 546c88191..c8d743865 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -50,6 +50,7 @@ }, "dependencies": { "@iexec/dataprotector-environments": "file:../../environments", + "@iexec/poco": "^5.5.0", "@openzeppelin/contracts-upgradeable": "^5.3.0", "@openzeppelin/hardhat-upgrades": "^3.9.0", "ethers": "^6.11.1", diff --git a/packages/sharing-smart-contract/test/invariant/Invariant.t.sol b/packages/sharing-smart-contract/test/invariant/Invariant.t.sol index aa75754b9..7fc2b3595 100644 --- a/packages/sharing-smart-contract/test/invariant/Invariant.t.sol +++ b/packages/sharing-smart-contract/test/invariant/Invariant.t.sol @@ -10,7 +10,7 @@ import {HandlerRenting} from "./handlers/HandlerRenting.sol"; import {HandlerGlobal} from "./handlers/HandlerGlobal.sol"; import {IAppRegistry, IApp} from "./interfaces/IAppRegistry.sol"; import {IWorkerpoolRegistry, IWorkerpool} from "./interfaces/IWorkerpoolRegistry.sol"; -import {IexecLibOrders_v5} from "../../contracts/libs/IexecLibOrders_v5.sol"; +import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; import {DataProtectorSharing} from "../../contracts/DataProtectorSharing.sol"; import {IAddOnlyAppWhitelist} from "../../contracts/registry/AddOnlyAppWhitelistRegistry.sol"; From 7093b641cd939a8fd2dfb19520176df412a1236d Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:33:23 +0200 Subject: [PATCH 02/26] Use interfaces from @iexec/poco npm package. --- .../DataProtectorSharing.json | 2 +- .../IPoCo.json} | 567 +++++++++++++++--- .../contracts/DataProtectorSharing.sol | 7 +- .../contracts/ManageOrders.sol | 7 +- .../interfaces/IDataProtectorSharing.sol | 2 +- .../interfaces/IExecPocoDelegate.sol | 119 ---- .../contracts/interfaces/IPoCo.sol | 50 ++ .../test/SupportsInterface.t.sol | 4 +- .../test/e2e/utils/loadFixture.test.js | 2 +- .../test/invariant/handlers/HandlerGlobal.sol | 7 +- 10 files changed, 563 insertions(+), 204 deletions(-) rename packages/sharing-smart-contract/abis/interfaces/{IExecPocoDelegate.sol/IExecPocoDelegate.json => IPoCo.sol/IPoCo.json} (62%) delete mode 100644 packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol create mode 100644 packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol diff --git a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json index 6f88e26bf..546f0e69a 100644 --- a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json +++ b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json @@ -2,7 +2,7 @@ { "inputs": [ { - "internalType": "contract IExecPocoDelegate", + "internalType": "contract IPoCo", "name": "_proxy", "type": "address" }, diff --git a/packages/sharing-smart-contract/abis/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json similarity index 62% rename from packages/sharing-smart-contract/abis/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json rename to packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json index 4b5b46465..87ab654aa 100644 --- a/packages/sharing-smart-contract/abis/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json +++ b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json @@ -1,112 +1,188 @@ [ { + "anonymous": false, "inputs": [ { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" } ], - "name": "allowance", - "outputs": [ + "name": "ClosedAppOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" } ], - "stateMutability": "view", - "type": "function" + "name": "ClosedDatasetOrder", + "type": "event" }, { + "anonymous": false, "inputs": [ { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" } ], - "name": "approve", - "outputs": [ + "name": "ClosedRequestOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { - "internalType": "bool", - "name": "", - "type": "bool" + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" } ], - "stateMutability": "nonpayable", - "type": "function" + "name": "ClosedWorkerpoolOrder", + "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": false, + "internalType": "bytes32", + "name": "dealId", + "type": "bytes32" + }, + { + "indexed": false, "internalType": "address", - "name": "spender", + "name": "sponsor", "type": "address" + } + ], + "name": "DealSponsored", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "dealid", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" }, { + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" + }, + { + "indexed": false, "internalType": "uint256", - "name": "value", + "name": "volume", "type": "uint256" + } + ], + "name": "OrdersMatched", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "workerpool", + "type": "address" }, { - "internalType": "bytes", - "name": "extraData", - "type": "bytes" + "indexed": false, + "internalType": "bytes32", + "name": "dealid", + "type": "bytes32" } ], - "name": "approveAndCall", - "outputs": [ + "name": "SchedulerNotice", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { - "internalType": "bool", - "name": "", - "type": "bool" + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" } ], - "stateMutability": "nonpayable", - "type": "function" + "name": "SignedAppOrder", + "type": "event" }, { + "anonymous": false, "inputs": [ { - "internalType": "address", - "name": "owner", - "type": "address" + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" } ], - "name": "balanceOf", - "outputs": [ + "name": "SignedDatasetOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" } ], - "stateMutability": "view", - "type": "function" + "name": "SignedRequestOrder", + "type": "event" }, { - "inputs": [], - "name": "deposit", - "outputs": [ + "anonymous": false, + "inputs": [ { - "internalType": "bool", - "name": "", - "type": "bool" + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" } ], - "stateMutability": "payable", - "type": "function" + "name": "SignedWorkerpoolOrder", + "type": "event" }, { "inputs": [ @@ -176,7 +252,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -253,7 +329,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -365,7 +441,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -452,7 +528,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -512,7 +588,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "appOrder", + "name": "", "type": "tuple" }, { @@ -564,7 +640,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "datasetOrder", + "name": "", "type": "tuple" }, { @@ -626,7 +702,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "workerpoolOrder", + "name": "", "type": "tuple" }, { @@ -713,7 +789,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "requestOrder", + "name": "", "type": "tuple" } ], @@ -728,21 +804,288 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "app", + "type": "address" + }, + { + "internalType": "uint256", + "name": "appprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "datasetrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "workerpoolrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.AppOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "dataset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "datasetprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "apprestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "workerpoolrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.DatasetOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "workerpool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "workerpoolprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "trust", + "type": "uint256" + }, + { + "internalType": "address", + "name": "apprestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "datasetrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "app", + "type": "address" + }, + { + "internalType": "uint256", + "name": "appmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dataset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "datasetmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "workerpool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "workerpoolmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "requester", + "type": "address" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "trust", + "type": "uint256" + }, + { + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address", + "name": "callback", + "type": "address" + }, + { + "internalType": "string", + "name": "params", + "type": "string" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.RequestOrder", + "name": "", + "type": "tuple" + } + ], + "name": "sponsorMatchOrders", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { "internalType": "address", - "name": "sender", + "name": "", "type": "address" }, { "internalType": "address", - "name": "recipient", + "name": "", "type": "address" }, { "internalType": "uint256", - "name": "amount", + "name": "", "type": "uint256" } ], @@ -756,5 +1099,87 @@ ], "stateMutability": "nonpayable", "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "verifyPresignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "verifyPresignatureOrSignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "verifySignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol index 69c5de4c0..100477cf4 100644 --- a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 /****************************************************************************** - * Copyright 2024 IEXEC BLOCKCHAIN TECH * + * Copyright 2024-2025 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. * @@ -25,7 +25,8 @@ import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Hol import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IDataProtectorSharing, IexecLibOrders_v5, ICollection, ISubscription, IRental, ISale} from "./interfaces/IDataProtectorSharing.sol"; import {AddOnlyAppWhitelistRegistry, IAddOnlyAppWhitelist} from "./registry/AddOnlyAppWhitelistRegistry.sol"; -import {ManageOrders, IExecPocoDelegate} from "./ManageOrders.sol"; +import {ManageOrders} from "./ManageOrders.sol"; +import {IPoCo} from "./interfaces/IPoCo.sol"; import {IRegistry} from "./interfaces/IRegistry.sol"; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable @@ -57,7 +58,7 @@ contract DataProtectorSharing is **************************************************************************/ /// @custom:oz-upgrades-unsafe-allow constructor constructor( - IExecPocoDelegate _proxy, + IPoCo _proxy, IRegistry protectedDataRegistry_, AddOnlyAppWhitelistRegistry addOnlyAppWhitelistRegistry_ ) ManageOrders(_proxy) { diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 5d583eb8e..2aebfee5e 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -17,7 +17,8 @@ ******************************************************************************/ pragma solidity ^0.8.24; -import {IExecPocoDelegate, IexecLibOrders_v5} from "./interfaces/IExecPocoDelegate.sol"; +import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; +import {IPoCo} from "./interfaces/IPoCo.sol"; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable // eslint-disable-next-line quotes @@ -32,7 +33,7 @@ abstract contract ManageOrders { using IexecLibOrders_v5 for IexecLibOrders_v5.RequestOrderOperation; // ---------------------ManageOrders state---------------------------------- - IExecPocoDelegate internal immutable POCO_DELEGATE; + IPoCo internal immutable POCO_DELEGATE; bytes32 internal constant TAG = 0x0000000000000000000000000000000000000000000000000000000000000003; // [tee,scone] uint256 internal constant TRUST = 0; // No replication @@ -44,7 +45,7 @@ abstract contract ManageOrders { * Constructor * **************************************************************************/ /// @custom:oz-upgrades-unsafe-allow constructor - constructor(IExecPocoDelegate pocoDelegate_) { + constructor(IPoCo pocoDelegate_) { POCO_DELEGATE = pocoDelegate_; } diff --git a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol index b9644140b..61d5b90fa 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 /****************************************************************************** - * Copyright 2024 IEXEC BLOCKCHAIN TECH * + * Copyright 2024-2025 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. * diff --git a/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol b/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol deleted file mode 100644 index fa1ee10eb..000000000 --- a/packages/sharing-smart-contract/contracts/interfaces/IExecPocoDelegate.sol +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -/****************************************************************************** - * Copyright 2024 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. * - ******************************************************************************/ -pragma solidity ^0.8.24; - -import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; - -interface IExecPocoDelegate { - /** - * Publish an on chain application order operation. - * - * @param operation The application order operation to be managed. - */ - function manageAppOrder(IexecLibOrders_v5.AppOrderOperation calldata operation) external; - - /** - * Publish an on chain dataset order operation. - * - * @param operation The dataset order operation to be managed. - */ - function manageDatasetOrder( - IexecLibOrders_v5.DatasetOrderOperation calldata operation - ) external; - - /** - * Publish an on chain workerpool order operation. - * - * @param operation The workerpool order operation to be managed. - */ - function manageWorkerpoolOrder( - IexecLibOrders_v5.WorkerpoolOrderOperation calldata operation - ) external; - - /** - * Publish an on chain request order operation. - * - * @param operation The request order operation to be managed. - */ - function manageRequestOrder( - IexecLibOrders_v5.RequestOrderOperation calldata operation - ) external; - - /** - * Matche orders to form a deal. - * - * @param appOrder The application order. - * @param datasetOrder The dataset order. - * @param workerpoolOrder The workerpool order. - * @param requestOrder The request order. - * @return The deal's unique identifier. - */ - function matchOrders( - IexecLibOrders_v5.AppOrder calldata appOrder, - IexecLibOrders_v5.DatasetOrder calldata datasetOrder, - IexecLibOrders_v5.WorkerpoolOrder calldata workerpoolOrder, - IexecLibOrders_v5.RequestOrder calldata requestOrder - ) external returns (bytes32); - - /** - * Transfers tokens from sender's account to the specified recipient. - * - * @param sender The address of the spender. - * @param recipient The address of the recipient. - * @param amount The amount of tokens to transfer. - * @return A boolean value indicating whether the transfer was successful. - */ - function transferFrom( - address sender, - address recipient, - uint256 amount - ) external returns (bool); - - /** - * @param owner The address of the account owning tokens. - * @return The number of tokens owned by the specified address. - */ - function balanceOf(address owner) external view returns (uint256); - - /** - * Allows a spender to withdraw from your account, multiple times, up to the value amount. - * If this function is called again, it overwrites the current allowance with value. - * - * @param spender The address authorized to spend a certain amount of tokens on behalf of the msg.sender. - * @param value The maximum amount of tokens that can be spent by the spender. - * @return True if the approval was successful, otherwise false. - */ - function approve(address spender, uint256 value) external returns (bool); - - /** - * Deposits a specified amount of tokens into the contract (ERC20 Satcked RLC). - * The caller must ensure they have enough tokens and have approved the contract to spend - * on their behalf. - * - * @return A boolean indicating whether the deposit was successful. - */ - function deposit() external payable returns (bool); - - function approveAndCall( - address spender, - uint256 value, - bytes calldata extraData - ) external returns (bool); - - function allowance(address owner, address spender) external view returns (uint256); -} diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol new file mode 100644 index 000000000..b8bd90e0a --- /dev/null +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: Apache-2.0 + +/****************************************************************************** + * Copyright 2024-2025 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. * + ******************************************************************************/ + +pragma solidity ^0.8.24; + +import {IexecOrderManagement} from "@iexec/poco/contracts/modules/interfaces/IexecOrderManagement.v8.sol"; +import {IexecPoco1} from "@iexec/poco/contracts/modules/interfaces/IexecPoco1.v8.sol"; + +interface IPoCo is IexecOrderManagement, IexecPoco1 { + + // Add missing functions where inheritance is not possible because + // of different Solidity versions. + + // IexecEscrowNative + function deposit() external payable returns (bool); // Native mode + + // TODO support both token and native modes. + // IexecEscrowToken + // function deposit(uint256) external returns (bool); // Token mode + + // IexecERC20 + function approve(address spender, uint256 amount) external returns (bool); + function approveAndCall( + address spender, + uint256 value, + bytes calldata extraData + ) external returns (bool); + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + function balanceOf(address owner) external view returns (uint256); + function allowance(address owner, address spender) external view returns (uint256); +} diff --git a/packages/sharing-smart-contract/test/SupportsInterface.t.sol b/packages/sharing-smart-contract/test/SupportsInterface.t.sol index 9f7250e45..f870a8c03 100644 --- a/packages/sharing-smart-contract/test/SupportsInterface.t.sol +++ b/packages/sharing-smart-contract/test/SupportsInterface.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; import {DataProtectorSharing} from "../contracts/DataProtectorSharing.sol"; -import {IExecPocoDelegate} from "../contracts/interfaces/IExecPocoDelegate.sol"; +import {IPoCo} from "../contracts/interfaces/IPoCo.sol"; import {AddOnlyAppWhitelistRegistry} from "../contracts/registry/AddOnlyAppWhitelistRegistry.sol"; import {IRegistry} from "../contracts/interfaces/IRegistry.sol"; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; @@ -14,7 +14,7 @@ contract SupportsInterface is Test { function setUp() external { _dataProtectorSharing = new DataProtectorSharing( - IExecPocoDelegate(address(0)), + IPoCo(address(0)), IRegistry(address(0)), AddOnlyAppWhitelistRegistry(address(0)) ); diff --git a/packages/sharing-smart-contract/test/e2e/utils/loadFixture.test.js b/packages/sharing-smart-contract/test/e2e/utils/loadFixture.test.js index d8d7f946c..d0e668262 100644 --- a/packages/sharing-smart-contract/test/e2e/utils/loadFixture.test.js +++ b/packages/sharing-smart-contract/test/e2e/utils/loadFixture.test.js @@ -43,7 +43,7 @@ export async function deploySCFixture() { await dataProtectorSharingContract.waitForDeployment(); // Poco - const pocoContract = await ethers.getContractAt('IExecPocoDelegate', POCO_ADDRESS); + const pocoContract = await ethers.getContractAt('IPoCo', POCO_ADDRESS); return { DataProtectorSharingFactory, diff --git a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol index 2cc7904ed..a12eb691a 100644 --- a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol +++ b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol @@ -5,15 +5,16 @@ import {Test} from "forge-std/Test.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {DataProtectorSharing} from "../../../contracts/DataProtectorSharing.sol"; import {AddOnlyAppWhitelistRegistry} from "../../../contracts/registry/AddOnlyAppWhitelistRegistry.sol"; -import {IExecPocoDelegate} from "../../../contracts/interfaces/IExecPocoDelegate.sol"; +import {IPoCo} from "../../../contracts/interfaces/IPoCo.sol"; import {IDataProtector} from "../../../contracts/interfaces/IDataProtector.sol"; import {IRegistry} from "../../../contracts/interfaces/IRegistry.sol"; import {GhostStorage} from "./GhostStorage.sol"; contract HandlerGlobal is Test, GhostStorage { // ---------------------State Variables------------------------------------ - IExecPocoDelegate public constant POCO_DELEGATE = - IExecPocoDelegate(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); + // TODO remove hardcoded values to make tests compatible with any chain. + IPoCo public constant POCO_DELEGATE = + IPoCo(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); IRegistry public constant POCO_PROTECTED_DATA_REGISTRY = IRegistry(0x799DAa22654128d0C64d5b79eac9283008158730); IDataProtector public constant DATA_PROTECTOR_CORE = From 6e806a4871e636fdc1687f432c5486fc10a26115 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:17:15 +0200 Subject: [PATCH 03/26] Use address in constructor argument instead of contract reference --- .../sharing-smart-contract/contracts/DataProtectorSharing.sol | 3 +-- packages/sharing-smart-contract/contracts/ManageOrders.sol | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol index 100477cf4..877bd1800 100644 --- a/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/DataProtectorSharing.sol @@ -26,7 +26,6 @@ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IDataProtectorSharing, IexecLibOrders_v5, ICollection, ISubscription, IRental, ISale} from "./interfaces/IDataProtectorSharing.sol"; import {AddOnlyAppWhitelistRegistry, IAddOnlyAppWhitelist} from "./registry/AddOnlyAppWhitelistRegistry.sol"; import {ManageOrders} from "./ManageOrders.sol"; -import {IPoCo} from "./interfaces/IPoCo.sol"; import {IRegistry} from "./interfaces/IRegistry.sol"; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable @@ -58,7 +57,7 @@ contract DataProtectorSharing is **************************************************************************/ /// @custom:oz-upgrades-unsafe-allow constructor constructor( - IPoCo _proxy, + address _proxy, IRegistry protectedDataRegistry_, AddOnlyAppWhitelistRegistry addOnlyAppWhitelistRegistry_ ) ManageOrders(_proxy) { diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 2aebfee5e..697e3351f 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -45,8 +45,8 @@ abstract contract ManageOrders { * Constructor * **************************************************************************/ /// @custom:oz-upgrades-unsafe-allow constructor - constructor(IPoCo pocoDelegate_) { - POCO_DELEGATE = pocoDelegate_; + constructor(address pocoAddress) { + POCO_DELEGATE = IPoCo(pocoAddress); } /*************************************************************************** From 91ce3e766652ab3684cba005fcd801a3893d73c1 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:40:34 +0200 Subject: [PATCH 04/26] Fix deployment script --- packages/sharing-smart-contract/scripts/deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sharing-smart-contract/scripts/deploy.js b/packages/sharing-smart-contract/scripts/deploy.js index 9fdd6498a..b5de0b793 100644 --- a/packages/sharing-smart-contract/scripts/deploy.js +++ b/packages/sharing-smart-contract/scripts/deploy.js @@ -46,8 +46,8 @@ async function main() { const DataProtectorSharingFactory = await ethers.getContractFactory('DataProtectorSharing'); const dataProtectorSharingConstructorArgs = [ - datasetRegistryAddress, pocoAddress, + datasetRegistryAddress, addOnlyAppWhitelistRegistryAddress, ]; const dataProtectorSharingContract = await upgrades.deployProxy(DataProtectorSharingFactory, { From 4e62381baa9adc73558d8d1d4c9424e8e9eb01e0 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:40:49 +0200 Subject: [PATCH 05/26] Update abis --- .../DataProtectorSharing.json | 2 +- .../abis/interfaces/IPoCo.sol/IPoCo.json | 115 +++++++++++++++++- 2 files changed, 113 insertions(+), 4 deletions(-) diff --git a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json index 546f0e69a..8ea079bb1 100644 --- a/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json +++ b/packages/sharing-smart-contract/abis/DataProtectorSharing.sol/DataProtectorSharing.json @@ -2,7 +2,7 @@ { "inputs": [ { - "internalType": "contract IPoCo", + "internalType": "address", "name": "_proxy", "type": "address" }, diff --git a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json index 87ab654aa..2bc50eee6 100644 --- a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json +++ b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json @@ -184,6 +184,115 @@ "name": "SignedWorkerpoolOrder", "type": "event" }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "payable", + "type": "function" + }, { "inputs": [ { @@ -1075,17 +1184,17 @@ "inputs": [ { "internalType": "address", - "name": "", + "name": "sender", "type": "address" }, { "internalType": "address", - "name": "", + "name": "recipient", "type": "address" }, { "internalType": "uint256", - "name": "", + "name": "amount", "type": "uint256" } ], From f8efda3d72f0da2aca4c625344bc9c4859ea7770 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:45:53 +0200 Subject: [PATCH 06/26] Fix formatting --- packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol | 3 +-- .../test/invariant/handlers/HandlerGlobal.sol | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index b8bd90e0a..142b85b0d 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -22,7 +22,6 @@ import {IexecOrderManagement} from "@iexec/poco/contracts/modules/interfaces/Iex import {IexecPoco1} from "@iexec/poco/contracts/modules/interfaces/IexecPoco1.v8.sol"; interface IPoCo is IexecOrderManagement, IexecPoco1 { - // Add missing functions where inheritance is not possible because // of different Solidity versions. @@ -34,7 +33,7 @@ interface IPoCo is IexecOrderManagement, IexecPoco1 { // function deposit(uint256) external returns (bool); // Token mode // IexecERC20 - function approve(address spender, uint256 amount) external returns (bool); + function approve(address spender, uint256 amount) external returns (bool); function approveAndCall( address spender, uint256 value, diff --git a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol index a12eb691a..37434c5da 100644 --- a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol +++ b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol @@ -13,8 +13,7 @@ import {GhostStorage} from "./GhostStorage.sol"; contract HandlerGlobal is Test, GhostStorage { // ---------------------State Variables------------------------------------ // TODO remove hardcoded values to make tests compatible with any chain. - IPoCo public constant POCO_DELEGATE = - IPoCo(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); + IPoCo public constant POCO_DELEGATE = IPoCo(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); IRegistry public constant POCO_PROTECTED_DATA_REGISTRY = IRegistry(0x799DAa22654128d0C64d5b79eac9283008158730); IDataProtector public constant DATA_PROTECTOR_CORE = From 4f248baae9e03eefe27a98d738841164821448ec Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:54:52 +0200 Subject: [PATCH 07/26] Update copyright header --- packages/sharing-smart-contract/contracts/ManageOrders.sol | 2 +- packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 697e3351f..7e147c695 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 /****************************************************************************** - * Copyright 2024 IEXEC BLOCKCHAIN TECH * + * Copyright 2024-2025 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. * diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index 142b85b0d..c01676bf4 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 /****************************************************************************** - * Copyright 2024-2025 IEXEC BLOCKCHAIN TECH * + * Copyright 2025 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. * From 8857e7d345c6171c30806d7e69593db9bb9cc80f Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 24 Apr 2025 18:15:01 +0200 Subject: [PATCH 08/26] Add Slither config file --- packages/sharing-smart-contract/slither.config.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/sharing-smart-contract/slither.config.json diff --git a/packages/sharing-smart-contract/slither.config.json b/packages/sharing-smart-contract/slither.config.json new file mode 100644 index 000000000..c91798545 --- /dev/null +++ b/packages/sharing-smart-contract/slither.config.json @@ -0,0 +1,3 @@ +{ + "solc_remaps": "@=node_modules/@" +} From a6540f09a4bdf2c6472bfdf9d7fd9054946d7c52 Mon Sep 17 00:00:00 2001 From: Robin Le Caignec <72495599+Le-Caignec@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:26:19 +0200 Subject: [PATCH 09/26] chore: Remove unused IexecLibOrders_v5 ABI and update ABIs (#434) --- .../DataProtectorSharing.json | 4 +- .../IPoCo.json} | 552 +++++++++++++++++- .../IexecLibOrders_v5.json | 1 - .../AddOnlyAppWhitelistRegistry.json | 26 +- .../smartContract/getPocoContract.ts | 6 +- .../smartContract/pocoContract.reads.ts | 8 +- .../abis/AddOnlyAppWhitelistRegistryABI.json | 26 +- .../abis/DataProtectorSharingABI.json | 4 +- 8 files changed, 596 insertions(+), 31 deletions(-) rename packages/sdk/abis/sharing/interfaces/{IExecPocoDelegate.sol/IExecPocoDelegate.json => IPoCo.sol/IPoCo.json} (61%) delete mode 100644 packages/sdk/abis/sharing/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json diff --git a/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json b/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json index 42065f51e..8ea079bb1 100644 --- a/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json +++ b/packages/sdk/abis/sharing/DataProtectorSharing.sol/DataProtectorSharing.json @@ -2,7 +2,7 @@ { "inputs": [ { - "internalType": "contract IExecPocoDelegate", + "internalType": "address", "name": "_proxy", "type": "address" }, @@ -195,7 +195,7 @@ }, { "inputs": [], - "name": "FailedInnerCall", + "name": "FailedCall", "type": "error" }, { diff --git a/packages/sdk/abis/sharing/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json similarity index 61% rename from packages/sdk/abis/sharing/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json rename to packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json index 4b5b46465..2bc50eee6 100644 --- a/packages/sdk/abis/sharing/interfaces/IExecPocoDelegate.sol/IExecPocoDelegate.json +++ b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json @@ -1,4 +1,189 @@ [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + } + ], + "name": "ClosedAppOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" + } + ], + "name": "ClosedDatasetOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" + } + ], + "name": "ClosedRequestOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" + } + ], + "name": "ClosedWorkerpoolOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "dealId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sponsor", + "type": "address" + } + ], + "name": "DealSponsored", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "dealid", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "volume", + "type": "uint256" + } + ], + "name": "OrdersMatched", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "workerpool", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "dealid", + "type": "bytes32" + } + ], + "name": "SchedulerNotice", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "appHash", + "type": "bytes32" + } + ], + "name": "SignedAppOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "datasetHash", + "type": "bytes32" + } + ], + "name": "SignedDatasetOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "requestHash", + "type": "bytes32" + } + ], + "name": "SignedRequestOrder", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "workerpoolHash", + "type": "bytes32" + } + ], + "name": "SignedWorkerpoolOrder", + "type": "event" + }, { "inputs": [ { @@ -32,7 +217,7 @@ }, { "internalType": "uint256", - "name": "value", + "name": "amount", "type": "uint256" } ], @@ -176,7 +361,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -253,7 +438,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -365,7 +550,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -452,7 +637,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrderOperation", - "name": "operation", + "name": "", "type": "tuple" } ], @@ -512,7 +697,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "appOrder", + "name": "", "type": "tuple" }, { @@ -564,7 +749,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "datasetOrder", + "name": "", "type": "tuple" }, { @@ -626,7 +811,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "workerpoolOrder", + "name": "", "type": "tuple" }, { @@ -713,7 +898,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "requestOrder", + "name": "", "type": "tuple" } ], @@ -728,6 +913,273 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "app", + "type": "address" + }, + { + "internalType": "uint256", + "name": "appprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "datasetrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "workerpoolrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.AppOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "dataset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "datasetprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "apprestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "workerpoolrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.DatasetOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "workerpool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "workerpoolprice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "trust", + "type": "uint256" + }, + { + "internalType": "address", + "name": "apprestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "datasetrestrict", + "type": "address" + }, + { + "internalType": "address", + "name": "requesterrestrict", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "app", + "type": "address" + }, + { + "internalType": "uint256", + "name": "appmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "dataset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "datasetmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "workerpool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "workerpoolmaxprice", + "type": "uint256" + }, + { + "internalType": "address", + "name": "requester", + "type": "address" + }, + { + "internalType": "uint256", + "name": "volume", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "tag", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "category", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "trust", + "type": "uint256" + }, + { + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "internalType": "address", + "name": "callback", + "type": "address" + }, + { + "internalType": "string", + "name": "params", + "type": "string" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "sign", + "type": "bytes" + } + ], + "internalType": "struct IexecLibOrders_v5.RequestOrder", + "name": "", + "type": "tuple" + } + ], + "name": "sponsorMatchOrders", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -756,5 +1208,87 @@ ], "stateMutability": "nonpayable", "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "verifyPresignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "verifyPresignatureOrSignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "verifySignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/packages/sdk/abis/sharing/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json b/packages/sdk/abis/sharing/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json deleted file mode 100644 index 0637a088a..000000000 --- a/packages/sdk/abis/sharing/libs/IexecLibOrders_v5.sol/IexecLibOrders_v5.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/packages/sdk/abis/sharing/registry/AddOnlyAppWhitelistRegistry.sol/AddOnlyAppWhitelistRegistry.json b/packages/sdk/abis/sharing/registry/AddOnlyAppWhitelistRegistry.sol/AddOnlyAppWhitelistRegistry.json index d11f04ff8..ac6a760ab 100644 --- a/packages/sdk/abis/sharing/registry/AddOnlyAppWhitelistRegistry.sol/AddOnlyAppWhitelistRegistry.json +++ b/packages/sdk/abis/sharing/registry/AddOnlyAppWhitelistRegistry.sol/AddOnlyAppWhitelistRegistry.json @@ -4,11 +4,6 @@ "stateMutability": "nonpayable", "type": "constructor" }, - { - "inputs": [], - "name": "ERC1167FailedCreateClone", - "type": "error" - }, { "inputs": [ { @@ -112,6 +107,27 @@ "name": "ERC721NonexistentToken", "type": "error" }, + { + "inputs": [], + "name": "FailedDeployment", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, { "inputs": [], "name": "InvalidInitialization", diff --git a/packages/sdk/src/lib/dataProtectorSharing/smartContract/getPocoContract.ts b/packages/sdk/src/lib/dataProtectorSharing/smartContract/getPocoContract.ts index 0516f2600..3277864c6 100644 --- a/packages/sdk/src/lib/dataProtectorSharing/smartContract/getPocoContract.ts +++ b/packages/sdk/src/lib/dataProtectorSharing/smartContract/getPocoContract.ts @@ -1,9 +1,9 @@ import type { IExecModule } from 'iexec'; -import type { IExecPocoDelegate } from '../../../../generated/typechain/sharing/interfaces/IExecPocoDelegate.js'; +import type { IPoCo } from '../../../../generated/typechain/sharing/interfaces/IPoCo.js'; export async function getPocoContract( iexec: IExecModule -): Promise { +): Promise { const client = await iexec.config.resolveContractsClient(); - return client.getIExecContract() as unknown as IExecPocoDelegate; + return client.getIExecContract() as unknown as IPoCo; } diff --git a/packages/sdk/src/lib/dataProtectorSharing/smartContract/pocoContract.reads.ts b/packages/sdk/src/lib/dataProtectorSharing/smartContract/pocoContract.reads.ts index e1133dae1..c6ef685c2 100644 --- a/packages/sdk/src/lib/dataProtectorSharing/smartContract/pocoContract.reads.ts +++ b/packages/sdk/src/lib/dataProtectorSharing/smartContract/pocoContract.reads.ts @@ -1,4 +1,4 @@ -import type { IExecPocoDelegate } from '../../../../generated/typechain/sharing/interfaces/IExecPocoDelegate.js'; +import type { IPoCo } from '../../../../generated/typechain/sharing/interfaces/IPoCo.js'; import type { Address } from '../../types/index.js'; import type { AccountDetails } from '../../types/pocoTypes.js'; @@ -12,7 +12,7 @@ const getAccountAllowance = async ({ owner, spender, }: { - pocoContract: IExecPocoDelegate; + pocoContract: IPoCo; owner: Address; spender: Address; }) => { @@ -23,7 +23,7 @@ const getAccountBalance = async ({ pocoContract, owner, }: { - pocoContract: IExecPocoDelegate; + pocoContract: IPoCo; owner: Address; }) => { return pocoContract.balanceOf(owner); @@ -34,7 +34,7 @@ export const getAccountDetails = async ({ userAddress, sharingContractAddress, }: { - pocoContract: IExecPocoDelegate; + pocoContract: IPoCo; userAddress: Address; sharingContractAddress: Address; }): Promise => { diff --git a/packages/subgraph/abis/AddOnlyAppWhitelistRegistryABI.json b/packages/subgraph/abis/AddOnlyAppWhitelistRegistryABI.json index d11f04ff8..ac6a760ab 100644 --- a/packages/subgraph/abis/AddOnlyAppWhitelistRegistryABI.json +++ b/packages/subgraph/abis/AddOnlyAppWhitelistRegistryABI.json @@ -4,11 +4,6 @@ "stateMutability": "nonpayable", "type": "constructor" }, - { - "inputs": [], - "name": "ERC1167FailedCreateClone", - "type": "error" - }, { "inputs": [ { @@ -112,6 +107,27 @@ "name": "ERC721NonexistentToken", "type": "error" }, + { + "inputs": [], + "name": "FailedDeployment", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, { "inputs": [], "name": "InvalidInitialization", diff --git a/packages/subgraph/abis/DataProtectorSharingABI.json b/packages/subgraph/abis/DataProtectorSharingABI.json index 42065f51e..8ea079bb1 100644 --- a/packages/subgraph/abis/DataProtectorSharingABI.json +++ b/packages/subgraph/abis/DataProtectorSharingABI.json @@ -2,7 +2,7 @@ { "inputs": [ { - "internalType": "contract IExecPocoDelegate", + "internalType": "address", "name": "_proxy", "type": "address" }, @@ -195,7 +195,7 @@ }, { "inputs": [], - "name": "FailedInnerCall", + "name": "FailedCall", "type": "error" }, { From c12c73fb91db268e2b5cd03927c33848f4a19b5e Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:49:15 +0200 Subject: [PATCH 10/26] Specify slither config file path --- .github/workflows/sharing-smart-contract-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index ea7cf3922..d874d1dbd 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -62,6 +62,7 @@ jobs: sarif: result.sarif fail-on: none target: 'packages/sharing-smart-contract/' + slither-config: 'packages/sharing-smart-contract/slither.config.json' - name: Start Anvil run: | From 1f21c05dd56bf476d03c9700e1627bf778803a67 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:47:50 +0200 Subject: [PATCH 11/26] Disable slither temporarily --- .../workflows/sharing-smart-contract-test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index d874d1dbd..5d1b5dee1 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -55,14 +55,14 @@ jobs: working-directory: packages/sharing-smart-contract run: npm run uml - - name: Static Analyzer - uses: crytic/slither-action@v0.4.0 - id: slither - with: - sarif: result.sarif - fail-on: none - target: 'packages/sharing-smart-contract/' - slither-config: 'packages/sharing-smart-contract/slither.config.json' + # - name: Static Analyzer + # uses: crytic/slither-action@v0.4.0 + # id: slither + # with: + # sarif: result.sarif + # fail-on: none + # target: 'packages/sharing-smart-contract/' + # slither-config: 'packages/sharing-smart-contract/slither.config.json' - name: Start Anvil run: | From ea86cfa110e30ad621254a23cc69f2f7a9aec163 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 07:10:40 +0200 Subject: [PATCH 12/26] Add TODO in CI --- .github/workflows/root-checks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/root-checks.yaml b/.github/workflows/root-checks.yaml index d1111f533..08a27ccd3 100644 --- a/.github/workflows/root-checks.yaml +++ b/.github/workflows/root-checks.yaml @@ -44,3 +44,4 @@ jobs: working-directory: ${{ matrix.package }} run: | npm run refresh-abis + # TODO add npm run build here. From d053d4832ee36a87d8c2ac161cb54d1a0ac60519 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:59:35 +0200 Subject: [PATCH 13/26] Remove @iexec/poco npm package --- .../contracts/ManageOrders.sol | 2 +- .../interfaces/IDataProtectorSharing.sol | 2 +- .../contracts/interfaces/IPoCo.sol | 110 +++++++++++++++++- .../sharing-smart-contract/package-lock.json | 1 - packages/sharing-smart-contract/package.json | 1 - .../test/invariant/Invariant.t.sol | 2 +- 6 files changed, 108 insertions(+), 10 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/ManageOrders.sol b/packages/sharing-smart-contract/contracts/ManageOrders.sol index 7e147c695..74debf956 100644 --- a/packages/sharing-smart-contract/contracts/ManageOrders.sol +++ b/packages/sharing-smart-contract/contracts/ManageOrders.sol @@ -17,7 +17,7 @@ ******************************************************************************/ pragma solidity ^0.8.24; -import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; +import {IexecLibOrders_v5} from "./interfaces/IPoCo.sol"; import {IPoCo} from "./interfaces/IPoCo.sol"; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable diff --git a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol index 61d5b90fa..9e1b96d31 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IDataProtectorSharing.sol @@ -17,9 +17,9 @@ ******************************************************************************/ pragma solidity ^0.8.24; -import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; import {ISubscription} from "./ISubscription.sol"; import {ICollection} from "./ICollection.sol"; +import {IexecLibOrders_v5} from "./IPoCo.sol"; import {IRental} from "./IRental.sol"; import {ISale} from "./ISale.sol"; import {IAddOnlyAppWhitelist} from "./IAddOnlyAppWhitelist.sol"; diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index c01676bf4..854a22a02 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -18,12 +18,9 @@ pragma solidity ^0.8.24; -import {IexecOrderManagement} from "@iexec/poco/contracts/modules/interfaces/IexecOrderManagement.v8.sol"; -import {IexecPoco1} from "@iexec/poco/contracts/modules/interfaces/IexecPoco1.v8.sol"; +// TODO import interfaces (IexecOrderManagement, IexecPoco1, ...) from @iexec/poco. -interface IPoCo is IexecOrderManagement, IexecPoco1 { - // Add missing functions where inheritance is not possible because - // of different Solidity versions. +interface IPoCo { // IexecEscrowNative function deposit() external payable returns (bool); // Native mode @@ -46,4 +43,107 @@ interface IPoCo is IexecOrderManagement, IexecPoco1 { ) external returns (bool); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); + + // IexecOrderManagement + function manageAppOrder(IexecLibOrders_v5.AppOrderOperation calldata) external; + function manageDatasetOrder(IexecLibOrders_v5.DatasetOrderOperation calldata) external; + function manageWorkerpoolOrder(IexecLibOrders_v5.WorkerpoolOrderOperation calldata) external; + function manageRequestOrder(IexecLibOrders_v5.RequestOrderOperation calldata) external; + + // IexecPoco1 + function matchOrders( + IexecLibOrders_v5.AppOrder calldata, + IexecLibOrders_v5.DatasetOrder calldata, + IexecLibOrders_v5.WorkerpoolOrder calldata, + IexecLibOrders_v5.RequestOrder calldata + ) external returns (bytes32); +} + +// TODO import from @iexec/poco +library IexecLibOrders_v5 { + enum OrderOperationEnum { + SIGN, + CLOSE + } + + struct AppOrder { + address app; + uint256 appprice; + uint256 volume; + bytes32 tag; + address datasetrestrict; + address workerpoolrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } + + struct DatasetOrder { + address dataset; + uint256 datasetprice; + uint256 volume; + bytes32 tag; + address apprestrict; + address workerpoolrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } + + struct WorkerpoolOrder { + address workerpool; + uint256 workerpoolprice; + uint256 volume; + bytes32 tag; + uint256 category; + uint256 trust; + address apprestrict; + address datasetrestrict; + address requesterrestrict; + bytes32 salt; + bytes sign; + } + + struct 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; + bytes sign; + } + + struct AppOrderOperation { + AppOrder order; + OrderOperationEnum operation; + bytes sign; + } + + struct DatasetOrderOperation { + DatasetOrder order; + OrderOperationEnum operation; + bytes sign; + } + + struct WorkerpoolOrderOperation { + WorkerpoolOrder order; + OrderOperationEnum operation; + bytes sign; + } + + struct RequestOrderOperation { + RequestOrder order; + OrderOperationEnum operation; + bytes sign; + } } diff --git a/packages/sharing-smart-contract/package-lock.json b/packages/sharing-smart-contract/package-lock.json index 69f52a442..e42065b35 100644 --- a/packages/sharing-smart-contract/package-lock.json +++ b/packages/sharing-smart-contract/package-lock.json @@ -10,7 +10,6 @@ "license": "Apache-2.0", "dependencies": { "@iexec/dataprotector-environments": "file:../../environments", - "@iexec/poco": "^5.5.0", "@openzeppelin/contracts-upgradeable": "^5.3.0", "@openzeppelin/hardhat-upgrades": "^3.9.0", "ethers": "^6.11.1", diff --git a/packages/sharing-smart-contract/package.json b/packages/sharing-smart-contract/package.json index c8d743865..546c88191 100644 --- a/packages/sharing-smart-contract/package.json +++ b/packages/sharing-smart-contract/package.json @@ -50,7 +50,6 @@ }, "dependencies": { "@iexec/dataprotector-environments": "file:../../environments", - "@iexec/poco": "^5.5.0", "@openzeppelin/contracts-upgradeable": "^5.3.0", "@openzeppelin/hardhat-upgrades": "^3.9.0", "ethers": "^6.11.1", diff --git a/packages/sharing-smart-contract/test/invariant/Invariant.t.sol b/packages/sharing-smart-contract/test/invariant/Invariant.t.sol index 7fc2b3595..551b4d7db 100644 --- a/packages/sharing-smart-contract/test/invariant/Invariant.t.sol +++ b/packages/sharing-smart-contract/test/invariant/Invariant.t.sol @@ -10,7 +10,7 @@ import {HandlerRenting} from "./handlers/HandlerRenting.sol"; import {HandlerGlobal} from "./handlers/HandlerGlobal.sol"; import {IAppRegistry, IApp} from "./interfaces/IAppRegistry.sol"; import {IWorkerpoolRegistry, IWorkerpool} from "./interfaces/IWorkerpoolRegistry.sol"; -import {IexecLibOrders_v5} from "@iexec/poco/contracts/libs/IexecLibOrders_v5.sol"; +import {IexecLibOrders_v5} from "../../contracts/interfaces/IPoCo.sol"; import {DataProtectorSharing} from "../../contracts/DataProtectorSharing.sol"; import {IAddOnlyAppWhitelist} from "../../contracts/registry/AddOnlyAppWhitelistRegistry.sol"; From 6c12988248b3923066379ecd774e886da2abed73 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:59:44 +0200 Subject: [PATCH 14/26] Enable slither --- .../workflows/sharing-smart-contract-test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index 5d1b5dee1..d874d1dbd 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -55,14 +55,14 @@ jobs: working-directory: packages/sharing-smart-contract run: npm run uml - # - name: Static Analyzer - # uses: crytic/slither-action@v0.4.0 - # id: slither - # with: - # sarif: result.sarif - # fail-on: none - # target: 'packages/sharing-smart-contract/' - # slither-config: 'packages/sharing-smart-contract/slither.config.json' + - name: Static Analyzer + uses: crytic/slither-action@v0.4.0 + id: slither + with: + sarif: result.sarif + fail-on: none + target: 'packages/sharing-smart-contract/' + slither-config: 'packages/sharing-smart-contract/slither.config.json' - name: Start Anvil run: | From dfb39c957920985557e4ea5db5dc53d046b26a52 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:01:50 +0200 Subject: [PATCH 15/26] Update abis --- .../abis/interfaces/IPoCo.sol/IPoCo.json | 534 ------------------ 1 file changed, 534 deletions(-) diff --git a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json index 2bc50eee6..a63a85ae6 100644 --- a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json +++ b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json @@ -1,189 +1,4 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - } - ], - "name": "ClosedAppOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - } - ], - "name": "ClosedDatasetOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - } - ], - "name": "ClosedRequestOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - } - ], - "name": "ClosedWorkerpoolOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "dealId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sponsor", - "type": "address" - } - ], - "name": "DealSponsored", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "dealid", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "volume", - "type": "uint256" - } - ], - "name": "OrdersMatched", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "dealid", - "type": "bytes32" - } - ], - "name": "SchedulerNotice", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - } - ], - "name": "SignedAppOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - } - ], - "name": "SignedDatasetOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - } - ], - "name": "SignedRequestOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - } - ], - "name": "SignedWorkerpoolOrder", - "type": "event" - }, { "inputs": [ { @@ -913,273 +728,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "app", - "type": "address" - }, - { - "internalType": "uint256", - "name": "appprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "datasetrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "workerpoolrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "dataset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "datasetprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "apprestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "workerpoolrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "workerpoolprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "category", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "trust", - "type": "uint256" - }, - { - "internalType": "address", - "name": "apprestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "datasetrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "app", - "type": "address" - }, - { - "internalType": "uint256", - "name": "appmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "dataset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "datasetmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "workerpoolmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "requester", - "type": "address" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "category", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "trust", - "type": "uint256" - }, - { - "internalType": "address", - "name": "beneficiary", - "type": "address" - }, - { - "internalType": "address", - "name": "callback", - "type": "address" - }, - { - "internalType": "string", - "name": "params", - "type": "string" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "", - "type": "tuple" - } - ], - "name": "sponsorMatchOrders", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -1208,87 +756,5 @@ ], "stateMutability": "nonpayable", "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "verifyPresignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "verifyPresignatureOrSignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "verifySignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" } ] \ No newline at end of file From c4e15f6908b82c5e6d1995060352e2df0b09595a Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:04:43 +0200 Subject: [PATCH 16/26] Update abis --- .../sharing/interfaces/IPoCo.sol/IPoCo.json | 534 ------------------ 1 file changed, 534 deletions(-) diff --git a/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json index 2bc50eee6..a63a85ae6 100644 --- a/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json +++ b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json @@ -1,189 +1,4 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - } - ], - "name": "ClosedAppOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - } - ], - "name": "ClosedDatasetOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - } - ], - "name": "ClosedRequestOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - } - ], - "name": "ClosedWorkerpoolOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "dealId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "sponsor", - "type": "address" - } - ], - "name": "DealSponsored", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "dealid", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "volume", - "type": "uint256" - } - ], - "name": "OrdersMatched", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "dealid", - "type": "bytes32" - } - ], - "name": "SchedulerNotice", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "appHash", - "type": "bytes32" - } - ], - "name": "SignedAppOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "datasetHash", - "type": "bytes32" - } - ], - "name": "SignedDatasetOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "requestHash", - "type": "bytes32" - } - ], - "name": "SignedRequestOrder", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "workerpoolHash", - "type": "bytes32" - } - ], - "name": "SignedWorkerpoolOrder", - "type": "event" - }, { "inputs": [ { @@ -913,273 +728,6 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "components": [ - { - "internalType": "address", - "name": "app", - "type": "address" - }, - { - "internalType": "uint256", - "name": "appprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "datasetrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "workerpoolrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "dataset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "datasetprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "apprestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "workerpoolrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "workerpoolprice", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "category", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "trust", - "type": "uint256" - }, - { - "internalType": "address", - "name": "apprestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "datasetrestrict", - "type": "address" - }, - { - "internalType": "address", - "name": "requesterrestrict", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "address", - "name": "app", - "type": "address" - }, - { - "internalType": "uint256", - "name": "appmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "dataset", - "type": "address" - }, - { - "internalType": "uint256", - "name": "datasetmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "workerpool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "workerpoolmaxprice", - "type": "uint256" - }, - { - "internalType": "address", - "name": "requester", - "type": "address" - }, - { - "internalType": "uint256", - "name": "volume", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "tag", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "category", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "trust", - "type": "uint256" - }, - { - "internalType": "address", - "name": "beneficiary", - "type": "address" - }, - { - "internalType": "address", - "name": "callback", - "type": "address" - }, - { - "internalType": "string", - "name": "params", - "type": "string" - }, - { - "internalType": "bytes32", - "name": "salt", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "sign", - "type": "bytes" - } - ], - "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "", - "type": "tuple" - } - ], - "name": "sponsorMatchOrders", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -1208,87 +756,5 @@ ], "stateMutability": "nonpayable", "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "verifyPresignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "verifyPresignatureOrSignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "name": "verifySignature", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" } ] \ No newline at end of file From f53b50fbda9c035b2884f76841953010c3944bec Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:05:52 +0200 Subject: [PATCH 17/26] Run formatter --- packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index 854a22a02..25ffd593f 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -21,7 +21,6 @@ pragma solidity ^0.8.24; // TODO import interfaces (IexecOrderManagement, IexecPoco1, ...) from @iexec/poco. interface IPoCo { - // IexecEscrowNative function deposit() external payable returns (bool); // Native mode From 7d49da1286da9f9d8e80e34399673df87ad9e67f Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:42:06 +0200 Subject: [PATCH 18/26] Clean changes --- .../workflows/sharing-smart-contract-test.yml | 1 - .../contracts/interfaces/IPoCo.sol | 18 +++++++++--------- .../sharing-smart-contract/slither.config.json | 3 --- .../test/SupportsInterface.t.sol | 4 +++- 4 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 packages/sharing-smart-contract/slither.config.json diff --git a/.github/workflows/sharing-smart-contract-test.yml b/.github/workflows/sharing-smart-contract-test.yml index d874d1dbd..ea7cf3922 100644 --- a/.github/workflows/sharing-smart-contract-test.yml +++ b/.github/workflows/sharing-smart-contract-test.yml @@ -62,7 +62,6 @@ jobs: sarif: result.sarif fail-on: none target: 'packages/sharing-smart-contract/' - slither-config: 'packages/sharing-smart-contract/slither.config.json' - name: Start Anvil run: | diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index 25ffd593f..70443f387 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -29,7 +29,7 @@ interface IPoCo { // function deposit(uint256) external returns (bool); // Token mode // IexecERC20 - function approve(address spender, uint256 amount) external returns (bool); + function approve(address spender, uint256 value) external returns (bool); function approveAndCall( address spender, uint256 value, @@ -44,17 +44,17 @@ interface IPoCo { function allowance(address owner, address spender) external view returns (uint256); // IexecOrderManagement - function manageAppOrder(IexecLibOrders_v5.AppOrderOperation calldata) external; - function manageDatasetOrder(IexecLibOrders_v5.DatasetOrderOperation calldata) external; - function manageWorkerpoolOrder(IexecLibOrders_v5.WorkerpoolOrderOperation calldata) external; - function manageRequestOrder(IexecLibOrders_v5.RequestOrderOperation calldata) external; + function manageAppOrder(IexecLibOrders_v5.AppOrderOperation calldata operation) external; + function manageDatasetOrder(IexecLibOrders_v5.DatasetOrderOperation calldata operation) external; + function manageWorkerpoolOrder(IexecLibOrders_v5.WorkerpoolOrderOperation calldata operation) external; + function manageRequestOrder(IexecLibOrders_v5.RequestOrderOperation calldata operation) external; // IexecPoco1 function matchOrders( - IexecLibOrders_v5.AppOrder calldata, - IexecLibOrders_v5.DatasetOrder calldata, - IexecLibOrders_v5.WorkerpoolOrder calldata, - IexecLibOrders_v5.RequestOrder calldata + IexecLibOrders_v5.AppOrder calldata appOrder, + IexecLibOrders_v5.DatasetOrder calldata datasetOrder, + IexecLibOrders_v5.WorkerpoolOrder calldata workerpoolOrder, + IexecLibOrders_v5.RequestOrder calldata requestOrder ) external returns (bytes32); } diff --git a/packages/sharing-smart-contract/slither.config.json b/packages/sharing-smart-contract/slither.config.json deleted file mode 100644 index c91798545..000000000 --- a/packages/sharing-smart-contract/slither.config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "solc_remaps": "@=node_modules/@" -} diff --git a/packages/sharing-smart-contract/test/SupportsInterface.t.sol b/packages/sharing-smart-contract/test/SupportsInterface.t.sol index f870a8c03..b0fc8a99f 100644 --- a/packages/sharing-smart-contract/test/SupportsInterface.t.sol +++ b/packages/sharing-smart-contract/test/SupportsInterface.t.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 + pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; @@ -14,7 +16,7 @@ contract SupportsInterface is Test { function setUp() external { _dataProtectorSharing = new DataProtectorSharing( - IPoCo(address(0)), + address(0), IRegistry(address(0)), AddOnlyAppWhitelistRegistry(address(0)) ); From 5348ed7af427665ea4f227cbb41857bb48594277 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:43:12 +0200 Subject: [PATCH 19/26] Regenerate abis --- .../abis/interfaces/IPoCo.sol/IPoCo.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json index a63a85ae6..4b5b46465 100644 --- a/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json +++ b/packages/sharing-smart-contract/abis/interfaces/IPoCo.sol/IPoCo.json @@ -32,7 +32,7 @@ }, { "internalType": "uint256", - "name": "amount", + "name": "value", "type": "uint256" } ], @@ -176,7 +176,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -253,7 +253,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -365,7 +365,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -452,7 +452,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -512,7 +512,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "", + "name": "appOrder", "type": "tuple" }, { @@ -564,7 +564,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "", + "name": "datasetOrder", "type": "tuple" }, { @@ -626,7 +626,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "", + "name": "workerpoolOrder", "type": "tuple" }, { @@ -713,7 +713,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "", + "name": "requestOrder", "type": "tuple" } ], From 19dc226b90921ee076a50877aa02194dd9cb3773 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:45:00 +0200 Subject: [PATCH 20/26] Regenerate abis --- .../sharing/interfaces/IPoCo.sol/IPoCo.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json index a63a85ae6..4b5b46465 100644 --- a/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json +++ b/packages/sdk/abis/sharing/interfaces/IPoCo.sol/IPoCo.json @@ -32,7 +32,7 @@ }, { "internalType": "uint256", - "name": "amount", + "name": "value", "type": "uint256" } ], @@ -176,7 +176,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -253,7 +253,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -365,7 +365,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -452,7 +452,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrderOperation", - "name": "", + "name": "operation", "type": "tuple" } ], @@ -512,7 +512,7 @@ } ], "internalType": "struct IexecLibOrders_v5.AppOrder", - "name": "", + "name": "appOrder", "type": "tuple" }, { @@ -564,7 +564,7 @@ } ], "internalType": "struct IexecLibOrders_v5.DatasetOrder", - "name": "", + "name": "datasetOrder", "type": "tuple" }, { @@ -626,7 +626,7 @@ } ], "internalType": "struct IexecLibOrders_v5.WorkerpoolOrder", - "name": "", + "name": "workerpoolOrder", "type": "tuple" }, { @@ -713,7 +713,7 @@ } ], "internalType": "struct IexecLibOrders_v5.RequestOrder", - "name": "", + "name": "requestOrder", "type": "tuple" } ], From 2d6c0dd6302b94bb2c5776b4900fd287a2a00af1 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:48:03 +0200 Subject: [PATCH 21/26] Format --- .../contracts/interfaces/IPoCo.sol | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol index 70443f387..96e22deac 100644 --- a/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol +++ b/packages/sharing-smart-contract/contracts/interfaces/IPoCo.sol @@ -45,9 +45,15 @@ interface IPoCo { // IexecOrderManagement function manageAppOrder(IexecLibOrders_v5.AppOrderOperation calldata operation) external; - function manageDatasetOrder(IexecLibOrders_v5.DatasetOrderOperation calldata operation) external; - function manageWorkerpoolOrder(IexecLibOrders_v5.WorkerpoolOrderOperation calldata operation) external; - function manageRequestOrder(IexecLibOrders_v5.RequestOrderOperation calldata operation) external; + function manageDatasetOrder( + IexecLibOrders_v5.DatasetOrderOperation calldata operation + ) external; + function manageWorkerpoolOrder( + IexecLibOrders_v5.WorkerpoolOrderOperation calldata operation + ) external; + function manageRequestOrder( + IexecLibOrders_v5.RequestOrderOperation calldata operation + ) external; // IexecPoco1 function matchOrders( From bbee490801c4bf1a1f687ca10c0eebc1ae443071 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:55:38 +0200 Subject: [PATCH 22/26] Fix invariant tests --- .../test/invariant/handlers/HandlerGlobal.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol index 37434c5da..5f9f3c62e 100644 --- a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol +++ b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol @@ -13,7 +13,7 @@ import {GhostStorage} from "./GhostStorage.sol"; contract HandlerGlobal is Test, GhostStorage { // ---------------------State Variables------------------------------------ // TODO remove hardcoded values to make tests compatible with any chain. - IPoCo public constant POCO_DELEGATE = IPoCo(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); + IPoCo public constant POCO_DELEGATE = 0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f; IRegistry public constant POCO_PROTECTED_DATA_REGISTRY = IRegistry(0x799DAa22654128d0C64d5b79eac9283008158730); IDataProtector public constant DATA_PROTECTOR_CORE = @@ -26,7 +26,7 @@ contract HandlerGlobal is Test, GhostStorage { constructor() { address admin = address(54321); vm.label(admin, "admin"); - vm.label(address(POCO_DELEGATE), "pocoDelegate"); + vm.label(POCO_DELEGATE, "pocoDelegate"); vm.label(address(POCO_PROTECTED_DATA_REGISTRY), "protectedDataRegistry"); AddOnlyAppWhitelistRegistry appWhitelistImpl = new AddOnlyAppWhitelistRegistry(); From a9e2cd4e6ce727bb3ccc0e6acc1bf85fcd0e401c Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:45:35 +0200 Subject: [PATCH 23/26] Fix type --- .../test/invariant/handlers/HandlerGlobal.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol index 5f9f3c62e..43e184c11 100644 --- a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol +++ b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol @@ -13,7 +13,7 @@ import {GhostStorage} from "./GhostStorage.sol"; contract HandlerGlobal is Test, GhostStorage { // ---------------------State Variables------------------------------------ // TODO remove hardcoded values to make tests compatible with any chain. - IPoCo public constant POCO_DELEGATE = 0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f; + address public constant POCO_DELEGATE = 0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f; IRegistry public constant POCO_PROTECTED_DATA_REGISTRY = IRegistry(0x799DAa22654128d0C64d5b79eac9283008158730); IDataProtector public constant DATA_PROTECTOR_CORE = From 329e8dedf76604750ae02998f389106230c55866 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:52:16 +0200 Subject: [PATCH 24/26] Fix --- .../test/invariant/handlers/HandlerGlobal.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol index 43e184c11..e3804386f 100644 --- a/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol +++ b/packages/sharing-smart-contract/test/invariant/handlers/HandlerGlobal.sol @@ -13,7 +13,7 @@ import {GhostStorage} from "./GhostStorage.sol"; contract HandlerGlobal is Test, GhostStorage { // ---------------------State Variables------------------------------------ // TODO remove hardcoded values to make tests compatible with any chain. - address public constant POCO_DELEGATE = 0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f; + IPoCo public constant POCO_DELEGATE = IPoCo(0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f); IRegistry public constant POCO_PROTECTED_DATA_REGISTRY = IRegistry(0x799DAa22654128d0C64d5b79eac9283008158730); IDataProtector public constant DATA_PROTECTOR_CORE = @@ -26,7 +26,7 @@ contract HandlerGlobal is Test, GhostStorage { constructor() { address admin = address(54321); vm.label(admin, "admin"); - vm.label(POCO_DELEGATE, "pocoDelegate"); + vm.label(address(POCO_DELEGATE), "pocoDelegate"); vm.label(address(POCO_PROTECTED_DATA_REGISTRY), "protectedDataRegistry"); AddOnlyAppWhitelistRegistry appWhitelistImpl = new AddOnlyAppWhitelistRegistry(); @@ -37,7 +37,7 @@ contract HandlerGlobal is Test, GhostStorage { addOnlyAppWhitelistRegistry.initialize(); DataProtectorSharing dataProtectorSharingImpl = new DataProtectorSharing( - POCO_DELEGATE, + address(POCO_DELEGATE), POCO_PROTECTED_DATA_REGISTRY, addOnlyAppWhitelistRegistry ); From bd91318b1e92029b248d1f40459dc21845644cd1 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 14:23:25 +0200 Subject: [PATCH 25/26] Update changelog --- .github/workflows/root-checks.yaml | 2 +- packages/sharing-smart-contract/CHANGELOG.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/root-checks.yaml b/.github/workflows/root-checks.yaml index 08a27ccd3..148d203d4 100644 --- a/.github/workflows/root-checks.yaml +++ b/.github/workflows/root-checks.yaml @@ -44,4 +44,4 @@ jobs: working-directory: ${{ matrix.package }} run: | npm run refresh-abis - # TODO add npm run build here. + # TODO check that SDK and Subgraph projects build is OK. diff --git a/packages/sharing-smart-contract/CHANGELOG.md b/packages/sharing-smart-contract/CHANGELOG.md index 202c8c0e4..8a9f1d845 100644 --- a/packages/sharing-smart-contract/CHANGELOG.md +++ b/packages/sharing-smart-contract/CHANGELOG.md @@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file. ### Changed -- update blockscout url +- Fix Sharing contract constructor arguments order (#433) +- Update blockscout url ## [2.0.0] From dbe3b7311c8c914586a016d84668cf2e3a98c908 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Tue, 29 Apr 2025 16:07:47 +0200 Subject: [PATCH 26/26] Clean imports --- packages/sharing-smart-contract/test/SupportsInterface.t.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sharing-smart-contract/test/SupportsInterface.t.sol b/packages/sharing-smart-contract/test/SupportsInterface.t.sol index b0fc8a99f..c1b5443e8 100644 --- a/packages/sharing-smart-contract/test/SupportsInterface.t.sol +++ b/packages/sharing-smart-contract/test/SupportsInterface.t.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; import {DataProtectorSharing} from "../contracts/DataProtectorSharing.sol"; -import {IPoCo} from "../contracts/interfaces/IPoCo.sol"; import {AddOnlyAppWhitelistRegistry} from "../contracts/registry/AddOnlyAppWhitelistRegistry.sol"; import {IRegistry} from "../contracts/interfaces/IRegistry.sol"; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";