Skip to content

Commit

Permalink
fixed indents, spaces, extra semicolonts, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jubalm committed Nov 20, 2024
1 parent 740fcd7 commit 0d0a741
Show file tree
Hide file tree
Showing 47 changed files with 203 additions and 3,352 deletions.
2 changes: 1 addition & 1 deletion app/ts/background/accessManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
Expand Down
8 changes: 4 additions & 4 deletions app/ts/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
} }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/ts/background/iconHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
}
Expand Down
10 changes: 5 additions & 5 deletions app/ts/background/messageSending.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions app/ts/background/sleeping.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 1 addition & 1 deletion app/ts/background/windows/personalSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<VisualizedPersonalSignRequest> {
Expand Down
12 changes: 6 additions & 6 deletions app/ts/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export function NetworkErrors({ rpcConnectionStatus } : NetworkErrorParams) {
<ErrorComponent warning = { true } text = {
<>Unable to connect to { rpcConnectionStatus.rpcNetwork.name }. Retrying in <SomeTimeAgo priorTimestamp = { nextConnectionAttempt } countBackwards = { true }/> .</>
}/>
: <></> }
: <></> }
{ rpcConnectionStatus.latestBlock !== undefined && noNewBlockForOverTwoMins(rpcConnectionStatus) && rpcConnectionStatus.latestBlock !== null ?
<ErrorComponent warning = { true } text = {
<>The connected RPC ({ rpcConnectionStatus.rpcNetwork.name }) seem to be stuck at block { rpcConnectionStatus.latestBlock.number } (occured on: { humanReadableDate(rpcConnectionStatus.latestBlock.timestamp) }). Retrying in <SomeTimeAgo priorTimestamp = { nextConnectionAttempt } countBackwards = { true }/>.</>
}/>
: <></> }
: <></> }
</>
}

