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

Release/0.13.3 #111

Merged
merged 7 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ jobs:
deploy_stage:
docker:
- image: cimg/node:14.17.3
resource_class: medium+
steps:
- checkout
- run: rm yarn.lock && yarn install --network-concurrency 1
- run: yarn build-staging
- run: ssh -oStrictHostKeyChecking=no -v $EC2_PROD_USER@$EC2_PROD_IP "sh /home/ubuntu/remove.sh reactdemo-staging"
- run: scp -oStrictHostKeyChecking=no -v -r /home/circleci/project/build/* $EC2_PROD_USER@$EC2_PROD_IP:/home/ubuntu/reactdemo-staging/
- run: ssh -oStrictHostKeyChecking=no -v $EC2_PROD_USER@$EC2_PROD_IP "sh /home/ubuntu/move.sh reactdemo-staging"

deploy_prod:
docker:
- image: cimg/node:14.17.3
resource_class: medium+
steps:
- checkout
- run: yarn cache clean && yarn install --network-concurrency 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onboard-notify-react",
"version": "0.13.2",
"version": "0.13.3",
"dependencies": {
"bnc-notify": "^1.9.1",
"bnc-notify-staging": "https://github.com/blocknative/notify#develop",
Expand Down
67 changes: 27 additions & 40 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import getSigner from './signer'
import { initOnboard, initNotify } from './services'
import { version, dependencies } from '../package.json'
import avatarPlaceholder from './avatar-placeholder.png'
import networkEnum from './networkEnum'

import './App.css'

Expand Down Expand Up @@ -34,7 +35,7 @@ const internalTransferABI = [

let internalTransferContract

function App() {
const App = () => {
const [address, setAddress] = useState(null)
const [ens, setEns] = useState(null)
const [network, setNetwork] = useState(null)
Expand Down Expand Up @@ -86,16 +87,15 @@ function App() {
}, [])

useEffect(() => {
const previouslySelectedWallet = window.localStorage.getItem(
'selectedWallet'
)
const previouslySelectedWallet =
window.localStorage.getItem('selectedWallet')

if (previouslySelectedWallet && onboard) {
onboard.walletSelect(previouslySelectedWallet)
}
}, [onboard])

async function readyToTransact() {
const readyToTransact = async () => {
if (!provider) {
const walletSelected = await onboard.walletSelect()
if (!walletSelected) return false
Expand All @@ -105,7 +105,7 @@ function App() {
return ready
}

async function sendHash() {
const sendHash = async () => {
if (!toAddress) {
alert('An Ethereum address to send Eth to is required.')
return
Expand Down Expand Up @@ -136,7 +136,7 @@ function App() {
emitter.on('txFailed', console.log)
}

async function sendInternalTransaction() {
const sendInternalTransaction = async () => {
if (!toAddress) {
alert('An Ethereum address to send Eth to is required.')
return
Expand All @@ -159,7 +159,7 @@ function App() {
emitter.on('txFailed', console.log)
}

async function sendTransaction() {
const sendTransaction = async () => {
if (!toAddress) {
alert('An Ethereum address to send Eth to is required.')
}
Expand All @@ -171,13 +171,15 @@ function App() {
value: 1000000000000000
}

const sendTransaction = () =>
signer.sendTransaction(txDetails).then(tx => tx.hash)
const sendTransaction = () => {
return signer.sendTransaction(txDetails).then(tx => tx.hash)
}

const gasPrice = () => provider.getGasPrice().then(res => res.toString())

const estimateGas = () =>
provider.estimateGas(txDetails).then(res => res.toString())
const estimateGas = () => {
return provider.estimateGas(txDetails).then(res => res.toString())
}

const { emitter } = await notify.transaction({
sendTransaction,
Expand All @@ -203,7 +205,9 @@ function App() {
emitter.on('txFailed', console.log)
}

return onboard && notify ? (
if (!onboard || !notify) return <div>Loading...</div>

return (
<main>
<header className="user-info">
{ens && ens.name ? (
Expand All @@ -213,9 +217,13 @@ function App() {
src={ens.avatar ? ens.avatar : avatarPlaceholder}
alt="avatar"
></img>
<div style={{
marginLeft: '10px'
}}>{ens.name}</div>
<div
style={{
marginLeft: '10px'
}}
>
{ens.name}
</div>
</span>
) : (
address && <span>{address}</span>
Expand All @@ -225,7 +233,9 @@ function App() {
{Number(balance) > 0 ? balance / 1000000000000000000 : balance} ETH
</span>
)}
{network && <span>{networkName(network)} network</span>}
{network && (
<span>{networkEnum?.[Number(network)] || 'local'} network</span>
)}
</header>
<section className="main">
<div className="container">
Expand Down Expand Up @@ -524,30 +534,7 @@ function App() {
</span>
</div>
</main>
) : (
<div>Loading...</div>
)
}

function networkName(id) {
switch (Number(id)) {
case 1:
return 'main'
case 3:
return 'ropsten'
case 4:
return 'rinkeby'
case 5:
return 'goerli'
case 42:
return 'kovan'
case 100:
return 'xdai'
case 'localhost':
return 'localhost'
default:
return 'local'
}
}

export default App
14 changes: 14 additions & 0 deletions src/networkEnum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const networkEnum = Object.freeze({
1: 'Ethereum Main',
3: 'Ropsten',
4: 'Rinkeby',
5: 'Goerli',
25: 'Cronos',
42: 'Kovan',
56: 'BSC',
100: 'XDai',
137: 'Polygon',
250: 'Fantom',
localhost: 'localhost'
});
export default networkEnum;
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14391,9 +14391,9 @@ tmp@^0.0.33:
os-tmpdir "~1.0.2"

tmpl@1.0.x:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=
version "1.0.5"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc"
integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==

to-arraybuffer@^1.0.0:
version "1.0.1"
Expand Down