From 774eece55581699240fa093aacb354e6aa30e842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=9F=A0=20CHANCE?= Date: Wed, 27 Sep 2023 22:45:33 -0500 Subject: [PATCH] feat: add safe support --- frontend/netlify.toml | 8 ++++++- frontend/public/manifest.json | 20 ++++++++++++++++++ .../src/components/Button/ConnectButton.js | 4 ++++ frontend/src/components/Wallet/Wallet.js | 14 +++++++++++-- frontend/src/hooks/useAutoConnect.js | 21 +++++++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 frontend/public/manifest.json create mode 100644 frontend/src/hooks/useAutoConnect.js diff --git a/frontend/netlify.toml b/frontend/netlify.toml index 1024a06..afcab88 100644 --- a/frontend/netlify.toml +++ b/frontend/netlify.toml @@ -1,4 +1,10 @@ [[redirects]] from = "/*" to = "/index.html" - status = 200 \ No newline at end of file + status = 200 +[[headers]] + for = "/manifest.json" + [headers.values] + Access-Control-Allow-Origin = "*" + Access-Control-Allow-Methods = "GET" + Access-Control-Allow-Headers = "X-Requested-With, content-type, Authorization" \ No newline at end of file diff --git a/frontend/public/manifest.json b/frontend/public/manifest.json new file mode 100644 index 0000000..0e8cfc6 --- /dev/null +++ b/frontend/public/manifest.json @@ -0,0 +1,20 @@ +{ + "name": "Badger", + "short_name": "Badger", + "icons": [ + { + "src": "/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#00ffe0", + "background_color": "#00ffe0", + "display": "standalone", + "start_url": "." +} diff --git a/frontend/src/components/Button/ConnectButton.js b/frontend/src/components/Button/ConnectButton.js index fe4bf8a..2e0c7b7 100644 --- a/frontend/src/components/Button/ConnectButton.js +++ b/frontend/src/components/Button/ConnectButton.js @@ -2,6 +2,8 @@ import { useAuthentication } from '@hooks' import { useConnectModal } from '@rainbow-me/rainbowkit' import { useAccount, useSwitchNetwork } from 'wagmi' +import { useAutoConnect } from '../../hooks/useAutoConnect' + const ConnectButton = props => { const { switchNetwork } = useSwitchNetwork() @@ -13,6 +15,8 @@ const ConnectButton = props => { const className = props.className || 'secondary' + useAutoConnect() + if (isConnected && isWrongNetwork && switchNetwork) return (