diff --git a/src/App.js b/src/App.js index 0240a8867..6fb9d1466 100644 --- a/src/App.js +++ b/src/App.js @@ -35,7 +35,6 @@ import Vendors from './components/Vendors'; import RecentTransactions from './components/RecentTransactions'; import Footer from './components/Footer'; import Loader from './components/Loader'; -import burnerlogo from './burnerwallet.png'; import BurnWallet from './components/BurnWallet' import Exchange from './components/Exchange' import Bottom from './components/Bottom'; @@ -43,13 +42,13 @@ import customRPCHint from './customRPCHint.png'; import namehash from 'eth-ens-namehash' import incogDetect from './services/incogDetect.js' import core, { mainAsset as xdai } from './core'; +import { token, XDAI_PROVIDER, WEB3_PROVIDER, ERC20IMAGE, LOADERIMAGE, } from './assets'; +import bufficorn from './bufficorn.png'; //https://github.com/lesnitsky/react-native-webview-messaging/blob/v1/examples/react-native/web/index.js import RNMessageChannel from 'react-native-webview-messaging'; -import bufficorn from './bufficorn.png'; -import cypherpunk from './cypherpunk.png'; import ethImg from './images/ethereum.png'; import daiImg from './images/dai.jpg'; import xdaiImg from './images/xdai.jpg'; @@ -58,20 +57,6 @@ import Wyre from './services/wyre'; let base64url = require('base64url') const EthCrypto = require('eth-crypto'); -//const POA_XDAI_NODE = "https://dai-b.poa.network" -const POA_XDAI_NODE = "https://dai.poa.network" - -const MAINNET_CHAIN_ID = '1'; - -let XDAI_PROVIDER = POA_XDAI_NODE - -let WEB3_PROVIDER -let CLAIM_RELAY -let ERC20TOKEN -let ERC20VENDOR -let ERC20IMAGE -let ERC20NAME -let LOADERIMAGE = burnerlogo let HARDCODEVIEW// = "loader"// = "receipt" let FAILCOUNT = 0 @@ -90,66 +75,9 @@ let titleImage = ( ) -// -if (window.location.hostname.indexOf("localhost") >= 0 || window.location.hostname.indexOf("10.0.0.107") >= 0) { - XDAI_PROVIDER = "http://localhost:8545" - WEB3_PROVIDER = "http://localhost:8545"; - CLAIM_RELAY = 'http://localhost:18462' - if(true){ - ERC20NAME = false - ERC20TOKEN = false - ERC20IMAGE = false - }else{ - ERC20NAME = 'BUFF' - ERC20VENDOR = 'VendingMachine' - ERC20TOKEN = 'ERC20Vendable' - ERC20IMAGE = bufficorn - XDAI_PROVIDER = "http://localhost:8545" - WEB3_PROVIDER = "http://localhost:8545"; - LOADERIMAGE = bufficorn - } -} -else if (window.location.hostname.indexOf("s.xdai.io") >= 0) { - WEB3_PROVIDER = POA_XDAI_NODE; - CLAIM_RELAY = 'https://x.xdai.io' - ERC20TOKEN = false//'Burner' -} -else if (window.location.hostname.indexOf("wallet.galleass.io") >= 0) { - //WEB3_PROVIDER = "https://rinkeby.infura.io/v3/e0ea6e73570246bbb3d4bd042c4b5dac"; - WEB3_PROVIDER = "http://localhost:8545" - //CLAIM_RELAY = 'https://x.xdai.io' - ERC20TOKEN = false//'Burner' - document.domain = 'galleass.io' -} -else if (window.location.hostname.indexOf("qreth") >= 0) { - WEB3_PROVIDER = "https://mainnet.infura.io/v3/e0ea6e73570246bbb3d4bd042c4b5dac" - CLAIM_RELAY = false - ERC20TOKEN = false -} -else if (window.location.hostname.indexOf("xdai") >= 0) { - WEB3_PROVIDER = POA_XDAI_NODE; - CLAIM_RELAY = 'https://x.xdai.io' - ERC20TOKEN = false -} -else if (window.location.hostname.indexOf("buffidai") >= 0) { - WEB3_PROVIDER = POA_XDAI_NODE; - CLAIM_RELAY = 'https://x.xdai.io' - ERC20NAME = 'BUFF' - ERC20VENDOR = 'VendingMachine' - ERC20TOKEN = 'ERC20Vendable' - ERC20IMAGE = bufficorn - LOADERIMAGE = bufficorn -} -else if (window.location.hostname.indexOf("burnerwithrelays") >= 0) { - WEB3_PROVIDER = "https://dai.poa.network"; - ERC20NAME = false - ERC20TOKEN = false - ERC20IMAGE = false -} - -if(ERC20NAME=="BUFF"){ +if(token && token.name === "BUFF"){ mainStyle.backgroundImage = "linear-gradient(#540d48, #20012d)" mainStyle.backgroundColor = "#20012d" mainStyle.mainColor = "#b6299e" @@ -163,20 +91,6 @@ if(ERC20NAME=="BUFF"){ marginTop:-10 }}/> ) -} else if(ERC20NAME=="BURN"){ - mainStyle.backgroundImage = "linear-gradient(#4923d8, #6c0664)" - mainStyle.backgroundColor = "#6c0664" - mainStyle.mainColor = "#e72da3" - mainStyle.mainColorAlt = "#f948b8" - title = "Burner" - titleImage = ( - - ) } @@ -487,55 +401,6 @@ class App extends Component { } - - //console.log(">>>>>>> <<< >>>>>> Looking into iframe...") - //console.log(document.getElementById('galleassFrame').contentWindow['web3']) - - if(ERC20TOKEN&&this.state.contracts&&(this.state.network=="xDai"||this.state.network=="Unknown")){ - let gasBalance = await this.state.web3.eth.getBalance(this.state.account) - gasBalance = this.state.web3.utils.fromWei(""+gasBalance,'ether') - //console.log("Getting balanceOf "+this.state.account+" in contract ",this.state.contracts[ERC20TOKEN]) - let tokenBalance = await this.state.contracts[ERC20TOKEN].balanceOf(this.state.account).call() - //console.log("balance is ",tokenBalance) - tokenBalance = this.state.web3.utils.fromWei(""+tokenBalance,'ether') - - //console.log("Getting admin from ",this.state.contracts[ERC20VENDOR]) - let isAdmin = await this.state.contracts[ERC20VENDOR].isAdmin(this.state.account).call() - //console.log("ISADMIN",this.state.account,isAdmin) - let isVendor = await this.state.contracts[ERC20VENDOR].vendors(this.state.account).call() - //console.log("isVendor",isVendor) - - let vendorObject = this.state.vendorObject - let products = []//this.state.products - if(isVendor.isAllowed){ - //console.log("LOADING VENDOR PRODUCTS") - let id = 0 - if(!vendorObject){ - let vendorData = await this.state.contracts[ERC20VENDOR].vendors(this.state.account).call() - //console.log("vendorData",vendorData) - vendorData.name = this.state.web3.utils.hexToUtf8(vendorData.name) - vendorObject = vendorData - } - //console.log("Looking up products for vendor ",this.state.account) - if(!products){ - products = [] - } - let found = true - while(found){ - let nextProduct = await this.state.contracts[ERC20VENDOR].products(this.state.account,id).call() - if(nextProduct.exists){ - products[id++] = nextProduct - }else{ - found=false - } - } - } - //console.log("isVendor",isVendor,"SAVING PRODUCTS",products) - - this.setState({gasBalance:gasBalance,balance:tokenBalance,isAdmin:isAdmin,isVendor:isVendor,hasUpdateOnce:true,vendorObject,products}) - } - - if(this.state.account){ const ethBalance = await eth.getDisplayBalance(this.state.account, 20); const daiBalance = await dai.getDisplayBalance(this.state.account, 20); @@ -554,6 +419,42 @@ class App extends Component { this.selectBadge(singleBadgeId) } + if(token){ + const gasAsset = token.network === '100' ? xdai : eth; + const gasBalance = await gasAsset.getDisplayBalance(this.state.account, 10); + const tokenBalance = await token.getDisplayBalance(this.state.account, 10); + + const isAdmin = await this.state.contracts.VendingMachine.isAdmin(this.state.account).call(); + const isVendor = await this.state.contracts.VendingMachine.vendors(this.state.account).call(); + + let vendorObject = this.state.vendorObject + const products = []; + if(isVendor.isAllowed){ + if(!vendorObject){ + let vendorData = await this.state.contracts.VendingMachine.vendors(this.state.account).call(); + vendorData.name = this.state.web3.utils.hexToUtf8(vendorData.name) + vendorObject = vendorData + } + + let id = 0; + let lastProduct = null; + do { + lastProduct = await this.state.contracts.VendingMachine.products(this.state.account,id).call(); + products.push(lastProduct); + id++; + } while (lastProduct); + } + + this.setState({ + hasUpdateOnce: true, + gasBalance, + balance: tokenBalance, + isAdmin, + isVendor, + vendorObject, + products, + }); + } } @@ -986,7 +887,7 @@ sortAndSaveTransactions(recentTxs,transactionsByAddress){ localStorage.setItem(this.state.account+"transactionsByAddress",JSON.stringify(transactionsByAddress)) this.setState({recentTxs:recentTxs,transactionsByAddress:transactionsByAddress},()=>{ - if(ERC20TOKEN){ + if(token){ this.syncFullTransactions() } }) @@ -1000,7 +901,7 @@ async addAllTransactionsFromList(recentTxs,transactionsByAddress,theList){ cleanEvent.to = cleanEvent.to.toLowerCase() cleanEvent.from = cleanEvent.from.toLowerCase() cleanEvent.value = this.state.web3.utils.fromWei(""+cleanEvent.value,'ether') - cleanEvent.token = ERC20TOKEN + cleanEvent.token = token ? 'ERC20Vendable' : null; if(cleanEvent.data) { let decrypted = await this.decryptInput(cleanEvent.data) if(decrypted){ @@ -1085,7 +986,7 @@ render() { metaAccount={metaAccount} onReady={(state) => { console.log("Transactions component is ready:", state); - if(ERC20TOKEN){ + if(token){ state.nativeSend = state.send //delete state.send state.send = tokenSend.bind(this) @@ -1116,7 +1017,7 @@ render() { } let totalBalance = parseFloat(this.state.ethBalance) * parseFloat(this.state.ethprice) + parseFloat(this.state.daiBalance) + parseFloat(this.state.xdaiBalance) - if(ERC20TOKEN){ + if(token){ totalBalance += parseFloat(this.state.balance) } @@ -1168,7 +1069,7 @@ render() { ) let subBalanceDisplay = "" - if(ERC20TOKEN){ + if(token){ if(!this.state.gasBalance){ subBalanceDisplay = "" }else{ @@ -1184,8 +1085,6 @@ render() { moreButtons = (
) - }else if(this.state.isVendor&&this.state.isVendor.isAllowed){ + }else if(this.state.isVendor){ moreButtons = (
) - }else if(ERC20TOKEN){ + }else if(token){ moreButtons = (
{ @@ -1317,7 +1215,7 @@ render() { buttonStyle={buttonStyle} saveKey={this.saveKey.bind(this)} metaAccount={this.state.metaAccount} - transactionsByAddress={ERC20TOKEN?this.state.fullTransactionsByAddress:this.state.transactionsByAddress} + transactionsByAddress={token ? this.state.fullTransactionsByAddress : this.state.transactionsByAddress} address={account} balance={balance} changeAlert={this.changeAlert} @@ -1357,11 +1255,18 @@ render() {
) - if(ERC20TOKEN){ - selected = ERC20NAME + if(token){ + selected = token.name extraTokens = (
- +
) @@ -1428,19 +1333,17 @@ render() { changeAlert={this.changeAlert} changeView={this.changeView} dollarDisplay={dollarDisplay} - ERC20TOKEN={ERC20TOKEN} /> {moreButtons} {defaultBalanceDisplay} { + sendWithLink={(amount, cb)=>{ let randomHash = this.state.web3.utils.sha3(""+Math.random()) let randomWallet = this.state.web3.eth.accounts.create() let sig = this.state.web3.eth.accounts.sign(randomHash, randomWallet.privateKey); console.log("STATE",this.state,this.state.contracts) // Use xDai as default token - const tokenAddress = ERC20TOKEN === false ? 0 : this.state.contracts[ERC20TOKEN]._address; + const tokenAddress = token ? 0 : token.address; // -- Temp hacks const expirationTime = 365; // Hard-coded to 1 year link expiration. const amountToSend = amount*10**18 ; // Conversion to wei // -- - if(!ERC20TOKEN) + if(!token) { this.state.tx(this.state.contracts.Links.send(randomHash,sig.signature,tokenAddress,amountToSend,expirationTime),250000,false,amountToSend,async (receipt)=>{ this.setState({sendLink: randomHash,sendKey: randomWallet.privateKey},()=>{ @@ -1768,7 +1666,7 @@ render() { cb(receipt) }) } else{ - this.state.tx(this.state.contracts[ERC20TOKEN].approve(this.state.contracts.Links._address, amountToSend),21000,false,0,async (approveReceipt)=>{ + this.state.tx(this.state.contracts.ERC20Vendable.approve(this.state.contracts.Links._address, amountToSend),21000,false,0,async (approveReceipt)=>{ //cb(approveReceipt) this.state.tx(this.state.contracts.Links.send(randomHash,sig.signature,tokenAddress,amountToSend,expirationTime),250000,false,amountToSend,async (sendReceipt)=>{ this.setState({sendLink: randomHash,sendKey: randomWallet.privateKey},()=>{ @@ -1857,10 +1755,6 @@ render() { { console.log("Dapparatus update",state) //console.log("DAPPARATUS UPDATE",state) - if(ERC20TOKEN){ + if(token){ delete state.balance } if (state.web3Provider) { @@ -2107,15 +2000,15 @@ async function tokenSend(to,value,gasLimit,txData,cb){ console.log("sending with meta account:",this.state.metaAccount.address) let tx={ - to:this.state.contracts[ERC20TOKEN]._address, + to: token.address, value: 0, gas: setGasLimit, gasPrice: Math.round(this.state.gwei * 1010101010) } if(data){ - tx.data = this.state.contracts[ERC20TOKEN].transferWithData(to,weiValue,data).encodeABI() + tx.data = this.state.contracts.ERC20Vendable.transferWithData(to,weiValue,data).encodeABI() }else{ - tx.data = this.state.contracts[ERC20TOKEN].transfer(to,weiValue).encodeABI() + tx.data = this.state.contracts.ERC20Vendable.transfer(to,weiValue).encodeABI() } console.log("TX SIGNED TO METAMASK:",tx) this.state.web3.eth.accounts.signTransaction(tx, this.state.metaAccount.privateKey).then(signed => { @@ -2146,16 +2039,16 @@ async function tokenSend(to,value,gasLimit,txData,cb){ } let txObject = { from:this.state.account, - to:this.state.contracts[ERC20TOKEN]._address, + to: token.address, value: 0, gas: setGasLimit, gasPrice: Math.round(this.state.gwei * 1010101010) } if(data){ - txObject.data = this.state.contracts[ERC20TOKEN].transferWithData(to,weiValue,data).encodeABI() + txObject.data = this.state.contracts.ERC20Vendable.transferWithData(to,weiValue,data).encodeABI() }else{ - txObject.data = this.state.contracts[ERC20TOKEN].transfer(to,weiValue).encodeABI() + txObject.data = this.state.contracts.ERC20Vendable.transfer(to,weiValue).encodeABI() } console.log("sending with injected web3 account",txObject) diff --git a/src/assets.js b/src/assets.js new file mode 100644 index 000000000..bd4e11100 --- /dev/null +++ b/src/assets.js @@ -0,0 +1,31 @@ +import { eth, dai, xdai, ERC20Asset } from '@burner-wallet/assets'; +import burnerlogo from './burnerwallet.png'; +import bufficorn from './bufficorn.png'; + +export const assets = [xdai, dai, eth]; +export let token = null; +export let WEB3_PROVIDER = 'https://dai.poa.network'; +export let ERC20IMAGE; +export let LOADERIMAGE = burnerlogo; +export let XDAI_PROVIDER = 'https://dai.poa.network' + + +if (window.location.hostname.indexOf("localhost") >= 0 || window.location.hostname.indexOf("10.0.0.107") >= 0) { + XDAI_PROVIDER = "http://localhost:8545" + WEB3_PROVIDER = "http://localhost:8545"; + ERC20IMAGE = false +} else if (window.location.hostname.indexOf("wallet.galleass.io") >= 0) { + WEB3_PROVIDER = "http://localhost:8545" + document.domain = 'galleass.io' +} else if (window.location.hostname.indexOf("buffidai") >= 0) { + token = new ERC20Asset({ + id: 'buff', + name: 'BUFF', + network: '100', + address: '0x3e50bf6703fc132a94e4baff068db2055655f11b', + usdPrice: 1, + }); + + ERC20IMAGE = bufficorn + LOADERIMAGE = bufficorn +} diff --git a/src/components/Admin.js b/src/components/Admin.js index 10fa9ad3a..daa0311a4 100644 --- a/src/components/Admin.js +++ b/src/components/Admin.js @@ -68,7 +68,7 @@ export default class Advanced extends React.Component { changingAllowed[v] = true this.setState({changingAllowed}) //updateVendor(address wallet, bytes32 name, bool newAllowed) - tx(contracts[this.props.ERC20VENDOR].updateVendor(vendors[v].vendor,web3.utils.utf8ToHex(vendors[v].name),vendors[v].isActive,!vendors[v].isAllowed),120000,0,0,(result)=>{ + tx(contracts.ERC20Vendable.updateVendor(vendors[v].vendor,web3.utils.utf8ToHex(vendors[v].name),vendors[v].isActive,!vendors[v].isAllowed),120000,0,0,(result)=>{ console.log("ACTIVE:",result) setTimeout(()=>{ let {changingAllowed} = this.state @@ -107,7 +107,7 @@ export default class Advanced extends React.Component { changingAllowed[v] = true this.setState({changingAllowed}) //updateVendor(address wallet, bytes32 name, bool newAllowed) - tx(contracts[this.props.ERC20VENDOR].updateVendor(vendors[v].vendor,web3.utils.utf8ToHex(vendors[v].name),!vendors[v].isActive,vendors[v].isAllowed),120000,0,0,(result)=>{ + tx(contracts.ERC20Vendable.updateVendor(vendors[v].vendor,web3.utils.utf8ToHex(vendors[v].name),!vendors[v].isActive,vendors[v].isAllowed),120000,0,0,(result)=>{ console.log("ACTIVE:",result) setTimeout(()=>{ let {changingAllowed} = this.state @@ -191,7 +191,7 @@ export default class Advanced extends React.Component {
@@ -1087,7 +1085,7 @@ export default class Exchange extends React.Component { this.setState({xdaiToDendaiMode:"withdraw"}) }}> - {this.props.ERC20NAME} to xDai + {token.name} to xDai @@ -1095,21 +1093,18 @@ export default class Exchange extends React.Component { ) } - let link = "" - if(this.props.contracts){ - link = "https://blockscout.com/poa/dai/address/"+this.props.contracts[this.props.ERC20TOKEN]._address+"/contracts" - } + const link = `https://blockscout.com/poa/dai/address/${token.address}/contracts`; tokenDisplay = (
- {this.props.ERC20NAME} + {token.name}
@@ -1344,7 +1339,7 @@ export default class Exchange extends React.Component { }else{ //BECAUSE THIS COULD BE ON A TOKEN, THE SEND FUNCTION IS SENDING TOKENS TO THE BRIDGE HAHAHAHA LETs FIX THAT - if(this.props.ERC20TOKEN){ + if(token){ console.log("native sending ",this.state.amount," to ",toDaiBridgeAccount) this.props.nativeSend(toDaiBridgeAccount, this.state.amount, 120000, (result) => { console.log("RESUTL!!!!",result) @@ -2145,7 +2140,7 @@ export default class Exchange extends React.Component { let sendXdaiButton - if(this.props.ERC20TOKEN){ + if(token){ sendXdaiButton = (
) - if(ERC20TOKEN){ + if(token){ sendButtons = (
diff --git a/src/components/Receipt.js b/src/components/Receipt.js index 12bf72089..dca063c6b 100644 --- a/src/components/Receipt.js +++ b/src/components/Receipt.js @@ -8,18 +8,11 @@ import RecentTransactions from './RecentTransactions'; import { scroller } from 'react-scroll' import i18n from '../i18n'; import axios from 'axios'; -const QRCode = require('qrcode.react'); const BockieSize = 12 export default class Receive extends React.Component { - - constructor(props) { - super(props); - let initialState = { - } - } componentDidMount(){ console.log("RECEIPT LOADED",this.props) if(this.props.receipt && this.props.receipt.daiposOrderId){ @@ -50,7 +43,7 @@ export default class Receive extends React.Component { } } render() { - let {receipt,buttonStyle,ERC20TOKEN,address, balance, changeView, dollarDisplay,account} = this.props + const { receipt, dollarDisplay } = this.props let message = "" diff --git a/src/components/Receive.js b/src/components/Receive.js index 582b7a7ab..15549ad71 100644 --- a/src/components/Receive.js +++ b/src/components/Receive.js @@ -6,17 +6,12 @@ import Blockies from 'react-blockies'; import RecentTransactions from './RecentTransactions'; import { scroller } from 'react-scroll' import i18n from '../i18n'; -const QRCode = require('qrcode.react'); +import QRCode from 'qrcode.react'; +import { token } from '../assets'; export default class Receive extends React.Component { - - constructor(props) { - super(props); - let initialState = { - } - } render() { - let {dollarDisplay,view,buttonStyle,ERC20TOKEN,address, balance, changeAlert, changeView, subBalanceDisplay,account} = this.props + const {dollarDisplay,view,buttonStyle,address, changeAlert, changeView } = this.props let qrSize = Math.min(document.documentElement.clientWidth,512)-90 @@ -49,12 +44,11 @@ export default class Receive extends React.Component { view={view} max={5} buttonStyle={buttonStyle} - ERC20TOKEN={ERC20TOKEN} - transactionsByAddress={ERC20TOKEN?this.props.fullTransactionsByAddress:this.props.transactionsByAddress} + transactionsByAddress={token ? this.props.fullTransactionsByAddress : this.props.transactionsByAddress} changeView={changeView} address={address} block={this.props.block} - recentTxs={ERC20TOKEN?this.props.fullRecentTxs:this.props.recentTxs} + recentTxs={token ? this.props.fullRecentTxs : this.props.recentTxs} />
diff --git a/src/components/RecentTransactions.js b/src/components/RecentTransactions.js index d7b6ae122..b0cea488f 100644 --- a/src/components/RecentTransactions.js +++ b/src/components/RecentTransactions.js @@ -2,8 +2,11 @@ import React from 'react'; import { Blockie } from "dapparatus"; import Ruler from "./Ruler"; import { Scaler } from "dapparatus"; +import { token } from '../assets'; -export default ({dollarDisplay, view, max, buttonStyle, ERC20TOKEN, vendorName, address, recentTxs, block, changeView}) => { +export default ({ + dollarDisplay, view, max, buttonStyle, vendorName, address, recentTxs, block, changeView +}) => { let txns = [] let count=0 if(!max) max=9999 @@ -39,7 +42,7 @@ export default ({dollarDisplay, view, max, buttonStyle, ERC20TOKEN, vendorName, } let dollarView - if(ERC20TOKEN){ + if(token){ if(recentTxs[r].token){ dollarView = ( diff --git a/src/components/SendBadge.js b/src/components/SendBadge.js index d00948b82..04e615c51 100644 --- a/src/components/SendBadge.js +++ b/src/components/SendBadge.js @@ -78,8 +78,6 @@ export default class SendBadge extends React.Component { } send = async () => { let { toAddress, amount } = this.state; - let {ERC20TOKEN} = this.props - if(this.state.canSend){ diff --git a/src/components/SendToAddress.js b/src/components/SendToAddress.js index 81a14f087..539292b6c 100644 --- a/src/components/SendToAddress.js +++ b/src/components/SendToAddress.js @@ -5,8 +5,9 @@ import cookie from 'react-cookies' import {CopyToClipboard} from "react-copy-to-clipboard"; import Blockies from 'react-blockies'; import { scroller } from 'react-scroll' +import queryString from 'query-string'; import i18n from '../i18n'; -const queryString = require('query-string'); +import { token } from '../assets'; export default class SendToAddress extends React.Component { @@ -159,29 +160,29 @@ export default class SendToAddress extends React.Component { send = async () => { let { toAddress, amount } = this.state; - let {ERC20TOKEN, dollarDisplay, convertToDollar} = this.props + let { dollarDisplay, convertToDollar } = this.props amount = convertToDollar(amount) console.log("CONVERTED TO DOLLAR AMOUNT",amount) if(this.state.canSend){ - if(ERC20TOKEN){ + if(token){ console.log("this is a token") }else{ console.log("this is not a token") } - console.log("ERC20TOKEN",ERC20TOKEN,"this.props.balance",parseFloat(this.props.balance),"amount",parseFloat(amount)) + console.log("ERC20TOKEN", token.name, "this.props.balance",parseFloat(this.props.balance),"amount",parseFloat(amount)) - if(!ERC20TOKEN && parseFloat(this.props.balance) <= 0){ - console.log("No funds!?!",ERC20TOKEN,parseFloat(this.props.balance)) + if(!token && parseFloat(this.props.balance) <= 0){ + console.log("No funds!?!", token.name, parseFloat(this.props.balance)) this.props.changeAlert({type: 'warning', message: "No Funds."}) - }else if(!ERC20TOKEN && parseFloat(this.props.balance)-0.0001<=parseFloat(amount)){ + }else if(!token && parseFloat(this.props.balance)-0.0001<=parseFloat(amount)){ let extraHint = "" - if(!ERC20TOKEN && parseFloat(amount)-parseFloat(this.props.balance)<=.01){ + if(!token && parseFloat(amount)-parseFloat(this.props.balance)<=.01){ extraHint = "(gas costs)" } this.props.changeAlert({type: 'warning', message: 'Not enough funds: '+dollarDisplay(Math.floor((parseFloat(this.props.balance)-0.0001)*100)/100)+' '+extraHint}) - }else if((ERC20TOKEN && (parseFloat(this.props.balance){ + tx(contracts.VendingMachine.addProduct(prod.id,prod.name,prod.cost,!prod.isAvailable),240000,0,0,(result)=>{ console.log("===PRODUCT:",result) let changingAvailable = this.state.changingAvailable changingAvailable[p] = false @@ -142,7 +142,7 @@ export default class Advanced extends React.Component {