From 327432d97982dabe2837b4ba343ca781388317ed Mon Sep 17 00:00:00 2001 From: KetanKudikyal Date: Thu, 30 May 2024 00:44:34 +0530 Subject: [PATCH 01/17] fix: ripple image fix --- src/components/ui/avatar.tsx | 8 ++++---- src/components/ui/header.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx index beef2ab..ea1fcbf 100644 --- a/src/components/ui/avatar.tsx +++ b/src/components/ui/avatar.tsx @@ -1,7 +1,8 @@ 'use client'; -import RippleLoader from '@/components/ui/RippleLoader'; import Image from 'next/image'; -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; + +import RippleLoader from '@/components/ui/RippleLoader'; const Avatar = ({ userName, @@ -49,7 +50,7 @@ const Avatar = ({ className=' flex flex-col gap-1 items-center justify-center cursor-pointer' >
- {avatarLoading ? ( + {avatarLoading && teaseData.image !== "" ? ( ) : ( )}
-

{teaseData.name}.tease

diff --git a/src/components/ui/header.tsx b/src/components/ui/header.tsx index 7390199..dfaee84 100644 --- a/src/components/ui/header.tsx +++ b/src/components/ui/header.tsx @@ -227,7 +227,7 @@ const Header = ({ isOpen, setIsOpen }: props) => {
- {loggedIn && ( + {loggedIn && ipfsUrl && ( Date: Thu, 30 May 2024 03:24:05 +0530 Subject: [PATCH 02/17] feat: moonbeam integration --- src/components/ui/dialog.tsx | 193 +++++++++++++++++++++-------------- src/components/ui/header.tsx | 5 +- src/hooks/useGlobalStore.tsx | 6 ++ src/hooks/useWeb3auth.tsx | 102 +++++++++++------- src/lib/func.tsx | 42 ++++---- 5 files changed, 212 insertions(+), 136 deletions(-) diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index 0c092ad..0a7b6bb 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -12,13 +12,15 @@ import toast from 'react-hot-toast'; import useWeb3auth, { chainConfig } from '@/hooks/useWeb3auth'; import { - PurchaseSubsAvaGasslessBundle, approveNSubscribe, batchSubscribeFor, chainLinkAutomationSubscription, + checkBalances, checkUserBalanceWeb3Auth, + getTestFunds, getTestFundsWeb3Auth, mintingNft, + PurchaseSubsAvaGasslessBundle, } from '@/lib/func'; import { cn, toastStyles } from '@/lib/utils'; @@ -46,11 +48,13 @@ export default function MyModal({ modelId: number; setIsUnlocked: React.Dispatch>; }) { + const [chainIndex, setChainIndex] = useState(0) const [isOpen, setIsOpen] = useState(false); const [walletChosen, setWalletChosen] = useState(''); const [batchGaslessTrx, setBatchGaslessTrx] = useState(''); const [approvetrx, setApproveTrx] = useState(''); const [avalancheCrossTxn, setAvalancheCrossTxn] = useState(''); + const [moonbeamTx, setMoonbeamTxn] = useState(''); const [chainlinkCrossTxn, setChainLinkCrossTxn] = useState(''); const [testTokensHash, setTestTokensHash] = useState(''); const [nftTrx, setNftTrx] = useState(''); @@ -62,7 +66,7 @@ export default function MyModal({ provider: Authprovider, login, email, - } = useWeb3auth(); + } = useWeb3auth(chainIndex); function open() { // if (!loggedIn) { @@ -145,6 +149,9 @@ export default function MyModal({ }; const handleOperation = async (walletChosen: string) => { try { + if (!smartAccount) { + return + } if (walletChosen === 'Morph') { setProgress(10); const resp = await approveNSubscribe({ provider, priceInUsd: value }); @@ -154,24 +161,29 @@ export default function MyModal({ if (resp.fromAddr) { mintNft(resp.fromAddr); } - } else if (walletChosen === 'MoonBeam') { + } else if (walletChosen.toLowerCase() === 'moonbeam') { setProgress(10); + const _provider = await login(2) + if (!_provider) { + throw new Error("Provider not initialized") + } const resp = await batchSubscribeFor({ modelId: modelId, subscriptionId: subscriptionId, priceInUsd: value, - provider, + provider: _provider }); setBatchGaslessTrx(resp.dispatch); showMsgs(); if (resp.dispatch) { + const res = await chainLinkNotifier(); // mintNft(resp.fromAddr); setProgress(100); toast.success('Transaction successfull 🚀', toastStyles); - localStorage.setItem( - modelId.toString(), - (BigInt(1e18) * BigInt(modelId) + BigInt(subscriptionId)).toString() - ); + // localStorage.setItem( + // modelId.toString(), + // (BigInt(1e18) * BigInt(modelId) + BigInt(subscriptionId)).toString() + // ); setIsOpen(true); // setIsUnlocked(true); } @@ -186,6 +198,7 @@ export default function MyModal({ subscriptionId, value ); + const res = await chainLinkNotifier(); console.log(resp); setAvalancheCrossTxn(resp?.hash); showMsgs(); @@ -198,7 +211,6 @@ export default function MyModal({ subscriptionId, value ); - login(1); if (resp?.hash) { const res = await chainLinkNotifier(); // if (res) { @@ -214,18 +226,34 @@ export default function MyModal({ } }; const insufficiantBalance = async () => { - const amount = await checkUserBalanceWeb3Auth(smartAccount); - if (parseInt(amount.signerBalance) < value) { - setLoadingState( - `Insufficient Funds need ${ - value - parseInt(amount.signerBalance) - }💸 to subscribe` - ); + let amount = { + signerBalance: '0' + } + if (walletChosen) { + if (walletChosen.toLowerCase() === "moonbeam") { + const _provider = await login(2) + const signer = _provider.getSigner() + amount = await checkBalances(signer) + } else { + amount = await checkUserBalanceWeb3Auth(smartAccount); + } + if (parseInt(amount.signerBalance) < value) { + setLoadingState( + `Insufficient Funds need ${value - parseInt(amount.signerBalance) + }💸 to subscribe` + ); + } else { + setLoadingState("Confirm Payment") + } } }; React.useEffect(() => { insufficiantBalance(); - }, [walletChosen !== '']); + }, [walletChosen]); + + console.log(batchGaslessTrx, "btcs"); + + return ( <>
- )} + {walletChosen === 'Morph' && ( + + Nft Minted + + + + + + + + )} + + )} {testTokensHash && (
@@ -425,15 +450,18 @@ export default function MyModal({