diff --git a/build.crx b/build.crx index 784d07d..c2b3aac 100644 Binary files a/build.crx and b/build.crx differ diff --git a/landing/index.html b/landing/index.html index 7de658f..897360f 100644 --- a/landing/index.html +++ b/landing/index.html @@ -73,7 +73,7 @@

get started

download
-

Cobweb is MIT-licensed and fully open source - the source is available on GitHub should you wish to build from source. The checksum of the current version is a0f59c908c6d6f65a22348d2abfe51c01ee530072da6a8ded98e84fd1ef3dda5. +

Cobweb is MIT-licensed and fully open source - the source is available on GitHub should you wish to build from source. The checksum of the current version is 4fd1072cb48c5612abc5b8f980953521733db40538f361d2c56648c502706d18.

view source
diff --git a/src/pages/Background/index.ts b/src/pages/Background/index.ts index 7778eb4..223341d 100644 --- a/src/pages/Background/index.ts +++ b/src/pages/Background/index.ts @@ -24,6 +24,7 @@ import { NEW_TOAST, FETCH_SIGNATURE, CHECK_METAMASK, + RESET_TESTCHAINMODE, } from "../shared/events"; import TOKEN_MAP, { PROD_TOKEN_MAP } from "../shared/tokens"; import { PayRates } from "../shared/types"; @@ -120,7 +121,7 @@ if (!addressTry || addressTry === "NO_ADDRESS") { let infuraProvider: InfuraProvider | null = null; try { infuraProvider = new ethers.providers.InfuraProvider( - isDev() ? "goerli" : "homestead", + (await isDev()) ? "goerli" : "homestead", { projectId: INFURA_PROJECT_ID, projectSecret: INFURA_PROJECT_SECRET, @@ -130,7 +131,7 @@ try { let sf: Framework | null = null; try { sf = await Framework.create({ - chainId: isDev() ? 5 : 1, + chainId: (await isDev()) ? 5 : 1, provider: infuraProvider, }); } catch (e) { @@ -141,7 +142,7 @@ let sfToken: SuperToken | null = null; try { if (sf) { sfToken = await sf.loadSuperToken( - isDev() ? TOKEN_MAP.ETH.xAddress : PROD_TOKEN_MAP.ETH.xAddress + (await isDev()) ? TOKEN_MAP.ETH.xAddress : PROD_TOKEN_MAP.ETH.xAddress ); } } catch (e) { @@ -391,6 +392,20 @@ const handleMessaging = async ( } sendResponse(); return; + case RESET_TESTCHAINMODE: + if (await isDev()) { + infuraProvider = new ethers.providers.InfuraProvider("goerli", { + projectId: INFURA_PROJECT_ID, + projectSecret: INFURA_PROJECT_SECRET, + }); + sf = await Framework.create({ + chainId: 5, + provider: infuraProvider, + }); + sfToken = await sf.loadSuperToken(TOKEN_MAP.ETH.xAddress); + } + sendResponse(); + return; default: sendResponse(); return; diff --git a/src/pages/Background/lib/isDev.ts b/src/pages/Background/lib/isDev.ts index 758b333..ea9a365 100644 --- a/src/pages/Background/lib/isDev.ts +++ b/src/pages/Background/lib/isDev.ts @@ -1,4 +1,8 @@ import "process"; +import { storage } from "@extend-chrome/storage"; -export const isDev = () => - !process.env.NODE_ENV || process.env.NODE_ENV === "development"; +export const isDev = async () => + !process.env.NODE_ENV || + process.env.NODE_ENV === "development" || + ((await storage.local.get("testChainMode")) as { testChainMode: boolean }) + .testChainMode === true; diff --git a/src/pages/Popup/CobwebInfo.tsx b/src/pages/Popup/CobwebInfo.tsx index 1c58825..9e66f64 100644 --- a/src/pages/Popup/CobwebInfo.tsx +++ b/src/pages/Popup/CobwebInfo.tsx @@ -1,9 +1,10 @@ import React, { useEffect, useState } from "react"; import CobwebPage from "./components/CobwebPage"; import ToastHandler from "./components/ToastHandler"; -import { FETCH_SIGNATURE } from "../shared/events"; +import { FETCH_SIGNATURE, RESET_TESTCHAINMODE } from "../shared/events"; import { useChromeStorageLocal } from "use-chrome-storage"; import { toast } from "../shared/toast"; +import "./info-accordion.css"; const CobwebInfo = () => { const [address, , ,]: [string, any, any, any] = useChromeStorageLocal( @@ -18,6 +19,8 @@ const CobwebInfo = () => { const [requested, setRequested, ,]: [any, any, any, any] = useChromeStorageLocal("extend-chrome/storage__local--requested", null); const [reactRequested, setReactRequested] = useState(false); + const [testChainMode, setTestChainMode, ,]: [any, any, any, any] = + useChromeStorageLocal("extend-chrome/storage__local--testChainMode", false); useEffect(() => { const getResponse = async () => { @@ -30,6 +33,18 @@ const CobwebInfo = () => { getResponse(); }, [signatureLocal]); + useEffect(() => { + const getResponse = async () => { + if (testChainMode) { + chrome.runtime.sendMessage({ + message: RESET_TESTCHAINMODE, + }); + } + }; + + getResponse(); + }, [testChainMode]); + const requestVerification = async () => { if (!address) { toast("Couldn't fetch Metamask account."); @@ -95,6 +110,66 @@ const CobwebInfo = () => { Copy this to the contents of any content you want to monetize. +
+
+
+

+ +

+
+
+
+ setTestChainMode(e.target.value)} + /> + +
+
+
+
+
+
{requested !== null && (!requested || reactRequested) ? (