mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
Optimized if-else statements.
This commit is contained in:
parent
3ce7974f67
commit
e6b993bf54
|
|
@ -62,9 +62,18 @@ contract LogicRegistry is AddressRegistry {
|
||||||
function logic(address _logicAddress) public view returns (bool) {
|
function logic(address _logicAddress) public view returns (bool) {
|
||||||
if (defaultLogicProxies[_logicAddress] || logicProxies[_logicAddress]) {
|
if (defaultLogicProxies[_logicAddress] || logicProxies[_logicAddress]) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev
|
||||||
|
/// @param _logicAddress (address)
|
||||||
|
/// @return (bool)
|
||||||
|
function defaultLogic(address _logicAddress) public view returns (bool) {
|
||||||
|
if (defaultLogicProxies[_logicAddress]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Sets the default logic proxy to true
|
/// @dev Sets the default logic proxy to true
|
||||||
|
|
@ -114,12 +123,12 @@ contract WalletRegistry is LogicRegistry {
|
||||||
/// @dev update the proxy record whenever owner changed on any proxy
|
/// @dev update the proxy record whenever owner changed on any proxy
|
||||||
/// Throws if msg.sender is not a proxy contract created via this contract
|
/// Throws if msg.sender is not a proxy contract created via this contract
|
||||||
/// @return proxy () UserWallet
|
/// @return proxy () UserWallet
|
||||||
function build(address owner) public returns (UserWallet proxy) {
|
function build(address _owner) public returns (UserWallet proxy) {
|
||||||
require(proxies[owner] == UserWallet(0), "multiple-proxy-per-user-not-allowed");
|
require(proxies[_owner] == UserWallet(0), "multiple-proxy-per-user-not-allowed");
|
||||||
proxy = new UserWallet();
|
proxy = new UserWallet();
|
||||||
proxies[address(this)] = proxy; // will be changed via record() in next line execution
|
proxies[address(this)] = proxy; // will be changed via record() in next line execution
|
||||||
proxy.setOwner(owner);
|
proxy.setOwner(_owner);
|
||||||
emit Created(msg.sender, owner, address(proxy));
|
emit Created(msg.sender, _owner, address(proxy));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Transafers ownership
|
/// @dev Transafers ownership
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,8 @@ contract UserAuth is AddressRecord {
|
||||||
return true;
|
return true;
|
||||||
} else if (src == address(this)) {
|
} else if (src == address(this)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user