diff --git a/.circleci/config.yml b/.circleci/config.yml index f6a04f64..53bd8dca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,7 @@ jobs: deploy_stage: docker: - image: cimg/node:14.17.3 + resource_class: medium+ steps: - checkout - run: rm yarn.lock && yarn install --network-concurrency 1 @@ -10,9 +11,11 @@ jobs: - 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 diff --git a/package.json b/package.json index ca3c5d84..aad8176d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/App.js b/src/App.js index 1a8dffbb..1f2df723 100644 --- a/src/App.js +++ b/src/App.js @@ -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' @@ -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) @@ -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 @@ -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 @@ -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 @@ -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.') } @@ -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, @@ -203,7 +205,9 @@ function App() { emitter.on('txFailed', console.log) } - return onboard && notify ? ( + if (!onboard || !notify) return
Loading...
+ + return (
{ens && ens.name ? ( @@ -213,9 +217,13 @@ function App() { src={ens.avatar ? ens.avatar : avatarPlaceholder} alt="avatar" > -
{ens.name}
+
+ {ens.name} +
) : ( address && {address} @@ -225,7 +233,9 @@ function App() { {Number(balance) > 0 ? balance / 1000000000000000000 : balance} ETH )} - {network && {networkName(network)} network} + {network && ( + {networkEnum?.[Number(network)] || 'local'} network + )}
@@ -524,30 +534,7 @@ function App() {
- ) : ( -
Loading...
) } -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 diff --git a/src/networkEnum.js b/src/networkEnum.js new file mode 100644 index 00000000..31cde2d1 --- /dev/null +++ b/src/networkEnum.js @@ -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; diff --git a/yarn.lock b/yarn.lock index a2a5e846..d738b89b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"