From d90d06c207eaaee634139a7606c0f5ec1068202b Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Tue, 10 Dec 2024 17:05:28 -0500 Subject: [PATCH] Cleanup some stuff --- .../src/components/DeployController.tsx | 12 +++++----- .../keychain/src/components/ErrorAlert.tsx | 22 ++++++------------- .../keychain/src/components/Transaction.tsx | 5 +++-- packages/keychain/src/hooks/connection.ts | 2 -- packages/keychain/src/utils/cookie.ts | 11 ---------- 5 files changed, 15 insertions(+), 37 deletions(-) delete mode 100644 packages/keychain/src/utils/cookie.ts diff --git a/packages/keychain/src/components/DeployController.tsx b/packages/keychain/src/components/DeployController.tsx index fae8f4311..223c2df49 100644 --- a/packages/keychain/src/components/DeployController.tsx +++ b/packages/keychain/src/components/DeployController.tsx @@ -15,6 +15,7 @@ import { Fees } from "./Fees"; import { ControllerError } from "utils/connection"; import { Policies } from "components/Policies"; import { ETH_CONTRACT_ADDRESS, useERC20Balance } from "@cartridge/utils"; +import { useExplorer } from "@starknet-react/core"; export function DeployController({ onClose, @@ -236,6 +237,8 @@ function ExplorerLink({ txHash: string; chainId: string; }) { + const explorer = useExplorer(); + if ( ![ constants.StarknetChainId.SN_SEPOLIA, @@ -246,12 +249,7 @@ function ExplorerLink({ } return ( - + ); diff --git a/packages/keychain/src/components/ErrorAlert.tsx b/packages/keychain/src/components/ErrorAlert.tsx index c9f26529c..5ce8a66f1 100644 --- a/packages/keychain/src/components/ErrorAlert.tsx +++ b/packages/keychain/src/components/ErrorAlert.tsx @@ -28,6 +28,7 @@ import { useConnection } from "hooks/connection"; import { constants } from "starknet"; import { parseExecutionError, parseValidationError } from "utils/errors"; import { formatAddress } from "@cartridge/utils"; +import { useExplorer } from "@starknet-react/core"; export function ErrorAlert({ title, @@ -336,17 +337,7 @@ function StackTraceDisplay({ stackTrace: ReturnType["stack"]; }) { const { chainId } = useConnection(); - - const getExplorerUrl = (type: "contract" | "class", value: string) => { - if (!chainId) return; - - const baseUrl = { - [constants.StarknetChainId.SN_SEPOLIA]: "https://sepolia.starkscan.co", - [constants.StarknetChainId.SN_MAIN]: "https://starkscan.co", - }[chainId]; - - return baseUrl ? `${baseUrl}/${type}/${value}` : undefined; - }; + const explorer = useExplorer(); const isExternalLink = [ constants.StarknetChainId.SN_SEPOLIA, @@ -377,10 +368,11 @@ function StackTraceDisplay({ {key === "address" || key === "class" ? ( ("pending"); const { color, icon } = useMemo(() => getColorIcon(state), [state]); const { controller } = useController(); @@ -78,7 +79,7 @@ export function Transaction({ - + diff --git a/packages/keychain/src/hooks/connection.ts b/packages/keychain/src/hooks/connection.ts index 7b521508d..7e3ae00dd 100644 --- a/packages/keychain/src/hooks/connection.ts +++ b/packages/keychain/src/hooks/connection.ts @@ -14,7 +14,6 @@ import { toSessionPolicies, } from "@cartridge/controller"; import { mergeDefaultETHPrefund } from "utils/token"; -import { setIsSignedUp } from "utils/cookie"; import { ConnectionContext, ConnectionContextValue, @@ -98,7 +97,6 @@ export function useConnectionValue() { } setControllerRaw(controller); - setIsSignedUp(); }, []); useEffect(() => { diff --git a/packages/keychain/src/utils/cookie.ts b/packages/keychain/src/utils/cookie.ts deleted file mode 100644 index 08c71ebaa..000000000 --- a/packages/keychain/src/utils/cookie.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function isSignedUp() { - return document.cookie.search("controller=1") >= 0; -} - -export function setIsSignedUp() { - if (isSignedUp()) { - return; - } - - document.cookie = "controller=1; SameSite=None; Secure"; -}