From 01d27eea75398ebbe976774dbde6616611edad2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Pastor=20Agust=C3=AD?= Date: Mon, 5 Aug 2024 20:12:31 +0200 Subject: [PATCH] change map by for and try to avoid pass step if the address is not set (#38) Co-authored-by: escottalexander --- .../useRecoveryProcess.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/nextjs/hooks/flashbotRecoveryBundle/useRecoveryProcess.ts b/packages/nextjs/hooks/flashbotRecoveryBundle/useRecoveryProcess.ts index 7d37bfc..dc43a65 100644 --- a/packages/nextjs/hooks/flashbotRecoveryBundle/useRecoveryProcess.ts +++ b/packages/nextjs/hooks/flashbotRecoveryBundle/useRecoveryProcess.ts @@ -77,7 +77,7 @@ export const useRecoveryProcess = () => { if (!address) { setStepActive(RecoveryProcessStatus.NO_CONNECTED_ACCOUNT); return false; - } else if (address != safeAddress || safeAddress == DUMMY_ADDRESS) { + } else if (address != safeAddress || safeAddress == DUMMY_ADDRESS || address == DUMMY_ADDRESS) { setStepActive(RecoveryProcessStatus.NO_SAFE_ACCOUNT); return false; } @@ -260,10 +260,12 @@ export const useRecoveryProcess = () => { safeAddress: string; hackedAddress: string; }): RecoveryTx[] => { - return transactions.map(item => { + const result: RecoveryTx[] = [] + for (const item of transactions) { + let newTX:RecoveryTx = {...item} if (item.type === "erc20") { const data = item as ERC20Tx; - const newErc20tx: ERC20Tx = { + newTX= { type: data.type, info: data.info, symbol: data.symbol, @@ -277,12 +279,11 @@ export const useRecoveryProcess = () => { ]) as `0x${string}`, }, }; - return newErc20tx; } if (item.type === "erc721") { const data = item as ERC721Tx; - const newErc721Tx: ERC721Tx = { + newTX= { type: data.type, info: data.info, symbol: data.symbol, @@ -297,12 +298,11 @@ export const useRecoveryProcess = () => { ]) as `0x${string}`, }, }; - return newErc721Tx; } if (item.type === "erc1155") { const data = item as ERC1155Tx; - const newErc1155Tx: ERC1155Tx = { + newTX= { type: data.type, info: data.info, uri: data.uri, @@ -320,11 +320,10 @@ export const useRecoveryProcess = () => { ]) as `0x${string}`, }, }; - return newErc1155Tx; } - - return item; - }); + result.push(newTX) + } + return result; }; const startRecoveryProcess = async ({