Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'polygon' into master-v2
- Loading branch information
Showing
98 changed files
with
251,012 additions
and
388,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
"scope-case": [2, 'always', 'lower-case'], | ||
"subject-case": [2, 'always', 'sentence-case'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint:fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.2; | ||
|
||
import { Governable } from "./Governable.sol"; | ||
|
||
/** | ||
* @title ClaimableGovernor | ||
* @author mStable | ||
* @notice 2 way handshake for Governance transfer | ||
* @dev Overrides the public functions in Governable to provide | ||
* a second step of validation. | ||
* VERSION: 1.1 | ||
* DATE: 2021-04-15 | ||
*/ | ||
contract ClaimableGovernor is Governable { | ||
event GovernorChangeClaimed(address indexed proposedGovernor); | ||
event GovernorChangeCancelled(address indexed governor, address indexed proposed); | ||
event GovernorChangeRequested(address indexed governor, address indexed proposed); | ||
|
||
address public proposedGovernor = address(0); | ||
|
||
/** | ||
* @dev Throws if called by any account other than the Proposed Governor. | ||
*/ | ||
modifier onlyProposedGovernor() { | ||
require(msg.sender == proposedGovernor, "Sender is not proposed governor"); | ||
_; | ||
} | ||
|
||
constructor(address _governorAddr) { | ||
_changeGovernor(_governorAddr); | ||
} | ||
|
||
// @override | ||
function changeGovernor(address) external view override onlyGovernor { | ||
revert("Direct change not allowed"); | ||
} | ||
|
||
/** | ||
* @dev Current Governor request to proposes a new Governor | ||
* @param _proposedGovernor Address of the proposed Governor | ||
*/ | ||
function requestGovernorChange(address _proposedGovernor) public virtual onlyGovernor { | ||
require(_proposedGovernor != address(0), "Proposed governor is address(0)"); | ||
require(proposedGovernor == address(0), "Proposed governor already set"); | ||
|
||
proposedGovernor = _proposedGovernor; | ||
emit GovernorChangeRequested(governor(), _proposedGovernor); | ||
} | ||
|
||
/** | ||
* @dev Current Governor cancel Governor change request | ||
*/ | ||
function cancelGovernorChange() public virtual onlyGovernor { | ||
require(proposedGovernor != address(0), "Proposed Governor not set"); | ||
|
||
emit GovernorChangeCancelled(governor(), proposedGovernor); | ||
proposedGovernor = address(0); | ||
} | ||
|
||
/** | ||
* @dev Proposed Governor can claim governance ownership | ||
*/ | ||
function claimGovernorChange() public virtual onlyProposedGovernor { | ||
_changeGovernor(proposedGovernor); | ||
emit GovernorChangeClaimed(proposedGovernor); | ||
proposedGovernor = address(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.2; | ||
|
||
import { ClaimableGovernor } from "./ClaimableGovernor.sol"; | ||
|
||
/** | ||
* @title DelayedClaimableGovernor | ||
* @author mStable | ||
* @notice Current Governor can initiate governance change request. | ||
* After a defined delay, proposed Governor can claim governance | ||
* ownership. | ||
* VERSION: 1.1 | ||
* DATE: 2021-04-15 | ||
*/ | ||
contract DelayedClaimableGovernor is ClaimableGovernor { | ||
uint256 public delay = 0; | ||
uint256 public requestTime = 0; | ||
|
||
/** | ||
* @dev Initializes the contract with given delay | ||
* @param _governorAddr Initial governor | ||
* @param _delay Delay in seconds for 2 way handshake | ||
*/ | ||
constructor(address _governorAddr, uint256 _delay) ClaimableGovernor(_governorAddr) { | ||
require(_delay > 0, "Delay must be greater than zero"); | ||
delay = _delay; | ||
} | ||
|
||
/** | ||
* @dev Requests change of governor and logs request time | ||
* @param _proposedGovernor Address of the new governor | ||
*/ | ||
function requestGovernorChange(address _proposedGovernor) public override onlyGovernor { | ||
requestTime = block.timestamp; | ||
super.requestGovernorChange(_proposedGovernor); | ||
} | ||
|
||
/** | ||
* @dev Cancels an outstanding governor change request by resetting request time | ||
*/ | ||
function cancelGovernorChange() public override onlyGovernor { | ||
requestTime = 0; | ||
super.cancelGovernorChange(); | ||
} | ||
|
||
/** | ||
* @dev Proposed governor claims new position, callable after time elapsed | ||
*/ | ||
function claimGovernorChange() public override onlyProposedGovernor { | ||
require(block.timestamp >= (requestTime + delay), "Delay not over"); | ||
super.claimGovernorChange(); | ||
requestTime = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.2; | ||
|
||
/** | ||
* @title Governable | ||
* @author mStable | ||
* @notice Simple contract implementing an Ownable pattern. | ||
* @dev Derives from V2.3.0 @openzeppelin/contracts/ownership/Ownable.sol | ||
* Modified to have custom name and features | ||
* - Removed `renounceOwnership` | ||
* - Changes `_owner` to `_governor` | ||
* VERSION: 1.1 | ||
* DATE: 2021-04-15 | ||
*/ | ||
contract Governable { | ||
event GovernorChanged(address indexed previousGovernor, address indexed newGovernor); | ||
|
||
address private _governor; | ||
|
||
/** | ||
* @dev Initializes the contract setting the deployer as the initial Governor. | ||
*/ | ||
constructor() { | ||
_governor = msg.sender; | ||
emit GovernorChanged(address(0), _governor); | ||
} | ||
|
||
/** | ||
* @dev Returns the address of the current Governor. | ||
*/ | ||
function governor() public view virtual returns (address) { | ||
return _governor; | ||
} | ||
|
||
/** | ||
* @dev Throws if called by any account other than the Governor. | ||
*/ | ||
modifier onlyGovernor() { | ||
require(isGovernor(), "GOV: caller is not the Governor"); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev Returns true if the caller is the current Governor. | ||
*/ | ||
function isGovernor() public view returns (bool) { | ||
return msg.sender == _governor; | ||
} | ||
|
||
/** | ||
* @dev Transfers Governance of the contract to a new account (`newGovernor`). | ||
* Can only be called by the current Governor. | ||
* @param _newGovernor Address of the new Governor | ||
*/ | ||
function changeGovernor(address _newGovernor) external virtual onlyGovernor { | ||
_changeGovernor(_newGovernor); | ||
} | ||
|
||
/** | ||
* @dev Change Governance of the contract to a new account (`newGovernor`). | ||
* @param _newGovernor Address of the new Governor | ||
*/ | ||
function _changeGovernor(address _newGovernor) internal { | ||
require(_newGovernor != address(0), "GOV: new Governor is address(0)"); | ||
emit GovernorChanged(_governor, _newGovernor); | ||
_governor = _newGovernor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.