diff --git a/packages/keychain/package.json b/packages/keychain/package.json index 2c97582abe..6afd6f3ffc 100644 --- a/packages/keychain/package.json +++ b/packages/keychain/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "tsc -b && vite build", "build:compat": "tsc -b && vite build", "preview": "vite preview --port 3001", diff --git a/packages/keychain/src/components/app.tsx b/packages/keychain/src/components/app.tsx index 9fdd3b9bf6..d5a573e949 100644 --- a/packages/keychain/src/components/app.tsx +++ b/packages/keychain/src/components/app.tsx @@ -45,11 +45,53 @@ import { useNavigation } from "@/context"; import { Purchase } from "./purchase"; import { PurchaseType } from "@/hooks/payments/crypto"; +import { Mocked } from "./mocked"; +import { constants } from "starknet"; + export function App() { const { navigate } = useNavigation(); return ( }> + { + p.set( + "address", + "0x0000000000000000000000000000000000000000000000000000000000000000", + ); + p.set("chain_id", constants.StarknetChainId.SN_MAIN); + p.set( + "rpc_url", + encodeURIComponent( + "https://api.cartridge.gg/x/starknet/mainnet", + ), + ); + }} + /> + } + /> + { + const sig = [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000000", + ]; + for (const s of sig) { + p.append("signature", s); + } + }} + /> + } + /> } /> } /> } /> diff --git a/packages/keychain/src/components/home.tsx b/packages/keychain/src/components/home.tsx index b90d5d4fa6..0ed7fe2bf6 100644 --- a/packages/keychain/src/components/home.tsx +++ b/packages/keychain/src/components/home.tsx @@ -28,7 +28,10 @@ export function Home() { } }, [context?.type, posthog]); - // Popup flow authentication + if (pathname.startsWith("/mocked")) { + return ; + } + if (pathname.startsWith("/authenticate")) { return ; } diff --git a/packages/keychain/src/components/mocked.tsx b/packages/keychain/src/components/mocked.tsx new file mode 100644 index 0000000000..484164b326 --- /dev/null +++ b/packages/keychain/src/components/mocked.tsx @@ -0,0 +1,45 @@ +import { Button } from "@cartridge/ui"; +import { useCallback, useMemo } from "react"; +import { useSearchParams } from "react-router-dom"; + +export function Mocked({ + title, + setSearchParams, +}: { + title: string; + setSearchParams: (searchParams: URLSearchParams) => void; +}) { + const [searchParams] = useSearchParams(); + + const searchParamsObj = useMemo(() => { + const p: Record = {}; + for (const [key, val] of searchParams.entries()) { + p[key] = decodeURIComponent(val); + } + return p; + }, [searchParams]); + + const onClick = useCallback(() => { + const callbackUrl = decodeURIComponent(searchParams.get("callback_uri")!); + if (!callbackUrl) { + throw new Error("callback_uri is required"); + } + const url = new URL(callbackUrl); + setSearchParams(url.searchParams); + + window.location.href = url.toString(); + }, [searchParams, setSearchParams]); + + return ( +
+
+
Search params:
+
+          {JSON.stringify(searchParamsObj, null, 2)}
+        
+
+ + +
+ ); +} diff --git a/packages/keychain/src/components/provider/index.tsx b/packages/keychain/src/components/provider/index.tsx index 56f5350c63..35f6459f44 100644 --- a/packages/keychain/src/components/provider/index.tsx +++ b/packages/keychain/src/components/provider/index.tsx @@ -2,7 +2,7 @@ import { UpgradeProvider } from "@/components/provider/upgrade"; import { useConnectionValue } from "@/hooks/connection"; import { WalletsProvider } from "@/hooks/wallets"; import { ENDPOINT } from "@/utils/graphql"; -import { Auth0Provider, Auth0ProviderOptions } from "@auth0/auth0-react"; +// import { Auth0Provider, Auth0ProviderOptions, } from "@auth0/auth0-react"; import { CartridgeAPIProvider } from "@cartridge/ui/utils/api/cartridge"; import { mainnet, sepolia } from "@starknet-react/chains"; import { @@ -54,34 +54,34 @@ export function Provider({ children }: PropsWithChildren) { - - - - - - - - - - - - {children} - - - - - - - - - - - + {/* */} + + + + + + + + + + + {children} + + + + + + + + + + + {/* */} @@ -107,10 +107,10 @@ const turnkeyConfig = { iframeUrl: import.meta.env.VITE_TURNKEY_IFRAME_URL, }; -const auth0Config: Auth0ProviderOptions = { - domain: import.meta.env.VITE_AUTH0_DOMAIN!, - clientId: import.meta.env.VITE_AUTH0_CLIENT_ID!, - authorizationParams: { - redirect_uri: window.location.origin, - }, -}; +// const auth0Config: Auth0ProviderOptions = { +// domain: import.meta.env.VITE_AUTH0_DOMAIN!, +// clientId: import.meta.env.VITE_AUTH0_CLIENT_ID!, +// authorizationParams: { +// redirect_uri: window.location.origin, +// }, +// };