Expand Down Expand Up @@ -366,7 +366,7 @@ export function App() {
close = { () => setAndSaveAppPage({ page: 'Home' }) }
editEnsNamedHashWindowState = { appPage.state }
/>
: <></> }
: <></> }
{ appPage.page === 'AccessList' ?
<InterceptorAccessList
setAndSaveAppPage = { setAndSaveAppPage }
Expand All @@ -375,7 +375,7 @@ export function App() {
websiteAccessAddressMetadata = { websiteAccessAddressMetadata }
renameAddressCallBack = { renameAddressCallBack }
/>
: <></> }
: <></> }
{ appPage.page === 'ChangeActiveAddress' ?
<ChangeActiveAddress
setActiveAddressAndInformAboutIt = { setActiveAddressAndInformAboutIt }
Expand All @@ -386,15 +386,15 @@ export function App() {
renameAddressCallBack = { renameAddressCallBack }
addNewAddress = { addNewAddress }
/>
: <></> }
: <></> }
{ appPage.page === 'AddNewAddress' || appPage.page === 'ModifyAddress' ?
<AddNewAddress
setActiveAddressAndInformAboutIt = { setActiveAddressAndInformAboutIt }
modifyAddressWindowState = { appPage.state }
close = { () => setAndSaveAppPage({ page: 'Home' }) }
activeAddress = { simulationMode ? activeSimulationAddress : activeSigningAddress }
/>
: <></> }
: <></> }
</div>
</> }
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/ts/components/pages/AddNewAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type NameInputParams = {

function NameInput({ nameInput, setNameInput, disabled }: NameInputParams) {
const ref = createRef<HTMLInputElement>()
useEffect(() => { ref.current?.focus() }, [])
useEffect(() => { ref.current?.focus() }, [])
return <input
className = 'input title is-5 is-spaced'
type = 'text'
Expand Down Expand Up @@ -103,7 +103,7 @@ type AbiInputParams = {

function AbiInput({ abiInput, setAbiInput, disabled }: AbiInputParams) {
const ref = createRef<HTMLInputElement>()
useEffect(() => { ref.current?.focus() }, [])
useEffect(() => { ref.current?.focus() }, [])
return <input
className = 'input is-spaced'
type = 'text'
Expand Down Expand Up @@ -232,7 +232,7 @@ export function AddNewAddress(param: AddAddressParam) {
askForAddressAccess: incompleteAddressBookEntry.askForAddressAccess,
entrySource: 'User' as const,
}

switch(incompleteAddressBookEntry.type) {
case 'ERC721': {
if (incompleteAddressBookEntry.symbol === undefined) return undefined
Expand Down
2 changes: 1 addition & 1 deletion app/ts/components/pages/ChangeActiveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function ChangeActiveAddress(param: ChangeActiveAddressParam) {
</div>
<div class = 'card-header-title'>
<p className = 'paragraph'>
Change Active Address
Change Active Address
</p>
</div>
<button class = 'card-header-icon' aria-label = 'close' onClick = { param.close }>
Expand Down
4 changes: 2 additions & 2 deletions app/ts/components/pages/ChangeChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ export function ChangeChain() {
</p>
{ chainChangeData.rpcNetwork.httpsRpc === undefined && chainChangeData.simulationMode ?
<ErrorComponent text = { 'This chain is not supported by The Interceptor. If you want to use this chain anyway. Select Signing mode instead of Simulation mode and attempt to change the chain again. You will then be able to disable The Interceptor and send transactions without its protection.' }/>
: <></> }
: <></> }
{ chainChangeData.rpcNetwork.httpsRpc === undefined && !chainChangeData.simulationMode ?
<ErrorCheckBox
text = { 'This chain is not supported by The Interceptor. Would you like to disable The Interceptor and attempt to connect anyway?' }
checked = { connectAnyway }
onInput = { setConnectAnyway }
/>
: <></> }
: <></> }
</div>
</div>
<div style = 'overflow: auto; display: flex; justify-content: space-around; width: 100%; height: 40px;'>
Expand Down
42 changes: 21 additions & 21 deletions app/ts/components/pages/ConfirmTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@ function Buttons({ currentPendingTransactionOrSignableMessage, reject, approve,
<button className = 'button is-primary button-overflow dialog-button-right' onClick = { approve } disabled = { confirmDisabled }>
{ currentPendingTransactionOrSignableMessage.approvalStatus.status === 'WaitingForSigner' ? <>
<span> <Spinner height = '1em' color = 'var(--text-color)' /> Waiting for <SignersLogoName signerName = { signerName } /> </span>
</> : <>
{ currentPendingTransactionOrSignableMessage.simulationMode
? `${ identified.simulationAction }!`
: <SignerLogoText signerName = { signerName } text = { identified.signingAction } />
}
</>
</> : <>
{ currentPendingTransactionOrSignableMessage.simulationMode
? `${ identified.simulationAction }!`
: <SignerLogoText signerName = { signerName } text = { identified.signingAction } />
}
</>
}
</button>
</div>
Expand Down Expand Up @@ -541,15 +541,15 @@ export function ConfirmTransaction() {
close = { () => { setModalState({ page: 'noModal' }) } }
editEnsNamedHashWindowState = { modalState.state }
/>
: <></> }
: <></> }
{ modalState.page === 'modifyAddress' ?
<AddNewAddress
setActiveAddressAndInformAboutIt = { undefined }
modifyAddressWindowState = { modalState.state }
close = { () => { setModalState({ page: 'noModal' }) } }
activeAddress = { currentPendingTransactionOrSignableMessage?.activeAddress }
/>
: <></> }
: <></> }
</div>
<div class = 'block popup-block popup-block-scroll' style = 'padding: 0px'>
<UnexpectedError close = { clearUnexpectedError } unexpectedError = { unexpectedError }/>
Expand All @@ -574,15 +574,15 @@ export function ConfirmTransaction() {
close = { () => { setModalState({ page: 'noModal' }) } }
editEnsNamedHashWindowState = { modalState.state }
/>
: <></> }
: <></> }
{ modalState.page === 'modifyAddress' ?
<AddNewAddress
setActiveAddressAndInformAboutIt = { undefined }
modifyAddressWindowState = { modalState.state }
close = { () => { setModalState({ page: 'noModal' }) } }
activeAddress = { currentPendingTransactionOrSignableMessage?.activeAddress }
/>
: <></> }
: <></> }
</div>
<div class = 'block popup-block popup-block-scroll' style = 'padding: 0px'>
<div style = 'position: sticky; top: 0; z-index:1'>
Expand All @@ -596,8 +596,8 @@ export function ConfirmTransaction() {
{ currentPendingTransactionOrSignableMessage.originalRequestParameters.method === 'eth_sendRawTransaction' && currentPendingTransactionOrSignableMessage.type === 'Transaction'
? <DinoSaysNotification
text = { `This transaction is signed already. No extra signing required to forward it to ${ currentPendingTransactionOrSignableMessage.transactionOrMessageCreationStatus !== 'Simulated' || currentPendingTransactionOrSignableMessage.simulationResults.statusCode === 'failed' ?
'network' :
currentPendingTransactionOrSignableMessage.simulationResults.data.simulationState.rpcNetwork.name }.` }
'network' :
currentPendingTransactionOrSignableMessage.simulationResults.data.simulationState.rpcNetwork.name }.` }
close = { () => setPendingTransactionAddedNotification(false)}
/>
: <></>
Expand All @@ -622,15 +622,15 @@ export function ConfirmTransaction() {
rpcConnectionStatus = { rpcConnectionStatus }
numberOfUnderTransactions = { underTransactions.length }
/>
: <>
<SignatureCard
visualizedPersonalSignRequest = { currentPendingTransactionOrSignableMessage.visualizedPersonalSignRequest }
renameAddressCallBack = { renameAddressCallBack }
removeTransactionOrSignedMessage = { undefined }
numberOfUnderTransactions = { underTransactions.length }
editEnsNamedHashCallBack = { editEnsNamedHashCallBack }
/>
</> }
: <>
<SignatureCard
visualizedPersonalSignRequest = { currentPendingTransactionOrSignableMessage.visualizedPersonalSignRequest }
renameAddressCallBack = { renameAddressCallBack }
removeTransactionOrSignedMessage = { undefined }
numberOfUnderTransactions = { underTransactions.length }
editEnsNamedHashCallBack = { editEnsNamedHashCallBack }
/>
</> }
</div>
<nav class = 'window-footer popup-button-row' style = 'position: sticky; bottom: 0; width: 100%;'>
<CheckBoxes currentPendingTransactionOrSignableMessage = { currentPendingTransactionOrSignableMessage } forceSend = { forceSend } setForceSend = { (enabled: boolean) => setForceSend(enabled) }/>
Expand Down
40 changes: 20 additions & 20 deletions app/ts/components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,28 @@ function SimulationResults(param: SimulationStateParam) {
</div>
{ param.simulationAndVisualisationResults.simulatedAndVisualizedTransactions.length === 0 && param.simulationAndVisualisationResults.visualizedPersonalSignRequests.length === 0 ?
<div style = 'padding: 10px'><DinoSays text = { 'Give me some transactions to munch on!' } /></div>
: <>
<div class = { param.simulationResultState === 'invalid' || param.simulationUpdatingState === 'failed' ? 'blur' : '' }>
<TransactionsAndSignedMessages
simulationAndVisualisationResults = { param.simulationAndVisualisationResults }
removeTransactionOrSignedMessage = { param.removeTransactionOrSignedMessage }
activeAddress = { param.simulationAndVisualisationResults.activeAddress }
renameAddressCallBack = { param.renameAddressCallBack }
editEnsNamedHashCallBack = { param.editEnsNamedHashCallBack }
removedTransactionOrSignedMessages = { param.removedTransactionOrSignedMessages }
addressMetaData = { param.simulationAndVisualisationResults.addressBookEntries }
/>
{ param.removedTransactionOrSignedMessages.length > 0
? <></>
: <SimulationSummary
: <>
<div class = { param.simulationResultState === 'invalid' || param.simulationUpdatingState === 'failed' ? 'blur' : '' }>
<TransactionsAndSignedMessages
simulationAndVisualisationResults = { param.simulationAndVisualisationResults }
currentBlockNumber = { param.currentBlockNumber }
removeTransactionOrSignedMessage = { param.removeTransactionOrSignedMessage }
activeAddress = { param.simulationAndVisualisationResults.activeAddress }
renameAddressCallBack = { param.renameAddressCallBack }
rpcConnectionStatus = { param.rpcConnectionStatus }
editEnsNamedHashCallBack = { param.editEnsNamedHashCallBack }
removedTransactionOrSignedMessages = { param.removedTransactionOrSignedMessages }
addressMetaData = { param.simulationAndVisualisationResults.addressBookEntries }
/>
}
</div>
</> }
{ param.removedTransactionOrSignedMessages.length > 0
? <></>
: <SimulationSummary
simulationAndVisualisationResults = { param.simulationAndVisualisationResults }
currentBlockNumber = { param.currentBlockNumber }
renameAddressCallBack = { param.renameAddressCallBack }
rpcConnectionStatus = { param.rpcConnectionStatus }
/>
}
</div>
</> }
<div class = 'content' style = 'height: 0.1px'/>
</div>
}
Expand Down Expand Up @@ -284,7 +284,7 @@ export function Home(param: HomeParams) {
return <>
{ rpcNetwork.httpsRpc === undefined ?
<ErrorComponent text = { `${ rpcNetwork.name } is not a supported network. The Interceptor is disabled while you are using ${ rpcNetwork.name }.` }/>
: <></> }
: <></> }

<FirstCard
activeAddresses = { activeAddresses }
Expand Down
14 changes: 7 additions & 7 deletions app/ts/components/pages/InterceptorAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ function AssociatedTogether({ associatedAddresses, renameAddressCallBack }: { as
function AccessRequest({ renameAddressCallBack, accessRequest, changeActiveAddress, refreshActiveAddress }: { renameAddressCallBack: (entry: AddressBookEntry) => void, accessRequest: PendingAccessRequest, changeActiveAddress: () => void, refreshActiveAddress: () => Promise<void> }) {
return <>
{ accessRequest.requestAccessToAddress === undefined ?
<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 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;'>
Expand Down
2 changes: 1 addition & 1 deletion app/ts/components/pages/InterceptorAccessList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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> :
Expand Down
Loading

0 comments on commit 0d0a741

Please sign in to comment.