diff --git a/package-lock.json b/package-lock.json index 3d0325c4..f968bf22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@emotion/styled": "^11.11.5", "@etherspot/data-utils": "^1.1.1", "@etherspot/modular-sdk": "^6.1.0", - "@etherspot/transaction-kit": "^1.1.0", + "@etherspot/transaction-kit": "^1.1.1", "@hypelab/sdk-react": "^1.0.4", "@lifi/sdk": "^3.6.8", "@lifi/types": "^9.2.0", @@ -3743,9 +3743,9 @@ } }, "node_modules/@etherspot/transaction-kit": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@etherspot/transaction-kit/-/transaction-kit-1.1.0.tgz", - "integrity": "sha512-cvwX/TX1HGWq9nG2Y5ipOHkxYHEDKH+ry6L0hbK8K4HL7KlsjnzGVcSW97YPs+gNtKmj8HPDqLGkjmqKdUgzZA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@etherspot/transaction-kit/-/transaction-kit-1.1.1.tgz", + "integrity": "sha512-AXr/c7RYBbi5g1LBU/Oktz8jNUpqxiQfd6jq3LTm+5bTRZomSLDRf4xjJHv8FrODQKXr297nW/kimuNbBwIFtQ==", "dependencies": { "@etherspot/data-utils": "^1.1.1", "@etherspot/eip1271-verification-util": "0.1.2", diff --git a/package.json b/package.json index 52791d64..fb4e8c52 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@emotion/styled": "^11.11.5", "@etherspot/data-utils": "^1.1.1", "@etherspot/modular-sdk": "^6.1.0", - "@etherspot/transaction-kit": "^1.1.0", + "@etherspot/transaction-kit": "^1.1.1", "@hypelab/sdk-react": "^1.0.4", "@lifi/sdk": "^3.6.8", "@lifi/types": "^9.2.0", diff --git a/src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap b/src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap index 723a3282..f8cfa40e 100644 --- a/src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap +++ b/src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap @@ -44,439 +44,49 @@ exports[` renders correctly and matches snapshot witho - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + `; diff --git a/src/components/BottomMenuModal/SendModal/SendModalBatchesTabView.tsx b/src/components/BottomMenuModal/SendModal/SendModalBatchesTabView.tsx index 9ef40219..64cba75a 100644 --- a/src/components/BottomMenuModal/SendModal/SendModalBatchesTabView.tsx +++ b/src/components/BottomMenuModal/SendModal/SendModalBatchesTabView.tsx @@ -123,64 +123,19 @@ const SendModalBatchesTabView = () => { transactionDebugLog('Preparing to send batch:', batchId); - const trySend = async ( - maxRetries = 3, - retryDelay = 2000 - ): Promise => { - for (let attempt = 1; attempt <= maxRetries; attempt++) { - try { - const startTime = performance.now(); - - const sent = await send([batchId]); - - const endTime = performance.now(); - const elapsedMs = endTime - startTime; - - transactionDebugLog( - `Time taken to send batch (ms): ${elapsedMs.toFixed(2)}` - ); - - transactionDebugLog( - `Transaction send batch succeeded on attempt ${attempt}:`, - sent - ); - - return sent; - } catch (error) { - const rawMessage = - typeof error === 'string' ? error : JSON.stringify(error); - transactionDebugLog(`Send attempt ${attempt} failed`, rawMessage); - - const shouldRetry = - rawMessage.includes( - 'maxFeePerGas must be greater or equal to baseFee' - ) || - rawMessage.includes('fee too low') || - rawMessage.includes('User op cannot be replaced'); - - if (!shouldRetry || attempt === maxRetries) { - throw error; - } - - transactionDebugLog( - `Retrying send() in ${retryDelay}ms due to gas-related error...` - ); - await new Promise((resolve) => { - setTimeout(resolve, retryDelay); - }); - } - } - - throw new Error('Retry logic exhausted without success'); - }; - let sent: ISentBatches[]; try { - sent = await trySend(); + sent = await send([batchId], { + retryOnFeeTooLow: true, + maxRetries: 3, + feeMultiplier: 1.2, // 20% increase per retry + }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { - const errorMes = error?.message || 'Unknown send error'; + const errorMes = + 'Something went wrong while sending the assets, please try again later. If the problem persists, contact the PillarX team for support.'; console.warn('Final send() failed after retries:', errorMes); setErrorMessage((prev) => ({ ...prev, [chainId]: errorMes })); setIsSending((prev) => ({ ...prev, [chainId]: false })); @@ -212,7 +167,8 @@ const SendModalBatchesTabView = () => { if (estimationErrorMessage) { setErrorMessage((prev) => ({ ...prev, - [chainId]: estimationErrorMessage, + [chainId]: + 'Something went wrong while estimating the asset transfer. Please try again later. If the problem persists, contact the PillarX team for support.', })); setIsSending((prev) => ({ ...prev, [chainId]: false })); return; @@ -220,7 +176,11 @@ const SendModalBatchesTabView = () => { const sendingErrorMessage = sent?.[0]?.sentBatches?.[0]?.errorMessage; if (sendingErrorMessage) { - setErrorMessage((prev) => ({ ...prev, [chainId]: sendingErrorMessage })); + setErrorMessage((prev) => ({ + ...prev, + [chainId]: + 'Something went wrong while sending the assets, please try again later. If the problem persists, contact the PillarX team for support.', + })); setIsSending((prev) => ({ ...prev, [chainId]: false })); return; } diff --git a/src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx b/src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx index 7374c706..854712be 100644 --- a/src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx +++ b/src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx @@ -294,64 +294,19 @@ const SendModalTokensTabView = ({ payload }: { payload?: SendModalData }) => { transactionDebugLog('Preparing to send transaction'); - const trySend = async ( - maxRetries = 3, - retryDelay = 2000 - ): Promise => { - for (let attempt = 1; attempt <= maxRetries; attempt++) { - try { - const startTime = performance.now(); - - const sent = await send(); - - const endTime = performance.now(); - const elapsedMs = endTime - startTime; - - transactionDebugLog( - `Time taken to send transaction (ms): ${elapsedMs.toFixed(2)}` - ); - - transactionDebugLog( - `Transaction send succeeded on attempt ${attempt}:`, - sent - ); - - return sent; - } catch (error) { - const rawMessage = - typeof error === 'string' ? error : JSON.stringify(error); - transactionDebugLog(`Send attempt ${attempt} failed`, rawMessage); - - const shouldRetry = - rawMessage.includes( - 'maxFeePerGas must be greater or equal to baseFee' - ) || - rawMessage.includes('fee too low') || - rawMessage.includes('User op cannot be replaced'); - - if (!shouldRetry || attempt === maxRetries) { - throw error; - } - - transactionDebugLog( - `Retrying send() in ${retryDelay}ms due to gas-related error...` - ); - await new Promise((resolve) => { - setTimeout(resolve, retryDelay); - }); - } - } - throw new Error('Retry logic exhausted without success'); - }; - let sent: ISentBatches[]; try { - sent = await trySend(); + sent = await send(undefined, { + retryOnFeeTooLow: true, + maxRetries: 3, + feeMultiplier: 1.2, // 20% increase per retry + }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { - const errorMes = error?.message || 'Unknown send error'; - console.warn('Final send() failed after retries:', errorMes); + const errorMes = + 'Something went wrong while sending the assets, please try again later. If the problem persists, contact the PillarX team for support.'; setErrorMessage(errorMes); setIsSending(false); return; @@ -381,7 +336,9 @@ const SendModalTokensTabView = ({ payload }: { payload?: SendModalData }) => { const estimationErrorMessage = sent?.[0]?.estimatedBatches?.[0]?.errorMessage; if (estimationErrorMessage) { - setErrorMessage(estimationErrorMessage); + setErrorMessage( + 'Something went wrong while estimating the asset transfer. Please try again later. If the problem persists, contact the PillarX team for support.' + ); setIsSending(false); return; } @@ -412,7 +369,9 @@ const SendModalTokensTabView = ({ payload }: { payload?: SendModalData }) => { const sendingErrorMessage = sent?.[0]?.sentBatches?.[0]?.errorMessage; if (sendingErrorMessage) { - setErrorMessage(sendingErrorMessage); + setErrorMessage( + 'Something went wrong while sending the assets, please try again later. If the problem persists, contact the PillarX team for support.' + ); setIsSending(false); return; }