forked from ethereum-optimism/optimism
-
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.
Merge pull request ethereum-optimism#66 from ethereum-optimism/m/depo…
…sit-contract
- Loading branch information
Showing
17 changed files
with
10,803 additions
and
45 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,5 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
typechain | ||
coverage* |
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,24 @@ | ||
module.exports = { | ||
env: { | ||
browser: false, | ||
es2021: true, | ||
mocha: true, | ||
node: true, | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'standard', | ||
'plugin:prettier/recommended', | ||
'plugin:node/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
}, | ||
rules: { | ||
'node/no-unsupported-features/es-syntax': [ | ||
'error', | ||
{ ignores: ['modules'] }, | ||
], | ||
}, | ||
} |
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,3 @@ | ||
artifacts | ||
cache | ||
typechain |
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,3 @@ | ||
hardhat.config.ts | ||
scripts | ||
test |
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,6 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
typechain | ||
coverage* | ||
gasReporterOutput.json |
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,24 @@ | ||
module.exports = { | ||
$schema: 'http://json.schemastore.org/prettierrc', | ||
trailingComma: 'es5', | ||
tabWidth: 2, | ||
semi: false, | ||
singleQuote: true, | ||
arrowParens: 'always', | ||
overrides: [ | ||
{ | ||
files: '*.sol', | ||
options: { | ||
// These options are native to Prettier. | ||
printWidth: 100, | ||
tabWidth: 4, | ||
useTabs: false, | ||
singleQuote: false, | ||
bracketSpacing: true, | ||
// These options are specific to the Solidity Plugin | ||
explicitTypes: 'always', | ||
compiler: '0.8.10', | ||
}, | ||
}, | ||
], | ||
} |
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,16 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"compiler-version": "off", | ||
"code-complexity": ["warn", 5], | ||
"max-line-length": ["error", 100], | ||
"func-param-name-mixedcase": "error", | ||
"modifier-name-mixedcase": "error", | ||
"ordering": "warn", | ||
"avoid-low-level-calls": "off", | ||
"reason-string": "off", | ||
"avoid-tx-origin": "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,17 @@ | ||
# Contracts for OVM 1.0 | ||
|
||
## Usage | ||
|
||
Install with yarn (v1), and Node.js (14+). | ||
|
||
```shell | ||
yarn | ||
``` | ||
|
||
### Running Tests | ||
|
||
Tests are executed via `yarn`: | ||
|
||
```shell | ||
yarn test | ||
``` |
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,51 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.10; | ||
|
||
/** | ||
* @title DepositFeed | ||
*/ | ||
contract DepositFeed { | ||
// Constant for address aliasing | ||
uint160 private constant OFFSET = uint160(0x1111000000000000000000000000000000001111); | ||
|
||
/** | ||
* Event with the parameters required to derive transactions on L2. | ||
*/ | ||
event TransactionDeposited( | ||
address indexed from, | ||
address indexed to, | ||
uint256 value, | ||
uint256 gasLimit, | ||
bool isCreation, | ||
bytes data | ||
); | ||
|
||
/** | ||
* Accepts deposits of ETH and data, and emits a TransactionDeposited event for use in deriving | ||
* deposit transactions. | ||
* @param _to The L2 destination address. | ||
* @param _gasLimit The L2 gasLimit. | ||
* @param _isCreation Whether or not the transaction should be contract creation. | ||
* @param _data The input data. | ||
*/ | ||
function depositTransaction( | ||
address _to, | ||
uint256 _gasLimit, | ||
bool _isCreation, | ||
bytes memory _data | ||
) external payable { | ||
if (_isCreation && _to != address(0)) { | ||
revert("Contract creation deposits must not specify a recipient address."); | ||
} | ||
|
||
address from = msg.sender; | ||
// Transform the from-address to its alias if the caller is a contract. | ||
if (msg.sender != tx.origin) { | ||
unchecked { | ||
from = address(uint160(msg.sender) + OFFSET); | ||
} | ||
} | ||
|
||
emit TransactionDeposited(from, _to, msg.value, _gasLimit, _isCreation, _data); | ||
} | ||
} |
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,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.10; | ||
|
||
/** | ||
* For use in testing with a call from a contract rather than an EOA. | ||
*/ | ||
contract Dummy { | ||
/** | ||
* Forwards a call. | ||
* @param _target Address to call | ||
* @param _data Data to forward | ||
*/ | ||
function forward(address _target, bytes calldata _data) external payable { | ||
(bool success, bytes memory ret) = _target.call{ value: msg.value }(_data); | ||
// Silence the 'Return value of low-level calls not used' warning. | ||
success; | ||
ret; | ||
} | ||
} |
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,24 @@ | ||
import { HardhatUserConfig, task } from 'hardhat/config' | ||
import '@nomiclabs/hardhat-waffle' | ||
import '@typechain/hardhat' | ||
import 'hardhat-gas-reporter' | ||
import 'solidity-coverage' | ||
|
||
task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => { | ||
const accounts = await hre.ethers.getSigners() | ||
|
||
for (const account of accounts) { | ||
console.log(account.address) | ||
} | ||
}) | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: '0.8.10', | ||
networks: {}, | ||
gasReporter: { | ||
enabled: process.env.REPORT_GAS !== undefined, | ||
currency: 'USD', | ||
}, | ||
} | ||
|
||
export default config |
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,53 @@ | ||
{ | ||
"name": "@eth-optimism/specs-contracts", | ||
"version": "0.1.0", | ||
"description": "Contracts for Optimism Specs", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"hardhat": "^2.7.1" | ||
}, | ||
"scripts": { | ||
"test": "hardhat test", | ||
"lint:ts:check": "eslint .", | ||
"lint:contracts:check": "yarn solhint -f table 'contracts/**/*.sol'", | ||
"lint:check": "yarn lint:contracts:check && yarn lint:ts:check", | ||
"lint:ts:fix": "prettier --write .", | ||
"lint:contracts:fix": "prettier --write 'contracts/**/*.sol'", | ||
"lint:fix": "yarn lint:contracts:fix && yarn lint:ts:fix", | ||
"lint": "yarn lint:fix && yarn lint:check" | ||
}, | ||
"devDependencies": { | ||
"@eth-optimism/core-utils": "^0.7.3", | ||
"@nomiclabs/hardhat-ethers": "^2.0.0", | ||
"@nomiclabs/hardhat-etherscan": "^2.1.3", | ||
"@nomiclabs/hardhat-waffle": "^2.0.0", | ||
"@typechain/ethers-v5": "^7.0.1", | ||
"@typechain/hardhat": "^2.3.0", | ||
"@types/chai": "^4.2.21", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^12.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.29.1", | ||
"@typescript-eslint/parser": "^4.29.1", | ||
"chai": "^4.2.0", | ||
"dotenv": "^10.0.0", | ||
"eslint": "^7.29.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-standard": "^16.0.3", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"ethereum-waffle": "^3.0.0", | ||
"ethers": "^5.0.0", | ||
"hardhat-gas-reporter": "^1.0.4", | ||
"prettier": "^2.3.2", | ||
"prettier-plugin-solidity": "^1.0.0-beta.13", | ||
"solhint": "^3.3.6", | ||
"solhint-plugin-prettier": "^0.0.5", | ||
"solidity-coverage": "^0.7.16", | ||
"ts-node": "^10.1.0", | ||
"typechain": "^5.1.2", | ||
"typescript": "^4.5.2" | ||
} | ||
} |
Oops, something went wrong.