-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathWorkerpoolRegistry.sol
More file actions
59 lines (52 loc) · 1.85 KB
/
WorkerpoolRegistry.sol
File metadata and controls
59 lines (52 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <contact@iex.ec>
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "../Registry.sol";
import "./Workerpool.sol";
/**
* @dev Referenced in the SDK with the current path `contracts/registries/workerpools/WorkerpoolRegistry.sol`.
* Changing the name or the path would cause a breaking change in the SDK.
*/
contract WorkerpoolRegistry is Registry {
/**
* Constructor
*/
constructor()
Registry(address(new Workerpool()), "iExec Workerpool Registry (V5)", "iExecWorkerpoolV5")
{}
/**
* Pool creation
*/
function encodeInitializer(
string memory _workerpoolDescription
) internal pure returns (bytes memory) {
return abi.encodeWithSignature("initialize(string)", _workerpoolDescription);
}
function createWorkerpool(
address _workerpoolOwner,
string calldata _workerpoolDescription
) external returns (Workerpool) {
// TEMPORARY MIGRATION FIX: Catch Create2 custom error and throw string error for backward compatibility
// TODO: Remove this in the next major version
try
this.internal_mintCreate(_workerpoolOwner, encodeInitializer(_workerpoolDescription))
returns (address entry) {
return Workerpool(entry);
} catch {
revert("Create2: Failed on deploy");
}
}
function internal_mintCreate(
address _workerpoolOwner,
bytes memory _args
) external returns (address) {
return _mintCreate(_workerpoolOwner, _args);
}
function predictWorkerpool(
address _workerpoolOwner,
string calldata _workerpoolDescription
) external view returns (Workerpool) {
return
Workerpool(_mintPredict(_workerpoolOwner, encodeInitializer(_workerpoolDescription)));
}
}