-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGuestModule.sol
More file actions
117 lines (101 loc) · 3.28 KB
/
GuestModule.sol
File metadata and controls
117 lines (101 loc) · 3.28 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.27;
import "../utils/SignatureValidator.sol";
import "./commons/Implementation.sol";
import "./commons/ModuleAuth.sol";
import "./commons/ModuleHooks.sol";
import "./commons/ModuleCalls.sol";
import "./commons/ModuleUpdate.sol";
import "./commons/ModuleCreator.sol";
import "../interfaces/receivers/IERC1155Receiver.sol";
import "../interfaces/receivers/IERC721Receiver.sol";
import "../interfaces/IERC1271Wallet.sol";
/**
* GuestModule implements an Arcadeum wallet without signatures, nonce or replay protection.
* executing transactions using this wallet is not an authenticated process, and can be done by any address.
*
* @notice This contract is completely public with no security, designed to execute pre-signed transactions
* and use Arcadeum tools without using the wallets.
*/
contract GuestModule is
ModuleAuth,
ModuleCalls,
ModuleCreator
{
/**
* @notice Allow any caller to execute an action
* @param _txs Transactions to process
*/
function execute(
Transaction[] memory _txs,
uint256,
bytes memory
) public override {
// Hash transaction bundle
bytes32 txHash = _subDigest(keccak256(abi.encode('guest:', _txs)));
// Execute the transactions
_executeGuest(txHash, _txs);
}
/**
* @notice Allow any caller to execute an action
* @param _txs Transactions to process
*/
function selfExecute(
Transaction[] memory _txs
) public override {
// Hash transaction bundle
bytes32 txHash = _subDigest(keccak256(abi.encode('self:', _txs)));
// Execute the transactions
_executeGuest(txHash, _txs);
}
/**
* @notice Executes a list of transactions
* @param _txHash Hash of the batch of transactions
* @param _txs Transactions to execute
*/
function _executeGuest(
bytes32 _txHash,
Transaction[] memory _txs
) private {
// Execute transaction
for (uint256 i = 0; i < _txs.length; i++) {
Transaction memory transaction = _txs[i];
bool success;
bytes memory result;
require(!transaction.delegateCall, 'GuestModule#_executeGuest: delegateCall not allowed');
require(gasleft() >= transaction.gasLimit, "GuestModule#_executeGuest: NOT_ENOUGH_GAS");
// solhint-disable
(success, result) = transaction.target.call{
value: transaction.value,
gas: transaction.gasLimit == 0 ? gasleft() : transaction.gasLimit
}(transaction.data);
// solhint-enable
if (success) {
emit TxExecuted(_txHash);
} else {
_revertBytes(transaction, _txHash, result);
}
}
}
/**
* @notice Validates any signature image, because the wallet is public and has now owner.
* @return true, all signatures are valid, false, no updates required
*/
function _isValidImage(bytes32) internal override view returns (bool, bool) {
return (true, false);
}
/**
* @notice Query if a contract implements an interface
* @param _interfaceID The interface identifier, as specified in ERC-165
* @return `true` if the contract implements `_interfaceID`
*/
function supportsInterface(
bytes4 _interfaceID
) public override (
ModuleAuth,
ModuleCalls,
ModuleCreator
) pure returns (bool) {
return super.supportsInterface(_interfaceID);
}
}