From 4f2147cd265e5bedd12f8237bd0e783248e9b766 Mon Sep 17 00:00:00 2001 From: Jubal Mabaquiao Date: Wed, 20 Nov 2024 12:24:09 +0800 Subject: [PATCH] fixed indents, spaces, extra semicolonts, etc (+1 squashed commit) --- app/ts/background/accessManagement.ts | 2 +- app/ts/background/background.ts | 8 +-- app/ts/background/iconHandler.ts | 2 +- app/ts/background/messageSending.ts | 10 +-- app/ts/background/sleeping.ts | 14 ++-- app/ts/background/windows/personalSign.ts | 2 +- app/ts/components/App.tsx | 12 ++-- app/ts/components/pages/AddNewAddress.tsx | 6 +- .../components/pages/ChangeActiveAddress.tsx | 2 +- app/ts/components/pages/ChangeChain.tsx | 4 +- .../components/pages/ConfirmTransaction.tsx | 43 ++++++------- app/ts/components/pages/Home.tsx | 40 ++++++------ app/ts/components/pages/InterceptorAccess.tsx | 14 ++-- .../pages/InterceptorAccessList.tsx | 2 +- app/ts/components/pages/WebsiteAccess.tsx | 64 +++++++++---------- .../SimulationSummary.tsx | 2 +- .../simulationExplaining/SwapTransactions.tsx | 4 +- .../simulationExplaining/Transactions.tsx | 10 +-- .../customExplainers/CatchAllVisualizer.tsx | 2 +- .../customExplainers/GnosisSafeVisualizer.tsx | 2 +- .../GovernanceVoteVisualizer.tsx | 4 +- .../customExplainers/OpenSeaOrder.tsx | 6 +- .../SimpleTokenApprovalVisualisation.tsx | 6 +- .../identifyTransaction.tsx | 1 + .../subcomponents/ConfigureRpcConnection.tsx | 6 +- app/ts/components/subcomponents/DinoSays.tsx | 4 +- .../subcomponents/DynamicScroller.tsx | 4 +- app/ts/components/subcomponents/Hint.tsx | 2 +- .../subcomponents/ParsedInputData.tsx | 2 +- .../components/subcomponents/PasteCatcher.tsx | 2 +- app/ts/components/subcomponents/Spinner.tsx | 2 +- app/ts/components/subcomponents/Tooltip.tsx | 2 +- app/ts/components/subcomponents/address.tsx | 2 +- app/ts/components/subcomponents/icons.tsx | 6 +- .../components/subcomponents/solidityType.tsx | 2 +- app/ts/components/ui-utils.tsx | 34 +++++----- .../services/EthereumClientService.ts | 6 +- .../services/EthereumSubscriptionService.ts | 6 +- .../SimulationModeEthereumClientService.ts | 8 +-- app/ts/types/JsonRpc-types.ts | 5 +- app/ts/types/ethSimulate-types.ts | 40 ++++++------ app/ts/utils/contentScriptsUpdating.ts | 4 +- app/ts/utils/errorDecoding.ts | 6 +- app/ts/utils/sleep.ts | 2 +- app/ts/utils/typescript.ts | 2 +- app/ts/utils/uniswap.ts | 8 +-- package.json | 3 +- 47 files changed, 211 insertions(+), 209 deletions(-) diff --git a/app/ts/background/accessManagement.ts b/app/ts/background/accessManagement.ts index 31b27924..5c6948fb 100644 --- a/app/ts/background/accessManagement.ts +++ b/app/ts/background/accessManagement.ts @@ -110,7 +110,7 @@ function getAddressesThatDoNotNeedIndividualAccesses(activeAddressEntries: Addre export async function setInterceptorDisabledForWebsite(website: Website, interceptorDisabled: boolean) { return await updateWebsiteAccess((previousWebsiteAccess) => { const index = previousWebsiteAccess.findIndex((entry) => entry.website.websiteOrigin === website.websiteOrigin) - const previousAccess = index !== -1 ? previousWebsiteAccess[index] : undefined; + const previousAccess = index !== -1 ? previousWebsiteAccess[index] : undefined if (previousAccess === undefined) return [...previousWebsiteAccess, { website, addressAccess: [], interceptorDisabled } ] return replaceElementInReadonlyArray(previousWebsiteAccess, index, { ...previousAccess, interceptorDisabled }) }) diff --git a/app/ts/background/background.ts b/app/ts/background/background.ts index 240885ab..b3cfc692 100644 --- a/app/ts/background/background.ts +++ b/app/ts/background/background.ts @@ -365,10 +365,10 @@ export async function refreshConfirmTransactionSimulation( ...transactionToSimulate.transaction, nonce: lastNonceFixed.preSimulationTransaction.signedTransaction.nonce, } } - : { error: { - ...transactionToSimulate.error, - decodedErrorMessage: decodeEthereumError(availableAbis, transactionToSimulate.error).reason - } } + : { error: { + ...transactionToSimulate.error, + decodedErrorMessage: decodeEthereumError(availableAbis, transactionToSimulate.error).reason + } } } } } diff --git a/app/ts/background/iconHandler.ts b/app/ts/background/iconHandler.ts index b4ca2da5..2bcbddd7 100644 --- a/app/ts/background/iconHandler.ts +++ b/app/ts/background/iconHandler.ts @@ -36,7 +36,7 @@ export async function updateExtensionIcon(websiteTabConnections: WebsiteTabConne return setIcon(ICON_ACCESS_DENIED, `The access to ${ activeAddress.name } for ${ websiteOrigin } has been DENIED!`) } if (settings.simulationMode) return setIcon(ICON_SIMULATING, 'The Interceptor simulates your sent transactions.') - if (settings.currentRpcNetwork.httpsRpc === undefined) return setIcon(ICON_SIGNING_NOT_SUPPORTED, `The Interceptor is disabled while it's on an unsupported network`) + if (settings.currentRpcNetwork.httpsRpc === undefined) return setIcon(ICON_SIGNING_NOT_SUPPORTED, 'The Interceptor is disabled while it\'s on an unsupported network') const tabState = await getTabState(tabId) return setIcon(ICON_SIGNING, `The Interceptor forwards your transactions to ${ getPrettySignerName(tabState.signerName) } once sent.`) } diff --git a/app/ts/background/messageSending.ts b/app/ts/background/messageSending.ts index 3ef5e2fe..cb170a08 100644 --- a/app/ts/background/messageSending.ts +++ b/app/ts/background/messageSending.ts @@ -1,8 +1,8 @@ -import { InterceptedRequestForward, InterceptorMessageToInpage, SubscriptionReplyOrCallBack } from "../types/interceptor-messages.js" -import { WebsiteSocket, checkAndPrintRuntimeLastError } from "../utils/requests.js" -import { WebsiteTabConnections } from "../types/user-interface-types.js" -import { websiteSocketToString } from "./backgroundUtils.js" -import { serialize } from "../types/wire-types.js" +import { InterceptedRequestForward, InterceptorMessageToInpage, SubscriptionReplyOrCallBack } from '../types/interceptor-messages.js' +import { WebsiteSocket, checkAndPrintRuntimeLastError } from '../utils/requests.js' +import { WebsiteTabConnections } from '../types/user-interface-types.js' +import { websiteSocketToString } from './backgroundUtils.js' +import { serialize } from '../types/wire-types.js' function postMessageToPortIfConnected(port: browser.runtime.Port, message: InterceptorMessageToInpage) { try { diff --git a/app/ts/background/sleeping.ts b/app/ts/background/sleeping.ts index 3b12b9f5..918d98a7 100644 --- a/app/ts/background/sleeping.ts +++ b/app/ts/background/sleeping.ts @@ -1,10 +1,10 @@ -import { EthereumClientService } from "../simulation/services/EthereumClientService.js" -import { TIME_BETWEEN_BLOCKS } from "../utils/constants.js" -import { modifyObject } from "../utils/typescript.js" -import { sendPopupMessageToOpenWindows } from "./backgroundUtils.js" -import { updateExtensionBadge } from "./iconHandler.js" -import { getInterceptorStartSleepingTimestamp, getRpcConnectionStatus, setInterceptorStartSleepingTimestamp, setRpcConnectionStatus } from "./storageVariables.js" -import { isConfirmTransactionFocused } from "./windows/confirmTransaction.js" +import { EthereumClientService } from '../simulation/services/EthereumClientService.js' +import { TIME_BETWEEN_BLOCKS } from '../utils/constants.js' +import { modifyObject } from '../utils/typescript.js' +import { sendPopupMessageToOpenWindows } from './backgroundUtils.js' +import { updateExtensionBadge } from './iconHandler.js' +import { getInterceptorStartSleepingTimestamp, getRpcConnectionStatus, setInterceptorStartSleepingTimestamp, setRpcConnectionStatus } from './storageVariables.js' +import { isConfirmTransactionFocused } from './windows/confirmTransaction.js' const updateConnectionStatusRetry = async (ethereumClientService: EthereumClientService) => { const status = await getRpcConnectionStatus() diff --git a/app/ts/background/windows/personalSign.ts b/app/ts/background/windows/personalSign.ts index 22197808..8fe5c8a1 100644 --- a/app/ts/background/windows/personalSign.ts +++ b/app/ts/background/windows/personalSign.ts @@ -19,7 +19,7 @@ async function addMetadataToOpenSeaOrder(ethereumClientService: EthereumClientSe offerer: await identifyAddress(ethereumClientService, requestAbortController, openSeaOrder.offerer), offer: await Promise.all(openSeaOrder.offer.map( async (offer) => ({ ...offer, token: await identifyAddress(ethereumClientService, requestAbortController, offer.token) }))), consideration: await Promise.all(openSeaOrder.consideration.map(async (offer) => ({ ...offer, token: await identifyAddress(ethereumClientService, requestAbortController, offer.token), recipient: await identifyAddress(ethereumClientService, requestAbortController, offer.recipient) }))) - } + } } export async function craftPersonalSignPopupMessage(ethereumClientService: EthereumClientService, requestAbortController: AbortController | undefined, signedMessageTransaction: SignedMessageTransaction, rpcNetwork: RpcNetwork): Promise { diff --git a/app/ts/components/App.tsx b/app/ts/components/App.tsx index e9d33ca7..ca0125c7 100644 --- a/app/ts/components/App.tsx +++ b/app/ts/components/App.tsx @@ -52,12 +52,12 @@ export function NetworkErrors({ rpcConnectionStatus } : NetworkErrorParams) { Unable to connect to { rpcConnectionStatus.rpcNetwork.name }. Retrying in . }/> - : <> } + : <> } { rpcConnectionStatus.latestBlock !== undefined && noNewBlockForOverTwoMins(rpcConnectionStatus) && rpcConnectionStatus.latestBlock !== null ? The connected RPC ({ rpcConnectionStatus.rpcNetwork.name }) seem to be stuck at block { rpcConnectionStatus.latestBlock.number } (occured on: { humanReadableDate(rpcConnectionStatus.latestBlock.timestamp) }). Retrying in . }/> - : <> } + : <> } } @@ -366,7 +366,7 @@ export function App() { close = { () => setAndSaveAppPage({ page: 'Home' }) } editEnsNamedHashWindowState = { appPage.state } /> - : <> } + : <> } { appPage.page === 'AccessList' ? - : <> } + : <> } { appPage.page === 'ChangeActiveAddress' ? - : <> } + : <> } { appPage.page === 'AddNewAddress' || appPage.page === 'ModifyAddress' ? setAndSaveAppPage({ page: 'Home' }) } activeAddress = { simulationMode ? activeSimulationAddress : activeSigningAddress } /> - : <> } + : <> } } diff --git a/app/ts/components/pages/AddNewAddress.tsx b/app/ts/components/pages/AddNewAddress.tsx index c860b22e..aaf94549 100644 --- a/app/ts/components/pages/AddNewAddress.tsx +++ b/app/ts/components/pages/AddNewAddress.tsx @@ -44,7 +44,7 @@ type NameInputParams = { function NameInput({ nameInput, setNameInput, disabled }: NameInputParams) { const ref = createRef() - useEffect(() => { ref.current?.focus() }, []) + useEffect(() => { ref.current?.focus() }, []) return () - useEffect(() => { ref.current?.focus() }, []) + useEffect(() => { ref.current?.focus() }, []) return

- Change Active Address + Change Active Address

@@ -542,7 +541,7 @@ export function ConfirmTransaction() { close = { () => { setModalState({ page: 'noModal' }) } } editEnsNamedHashWindowState = { modalState.state } /> - : <> } + : <> } { modalState.page === 'modifyAddress' ? { setModalState({ page: 'noModal' }) } } activeAddress = { currentPendingTransactionOrSignableMessage?.activeAddress } /> - : <> } + : <> } { param.simulationAndVisualisationResults.simulatedAndVisualizedTransactions.length === 0 && param.simulationAndVisualisationResults.visualizedPersonalSignRequests.length === 0 ?
- : <> -
- - { param.removedTransactionOrSignedMessages.length > 0 - ? <> - : +
+ - } -
- } + { param.removedTransactionOrSignedMessages.length > 0 + ? <> + : + } +
+ }
} @@ -284,7 +284,7 @@ export function Home(param: HomeParams) { return <> { rpcNetwork.httpsRpc === undefined ? - : <> } + : <> } void, accessRequest: PendingAccessRequest, changeActiveAddress: () => void, refreshActiveAddress: () => Promise }) { return <> { accessRequest.requestAccessToAddress === undefined ? -
-

- - <br/> - would like to connect to The Interceptor - </p> - </div> : + <div style = 'margin: 10px'> + <p className = 'title is-4' style = 'text-align: center; margin-top: 40px; margin-bottom: 40px;'> + <Title icon = { accessRequest.website.icon } title = { accessRequest.website.title === undefined ? accessRequest.website.websiteOrigin : accessRequest.website.title }/> + <br/> + would like to connect to The Interceptor + </p> + </div> : <> <div class = 'notification' style = 'background-color: var(--importance-box-color); color: var(--text-color)'> <p className = 'title is-3' style = 'text-align: center; margin-bottom: 10px;'> diff --git a/app/ts/components/pages/InterceptorAccessList.tsx b/app/ts/components/pages/InterceptorAccessList.tsx index 86ac6a25..86e5d2c4 100644 --- a/app/ts/components/pages/InterceptorAccessList.tsx +++ b/app/ts/components/pages/InterceptorAccessList.tsx @@ -227,7 +227,7 @@ export function InterceptorAccessList(param: InterceptorAccessListParams) { </div> </div> </li> - : <></> } + : <></> } { editableAccessList === undefined ? <></> : editableAccessList.map((access, accessListIndex) => ( <li> { access.removed ? <p style = 'color: var(--negative-color)' > { `Forgot ${ access.websiteAccess.website.websiteOrigin }. `}</p> : diff --git a/app/ts/components/pages/WebsiteAccess.tsx b/app/ts/components/pages/WebsiteAccess.tsx index f3dae282..8df05cad 100644 --- a/app/ts/components/pages/WebsiteAccess.tsx +++ b/app/ts/components/pages/WebsiteAccess.tsx @@ -40,7 +40,7 @@ const WebsiteAccessProvider = ({ children }: { children: ComponentChildren }) => retrieveWebsiteAccess({ query: searchQuery.value }) } - const listenForPopupMessages = () => { + const listenForPopupMessages = () => { const popupMessageListener = async (msg: unknown) => { const maybeParsed = MessageToPopup.safeParse(msg) if (!maybeParsed.success) return // not a message we are interested in @@ -177,8 +177,8 @@ const WebsiteSettingsList = () => { const selectedWebsiteOrigin = formData.get(URL_HASH_KEY)?.toString() if (!selectedWebsiteOrigin) { - window.location.href = window.location.pathname - return + window.location.href = window.location.pathname + return } window.location.href = `${ window.location.pathname }${ URL_HASH_PREFIX }${ selectedWebsiteOrigin }` @@ -276,7 +276,7 @@ const WebsiteSettingsDetail = () => { <form method = 'dialog' class = 'layout' onSubmit = { closeDetails }> <header style = { { paddingBlock: '1rem' } }> <button type = 'submit' class = 'btn btn--ghost' style = { { fontSize: '0.875rem', paddingInline: '0.5rem', paddingBlock: '0.125rem' } } autoFocus>← Show website access list</button> - <DetailsHeader websiteAccess = { selectedWebsiteAccess.value } /> + <DetailsHeader websiteAccess = { selectedWebsiteAccess.value } /> </header> <article> <NoAccessPrompt websiteAccess = { selectedWebsiteAccess } /> @@ -289,16 +289,16 @@ const WebsiteSettingsDetail = () => { } const DetailsHeader = ({ websiteAccess }: { websiteAccess: WebsiteAccess | undefined }) => { - if (!websiteAccess) return <></> - return ( - <div class = 'flexy flexy-sm' style = { { '--gap-x': '1rem', flex: 1 } }> - <figure><img width = '34' height = '34' src = { websiteAccess.website.icon } /></figure> - <div style = { { flex: 1 } }> - <h2 class = 'truncate' style = { { contain: 'inline-size', fontSize: 'clamp(1.25rem,2vw,2rem)', fontWeight: 600, color: 'var(--text-color)' } }>{ websiteAccess.website.title }</h2> - <p><span class = 'truncate' style = { { flex: 1, lineHeight: 1, color: 'var(--disabled-text-color)', direction: 'rtl', textAlign: 'left' } }>‎{ websiteAccess.website.websiteOrigin }</span></p> - </div> - </div> - ) + if (!websiteAccess) return <></> + return ( + <div class = 'flexy flexy-sm' style = { { '--gap-x': '1rem', flex: 1 } }> + <figure><img width = '34' height = '34' src = { websiteAccess.website.icon } /></figure> + <div style = { { flex: 1 } }> + <h2 class = 'truncate' style = { { contain: 'inline-size', fontSize: 'clamp(1.25rem,2vw,2rem)', fontWeight: 600, color: 'var(--text-color)' } }>{ websiteAccess.website.title }</h2> + <p><span class = 'truncate' style = { { flex: 1, lineHeight: 1, color: 'var(--disabled-text-color)', direction: 'rtl', textAlign: 'left' } }>‎{ websiteAccess.website.websiteOrigin }</span></p> + </div> + </div> + ) } const NoAccessPrompt = ({ websiteAccess }: { websiteAccess: Signal<WebsiteAccess | undefined> }) => { @@ -314,21 +314,21 @@ const NoAccessPrompt = ({ websiteAccess }: { websiteAccess: Signal<WebsiteAccess return ( <div style = { { color: 'var(--disabled-text-color)', border: '1px dashed', padding: '2rem', maxWidth: '50ch', textAlign: 'center', margin: '1rem auto' } }> - <h4 style = { { fontWeight: 600, color: 'var(--text-color)', lineHeight: '1.25', marginBottom: '0.5rem' } }>This website was denied access to The Interceptor.</h4> - <p style = { { fontSize: '0.875rem', lineHeight: 1.25, marginBottom: '1rem' } }>Interceptor will automatically deny further requests from <WebsiteCard website = { websiteAccess.value.website } /> for access while this preference is set.</p> - <Modal> - <Modal.Open class = 'btn btn--outline' style = { { display: 'inline-block' } }>Stop automatically denying access requests</Modal.Open> - <Modal.Dialog class = 'dialog' style = { { textAlign: 'center', color: 'var(--disabled-text-color)' } } onModalClose = { confirmOrRejectRemoval }> - <h2 style = { { fontWeight: 600, fontSize: '1.125rem', color: 'var(--text-color)', marginBlock: '1rem' } }>Stop automatically denying access requests</h2> - <p></p> - <p style = { { marginBlock: '0.5rem', lineHeight: 1.5 } }>After confirming this action, The Interceptor will stop automatically denying access requests from <WebsiteCard website = { websiteAccess.value.website } /> and will prompt you for permission the next time you try to connect.</p> - <div style = { { display: 'flex', flexWrap: 'wrap', columnGap: '1rem', justifyContent: 'center', marginBlock: '1rem' } }> - <Modal.Close class = 'btn btn--outline' value = 'reject'>Cancel</Modal.Close> - <Modal.Close class = 'btn btn--destructive' value = 'confirm'>Confirm</Modal.Close> - </div> - </Modal.Dialog> - </Modal> - </div> + <h4 style = { { fontWeight: 600, color: 'var(--text-color)', lineHeight: '1.25', marginBottom: '0.5rem' } }>This website was denied access to The Interceptor.</h4> + <p style = { { fontSize: '0.875rem', lineHeight: 1.25, marginBottom: '1rem' } }>Interceptor will automatically deny further requests from <WebsiteCard website = { websiteAccess.value.website } /> for access while this preference is set.</p> + <Modal> + <Modal.Open class = 'btn btn--outline' style = { { display: 'inline-block' } }>Stop automatically denying access requests</Modal.Open> + <Modal.Dialog class = 'dialog' style = { { textAlign: 'center', color: 'var(--disabled-text-color)' } } onModalClose = { confirmOrRejectRemoval }> + <h2 style = { { fontWeight: 600, fontSize: '1.125rem', color: 'var(--text-color)', marginBlock: '1rem' } }>Stop automatically denying access requests</h2> + <p></p> + <p style = { { marginBlock: '0.5rem', lineHeight: 1.5 } }>After confirming this action, The Interceptor will stop automatically denying access requests from <WebsiteCard website = { websiteAccess.value.website } /> and will prompt you for permission the next time you try to connect.</p> + <div style = { { display: 'flex', flexWrap: 'wrap', columnGap: '1rem', justifyContent: 'center', marginBlock: '1rem' } }> + <Modal.Close class = 'btn btn--outline' value = 'reject'>Cancel</Modal.Close> + <Modal.Close class = 'btn btn--destructive' value = 'confirm'>Confirm</Modal.Close> + </div> + </Modal.Dialog> + </Modal> + </div> ) } @@ -340,7 +340,7 @@ const AddressAccessList = ({ websiteAccess }: { websiteAccess: Signal<WebsiteAcc return ( <Collapsible summary = 'Address Access' defaultOpen> <p style = { { fontSize: '0.875rem', color: 'var(--text-color)', marginTop: '0.5rem' } }>Configure website access to these address(es). <button type = 'button' class = 'btn btn--ghost' style = { { fontSize: '0.875rem', border: '1px solid', width: '1rem', height: '1rem', padding: 0, borderRadius: '100%', display: 'inline-flex' } }>?</button></p> - <div style = { { display: 'grid', rowGap: '0.5rem', padding: '0.5rem 0' } }> + <div style = { { display: 'grid', rowGap: '0.5rem', padding: '0.5rem 0' } }> { access.addressAccess.map(addressAcces => <AddressAccessCard website = { access.website } addressAccess = { addressAcces } />) } </div> </Collapsible> @@ -439,7 +439,7 @@ const BlockRequestSetting = ({ websiteAccess }: { websiteAccess: Signal<WebsiteA </div> <aside> { requestBlockMode.value === 'block-all' ? ( - <button type='button' class = 'btn btn--primary' onClick = { () => setWebsiteExternalRequestBlocking(false) }><span style = { { whiteSpace: 'nowrap' } }>Unblock Requests</span></button> + <button type = 'button' class = 'btn btn--primary' onClick = { () => setWebsiteExternalRequestBlocking(false) }><span style = { { whiteSpace: 'nowrap' } }>Unblock Requests</span></button> ) : ( <Modal> <Modal.Open class = 'btn btn--destructive'><span style = { { whiteSpace: 'nowrap' } }>Block Requests</span></Modal.Open> @@ -487,7 +487,7 @@ const DisableProtectionSetting = ({ websiteAccess }: { websiteAccess: Signal<Web </div> <aside> { isInterceptorDisabled.value ? ( - <button type='button' class = 'btn btn--primary' onClick = { () => disableWebsiteProtection(false) }><span style = { { whiteSpace: 'nowrap' } }>Enable Protection</span></button> + <button type = 'button' class = 'btn btn--primary' onClick = { () => disableWebsiteProtection(false) }><span style = { { whiteSpace: 'nowrap' } }>Enable Protection</span></button> ) : ( <Modal> <Modal.Open class = 'btn btn--destructive'><span style = { { whiteSpace: 'nowrap' } }>Disable Protection</span></Modal.Open> diff --git a/app/ts/components/simulationExplaining/SimulationSummary.tsx b/app/ts/components/simulationExplaining/SimulationSummary.tsx index 4e1a92e8..ae855e3d 100644 --- a/app/ts/components/simulationExplaining/SimulationSummary.tsx +++ b/app/ts/components/simulationExplaining/SimulationSummary.tsx @@ -290,7 +290,7 @@ export function Erc721TokenIdApprovalChanges(param: Erc721TokenIdApprovalChanges </div> )) } </> - : <></> } </> + : <></> } </> } diff --git a/app/ts/components/simulationExplaining/SwapTransactions.tsx b/app/ts/components/simulationExplaining/SwapTransactions.tsx index 1e4cfbfe..21f1a517 100644 --- a/app/ts/components/simulationExplaining/SwapTransactions.tsx +++ b/app/ts/components/simulationExplaining/SwapTransactions.tsx @@ -273,7 +273,7 @@ function VisualizeSwapAsset({ swapAsset, renameAddressCallBack }: { swapAsset: S <TokenOrEthValue tokenEntry = { swapAsset.token } amount = { swapAsset.beforeAfterBalance?.beforeBalance } style = { balanceTextStyle } fontSize = 'normal'/> <p class = 'paragraph' style = { balanceTextStyle }> {'->'} </p> <TokenOrEthValue tokenEntry = { swapAsset.token } amount = { swapAsset.beforeAfterBalance?.afterBalance } style = { balanceTextStyle } fontSize = 'normal'/> - </div> : <></> + </div> : <></> } </span> </> @@ -318,7 +318,7 @@ function VisualizeSwapAsset({ swapAsset, renameAddressCallBack }: { swapAsset: S <TokenOrEthValue tokenEntry = { swapAsset.token } amount = { swapAsset.beforeAfterBalance?.beforeBalance } style = { balanceTextStyle } fontSize = 'normal'/> <p class = 'paragraph' style = { balanceTextStyle }> {'->'} </p> <TokenOrEthValue tokenEntry = { swapAsset.token } amount = { swapAsset.beforeAfterBalance?.afterBalance } style = { balanceTextStyle } fontSize = 'normal'/> - </div> : <></> + </div> : <></> } </span> </> diff --git a/app/ts/components/simulationExplaining/Transactions.tsx b/app/ts/components/simulationExplaining/Transactions.tsx index 6364ae54..ed4586d7 100644 --- a/app/ts/components/simulationExplaining/Transactions.tsx +++ b/app/ts/components/simulationExplaining/Transactions.tsx @@ -227,9 +227,9 @@ function TokenLogEvent(params: TokenLogEventParams ) { style = { style } fontSize = 'normal' /> - : <> { 'amount' in params.tokenVisualizerResult && params.tokenVisualizerResult.amount >= (2n ** 96n - 1n ) && params.tokenVisualizerResult.isApproval ? + : <> { 'amount' in params.tokenVisualizerResult && params.tokenVisualizerResult.amount >= (2n ** 96n - 1n ) && params.tokenVisualizerResult.isApproval ? <p class = 'ellipsis' style = { `color: ${ style.color }` }><b>ALL</b></p> - : + : 'amount' in params.tokenVisualizerResult ? <TokenAmount amount = { params.tokenVisualizerResult.amount } @@ -237,7 +237,7 @@ function TokenLogEvent(params: TokenLogEventParams ) { style = { style } fontSize = 'normal' /> - : <></> + : <></> } </> } </div> @@ -283,7 +283,7 @@ export function TokenLogAnalysis(param: LogAnalysisParams) { renameAddressCallBack = { param.renameAddressCallBack } /> )) - : + : tokenEvents.map((tokenEvent) => ( <TokenLogEvent tokenVisualizerResult = { tokenEvent } @@ -347,7 +347,7 @@ function NonTokenLogEvent(params: NonTokenLogEventParams) { return <> <p style = { textStyle } class = 'paragraph'> { `${ arg.paramName } = [` }</p> <StringElement text = { params.nonTokenLog.logInformation.fuses.join(', ') } /> - <p style = { textStyle } class = 'paragraph'> { `]` }</p> + <p style = { textStyle } class = 'paragraph'> { ']' }</p> </> } return <> diff --git a/app/ts/components/simulationExplaining/customExplainers/CatchAllVisualizer.tsx b/app/ts/components/simulationExplaining/customExplainers/CatchAllVisualizer.tsx index 0f8c1329..eb70b48f 100644 --- a/app/ts/components/simulationExplaining/customExplainers/CatchAllVisualizer.tsx +++ b/app/ts/components/simulationExplaining/customExplainers/CatchAllVisualizer.tsx @@ -51,7 +51,7 @@ function SendOrReceiveTokensImportanceBox(param: SendOrReceiveTokensImportanceBo style = { { color: param.textColor } } fontSize = 'normal' /> - : <></>} + : <></>} </div> <div class = 'log-cell'> <TokenSymbol diff --git a/app/ts/components/simulationExplaining/customExplainers/GnosisSafeVisualizer.tsx b/app/ts/components/simulationExplaining/customExplainers/GnosisSafeVisualizer.tsx index 1884dd67..821a40fe 100644 --- a/app/ts/components/simulationExplaining/customExplainers/GnosisSafeVisualizer.tsx +++ b/app/ts/components/simulationExplaining/customExplainers/GnosisSafeVisualizer.tsx @@ -102,7 +102,7 @@ export function GnosisSafeVisualizer(param: GnosisSafeVisualizerParams) { }, [param.activeAddress, param.gnosisSafeMessage.messageIdentifier]) if (activeAddress === undefined) return <></> - return <> + return <> <div class = 'notification transaction-importance-box'> <span class = 'log-table' style = 'justify-content: center; grid-template-columns: auto auto auto'> <div class = 'log-cell'> <p class = 'paragraph'>Approves Gnosis Safe</p> </div> diff --git a/app/ts/components/simulationExplaining/customExplainers/GovernanceVoteVisualizer.tsx b/app/ts/components/simulationExplaining/customExplainers/GovernanceVoteVisualizer.tsx index 33e5d90e..f2889bc2 100644 --- a/app/ts/components/simulationExplaining/customExplainers/GovernanceVoteVisualizer.tsx +++ b/app/ts/components/simulationExplaining/customExplainers/GovernanceVoteVisualizer.tsx @@ -97,12 +97,12 @@ const ShowSuccessOrFailure = ({ simulateExecutionReply, simTx, activeAddress, re > Simulate execution on a passing vote </button> - : <> <MissingAbi + : <> <MissingAbi errorMessage = { missingAbiText } addressBookEntry = { simTx.transaction.to } renameAddressCallBack = { renameAddressCallBack } /> - </> } + </> } </div> } if (simulateExecutionReply.data.success === false) { diff --git a/app/ts/components/simulationExplaining/customExplainers/OpenSeaOrder.tsx b/app/ts/components/simulationExplaining/customExplainers/OpenSeaOrder.tsx index 3b241eb2..4866f926 100644 --- a/app/ts/components/simulationExplaining/customExplainers/OpenSeaOrder.tsx +++ b/app/ts/components/simulationExplaining/customExplainers/OpenSeaOrder.tsx @@ -41,7 +41,7 @@ function SwapGrid(param: VisualizeOpenSeaAssetParams) { <div class = 'log-cell' style = 'justify-content: right;'> { param.orderOrConsideration.itemType === 'ERC721' || param.orderOrConsideration.itemType === 'ERC1155' ? <TokenOrEthSymbol { ...param.orderOrConsideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> - : <TokenOrEthSymbol { ...param.orderOrConsideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> } + : <TokenOrEthSymbol { ...param.orderOrConsideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> } </div> </span> </> @@ -61,7 +61,7 @@ function VisualizeOpenSeaAsset(param: VisualizeOpenSeaConsiderationAssetParams) <div class = 'log-cell' style = 'padding-right: 0.2em'> { param.consideration.itemType === 'ERC721' || param.consideration.itemType === 'ERC1155' ? <TokenOrEthSymbol { ...param.consideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> - : <TokenOrEthSymbol { ...param.consideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> } + : <TokenOrEthSymbol { ...param.consideration.token } rpcNetwork = { param.rpcNetwork } style = { tokenStyle } fontSize = 'big'/> } </div> <div class = 'log-cell' style = 'padding-right: 0.2em; padding-left: 0.2em'> { <ArrowIcon color = 'var(--text-color)' /> } @@ -118,4 +118,4 @@ export function OrderComponentsExtraDetails({ orderComponents, renameAddressCall <CellElement text = 'Zone hash: '/> <CellElement text = { bytes32String(orderComponents.zoneHash) }/> </> -} \ No newline at end of file +} diff --git a/app/ts/components/simulationExplaining/customExplainers/SimpleTokenApprovalVisualisation.tsx b/app/ts/components/simulationExplaining/customExplainers/SimpleTokenApprovalVisualisation.tsx index 62c2e130..37275ced 100644 --- a/app/ts/components/simulationExplaining/customExplainers/SimpleTokenApprovalVisualisation.tsx +++ b/app/ts/components/simulationExplaining/customExplainers/SimpleTokenApprovalVisualisation.tsx @@ -38,9 +38,9 @@ export function SimpleTokenApprovalVisualisation(params: SimpleTokenApprovalVisu style = { { 'font-weight': '500', color: textColor } } fontSize = 'big' /> - : <> { 'amount' in params.approval && params.approval.amount >= (2n ** 96n - 1n ) ? + : <> { 'amount' in params.approval && params.approval.amount >= (2n ** 96n - 1n ) ? <p class = 'ellipsis' style = { `color: ${ textColor }; font-size: 28px; font-weight: 500` }><b>ALL</b></p> - : + : 'amount' in params.approval ? <TokenAmount amount = { params.approval.amount } @@ -48,7 +48,7 @@ export function SimpleTokenApprovalVisualisation(params: SimpleTokenApprovalVisu style = { { 'font-weight': '500', color: textColor } } fontSize = 'big' /> - : <></> + : <></> } </> } </div> diff --git a/app/ts/components/simulationExplaining/identifyTransaction.tsx b/app/ts/components/simulationExplaining/identifyTransaction.tsx index 2e2b5bfc..8d876502 100644 --- a/app/ts/components/simulationExplaining/identifyTransaction.tsx +++ b/app/ts/components/simulationExplaining/identifyTransaction.tsx @@ -259,6 +259,7 @@ export function identifyTransaction(simTx: SimulatedAndVisualizedTransaction): I const edges = tokenResults.map((tokenResult) => ({ from: tokenResult.from.address, to: tokenResult.to.address, data: tokenResult.to, amount: !tokenResult.isApproval && tokenResult.type !== 'ERC721' ? tokenResult.amount : 1n })) const deadEnds = findDeadEnds(edges, simTx.transaction.from.address) + // eslint-disable-next-line no-inner-declarations function removeDuplicates(entries: AddressBookEntry[]): AddressBookEntry[] { const unique: Map<bigint, AddressBookEntry> = new Map() for (const entry of entries) { diff --git a/app/ts/components/subcomponents/ConfigureRpcConnection.tsx b/app/ts/components/subcomponents/ConfigureRpcConnection.tsx index 9b44773a..0815680a 100644 --- a/app/ts/components/subcomponents/ConfigureRpcConnection.tsx +++ b/app/ts/components/subcomponents/ConfigureRpcConnection.tsx @@ -66,13 +66,14 @@ const RpcQueryProvider = ({ children }: { children: ComponentChildren }) => { params: [ethSimulateV1ParamObject, 'latest'] }) + // eslint-disable-next-line no-inner-declarations function resultContainsLog(result: ReturnType<typeof EthSimulateV1Result.safeParse>) { return Boolean(result.success && result.value && result.value[0] && result.value[0].calls[0] && result.value[0].calls[0].status === 'success' && result.value[0].calls[0].logs.length === 1) } const parsedResult = EthSimulateV1Result.safeParse(serializedResult) - if (!resultContainsLog(parsedResult)) throw new Error(`The RPC server does not have a support for eth_simulateV1 (it doesn't return ETH logs). The Interceptor requires this feature to function.`) + if (!resultContainsLog(parsedResult)) throw new Error('The RPC server does not have a support for eth_simulateV1 (it doesn\'t return ETH logs). The Interceptor requires this feature to function.') } catch (error) { let errorMessage = 'RPC eth_simulateV1 validation error' console.warn(errorMessage, error) @@ -175,7 +176,7 @@ const ConfigureRpcForm = ({ defaultValues, onCancel, onSave, onRemove }: Configu if (defaultValues !== undefined) onRemove?.(defaultValues.httpsRpc) return - case 'save': + case 'save': { const formData = new FormData(event.target) const parsedData = parseRpcFormData(formData) @@ -185,6 +186,7 @@ const ConfigureRpcForm = ({ defaultValues, onCancel, onSave, onRemove }: Configu event.target.reset() return } + } } } } diff --git a/app/ts/components/subcomponents/DinoSays.tsx b/app/ts/components/subcomponents/DinoSays.tsx index 2c39b658..824d5efc 100644 --- a/app/ts/components/subcomponents/DinoSays.tsx +++ b/app/ts/components/subcomponents/DinoSays.tsx @@ -1,4 +1,4 @@ -import { XMarkIcon } from "./icons.js" +import { XMarkIcon } from './icons.js' export function DinoSays( { text } : { text: string }) { return <div class = 'media'> @@ -19,7 +19,7 @@ export function DinoSaysNotification( { text, close } : { text: string, close?: <button class = 'card-header-icon' aria-label = 'remove' onClick = { close }> <XMarkIcon /> </button> - : <></> } + : <></> } </div> </div> } diff --git a/app/ts/components/subcomponents/DynamicScroller.tsx b/app/ts/components/subcomponents/DynamicScroller.tsx index abb7dddf..a0f0afea 100644 --- a/app/ts/components/subcomponents/DynamicScroller.tsx +++ b/app/ts/components/subcomponents/DynamicScroller.tsx @@ -2,12 +2,12 @@ import { Signal, useComputed, useSignal, useSignalEffect } from '@preact/signals import { ComponentChild } from 'preact' import { useRef } from 'preact/hooks' -interface DynamicScrollerProps<T extends {}> { +interface DynamicScrollerProps<T extends object> { items: Signal<Readonly<T[]>> renderItem: (item: T) => ComponentChild } -export const DynamicScroller = <T extends {}>({ items, renderItem, }: DynamicScrollerProps<T>) => { +export const DynamicScroller = <T extends object>({ items, renderItem, }: DynamicScrollerProps<T>) => { const startIndex = useSignal(0) const maxItems = useSignal(0) const itemHeight = useSignal(0) diff --git a/app/ts/components/subcomponents/Hint.tsx b/app/ts/components/subcomponents/Hint.tsx index b861cdbc..87a3b99e 100644 --- a/app/ts/components/subcomponents/Hint.tsx +++ b/app/ts/components/subcomponents/Hint.tsx @@ -127,7 +127,7 @@ function Hint(props: HintProps) { }, [hint, props.clickPosition, hintWidth] ) return ( - <div class ='preact-hint' style = { dialogPosition }> + <div class = 'preact-hint' style = { dialogPosition }> <span class = 'preact-hint__content' ref = { hint }> { props.template ? props.template(props.content) : props.content } </span> diff --git a/app/ts/components/subcomponents/ParsedInputData.tsx b/app/ts/components/subcomponents/ParsedInputData.tsx index 8b96b2a4..251ce077 100644 --- a/app/ts/components/subcomponents/ParsedInputData.tsx +++ b/app/ts/components/subcomponents/ParsedInputData.tsx @@ -31,7 +31,7 @@ export function TransactionInput({ parsedInputData, input, to, addressMetaData, <div style = 'display: flex;'> { to !== undefined ? <> <p class = 'paragraph' style = 'color: var(--subtitle-text-color)'>No ABI available for </p> - <SmallAddress addressBookEntry = { to} renameAddressCallBack = { renameAddressCallBack } /> + <SmallAddress addressBookEntry = { to} renameAddressCallBack = { renameAddressCallBack } /> </> : <> <p class = 'paragraph' style = 'color: var(--subtitle-text-color)'>No ABI available</p> </> } diff --git a/app/ts/components/subcomponents/PasteCatcher.tsx b/app/ts/components/subcomponents/PasteCatcher.tsx index 418944a9..987314dd 100644 --- a/app/ts/components/subcomponents/PasteCatcher.tsx +++ b/app/ts/components/subcomponents/PasteCatcher.tsx @@ -1,7 +1,7 @@ import { useEffect } from 'preact/hooks' interface PasteProps { - onPaste: (text: string) => void, + onPaste: (text: string) => void, enabled: boolean, } diff --git a/app/ts/components/subcomponents/Spinner.tsx b/app/ts/components/subcomponents/Spinner.tsx index 83d678e7..1822839e 100644 --- a/app/ts/components/subcomponents/Spinner.tsx +++ b/app/ts/components/subcomponents/Spinner.tsx @@ -5,7 +5,7 @@ export function Spinner({ height, color } : { height: string, color?: string }) class = 'spinner' viewBox = '0 0 100 100' xmlns = 'http://www.w3.org/2000/svg'> - <circle cx = '50' cy = '50' r = '45' style = { { ...color !== undefined ? { stroke: color } : {} } }/> + <circle cx = '50' cy = '50' r = '45' style = { { ...color !== undefined ? { stroke: color } : {} } }/> </svg> ) } diff --git a/app/ts/components/subcomponents/Tooltip.tsx b/app/ts/components/subcomponents/Tooltip.tsx index 6315280f..55def2df 100644 --- a/app/ts/components/subcomponents/Tooltip.tsx +++ b/app/ts/components/subcomponents/Tooltip.tsx @@ -22,7 +22,7 @@ export function Tooltip({ config }: { config: Signal<TooltipConfig | undefined> }) return ( - <div ref = { popoverRef } class='tooltip' popover style = { { left: config.value?.x || 0, top: config.value?.y || 0 } }> + <div ref = { popoverRef } class = 'tooltip' popover style = { { left: config.value?.x || 0, top: config.value?.y || 0 } }> { config.value?.message || '' } </div> ) diff --git a/app/ts/components/subcomponents/address.tsx b/app/ts/components/subcomponents/address.tsx index 66ee9430..60324047 100644 --- a/app/ts/components/subcomponents/address.tsx +++ b/app/ts/components/subcomponents/address.tsx @@ -164,7 +164,7 @@ export function SmallAddress({ addressBookEntry, renameAddressCallBack, style }: return <></> } - return <InlineCard label={ addressBookEntry.name } copyValue = { addressString } icon={ generateIcon } onEditClicked={ () => renameAddressCallBack(addressBookEntry) } style = { style } /> + return <InlineCard label = { addressBookEntry.name } copyValue = { addressString } icon = { generateIcon } onEditClicked = { () => renameAddressCallBack(addressBookEntry) } style = { style } /> } export function WebsiteOriginText( { icon, websiteOrigin, title }: Website) { diff --git a/app/ts/components/subcomponents/icons.tsx b/app/ts/components/subcomponents/icons.tsx index 4799ae61..6e8cbead 100644 --- a/app/ts/components/subcomponents/icons.tsx +++ b/app/ts/components/subcomponents/icons.tsx @@ -45,12 +45,12 @@ export const TrashIcon = () => <svg width = '1em' height = '1em' viewBox = '0 0 <path fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M6.01632 1.62773C5.83827 1.80578 5.76002 2.00587 5.76002 2.14857V2.92571H10.24V2.14857C10.24 2.00587 10.1618 1.80578 9.98372 1.62773C9.80567 1.44968 9.60557 1.37143 9.46288 1.37143H6.53716C6.39446 1.37143 6.19437 1.44968 6.01632 1.62773ZM11.6114 2.92571V2.14857C11.6114 1.55984 11.324 1.02851 10.9535 0.657984C10.5829 0.287461 10.0516 0 9.46288 0H6.53716C5.94843 0 5.4171 0.287461 5.04657 0.657984C4.67605 1.02851 4.38859 1.55984 4.38859 2.14857V2.92571H1.41716C1.03845 2.92571 0.731445 3.23272 0.731445 3.61143C0.731445 3.99014 1.03845 4.29714 1.41716 4.29714H2.1943V13.8514C2.1943 14.4402 2.48176 14.9715 2.85229 15.342C3.22281 15.7125 3.75414 16 4.34287 16H11.6572C12.2459 16 12.7772 15.7125 13.1477 15.342C13.5183 14.9715 13.8057 14.4402 13.8057 13.8514V4.29714H14.5829C14.9616 4.29714 15.2686 3.99014 15.2686 3.61143C15.2686 3.23272 14.9616 2.92571 14.5829 2.92571H11.6114ZM3.56573 4.29714V13.8514C3.56573 13.9941 3.64398 14.1942 3.82203 14.3723C4.00008 14.5503 4.20018 14.6286 4.34287 14.6286H11.6572C11.7999 14.6286 12 14.5503 12.178 14.3723C12.3561 14.1942 12.4343 13.9941 12.4343 13.8514V4.29714H3.56573ZM6.53716 6.58286C6.91587 6.58286 7.22287 6.88986 7.22287 7.26857V11.6571C7.22287 12.0359 6.91587 12.3429 6.53716 12.3429C6.15845 12.3429 5.85145 12.0359 5.85145 11.6571V7.26857C5.85145 6.88986 6.15845 6.58286 6.53716 6.58286ZM9.46288 6.58286C9.84158 6.58286 10.1486 6.88986 10.1486 7.26857V11.6571C10.1486 12.0359 9.84158 12.3429 9.46288 12.3429C9.08417 12.3429 8.77716 12.0359 8.77716 11.6571V7.26857C8.77716 6.88986 9.08417 6.58286 9.46288 6.58286Z' fill = 'currentColor'/> </svg> -export const SearchIcon = () => <svg width='1em' height='1em' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'> - <path d='M15 15L11.4563 11.4563M11.4563 11.4563C12.0251 10.8876 12.4763 10.2123 12.7841 9.46918C13.0919 8.72604 13.2504 7.92955 13.2504 7.12518C13.2504 6.32081 13.0919 5.52431 12.7841 4.78117C12.4763 4.03803 12.0251 3.3628 11.4563 2.79402C10.8876 2.22525 10.2123 1.77407 9.46918 1.46625C8.72604 1.15843 7.92955 1 7.12518 1C6.32081 1 5.52431 1.15843 4.78117 1.46625C4.03803 1.77407 3.3628 2.22525 2.79402 2.79402C1.64533 3.94272 1 5.50068 1 7.12518C1 8.74967 1.64533 10.3076 2.79402 11.4563C3.94272 12.605 5.50068 13.2504 7.12518 13.2504C8.74967 13.2504 10.3076 12.605 11.4563 11.4563Z' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' /> +export const SearchIcon = () => <svg width = '1em' height = '1em' viewBox = '0 0 16 16' fill = 'none' xmlns = 'http://www.w3.org/2000/svg'> + <path d = 'M15 15L11.4563 11.4563M11.4563 11.4563C12.0251 10.8876 12.4763 10.2123 12.7841 9.46918C13.0919 8.72604 13.2504 7.92955 13.2504 7.12518C13.2504 6.32081 13.0919 5.52431 12.7841 4.78117C12.4763 4.03803 12.0251 3.3628 11.4563 2.79402C10.8876 2.22525 10.2123 1.77407 9.46918 1.46625C8.72604 1.15843 7.92955 1 7.12518 1C6.32081 1 5.52431 1.15843 4.78117 1.46625C4.03803 1.77407 3.3628 2.22525 2.79402 2.79402C1.64533 3.94272 1 5.50068 1 7.12518C1 8.74967 1.64533 10.3076 2.79402 11.4563C3.94272 12.605 5.50068 13.2504 7.12518 13.2504C8.74967 13.2504 10.3076 12.605 11.4563 11.4563Z' stroke = 'currentColor' stroke-width = '2' stroke-linecap = 'round' stroke-linejoin = 'round' /> </svg> export const CopyIcon = () => <svg width = '1em' height = '1em' viewBox = '0 0 24 24' fill = 'none' xmlns = 'http://www.w3.org/2000/svg'><path d = 'M14.188 4.813H4.813v9.375h.937V17H3.875A1.875 1.875 0 0 1 2 15.125V3.875C2 2.839 2.84 2 3.875 2h11.25C16.16 2 17 2.84 17 3.875V5.75h-2.812z' fill = 'currentColor' /><path fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M7 20V9a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2m12-1h-9v-9h9z' fill = 'currentColor' /></svg> export const EditIcon = () => <svg width = '1em' height = '1em' viewBox = '0 0 24 24' fill = 'none' xmlns = 'http://www.w3.org/2000/svg'><path fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M10 3H7v2H4a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h3v2h3zM7 8v8H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z' fill = 'currentColor' /><path d = 'M19 16h-7v3h8a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3h-8v3h7a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1' fill = 'currentColor' /></svg> -export const CheckIcon = () => <svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M22.08 6.04 8.478 20.163l-6.558-6.81 2.16-2.081 4.398 4.566L19.92 3.959z" fill="currentColor"/></svg> +export const CheckIcon = () => <svg width = '1em' height = '1em' viewBox = '0 0 24 24' fill = 'none' xmlns = 'http://www.w3.org/2000/svg'><path fill-rule = 'evenodd' clip-rule = 'evenodd' d = 'M22.08 6.04 8.478 20.163l-6.558-6.81 2.16-2.081 4.398 4.566L19.92 3.959z' fill = 'currentColor'/></svg> diff --git a/app/ts/components/subcomponents/solidityType.tsx b/app/ts/components/subcomponents/solidityType.tsx index aadd2905..4f747dc0 100644 --- a/app/ts/components/subcomponents/solidityType.tsx +++ b/app/ts/components/subcomponents/solidityType.tsx @@ -13,7 +13,7 @@ export const StringElement = ({ text }: { text: string }) => <p class = 'paragra const JsxArray = ( { array }: { array: JSX.Element[] }) => <> <StringElement text = '['/> - { insertBetweenElements(array, <p style = { textStyle } class = 'paragraph'>, </p>) } + { insertBetweenElements(array, <p style = { textStyle } class = 'paragraph'>, </p>) } <StringElement text = ']'/> </> diff --git a/app/ts/components/ui-utils.tsx b/app/ts/components/ui-utils.tsx index 5ce6e890..331804b4 100644 --- a/app/ts/components/ui-utils.tsx +++ b/app/ts/components/ui-utils.tsx @@ -11,25 +11,25 @@ import { checkAndThrowRuntimeLastError, safeGetTab, safeGetWindow, updateTabIfEx function assertIsNode(e: EventTarget | null): asserts e is Node { if (!e || !('nodeType' in e)) { - throw new Error('Node expected') - } + throw new Error('Node expected') + } } export function clickOutsideAlerter(ref: RefObject<HTMLDivElement>, callback: () => void) { useEffect(() => { function handleClickOutside({ target }: MouseEvent) { - assertIsNode(target); + assertIsNode(target) if (ref.current && !ref.current.contains(target)) { callback() } } - document.addEventListener('mousedown', handleClickOutside); + document.addEventListener('mousedown', handleClickOutside) return () => { - document.removeEventListener('mousedown', handleClickOutside); + document.removeEventListener('mousedown', handleClickOutside) } - }, [ref]); + }, [ref]) } export function getIssueWithAddressString(address: string): string | undefined { @@ -37,18 +37,18 @@ export function getIssueWithAddressString(address: string): string | undefined { if (address.length > 2 && address.substring(0, 2) !== '0x') { return 'Address does not contain 0x prefix.' } if (address.length < 42) return 'Address is too short.' - if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { - const checkSummedAddress = ethers.getAddress(address.toLowerCase()); + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + const checkSummedAddress = ethers.getAddress(address.toLowerCase()) - // It is a checksummed address with a bad checksum - if (checkSummedAddress !== address && address.toLowerCase() !== address) { - return `Bad address checksum, did you mean ${ checkSummedAddress } ?`; - } - } else { - return 'Address contains invalid characters.' - } + // It is a checksummed address with a bad checksum + if (checkSummedAddress !== address && address.toLowerCase() !== address) { + return `Bad address checksum, did you mean ${ checkSummedAddress } ?` + } + } else { + return 'Address contains invalid characters.' + } - return undefined + return undefined } export function upperCaseFirstCharacter(text: string) { @@ -64,7 +64,7 @@ export function convertNumberToCharacterRepresentationIfSmallEnough(num: number) function convertTens(num: number) { if (num < 10) return ones[num] if (num >= 10 && num < 20) return teens[num - 10] - return tens[Math.floor(num / 10)] + " " + ones[num % 10] + return tens[Math.floor(num / 10)] + ' ' + ones[num % 10] } if (num === 0) return 'zero' diff --git a/app/ts/simulation/services/EthereumClientService.ts b/app/ts/simulation/services/EthereumClientService.ts index 512e02eb..9621a6f5 100644 --- a/app/ts/simulation/services/EthereumClientService.ts +++ b/app/ts/simulation/services/EthereumClientService.ts @@ -21,14 +21,14 @@ export class EthereumClientService { private requestHandler private rpcEntry - constructor(requestHandler: IEthereumJSONRpcRequestHandler, newBlockAttemptCallback: (blockHeader: EthereumBlockHeader, ethereumClientService: EthereumClientService, isNewBlock: boolean) => Promise<void>, onErrorBlockCallback: (ethereumClientService: EthereumClientService) => Promise<void>, rpcEntry: RpcEntry) { + constructor(requestHandler: IEthereumJSONRpcRequestHandler, newBlockAttemptCallback: (blockHeader: EthereumBlockHeader, ethereumClientService: EthereumClientService, isNewBlock: boolean) => Promise<void>, onErrorBlockCallback: (ethereumClientService: EthereumClientService) => Promise<void>, rpcEntry: RpcEntry) { this.requestHandler = requestHandler this.newBlockAttemptCallback = newBlockAttemptCallback this.onErrorBlockCallback = onErrorBlockCallback this.rpcEntry = rpcEntry if (this.rpcEntry.httpsRpc !== requestHandler.rpcUrl) throw new Error('The URL values for rpcEntry and requestHander must match') - } + } public readonly getRpcEntry = () => this.rpcEntry @@ -194,7 +194,7 @@ export class EthereumClientService { validation: false, }, blockTag === parentBlock.number + 1n ? blockTag - 1n : blockTag - ] } as const + ] } as const const unvalidatedResult = await this.requestHandler.jsonRpcRequest(call) /* console.log('ethSimulateV1') diff --git a/app/ts/simulation/services/EthereumSubscriptionService.ts b/app/ts/simulation/services/EthereumSubscriptionService.ts index 1c538346..8255053e 100644 --- a/app/ts/simulation/services/EthereumSubscriptionService.ts +++ b/app/ts/simulation/services/EthereumSubscriptionService.ts @@ -76,9 +76,9 @@ export async function createEthereumSubscription(params: EthSubscribeParams, sub }) return subscriptionOrFilterId } - case 'logs': throw `Dapp requested for 'logs' subscription but it's not implemented` //TODO: implement - case 'newPendingTransactions': throw `Dapp requested for 'newPendingTransactions' subscription but it's not implemented` //TODO: implement - case 'syncing': throw `Dapp requested for 'syncing' subscription but it's not implemented` //TODO: implement + case 'logs': throw 'Dapp requested for \'logs\' subscription but it\'s not implemented' //TODO: implement + case 'newPendingTransactions': throw 'Dapp requested for \'newPendingTransactions\' subscription but it\'s not implemented' //TODO: implement + case 'syncing': throw 'Dapp requested for \'syncing\' subscription but it\'s not implemented' //TODO: implement } } diff --git a/app/ts/simulation/services/SimulationModeEthereumClientService.ts b/app/ts/simulation/services/SimulationModeEthereumClientService.ts index 0a2ad1e5..d5878496 100644 --- a/app/ts/simulation/services/SimulationModeEthereumClientService.ts +++ b/app/ts/simulation/services/SimulationModeEthereumClientService.ts @@ -88,9 +88,9 @@ export const getSimulatedStackOld = (simulationState: SimulationState | undefine ... ( transaction.ethSimulateV1CallResult.status === 'failure' ? { statusCode: transaction.ethSimulateV1CallResult.status, error: transaction.ethSimulateV1CallResult.error.message } : { - statusCode: transaction.ethSimulateV1CallResult.status, - events: transaction.ethSimulateV1CallResult.logs.map((x) => ({ loggersAddress: x.address, data: x.data, topics: x.topics })) - } + statusCode: transaction.ethSimulateV1CallResult.status, + events: transaction.ethSimulateV1CallResult.logs.map((x) => ({ loggersAddress: x.address, data: x.data, topics: x.topics })) + } ), returnValue: transaction.ethSimulateV1CallResult.returnData, maxPriorityFeePerGas, @@ -908,7 +908,7 @@ const getAddressesAndTokensIdsInteractedWithErc1155s = (events: readonly Ethereu } case 'TransferBatch': { for (const parsedLog of handleERC1155TransferBatch(log)) { - if (parsedLog.type !== "ERC1155") continue + if (parsedLog.type !== 'ERC1155') continue tokenOwners.push({ ...base, owner: parsedLog.from, tokenId: parsedLog.tokenId }) tokenOwners.push({ ...base, owner: parsedLog.to, tokenId: parsedLog.tokenId }) } diff --git a/app/ts/types/JsonRpc-types.ts b/app/ts/types/JsonRpc-types.ts index 050f3584..b5ae40f6 100644 --- a/app/ts/types/JsonRpc-types.ts +++ b/app/ts/types/JsonRpc-types.ts @@ -75,12 +75,11 @@ export const DappRequestTransaction = funtypes.ReadonlyPartial({ return areEqualUint8Arrays(dappRequestTransaction.input, dappRequestTransaction.data) } return true -}) -.withConstraint((x) => { +}).withConstraint((x) => { if (x.gasPrice !== undefined) return x.maxPriorityFeePerGas === undefined && x.maxFeePerGas === undefined if (x.maxPriorityFeePerGas !== undefined) return x.maxFeePerGas !== undefined && x.gasPrice === undefined if (x.maxFeePerGas !== undefined) return x.gasPrice === undefined /* && x.maxPriorityFeePerGas !== undefined*/ //Remix doesn't send "maxPriorityFeePerGas" with "maxFeePerGas" - return true + return true }) export type EthTransactionReceiptResponse = funtypes.Static<typeof EthTransactionReceiptResponse> diff --git a/app/ts/types/ethSimulate-types.ts b/app/ts/types/ethSimulate-types.ts index dac69c10..03ed6f6f 100644 --- a/app/ts/types/ethSimulate-types.ts +++ b/app/ts/types/ethSimulate-types.ts @@ -13,12 +13,12 @@ const AccountOverride = funtypes.ReadonlyPartial({ type BlockOverride = funtypes.Static<typeof BlockOverride> const BlockOverride = funtypes.Partial({ - number: EthereumQuantity, - prevRandao: EthereumQuantity, - time: EthereumTimestamp, - gasLimit: EthereumQuantitySmall, - feeRecipient: EthereumAddress, - baseFeePerGas: EthereumQuantity, + number: EthereumQuantity, + prevRandao: EthereumQuantity, + time: EthereumTimestamp, + gasLimit: EthereumQuantitySmall, + feeRecipient: EthereumAddress, + baseFeePerGas: EthereumQuantity, }).asReadonly() type BlockCall = funtypes.Static<typeof BlockCall> @@ -95,13 +95,13 @@ const CallResultLogs = funtypes.ReadonlyArray(CallResultLog) type EthSimulateCallResultFailure = funtypes.Static<typeof EthSimulateCallResultFailure> const EthSimulateCallResultFailure = funtypes.ReadonlyObject({ - status: funtypes.Literal('0x0').withParser(LiteralConverterParserFactory('0x0', 'failure' as const)), - returnData: EthereumData, - gasUsed: EthereumQuantitySmall, - error: funtypes.ReadonlyObject({ - code: funtypes.Number, - message: funtypes.String - }) + status: funtypes.Literal('0x0').withParser(LiteralConverterParserFactory('0x0', 'failure' as const)), + returnData: EthereumData, + gasUsed: EthereumQuantitySmall, + error: funtypes.ReadonlyObject({ + code: funtypes.Number, + message: funtypes.String + }) }) type EthSimulateCallResultSuccess = funtypes.Static<typeof EthSimulateCallResultSuccess> @@ -120,13 +120,13 @@ export const EthSimulateV1CallResults = funtypes.ReadonlyArray(EthSimulateV1Call type EthSimulateV1BlockResult = funtypes.Static<typeof EthSimulateV1BlockResult> const EthSimulateV1BlockResult = funtypes.ReadonlyObject({ - number: EthereumQuantity, - hash: EthereumBytes32, - timestamp: EthereumQuantity, - gasLimit: EthereumQuantitySmall, - gasUsed: EthereumQuantitySmall, - baseFeePerGas: EthereumQuantity, - calls: EthSimulateV1CallResults, + number: EthereumQuantity, + hash: EthereumBytes32, + timestamp: EthereumQuantity, + gasLimit: EthereumQuantitySmall, + gasUsed: EthereumQuantitySmall, + baseFeePerGas: EthereumQuantity, + calls: EthSimulateV1CallResults, }) export type EthSimulateV1Result = funtypes.Static<typeof EthSimulateV1Result> diff --git a/app/ts/utils/contentScriptsUpdating.ts b/app/ts/utils/contentScriptsUpdating.ts index d4216fa9..4fc2b20c 100644 --- a/app/ts/utils/contentScriptsUpdating.ts +++ b/app/ts/utils/contentScriptsUpdating.ts @@ -1,5 +1,5 @@ -import { getInterceptorDisabledSites, getSettings } from "../background/settings.js" -import { checkAndThrowRuntimeLastError } from "./requests.js" +import { getInterceptorDisabledSites, getSettings } from '../background/settings.js' +import { checkAndThrowRuntimeLastError } from './requests.js' const injectableSitesWildcard = ['file://*/*', 'http://*/*', 'https://*/*'] const injectableSitesRegexp = [/^file:\/\/.*/, /^http:\/\/.*/, /^https:\/\/.*/] diff --git a/app/ts/utils/errorDecoding.ts b/app/ts/utils/errorDecoding.ts index 2eb70270..f3adbf50 100644 --- a/app/ts/utils/errorDecoding.ts +++ b/app/ts/utils/errorDecoding.ts @@ -14,9 +14,9 @@ enum ErrorType { } type EthereumError = { - readonly code: number; - readonly message: string; - readonly data: string; + readonly code: number + readonly message: string + readonly data: string } type DecodedError = { diff --git a/app/ts/utils/sleep.ts b/app/ts/utils/sleep.ts index a953d44d..3daec556 100644 --- a/app/ts/utils/sleep.ts +++ b/app/ts/utils/sleep.ts @@ -1,3 +1,3 @@ export function sleep(milliseconds: number) { - return new Promise(resolve => setTimeout(resolve, milliseconds)) + return new Promise(resolve => setTimeout(resolve, milliseconds)) } diff --git a/app/ts/utils/typescript.ts b/app/ts/utils/typescript.ts index 0c48b89e..9189fa42 100644 --- a/app/ts/utils/typescript.ts +++ b/app/ts/utils/typescript.ts @@ -21,7 +21,7 @@ export function assertIsObject(maybe: unknown): asserts maybe is Object { } export function createGuard<T, U extends T>(check: (maybe: T) => U | undefined): (maybe: T) => maybe is U { - return (maybe: T): maybe is U => check(maybe) !== undefined + return (maybe: T): maybe is U => check(maybe) !== undefined } export function getWithDefault<Key, Value>(map: Map<Key, Value>, key: Key, defaultValue: Value) { diff --git a/app/ts/utils/uniswap.ts b/app/ts/utils/uniswap.ts index cf5249d2..73688b40 100644 --- a/app/ts/utils/uniswap.ts +++ b/app/ts/utils/uniswap.ts @@ -1,7 +1,7 @@ -import { AbiCoder, getCreate2Address, keccak256, solidityPacked, Interface } from "ethers" -import { EthereumAddress } from "../types/wire-types.js" -import { addressString } from "./bigint.js" -import { networkPriceSources } from "../background/settings.js" +import { AbiCoder, getCreate2Address, keccak256, solidityPacked, Interface } from 'ethers' +import { EthereumAddress } from '../types/wire-types.js' +import { addressString } from './bigint.js' +import { networkPriceSources } from '../background/settings.js' interface UniswapPools { token0IsQuote: boolean diff --git a/package.json b/package.json index 84138040..5a126c83 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "inpage": "tsc --project tsconfig-inpage.json", "cleanup": "npx knip@5.1.6 --fix", "cleanup:dryrun": "npx knip@5.1.6", - "lint": "npx @biomejs/biome@1.6.1 lint ." + "lint": "npx @biomejs/biome@1.6.1 lint .", + "format": "npx --prefix formatter eslint@9.15.0 --config formatter/eslint.config.js app/ts" }, "dependencies": { "@darkflorist/address-metadata": "0.10.0",