forked from dharma-eng/dharma-smart-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add solium linter + clean up contracts
- Loading branch information
Showing
36 changed files
with
657 additions
and
82 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
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,15 @@ | ||
# skip | ||
node_modules | ||
contracts/mock/RelayContract.sol | ||
contracts/mock/RelayContractV2.sol | ||
|
||
# disagree with indentation error | ||
contracts/helpers/FactoryFactFinder.sol | ||
contracts/upgradeability/DharmaUpgradeBeaconController.sol | ||
|
||
# parsing error due to dynamic abi.decode - try again in later version | ||
contracts/implementations/smart-wallet/DharmaSmartWalletImplementationV0.sol | ||
contracts/implementations/smart-wallet/DharmaSmartWalletImplementationV1.sol | ||
contracts/implementations/smart-wallet/DharmaSmartWalletImplementationV2.sol | ||
contracts/implementations/smart-wallet/DharmaSmartWalletImplementationV3.sol | ||
contracts/implementations/smart-wallet/DharmaSmartWalletImplementationV4.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,28 @@ | ||
{ | ||
"extends": "solium:all", | ||
"plugins": [ | ||
"security" | ||
], | ||
"rules": { | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"indentation": [ | ||
"error", | ||
2 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"lbrace": "off", | ||
"arg-overflow": "off", | ||
"no-experimental": "off", | ||
"security/no-inline-assembly": "off", | ||
"security/no-call-value": "off", | ||
"security/no-low-level-calls": "off", | ||
"security/no-tx-origin": "off", | ||
"security/no-block-members": "off" | ||
} | ||
} |
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
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,34 @@ | ||
pragma solidity 0.5.11; | ||
|
||
import "../../interfaces/DharmaKeyRingImplementationV0Interface.sol"; | ||
|
||
|
||
/** | ||
* @title DharmaLocksmith | ||
* @author 0age | ||
* @notice This contract provides a helper function for setting new keys on a V0 | ||
* Dharma Key Ring. | ||
*/ | ||
contract DharmaLocksmith { | ||
/** | ||
* @notice Set a new signing key on a keyring using an existing signature on | ||
* the key ring. | ||
* @param keyRing address The key ring to set the new user signing key on. | ||
* @param newUserSigningKey address The new user signing key. | ||
* @param signature bytes The signature, validated from an existing key and | ||
* signed using a valid message hash. | ||
*/ | ||
function setAdditionalKey( | ||
address keyRing, address newUserSigningKey, bytes calldata signature | ||
) external { | ||
// Ensure that a key ring has been provided. | ||
require(keyRing != address(0), "No key ring supplied."); | ||
|
||
// Add the new key by providing it as an argument to the key ring. | ||
DharmaKeyRingImplementationV0Interface(keyRing).takeAdminAction( | ||
DharmaKeyRingImplementationV0Interface.AdminActionType.AddDualKey, | ||
uint160(newUserSigningKey), | ||
signature | ||
); | ||
} | ||
} |
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,123 @@ | ||
pragma solidity 0.5.11; | ||
|
||
import "../../interfaces/DharmaSmartWalletFactoryV1Interface.sol"; | ||
import "../../interfaces/DharmaKeyRingFactoryV1Interface.sol"; | ||
import "../../interfaces/DharmaSmartWalletImplementationV0Interface.sol"; | ||
|
||
|
||
/** | ||
* @title FactoryFactFinder (staging) | ||
* @author 0age | ||
* @notice This contract facilitates determining information on counterfactual | ||
* deployment addresses, as well as current deployment statuses, of Dharma Smart | ||
* Wallet + Dharma Key Ring pairs. | ||
*/ | ||
contract FactoryFactFinder { | ||
DharmaSmartWalletFactoryV1Interface private constant _smartWalletFactory = ( | ||
DharmaSmartWalletFactoryV1Interface( | ||
0x8D1e00b000e56d5BcB006F3a008Ca6003b9F0033 | ||
) | ||
); | ||
|
||
DharmaKeyRingFactoryV1Interface private constant _keyRingFactory = ( | ||
DharmaKeyRingFactoryV1Interface( | ||
0x06f3342295530DdFF6182f7a40906FD60cd19100 | ||
) | ||
); | ||
|
||
/** | ||
* @notice View function to find the address of the next key ring address that | ||
* will be deployed when supplying a given initial user signing key. Note that | ||
* a new value will be returned if a particular user signing key has been used | ||
* before. | ||
* @param userSigningKey address The user signing key, supplied as a | ||
* constructor argument. | ||
* @return The future address of the next key ring (with the user signing key | ||
* as its input) and of the next smart wallet (with the key ring address as | ||
* its input). | ||
*/ | ||
function getNextKeyRingAndSmartWallet( | ||
address userSigningKey | ||
) external view returns (address keyRing, address smartWallet) { | ||
// Ensure that a user signing key has been provided. | ||
require(userSigningKey != address(0), "No user signing key supplied."); | ||
|
||
// Get the next key ring address based on the signing key. | ||
keyRing = _keyRingFactory.getNextKeyRing(userSigningKey); | ||
|
||
// Determine the next smart wallet address based on the key ring address. | ||
smartWallet = _smartWalletFactory.getNextSmartWallet(keyRing); | ||
} | ||
|
||
/** | ||
* @notice View function to determine whether a given smart wallet has been | ||
* deployed as well as whether the corresponding keyring contract still needs | ||
* to be deployed for the smart wallet. | ||
* @return Two booleans, indicating if the smart wallet and/or the keyring are | ||
* deployed or not, and the address of the keyring. Note that keyRing and | ||
* keyRingDeployed will always return the null address and false in the event | ||
* that the smart wallet has not been deployed yet. | ||
*/ | ||
function getDeploymentStatuses( | ||
address smartWallet | ||
) external view returns ( | ||
bool smartWalletDeployed, | ||
bool keyRingDeployed, | ||
address keyRing | ||
) { | ||
// Ensure that a smart wallet address has been provided. | ||
require(smartWallet != address(0), "No smart wallet supplied."); | ||
|
||
// Determine if the smart wallet has been deployed. | ||
smartWalletDeployed = _hasContractCode(smartWallet); | ||
|
||
// Get keyring address and deployment status if smart wallet is deployed. | ||
if (smartWalletDeployed) { | ||
keyRing = DharmaSmartWalletImplementationV0Interface( | ||
smartWallet | ||
).getUserSigningKey(); | ||
|
||
keyRingDeployed = _hasContractCode(keyRing); | ||
} | ||
} | ||
|
||
/** | ||
* @notice View function for deriving the message hash that must be signed in | ||
* order to add a new key to a given key ring that has not yet been deployed | ||
* based on given parameters. Note that V0 does not include a prefix when | ||
* constructing the message hash. | ||
* @param keyRing address The yet-to-be-deployed keyring address. | ||
* @param additionalUserSigningKey address The additional user signing key to | ||
* add. | ||
* @return The message hash to sign. | ||
*/ | ||
function getFirstAdminActionHash( | ||
address keyRing, address additionalUserSigningKey | ||
) external view returns (bytes32 hash) { | ||
hash = keccak256( | ||
abi.encodePacked( | ||
keyRing, uint256(0), uint256(0), uint160(additionalUserSigningKey) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @notice View function to determine if a given account contains contract | ||
* code. | ||
* @return True if a contract is deployed at the address with code. | ||
*/ | ||
function hasContractCode(address target) external view returns (bool) { | ||
return _hasContractCode(target); | ||
} | ||
|
||
/** | ||
* @notice Internal view function to determine if a given account contains | ||
* contract code. | ||
* @return True if a contract is deployed at the address with code. | ||
*/ | ||
function _hasContractCode(address target) internal view returns (bool) { | ||
uint256 size; | ||
assembly { size := extcodesize(target) } | ||
return size > 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
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.