Commit 02e1a952 authored by kevinflo's avatar kevinflo

analytics. withdraw in ownable contract

parent 285005b8
......@@ -16,6 +16,12 @@ contract Ownable {
function transferOwnership(address _newOwner) onlyOwner public {
owner = _newOwner;
}
function withdraw(uint amount) onlyOwner public returns(bool) {
require(amount <= address(this).balance);
owner.transfer(amount);
return true;
}
}
contract Mortal is Ownable {
......
......@@ -4,7 +4,7 @@ const addresses = require('../addresses.json');
const instance = new web3.eth.Contract(
JSON.parse(Dposts.interface),
addresses.DPOSTS.MAINNET
addresses.DPOSTS.RINKEBY6
);
export default instance;
......@@ -7,7 +7,7 @@ if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
web3 = new Web3(window.web3.currentProvider);
web3.isServer = false;
} else {
const provider = new Web3.providers.HttpProvider(INFURA_MAINNET);
const provider = new Web3.providers.HttpProvider(INFURA_RINKEBY);
web3 = new Web3(provider);
web3.isServer = true;
}
......
......@@ -6,7 +6,7 @@
"scripts": {
"test": "mocha",
"dev": "node ./web/server.js",
"build": "next build",
"build": "next build ./web",
"start": "NODE_ENV=production node ./web/server.js"
},
"author": "Kflo",
......
......@@ -67,6 +67,12 @@ class BoardCreation extends React.Component {
const accounts = await web3.eth.getAccounts();
console.log('got accounts3', accounts);
this.setState({ accounts });
let feeWei =
typeof this.state.fee === 'number' && parseFloat(this.state.fee) > 0
? web3.utils.toWei(this.state.fee.toString())
: 0;
let gasCost = await dposts.methods
.createBoard(
web3.utils.asciiToHex(this.state.name),
......@@ -77,7 +83,7 @@ class BoardCreation extends React.Component {
this.state.allowPostTipping,
this.state.allowComments,
this.state.allowCommentTipping,
this.state.fee
feeWei
)
.estimateGas({ from: accounts[0] });
......@@ -91,7 +97,7 @@ class BoardCreation extends React.Component {
this.state.allowPostTipping,
this.state.allowComments,
this.state.allowCommentTipping,
this.state.fee
feeWei
)
.send({ gas: gasCost, from: accounts[0] });
......
......@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import HasMainNavbar from './HasMainNavbar';
import { Container } from 'reactstrap';
import '../styles/main-styles.scss';
import Head from 'next/head';
class Page extends Component {
constructor(props) {
......
......@@ -7,6 +7,8 @@ import Page from '../components/Page';
import BoardCreation from '../components/BoardCreation';
import BoardList from '../components/BoardList';
import { GA_KEY } from '../../secrets.json';
class Index extends React.Component {
constructor(props) {
super(props);
......@@ -32,6 +34,27 @@ class Index extends React.Component {
render() {
return (
<Page>
{process.env.NODE_ENV === 'production' && (
<React.Fragment>
<Head>
<script
dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${GA_KEY}');`
}}
/>
</Head>
<noscript
dangerouslySetInnerHTML={{
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${GA_KEY}" height="0" width="0" style="display:none;visibility:hidden;"></iframe>`
}}
/>
</React.Fragment>
)}
<Jumbotron>
<h1 className="display-3">Decentralized Posts</h1>
<p className="lead">
......@@ -40,17 +63,6 @@ class Index extends React.Component {
<a href="#boardList">
<Button color="primary">Show me the boards</Button>
</a>
{/* <div className="intro-vid-holder">
<iframe
width="560"
height="315"
src="https://emb.d.tube/#!/jacksonchakma/y5lvnttv"
frameBorder="0"
allowFullScreen
className="intro-vid"
/>
</div> */}
</Jumbotron>
<div
style={{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment