From 594e4f3e96b5efa1181d42b10bdc5e4d9eb3ef7c Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 4 Oct 2018 22:31:39 -0400 Subject: [PATCH] FIxing showing ENS section conditions --- README.md | 2 +- app/js/index.js | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5bf8e1e..91e056a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To generate the codes, execute `node server/codegen.js`. This comand will output A nodejs service was created to receive funding requests. It requires a geth light node to run 0. `chmod 600 server/config.js` 1. Edit `server/config.js` and set the contract address and the private key of the controller address. -2. `npm start` +2. `node server/main.js` ### Running the dapp. 0. `embark run` diff --git a/app/js/index.js b/app/js/index.js index 5c8db89..6f6cb0f 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -46,8 +46,7 @@ class App extends React.Component { async redirectIfProcessed(code){ const sentToAddress = await SNTGiveaway.methods.sentToAddress(web3.eth.defaultAccount).call(); const usedCode = await SNTGiveaway.methods.codeUsed( '0x' + code,).call(); - - if(sentToAddress || usedCode){ + if(sentToAddress && usedCode){ this.setState({showENSLink: true}); } } @@ -94,12 +93,11 @@ class App extends React.Component { } const response = await axios.post('http://localhost:3000/requestFunds/', record); - - console.log(response); + if(response.data.error){ + this.setState({error: true, errorMessage: response.data.message}); + } // TODO: avoid people spamming with localstorage - } else { - console.log("Transaction already exists"); } setInterval(async () => { @@ -119,7 +117,7 @@ class App extends React.Component { { !ready && !error &&

Add a loading message / indicator that the dapp is checking whether the code is valid or not

} - { ready && !showENSLink &&

Add a message indicating that the code has been received, and we're processing the trx

} + { ready && !error && !showENSLink &&

Add a message indicating that the code has been received, and we're processing the trx

} { showENSLink && !error &&

Show link or redirect to ENS DAPP

}