diff --git a/README.md b/README.md index 0dcf8d5..e7086f6 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,24 @@ -# Clink Safe -Clink, the easiest way to send and receive crypto tokens. +# Micropay +Micropay, the easiest way to send and receive crypto tokens. -Using Clink, anyone can deposit and send tokens to another person whether or not they already have a crypto wallet with just a link. The kicker is… the link is a smart contract wallet! +Using Micropay, anyone can deposit and send tokens to another person whether or not they already have a crypto wallet with just a link. The kicker is… the link is a smart contract wallet! -Clink is a lightweight non custodial wallet designed to make transferring digital assets as easy as sending a link. Someone with crypto can create a Clink and send that link to anyone over any platform (text, discord, email, etc). The amazing thing is, the link is the smart contract wallet! +Micropay is a lightweight non custodial wallet designed to make transferring digital assets as easy as sending a link. Someone with crypto can create a Micropay and send that link to anyone over any platform (text, discord, email, etc). The amazing thing is, the link is the smart contract wallet! ### How it Works -1. Create a Clink Link -2. Share your Clink Link +1. Create a Micropay Link +2. Share your Micropay Link 3. Claim Reward -e.g., - -Consider Bob wants to send money to Alice But he doesn’t know Alice Address or any other details. - -![Clink Safe Infra](https://github.com/punithbm/eth-micropay-superhack/assets/13044958/3fb0dfaf-827b-4bc8-a7b3-2f7a56cf1e42) - - -Clink trying to represent the idea of 'Digital Cash' better than any other cryptocurrency, asset or tool on the market today +Micropay trying to represent the idea of 'Digital Cash' better than any other cryptocurrency, asset or tool on the market today ### Inspiration *There's still a tremendous amount of friction in crypto that holds back mainstream adoption. It's unreasonable to ask the general population to set up a 12- or 24-word seed phrase wallet, much less a hardware wallet, just to send a dollar or receive a commemorative NFT.* - ### Why Does it Matter? - Social and Email - - Send clinks at scale via email, twitter, discord etc., + - Send Micropays at scale via email, twitter, discord etc., - In Real Life - - Distribute Clinks vai QR Code or NFC Tags at in person events + - Distribute Micropays vai QR Code or NFC Tags at in person events - Web Apps - - Place a button to distribute Clinks on your Dapp - -### Working Demo -![clink_demo](https://github.com/punithbm/eth-micropay-superhack/assets/13044958/032e630e-8dd7-4146-a1b9-6bbacc81f482) - -### Complete Guide -Find the below step by step guid on how to do it -![Clink Safe Infra2](https://github.com/punithbm/eth-micropay-superhack/assets/13044958/760038db-765b-4a56-a45b-427184bd1447) + - Place a button to distribute Micropays on your Dapp diff --git a/app/favicon.ico b/app/favicon.ico index ba1b4f4..664a619 100644 Binary files a/app/favicon.ico and b/app/favicon.ico differ diff --git a/constants/index.ts b/constants/index.ts index 5727d9a..3d423a3 100644 --- a/constants/index.ts +++ b/constants/index.ts @@ -1,11 +1,8 @@ -export const projectId = - "BI5-250tyqwU_79yFve_chx6hiE-f8iCxPHe0oqDpv-xU9dvGJ1p3JLo1y0AqzlMKDoZ_w0NLjxIFyNhxXJ6L6Y"; -export const oauthClientId = - "97006979879-hpprsfnk927avhc0368fvbqjra6h5c4t.apps.googleusercontent.com"; +export const projectId = "BI5-250tyqwU_79yFve_chx6hiE-f8iCxPHe0oqDpv-xU9dvGJ1p3JLo1y0AqzlMKDoZ_w0NLjxIFyNhxXJ6L6Y"; +export const oauthClientId = "97006979879-hpprsfnk927avhc0368fvbqjra6h5c4t.apps.googleusercontent.com"; export const web3AuthVerifier = "micropay"; export const web3AuthLoginType = "google"; -export const web3AuthClientId = - "BFWg2RH35EKxZJtntj1l-G2XU8AY0l-yFgFIs9iDbgKAW45ZxE9_qfj6COAWwI-RhOs2pN6OHwgZHgtoHjOlMFM"; -export const productName = "Clink Safe"; +export const web3AuthClientId = "BFWg2RH35EKxZJtntj1l-G2XU8AY0l-yFgFIs9iDbgKAW45ZxE9_qfj6COAWwI-RhOs2pN6OHwgZHgtoHjOlMFM"; +export const productName = "Micropay Safe"; export const rainbowKitProjectId = "fb3037b60ba3165d90a7f1bb1a727cc5"; export const RE_DIGIT = new RegExp(/^\d+$/); diff --git a/pages/[id].tsx b/pages/[id].tsx index 9711862..2b67ad9 100644 --- a/pages/[id].tsx +++ b/pages/[id].tsx @@ -12,47 +12,39 @@ import ShareLink from "../ui_components/ShareLinkPage"; import MetaHead from "../ui_components/siteMeta"; import { BaseGoerli } from "../utils/chain/baseGoerli"; -const { chains, publicClient, webSocketPublicClient } = configureChains( - [baseGoerli], - [publicProvider()], -); +const { chains, publicClient, webSocketPublicClient } = configureChains([baseGoerli], [publicProvider()]); const config = createConfig({ - autoConnect: true, - connectors: [ - new MetaMaskConnector({ chains }), - new CoinbaseWalletConnector({ - chains, - options: { - appName: productName, - jsonRpcUrl: BaseGoerli.info.url, - chainId: BaseGoerli.coinId, - }, - }), - new InjectedConnector({ - chains, - options: { - name: "Injected", - shimDisconnect: true, - }, - }), - ], - publicClient, - webSocketPublicClient, + autoConnect: true, + connectors: [ + new MetaMaskConnector({ chains }), + new CoinbaseWalletConnector({ + chains, + options: { + appName: productName, + jsonRpcUrl: BaseGoerli.info.url, + chainId: BaseGoerli.coinId, + }, + }), + new InjectedConnector({ + chains, + options: { + name: "Injected", + shimDisconnect: true, + }, + }), + ], + publicClient, + webSocketPublicClient, }); export default function claim() { - const router = useRouter(); - const uuid = router.asPath; - return ( - - - - - ); + const router = useRouter(); + const uuid = router.asPath; + return ( + + + + + ); } diff --git a/pages/index.tsx b/pages/index.tsx index 23dc71a..e7bdf29 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -2,16 +2,8 @@ import "react-toastify/dist/ReactToastify.css"; import "./globals.css"; import { useConnectModal } from "@rainbow-me/rainbowkit"; -import { - EthersAdapter, - SafeAccountConfig, - SafeFactory, -} from "@safe-global/protocol-kit"; -import { - CHAIN_NAMESPACES, - SafeEventEmitterProvider, - WALLET_ADAPTERS, -} from "@web3auth/base"; +import { EthersAdapter, SafeAccountConfig, SafeFactory } from "@safe-global/protocol-kit"; +import { CHAIN_NAMESPACES, SafeEventEmitterProvider, WALLET_ADAPTERS } from "@web3auth/base"; import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider"; import { Web3AuthNoModal } from "@web3auth/no-modal"; import { OpenloginAdapter } from "@web3auth/openlogin-adapter"; @@ -20,13 +12,7 @@ import React, { useContext, useEffect, useState } from "react"; import { ToastContainer } from "react-toastify"; import { toast } from "react-toastify"; -import { - oauthClientId, - productName, - web3AuthClientId, - web3AuthLoginType, - web3AuthVerifier, -} from "../constants"; +import { oauthClientId, productName, web3AuthClientId, web3AuthLoginType, web3AuthVerifier } from "../constants"; import { ACTIONS, GlobalContext } from "../context/GlobalContext"; import BottomSheet from "../ui_components/bottom-sheet"; import ConnectWallet from "../ui_components/connect_wallet/"; @@ -36,24 +22,15 @@ import HomePage from "../ui_components/home/HomePage"; import { LoadChestComponent } from "../ui_components/loadchest/LoadChestComponent"; import { BaseGoerli } from "../utils/chain/baseGoerli"; import { useWagmi } from "../utils/wagmi/WagmiContext"; -import { - useWalletLogin, - useWalletLogout, - useActiveProfile, - useActiveWallet, -} from "@lens-protocol/react-web"; +import { useWalletLogin, useWalletLogout, useActiveProfile } from "@lens-protocol/react-web"; import { useAccount, useConnect, useDisconnect } from "wagmi"; import { InjectedConnector } from "wagmi/connectors/injected"; import { Magic } from "magic-sdk"; import { IPaymaster, BiconomyPaymaster } from "@biconomy/paymaster"; import { IBundler, Bundler } from "@biconomy/bundler"; -import { - BiconomySmartAccount, - BiconomySmartAccountV2, - DEFAULT_ENTRYPOINT_ADDRESS, -} from "@biconomy/account"; +import { BiconomySmartAccount, BiconomySmartAccountV2, DEFAULT_ENTRYPOINT_ADDRESS } from "@biconomy/account"; import { ethers } from "ethers"; -import { saveToLocalStorage } from "../utils"; +import { getFromLocalStorage, saveToLocalStorage } from "../utils"; import { useRouter } from "next/router"; export type THandleStep = { @@ -68,6 +45,8 @@ export enum ESTEPS { export enum LOGGED_IN { GOOGLE = "google", EXTERNAL_WALLET = "external_wallet", + MAGIC = "magic", + LENS = "lens", } export default function Home() { @@ -88,23 +67,11 @@ export default function Home() { const { getAccount, disconnect } = useWagmi(); const { address, isConnecting, isConnected } = useAccount(); const [web3auth, setWeb3auth] = useState(null); - const [provider, setProvider] = useState( - null - ); + const [provider, setProvider] = useState(null); const [loggedIn, setLoggedIn] = useState(false); - const { - execute: login, - error: loginError, - isPending: isLoginPending, - } = useWalletLogin(); + const { execute: login, error: loginError, isPending: isLoginPending } = useWalletLogin(); const { execute: logout } = useWalletLogout(); - const { data: wallet, loading: walletLoading } = useActiveWallet(); - const { - data: profile, - error: profileerror, - loading: profileLoading, - } = useActiveProfile(); const { disconnectAsync } = useDisconnect(); const router = useRouter(); @@ -114,46 +81,71 @@ export default function Home() { }); useEffect(() => { - if (loggedIn) { - console.log(profile, "profile"); - console.log(profileerror, "profileerror"); - console.log(wallet, "wallet"); - console.log(walletLoading, "walletLoading"); - console.log(profileLoading, "profileLoading"); - if (profile !== null) { - dispatch({ - type: ACTIONS.LOGGED_IN_VIA, - payload: LOGGED_IN.GOOGLE, - }); - dispatch({ - type: ACTIONS.SET_ADDRESS, - payload: address, - }); - setWalletAddress(address ?? ""); - setLoader(false); - saveToLocalStorage("address", address); - handleSteps(ESTEPS.THREE); - } else { - toast.info("Your wallet doesn't have lens account"); + async function initLens() { + if (loggedIn) { + try { + const activeProfile = useActiveProfile(); + const { data: profile } = activeProfile; + if (profile == null) { + await disconnect(); + toast.info("Your wallet doesn't have lens account"); + } + } catch(e){ + await disconnect(); + toast.info("Your wallet doesn't have lens account"); + } } } + initLens(); }, [loggedIn]); const onLoginClick = async () => { - if (isConnected) { - await disconnectAsync(); - } + try { + if (isConnected) { + await disconnectAsync(); + } - const { connector } = await connectAsync(); + const { connector } = await connectAsync(); - if (connector instanceof InjectedConnector) { - const walletClient = await connector.getWalletClient(); + if (connector instanceof InjectedConnector) { + const walletClient = await connector.getWalletClient(); - await login({ - address: walletClient.account.address, - }); - setLoggedIn(true); + const resp = await login({ + address: walletClient.account.address, + }); + const prov = await connector?.getProvider(); + saveToLocalStorage("lensProvider", prov); + setLoggedIn(true); + await connectWithBiconomy(prov, LOGGED_IN.LENS); + } + } catch (error) { + toast.error("Something went wrong!"); + } + }; + + const handleDisconnect = async () => { + if (isConnected) { + await disconnectAsync(); } + // await logout(); + await disconnect(); + saveToLocalStorage("loginType", ""); + localStorage.removeItem("isGoogleLogin"); + localStorage.removeItem("isConnected"); + handleSteps(ESTEPS.ONE); + setWalletAddress(""); + dispatch({ + type: ACTIONS.LOGOUT, + payload: "", + }); + dispatch({ + type: ACTIONS.LOGGED_IN_VIA, + payload: "", + }); + dispatch({ + type: ACTIONS.SET_ADDRESS, + payload: "", + }); }; useEffect(() => { @@ -245,12 +237,9 @@ export default function Home() { if (web3auth.connected) { return; } - const web3authProvider = await web3auth.connectTo( - WALLET_ADAPTERS.OPENLOGIN, - { - loginProvider: "google", - } - ); + const web3authProvider = await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, { + loginProvider: "google", + }); setProvider(web3authProvider); const acc = (await getAccounts()) as any; const email = await (await web3auth.getUserInfo()).email; @@ -299,9 +288,7 @@ export default function Home() { owners: [await signer.getAddress()], threshold: 1, }; - const safeSdkOwnerPredicted = await safeFactory.predictSafeAddress( - safeAccountConfig - ); + const safeSdkOwnerPredicted = await safeFactory.predictSafeAddress(safeAccountConfig); return safeSdkOwnerPredicted; }; @@ -343,33 +330,31 @@ export default function Home() { useEffect(() => { async function initMagic() { + const loggedInVia = getFromLocalStorage("loginType"); + const add = getFromLocalStorage("address"); if (window !== undefined) { - console.log(window.location.origin, "window.location.origin"); - console.log("came inside if"); setLoader(true); const magicSdk = new Magic("pk_live_8A226AACC0D8D290"); const prov = await magicSdk.wallet.getProvider(); setProvider(prov); setMagic(magicSdk); const isLoggedIn = await magicSdk.user.isLoggedIn(); - console.log(isLoggedIn, "isloggedin"); - console.log(router.query, "query"); if (router && router.query.magic_credential) { - console.log("came inside callback"); try { await magicSdk.auth.loginWithCredential(); - const userMetadata = await magicSdk.user.getMetadata(); saveToLocalStorage("email", userMetadata.email); - connectWithBiconomy(magicSdk.rpcProvider); + connectWithBiconomy(magicSdk.rpcProvider, LOGGED_IN.MAGIC); } catch (e) { console.error(e); } } else if (isLoggedIn) { - console.log("came inside isloggedin"); const userMetadata = await magicSdk.user.getMetadata(); saveToLocalStorage("email", userMetadata.email); - connectWithBiconomy(magicSdk.rpcProvider); + connectWithBiconomy(magicSdk.rpcProvider, LOGGED_IN.MAGIC); + } else if (loggedInVia && loggedInVia === LOGGED_IN.LENS && add) { + const { connector } = await connectAsync(); + connectWithBiconomy(await connector?.getProvider(), LOGGED_IN.LENS); } else { setLoader(false); } @@ -399,22 +384,17 @@ export default function Home() { }); }; - const connectWithBiconomy = async (rpcProvider: any) => { + const connectWithBiconomy = async (rpcProvider: any, logintype: LOGGED_IN) => { setLoader(true); try { - const web3Provider = new ethers.providers.Web3Provider( - rpcProvider, - "any" - ); + const web3Provider = new ethers.providers.Web3Provider(rpcProvider, "any"); const paymaster = new BiconomyPaymaster({ - paymasterUrl: - "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", + paymasterUrl: "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", }); const bundler: IBundler = new Bundler({ - bundlerUrl: - "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", + bundlerUrl: "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", chainId: 84531, entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS, }); @@ -430,7 +410,7 @@ export default function Home() { const scw = await wallet.getSmartAccountAddress(); dispatch({ type: ACTIONS.LOGGED_IN_VIA, - payload: LOGGED_IN.GOOGLE, + payload: logintype, }); dispatch({ type: ACTIONS.SET_ADDRESS, @@ -443,6 +423,7 @@ export default function Home() { setWalletAddress(scw ?? ""); setLoader(false); saveToLocalStorage("address", scw); + saveToLocalStorage("loginType", logintype); handleSteps(ESTEPS.THREE); } catch (error) { setLoader(false); @@ -453,10 +434,6 @@ export default function Home() { const connectMagicWallet = async (val: string) => { setSigninLoading(true); - // const login = magic.auth.loginWithEmailOTP({ - // email: val, - // showUI: false, - // }); const redirectURI = `${window.location.origin}`; const loginWithLink = magic.auth.loginWithMagicLink({ email: val, @@ -480,51 +457,6 @@ export default function Home() { .on("settled", () => { // is called when the Promise either resolves or rejects }); - // setLoginItem(login); - - // login - // .on("email-otp-sent", () => { - // // The email has been sent to the user - // console.log("OTP sent"); - // setSigninLoading(false); - // toast.success("OTP sent!"); - // setShowOtp(true); - // }) - // .on("invalid-email-otp", () => { - // login.emit("cancel"); - // }) - // .on("done", (result: any) => { - // // is called when the Promise resolves - // // convey login success to user - // setProvider(magic.wallet.getProvider()); - // console.log(result, "success"); - // getAccounts() - // .then((res: any) => { - // setLoader(false); - // console.log(res, "address is what"); - // dispatch({ - // type: ACTIONS.LOGGED_IN_VIA, - // payload: LOGGED_IN.GOOGLE, - // }); - // dispatch({ - // type: ACTIONS.SET_ADDRESS, - // payload: res, - // }); - // setWalletAddress(res); - // }) - // .catch((e) => { - // console.log(e, "error"); - // }); - // DID Token returned in result - // const didToken = result; - // }) - // .on("error", (reason: any) => { - // setSigninLoading(false); - // console.error(reason, "errorqw"); - // }) - // .on("settled", () => { - // // is called when the Promise either resolves or rejects - // }); }; const getUIComponent = (step: number) => { @@ -532,17 +464,7 @@ export default function Home() { case ESTEPS.ONE: return ; case ESTEPS.TWO: - return ( - - ); + return ; case ESTEPS.THREE: return ; default: @@ -592,30 +514,9 @@ export default function Home() { return ( <> -
+
- + {getUIComponent(step)} = (props) => { const [shareText, setShareText] = useState("Share"); const [showShareIcon, setShowShareIcon] = useState(true); const [tokenValue, setTokenValue] = useState(""); - const [headingText, setHeadingText] = useState( - "Your Chest is ready to claim!" - ); + const [headingText, setHeadingText] = useState("Your Chest is ready to claim!"); const [linkValueUsd, setLinkValueUsd] = useState(""); const [isRedirected, setIsRedirected] = useState(false); const [isLoading, setIsLoading] = useState(true); @@ -102,12 +67,8 @@ const ShareLink: FC = (props) => { const [showQr, setShowQr] = useState(false); const [isClaimSuccessful, setIsClaimSuccessful] = useState(false); const [txHash, setTxHash] = useState(""); - const ethersProvider = new ethers.providers.JsonRpcProvider( - BaseGoerli.info.rpc - ); - const relayPack = new GelatoRelayPack( - process.env.NEXT_PUBLIC_GELATO_RELAY_API_KEY - ); + const ethersProvider = new ethers.providers.JsonRpcProvider(BaseGoerli.info.rpc); + const relayPack = new GelatoRelayPack(process.env.NEXT_PUBLIC_GELATO_RELAY_API_KEY); const options: MetaTransactionOptions = { gasLimit: "100000", isSponsored: true, @@ -153,7 +114,7 @@ const ShareLink: FC = (props) => { const walletCore = await initWasm(); const wallet = new Wallet(walletCore); setWallet(wallet); - const chars = uuid.split("|"); + const chars = uuid.split("~"); if (chars.length < 1) { return; } @@ -182,16 +143,9 @@ const ShareLink: FC = (props) => { setTokenValue(getTokenValueFormatted(bgNum, 6, false)); setIsLoading(false); const formatBal = bgNum * res.data.ethereum.usd; - setLinkValueUsd( - getCurrencyFormattedNumber(roundDownToTenth(formatBal), 2, "USD", true) - ); - const zeroBal = - getCurrencyFormattedNumber(formatBal, 2, "USD", true) === "$0"; - setHeadingText( - zeroBal - ? "Chest have found their owner!" - : "Your Chest is ready to claim!" - ); + setLinkValueUsd(getCurrencyFormattedNumber(roundDownToTenth(formatBal), 2, "USD", true)); + const zeroBal = getCurrencyFormattedNumber(formatBal, 2, "USD", true) === "$0"; + setHeadingText(zeroBal ? "Chest have found their owner!" : "Your Chest is ready to claim!"); }); }; @@ -204,7 +158,6 @@ const ShareLink: FC = (props) => { }; const handlePublicAddressTransaction = (toAdd: string) => { - console.log(toAdd, "to add"); handleCloseClaimModal(); sendToken(toAdd); }; @@ -222,9 +175,7 @@ const ShareLink: FC = (props) => { connector: injectConnector, }); setToAddress(result.account); - toast.success( - `Please wait, wallet connected and claim initiated for the chest` - ); + toast.success(`Please wait, wallet connected and claim initiated for the chest`); handleCloseClaimModal(); sendToken(result.account); } catch (e: any) { @@ -245,7 +196,7 @@ const ShareLink: FC = (props) => { const handleSendToken = async () => { const walletCore = await initWasm(); const wallet = new Wallet(walletCore); - const chars = uuid.split("|"); + const chars = uuid.split("~"); if (chars.length < 1) { return; } @@ -255,134 +206,61 @@ const ShareLink: FC = (props) => { // from signer address const fromSigner = new ethers.Wallet(fromKey.key, ethersProvider); - console.log(fromSigner, "fromSigner"); - const paymaster = new BiconomyPaymaster({ - paymasterUrl: - "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", + paymasterUrl: "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", }); - console.log(paymaster, "paymaster"); const bundler: IBundler = new Bundler({ - bundlerUrl: - "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", + bundlerUrl: "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", chainId: 84531, entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS, }); - console.log(bundler, "bundler"); let biWallet = new BiconomySmartAccount({ signer: fromSigner, chainId: 84531, bundler: bundler, paymaster: paymaster, }); - console.log(biWallet, "biWallet"); biWallet = await biWallet.init({ accountIndex: 0, }); - console.log("biWallet initiated"); bicomomySmartAcc.current = biWallet; - // const safeAccountAbs = new AccountAbstraction(fromSigner); - // await safeAccountAbs.init({ relayPack }); - // safeAccountAbstraction.current = safeAccountAbs; - // isRelayInitiated.current = true; }; const sendToken = async (toAdd: string) => { setProcessing(true); try { if (bicomomySmartAcc.current) { - // setTransactionLoading(true); - // setChestLoadingText("Initializing wallet and creating link..."); const amountValue = hexToNumber(walletBalanceHex) / Math.pow(10, 18); - // const amount = ethers.utils.parseEther( - // amountValue as unknown as string - // ); - // console.log(amount, "amount"); - console.log(amountValue, "amountValue"); const data = "0x"; const tx = { to: toAdd, value: parseEther(amountValue.toString()).toString(), data, }; - console.log(tx, "tx"); const smartAccount = bicomomySmartAcc; let partialUserOp = await smartAccount.current?.buildUserOp([tx]); - console.log(partialUserOp, "partialUserOp"); - // setChestLoadingText("Setting up smart account..."); - const biconomyPaymaster = smartAccount.current - ?.paymaster as IHybridPaymaster; - console.log(biconomyPaymaster, "biconomyPaymaster"); + const biconomyPaymaster = smartAccount.current?.paymaster as IHybridPaymaster; let paymasterServiceData: SponsorUserOperationDto = { mode: PaymasterMode.SPONSORED, // optional params... }; - console.log(paymasterServiceData, "paymasterServiceData"); try { // setChestLoadingText("Setting up paymaster..."); - const paymasterAndDataResponse = - await biconomyPaymaster.getPaymasterAndData( - partialUserOp!, - paymasterServiceData - ); - console.log(paymasterAndDataResponse, "paymasterAndDataResponse"); - partialUserOp!.paymasterAndData = - paymasterAndDataResponse.paymasterAndData; - - const userOpResponse = await smartAccount.current?.sendUserOp( - partialUserOp! - ); - console.log(userOpResponse, "userOpResponse"); + const paymasterAndDataResponse = await biconomyPaymaster.getPaymasterAndData(partialUserOp!, paymasterServiceData); + partialUserOp!.paymasterAndData = paymasterAndDataResponse.paymasterAndData; + + const userOpResponse = await smartAccount.current?.sendUserOp(partialUserOp!); const transactionDetails = await userOpResponse?.wait(); - console.log(transactionDetails, "transactionDetails"); - // setExplorerUrl( - // `https://goerli.basescan.org/tx/${transactionDetails.receipt.transactionHash}` - // ); - console.log( - `https://goerli.basescan.org/tx/${transactionDetails?.receipt.transactionHash}`, - "tx hash" - ); - handleTransactionStatus( - transactionDetails?.receipt.transactionHash ?? "" - ); - // setChestLoadingText("Success! Transaction Processed"); - // setIsSucceed(true); - // setChestLoadingText("Operation Successful: Transaction Completed!"); - - // router.push(linkHash); + handleTransactionStatus(transactionDetails?.receipt.transactionHash ?? ""); } catch (error) { console.error("Error executing transaction:", error); } } - // if (isRelayInitiated.current) { - // const amountValue = hexToNumber(walletBalanceHex) / Math.pow(10, 18); - - // const safeTransactionData: MetaTransactionData = { - // to: toAdd, - // data: "0x", - // value: parseEther(amountValue.toString()).toString(), - // operation: OperationType.Call, - // }; - - // const gelatoTaskId = - // await safeAccountAbstraction?.current?.relayTransaction( - // [safeTransactionData], - // options - // ); - // if (gelatoTaskId) { - // handleTransactionStatus(gelatoTaskId); - // } - // } else { - // await handleSendToken(); - // sendToken(toAdd); - // return; - // } } catch (e: any) { setProcessing(false); toast.error(e.message); - console.log(e, "e"); } }; @@ -417,47 +295,6 @@ const ShareLink: FC = (props) => { }, intervalInMilliseconds); }; - // const handleTransactionStatus = (hash: string) => { - // const intervalInMilliseconds = 1000; - // const interval = setInterval(() => { - // getRelayTransactionStatus(hash) - // .then((res: any) => { - // if (res) { - // const task = res.data.task; - // if (task) { - // if ( - // task.taskState === "WaitingForConfirmation" || - // task.taskState === "ExecSuccess" - // ) { - // setLinkValueUsd("$0"); - // setTokenValue("0"); - // setTxHash(task.transactionHash); - // setHeadingText("Chest have found their owner!"); - // handleClaimSuccess(); - // if (interval !== null) { - // clearInterval(interval); - // } - // } - // } else { - // setProcessing(false); - // const err = serializeError("Failed to Claim!"); - // toast.error(err.message); - // if (interval !== null) { - // clearInterval(interval); - // } - // } - // } - // }) - // .catch((e) => { - // setProcessing(false); - // toast.error(e.message); - // console.log(e, "e"); - // if (interval !== null) { - // clearInterval(interval); - // } - // }); - // }, intervalInMilliseconds); - // }; const handleClaimSuccess = () => { setIsClaimSuccessful(true); @@ -497,22 +334,9 @@ const ShareLink: FC = (props) => { return (
- +
- {!processing && ( -

{headingText}

- )} + {!processing &&

{headingText}

}
@@ -527,15 +351,8 @@ const ShareLink: FC = (props) => {

{`${linkValueUsd}`}

{`~ ${tokenValue} ETH`}

- - external link + + external link = (props) => { setShowQr(!showQr); }} /> - copy address + copy address
)} -
- {isClaimSuccessful || linkValueUsd === "$0" ? ( - Chest Open - ) : ( - Chest - )} -
+
{isClaimSuccessful || linkValueUsd === "$0" ? Chest Open : Chest}
{linkValueUsd === "$0" ? ( txHash ? ( -
+

🎉 Claim successful!

{" "} The treasure is now yours to behold! - + {"View ->"}

@@ -596,9 +391,7 @@ const ShareLink: FC = (props) => { {!processing && (
{ handleShareURL(); @@ -613,9 +406,7 @@ const ShareLink: FC = (props) => { {!processing && (
{ setOpenShareModal(true); @@ -626,42 +417,18 @@ const ShareLink: FC = (props) => { />
)} - handleClaimClick()} - rightImage={processing ? undefined : icons.downloadBtnIconBlack} - btnDisable={handleDisableBtn()} - loading={isLoading || processing} - /> - {processing && ( -

- {"⏳ Hang tight! We're currently processing your claim."} -

- )} + handleClaimClick()} rightImage={processing ? undefined : icons.downloadBtnIconBlack} btnDisable={handleDisableBtn()} loading={isLoading || processing} /> + {processing &&

{"⏳ Hang tight! We're currently processing your claim."}

} ) : ( <> - handleClaimClick()} - rightImage={processing ? undefined : icons.downloadBtnIconBlack} - btnDisable={handleDisableBtn()} - loading={isLoading || processing} - /> - - {processing && ( -

- {"⏳ Hang tight! We're currently processing your claim."} -

- )} + handleClaimClick()} rightImage={processing ? undefined : icons.downloadBtnIconBlack} btnDisable={handleDisableBtn()} loading={isLoading || processing} /> + + {processing &&

{"⏳ Hang tight! We're currently processing your claim."}

} {!processing && (
{ handleShareURL(); @@ -676,9 +443,7 @@ const ShareLink: FC = (props) => { {!processing && (
{ setOpenShareModal(true); @@ -692,23 +457,10 @@ const ShareLink: FC = (props) => { )}
- + - {isClaimSuccessful && ( - - )} + {isClaimSuccessful && } {/*
*/}
diff --git a/ui_components/bottom-sheet/index.tsx b/ui_components/bottom-sheet/index.tsx index 32d6fa4..8a37316 100644 --- a/ui_components/bottom-sheet/index.tsx +++ b/ui_components/bottom-sheet/index.tsx @@ -158,11 +158,11 @@ const BottomSheet: FC = (props) => { >
login with google

- Login with Google + Login with Lens

{ - console.log(val, "value"); setOtp(val); }; useEffect(() => { - // This effect runs after each render when 'otp' changes. - console.log(otp.length, "otp"); // Check the length and set 'enableVerifyBtn' accordingly. if (otp.trim().length === 6) { - console.log("came to if"); setEnableVerifyBtn(true); } else { - console.log("came to else"); setEnableVerifyBtn(false); } }, [otp]); diff --git a/ui_components/header/index.tsx b/ui_components/header/index.tsx index 263ef42..38c44cc 100644 --- a/ui_components/header/index.tsx +++ b/ui_components/header/index.tsx @@ -10,274 +10,239 @@ import { icons } from "../../utils/images"; import { useWagmi } from "../../utils/wagmi/WagmiContext"; import BackBtn from "../BackBtn"; import PrimaryBtn from "../PrimaryBtn"; +import { useWalletLogout } from "@lens-protocol/react-web"; +import { useDisconnect } from "wagmi"; interface IHeader { - walletAddress: string; - signIn: () => Promise; - handleSteps: (step: number) => void; - step: number; - onHamburgerClick: () => void; - signOut: () => Promise; - setWalletAddress: (val: string) => void; - loader?: boolean; - initLoader?: boolean; + walletAddress: string; + signIn: () => Promise; + handleSteps: (step: number) => void; + step: number; + onHamburgerClick: () => void; + signOut: () => Promise; + setWalletAddress: (val: string) => void; + handleDisconnect: () => Promise; + loader?: boolean; + initLoader?: boolean; } const Header = (props: IHeader) => { - const menuRef = useRef(null); - const { - walletAddress, - signIn, - step, - handleSteps, - onHamburgerClick, - signOut, - setWalletAddress, - loader, - initLoader, - } = props; - const { - dispatch, - state: { googleUserInfo, address, isConnected, loggedInVia }, - } = useContext(GlobalContext); - const [copyText, setCopyText] = useState("Copy Address"); - const [opacity, setOpacity] = useState(false); - const { disconnect } = useWagmi(); + const menuRef = useRef(null); + const { + walletAddress, + signIn, + step, + handleSteps, + onHamburgerClick, + signOut, + setWalletAddress, + loader, + initLoader, + handleDisconnect, + } = props; + const { + dispatch, + state: { googleUserInfo, address, isConnected, loggedInVia }, + } = useContext(GlobalContext); + const [copyText, setCopyText] = useState("Copy Address"); + const [opacity, setOpacity] = useState(false); + const { disconnect } = useWagmi(); + const { execute: logout } = useWalletLogout(); + const { disconnectAsync } = useDisconnect(); - const copyToClipBoard = (e: any) => { - e.preventDefault(); - e.stopPropagation(); - navigator.clipboard.writeText(address); - setCopyText("Address copied"); - setTimeout(() => { - setCopyText("Copy Address"); - }, 4000); - }; + const copyToClipBoard = (e: any) => { + e.preventDefault(); + e.stopPropagation(); + navigator.clipboard.writeText(address); + setCopyText("Address copied"); + setTimeout(() => { + setCopyText("Copy Address"); + }, 4000); + }; - const handleLogout = () => { - signOut(); - setOpacity(false); - }; + const handleLogout = () => { + signOut(); + setOpacity(false); + }; - const handleClick = () => { - setOpacity(!opacity); - onHamburgerClick(); - }; + const handleClick = () => { + setOpacity(!opacity); + onHamburgerClick(); + }; - const handleClickOutside = (e: any) => { - if (menuRef.current && !menuRef?.current?.contains(e.target)) { - setOpacity(false); - } + const handleClickOutside = (e: any) => { + if (menuRef.current && !menuRef?.current?.contains(e.target)) { + setOpacity(false); + } + }; + + useEffect(() => { + document.addEventListener("click", handleClickOutside); + return () => { + document.removeEventListener("click", handleClickOutside); }; + }, []); - useEffect(() => { - document.addEventListener("click", handleClickOutside); - return () => { - document.removeEventListener("click", handleClickOutside); - }; - }, []); + return ( +
+
+
+
+ {step === 1 ? ( +
+ logo +

+ Micropay +

+
+ ) : ( +
+ handleSteps(step === 3 ? 1 : step - 1)} /> +
+ )} - const handleDisConnect = async () => { - await disconnect(); - localStorage.removeItem("isGoogleLogin"); - localStorage.removeItem("isConnected"); - handleSteps(ESTEPS.ONE); - setWalletAddress(""); - dispatch({ - type: ACTIONS.LOGOUT, - payload: "", - }); - dispatch({ - type: ACTIONS.LOGGED_IN_VIA, - payload: "", - }); - dispatch({ - type: ACTIONS.SET_ADDRESS, - payload: "", - }); - }; +
+ +
+ -
- -
+

Logout

+
+ logout +
+ ) : null} +
-
+
+ ) : null} +
-
- ); + + + +
+ ); }; export default Header; diff --git a/ui_components/loadchest/LoadChestComponent.tsx b/ui_components/loadchest/LoadChestComponent.tsx index ecd5ed4..9d7c573 100644 --- a/ui_components/loadchest/LoadChestComponent.tsx +++ b/ui_components/loadchest/LoadChestComponent.tsx @@ -4,11 +4,7 @@ import AccountAbstraction from "@safe-global/account-abstraction-kit-poc"; import { EthersAdapter } from "@safe-global/protocol-kit"; import { SafeAccountConfig, SafeFactory } from "@safe-global/protocol-kit"; import { GelatoRelayPack } from "@safe-global/relay-kit"; -import { - MetaTransactionData, - MetaTransactionOptions, - OperationType, -} from "@safe-global/safe-core-sdk-types"; +import { MetaTransactionData, MetaTransactionOptions, OperationType } from "@safe-global/safe-core-sdk-types"; import { initWasm } from "@trustwallet/wallet-core"; import { serializeError } from "eth-rpc-errors"; import { ethers } from "ethers"; @@ -22,22 +18,11 @@ import { ToastContainer } from "react-toastify"; import ReactTyped from "react-typed"; import { parseEther } from "viem"; -import { - getBalance, - getRelayTransactionStatus, - getSendTransactionStatus, - getUsdPrice, -} from "../../apiServices"; +import { getBalance, getRelayTransactionStatus, getSendTransactionStatus, getUsdPrice } from "../../apiServices"; import { GlobalContext } from "../../context/GlobalContext"; import { LOGGED_IN, THandleStep } from "../../pages"; import * as loaderAnimation from "../../public/lottie/loader.json"; -import { - encodeAddress, - getCurrencyFormattedNumber, - getTokenFormattedNumber, - getTokenValueFormatted, - hexToNumber, -} from "../../utils"; +import { encodeAddress, getCurrencyFormattedNumber, getTokenFormattedNumber, getTokenValueFormatted, hexToNumber } from "../../utils"; import { BaseGoerli } from "../../utils/chain/baseGoerli"; import { icons } from "../../utils/images"; import { useWagmi } from "../../utils/wagmi/WagmiContext"; @@ -46,23 +31,11 @@ import PrimaryBtn from "../PrimaryBtn"; import SecondaryBtn from "../SecondaryBtn"; import DepositAmountModal from "./DepositAmountModal"; import { ProfileCard } from "./ProfileCard"; -import { - GateFiEventTypes, - GateFiDisplayModeEnum, - GateFiSDK, -} from "@gatefi/js-sdk"; +import { GateFiEventTypes, GateFiDisplayModeEnum, GateFiSDK } from "@gatefi/js-sdk"; import { IPaymaster, BiconomyPaymaster } from "@biconomy/paymaster"; import { IBundler, Bundler } from "@biconomy/bundler"; -import { - BiconomySmartAccount, - BiconomySmartAccountV2, - DEFAULT_ENTRYPOINT_ADDRESS, -} from "@biconomy/account"; -import { - IHybridPaymaster, - PaymasterMode, - SponsorUserOperationDto, -} from "@biconomy/paymaster"; +import { BiconomySmartAccount, BiconomySmartAccountV2, DEFAULT_ENTRYPOINT_ADDRESS } from "@biconomy/account"; +import { IHybridPaymaster, PaymasterMode, SponsorUserOperationDto } from "@biconomy/paymaster"; export interface ILoadChestComponent { provider?: any; @@ -91,12 +64,8 @@ export const LoadChestComponent: FC = (props) => { const [balanceInUsd, setBalanceInUsd] = useState(""); const [showActivity, setShowActivity] = useState(false); const [chestLoadingText, setChestLoadingText] = useState(""); - const ethersProvider = new ethers.providers.JsonRpcProvider( - BaseGoerli.info.rpc - ); - const relayPack = new GelatoRelayPack( - process.env.NEXT_PUBLIC_GELATO_RELAY_API_KEY - ); + const ethersProvider = new ethers.providers.JsonRpcProvider(BaseGoerli.info.rpc); + const relayPack = new GelatoRelayPack(process.env.NEXT_PUBLIC_GELATO_RELAY_API_KEY); const isRelayInitiated = useRef(false); const handleToggle = () => { setToggle(!toggle); @@ -128,16 +97,8 @@ export const LoadChestComponent: FC = (props) => { setTokenPrice(res.data.ethereum.usd); setFromAddress(address); const balance = (await getBalance(address)) as any; - setTokenValue( - getTokenFormattedNumber( - hexToNumber(balance.result) as unknown as string, - 18 - ) - ); - const formatBal = ( - (hexToNumber(balance.result) / Math.pow(10, 18)) * - res.data.ethereum.usd - ).toFixed(3); + setTokenValue(getTokenFormattedNumber(hexToNumber(balance.result) as unknown as string, 18)); + const formatBal = ((hexToNumber(balance.result) / Math.pow(10, 18)) * res.data.ethereum.usd).toFixed(3); setPrice(getCurrencyFormattedNumber(formatBal)); setBalanceInUsd(formatBal); setLoading(false); @@ -187,13 +148,11 @@ export const LoadChestComponent: FC = (props) => { setChestLoadingText("Setting up destination signer and address"); const paymaster = new BiconomyPaymaster({ - paymasterUrl: - "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", + paymasterUrl: "https://paymaster.biconomy.io/api/v1/84531/76v47JPQ6.7a881a9f-4cec-45e0-95e9-c39c71ca54f4", }); const bundler: IBundler = new Bundler({ - bundlerUrl: - "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", + bundlerUrl: "https://bundler.biconomy.io/api/v2/84531/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44", chainId: 84531, entryPointAddress: DEFAULT_ENTRYPOINT_ADDRESS, }); @@ -208,39 +167,9 @@ export const LoadChestComponent: FC = (props) => { }); const scw = await biWallet.getSmartAccountAddress(); const destinatinoHash = encodeAddress(scw); - const fullHash = payData.link + "|" + destinatinoHash; + const fullHash = payData.link + "~" + destinatinoHash; setLinkHash(fullHash); setDestinationAddress(scw); - console.log(scw, "smart address"); - - // const destinationSigner = new ethers.Wallet(payData.key, ethersProvider); - // const destinationEOAAddress = await destinationSigner.getAddress(); - // const ethAdapter = new EthersAdapter({ - // ethers, - // signerOrProvider: destinationSigner, - // }); - // setChestLoadingText("Creating safe contract for chest"); - // const safeFactory = await SafeFactory.create({ - // ethAdapter: ethAdapter, - // }); - // const safeAccountConfig: SafeAccountConfig = { - // owners: [destinationEOAAddress], - // threshold: 1, - // }; - // const destinationAdd = await safeFactory.predictSafeAddress( - // safeAccountConfig - // ); - // setDestinationAddress(destinationAdd); - // const destinatinoHash = encodeAddress(destinationAdd); - // const fullHash = payData.link + "|" + destinatinoHash; - // setLinkHash(fullHash); - // setChestLoadingText("Safe contract created"); - // const fromEthProvider = new ethers.providers.Web3Provider(provider); - // const fromSigner = await fromEthProvider.getSigner(); - // const safeAccountAbs = new AccountAbstraction(fromSigner); - // await safeAccountAbs.init({ relayPack }); - // safeAccountAbstraction.current = safeAccountAbs; - // isRelayInitiated.current = true; }; const createWallet = async () => { @@ -255,104 +184,32 @@ export const LoadChestComponent: FC = (props) => { value: amount, data, }; - console.log(tx, "tx"); const smartAccount = biconomyWallet; let partialUserOp = await smartAccount.buildUserOp([tx]); - console.log(partialUserOp, "partialUserOp"); setChestLoadingText("Setting up smart account..."); - const biconomyPaymaster = - smartAccount.paymaster as IHybridPaymaster; - console.log(biconomyPaymaster, "biconomyPaymaster"); + const biconomyPaymaster = smartAccount.paymaster as IHybridPaymaster; let paymasterServiceData: SponsorUserOperationDto = { mode: PaymasterMode.SPONSORED, // optional params... }; - console.log(paymasterServiceData, "paymasterServiceData"); try { setChestLoadingText("Setting up paymaster..."); - const paymasterAndDataResponse = - await biconomyPaymaster.getPaymasterAndData( - partialUserOp, - paymasterServiceData - ); - console.log(paymasterAndDataResponse, "paymasterAndDataResponse"); - partialUserOp.paymasterAndData = - paymasterAndDataResponse.paymasterAndData; + const paymasterAndDataResponse = await biconomyPaymaster.getPaymasterAndData(partialUserOp, paymasterServiceData); + partialUserOp.paymasterAndData = paymasterAndDataResponse.paymasterAndData; const userOpResponse = await smartAccount.sendUserOp(partialUserOp); - console.log(userOpResponse, "userOpResponse"); const transactionDetails = await userOpResponse.wait(); - console.log(transactionDetails, "transactionDetails"); - setExplorerUrl( - `https://goerli.basescan.org/tx/${transactionDetails.receipt.transactionHash}` - ); - console.log(transactionDetails.receipt.transactionHash, "tx hash"); + setExplorerUrl(`https://goerli.basescan.org/tx/${transactionDetails.receipt.transactionHash}`); setChestLoadingText("Success! Transaction Processed"); setIsSucceed(true); - handleTransactionStatus( - transactionDetails.receipt.transactionHash, - linkHash - ); + handleTransactionStatus(transactionDetails.receipt.transactionHash, linkHash); setChestLoadingText("Transaction Submitted!"); // router.push(linkHash); } catch (error) { console.error("Error executing transaction:", error); } - // try { - // if (loggedInVia === LOGGED_IN.GOOGLE) { - // if (isRelayInitiated.current) { - // setChestLoadingText("Transaction process has begun..."); - - // const safeTransactionData: MetaTransactionData = { - // to: destinationAddress, - // data: "0x", - // value: parseEther(inputValue).toString(), - // operation: OperationType.Call, - // }; - - // const options: MetaTransactionOptions = { - // gasLimit: "100000", - // isSponsored: true, - // }; - - // const gelatoTaskId = - // await safeAccountAbstraction?.current?.relayTransaction( - // [safeTransactionData], - // options - // ); - // if (gelatoTaskId) { - // setChestLoadingText( - // "Transaction on its way! Awaiting confirmation..." - // ); - // handleTransactionStatus(gelatoTaskId, linkHash); - // } - // } else { - // await handleInitWallet(); - // createWallet(); - // return; - // } - // } else { - // try { - // const sendAmount = await sendTransaction({ - // to: destinationAddress, - // value: parseEther(inputValue), - // }); - // handleTransactionStatus(sendAmount.hash, linkHash); - // } catch (e: any) { - // setTransactionLoading(false); - // const err = serializeError(e); - // toast.error(err.message); - // console.log(e, "error"); - // } - // } - // } catch (e: any) { - // setTransactionLoading(false); - // const err = serializeError(e); - // toast.error(err.message); - // console.log(e, "e"); - // } } }; @@ -423,74 +280,6 @@ export const LoadChestComponent: FC = (props) => { }, intervalInMilliseconds); }; - // const handleTransactionStatus = (hash: string, link: string) => { - // const intervalInMilliseconds = 1000; - // const interval = setInterval(() => { - // if (loggedInVia === LOGGED_IN.GOOGLE) { - // getRelayTransactionStatus(hash) - // .then((res: any) => { - // if (res) { - // console.log(res, "res"); - // const task = res.data.task; - // if (task) { - // setChestLoadingText("Verifying Transaction Status..."); - // if (task.taskState === "ExecSuccess") { - // setChestLoadingText( - // "Operation Successful: Transaction Completed!" - // ); - // router.push(link); - // if (interval !== null) { - // clearInterval(interval); - // } - // } - // } else { - // setTransactionLoading(false); - // toast.error("Failed to Load Chest. Try Again"); - // if (interval !== null) { - // clearInterval(interval); - // } - // } - // } - // }) - // .catch((e) => { - // setTransactionLoading(false); - // toast.error(e.message); - // console.log(e, "e"); - // if (interval !== null) { - // clearInterval(interval); - // } - // }); - // } else { - // getSendTransactionStatus(hash) - // .then((res: any) => { - // if (res.result) { - // const status = Number(res.result.status); - // if (status === 1) { - // router.push(link); - // if (interval !== null) { - // clearInterval(interval); - // } - // } else { - // setTransactionLoading(false); - // toast.error("Failed to Load Chest. Try Again"); - // if (interval !== null) { - // clearInterval(interval); - // } - // } - // } - // }) - // .catch((e) => { - // setTransactionLoading(false); - // toast.error(e.message); - // console.log(e, "e"); - // if (interval !== null) { - // clearInterval(interval); - // } - // }); - // } - // }, intervalInMilliseconds); - // }; - const handleShowActivity = () => { setShowActivity(!showActivity); }; @@ -499,11 +288,7 @@ export const LoadChestComponent: FC = (props) => {
{!transactionLoading ? (
- + {!showActivity ? ( <> @@ -512,12 +297,7 @@ export const LoadChestComponent: FC = (props) => {

YOUR BALANCE

- transferIcon + transferIcon {toggle ? ( loading || loader ? (
@@ -526,12 +306,8 @@ export const LoadChestComponent: FC = (props) => {
) : (
-

- {price} -

-

- {tokenValue} ETH -

+

{price}

+

{tokenValue} ETH

) ) : loading ? ( @@ -541,31 +317,15 @@ export const LoadChestComponent: FC = (props) => {
) : (
-

- ~ {tokenValue} ETH -

-

- {price} -

+

~ {tokenValue} ETH

+

{price}

)}
- transferIcon - {!loading && !loader ? ( -

- ETH -

- ) : ( -
- )} + transferIcon + {!loading && !loader ?

ETH

:
}
= (props) => { setOpen(true); }} > -

- + Add funds to your account -

+

+ Add funds to your account

@@ -598,16 +356,10 @@ export const LoadChestComponent: FC = (props) => { handleInputChange(e.target.value); }} disabled={loading} - onWheel={() => - (document.activeElement as HTMLElement).blur() - } + onWheel={() => (document.activeElement as HTMLElement).blur()} />
- {Number(inputValue) > 0 && ( -

- ~ {inputValue} ETH -

- )} + {Number(inputValue) > 0 &&

~ {inputValue} ETH

} @@ -643,20 +395,9 @@ export const LoadChestComponent: FC = (props) => {
- +
- +
@@ -665,22 +406,11 @@ export const LoadChestComponent: FC = (props) => { ) : (
- +
)} - + {/*
*/} ); diff --git a/ui_components/loadchest/ProfileCard.tsx b/ui_components/loadchest/ProfileCard.tsx index 667d541..f3acd8e 100644 --- a/ui_components/loadchest/ProfileCard.tsx +++ b/ui_components/loadchest/ProfileCard.tsx @@ -6,88 +6,65 @@ import Link from "next/link"; import { FC, useContext, useState } from "react"; import { GlobalContext } from "../../context/GlobalContext"; -import { trimAddress } from "../../utils"; +import { getFromLocalStorage, trimAddress } from "../../utils"; import { icons } from "../../utils/images"; import QrModal from "../QrModal"; +import { useActiveProfile } from "@lens-protocol/react-web"; +import { LOGGED_IN } from "../../pages"; export interface IProfileCard { - profileImage?: string; - balance: string; - showActivity: boolean; - transactionLoading: boolean; + profileImage?: string; + balance: string; + showActivity: boolean; + transactionLoading: boolean; } export const ProfileCard: FC = (props) => { - const { transactionLoading } = props; - const { - state: { address }, - } = useContext(GlobalContext); - const [showQr, setShowQr] = useState(false); + const { transactionLoading } = props; + const { + state: { address, loggedInVia }, + } = useContext(GlobalContext); + let handle = "Lens Smart Account"; + try { + const { data: profile } = useActiveProfile(); + handle = `@` + profile?.handle; + } catch (e) {} + const [showQr, setShowQr] = useState(false); - const copyToClipBoard = (e: any) => { - e.preventDefault(); - e.stopPropagation(); - navigator.clipboard.writeText(address); - }; + const copyToClipBoard = (e: any) => { + e.preventDefault(); + e.stopPropagation(); + navigator.clipboard.writeText(address); + }; - return ( - <> -
-
- profile image -
-

My Smart Wallet

- {transactionLoading ? ( -
- ) : ( -

{`${trimAddress(address)}`}

- )} + return ( + <> +
+
+ profile image +
+

{loggedInVia === LOGGED_IN.LENS ? `${handle}` : "My Smart Account"}

+ {transactionLoading ?
:

{`${trimAddress(address)}`}

} -
- copy address - show qr code { - setShowQr(!showQr); - }} - /> - - external link - -
- -

Powered by:

- {/* safe logo */} - +
+ copy address + show qr code { + setShowQr(!showQr); + }} + /> + + external link + +
+ +

Powered by:

+ safe logo + - {/* {showActivity ? ( + {/* {showActivity ? (
= (props) => { />
) : null} */} -
- {/* {showActivity ? ( +
+ {/* {showActivity ? (

Activity

) : null} */} - - - ); + + + ); }; diff --git a/ui_components/loadchest/QRComponent.tsx b/ui_components/loadchest/QRComponent.tsx index 05debe8..bb6ca5d 100644 --- a/ui_components/loadchest/QRComponent.tsx +++ b/ui_components/loadchest/QRComponent.tsx @@ -87,7 +87,7 @@ export const QRComponent: FC = (props) => { }, dotsOptions: { type: "extra-rounded", - color: "#FFFFFF", + color: "#000000", }, // imageOptions: { // hideBackgroundDots: true, @@ -96,7 +96,7 @@ export const QRComponent: FC = (props) => { // crossOrigin: "anonymous", // }, backgroundOptions: { - color: "#2B2D30", + color: "#FFFF", }, }); const [showcopyText, setShowCopyText] = useState(false); @@ -123,7 +123,7 @@ export const QRComponent: FC = (props) => { }; return (
-

+

{!isShareQr ? "You can deposit crypto into your account via address" : null} @@ -133,13 +133,13 @@ export const QRComponent: FC = (props) => { {!isShareQr ? (

-
-
+
+
{trimAddress(walletAddress)}
{showcopyText && ( -

Copied!

+

Copied!

)}
) : null} diff --git a/utils/images/index.ts b/utils/images/index.ts index b1aae87..4456f93 100644 --- a/utils/images/index.ts +++ b/utils/images/index.ts @@ -15,10 +15,10 @@ import linkWhite from "../../public/assets/images/link_white.svg"; import linkedinBlue from "../../public/assets/images/linkedin_blue.svg"; import loadAvatar from "../../public/assets/images/load_avatar.png"; import logo from "../../public/assets/images/logo.svg"; -import logo2 from "../../public/assets/images/logo_clink.png"; +import logo2 from "../../public/assets/images/logo_micropay.png"; import logoutIcon from "../../public/assets/images/logout_icon.svg"; import qrWhite from "../../public/assets/images/qr_white.svg"; -import safeLogo from "../../public/assets/images/safe_logo.svg"; +import bicoLogo from "../../public/assets/images/biconomy_logo.png"; import shareBtnIcon from "../../public/assets/images/share_btn_icon.svg"; import shareBtnIconWhite from "../../public/assets/images/share_btn_icon_white.svg"; import tchest from "../../public/assets/images/tchest.png"; @@ -54,7 +54,7 @@ export type TImages = | "x" | "telegramBlue" | "linkedinBlue" - | "safeLogo" + | "bicoLogo" | "baseLogo" | "copyIconWhite" | "linkWhite" @@ -95,7 +95,7 @@ export const icons: Record = { x, linkedinBlue, telegramBlue, - safeLogo, + bicoLogo, baseLogo, copyIconWhite, linkWhite,