From 4349f26586bfdf3b93b9a25697688ccd8b3565ca Mon Sep 17 00:00:00 2001 From: tonwayer Date: Sun, 13 Mar 2022 12:37:10 -0700 Subject: [PATCH 1/2] Remove unnecessary semicolons and spaces --- src/App.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/App.js b/src/App.js index 43ff02a..115848e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ -import './App.css'; -import { useState } from 'react'; +import './App.css' +import { useState } from 'react' import { ethers } from 'ethers' import Greeter from './artifacts/contracts/Greeter.sol/Greeter.json' import Token from './artifacts/contracts/Token.sol/Token.json' @@ -13,7 +13,7 @@ function App() { const [amount, setAmount] = useState() async function requestAccount() { - await window.ethereum.request({ method: 'eth_requestAccounts' }); + await window.ethereum.request({ method: 'eth_requestAccounts' }) } async function fetchGreeting() { @@ -27,16 +27,16 @@ function App() { } catch (err) { console.log("Error: ", err) } - } + } } async function getBalance() { if (typeof window.ethereum !== 'undefined') { const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' }) - const provider = new ethers.providers.Web3Provider(window.ethereum); + const provider = new ethers.providers.Web3Provider(window.ethereum) const contract = new ethers.Contract(tokenAddress, Token.abi, provider) - const balance = await contract.balanceOf(account); - console.log("Balance: ", balance.toString()); + const balance = await contract.balanceOf(account) + console.log("Balance: ", balance.toString()) } } @@ -44,7 +44,7 @@ function App() { if (!greeting) return if (typeof window.ethereum !== 'undefined') { await requestAccount() - const provider = new ethers.providers.Web3Provider(window.ethereum); + const provider = new ethers.providers.Web3Provider(window.ethereum) console.log({ provider }) const signer = provider.getSigner() const contract = new ethers.Contract(greeterAddress, Greeter.abi, signer) @@ -57,12 +57,12 @@ function App() { async function sendCoins() { if (typeof window.ethereum !== 'undefined') { await requestAccount() - const provider = new ethers.providers.Web3Provider(window.ethereum); - const signer = provider.getSigner(); - const contract = new ethers.Contract(tokenAddress, Token.abi, signer); - const transaction = await contract.transfer(userAccount, amount); - await transaction.wait(); - console.log(`${amount} Coins successfully sent to ${userAccount}`); + const provider = new ethers.providers.Web3Provider(window.ethereum) + const signer = provider.getSigner() + const contract = new ethers.Contract(tokenAddress, Token.abi, signer) + const transaction = await contract.transfer(userAccount, amount) + await transaction.wait() + console.log(`${amount} Coins successfully sent to ${userAccount}`) } } @@ -80,7 +80,7 @@ function App() { setAmount(e.target.value)} placeholder="Amount" /> - ); + ) } -export default App; +export default App From 0b0af8f17f34debdff4bf7783c0db08fd302a7f5 Mon Sep 17 00:00:00 2001 From: tonwayer Date: Sun, 13 Mar 2022 12:37:59 -0700 Subject: [PATCH 2/2] Fix double quote to single quote in JS code --- src/App.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 115848e..94a2cbe 100644 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,7 @@ function App() { const data = await contract.greet() console.log('data: ', data) } catch (err) { - console.log("Error: ", err) + console.log('Error: ', err) } } } @@ -36,7 +36,7 @@ function App() { const provider = new ethers.providers.Web3Provider(window.ethereum) const contract = new ethers.Contract(tokenAddress, Token.abi, provider) const balance = await contract.balanceOf(account) - console.log("Balance: ", balance.toString()) + console.log('Balance: ', balance.toString()) } }