-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathPRBProxyAnnex.sol
106 lines (86 loc) · 4.68 KB
/
PRBProxyAnnex.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
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
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.18;
import { PRBProxyStorage } from "./abstracts/PRBProxyStorage.sol";
import { IPRBProxyAnnex } from "./interfaces/IPRBProxyAnnex.sol";
import { IPRBProxyPlugin } from "./interfaces/IPRBProxyPlugin.sol";
/*
██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗██╗ ██╗
██╔══██╗██╔══██╗██╔══██╗██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝╚██╗ ██╔╝
██████╔╝██████╔╝██████╔╝██████╔╝██████╔╝██║ ██║ ╚███╔╝ ╚████╔╝
██╔═══╝ ██╔══██╗██╔══██╗██╔═══╝ ██╔══██╗██║ ██║ ██╔██╗ ╚██╔╝
██║ ██║ ██║██████╔╝██║ ██║ ██║╚██████╔╝██╔╝ ██╗ ██║
╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
█████╗ ███╗ ██╗███╗ ██╗███████╗██╗ ██╗
██╔══██╗████╗ ██║████╗ ██║██╔════╝╚██╗██╔╝
███████║██╔██╗ ██║██╔██╗ ██║█████╗ ╚███╔╝
██╔══██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔██╗
██║ ██║██║ ╚████║██║ ╚████║███████╗██╔╝ ██╗
╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
*/
/// @title PRBProxyAnnex
/// @dev See the documentation in {IPRBProxyAnnex}.
contract PRBProxyAnnex is
IPRBProxyAnnex, // 0 inherited components
PRBProxyStorage // 1 inherited component
{
/*//////////////////////////////////////////////////////////////////////////
PUBLIC STORAGE
//////////////////////////////////////////////////////////////////////////*/
/// @inheritdoc IPRBProxyAnnex
string public constant override VERSION = "4.0.0-beta.4";
/*//////////////////////////////////////////////////////////////////////////
NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/
/// @inheritdoc IPRBProxyAnnex
function installPlugin(IPRBProxyPlugin plugin) external override {
// Get the method list to install.
bytes4[] memory methodList = plugin.methodList();
// The plugin must have at least one listed method.
uint256 length = methodList.length;
if (length == 0) {
revert PRBProxy_NoPluginMethods(plugin);
}
// Enable every method in the list.
for (uint256 i = 0; i < length;) {
plugins[methodList[i]] = plugin;
unchecked {
i += 1;
}
}
// Log the plugin installation.
emit InstallPlugin(plugin);
}
/// @inheritdoc IPRBProxyAnnex
function setMinGasReserve(uint256 newMinGasReserve) external override {
// Load the current minimum gas reserve.
uint256 oldMinGasReserve = minGasReserve;
// Update the minimum gas reserve.
minGasReserve = newMinGasReserve;
// Log the minimum gas reserve update.
emit SetMinGasReserve(oldMinGasReserve, newMinGasReserve);
}
/// @inheritdoc IPRBProxyAnnex
function setPermission(address envoy, address target, bool permission) external override {
permissions[envoy][target] = permission;
emit SetPermission(envoy, target, permission);
}
/// @inheritdoc IPRBProxyAnnex
function uninstallPlugin(IPRBProxyPlugin plugin) external {
// Get the method list to uninstall.
bytes4[] memory methodList = plugin.methodList();
// The plugin must have at least one listed method.
uint256 length = methodList.length;
if (length == 0) {
revert PRBProxy_NoPluginMethods(plugin);
}
// Disable every method in the list.
for (uint256 i = 0; i < length;) {
delete plugins[methodList[i]];
unchecked {
i += 1;
}
}
// Log the plugin uninstallation.
emit UninstallPlugin(plugin);
}
}