Skip to content

Commit

Permalink
Make addModule function public and override external interface defini…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
elenadimitrova committed Jun 12, 2020
1 parent a47c043 commit c03e3cc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
5 changes: 2 additions & 3 deletions contracts/modules/TransferManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ contract TransferManager is OnlyOwnerModule, BaseTransfer, LimitManager {
}
}

function addModule(address _wallet, address _module) external override(BaseModule, OnlyOwnerModule) onlyWalletOwner(_wallet) {
require(registry.isRegisteredModule(_module), "BM: module is not registered");
IWallet(_wallet).authoriseModule(_module, true);
function addModule(address _wallet, address _module) public override(BaseModule, OnlyOwnerModule) onlyWalletOwner(_wallet) {
OnlyOwnerModule.addModule(_wallet, _module);
}

// *************** External/Public Functions ********************* //
Expand Down
24 changes: 12 additions & 12 deletions contracts/modules/common/BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ contract BaseModule is IModule {
_;
}

/**
* @dev Utility method enbaling anyone to recover ERC20 token sent to the
* module by mistake and transfer them to the Module Registry.
* @param _token The token to recover.
*/
function recoverToken(address _token) external override {
uint total = ERC20(_token).balanceOf(address(this));
bool success = ERC20(_token).transfer(address(registry), total);
require(success, "BM: recover token transfer failed");
}

/**
* @dev Inits the module for a wallet by logging an event.
* The method can only be called by the wallet itself.
Expand All @@ -94,22 +105,11 @@ contract BaseModule is IModule {
* @param _wallet The target wallet.
* @param _module The modules to authorise.
*/
function addModule(address _wallet, address _module) external virtual override strictOnlyWalletOwner(_wallet) {
function addModule(address _wallet, address _module) public virtual override strictOnlyWalletOwner(_wallet) {
require(registry.isRegisteredModule(_module), "BM: module is not registered");
IWallet(_wallet).authoriseModule(_module, true);
}

/**
* @dev Utility method enbaling anyone to recover ERC20 token sent to the
* module by mistake and transfer them to the Module Registry.
* @param _token The token to recover.
*/
function recoverToken(address _token) external virtual override {
uint total = ERC20(_token).balanceOf(address(this));
bool success = ERC20(_token).transfer(address(registry), total);
require(success, "BM: recover token transfer failed");
}

/**
* @dev Verify that the wallet is unlocked.
* @param _wallet The target wallet.
Expand Down
14 changes: 7 additions & 7 deletions contracts/modules/common/IModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ pragma solidity >=0.5.4 <0.7.0;
*/
interface IModule {

/**
* @dev Utility method to recover any ERC20 token that was sent to the
* module by mistake.
* @param _token The token to recover.
*/
function recoverToken(address _token) external;

/**
* @dev Inits a module for a wallet by e.g. setting some wallet specific parameters in storage.
* @param _wallet The wallet.
Expand All @@ -37,11 +44,4 @@ interface IModule {
* @param _module The modules to authorise.
*/
function addModule(address _wallet, address _module) external;

/**
* @dev Utility method to recover any ERC20 token that was sent to the
* module by mistake.
* @param _token The token to recover.
*/
function recoverToken(address _token) external;
}
2 changes: 1 addition & 1 deletion contracts/modules/common/OnlyOwnerModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract contract OnlyOwnerModule is BaseModule, RelayerModule {
* @param _wallet The target wallet.
* @param _module The modules to authorise.
*/
function addModule(address _wallet, address _module) external override virtual onlyWalletOwner(_wallet) {
function addModule(address _wallet, address _module) public override virtual onlyWalletOwner(_wallet) {
require(registry.isRegisteredModule(_module), "BM: module is not registered");
IWallet(_wallet).authoriseModule(_module, true);
}
Expand Down

0 comments on commit c03e3cc

Please sign in to comment.