@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.
- package/README.md +107 -4
- package/dist/cjs/abis/bridge/1.0.0.js +385 -0
- package/dist/cjs/abis/circulatingSupplyERC20/1.0.0.js +248 -0
- package/dist/cjs/abis/circulatingSupplyERC20/1.1.0.js +248 -0
- package/dist/cjs/abis/circulatingSupplyERC20/1.2.0.js +248 -0
- package/dist/cjs/abis/circulatingSupplyERC721/1.1.0.js +248 -0
- package/dist/cjs/abis/circulatingSupplyERC721/1.2.0.js +248 -0
- package/dist/cjs/abis/connext/1.0.0.js +496 -0
- package/dist/cjs/abis/delay/1.0.0.js +731 -0
- package/dist/cjs/abis/delay/1.0.1.js +731 -0
- package/dist/cjs/abis/delay/1.1.0.js +941 -0
- package/dist/cjs/abis/delay/1.1.1.js +941 -0
- package/dist/cjs/abis/erc20Votes/1.0.0.js +800 -0
- package/dist/cjs/abis/erc721Votes/1.0.0.js +795 -0
- package/dist/cjs/abis/exit/1.0.0.js +403 -0
- package/dist/cjs/abis/exit/1.1.0.js +422 -0
- package/dist/cjs/abis/exit/1.2.0.js +422 -0
- package/dist/cjs/abis/exitERC721/1.1.0.js +422 -0
- package/dist/cjs/abis/exitERC721/1.2.0.js +422 -0
- package/dist/cjs/abis/factory/1.0.0.js +53 -0
- package/dist/cjs/abis/factory/1.1.0.js +80 -0
- package/dist/cjs/abis/factory/1.2.0.js +91 -0
- package/dist/cjs/abis/index.js +101 -0
- package/dist/cjs/abis/metaGuard/1.0.0.js +474 -0
- package/dist/cjs/abis/multisendEncoder/1.0.0.js +64 -0
- package/dist/cjs/abis/ozGovernor/1.0.0.js +1066 -0
- package/dist/cjs/abis/realityERC20/2.0.0.js +874 -0
- package/dist/cjs/abis/realityETH/2.0.0.js +874 -0
- package/dist/cjs/abis/roles/1.0.0.js +993 -0
- package/dist/cjs/abis/roles/1.1.0.js +993 -0
- package/dist/cjs/abis/roles/2.1.0.js +1411 -0
- package/dist/cjs/abis/roles/2.1.1.js +1411 -0
- package/dist/cjs/abis/scopeGuard/1.0.0.js +595 -0
- package/dist/cjs/contracts.js +145 -0
- package/dist/cjs/explorer.js +264 -0
- package/dist/cjs/extract.js +117 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/mastercopies.js +34 -0
- package/dist/cjs/networks.js +233 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/rpc.js +36 -0
- package/dist/cjs/singleton.js +42 -0
- package/dist/cjs/types.js +7 -0
- package/dist/cjs/ui.js +64 -0
- package/dist/cjs/zodiacModule.js +61 -0
- package/dist/esm/abis/bridge/1.0.0.d.ts +297 -0
- package/dist/esm/abis/bridge/1.0.0.js +382 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.0.0.d.ts +188 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.0.0.js +245 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.1.0.d.ts +188 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.1.0.js +245 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.2.0.d.ts +188 -0
- package/dist/esm/abis/circulatingSupplyERC20/1.2.0.js +245 -0
- package/dist/esm/abis/circulatingSupplyERC721/1.1.0.d.ts +188 -0
- package/dist/esm/abis/circulatingSupplyERC721/1.1.0.js +245 -0
- package/dist/esm/abis/circulatingSupplyERC721/1.2.0.d.ts +188 -0
- package/dist/esm/abis/circulatingSupplyERC721/1.2.0.js +245 -0
- package/dist/esm/abis/connext/1.0.0.d.ts +383 -0
- package/dist/esm/abis/connext/1.0.0.js +493 -0
- package/dist/esm/abis/delay/1.0.0.d.ts +562 -0
- package/dist/esm/abis/delay/1.0.0.js +728 -0
- package/dist/esm/abis/delay/1.0.1.d.ts +562 -0
- package/dist/esm/abis/delay/1.0.1.js +728 -0
- package/dist/esm/abis/delay/1.1.0.d.ts +720 -0
- package/dist/esm/abis/delay/1.1.0.js +938 -0
- package/dist/esm/abis/delay/1.1.1.d.ts +720 -0
- package/dist/esm/abis/delay/1.1.1.js +938 -0
- package/dist/esm/abis/erc20Votes/1.0.0.d.ts +613 -0
- package/dist/esm/abis/erc20Votes/1.0.0.js +797 -0
- package/dist/esm/abis/erc721Votes/1.0.0.d.ts +610 -0
- package/dist/esm/abis/erc721Votes/1.0.0.js +792 -0
- package/dist/esm/abis/exit/1.0.0.d.ts +309 -0
- package/dist/esm/abis/exit/1.0.0.js +400 -0
- package/dist/esm/abis/exit/1.1.0.d.ts +323 -0
- package/dist/esm/abis/exit/1.1.0.js +419 -0
- package/dist/esm/abis/exit/1.2.0.d.ts +323 -0
- package/dist/esm/abis/exit/1.2.0.js +419 -0
- package/dist/esm/abis/exitERC721/1.1.0.d.ts +323 -0
- package/dist/esm/abis/exitERC721/1.1.0.js +419 -0
- package/dist/esm/abis/exitERC721/1.2.0.d.ts +323 -0
- package/dist/esm/abis/exitERC721/1.2.0.js +419 -0
- package/dist/esm/abis/factory/1.0.0.d.ts +38 -0
- package/dist/esm/abis/factory/1.0.0.js +50 -0
- package/dist/esm/abis/factory/1.1.0.d.ts +58 -0
- package/dist/esm/abis/factory/1.1.0.js +77 -0
- package/dist/esm/abis/factory/1.2.0.d.ts +66 -0
- package/dist/esm/abis/factory/1.2.0.js +88 -0
- package/dist/esm/abis/index.d.ts +13970 -0
- package/dist/esm/abis/index.js +98 -0
- package/dist/esm/abis/metaGuard/1.0.0.d.ts +363 -0
- package/dist/esm/abis/metaGuard/1.0.0.js +471 -0
- package/dist/esm/abis/multisendEncoder/1.0.0.d.ts +47 -0
- package/dist/esm/abis/multisendEncoder/1.0.0.js +61 -0
- package/dist/esm/abis/ozGovernor/1.0.0.d.ts +821 -0
- package/dist/esm/abis/ozGovernor/1.0.0.js +1063 -0
- package/dist/esm/abis/realityERC20/2.0.0.d.ts +674 -0
- package/dist/esm/abis/realityERC20/2.0.0.js +871 -0
- package/dist/esm/abis/realityETH/2.0.0.d.ts +674 -0
- package/dist/esm/abis/realityETH/2.0.0.js +871 -0
- package/dist/esm/abis/roles/1.0.0.d.ts +770 -0
- package/dist/esm/abis/roles/1.0.0.js +990 -0
- package/dist/esm/abis/roles/1.1.0.d.ts +770 -0
- package/dist/esm/abis/roles/1.1.0.js +990 -0
- package/dist/esm/abis/roles/2.1.0.d.ts +1094 -0
- package/dist/esm/abis/roles/2.1.0.js +1408 -0
- package/dist/esm/abis/roles/2.1.1.d.ts +1094 -0
- package/dist/esm/abis/roles/2.1.1.js +1408 -0
- package/dist/esm/abis/scopeGuard/1.0.0.d.ts +457 -0
- package/dist/esm/abis/scopeGuard/1.0.0.js +592 -0
- package/dist/esm/contracts.d.ts +66 -0
- package/dist/esm/contracts.js +142 -0
- package/dist/esm/explorer.d.ts +81 -0
- package/dist/esm/explorer.js +256 -0
- package/dist/esm/extract.d.ts +15 -0
- package/dist/esm/extract.js +114 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/mastercopies.d.ts +21 -0
- package/dist/esm/mastercopies.js +27 -0
- package/dist/esm/networks.d.ts +37 -0
- package/dist/esm/networks.js +229 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/rpc.d.ts +6 -0
- package/dist/esm/rpc.js +33 -0
- package/dist/esm/singleton.d.ts +24 -0
- package/dist/esm/singleton.js +38 -0
- package/dist/esm/types.d.ts +43 -0
- package/dist/esm/types.js +6 -0
- package/dist/esm/ui.d.ts +16 -0
- package/dist/esm/ui.js +53 -0
- package/dist/esm/zodiacModule.d.ts +4 -0
- package/dist/esm/zodiacModule.js +56 -0
- package/package.json +29 -74
- package/contracts/core/GuardableModifier.sol +0 -96
- package/contracts/core/GuardableModule.sol +0 -95
- package/contracts/core/Modifier.sol +0 -204
- package/contracts/core/Module.sol +0 -73
- package/contracts/factory/FactoryFriendly.sol +0 -10
- package/contracts/factory/ModuleProxyFactory.sol +0 -51
- package/contracts/guard/BaseGuard.sol +0 -36
- package/contracts/guard/Guardable.sol +0 -32
- package/contracts/interfaces/IAvatar.sol +0 -71
- package/contracts/interfaces/IGuard.sol +0 -22
- package/contracts/signature/ExecutionTracker.sol +0 -17
- package/contracts/signature/IERC1271.sol +0 -19
- package/contracts/signature/SignatureChecker.sol +0 -154
- package/contracts/test/TestAvatar.sol +0 -64
- package/contracts/test/TestGuard.sol +0 -82
- package/contracts/test/TestGuardableModifier.sol +0 -82
- package/contracts/test/TestModifier.sol +0 -88
- package/contracts/test/TestModule.sol +0 -66
- package/contracts/test/TestSignature.sol +0 -71
- package/dist/index.d.mts +0 -16332
- package/dist/index.d.ts +0 -16332
- package/dist/index.js +0 -24880
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -24845
- package/dist/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnosis-guild/zodiac",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Zodiac is a composable design philosophy and collection of standards for building DAO ecosystem tooling.",
|
|
5
5
|
"author": "Auryn Macmillan <auryn@gnosisguild.org>",
|
|
6
6
|
"license": "LGPL-3.0+",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/cjs/index.js",
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
13
|
+
"types": "./dist/esm/index.d.ts",
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
14
16
|
},
|
|
15
17
|
"./package.json": "./package.json"
|
|
16
18
|
},
|
|
@@ -18,84 +20,37 @@
|
|
|
18
20
|
"package.json",
|
|
19
21
|
"LICENSE",
|
|
20
22
|
"README.md",
|
|
21
|
-
"dist"
|
|
22
|
-
"contracts"
|
|
23
|
+
"dist"
|
|
23
24
|
],
|
|
24
25
|
"scripts": {
|
|
25
|
-
"
|
|
26
|
-
"build
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"format": "yarn format:sol && yarn format:ts",
|
|
37
|
-
"format:sol": "prettier --write --plugin=prettier-plugin-solidity ./contracts/**/*.sol",
|
|
38
|
-
"format:ts": "prettier --write ./sdk/**/*.ts ./test/**/*.ts ./*.ts",
|
|
39
|
-
"generate:types": "patch-package && rimraf src/types && typechain --target ethers-v6 --out-dir sdk/types './sdk/abi/*.json'",
|
|
40
|
-
"prepare": "yarn generate:types && yarn build",
|
|
41
|
-
"prerelease": "yarn clean && yarn build && yarn build:sdk",
|
|
42
|
-
"release": "yarn publish --access public",
|
|
43
|
-
"verify": "yarn hardhat verify --network"
|
|
44
|
-
},
|
|
45
|
-
"directories": {
|
|
46
|
-
"test": "test"
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"build": "yarn clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",
|
|
28
|
+
"postbuild": "node postbuild.mjs",
|
|
29
|
+
"cli": "tsx src/cli.ts",
|
|
30
|
+
"extract": "tsx src/cli.ts extract",
|
|
31
|
+
"deploy": "tsx src/cli.ts deploy",
|
|
32
|
+
"deploy:list": "tsx src/cli.ts deploy list",
|
|
33
|
+
"verify": "tsx src/cli.ts verify",
|
|
34
|
+
"verify:list": "tsx src/cli.ts verify list",
|
|
35
|
+
"format": "prettier --write ./src/**/*.ts ./commands/**/*.ts",
|
|
36
|
+
"release": "yarn build && yarn publish --access public"
|
|
47
37
|
},
|
|
48
38
|
"repository": {
|
|
49
39
|
"type": "git",
|
|
50
40
|
"url": "https://github.com/gnosis/zodiac.git"
|
|
51
41
|
},
|
|
52
42
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
|
58
|
-
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
|
59
|
-
"@nomiclabs/hardhat-etherscan": "3.1.7",
|
|
60
|
-
"@typechain/ethers-v6": "^0.5.1",
|
|
61
|
-
"@typechain/hardhat": "^9.1.0",
|
|
62
|
-
"@types/chai": "^4.3.3",
|
|
63
|
-
"@types/mocha": "^10.0.0",
|
|
64
|
-
"@types/node": "^18.8.5",
|
|
65
|
-
"@types/yargs": "^17.0.13",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
|
67
|
-
"@typescript-eslint/parser": "^6.9.1",
|
|
68
|
-
"chai": "^4.3.7",
|
|
69
|
-
"dotenv": "^16.0.3",
|
|
70
|
-
"eslint": "^8.25.0",
|
|
71
|
-
"eslint-config-prettier": "^9.0.0",
|
|
72
|
-
"eslint-plugin-import": "^2.26.0",
|
|
73
|
-
"eslint-plugin-no-only-tests": "^3.0.0",
|
|
74
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
75
|
-
"hardhat": "^2.14.0",
|
|
76
|
-
"hardhat-change-network": "^0.0.7",
|
|
77
|
-
"hardhat-deploy": "^0.11.28",
|
|
78
|
-
"hardhat-gas-reporter": "^1.0.9",
|
|
79
|
-
"husky": "^8.0.1",
|
|
80
|
-
"patch-package": "^8.0.0",
|
|
81
|
-
"prettier": "^3.0.3",
|
|
82
|
-
"prettier-plugin-solidity": "^1.1.3",
|
|
83
|
-
"rimraf": "^6.0.1",
|
|
84
|
-
"solhint": "^4.0.0",
|
|
85
|
-
"solhint-plugin-prettier": "^0.1.0",
|
|
86
|
-
"solidity-coverage": "^0.8.4",
|
|
87
|
-
"ts-node": "^10.9.1",
|
|
88
|
-
"tsdown": "^0.14.1",
|
|
89
|
-
"typechain": "^8.3.2",
|
|
90
|
-
"typescript": "^5.2.2",
|
|
91
|
-
"yargs": "^17.6.0"
|
|
43
|
+
"@types/semver": "^7.7.1",
|
|
44
|
+
"prettier": "^3.8.4",
|
|
45
|
+
"tsx": "^4.19.0",
|
|
46
|
+
"typescript": "^5.9.3"
|
|
92
47
|
},
|
|
93
48
|
"dependencies": {
|
|
94
|
-
"@gnosis
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
49
|
+
"@gnosis-guild/zodiac-core": "4.1.0",
|
|
50
|
+
"dotenv": "^17.4.2",
|
|
51
|
+
"eth-provider": "^0.13.7",
|
|
52
|
+
"ethers": "^6.17.0",
|
|
53
|
+
"semver": "^7.7.3"
|
|
99
54
|
},
|
|
100
55
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
101
56
|
}
|
|
@@ -1,96 +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
|
-
import {Guardable} from "../guard/Guardable.sol";
|
|
7
|
-
import {IAvatar} from "../interfaces/IAvatar.sol";
|
|
8
|
-
import {IGuard} from "../interfaces/IGuard.sol";
|
|
9
|
-
import {Modifier} from "./Modifier.sol";
|
|
10
|
-
import {Module} from "./Module.sol";
|
|
11
|
-
|
|
12
|
-
abstract contract GuardableModifier is Module, Guardable, Modifier {
|
|
13
|
-
/// @dev Passes a transaction to be executed by the avatar.
|
|
14
|
-
/// @notice Can only be called by this contract.
|
|
15
|
-
/// @param to Destination address of module transaction.
|
|
16
|
-
/// @param value Ether value of module transaction.
|
|
17
|
-
/// @param data Data payload of module transaction.
|
|
18
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
19
|
-
function exec(
|
|
20
|
-
address to,
|
|
21
|
-
uint256 value,
|
|
22
|
-
bytes memory data,
|
|
23
|
-
Enum.Operation operation
|
|
24
|
-
) internal virtual override returns (bool success) {
|
|
25
|
-
address currentGuard = guard;
|
|
26
|
-
if (currentGuard != address(0)) {
|
|
27
|
-
IGuard(currentGuard).checkTransaction(
|
|
28
|
-
/// Transaction info used by module transactions.
|
|
29
|
-
to,
|
|
30
|
-
value,
|
|
31
|
-
data,
|
|
32
|
-
operation,
|
|
33
|
-
/// Zero out the redundant transaction information only used for Safe multisig transctions.
|
|
34
|
-
0,
|
|
35
|
-
0,
|
|
36
|
-
0,
|
|
37
|
-
address(0),
|
|
38
|
-
payable(0),
|
|
39
|
-
"",
|
|
40
|
-
sentOrSignedByModule()
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
success = IAvatar(target).execTransactionFromModule(
|
|
44
|
-
to,
|
|
45
|
-
value,
|
|
46
|
-
data,
|
|
47
|
-
operation
|
|
48
|
-
);
|
|
49
|
-
if (currentGuard != address(0)) {
|
|
50
|
-
IGuard(currentGuard).checkAfterExecution(bytes32(0), success);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/// @dev Passes a transaction to be executed by the target and returns data.
|
|
55
|
-
/// @notice Can only be called by this contract.
|
|
56
|
-
/// @param to Destination address of module transaction.
|
|
57
|
-
/// @param value Ether value of module transaction.
|
|
58
|
-
/// @param data Data payload of module transaction.
|
|
59
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
60
|
-
function execAndReturnData(
|
|
61
|
-
address to,
|
|
62
|
-
uint256 value,
|
|
63
|
-
bytes memory data,
|
|
64
|
-
Enum.Operation operation
|
|
65
|
-
) internal virtual override returns (bool success, bytes memory returnData) {
|
|
66
|
-
address currentGuard = guard;
|
|
67
|
-
if (currentGuard != address(0)) {
|
|
68
|
-
IGuard(currentGuard).checkTransaction(
|
|
69
|
-
/// Transaction info used by module transactions.
|
|
70
|
-
to,
|
|
71
|
-
value,
|
|
72
|
-
data,
|
|
73
|
-
operation,
|
|
74
|
-
/// Zero out the redundant transaction information only used for Safe multisig transctions.
|
|
75
|
-
0,
|
|
76
|
-
0,
|
|
77
|
-
0,
|
|
78
|
-
address(0),
|
|
79
|
-
payable(0),
|
|
80
|
-
"",
|
|
81
|
-
sentOrSignedByModule()
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
(success, returnData) = IAvatar(target).execTransactionFromModuleReturnData(
|
|
86
|
-
to,
|
|
87
|
-
value,
|
|
88
|
-
data,
|
|
89
|
-
operation
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
if (currentGuard != address(0)) {
|
|
93
|
-
IGuard(currentGuard).checkAfterExecution(bytes32(0), success);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,95 +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 {IGuard} from "../interfaces/IGuard.sol";
|
|
6
|
-
import {Guardable} from "../guard/Guardable.sol";
|
|
7
|
-
import {Module} from "./Module.sol";
|
|
8
|
-
import {IAvatar} from "../interfaces/IAvatar.sol";
|
|
9
|
-
|
|
10
|
-
/// @title GuardableModule - A contract that can pass messages to a Module Manager contract if enabled by that contract.
|
|
11
|
-
abstract contract GuardableModule is Module, Guardable {
|
|
12
|
-
/// @dev Passes a transaction to be executed by the avatar.
|
|
13
|
-
/// @notice Can only be called by this contract.
|
|
14
|
-
/// @param to Destination address of module transaction.
|
|
15
|
-
/// @param value Ether value of module transaction.
|
|
16
|
-
/// @param data Data payload of module transaction.
|
|
17
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
18
|
-
function exec(
|
|
19
|
-
address to,
|
|
20
|
-
uint256 value,
|
|
21
|
-
bytes memory data,
|
|
22
|
-
Enum.Operation operation
|
|
23
|
-
) internal override returns (bool success) {
|
|
24
|
-
address currentGuard = guard;
|
|
25
|
-
if (currentGuard != address(0)) {
|
|
26
|
-
IGuard(currentGuard).checkTransaction(
|
|
27
|
-
/// Transaction info used by module transactions.
|
|
28
|
-
to,
|
|
29
|
-
value,
|
|
30
|
-
data,
|
|
31
|
-
operation,
|
|
32
|
-
/// Zero out the redundant transaction information only used for Safe multisig transctions.
|
|
33
|
-
0,
|
|
34
|
-
0,
|
|
35
|
-
0,
|
|
36
|
-
address(0),
|
|
37
|
-
payable(0),
|
|
38
|
-
"",
|
|
39
|
-
msg.sender
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
success = IAvatar(target).execTransactionFromModule(
|
|
43
|
-
to,
|
|
44
|
-
value,
|
|
45
|
-
data,
|
|
46
|
-
operation
|
|
47
|
-
);
|
|
48
|
-
if (currentGuard != address(0)) {
|
|
49
|
-
IGuard(currentGuard).checkAfterExecution(bytes32(0), success);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/// @dev Passes a transaction to be executed by the target and returns data.
|
|
54
|
-
/// @notice Can only be called by this contract.
|
|
55
|
-
/// @param to Destination address of module transaction.
|
|
56
|
-
/// @param value Ether value of module transaction.
|
|
57
|
-
/// @param data Data payload of module transaction.
|
|
58
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
59
|
-
function execAndReturnData(
|
|
60
|
-
address to,
|
|
61
|
-
uint256 value,
|
|
62
|
-
bytes memory data,
|
|
63
|
-
Enum.Operation operation
|
|
64
|
-
) internal virtual override returns (bool success, bytes memory returnData) {
|
|
65
|
-
address currentGuard = guard;
|
|
66
|
-
if (currentGuard != address(0)) {
|
|
67
|
-
IGuard(currentGuard).checkTransaction(
|
|
68
|
-
/// Transaction info used by module transactions.
|
|
69
|
-
to,
|
|
70
|
-
value,
|
|
71
|
-
data,
|
|
72
|
-
operation,
|
|
73
|
-
/// Zero out the redundant transaction information only used for Safe multisig transctions.
|
|
74
|
-
0,
|
|
75
|
-
0,
|
|
76
|
-
0,
|
|
77
|
-
address(0),
|
|
78
|
-
payable(0),
|
|
79
|
-
"",
|
|
80
|
-
msg.sender
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
(success, returnData) = IAvatar(target).execTransactionFromModuleReturnData(
|
|
85
|
-
to,
|
|
86
|
-
value,
|
|
87
|
-
data,
|
|
88
|
-
operation
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (currentGuard != address(0)) {
|
|
92
|
-
IGuard(currentGuard).checkAfterExecution(bytes32(0), success);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,204 +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 {ExecutionTracker} from "../signature/ExecutionTracker.sol";
|
|
6
|
-
import {IAvatar} from "../interfaces/IAvatar.sol";
|
|
7
|
-
import {Module} from "./Module.sol";
|
|
8
|
-
import {SignatureChecker} from "../signature/SignatureChecker.sol";
|
|
9
|
-
|
|
10
|
-
/// @title Modifier Interface - A contract that sits between a Module and an Avatar and enforce some additional logic.
|
|
11
|
-
abstract contract Modifier is
|
|
12
|
-
Module,
|
|
13
|
-
ExecutionTracker,
|
|
14
|
-
SignatureChecker,
|
|
15
|
-
IAvatar
|
|
16
|
-
{
|
|
17
|
-
address internal constant SENTINEL_MODULES = address(0x1);
|
|
18
|
-
/// Mapping of modules.
|
|
19
|
-
mapping(address => address) internal modules;
|
|
20
|
-
|
|
21
|
-
/// `sender` is not an authorized module.
|
|
22
|
-
/// @param sender The address of the sender.
|
|
23
|
-
error NotAuthorized(address sender);
|
|
24
|
-
|
|
25
|
-
/// `module` is invalid.
|
|
26
|
-
error InvalidModule(address module);
|
|
27
|
-
|
|
28
|
-
/// `pageSize` is invalid.
|
|
29
|
-
error InvalidPageSize();
|
|
30
|
-
|
|
31
|
-
/// `module` is already disabled.
|
|
32
|
-
error AlreadyDisabledModule(address module);
|
|
33
|
-
|
|
34
|
-
/// `module` is already enabled.
|
|
35
|
-
error AlreadyEnabledModule(address module);
|
|
36
|
-
|
|
37
|
-
/// @dev `setModules()` was already called.
|
|
38
|
-
error SetupModulesAlreadyCalled();
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
--------------------------------------------------
|
|
42
|
-
You must override both of the following virtual functions,
|
|
43
|
-
execTransactionFromModule() and execTransactionFromModuleReturnData().
|
|
44
|
-
It is recommended that implementations of both functions make use the
|
|
45
|
-
onlyModule modifier.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/// @dev Passes a transaction to the modifier.
|
|
49
|
-
/// @notice Can only be called by enabled modules.
|
|
50
|
-
/// @param to Destination address of module transaction.
|
|
51
|
-
/// @param value Ether value of module transaction.
|
|
52
|
-
/// @param data Data payload of module transaction.
|
|
53
|
-
/// @param operation Operation type of module transaction.
|
|
54
|
-
function execTransactionFromModule(
|
|
55
|
-
address to,
|
|
56
|
-
uint256 value,
|
|
57
|
-
bytes calldata data,
|
|
58
|
-
Enum.Operation operation
|
|
59
|
-
) public virtual returns (bool success);
|
|
60
|
-
|
|
61
|
-
/// @dev Passes a transaction to the modifier, expects return data.
|
|
62
|
-
/// @notice Can only be called by enabled modules.
|
|
63
|
-
/// @param to Destination address of module transaction.
|
|
64
|
-
/// @param value Ether value of module transaction.
|
|
65
|
-
/// @param data Data payload of module transaction.
|
|
66
|
-
/// @param operation Operation type of module transaction.
|
|
67
|
-
function execTransactionFromModuleReturnData(
|
|
68
|
-
address to,
|
|
69
|
-
uint256 value,
|
|
70
|
-
bytes calldata data,
|
|
71
|
-
Enum.Operation operation
|
|
72
|
-
) public virtual returns (bool success, bytes memory returnData);
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
--------------------------------------------------
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
modifier moduleOnly() {
|
|
79
|
-
if (modules[msg.sender] == address(0)) {
|
|
80
|
-
(bytes32 hash, address signer) = moduleTxSignedBy();
|
|
81
|
-
|
|
82
|
-
// is the signer a module?
|
|
83
|
-
if (modules[signer] == address(0)) {
|
|
84
|
-
revert NotAuthorized(msg.sender);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// is the provided signature fresh?
|
|
88
|
-
if (consumed[signer][hash]) {
|
|
89
|
-
revert HashAlreadyConsumed(hash);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
consumed[signer][hash] = true;
|
|
93
|
-
emit HashExecuted(hash);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function sentOrSignedByModule() internal view returns (address) {
|
|
100
|
-
if (modules[msg.sender] != address(0)) {
|
|
101
|
-
return msg.sender;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
(, address signer) = moduleTxSignedBy();
|
|
105
|
-
if (modules[signer] != address(0)) {
|
|
106
|
-
return signer;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return address(0);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/// @dev Disables a module on the modifier.
|
|
113
|
-
/// @notice This can only be called by the owner.
|
|
114
|
-
/// @param prevModule Module that pointed to the module to be removed in the linked list.
|
|
115
|
-
/// @param module Module to be removed.
|
|
116
|
-
function disableModule(
|
|
117
|
-
address prevModule,
|
|
118
|
-
address module
|
|
119
|
-
) public override onlyOwner {
|
|
120
|
-
if (module == address(0) || module == SENTINEL_MODULES)
|
|
121
|
-
revert InvalidModule(module);
|
|
122
|
-
if (modules[prevModule] != module) revert AlreadyDisabledModule(module);
|
|
123
|
-
modules[prevModule] = modules[module];
|
|
124
|
-
modules[module] = address(0);
|
|
125
|
-
emit DisabledModule(module);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/// @dev Enables a module that can add transactions to the queue
|
|
129
|
-
/// @param module Address of the module to be enabled
|
|
130
|
-
/// @notice This can only be called by the owner
|
|
131
|
-
function enableModule(address module) public override onlyOwner {
|
|
132
|
-
if (module == address(0) || module == SENTINEL_MODULES)
|
|
133
|
-
revert InvalidModule(module);
|
|
134
|
-
if (modules[module] != address(0)) revert AlreadyEnabledModule(module);
|
|
135
|
-
modules[module] = modules[SENTINEL_MODULES];
|
|
136
|
-
modules[SENTINEL_MODULES] = module;
|
|
137
|
-
emit EnabledModule(module);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/// @dev Returns if an module is enabled
|
|
141
|
-
/// @return True if the module is enabled
|
|
142
|
-
function isModuleEnabled(
|
|
143
|
-
address _module
|
|
144
|
-
) public view override returns (bool) {
|
|
145
|
-
return SENTINEL_MODULES != _module && modules[_module] != address(0);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/// @dev Returns array of modules.
|
|
149
|
-
/// If all entries fit into a single page, the next pointer will be 0x1.
|
|
150
|
-
/// If another page is present, next will be the last element of the returned array.
|
|
151
|
-
/// @param start Start of the page. Has to be a module or start pointer (0x1 address)
|
|
152
|
-
/// @param pageSize Maximum number of modules that should be returned. Has to be > 0
|
|
153
|
-
/// @return array Array of modules.
|
|
154
|
-
/// @return next Start of the next page.
|
|
155
|
-
function getModulesPaginated(
|
|
156
|
-
address start,
|
|
157
|
-
uint256 pageSize
|
|
158
|
-
) external view override returns (address[] memory array, address next) {
|
|
159
|
-
if (start != SENTINEL_MODULES && !isModuleEnabled(start)) {
|
|
160
|
-
revert InvalidModule(start);
|
|
161
|
-
}
|
|
162
|
-
if (pageSize == 0) {
|
|
163
|
-
revert InvalidPageSize();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Init array with max page size
|
|
167
|
-
array = new address[](pageSize);
|
|
168
|
-
|
|
169
|
-
// Populate return array
|
|
170
|
-
uint256 moduleCount = 0;
|
|
171
|
-
next = modules[start];
|
|
172
|
-
while (
|
|
173
|
-
next != address(0) && next != SENTINEL_MODULES && moduleCount < pageSize
|
|
174
|
-
) {
|
|
175
|
-
array[moduleCount] = next;
|
|
176
|
-
next = modules[next];
|
|
177
|
-
moduleCount++;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Because of the argument validation we can assume that
|
|
181
|
-
// the `currentModule` will always be either a module address
|
|
182
|
-
// or sentinel address (aka the end). If we haven't reached the end
|
|
183
|
-
// inside the loop, we need to set the next pointer to the last element
|
|
184
|
-
// because it skipped over to the next module which is neither included
|
|
185
|
-
// in the current page nor won't be included in the next one
|
|
186
|
-
// if you pass it as a start.
|
|
187
|
-
if (next != SENTINEL_MODULES) {
|
|
188
|
-
next = array[moduleCount - 1];
|
|
189
|
-
}
|
|
190
|
-
// Set correct size of returned array
|
|
191
|
-
// solhint-disable-next-line no-inline-assembly
|
|
192
|
-
assembly {
|
|
193
|
-
mstore(array, moduleCount)
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/// @dev Initializes the modules linked list.
|
|
198
|
-
/// @notice Should be called as part of the `setUp` / initializing function and can only be called once.
|
|
199
|
-
function setupModules() internal {
|
|
200
|
-
if (modules[SENTINEL_MODULES] != address(0))
|
|
201
|
-
revert SetupModulesAlreadyCalled();
|
|
202
|
-
modules[SENTINEL_MODULES] = SENTINEL_MODULES;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,73 +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
|
-
import {FactoryFriendly} from "../factory/FactoryFriendly.sol";
|
|
7
|
-
import {IAvatar} from "../interfaces/IAvatar.sol";
|
|
8
|
-
|
|
9
|
-
/// @title Module Interface - A contract that can pass messages to a Module Manager contract if enabled by that contract.
|
|
10
|
-
abstract contract Module is FactoryFriendly {
|
|
11
|
-
/// @dev Address that will ultimately execute function calls.
|
|
12
|
-
address public avatar;
|
|
13
|
-
/// @dev Address that this module will pass transactions to.
|
|
14
|
-
address public target;
|
|
15
|
-
|
|
16
|
-
/// @dev Emitted each time the avatar is set.
|
|
17
|
-
event AvatarSet(address indexed previousAvatar, address indexed newAvatar);
|
|
18
|
-
/// @dev Emitted each time the Target is set.
|
|
19
|
-
event TargetSet(address indexed previousTarget, address indexed newTarget);
|
|
20
|
-
|
|
21
|
-
/// @dev Sets the avatar to a new avatar (`newAvatar`).
|
|
22
|
-
/// @notice Can only be called by the current owner.
|
|
23
|
-
function setAvatar(address _avatar) public onlyOwner {
|
|
24
|
-
address previousAvatar = avatar;
|
|
25
|
-
avatar = _avatar;
|
|
26
|
-
emit AvatarSet(previousAvatar, _avatar);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/// @dev Sets the target to a new target (`newTarget`).
|
|
30
|
-
/// @notice Can only be called by the current owner.
|
|
31
|
-
function setTarget(address _target) public onlyOwner {
|
|
32
|
-
address previousTarget = target;
|
|
33
|
-
target = _target;
|
|
34
|
-
emit TargetSet(previousTarget, _target);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/// @dev Passes a transaction to be executed by the avatar.
|
|
38
|
-
/// @notice Can only be called by this contract.
|
|
39
|
-
/// @param to Destination address of module transaction.
|
|
40
|
-
/// @param value Ether value of module transaction.
|
|
41
|
-
/// @param data Data payload of module transaction.
|
|
42
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
43
|
-
function exec(
|
|
44
|
-
address to,
|
|
45
|
-
uint256 value,
|
|
46
|
-
bytes memory data,
|
|
47
|
-
Enum.Operation operation
|
|
48
|
-
) internal virtual returns (bool success) {
|
|
49
|
-
return
|
|
50
|
-
IAvatar(target).execTransactionFromModule(to, value, data, operation);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/// @dev Passes a transaction to be executed by the target and returns data.
|
|
54
|
-
/// @notice Can only be called by this contract.
|
|
55
|
-
/// @param to Destination address of module transaction.
|
|
56
|
-
/// @param value Ether value of module transaction.
|
|
57
|
-
/// @param data Data payload of module transaction.
|
|
58
|
-
/// @param operation Operation type of module transaction: 0 == call, 1 == delegate call.
|
|
59
|
-
function execAndReturnData(
|
|
60
|
-
address to,
|
|
61
|
-
uint256 value,
|
|
62
|
-
bytes memory data,
|
|
63
|
-
Enum.Operation operation
|
|
64
|
-
) internal virtual returns (bool success, bytes memory returnData) {
|
|
65
|
-
return
|
|
66
|
-
IAvatar(target).execTransactionFromModuleReturnData(
|
|
67
|
-
to,
|
|
68
|
-
value,
|
|
69
|
-
data,
|
|
70
|
-
operation
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
-
|
|
3
|
-
/// @title Zodiac FactoryFriendly - A contract that allows other contracts to be initializable and pass bytes as arguments to define contract state
|
|
4
|
-
pragma solidity >=0.7.0 <0.9.0;
|
|
5
|
-
|
|
6
|
-
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
7
|
-
|
|
8
|
-
abstract contract FactoryFriendly is OwnableUpgradeable {
|
|
9
|
-
function setUp(bytes memory initializeParams) public virtual;
|
|
10
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
-
pragma solidity >=0.8.0;
|
|
3
|
-
|
|
4
|
-
contract ModuleProxyFactory {
|
|
5
|
-
event ModuleProxyCreation(address indexed proxy, address indexed masterCopy);
|
|
6
|
-
|
|
7
|
-
/// `target` can not be zero.
|
|
8
|
-
error ZeroAddress(address target);
|
|
9
|
-
|
|
10
|
-
/// `target` has no code deployed.
|
|
11
|
-
error TargetHasNoCode(address target);
|
|
12
|
-
|
|
13
|
-
/// `address_` is already taken.
|
|
14
|
-
error TakenAddress(address address_);
|
|
15
|
-
|
|
16
|
-
/// @notice Initialization failed.
|
|
17
|
-
error FailedInitialization();
|
|
18
|
-
|
|
19
|
-
function createProxy(
|
|
20
|
-
address target,
|
|
21
|
-
bytes32 salt
|
|
22
|
-
) internal returns (address result) {
|
|
23
|
-
if (address(target) == address(0)) revert ZeroAddress(target);
|
|
24
|
-
if (address(target).code.length == 0) revert TargetHasNoCode(target);
|
|
25
|
-
bytes memory deployment = abi.encodePacked(
|
|
26
|
-
hex"602d8060093d393df3363d3d373d3d3d363d73",
|
|
27
|
-
target,
|
|
28
|
-
hex"5af43d82803e903d91602b57fd5bf3"
|
|
29
|
-
);
|
|
30
|
-
// solhint-disable-next-line no-inline-assembly
|
|
31
|
-
assembly {
|
|
32
|
-
result := create2(0, add(deployment, 0x20), mload(deployment), salt)
|
|
33
|
-
}
|
|
34
|
-
if (result == address(0)) revert TakenAddress(result);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function deployModule(
|
|
38
|
-
address masterCopy,
|
|
39
|
-
bytes memory initializer,
|
|
40
|
-
uint256 saltNonce
|
|
41
|
-
) public returns (address proxy) {
|
|
42
|
-
proxy = createProxy(
|
|
43
|
-
masterCopy,
|
|
44
|
-
keccak256(abi.encodePacked(keccak256(initializer), saltNonce))
|
|
45
|
-
);
|
|
46
|
-
(bool success, ) = proxy.call(initializer);
|
|
47
|
-
if (!success) revert FailedInitialization();
|
|
48
|
-
|
|
49
|
-
emit ModuleProxyCreation(proxy, masterCopy);
|
|
50
|
-
}
|
|
51
|
-
}
|