-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hebao_1.1] add AddOfficialGuardianModule (#1641)
* compatible * add OfficialGuardianModule * add OfficialGuardianModule * add OfficialGuardianModule * Update AddOfficialGuardianModule.sol Co-authored-by: wangdong <[email protected]>
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
packages/hebao_v1/contracts/modules/aux/AddOfficialGuardianModule.sol
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,70 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2017 Loopring Technology Limited. | ||
pragma solidity ^0.7.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "../../base/BaseWallet.sol"; | ||
import "../../stores/SecurityStore.sol"; | ||
import "../base/BaseModule.sol"; | ||
|
||
|
||
/// @title AddOfficialGuardianModule | ||
/// @dev This module adds the official guardian to a wallet and removes itself | ||
/// from the module list. | ||
/// | ||
/// @author Daniel Wang - <[email protected]> | ||
contract AddOfficialGuardianModule is BaseModule { | ||
ControllerImpl private controller_; | ||
address public officialGuardian; | ||
uint public officialGuardianGroup; | ||
|
||
constructor( | ||
ControllerImpl _controller, | ||
address _officialGuardian, | ||
uint _officialGuardianGroup | ||
) | ||
{ | ||
controller_ = _controller; | ||
officialGuardian = _officialGuardian; | ||
officialGuardianGroup = _officialGuardianGroup; | ||
} | ||
|
||
function controller() | ||
internal | ||
view | ||
override | ||
returns(ControllerImpl) | ||
{ | ||
return ControllerImpl(controller_); | ||
} | ||
|
||
function bindableMethods() | ||
public | ||
pure | ||
override | ||
returns (bytes4[] memory methods) | ||
{ | ||
} | ||
|
||
function activate() | ||
external | ||
override | ||
{ | ||
address payable wallet = msg.sender; | ||
|
||
SecurityStore ss = controller().securityStore(); | ||
require( | ||
ss.numGuardiansWithPending(wallet) == 0, | ||
"NOT_THE_FIRST_GUARDIAN" | ||
); | ||
|
||
ss.addGuardian( | ||
wallet, | ||
officialGuardian, | ||
officialGuardianGroup, | ||
block.timestamp | ||
); | ||
|
||
BaseWallet(wallet).removeModule(address(this)); | ||
} | ||
} |