diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d6c9537..92d403a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,7 +11,7 @@ module.exports = { plugins: ['react-refresh'], rules: { 'react-refresh/only-export-components': [ - 'warn', + 'off', { allowConstantExport: true }, ], }, diff --git a/src/components/Apps/useQortalMessageListener.tsx b/src/components/Apps/useQortalMessageListener.tsx index e25c1bb..f8bd7a0 100644 --- a/src/components/Apps/useQortalMessageListener.tsx +++ b/src/components/Apps/useQortalMessageListener.tsx @@ -320,7 +320,7 @@ const UIQortalRequests = [ // Handle the obj.file if it exists and is a File instance if (obj.file) { - const fileId = "objFile_qortalfile"; + const fileId = Date.now() + "objFile_qortalfile"; // Store the file in IndexedDB const fileData = { @@ -334,7 +334,7 @@ const UIQortalRequests = [ delete obj.file; } if (obj.blob) { - const fileId = "objFile_qortalfile"; + const fileId = Date.now() + "objFile_qortalfile"; // Store the file in IndexedDB const fileData = { @@ -355,8 +355,8 @@ const UIQortalRequests = [ // Iterate through resources to find files and save them to IndexedDB for (let resource of (obj?.resources || [])) { if (resource.file) { - const fileId = resource.identifier + "_qortalfile"; - + const fileId = resource.identifier + Date.now() + "_qortalfile"; + // Store the file in IndexedDB const fileData = { id: fileId, @@ -484,17 +484,8 @@ isDOMContentLoaded: false event?.data?.action === 'ENCRYPT_DATA' || event?.data?.action === 'ENCRYPT_DATA_WITH_SHARING_KEY' || event?.data?.action === 'ENCRYPT_QORTAL_GROUP_DATA' ) { - let data; - try { - data = await storeFilesInIndexedDB(event.data); - } catch (error) { - console.error('Error storing files in IndexedDB:', error); - event.ports[0].postMessage({ - result: null, - error: 'Failed to store files in IndexedDB', - }); - return; - } + const data = event.data; + if (data) { sendMessageToRuntime( { action: event.data.action, type: 'qortalRequest', payload: data, isExtension: true }, diff --git a/src/components/Chat/TipTap.tsx b/src/components/Chat/TipTap.tsx index 4493482..929ab41 100644 --- a/src/components/Chat/TipTap.tsx +++ b/src/components/Chat/TipTap.tsx @@ -472,7 +472,12 @@ export default ({ return ( -
+
{ if (groups?.length === 0) return false; return !!groups?.find((item) => item?.groupId?.toString() === "694"); @@ -199,6 +198,7 @@ export const Minting = ({ } const data = await response.json(); setRewardShares(data); + return data } catch (error) {} }, []); @@ -338,6 +338,31 @@ export const Minting = ({ }); }, []); + const waitUntilRewardShareIsConfirmed = async (timeoutMs = 600000) => { + const pollingInterval = 30000; + const startTime = Date.now(); + + const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); + + while (Date.now() - startTime < timeoutMs) { + + const rewardShares = await getRewardShares(myAddress); + const findRewardShare = rewardShares?.find( + (item) => + item?.recipient === myAddress && item?.mintingAccount === myAddress + ); + + if (findRewardShare) { + return true; // Exit early if found + } + + + await sleep(pollingInterval); // Wait before the next poll + } + + throw new Error("Timeout waiting for reward share confirmation"); + }; + const startMinting = async () => { try { setIsLoading(true); @@ -352,12 +377,20 @@ export const Minting = ({ addMintingAccount(privateRewardShare); } else { await createRewardShare(accountInfo?.publicKey, myAddress); + setShowWaitDialog(true) + await waitUntilRewardShareIsConfirmed() + await showNext({ + message: '' + }) const privateRewardShare = await getRewardSharePrivateKey( accountInfo?.publicKey ); + setShowWaitDialog(false) addMintingAccount(privateRewardShare); + } } catch (error) { + setShowWaitDialog(false) setInfo({ type: "error", message: error?.message || "Unable to start minting", @@ -436,8 +469,8 @@ export const Minting = ({ const confirmReceiver = await getNameOrAddress(receiver); if (confirmReceiver.error) throw new Error("Invalid receiver address or name"); - const isInMinterGroup = await checkIfMinterGroup(confirmReceiver) - if(!isInMinterGroup) throw new Error('Account not in Minter Group') + const isInMinterGroup = await checkIfMinterGroup(confirmReceiver); + if (!isInMinterGroup) throw new Error("Account not in Minter Group"); const publicKey = await getPublicKeyFromAddress(confirmReceiver); const findRewardShare = rewardShares?.find( (item) => @@ -520,18 +553,8 @@ export const Minting = ({ return "" + countBlocksString; }; - const showAndCopySponsorshipKey = async (rs) => { - try { - const sponsorshipKey = await getRewardSharePrivateKey( - rs?.rewardSharePublicKey - ); - await showKey({ - message: sponsorshipKey, - }); - } catch (error) {} - }; - + return ( {"Manage your minting"} setIsOpenMinting(false)} - aria-label="close" - > - - + sx={{ + position: "absolute", + right: 8, + top: 8, + }} + color="inherit" + onClick={() => setIsOpenMinting(false)} + aria-label="close" + > + + Minting account: {handleNames(acct?.mintingAccount)} - {/* - Recipient account: {handleNames(acct?.recipientAccount)} - */} - {/* {acct?.mintingAccount !== accountInfo?.address && - acct?.recipientAccount === accountInfo?.address && - (accountInfo?.level || 0) > 0 && ( - - You have reached level 1+. Remove this minting key and then - click "Start Minting". - - )} */} - - - - - ))} - - - )} - - - Sponsor a new Minter - - {rewardShares?.filter((item) => item?.recipient !== myAddress) - ?.length > 0 ? ( - <> - - You are currently sponsoring one account. To sponsor - another account please remove the existing reward share. - - - ) : ( - <> - - Enter in the new Minter's address or name into the - input. Next, click on "Create reward share". If - successful, you will see a rewardshare key generated. - Copy the key and send it to your new Minter. - - - - setRewardSharePublicKey(e.target.value) - } - sx={{ - border: "0.5px solid var(--50-white, #FFFFFF80)", - padding: "0px 15px", - borderRadius: "5px", - height: "36px", - width: "350px", - maxWidth: "95%", - }} - placeholder="New minter's address or name" - inputProps={{ - "aria-label": "New minter's address or name", - fontSize: "14px", - fontWeight: 400, - }} - /> - - {rewardsharekey && ( - <> - - - - Click to copy the reward share key and share it with - your new minter - - - - - {rewardsharekey} - - - - )} - - )} - - - )} - {accountInfo?.level === 0 && !accountIsMinting && ( - <> - Become a minter! - - - - Ask a level 5+ minter to send you a minting key - - - Add the minting key in the input below and click "Add - minting key" - - - setMintingKey(e.target.value)} - sx={{ - border: "0.5px solid var(--50-white, #FFFFFF80)", - padding: "0px 15px", - borderRadius: "5px", - height: "36px", - width: "250px", - }} - placeholder="Add minting key" - inputProps={{ - "aria-label": "Add minting key", - fontSize: "14px", - fontWeight: 400, - }} - /> - - - - - )} - {accountInfo?.level === 0 && accountIsMinting && ( - - - You are currently on your way to level 1 - - - )} - - )} */} - {/* {isShow && ( + {showWaitDialog && ( - {"Copy sponsorship key"} + {isShowNext ? "Confirmed" : "Please Wait"} - - Click to copy the reward share key and share it with your new - minter + {!isShowNext && ( + + Confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds. - - - - {message?.message} - - + )} + {isShowNext && ( + + Rewardshare confirmed. Please click Next. + + )} + - - + + - )} */} + )}