Commit 4fa664db authored by Viktor Velev's avatar Viktor Velev

Added js import, function calling success

parent c0fc5f00
This diff is collapsed.
......@@ -2,6 +2,7 @@ var abi = [{"constant":true,"inputs":[{"name":"eventID","type":"uint256"},{"name
function init(){
console.log("success")
if (typeof web3 === 'undefined') {
//if there is no web3 variable
displayMessage("Error! Are you sure that you are using metamask?");
......@@ -13,12 +14,11 @@ function init(){
//this function will be called when the whole page is loaded
window.onload = function(){
init();
}
var inst;
var address = "0x5f9c1c404e70b85ace4ed48b6f7a40dd9dc89023";
var address = "0x369a165581ba94afcced493d49dc339e13505f29";
var acc;
//temp fix:
......@@ -29,7 +29,7 @@ var acc;
function connectContract(){
var Contract = web3.eth.contract(abi);
inst = Contract.at(address);
inst = Contract.at(address);
updateAccount();
}
......@@ -60,6 +60,8 @@ function isCallerAdmin() {
}
function getEventIDs() {
console.log(web3)
console.log(inst)
return new Promise((accept, reject) => {
inst.getEventIDs.call({"from": acc}, function(err, res){
if(!err) {
......@@ -83,7 +85,7 @@ function getEventByID(id) {
})
}
test();
//test();
function onButtonPressed(){
updateAccount();
......
......@@ -19,7 +19,8 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<script src="%PUBLIC_URL%/contract_operations.js"></script>
<title>Pun</title>
</head>
<body>
<noscript>
......
......@@ -5,6 +5,10 @@ import BetPage from './component/main'
import AdminPage from './component/admin'
class App extends Component {
componentDidMount() {
init(); //eslint-disable-line
}
routes = {
main: () => <BetPage/>,
admin: () => <AdminPage/>
......
......@@ -17,6 +17,11 @@ export default class BetPage extends Component {
constructor(props) {
super(props)
// Don't ask
setTimeout(() => getEventIDs(), 1) //eslint-disable-line
this.getAllEvents()
}
......
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