@gnosis-guild/zodiac 4.2.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +107 -4
  2. package/dist/cjs/abis/bridge/1.0.0.js +385 -0
  3. package/dist/cjs/abis/circulatingSupplyERC20/1.0.0.js +248 -0
  4. package/dist/cjs/abis/circulatingSupplyERC20/1.1.0.js +248 -0
  5. package/dist/cjs/abis/circulatingSupplyERC20/1.2.0.js +248 -0
  6. package/dist/cjs/abis/circulatingSupplyERC721/1.1.0.js +248 -0
  7. package/dist/cjs/abis/circulatingSupplyERC721/1.2.0.js +248 -0
  8. package/dist/cjs/abis/connext/1.0.0.js +496 -0
  9. package/dist/cjs/abis/delay/1.0.0.js +731 -0
  10. package/dist/cjs/abis/delay/1.0.1.js +731 -0
  11. package/dist/cjs/abis/delay/1.1.0.js +941 -0
  12. package/dist/cjs/abis/delay/1.1.1.js +941 -0
  13. package/dist/cjs/abis/erc20Votes/1.0.0.js +800 -0
  14. package/dist/cjs/abis/erc721Votes/1.0.0.js +795 -0
  15. package/dist/cjs/abis/exit/1.0.0.js +403 -0
  16. package/dist/cjs/abis/exit/1.1.0.js +422 -0
  17. package/dist/cjs/abis/exit/1.2.0.js +422 -0
  18. package/dist/cjs/abis/exitERC721/1.1.0.js +422 -0
  19. package/dist/cjs/abis/exitERC721/1.2.0.js +422 -0
  20. package/dist/cjs/abis/factory/1.0.0.js +53 -0
  21. package/dist/cjs/abis/factory/1.1.0.js +80 -0
  22. package/dist/cjs/abis/factory/1.2.0.js +91 -0
  23. package/dist/cjs/abis/index.js +101 -0
  24. package/dist/cjs/abis/metaGuard/1.0.0.js +474 -0
  25. package/dist/cjs/abis/multisendEncoder/1.0.0.js +64 -0
  26. package/dist/cjs/abis/ozGovernor/1.0.0.js +1066 -0
  27. package/dist/cjs/abis/realityERC20/2.0.0.js +874 -0
  28. package/dist/cjs/abis/realityETH/2.0.0.js +874 -0
  29. package/dist/cjs/abis/roles/1.0.0.js +993 -0
  30. package/dist/cjs/abis/roles/1.1.0.js +993 -0
  31. package/dist/cjs/abis/roles/2.1.0.js +1411 -0
  32. package/dist/cjs/abis/roles/2.1.1.js +1411 -0
  33. package/dist/cjs/abis/scopeGuard/1.0.0.js +595 -0
  34. package/dist/cjs/contracts.js +145 -0
  35. package/dist/cjs/explorer.js +264 -0
  36. package/dist/cjs/extract.js +117 -0
  37. package/dist/cjs/index.js +16 -0
  38. package/dist/cjs/mastercopies.js +34 -0
  39. package/dist/cjs/networks.js +233 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/rpc.js +36 -0
  42. package/dist/cjs/singleton.js +42 -0
  43. package/dist/cjs/types.js +7 -0
  44. package/dist/cjs/ui.js +64 -0
  45. package/dist/cjs/zodiacModule.js +61 -0
  46. package/dist/esm/abis/bridge/1.0.0.d.ts +297 -0
  47. package/dist/esm/abis/bridge/1.0.0.js +382 -0
  48. package/dist/esm/abis/circulatingSupplyERC20/1.0.0.d.ts +188 -0
  49. package/dist/esm/abis/circulatingSupplyERC20/1.0.0.js +245 -0
  50. package/dist/esm/abis/circulatingSupplyERC20/1.1.0.d.ts +188 -0
  51. package/dist/esm/abis/circulatingSupplyERC20/1.1.0.js +245 -0
  52. package/dist/esm/abis/circulatingSupplyERC20/1.2.0.d.ts +188 -0
  53. package/dist/esm/abis/circulatingSupplyERC20/1.2.0.js +245 -0
  54. package/dist/esm/abis/circulatingSupplyERC721/1.1.0.d.ts +188 -0
  55. package/dist/esm/abis/circulatingSupplyERC721/1.1.0.js +245 -0
  56. package/dist/esm/abis/circulatingSupplyERC721/1.2.0.d.ts +188 -0
  57. package/dist/esm/abis/circulatingSupplyERC721/1.2.0.js +245 -0
  58. package/dist/esm/abis/connext/1.0.0.d.ts +383 -0
  59. package/dist/esm/abis/connext/1.0.0.js +493 -0
  60. package/dist/esm/abis/delay/1.0.0.d.ts +562 -0
  61. package/dist/esm/abis/delay/1.0.0.js +728 -0
  62. package/dist/esm/abis/delay/1.0.1.d.ts +562 -0
  63. package/dist/esm/abis/delay/1.0.1.js +728 -0
  64. package/dist/esm/abis/delay/1.1.0.d.ts +720 -0
  65. package/dist/esm/abis/delay/1.1.0.js +938 -0
  66. package/dist/esm/abis/delay/1.1.1.d.ts +720 -0
  67. package/dist/esm/abis/delay/1.1.1.js +938 -0
  68. package/dist/esm/abis/erc20Votes/1.0.0.d.ts +613 -0
  69. package/dist/esm/abis/erc20Votes/1.0.0.js +797 -0
  70. package/dist/esm/abis/erc721Votes/1.0.0.d.ts +610 -0
  71. package/dist/esm/abis/erc721Votes/1.0.0.js +792 -0
  72. package/dist/esm/abis/exit/1.0.0.d.ts +309 -0
  73. package/dist/esm/abis/exit/1.0.0.js +400 -0
  74. package/dist/esm/abis/exit/1.1.0.d.ts +323 -0
  75. package/dist/esm/abis/exit/1.1.0.js +419 -0
  76. package/dist/esm/abis/exit/1.2.0.d.ts +323 -0
  77. package/dist/esm/abis/exit/1.2.0.js +419 -0
  78. package/dist/esm/abis/exitERC721/1.1.0.d.ts +323 -0
  79. package/dist/esm/abis/exitERC721/1.1.0.js +419 -0
  80. package/dist/esm/abis/exitERC721/1.2.0.d.ts +323 -0
  81. package/dist/esm/abis/exitERC721/1.2.0.js +419 -0
  82. package/dist/esm/abis/factory/1.0.0.d.ts +38 -0
  83. package/dist/esm/abis/factory/1.0.0.js +50 -0
  84. package/dist/esm/abis/factory/1.1.0.d.ts +58 -0
  85. package/dist/esm/abis/factory/1.1.0.js +77 -0
  86. package/dist/esm/abis/factory/1.2.0.d.ts +66 -0
  87. package/dist/esm/abis/factory/1.2.0.js +88 -0
  88. package/dist/esm/abis/index.d.ts +13970 -0
  89. package/dist/esm/abis/index.js +98 -0
  90. package/dist/esm/abis/metaGuard/1.0.0.d.ts +363 -0
  91. package/dist/esm/abis/metaGuard/1.0.0.js +471 -0
  92. package/dist/esm/abis/multisendEncoder/1.0.0.d.ts +47 -0
  93. package/dist/esm/abis/multisendEncoder/1.0.0.js +61 -0
  94. package/dist/esm/abis/ozGovernor/1.0.0.d.ts +821 -0
  95. package/dist/esm/abis/ozGovernor/1.0.0.js +1063 -0
  96. package/dist/esm/abis/realityERC20/2.0.0.d.ts +674 -0
  97. package/dist/esm/abis/realityERC20/2.0.0.js +871 -0
  98. package/dist/esm/abis/realityETH/2.0.0.d.ts +674 -0
  99. package/dist/esm/abis/realityETH/2.0.0.js +871 -0
  100. package/dist/esm/abis/roles/1.0.0.d.ts +770 -0
  101. package/dist/esm/abis/roles/1.0.0.js +990 -0
  102. package/dist/esm/abis/roles/1.1.0.d.ts +770 -0
  103. package/dist/esm/abis/roles/1.1.0.js +990 -0
  104. package/dist/esm/abis/roles/2.1.0.d.ts +1094 -0
  105. package/dist/esm/abis/roles/2.1.0.js +1408 -0
  106. package/dist/esm/abis/roles/2.1.1.d.ts +1094 -0
  107. package/dist/esm/abis/roles/2.1.1.js +1408 -0
  108. package/dist/esm/abis/scopeGuard/1.0.0.d.ts +457 -0
  109. package/dist/esm/abis/scopeGuard/1.0.0.js +592 -0
  110. package/dist/esm/contracts.d.ts +66 -0
  111. package/dist/esm/contracts.js +142 -0
  112. package/dist/esm/explorer.d.ts +81 -0
  113. package/dist/esm/explorer.js +256 -0
  114. package/dist/esm/extract.d.ts +15 -0
  115. package/dist/esm/extract.js +114 -0
  116. package/dist/esm/index.d.ts +3 -0
  117. package/dist/esm/index.js +3 -0
  118. package/dist/esm/mastercopies.d.ts +21 -0
  119. package/dist/esm/mastercopies.js +27 -0
  120. package/dist/esm/networks.d.ts +37 -0
  121. package/dist/esm/networks.js +229 -0
  122. package/dist/esm/package.json +1 -0
  123. package/dist/esm/rpc.d.ts +6 -0
  124. package/dist/esm/rpc.js +33 -0
  125. package/dist/esm/singleton.d.ts +24 -0
  126. package/dist/esm/singleton.js +38 -0
  127. package/dist/esm/types.d.ts +43 -0
  128. package/dist/esm/types.js +6 -0
  129. package/dist/esm/ui.d.ts +16 -0
  130. package/dist/esm/ui.js +53 -0
  131. package/dist/esm/zodiacModule.d.ts +4 -0
  132. package/dist/esm/zodiacModule.js +56 -0
  133. package/package.json +29 -74
  134. package/contracts/core/GuardableModifier.sol +0 -96
  135. package/contracts/core/GuardableModule.sol +0 -95
  136. package/contracts/core/Modifier.sol +0 -204
  137. package/contracts/core/Module.sol +0 -73
  138. package/contracts/factory/FactoryFriendly.sol +0 -10
  139. package/contracts/factory/ModuleProxyFactory.sol +0 -51
  140. package/contracts/guard/BaseGuard.sol +0 -36
  141. package/contracts/guard/Guardable.sol +0 -32
  142. package/contracts/interfaces/IAvatar.sol +0 -71
  143. package/contracts/interfaces/IGuard.sol +0 -22
  144. package/contracts/signature/ExecutionTracker.sol +0 -17
  145. package/contracts/signature/IERC1271.sol +0 -19
  146. package/contracts/signature/SignatureChecker.sol +0 -154
  147. package/contracts/test/TestAvatar.sol +0 -64
  148. package/contracts/test/TestGuard.sol +0 -82
  149. package/contracts/test/TestGuardableModifier.sol +0 -82
  150. package/contracts/test/TestModifier.sol +0 -88
  151. package/contracts/test/TestModule.sol +0 -66
  152. package/contracts/test/TestSignature.sol +0 -71
  153. package/dist/index.d.mts +0 -16332
  154. package/dist/index.d.ts +0 -16332
  155. package/dist/index.js +0 -24880
  156. package/dist/index.js.map +0 -1
  157. package/dist/index.mjs +0 -24845
  158. package/dist/index.mjs.map +0 -1
