@web3dotorg/evm-slc-core-contracts 0.3.13 → 0.3.14
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/governance/Governance.sol +31 -26
- package/package.json +1 -1
|
@@ -92,7 +92,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
92
92
|
VotingPhase votingPhase;
|
|
93
93
|
bytes32 leadingOperationHash;
|
|
94
94
|
// Proposals
|
|
95
|
-
uint256
|
|
95
|
+
uint256 proposalNonce;
|
|
96
96
|
uint256[] proposalIds;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -114,7 +114,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
114
114
|
struct SLCProposalState {
|
|
115
115
|
// Parent data
|
|
116
116
|
address slcCore;
|
|
117
|
-
uint256
|
|
117
|
+
uint256 requestId;
|
|
118
118
|
// Voting parameters
|
|
119
119
|
uint256 neutralsThreshold;
|
|
120
120
|
uint256 executorsThreshold;
|
|
@@ -193,9 +193,14 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
193
193
|
uint256 minServiceFee_ = _getMinServiceFee();
|
|
194
194
|
require(serviceFee_ >= minServiceFee_, ServiceFeeTooLow(serviceFee_, minServiceFee_));
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
// solhint-disable-next-line gas-increment-by-one
|
|
197
|
+
uint256 requestCounter_ = $.slcGovernanceState[slcCore_].totalRequestsCount++;
|
|
198
|
+
|
|
199
|
+
uint256 proposalId_ = _makeProposal(
|
|
197
200
|
additionalLink_,
|
|
198
|
-
requester_
|
|
201
|
+
requester_,
|
|
202
|
+
slcCore_,
|
|
203
|
+
requestCounter_
|
|
199
204
|
);
|
|
200
205
|
|
|
201
206
|
address[] memory selectedNeutrals_ = $.neutralsRegistry.getNeutralsSlice(neutralsNumber_);
|
|
@@ -228,7 +233,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
228
233
|
|
|
229
234
|
ServiceRequestState storage requestState = $
|
|
230
235
|
.slcGovernanceState[$.proposalState[proposalId_].slcCore]
|
|
231
|
-
.requestState[$.proposalState[proposalId_].
|
|
236
|
+
.requestState[$.proposalState[proposalId_].requestId];
|
|
232
237
|
|
|
233
238
|
require(
|
|
234
239
|
requestState.votingPhase == VotingPhase.Neutrals,
|
|
@@ -343,7 +348,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
343
348
|
|
|
344
349
|
ServiceRequestState storage requestState = $
|
|
345
350
|
.slcGovernanceState[proposalState.slcCore]
|
|
346
|
-
.requestState[proposalState.
|
|
351
|
+
.requestState[proposalState.requestId];
|
|
347
352
|
|
|
348
353
|
uint256 selectedNeutralsLength_ = requestState.selectedNeutrals.length();
|
|
349
354
|
bytes32[] memory neutralToOperationHashes_ = new bytes32[](selectedNeutralsLength_);
|
|
@@ -388,7 +393,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
388
393
|
data: requestState.data,
|
|
389
394
|
votingPhase: requestState.votingPhase,
|
|
390
395
|
leadingOperationHash: requestState.leadingOperationHash,
|
|
391
|
-
requestNonce: requestState.
|
|
396
|
+
requestNonce: requestState.proposalNonce,
|
|
392
397
|
proposalIds: requestState.proposalIds
|
|
393
398
|
});
|
|
394
399
|
}
|
|
@@ -524,7 +529,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
524
529
|
|
|
525
530
|
ServiceRequestState storage requestState = $
|
|
526
531
|
.slcGovernanceState[$.proposalState[proposalId_].slcCore]
|
|
527
|
-
.requestState[$.proposalState[proposalId_].
|
|
532
|
+
.requestState[$.proposalState[proposalId_].requestId];
|
|
528
533
|
|
|
529
534
|
uint256 serviceFee_ = requestState.serviceFee;
|
|
530
535
|
if (serviceFee_ == 0 && msg.value == 0) return;
|
|
@@ -577,7 +582,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
577
582
|
|
|
578
583
|
ServiceRequestState storage requestState = $
|
|
579
584
|
.slcGovernanceState[$.proposalState[proposalId].slcCore]
|
|
580
|
-
.requestState[$.proposalState[proposalId].
|
|
585
|
+
.requestState[$.proposalState[proposalId].requestId];
|
|
581
586
|
|
|
582
587
|
bytes32 leadingOperationHash_ = requestState.leadingOperationHash;
|
|
583
588
|
if (leadingOperationHash_ == bytes32(0)) {
|
|
@@ -620,7 +625,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
620
625
|
|
|
621
626
|
ServiceRequestState storage requestState = $
|
|
622
627
|
.slcGovernanceState[$.proposalState[proposalId].slcCore]
|
|
623
|
-
.requestState[$.proposalState[proposalId].
|
|
628
|
+
.requestState[$.proposalState[proposalId].requestId];
|
|
624
629
|
|
|
625
630
|
require($.executorsRegistry.isExecutor(account), AccountNotExecutor(account));
|
|
626
631
|
|
|
@@ -651,9 +656,11 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
651
656
|
$.proposalState[proposalId].negativeExecutorVotes.length() >=
|
|
652
657
|
$.proposalState[proposalId].executorsThreshold
|
|
653
658
|
) {
|
|
654
|
-
|
|
659
|
+
uint256 newProposalId_ = _makeProposal(
|
|
655
660
|
requestState.additionalLink,
|
|
656
|
-
requestState.requester
|
|
661
|
+
requestState.requester,
|
|
662
|
+
$.proposalState[proposalId].slcCore,
|
|
663
|
+
requestState.requestId
|
|
657
664
|
);
|
|
658
665
|
_fillProposalState(newProposalId_);
|
|
659
666
|
|
|
@@ -728,19 +735,17 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
728
735
|
|
|
729
736
|
function _makeProposal(
|
|
730
737
|
string memory additionalLink_,
|
|
731
|
-
address requester_
|
|
732
|
-
|
|
738
|
+
address requester_,
|
|
739
|
+
address slcCore_,
|
|
740
|
+
uint256 requestId_
|
|
741
|
+
) private returns (uint256 proposalId_) {
|
|
733
742
|
GovernanceStorage storage $ = _getGovernanceStorage();
|
|
734
743
|
|
|
735
|
-
address slcCore_ = msg.sender;
|
|
736
|
-
|
|
737
|
-
// solhint-disable-next-line gas-increment-by-one
|
|
738
|
-
requestCounter_ = $.slcGovernanceState[slcCore_].totalRequestsCount++;
|
|
739
744
|
// solhint-disable-next-line gas-increment-by-one
|
|
740
|
-
uint256
|
|
745
|
+
uint256 proposalNonce_ = $
|
|
741
746
|
.slcGovernanceState[slcCore_]
|
|
742
|
-
.requestState[
|
|
743
|
-
.
|
|
747
|
+
.requestState[requestId_]
|
|
748
|
+
.proposalNonce++;
|
|
744
749
|
|
|
745
750
|
address[] memory targets = new address[](1);
|
|
746
751
|
targets[0] = slcCore_;
|
|
@@ -749,18 +754,18 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
749
754
|
values[0] = 0;
|
|
750
755
|
|
|
751
756
|
bytes[] memory calldatas = new bytes[](1);
|
|
752
|
-
calldatas[0] = abi.encodePacked(
|
|
757
|
+
calldatas[0] = abi.encodePacked(requestId_, proposalNonce_);
|
|
753
758
|
|
|
754
759
|
proposalId_ = _propose(targets, values, calldatas, additionalLink_, requester_);
|
|
755
760
|
|
|
756
761
|
$.proposalState[proposalId_].slcCore = slcCore_;
|
|
757
|
-
$.proposalState[proposalId_].
|
|
762
|
+
$.proposalState[proposalId_].requestId = requestId_;
|
|
758
763
|
}
|
|
759
764
|
|
|
760
765
|
function _executeProposal(uint256 proposalId_) private {
|
|
761
766
|
GovernanceStorage storage $ = _getGovernanceStorage();
|
|
762
767
|
|
|
763
|
-
uint256 requestCounter_ = $.proposalState[proposalId_].
|
|
768
|
+
uint256 requestCounter_ = $.proposalState[proposalId_].requestId;
|
|
764
769
|
ServiceRequestState storage requestState = $
|
|
765
770
|
.slcGovernanceState[$.proposalState[proposalId_].slcCore]
|
|
766
771
|
.requestState[requestCounter_];
|
|
@@ -770,7 +775,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
770
775
|
|
|
771
776
|
// Here we need to execute the previous proposal related to this request
|
|
772
777
|
bytes[] memory calldatas = new bytes[](1);
|
|
773
|
-
calldatas[0] = abi.encodePacked(requestCounter_, requestState.
|
|
778
|
+
calldatas[0] = abi.encodePacked(requestCounter_, requestState.proposalNonce - 1);
|
|
774
779
|
|
|
775
780
|
execute(
|
|
776
781
|
targets,
|
|
@@ -785,7 +790,7 @@ contract Governance is IGovernance, GovernorUpgradeable, UUPSUpgradeable {
|
|
|
785
790
|
|
|
786
791
|
ServiceRequestState storage requestState = $
|
|
787
792
|
.slcGovernanceState[$.proposalState[proposalId_].slcCore]
|
|
788
|
-
.requestState[$.proposalState[proposalId_].
|
|
793
|
+
.requestState[$.proposalState[proposalId_].requestId];
|
|
789
794
|
|
|
790
795
|
uint256 neutralsLength_ = requestState.selectedNeutrals.length();
|
|
791
796
|
|