-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ivan Rukhavets <[email protected]> Co-authored-by: Dmytro Maretskyi <[email protected]> Co-authored-by: Anze1m <[email protected]>
- Loading branch information
Showing
53 changed files
with
9,070 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.sol] | ||
indent_size = 4 |
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,33 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"eslint:recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json", | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"no-redeclare": "off", | ||
"no-unused-vars": "off" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"test/**/*.{js,ts,tsx}" | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"no-unused-expressions": "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 @@ | ||
*.sol linguist-language=Solidity |
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,21 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
node: ['10.x', '12.x'] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn lint | ||
- run: yarn build | ||
- run: 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,3 @@ | ||
node_modules | ||
build | ||
yarn-error.log |
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 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"bracketSpacing": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"tabWidth": 4, | ||
"explicitTypes": "always" | ||
} | ||
} | ||
] | ||
} |
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,20 @@ | ||
import { | ||
createArtifact, | ||
NumberLike, | ||
AddressLike, | ||
NumberLike, | ||
FutureNumber, | ||
Transaction, | ||
Result // null as any | ||
} from 'ethereum-mars' | ||
|
||
export const Token = createArtifact({ | ||
name: 'Token', | ||
constructor: (totalSupply: NumberLike): void => Result, | ||
methods: { | ||
transfer: (to: AddressLike, value: NumberLike): Transaction => Result, | ||
balanceOf: (account: AddressLike): FutureNumber => Result, | ||
}, | ||
abi: [/* ... */], | ||
bytecode: '...', | ||
}) |
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,97 @@ | ||
// use | ||
|
||
import { run, contract, switchChain } from 'ethereum-mars' | ||
import * as Mainnet from '../build/artifacts.ts' | ||
import * as Ropsten from '../build2/artifacts.ts' | ||
|
||
// cli arguments | ||
// environment | ||
// options in code | ||
|
||
|
||
// AddressLike: string, FutureString, Contract, Wallet | ||
// NumberLike: number, string, BigNumber, FutureBigNumber, FutureNumber, BigNumberish? | ||
// BooleanLike | ||
// BytesLike | ||
// StringLike: string, FutureString | ||
|
||
// $ mars generate inDir outFile | ||
|
||
// $ ts-node scripts/deploy.ts [--network ropsten] | ||
// $ mars scripts/deploy.ts [--network ropsten] | ||
|
||
|
||
// tasks | ||
// 1. generate (Dima) | ||
// 2. cli for script (config) -> (options) | ||
// - arguments | ||
// - env variables | ||
// - pretty print | ||
// 3. syntax | ||
// 3.1 contract | ||
// 3.2 method | ||
// 3.3 Future | ||
// 4. runner | ||
// 4.1 fork | ||
// 4.2 actual | ||
// 4.3 deployments.json | ||
|
||
const options = { | ||
gasPrice: 32 | ||
} | ||
|
||
run(options, () => { | ||
const Token = switchChain({ | ||
mainnet: Mainnet.Token, | ||
ropsten: Ropsten.Token | ||
}) | ||
|
||
const dai = contract('dai', Token) // FutureContract | ||
const supply = dai.totalSupply() // FutureBigNumber | ||
const btc = contract('btc', Token) | ||
contract(Market, [dai, btc, supply]) | ||
}) | ||
|
||
// type Action = { | ||
// kind: 'DEPLOY' | ||
// aftifact: Artifact, | ||
// args: Future[] | ||
// resolveTo: Future | ||
// } | { | ||
// kind: 'CALL', | ||
// contract: Contract | ||
// args: Future[] | ||
// resolveTo: Future | ||
// } | ||
// output is saved to deployment.json | ||
|
||
// api | ||
|
||
// just deploy, name is "artifact" | ||
contract(Artifact) | ||
// deploy with constructor parameters | ||
contract(Artifact, [a, b]) | ||
// deploy with named constructor parameters | ||
contract(Artifact, { a: 1, b: 'foo' }) | ||
// deploy with name "bob" | ||
contract('bob', Artifact) | ||
// deploy with name and constructor parameters | ||
contract('bob', Artifact, [a, b]) | ||
// deploy with name and named constructor parameters | ||
contract('bob', Artifact, { a: 1, b: 'foo' }) | ||
// deploy with options | ||
contract(Artifact, [], { | ||
useUniversalDeployer: true | ||
}) | ||
// deploy with name and options | ||
contract('bob', Artifact, [], { | ||
useUniversalDeployer: true | ||
}) | ||
// deploy with name and constructor parameters and options | ||
contract('bob', Artifact, [a, b], { | ||
useUniversalDeployer: true | ||
}) | ||
// deploy with name and named constructor parameters and options | ||
contract('bob', Artifact, { a: 1, b: 'foo' }, { | ||
useUniversalDeployer: true | ||
}) |
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,20 @@ | ||
{ | ||
"name": "ethereum-mars-monorepo", | ||
"private": true, | ||
"engines": { | ||
"node": ">=10", | ||
"yarn": "^1.17.3" | ||
}, | ||
"workspaces": { | ||
"packages": ["packages/*"], | ||
"nohoist": ["**/prettier-plugin-solidity"] | ||
}, | ||
"scripts": { | ||
"lint": "wsrun -c lint", | ||
"build": "wsrun -te -c build", | ||
"test": "wsrun -te -c test" | ||
}, | ||
"dependencies": { | ||
"wsrun": "^5.2.1" | ||
} | ||
} |
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 @@ | ||
const baseConfig = require('../../.eslintrc.json') | ||
|
||
module.exports = { | ||
...baseConfig, | ||
} |
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 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "./test/**/*.test.ts", | ||
"require": "ts-node/register", | ||
"timeout": 12000 | ||
} |
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,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.8; | ||
|
||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
||
contract Market { | ||
IERC20 public xToken; | ||
IERC20 public yToken; | ||
|
||
event Supply(uint256, uint256); | ||
|
||
constructor(IERC20 _xToken, IERC20 _yToken) public { | ||
xToken = _xToken; | ||
yToken = _yToken; | ||
} | ||
|
||
function supply(uint256 xAmount, uint256 yAmount) public { | ||
xToken.transferFrom(msg.sender, address(this), xAmount); | ||
yToken.transferFrom(msg.sender, address(this), yAmount); | ||
emit Supply(xAmount, yAmount); | ||
} | ||
|
||
function trade(uint256 xAmount) public { | ||
require(xAmount > 0, "amount is 0"); | ||
uint256 amount = (xAmount * yToken.balanceOf(address(this))) / | ||
xToken.balanceOf(address(this)); | ||
xToken.transferFrom(msg.sender, address(this), xAmount); | ||
yToken.transfer(msg.sender, amount); | ||
} | ||
} |
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.8; | ||
|
||
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract Token is ERC20 { | ||
constructor() public ERC20("Token", "Tkn") { | ||
_mint(msg.sender, 2000); | ||
} | ||
} |
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 @@ | ||
{ | ||
"kovan": { | ||
"dai": { | ||
"txHash": "0x26784f64fec2ed4d0a1e0b4e9f7d39381081ca509783825bb150bd4620d93cd3", | ||
"address": "0xE92b6a4478F40eD4e84253A24e19Bd712B4d979e" | ||
}, | ||
"btc": { | ||
"txHash": "0x79bb3a7ac9b9d13fc7c78c2aacc6b0efab27e0577835e587d509a830a57f5b4e", | ||
"address": "0xe5DE2f4aDb01dCA209fF4D6F4Ab781612c02f50a" | ||
}, | ||
"market": { | ||
"txHash": "0x87286eef4cf357b8097d640cd44793f409e6cb65efdf5f303504bd4090520445", | ||
"address": "0x347FF02141dE0300528CDF0b768bF3189986DAE0" | ||
} | ||
} | ||
} |
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,36 @@ | ||
{ | ||
"name": "example", | ||
"private": true, | ||
"version": "0.1.0", | ||
"engines": { | ||
"node": ">=10", | ||
"yarn": "^1.17.3" | ||
}, | ||
"scripts": { | ||
"lint": "yarn lint:prettier --check && yarn lint:eslint", | ||
"lint:fix": "yarn lint:prettier --write && yarn lint:eslint --fix", | ||
"lint:eslint": "eslint './{src,test}/**/*.ts'", | ||
"lint:prettier": "prettier './{src,test}/**/*.ts'", | ||
"build": "yarn waffle && mars", | ||
"deploy": "ts-node src/index.ts", | ||
"test": "mocha" | ||
}, | ||
"dependencies": { | ||
"ethereum-mars": "0.1.0" | ||
}, | ||
"devDependencies": { | ||
"@openzeppelin/contracts": "^3.2.0", | ||
"@types/chai": "^4.2.13", | ||
"@types/mocha": "^8.0.3", | ||
"@typescript-eslint/eslint-plugin": "^4.4.1", | ||
"@typescript-eslint/parser": "^4.4.1", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.11.0", | ||
"ethereum-waffle": "^3.1.1", | ||
"mocha": "^8.1.3", | ||
"prettier": "^2.1.2", | ||
"prettier-plugin-solidity": "^1.0.0-alpha.59", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
} | ||
} |
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,10 @@ | ||
import { contract, deploy } from 'ethereum-mars' | ||
import { Market, Token } from '../build/artifacts' | ||
|
||
deploy({}, () => { | ||
const dai = contract('dai', Token) | ||
const btc = contract('btc', Token) | ||
const market = contract(Market, [dai, btc]) | ||
dai.approve(market, dai.totalSupply().add(42)) | ||
btc.approve(market, btc.totalSupply()) | ||
}) |
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,7 @@ | ||
import { expect } from 'chai' | ||
|
||
describe('the * symbol', () => { | ||
it('multiplies numbers', () => { | ||
expect(2 * 3).to.equal(6) | ||
}) | ||
}) |
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": true | ||
} | ||
} |
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 @@ | ||
const baseConfig = require('../../.eslintrc.json') | ||
|
||
module.exports = { | ||
...baseConfig, | ||
} |
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 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "./test/**/*.test.ts", | ||
"require": "ts-node/register", | ||
"timeout": 12000 | ||
} |
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,7 @@ | ||
Copyright 2020 Ethworks | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 @@ | ||
#!/usr/bin/env node | ||
|
||
require('./build/src/bin.js') |
Oops, something went wrong.