@@ -1,36 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.7.0 <0.9.0;
3
-
4
- import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
5
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
-
7
- import {IGuard} from "../interfaces/IGuard.sol";
8
-
9
- abstract contract BaseGuard is IERC165 {
10
- function supportsInterface(
11
- bytes4 interfaceId
12
- ) external pure override returns (bool) {
13
- return
14
- interfaceId == type(IGuard).interfaceId || // 0xe6d7a83a
15
- interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7
16
- }
17
-
18
- /// @dev Module transactions only use the first four parameters: to, value, data, and operation.
19
- /// Module.sol hardcodes the remaining parameters as 0 since they are not used for module transactions.
20
- /// @notice This interface is used to maintain compatibilty with Gnosis Safe transaction guards.
21
- function checkTransaction(
22
- address to,
23
- uint256 value,
24
- bytes memory data,
25
- Enum.Operation operation,
26
- uint256 safeTxGas,
27
- uint256 baseGas,
28
- uint256 gasPrice,
29
- address gasToken,
30
- address payable refundReceiver,
31
- bytes memory signatures,
32
- address msgSender
33
- ) external virtual;
34
-
35
- function checkAfterExecution(bytes32 txHash, bool success) external virtual;
36
- }
@@ -1,32 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.7.0 <0.9.0;
3
-
4
- import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
5
-
6
- import {BaseGuard} from "../guard/BaseGuard.sol";
7
- import {IGuard} from "../interfaces/IGuard.sol";
8
-
9
- /// @title Guardable - A contract that manages fallback calls made to this contract
10
- contract Guardable is OwnableUpgradeable {
11
- address public guard;
12
-
13
- event ChangedGuard(address guard);
14
-
15
- /// `guard_` does not implement IERC165.
16
- error NotIERC165Compliant(address guard_);
17
-
18
- /// @dev Set a guard that checks transactions before execution.
19
- /// @param _guard The address of the guard to be used or the 0 address to disable the guard.
20
- function setGuard(address _guard) external onlyOwner {
21
- if (_guard != address(0)) {
22
- if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId))
23
- revert NotIERC165Compliant(_guard);
24
- }
25
- guard = _guard;
26
- emit ChangedGuard(guard);
27
- }
28
-
29
- function getGuard() external view returns (address _guard) {
30
- return guard;
31
- }
32
- }
@@ -1,71 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
-
3
- /// @title Zodiac Avatar - A contract that manages modules that can execute transactions via this contract.
4
- pragma solidity >=0.7.0 <0.9.0;
5
-
6
- import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
7
-
8
- interface IAvatar {
9
- event EnabledModule(address module);
10
- event DisabledModule(address module);
11
- event ExecutionFromModuleSuccess(address indexed module);
12
- event ExecutionFromModuleFailure(address indexed module);
13
-
14
- /// @dev Enables a module on the avatar.
15
- /// @notice Can only be called by the avatar.
16
- /// @notice Modules should be stored as a linked list.
17
- /// @notice Must emit EnabledModule(address module) if successful.
18
- /// @param module Module to be enabled.
19
- function enableModule(address module) external;
20
-
21
- /// @dev Disables a module on the avatar.
22
- /// @notice Can only be called by the avatar.
23
- /// @notice Must emit DisabledModule(address module) if successful.
24
- /// @param prevModule Address that pointed to the module to be removed in the linked list
25
- /// @param module Module to be removed.
26
- function disableModule(address prevModule, address module) external;
27
-
28
- /// @dev Allows a Module to execute a transaction.
29
- /// @notice Can only be called by an enabled module.
30
- /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.
31
- /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.
32
- /// @param to Destination address of module transaction.
33
- /// @param value Ether value of module transaction.
34
- /// @param data Data payload of module transaction.
35
- /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
36
- function execTransactionFromModule(
37
- address to,
38
- uint256 value,
39
- bytes memory data,
40
- Enum.Operation operation
41
- ) external returns (bool success);
42
-
43
- /// @dev Allows a Module to execute a transaction and return data
44
- /// @notice Can only be called by an enabled module.
45
- /// @notice Must emit ExecutionFromModuleSuccess(address module) if successful.
46
- /// @notice Must emit ExecutionFromModuleFailure(address module) if unsuccessful.
47
- /// @param to Destination address of module transaction.
48
- /// @param value Ether value of module transaction.
49
- /// @param data Data payload of module transaction.
50
- /// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
51
- function execTransactionFromModuleReturnData(
52
- address to,
53
- uint256 value,
54
- bytes memory data,
55
- Enum.Operation operation
56
- ) external returns (bool success, bytes memory returnData);
57
-
58
- /// @dev Returns if an module is enabled
59
- /// @return True if the module is enabled
60
- function isModuleEnabled(address module) external view returns (bool);
61
-
62
- /// @dev Returns array of modules.
63
- /// @param start Start of the page.
64
- /// @param pageSize Maximum number of modules that should be returned.
65
- /// @return array Array of modules.
66
- /// @return next Start of the next page.
67
- function getModulesPaginated(
68
- address start,
69
- uint256 pageSize
70
- ) external view returns (address[] memory array, address next);
71
- }
@@ -1,22 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.7.0 <0.9.0;
3
-
4
- import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
5
-
6
- interface IGuard {
7
- function checkTransaction(
8
- address to,
9
- uint256 value,
10
- bytes memory data,
11
- Enum.Operation operation,
12
- uint256 safeTxGas,
13
- uint256 baseGas,
14
- uint256 gasPrice,
15
- address gasToken,
16
- address payable refundReceiver,
17
- bytes memory signatures,
18
- address msgSender
19
- ) external;
20
-
21
- function checkAfterExecution(bytes32 txHash, bool success) external;
22
- }
@@ -1,17 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.8.0 <0.9.0;
3
-
4
- /// @title ExecutionTracker - A contract that keeps track of executed and invalidated hashes
5
- contract ExecutionTracker {
6
- error HashAlreadyConsumed(bytes32);
7
-
8
- event HashExecuted(bytes32);
9
- event HashInvalidated(bytes32);
10
-
11
- mapping(address => mapping(bytes32 => bool)) public consumed;
12
-
13
- function invalidate(bytes32 hash) external {
14
- consumed[msg.sender][hash] = true;
15
- emit HashInvalidated(hash);
16
- }
17
- }
@@ -1,19 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- /* solhint-disable one-contract-per-file */
3
- pragma solidity >=0.7.0 <0.9.0;
4
-
5
- interface IERC1271 {
6
- /**
7
- * @notice EIP1271 method to validate a signature.
8
- * @param hash Hash of the data signed on the behalf of address(this).
9
- * @param signature Signature byte array associated with _data.
10
- *
11
- * MUST return the bytes4 magic value 0x1626ba7e when function passes.
12
- * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
13
- * MUST allow external calls
14
- */
15
- function isValidSignature(
16
- bytes32 hash,
17
- bytes memory signature
18
- ) external view returns (bytes4);
19
- }
@@ -1,154 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.8.0 <0.9.0;
3
-
4
- import {IERC1271} from "./IERC1271.sol";
5
-
6
- /// @title SignatureChecker - A contract that retrieves and validates signatures appended to transaction calldata.
7
- /// @dev currently supports eip-712 and eip-1271 signatures
8
- abstract contract SignatureChecker {
9
- /**
10
- * @notice Searches for a signature, validates it, and returns the signer's address.
11
- * @dev When signature not found or invalid, zero address is returned
12
- * @return The address of the signer.
13
- */
14
- function moduleTxSignedBy() internal view returns (bytes32, address) {
15
- bytes calldata data = msg.data;
16
-
17
- /*
18
- * The idea is to extend `onlyModule` and provide signature checking
19
- * without code changes to inheriting contracts (Modifiers).
20
- *
21
- * Since it's a generic mechanism, there is no way to conclusively
22
- * identify the trailing bytes as a signature. We simply slice those
23
- * and recover signer.
24
- *
25
- * As a result, we impose a minimum calldata length equal to a function
26
- * selector plus salt, plus a signature (i.e., 4 + 32 + 65 bytes), any
27
- * shorter and calldata it guaranteed to not contain a signature.
28
- */
29
- if (data.length < 4 + 32 + 65) {
30
- return (bytes32(0), address(0));
31
- }
32
-
33
- (uint8 v, bytes32 r, bytes32 s) = _splitSignature(data);
34
-
35
- uint256 end = data.length - (32 + 65);
36
- bytes32 salt = bytes32(data[end:]);
37
-
38
- /*
39
- * When handling contract signatures:
40
- * v - is zero
41
- * r - contains the signer
42
- * s - contains the offset within calldata where the signer specific
43
- * signature is located
44
- *
45
- * We detect contract signatures by checking:
46
- * 1- `v` is zero
47
- * 2- `s` points within the buffer, is after selector, is before
48
- * salt and delimits a non-zero length buffer
49
- */
50
- if (v == 0) {
51
- uint256 start = uint256(s);
52
- if (start < 4 || start > end) {
53
- return (bytes32(0), address(0));
54
- }
55
- address signer = address(uint160(uint256(r)));
56
-
57
- bytes32 hash = moduleTxHash(data[:start], salt);
58
- return
59
- _isValidContractSignature(signer, hash, data[start:end])
60
- ? (hash, signer)
61
- : (bytes32(0), address(0));
62
- } else {
63
- bytes32 hash = moduleTxHash(data[:end], salt);
64
- return (hash, ecrecover(hash, v, r, s));
65
- }
66
- }
67
-
68
- /**
69
- * @notice Hashes the transaction EIP-712 data structure.
70
- * @dev The produced hash is intended to be signed.
71
- * @param data The current transaction's calldata.
72
- * @param salt The salt value.
73
- * @return The 32-byte hash that is to be signed.
74
- */
75
- function moduleTxHash(
76
- bytes calldata data,
77
- bytes32 salt
78
- ) public view returns (bytes32) {
79
- bytes32 domainSeparator = keccak256(
80
- abi.encode(DOMAIN_SEPARATOR_TYPEHASH, block.chainid, this)
81
- );
82
- bytes memory moduleTxData = abi.encodePacked(
83
- bytes1(0x19),
84
- bytes1(0x01),
85
- domainSeparator,
86
- keccak256(abi.encode(MODULE_TX_TYPEHASH, keccak256(data), salt))
87
- );
88
- return keccak256(moduleTxData);
89
- }
90
-
91
- /**
92
- * @dev Extracts signature from calldata, and divides it into `uint8 v, bytes32 r, bytes32 s`.
93
- * @param data The current transaction's calldata.
94
- * @return v The ECDSA v value
95
- * @return r The ECDSA r value
96
- * @return s The ECDSA s value
97
- */
98
- function _splitSignature(
99
- bytes calldata data
100
- ) private pure returns (uint8 v, bytes32 r, bytes32 s) {
101
- v = uint8(bytes1(data[data.length - 1:]));
102
- r = bytes32(data[data.length - 65:]);
103
- s = bytes32(data[data.length - 33:]);
104
- }
105
-
106
- /**
107
- * @dev Calls the signer contract, and validates the contract signature.
108
- * @param signer The address of the signer contract.
109
- * @param hash Hash of the data signed
110
- * @param signature The contract signature.
111
- * @return result Indicates whether the signature is valid.
112
- */
113
- function _isValidContractSignature(
114
- address signer,
115
- bytes32 hash,
116
- bytes calldata signature
117
- ) internal view returns (bool result) {
118
- uint256 size;
119
- // eslint-disable-line no-inline-assembly
120
- assembly {
121
- size := extcodesize(signer)
122
- }
123
- if (size == 0) {
124
- return false;
125
- }
126
-
127
- (, bytes memory returnData) = signer.staticcall(
128
- abi.encodeWithSelector(
129
- IERC1271.isValidSignature.selector,
130
- hash,
131
- signature
132
- )
133
- );
134
-
135
- return bytes4(returnData) == EIP1271_MAGIC_VALUE;
136
- }
137
-
138
- // keccak256(
139
- // "EIP712Domain(uint256 chainId,address verifyingContract)"
140
- // );
141
- bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH =
142
- 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;
143
-
144
- // keccak256(
145
- // "ModuleTx(bytes data,bytes32 salt)"
146
- // );
147
- bytes32 private constant MODULE_TX_TYPEHASH =
148
- 0x2939aeeda3ca260200c9f7b436b19e13207547ccc65cfedc857751c5ea6d91d4;
149
-
150
- // bytes4(keccak256(
151
- // "isValidSignature(bytes32,bytes)"
152
- // ));
153
- bytes4 private constant EIP1271_MAGIC_VALUE = 0x1626ba7e;
154
- }
@@ -1,64 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.8.0;
3
-
4
- contract Enum {
5
- enum Operation {
6
- Call,
7
- DelegateCall
8
- }
9
- }
10
-
11
- contract TestAvatar {
12
- address public module;
13
-
14
- receive() external payable {}
15
-
16
- function enableModule(address _module) external {
17
- module = _module;
18
- }
19
-
20
- function disableModule(address, address) external {
21
- module = address(0);
22
- }
23
-
24
- function isModuleEnabled(address _module) external view returns (bool) {
25
- if (module == _module) {
26
- return true;
27
- } else {
28
- return false;
29
- }
30
- }
31
-
32
- function execTransactionFromModule(
33
- address payable to,
34
- uint256 value,
35
- bytes calldata data,
36
- uint8 operation
37
- ) external returns (bool success) {
38
- require(msg.sender == module, "Not authorized");
39
- if (operation == 1) (success, ) = to.delegatecall(data);
40
- else (success, ) = to.call{value: value}(data);
41
- }
42
-
43
- function execTransactionFromModuleReturnData(
44
- address payable to,
45
- uint256 value,
46
- bytes calldata data,
47
- uint8 operation
48
- ) external returns (bool success, bytes memory returnData) {
49
- require(msg.sender == module, "Not authorized");
50
- if (operation == 1) (success, ) = to.delegatecall(data);
51
- else (success, returnData) = to.call{value: value}(data);
52
- }
53
-
54
- function getModulesPaginated(
55
- address,
56
- uint256 pageSize
57
- ) external view returns (address[] memory array, address next) {
58
- // Init array with max page size
59
- array = new address[](pageSize);
60
-
61
- array[0] = module;
62
- next = module;
63
- }
64
- }
@@ -1,82 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.7.0 <0.9.0;
3
-
4
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
5
-
6
- import {BaseGuard} from "../guard/BaseGuard.sol";
7
- import {Enum} from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
8
- import {FactoryFriendly} from "../factory/FactoryFriendly.sol";
9
- import {GuardableModule} from "../core/GuardableModule.sol";
10
-
11
- /* solhint-disable */
12
-
13
- contract TestGuard is FactoryFriendly, BaseGuard {
14
- event PreChecked(address sender);
15
- event PostChecked(bool checked);
16
-
17
- address public module;
18
-
19
- constructor(address _module) {
20
- bytes memory initParams = abi.encode(_module);
21
- setUp(initParams);
22
- }
23
-
24
- function setModule(address _module) public {
25
- module = _module;
26
- }
27
-
28
- function checkTransaction(
29
- address to,
30
- uint256 value,
31
- bytes memory data,
32
- Enum.Operation operation,
33
- uint256,
34
- uint256,
35
- uint256,
36
- address,
37
- address payable,
38
- bytes memory,
39
- address sender
40
- ) public override {
41
- require(to != address(0), "Cannot send to zero address");
42
- require(value != 1337, "Cannot send 1337");
43
- require(bytes3(data) != bytes3(0xbaddad), "Cannot call 0xbaddad");
44
- require(operation != Enum.Operation(1), "No delegate calls");
45
- emit PreChecked(sender);
46
- }
47
-
48
- function checkAfterExecution(bytes32, bool) public override {
49
- require(
50
- GuardableModule(module).guard() == address(this),
51
- "Module cannot remove its own guard."
52
- );
53
- emit PostChecked(true);
54
- }
55
-
56
- function setUp(bytes memory initializeParams) public override initializer {
57
- address _module = abi.decode(initializeParams, (address));
58
- module = _module;
59
- }
60
- }
61
-
62
- contract TestNonCompliantGuard is IERC165 {
63
- function supportsInterface(bytes4) external pure returns (bool) {
64
- return false;
65
- }
66
-
67
- function checkTransaction(
68
- address,
69
- uint256,
70
- bytes memory,
71
- Enum.Operation,
72
- uint256,
73
- uint256,
74
- uint256,
75
- address,
76
- address,
77
- bytes memory,
78
- address
79
- ) public {}
80
-
81
- function checkAfterExecution(bytes32, bool) public {}
82
- }
@@ -1,82 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
- pragma solidity >=0.7.0 <0.9.0;
3
-
4
- import "../core/GuardableModifier.sol";
5
-
6
- contract TestGuardableModifier is GuardableModifier {
7
- event Executed(
8
- address to,
9
- uint256 value,
10
- bytes data,
11
- Enum.Operation operation,
12
- bool success
13
- );
14
-
15
- event ExecutedAndReturnedData(
16
- address to,
17
- uint256 value,
18
- bytes data,
19
- Enum.Operation operation,
20
- bytes returnData,
21
- bool success
22
- );
23
-
24
- constructor(address _avatar, address _target) {
25
- bytes memory initParams = abi.encode(_avatar, _target);
26
- setUp(initParams);
27
- }
28
-
29
- /// @dev Passes a transaction to the modifier.
30
- /// @param to Destination address of module transaction
31
- /// @param value Ether value of module transaction
32
- /// @param data Data payload of module transaction
33
- /// @param operation Operation type of module transaction
34
- /// @notice Can only be called by enabled modules
35
- function execTransactionFromModule(
36
- address to,
37
- uint256 value,
38
- bytes calldata data,
39
- Enum.Operation operation
40
- ) public override moduleOnly returns (bool success) {
41
- success = exec(to, value, data, operation);
42
- emit Executed(to, value, data, operation, success);
43
- }
44
-
45
- /// @dev Passes a transaction to the modifier, expects return data.
46
- /// @param to Destination address of module transaction
47
- /// @param value Ether value of module transaction
48
- /// @param data Data payload of module transaction
49
- /// @param operation Operation type of module transaction
50
- /// @notice Can only be called by enabled modules
51
- function execTransactionFromModuleReturnData(
52
- address to,
53
- uint256 value,
54
- bytes calldata data,
55
- Enum.Operation operation
56
- ) public override moduleOnly returns (bool success, bytes memory returnData) {
57
- (success, returnData) = execAndReturnData(to, value, data, operation);
58
- emit ExecutedAndReturnedData(
59
- to,
60
- value,
61
- data,
62
- operation,
63
- returnData,
64
- success
65
- );
66
- }
67
-
68
- function setUp(bytes memory initializeParams) public override initializer {
69
- setupModules();
70
- __Ownable_init(msg.sender);
71
- (address _avatar, address _target) = abi.decode(
72
- initializeParams,
73
- (address, address)
74
- );
75
- avatar = _avatar;
76
- target = _target;
77
- }
78
-
79
- function attemptToSetupModules() public {
80
- setupModules();
81
- }
82
- }
@@ -1,88 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-only
2
-
3
- /// @title Modifier Interface - A contract that sits between a Module and an Avatar and enforce some additional logic.
4
- pragma solidity >=0.7.0 <0.9.0;
5
-
6
- import "../core/Modifier.sol";
7
-
8
- contract TestModifier is Modifier {
9
- event Executed(
10
- address to,
11
- uint256 value,
12
- bytes data,
13
- Enum.Operation operation,
14
- bool success
15
- );
16
-
17
- event ExecutedAndReturnedData(
18
- address to,
19
- uint256 value,
20
- bytes data,
21
- Enum.Operation operation,
22
- bytes returnData,
23
- bool success
24
- );
25
-
26
- constructor(address _avatar, address _target) {
27
- bytes memory initParams = abi.encode(_avatar, _target);
28
- setUp(initParams);
29
- }
30
-
31
- /// @dev Passes a transaction to the modifier.
32
- /// @param to Destination address of module transaction
33
- /// @param value Ether value of module transaction
34
- /// @param data Data payload of module transaction
35
- /// @param operation Operation type of module transaction
36
- /// @notice Can only be called by enabled modules
37
- function execTransactionFromModule(
38
- address to,
39
- uint256 value,
40
- bytes calldata data,
41
- Enum.Operation operation
42
- ) public override moduleOnly returns (bool success) {
43
- success = exec(to, value, data, operation);
44
- emit Executed(to, value, data, operation, success);
45
- }
46
-
47
- /// @dev Passes a transaction to the modifier, expects return data.
48
- /// @param to Destination address of module transaction
49
- /// @param value Ether value of module transaction
50
- /// @param data Data payload of module transaction
51
- /// @param operation Operation type of module transaction
52
- /// @notice Can only be called by enabled modules
53
- function execTransactionFromModuleReturnData(
54
- address to,
55
- uint256 value,
56
- bytes calldata data,
57
- Enum.Operation operation
58
- ) public override moduleOnly returns (bool success, bytes memory returnData) {
59
- (success, returnData) = execAndReturnData(to, value, data, operation);
60
- emit ExecutedAndReturnedData(
61
- to,
62
- value,
63
- data,
64
- operation,
65
- returnData,
66
- success
67
- );
68
- }
69
-
70
- function setUp(bytes memory initializeParams) public override initializer {
71
- (address _avatar, address _target) = abi.decode(
72
- initializeParams,
73
- (address, address)
74
- );
75
- setupModules();
76
- _transferOwnership(msg.sender);
77
- avatar = _avatar;
78
- target = _target;
79
- }
80
-
81
- function exposeSentOrSignedByModule() external view returns (address) {
82
- return sentOrSignedByModule();
83
- }
84
-
85
- function attemptToSetupModules() public {
86
- setupModules();
87
- }
88
- }