forked from sherlock-audit/2023-04-splits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WalletImpl.sol
66 lines (52 loc) · 1.87 KB
/
WalletImpl.sol
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
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
import {OwnableImpl} from "./OwnableImpl.sol";
/// @title Wallet Implementation
/// @author 0xSplits
/// @notice Minimal smart wallet clone-implementation
abstract contract WalletImpl is OwnableImpl {
struct Call {
address to;
uint256 value;
bytes data;
}
event ExecCalls(Call[] calls);
/// -----------------------------------------------------------------------
/// storage - mutables
/// -----------------------------------------------------------------------
/// slot 0 - 12 bytes free
/// OwnableImpl storage
/// address internal $owner;
/// 20 bytes
/// -----------------------------------------------------------------------
/// constructor & initializer
/// -----------------------------------------------------------------------
constructor() {}
function __initWallet(address owner_) internal {
OwnableImpl.__initOwnable(owner_);
}
/// -----------------------------------------------------------------------
/// functions - external & public - onlyOwner
/// -----------------------------------------------------------------------
/// allow owner to execute arbitrary calls
function execCalls(Call[] calldata calls_)
external
payable
onlyOwner
returns (uint256 blockNumber, bytes[] memory returnData)
{
blockNumber = block.number;
uint256 length = calls_.length;
returnData = new bytes[](length);
bool success;
for (uint256 i; i < length;) {
Call calldata calli = calls_[i];
(success, returnData[i]) = calli.to.call{value: calli.value}(calli.data);
require(success, string(returnData[i]));
unchecked {
++i;
}
}
emit ExecCalls(calls_);
}
}