@@ -23,7 +23,6 @@ contract ProposalTypesConfigurator is IProposalTypesConfigurator {
23
23
mapping (uint8 proposalTypeId = > bool ) internal _proposalTypesExists;
24
24
mapping (uint8 proposalTypeId = > Scope[]) public scopes;
25
25
mapping (uint8 proposalTypeId = > mapping (bytes32 typeHash = > bool )) public scopeExists;
26
- mapping (bytes32 typeHash = > bytes32 limits ) public limits;
27
26
28
27
/*//////////////////////////////////////////////////////////////
29
28
MODIFIERS
@@ -137,4 +136,39 @@ contract ProposalTypesConfigurator is IProposalTypesConfigurator {
137
136
138
137
emit ProposalTypeSet (proposalTypeId, quorum, approvalThreshold, name, txTypeHashes);
139
138
}
139
+
140
+ /**
141
+ * @notice Adds an additional scope for a given proposal type.
142
+ * @param proposalTypeId Id of the proposal type
143
+ * @param scope An object that contains the scope for a transaction type hash
144
+ */
145
+ function updateScopeForProposalType (uint8 proposalTypeId , Scope calldata scope ) external override onlyAdmin {
146
+ _updateScopeForProposalType (proposalTypeId, scope);
147
+ }
148
+
149
+ function _updateScopeForProposalType (uint8 proposalTypeId , Scope calldata scope ) internal {
150
+ if (_proposalTypesExists[proposalTypeId]) revert InvalidProposalType ();
151
+ scopes[proposalTypeId].push (scope);
152
+
153
+ require (scopeExists[proposalTypeId][scope.txTypeHash]); // Do not allow multiple scopes for a single transaction type
154
+ scopeExists[proposalTypeId][scope.txTypeHash] = true ;
155
+ }
156
+
157
+ /**
158
+ * @notice Retrives the encoded limit of a transaction type signature for a given proposal type.
159
+ * @param proposalTypeId Id of the proposal type
160
+ * @param txTypeHash A type signature of a function that has a limit specified in a scope
161
+ */
162
+ function getLimit (uint8 proposalTypeId , bytes32 txTypeHash ) public view returns (bytes32 ) {
163
+ if (_proposalTypesExists[proposalTypeId]) revert InvalidProposalType ();
164
+
165
+ require (scopeExists[proposalTypeId][txTypeHash]);
166
+ Scope[] memory validScopes = scopes[proposalTypeId];
167
+
168
+ for (uint8 i = 0 ; i < validScopes.length ; i++ ) {
169
+ if (validScopes[i].txTypeHash == txTypeHash) {
170
+ return validScopes[i].encodedLimits;
171
+ }
172
+ }
173
+ }
140
174
}
0 commit comments