diff --git a/src/components/Chat/ChatDirect.tsx b/src/components/Chat/ChatDirect.tsx index ca09959..6dbd748 100644 --- a/src/components/Chat/ChatDirect.tsx +++ b/src/components/Chat/ChatDirect.tsx @@ -605,7 +605,8 @@ const sendMessage = async ()=> { bottom: isFocusedParent ? '0px' : 'unset', top: isFocusedParent ? '0px' : 'unset', zIndex: isFocusedParent ? 11 : 'unset', - flexShrink: 0 + flexShrink: 0, + gap: '15px' }}>
{ + 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 +380,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", @@ -705,63 +741,7 @@ export const Minting = ({ )} - {txList?.filter( - (item) => - !item?.done && - (item?.type === "remove-rewardShare" || - item?.type === "add-rewardShare") - )?.length > 0 && ( - <> - - Ongoing transactions - - - {txList - ?.filter( - (item) => - !item.done && - (item?.type === "remove-rewardShare" || - item?.type === "add-rewardShare") - ) - ?.map((txItem) => ( - - {txItem?.type === "remove-rewardShare" && ( - Reward share being removed - )} - {txItem?.type === "add-rewardShare" && ( - Reward share being created - )} - - Recipient: {handleNames(txItem?.recipient)} - - - - - ))} - - - - )} {!isPartOfMintingGroup && ( )} + {showWaitDialog && ( + + + {isShowNext ? "Confirmed" : "Please Wait"} + + + {!isShowNext && ( + + Confirming creation of rewardshare on chain. Please be patient, this could take up to 90 seconds. + + )} + {isShowNext && ( + + Rewardshare confirmed. Please click Next. + + )} + + + + + + + + + + )} +