Skip to content

Commit

Permalink
[Hebao_1.1] add AddOfficialGuardianModule (#1641)
Browse files Browse the repository at this point in the history
* compatible

* add OfficialGuardianModule

* add OfficialGuardianModule

* add OfficialGuardianModule

* Update AddOfficialGuardianModule.sol

Co-authored-by: wangdong <[email protected]>
  • Loading branch information
dong77 and wangdong authored Aug 24, 2020
1 parent ba41c2c commit 09da13d
Showing 1 changed file with 70 additions and 0 deletions.
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));
}
}

0 comments on commit 09da13d

Please sign in to comment.