-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMultiCallDeployV3.sol
More file actions
74 lines (65 loc) · 2.74 KB
/
MultiCallDeployV3.sol
File metadata and controls
74 lines (65 loc) · 2.74 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.17;
import "./interfaces/IFactory.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
/**
* @notice Interface for V3 wallet execute function
*/
interface IV3Wallet {
function execute(bytes calldata _payload, bytes calldata _signature) external;
}
/**
* @title MultiCallDeployV3
* @notice Contract for deploying and executing transactions on V3 wallets
* @dev V3 version that accepts bytes payload instead of Transaction[]
*/
contract MultiCallDeployV3 is AccessControl {
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
/**
* @notice Constructor
* @param _admin address with admin role
* @param _executor address with executor role
*/
constructor(address _admin, address _executor) {
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(EXECUTOR_ROLE, _executor);
}
/**
* @notice Deploy wallet, upgrade it to Stage 2, then execute user transaction *
* @param cfa counter factual address of the wallet
* @param _mainModule Address of the main module to be used by the wallet
* @param _salt Salt used to generate the address (should be final imageHash)
* @param factory address of the factory contract
* @param _bootstrapPayload V3 encoded payload containing updateImageHash transaction (always required)
* @param _bootstrapSignature Immutable-only signature for bootstrap (always required)
* @param _userPayload V3 encoded payload containing user's transaction
* @param _userSignature EOA + Immutable signature for user transaction
*/
function deployBootstrapAndExecute(
address cfa,
address _mainModule,
bytes32 _salt,
address factory,
bytes calldata _bootstrapPayload,
bytes calldata _bootstrapSignature // TODO not used after wallet is deployed, to improve
bytes calldata _userPayload,
bytes calldata _userSignature
) external onlyRole(EXECUTOR_ROLE) {
// Get code size at CFA
uint32 size;
assembly {
size := extcodesize(cfa)
}
if (size == 0) {
// 1. Deploy wallet
address wallet = IFactory(factory).deploy(_mainModule, _salt);
require(cfa == wallet, "MultiCallDeployV3: deployed address does not match CFA");
// 2. Bootstrap transaction (updateImageHash) - signed by Immutable-only
IV3Wallet(wallet).execute(_bootstrapPayload, _bootstrapSignature);
// 3. Actual transaction - signed by EOA + Immutable
IV3Wallet(wallet).execute(_userPayload, _userSignature);
} else {
IV3Wallet(cfa).execute(_userPayload, _userSignature);
}
}
}