diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js new file mode 100644 index 0000000..ee2135d --- /dev/null +++ b/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/package.json b/package.json index ee0919f..4008b46 100644 --- a/package.json +++ b/package.json @@ -10,14 +10,42 @@ "@nomiclabs/hardhat-ethers": "^2.0.1", "@nomiclabs/hardhat-etherscan": "^2.0.1", "@nomiclabs/hardhat-waffle": "^2.0.0", - "chai": "^4.2.0", "ethereum-waffle": "^3.2.1", "ethers": "^5.0.23", - "hardhat": "^2.0.6" + "hardhat": "^2.0.6", + "babel-polyfill": "6.26.0", + "babel-preset-env": "1.7.0", + "babel-preset-es2015": "6.24.1", + "babel-preset-stage-2": "6.24.1", + "babel-preset-stage-3": "6.24.1", + "babel-register": "6.26.0", + "bootstrap": "4.3.1", + "chai-as-promised": "7.1.1", + "chai-bignumber": "3.0.0", + "css": "^3.0.0", + "react": "^16.8.4", + "react-bootstrap": "1.0.0-beta.5", + "react-dom": "16.8.4", + "react-scripts": "2.1.3", + "semantic": "0.0.1", + "semantic-ui-css": "^2.4.1", + "semantic-ui-react": "^2.0.3", + "truffle": "5.0.5", + "ui": "^0.2.4", + "web3": "1.0.0-beta.55" }, "scripts": { - "test": "npx hardhat test" + "test": "npx hardhat test", + "start": "react-scripts start", + "build": "react-scripts build", + "eject": "react-scripts eject" }, "author": "Zer0dot", - "license": "AGPL-3.0-only" + "license": "AGPL-3.0-only", + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ] } diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e19bbf1 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100755 index 0000000..e9f225e --- /dev/null +++ b/public/index.html @@ -0,0 +1,41 @@ + + +
+ + + + + + + + + + + + + + + diff --git a/public/manifest.json b/public/manifest.json new file mode 100755 index 0000000..53bb8fe --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Starter Kit", + "name": "Dapp University Starter Kit", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/src/abi/Operator.json b/src/abi/Operator.json new file mode 100644 index 0000000..95979c2 --- /dev/null +++ b/src/abi/Operator.json @@ -0,0 +1,43 @@ +[ + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "openVaultAndDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldOtoken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "rolloverAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rolloverStrike", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rolloverExpiry", + "type": "uint256" + } + ], + "name": "rollover", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/components/App.css b/src/components/App.css new file mode 100644 index 0000000..87b6089 --- /dev/null +++ b/src/components/App.css @@ -0,0 +1 @@ +/* Styles go here */ diff --git a/src/components/App.js b/src/components/App.js new file mode 100755 index 0000000..eaa06c8 --- /dev/null +++ b/src/components/App.js @@ -0,0 +1,194 @@ +import React, { Component } from 'react'; +import './App.css'; +import Web3 from 'web3' +import Operator from '../abi/Operator.json' + +import { Button, Card, Form, Input} from 'semantic-ui-react' + +class App extends Component { + + + async componentWillMount() { + await this.loadWeb3() + await this.loadBlockchainData() + } + + async loadBlockchainData() { + const web3 = window.web3 + + const accounts = await web3.eth.getAccounts() + this.setState({ account: accounts[0] }) + + + + // Load Token + const networkId = await web3.eth.net.getId() + + + const operator = new web3.eth.Contract(Operator.abi,"0xA391CE933dbdB66e6918965C06e157a25C923115") + this.setState({ operator }); + + + window.alert('Token contract not deployed to detected network.') + + + + + this.setState({ loading: false }) + } + + async loadWeb3() { + if (window.ethereum) { + window.web3 = new Web3(window.ethereum) + await window.ethereum.enable() + } + else if (window.web3) { + window.web3 = new Web3(window.web3.currentProvider) + } + else { + window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!') + } + } + + + constructor(props) { + super(props); + + this.state = { + account: '', + ethBalance: '0', + tokenBalance: '0', + loading: true, + operator:{}, + amount:1, + oldOtoken:"", + rolloverAmount:1, + rolloverStrike:1, + rolloverExpiry:1 + } + this.handleChange = this.handleChange.bind(this); + this.handlePolicySubmit = this.handlePolicySubmit.bind(this); + } + + async handlePolicySubmit(event){ + event.preventDefault(); + this.state.operator.methods.openVaultAndDeposit(this.state.amount).send({from: this.state.account }).on('transactionHash', (hash) => { + console.log(hash); + }) + } + + + async handlePolicySubmit1(event){ + event.preventDefault(); + this.state.operator.methods.rollover(this.state.oldOtoken,this.state.rolloverAmount,this.state.rolloverStrike,this.state.rolloverExpiry).send({from: this.state.account }).on('transactionHash', (hash) => { + console.log(hash); + }) + } + + handleChange(evt) { + this.setState({ [evt.target.name]: evt.target.value }); + } + + handleChange1(evt) { + this.setState({ [evt.target.name]: evt.target.value }); + } + + render() { + return ( + + ); + } +} + +export default App; diff --git a/contracts/Operator.sol b/src/contracts/Operator.sol similarity index 100% rename from contracts/Operator.sol rename to src/contracts/Operator.sol diff --git a/contracts/interface/IController.sol b/src/contracts/interface/IController.sol similarity index 100% rename from contracts/interface/IController.sol rename to src/contracts/interface/IController.sol diff --git a/contracts/interface/IOtokenFactory.sol b/src/contracts/interface/IOtokenFactory.sol similarity index 100% rename from contracts/interface/IOtokenFactory.sol rename to src/contracts/interface/IOtokenFactory.sol diff --git a/contracts/lib/Actions.sol b/src/contracts/lib/Actions.sol similarity index 100% rename from contracts/lib/Actions.sol rename to src/contracts/lib/Actions.sol diff --git a/src/index.js b/src/index.js new file mode 100755 index 0000000..bb91521 --- /dev/null +++ b/src/index.js @@ -0,0 +1,13 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import 'bootstrap/dist/css/bootstrap.css' +import App from './components/App'; +import * as serviceWorker from './serviceWorker'; +import 'semantic-ui-css/semantic.min.css'; + +ReactDOM.render(