Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coding style #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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() {
Expand All @@ -25,26 +25,26 @@ function App() {
const data = await contract.greet()
console.log('data: ', data)
} catch (err) {
console.log("Error: ", 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())
}
}

async function setGreeting() {
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)
Expand All @@ -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}`)
}
}

Expand All @@ -80,7 +80,7 @@ function App() {
<input onChange={e => setAmount(e.target.value)} placeholder="Amount" />
</header>
</div>
);
)
}

export default App;
export default App