diff --git a/app/ts/AddressBook.tsx b/app/ts/AddressBook.tsx index 55cee38f..8ff582c9 100644 --- a/app/ts/AddressBook.tsx +++ b/app/ts/AddressBook.tsx @@ -357,7 +357,7 @@ export function AddressBook() { ? ( - modalState.value = { page: 'confirmaddressBookEntryToBeRemoved', addressBookEntry } } renameAddressCallBack = { renameAddressCallBack } /> + { modalState.value = { page: 'confirmaddressBookEntryToBeRemoved', addressBookEntry } } } renameAddressCallBack = { renameAddressCallBack } /> ) } /> : @@ -371,7 +371,7 @@ export function AddressBook() { modalState.value = { page: 'noModal' } } + close = { () => { modalState.value = { page: 'noModal' } } } activeAddress = { undefined } rpcEntries = { rpcEntries } modifyStateCallBack = { (newState: ModifyAddressWindowState) => { @@ -385,7 +385,7 @@ export function AddressBook() { category = { viewFilter.value.activeFilter } addressBookEntry = { modalState.value.addressBookEntry } removeEntry = { removeAddressBookEntry } - close = { () => modalState.value = { page: 'noModal' } } + close = { () => { modalState.value = { page: 'noModal' } } } renameAddressCallBack = { renameAddressCallBack } /> : <> } diff --git a/app/ts/background/metadataUtils.ts b/app/ts/background/metadataUtils.ts index 0eadfd9c..40277614 100644 --- a/app/ts/background/metadataUtils.ts +++ b/app/ts/background/metadataUtils.ts @@ -260,7 +260,7 @@ const addNewEnsNameEntry = async (name: string) => { await addEnsNodeHash(name) } -export const getAndCacheEnsNodeHash = async (ethereumClientService: EthereumClientService, ensNameHash: EthereumBytes32, extraNameHashes: ENSNameHashes) => { +const getAndCacheEnsNodeHash = async (ethereumClientService: EthereumClientService, ensNameHash: EthereumBytes32, extraNameHashes: ENSNameHashes) => { const currentHashes = [ENS_ADDR_REVERSE_NODE, ...await getEnsNodeHashes()] const entry = currentHashes.find((entry) => entry.nameHash === ensNameHash) if (entry !== undefined) return entry diff --git a/app/ts/components/pages/InterceptorAccess.tsx b/app/ts/components/pages/InterceptorAccess.tsx index c858f54f..66794ff4 100644 --- a/app/ts/components/pages/InterceptorAccess.tsx +++ b/app/ts/components/pages/InterceptorAccess.tsx @@ -325,7 +325,7 @@ export function InterceptorAccess() { ? setActiveAddressAndInformAboutIt(appPage.value.accessRequestId, address) } modifyAddressWindowState = { modifyAddressSignal } - close = { () => appPage.value = { page: { page: 'Home' }, accessRequestId: '' } } + close = { () => { appPage.value = { page: { page: 'Home' }, accessRequestId: '' } } } activeAddress = { pendingAccessRequest.requestAccessToAddress?.address } rpcEntries = { rpcEntries } modifyStateCallBack = { (newState: ModifyAddressWindowState) => { @@ -340,7 +340,7 @@ export function InterceptorAccess() { ? setActiveAddressAndInformAboutIt(appPage.value.accessRequestId, address) } signerAccounts = { pendingAccessRequest.signerAccounts } - close = { () => appPage.value = { page: { page: 'Home' }, accessRequestId: '' } } + close = { () => { appPage.value = { page: { page: 'Home' }, accessRequestId: '' } } } activeAddresses = { activeAddresses } signerName = { pendingAccessRequest.signerName } renameAddressCallBack = { (entry: AddressBookEntry) => renameAddressCallBack(appPage.value.accessRequestId, entry) } diff --git a/app/ts/components/pages/WebsiteAccess.tsx b/app/ts/components/pages/WebsiteAccess.tsx index ae58e49b..935e69c4 100644 --- a/app/ts/components/pages/WebsiteAccess.tsx +++ b/app/ts/components/pages/WebsiteAccess.tsx @@ -437,7 +437,7 @@ const BlockRequestSetting = ({ websiteAccess }: { websiteAccess: Signal }) => { - const disableWebsiteProtection = async (shouldDisable: boolean = true) => { + const disableWebsiteProtection = async (shouldDisable = true) => { if (!websiteAccess.value) return sendPopupMessageToBackgroundPage({ method: 'popup_setDisableInterceptor', data: { website: websiteAccess.value.website, interceptorDisabled: shouldDisable } }) } diff --git a/app/ts/components/simulationExplaining/Transactions.tsx b/app/ts/components/simulationExplaining/Transactions.tsx index e19e2773..0a43ea3b 100644 --- a/app/ts/components/simulationExplaining/Transactions.tsx +++ b/app/ts/components/simulationExplaining/Transactions.tsx @@ -347,7 +347,7 @@ function NonTokenLogEvent(params: NonTokenLogEventParams) { return <>

{ `${ arg.paramName } = [` }

-

{ `]` }

+

]

} return <> diff --git a/app/ts/components/simulationExplaining/identifyTransaction.tsx b/app/ts/components/simulationExplaining/identifyTransaction.tsx index 2e2b5bfc..bf2429cb 100644 --- a/app/ts/components/simulationExplaining/identifyTransaction.tsx +++ b/app/ts/components/simulationExplaining/identifyTransaction.tsx @@ -14,7 +14,6 @@ import { UniqueRequestIdentifier } from '../../utils/requests.js' import { findDeadEnds } from '../../utils/findDeadEnds.js' import { EthereumAddress, EthereumQuantity } from '../../types/wire-types.js' import { extractTokenEvents } from '../../background/metadataUtils.js' -import { TokenVisualizerErc1155Event, TokenVisualizerErc20Event, TokenVisualizerErc721Event } from '../../types/EnrichedEthereumData.js' type IdentifiedTransactionBase = { title: string @@ -146,9 +145,6 @@ function isSimpleTokenApproval(simTx: SimulatedAndVisualizedTransaction): simTx } const getSimpleTokenApprovalOrUndefined = createGuard((simTx) => isSimpleTokenApproval(simTx) ? simTx : undefined) -export type TokenResult = funtypes.Static -export const TokenResult = funtypes.Intersect(funtypes.Union(TokenVisualizerErc20Event, TokenVisualizerErc721Event, TokenVisualizerErc1155Event), funtypes.ReadonlyObject({ isApproval: funtypes.Literal(false) })) - export type SimulatedAndVisualizedSimpleTokenTransferTransaction = funtypes.Static export const SimulatedAndVisualizedSimpleTokenTransferTransaction = funtypes.Intersect( SimulatedAndVisualizedTransactionBase, diff --git a/app/ts/components/subcomponents/AutosizingInput.tsx b/app/ts/components/subcomponents/AutosizingInput.tsx index 4354ebbe..3d453be5 100644 --- a/app/ts/components/subcomponents/AutosizingInput.tsx +++ b/app/ts/components/subcomponents/AutosizingInput.tsx @@ -55,7 +55,7 @@ function ParsedInput(model: ParsedInputModel) { // we want to pass through all model values *except* the rawValue, which may contain a password const inputModel = { ...model } delete inputModel.rawValue - return internalValue.value = event.currentTarget.value } onChange = { onChange }/> + return { internalValue.value = event.currentTarget.value } } onChange = { onChange }/> } function Input(model: UnparsedInputModel | ParsedInputModel) { @@ -73,7 +73,7 @@ interface BaseAutosizingInputModel extends Pick {} interface ParsedAutosizingInputModel extends BaseAutosizingInputModel, Pick, 'value' | 'sanitize' | 'tryParse' | 'serialize'> {} -export function AutosizingInput(model: UnparsedAutosizingInputModel | ParsedAutosizingInputModel) { +function AutosizingInput(model: UnparsedAutosizingInputModel | ParsedAutosizingInputModel) { const internalValue = model.rawValue || useSignal(model.serialize ? model.serialize(model.value.deepPeek()) : model.value.peek()) const inputModel = { rawValue: internalValue, diff --git a/app/ts/components/subcomponents/ConfigureRpcConnection.tsx b/app/ts/components/subcomponents/ConfigureRpcConnection.tsx index f6910f0e..3d0c1269 100644 --- a/app/ts/components/subcomponents/ConfigureRpcConnection.tsx +++ b/app/ts/components/subcomponents/ConfigureRpcConnection.tsx @@ -313,7 +313,7 @@ const RpcUrlField = ({ defaultValue }: { defaultValue?: string }) => { return deferredQueryAnRpcUrl(e.currentTarget.value) } statusIcon = { } style = '--area: 1 / span 2' required autoComplete = 'off' autoFocus = { defaultValue === undefined } readOnly = { defaultValue !== undefined } /> } -export const StatusIcon = ({ state }: { state: AsyncStates }) => { +const StatusIcon = ({ state }: { state: AsyncStates }) => { switch (state) { case 'inactive': return <> case 'pending': return @@ -322,19 +322,19 @@ export const StatusIcon = ({ state }: { state: AsyncStates }) => { } } -export const SpinnerIcon = () => ( +const SpinnerIcon = () => ( ) -export const CheckIcon = () => ( +const CheckIcon = () => ( ) -export const Trash = () => ( +const Trash = () => ( ) diff --git a/app/ts/components/subcomponents/InlineCard.tsx b/app/ts/components/subcomponents/InlineCard.tsx index cc00842a..50c274c3 100644 --- a/app/ts/components/subcomponents/InlineCard.tsx +++ b/app/ts/components/subcomponents/InlineCard.tsx @@ -4,7 +4,7 @@ import { clipboardCopy } from './clipboardcopy.js' import { CopyIcon, EditIcon } from './icons.js' import { Tooltip, TooltipConfig } from './Tooltip.js' -export type InlineCardProps = { +type InlineCardProps = { icon: () => JSX.Element label: string copyValue?: string diff --git a/app/ts/components/subcomponents/MultilineCard.tsx b/app/ts/components/subcomponents/MultilineCard.tsx index 2eff04ab..fe56d704 100644 --- a/app/ts/components/subcomponents/MultilineCard.tsx +++ b/app/ts/components/subcomponents/MultilineCard.tsx @@ -4,7 +4,7 @@ import { Tooltip, TooltipConfig } from './Tooltip.js' import { clipboardCopy } from './clipboardcopy.js' import { CopyIcon } from './icons.js' -export type MultilineCardProps = { +type MultilineCardProps = { icon: ActionableIconProps label: ActionableTextProps note: ActionableTextProps diff --git a/app/ts/components/subcomponents/SVGBlockie.tsx b/app/ts/components/subcomponents/SVGBlockie.tsx index b8a92801..c66a2a23 100644 --- a/app/ts/components/subcomponents/SVGBlockie.tsx +++ b/app/ts/components/subcomponents/SVGBlockie.tsx @@ -86,7 +86,7 @@ function generateIdenticon(options: { address: bigint; size?: number }) { return { imageData, color, bgcolor, spotcolor } } -export type SVGBlockieProps = { +type SVGBlockieProps = { style?: JSX.CSSProperties address: bigint } diff --git a/app/ts/components/subcomponents/Tooltip.tsx b/app/ts/components/subcomponents/Tooltip.tsx index 6315280f..eef60f20 100644 --- a/app/ts/components/subcomponents/Tooltip.tsx +++ b/app/ts/components/subcomponents/Tooltip.tsx @@ -18,7 +18,7 @@ export function Tooltip({ config }: { config: Signal } popoverRef.current?.showPopover() - setTimeout(() => config.value = undefined, config.value.duration || 1500) + setTimeout(() => { config.value = undefined }, config.value.duration || 1500) }) return ( diff --git a/app/ts/components/subcomponents/icons.tsx b/app/ts/components/subcomponents/icons.tsx index 0313b1aa..61372e00 100644 --- a/app/ts/components/subcomponents/icons.tsx +++ b/app/ts/components/subcomponents/icons.tsx @@ -53,6 +53,4 @@ export const CopyIcon = () => -export const CheckIcon = () => - export const ChevronIcon = () => diff --git a/app/ts/simulation/logHandlers.ts b/app/ts/simulation/logHandlers.ts index 7648b3d4..31964571 100644 --- a/app/ts/simulation/logHandlers.ts +++ b/app/ts/simulation/logHandlers.ts @@ -292,7 +292,7 @@ function decodeENSName(encodedName: Uint8Array): string { const length = encodedName[i] if (length === 0 || length === undefined) break i++ - let label = new TextDecoder().decode(encodedName.slice(i, i + length)) + const label = new TextDecoder().decode(encodedName.slice(i, i + length)) decodedName += label + '.' i += length } diff --git a/app/ts/simulation/services/EtherScanAbiFetcher.ts b/app/ts/simulation/services/EtherScanAbiFetcher.ts index 44ab2fef..202fabe5 100644 --- a/app/ts/simulation/services/EtherScanAbiFetcher.ts +++ b/app/ts/simulation/services/EtherScanAbiFetcher.ts @@ -22,7 +22,7 @@ export function isValidAbi(abi: string) { } } -export function getBlockExplorer(chainId: ChainIdWithUniversal, rpcEntries: RpcEntries) { +function getBlockExplorer(chainId: ChainIdWithUniversal, rpcEntries: RpcEntries) { if (chainId === 'AllChains') return undefined const primaryRpc = rpcEntries.find((rpc) => rpc.chainId === chainId && rpc.primary) if (primaryRpc !== undefined && primaryRpc.blockExplorer !== undefined) return primaryRpc.blockExplorer diff --git a/app/ts/simulation/services/LogSummarizer.ts b/app/ts/simulation/services/LogSummarizer.ts index 22c5f5be..878a4dc5 100644 --- a/app/ts/simulation/services/LogSummarizer.ts +++ b/app/ts/simulation/services/LogSummarizer.ts @@ -4,7 +4,7 @@ import { AddressBookEntry, Erc1155Entry, Erc721Entry } from '../../types/address import { ETHEREUM_LOGS_LOGGER_ADDRESS } from '../../utils/constants.js' import { extractTokenEvents } from '../../background/metadataUtils.js' import { TokenVisualizerResultWithMetadata } from '../../types/EnrichedEthereumData.js' -export type BalanceChangeSummary = { +type BalanceChangeSummary = { erc20TokenBalanceChanges: Map, // token address, amount erc20TokenApprovalChanges: Map > // token address, approved address, amount diff --git a/app/ts/simulation/services/SimulationModeEthereumClientService.ts b/app/ts/simulation/services/SimulationModeEthereumClientService.ts index b9cd37d1..54b8f733 100644 --- a/app/ts/simulation/services/SimulationModeEthereumClientService.ts +++ b/app/ts/simulation/services/SimulationModeEthereumClientService.ts @@ -3,7 +3,7 @@ import { EthereumUnsignedTransaction, EthereumSignedTransactionWithBlockData, Et import { addressString, bigintToUint8Array, bytes32String, calculateWeightedPercentile, dataStringWith0xStart, max, min, stringToUint8Array } from '../../utils/bigint.js' import { CANNOT_SIMULATE_OFF_LEGACY_BLOCK, ERROR_INTERCEPTOR_GAS_ESTIMATION_FAILED, ETHEREUM_LOGS_LOGGER_ADDRESS, ETHEREUM_EIP1559_BASEFEECHANGEDENOMINATOR, ETHEREUM_EIP1559_ELASTICITY_MULTIPLIER, MOCK_ADDRESS, MULTICALL3, Multicall3ABI, DEFAULT_CALL_ADDRESS, GAS_PER_BLOB, MAKE_YOU_RICH_TRANSACTION } from '../../utils/constants.js' import { Interface, ethers, hashMessage, keccak256, } from 'ethers' -import { SimulatedTransaction, SimulationState, TokenBalancesAfter, EstimateGasError, SignedMessageTransaction, WebsiteCreatedEthereumUnsignedTransactionOrFailed, TransactionStack, PreSimulationTransaction } from '../../types/visualizer-types.js' +import { SimulatedTransaction, SimulationState, TokenBalancesAfter, EstimateGasError, WebsiteCreatedEthereumUnsignedTransactionOrFailed, TransactionStack, PreSimulationTransaction } from '../../types/visualizer-types.js' import { EthereumUnsignedTransactionToUnsignedTransaction, IUnsignedTransaction1559, rlpEncode, serializeSignedTransactionToBytes } from '../../utils/ethereum.js' import { EthGetLogsResponse, EthGetLogsRequest, EthTransactionReceiptResponse, DappRequestTransaction, EthGetFeeHistoryResponse, FeeHistory } from '../../types/JsonRpc-types.js' import { handleERC1155TransferBatch, handleERC1155TransferSingle, handleERC20TransferLog } from '../logHandlers.js' @@ -357,17 +357,6 @@ const getTransactionQueue = (simulationState: SimulationState | undefined) => { return simulationState.simulatedTransactions.map((x) => x.preSimulationTransaction.signedTransaction) } -export const getEmptySimulationStateWithRichAddress = (ethereumClientService: EthereumClientService, addressToMakeRich: EthereumAddress | undefined, oldSimulationState: SimulationState | undefined): SimulationState => ({ - addressToMakeRich, - simulatedTransactions: [], - blockNumber: oldSimulationState?.blockNumber || 0n, - blockTimestamp: new Date(), - rpcNetwork: ethereumClientService.getRpcEntry(), - simulationConductedTimestamp: new Date(), - signedMessages: [], - baseFeePerGas: 0n, -}) - export const getNonceFixedSimulatedTransactions = async(ethereumClientService: EthereumClientService, requestAbortController: AbortController | undefined, simulatedTransactions: readonly SimulatedTransaction[]) => { const isFixableNonceError = (transaction: SimulatedTransaction) => { return transaction.ethSimulateV1CallResult.status === 'failure' @@ -726,7 +715,7 @@ const getSignedMessagesWithFakeSigner = (simulationState: SimulationState | unde return simulationState === undefined ? [] : simulationState.signedMessages.map((x) => ({ fakeSignedFor: x.fakeSignedFor, originalRequestParameters: x.originalRequestParameters })) } -const simulatedMulticall = async (ethereumClientService: EthereumClientService, requestAbortController: AbortController | undefined, simulationState: SimulationState | undefined, transactions: EthereumUnsignedTransaction[], blockNumber: bigint, extraAccountOverrides: StateOverrides = {}, simulateOnBlockAboveExistingSimulationStack: boolean = false) => { +const simulatedMulticall = async (ethereumClientService: EthereumClientService, requestAbortController: AbortController | undefined, simulationState: SimulationState | undefined, transactions: EthereumUnsignedTransaction[], blockNumber: bigint, extraAccountOverrides: StateOverrides = {}, simulateOnBlockAboveExistingSimulationStack = false) => { const mergedTxs: EthereumUnsignedTransaction[] = getTransactionQueue(simulationState) const makeMeRich = getMakeMeRichStateOverride(simulationState?.addressToMakeRich) const transactionsInBlocks = simulateOnBlockAboveExistingSimulationStack ? [mergedTxs, transactions] : [mergedTxs.concat(transactions)] @@ -957,10 +946,6 @@ export const getTokenBalancesAfter = async ( return await Promise.all(tokenBalancesAfter) } -export const appendSignedMessage = async (simulationState: SimulationState, signedMessage: SignedMessageTransaction): Promise => { - return modifyObject(simulationState, { signedMessages: simulationState.signedMessages.concat(signedMessage) }) -} - // takes the most recent block that the application is querying and does the calculation based on that export const getSimulatedFeeHistory = async (ethereumClientService: EthereumClientService, requestAbortController: AbortController | undefined, request: FeeHistory): Promise => { //const numberOfBlocks = Number(request.params[0]) // number of blocks, not used atm as we just return one block diff --git a/app/ts/simulation/services/priceEstimator.ts b/app/ts/simulation/services/priceEstimator.ts index 763121e8..001dd734 100644 --- a/app/ts/simulation/services/priceEstimator.ts +++ b/app/ts/simulation/services/priceEstimator.ts @@ -18,7 +18,6 @@ interface CachedTokenPriceEstimate { } const IMulticall3 = new Interface(Multicall3ABI) -export type ITokenPriceService = Pick export class TokenPriceService { private cachedPrices = new Map > // quoteTokenAddress -> tokenAddress -> TokenPriceEstimate public cacheAge: number @@ -39,7 +38,7 @@ export class TokenPriceService { if (quoteTokenAddressCache.size === 0) this.cachedPrices.delete(quoteTokenAddressString) }) } - + private async getTokenPrice(requestAbortController: AbortController | undefined, token: TokenDecimals, quoteToken: Erc20TokenEntry) { const poolAddresses = calculateUniswapLikePools(token.address, quoteToken.address) if (!poolAddresses) return undefined @@ -50,7 +49,7 @@ export class TokenPriceService { const callTransaction = { type: '1559', to: MULTICALL3, value: 0n, input: callData, } const multicallReturnData: { success: boolean, returnData: string }[] = IMulticall3.decodeFunctionResult('aggregate3', await this.ethereumClientService.call(callTransaction, 'latest', requestAbortController))[0] const prices = calculatePricesFromUniswapLikeReturnData(multicallReturnData, poolAddresses) - if (prices.length === 0) return undefined + if (prices.length === 0) return undefined return { token, quoteToken, diff --git a/app/ts/types/EnrichedEthereumData.ts b/app/ts/types/EnrichedEthereumData.ts index 47677835..411a08ca 100644 --- a/app/ts/types/EnrichedEthereumData.ts +++ b/app/ts/types/EnrichedEthereumData.ts @@ -79,8 +79,8 @@ export const TokenVisualizerResult = funtypes.Intersect( ) ) -export type EnsFuseName = funtypes.Static -export const EnsFuseName = funtypes.Union( +type EnsFuseName = funtypes.Static +const EnsFuseName = funtypes.Union( funtypes.Literal('Cannot Unwrap Name'), funtypes.Literal('Cannot Burn Fuses'), funtypes.Literal('Cannot Transfer'), @@ -290,8 +290,8 @@ export const TokenVisualizerErc721Event = funtypes.ReadonlyObject({ isApproval: funtypes.Boolean, }) -export type TokenVisualizerErc1155Event = funtypes.Static -export const TokenVisualizerErc1155Event = funtypes.ReadonlyObject({ +type TokenVisualizerErc1155Event = funtypes.Static +const TokenVisualizerErc1155Event = funtypes.ReadonlyObject({ logObject: funtypes.Union(funtypes.Undefined, EnrichedEthereumEvent), type: funtypes.Literal('ERC1155'), from: AddressBookEntry, @@ -322,13 +322,6 @@ export const TokenVisualizerResultWithMetadata = funtypes.Union( TokenVisualizerNFTAllApprovalEvent, ) -export type MaybeParsedEvent = funtypes.Static -export const MaybeParsedEvent = funtypes.Union(ParsedEvent, NonParsedEvent) - -export type MaybeParsedEvents = funtypes.Static -export const MaybeParsedEvents = funtypes.ReadonlyArray(MaybeParsedEvent) - - export type TokenEvent = funtypes.Static export const TokenEvent = funtypes.Intersect( ParsedEvent, diff --git a/app/ts/types/accessRequest.ts b/app/ts/types/accessRequest.ts index 2510838e..3c435aba 100644 --- a/app/ts/types/accessRequest.ts +++ b/app/ts/types/accessRequest.ts @@ -38,8 +38,8 @@ const ConfirmTransactionSimulationBaseData = funtypes.ReadonlyObject({ signerName: SignerName, }) -export type ConfirmTransactionDialogState = funtypes.Static -export const ConfirmTransactionDialogState = funtypes.Intersect( +type ConfirmTransactionDialogState = funtypes.Static +const ConfirmTransactionDialogState = funtypes.Intersect( ConfirmTransactionSimulationBaseData, funtypes.ReadonlyObject({ eventsForEachTransaction: funtypes.ReadonlyArray(funtypes.ReadonlyArray(EnrichedEthereumEvent)), diff --git a/app/ts/types/ens.ts b/app/ts/types/ens.ts index deb70671..bd111872 100644 --- a/app/ts/types/ens.ts +++ b/app/ts/types/ens.ts @@ -10,8 +10,8 @@ export const MaybeENSNameHash = funtypes.ReadonlyObject({ export type MaybeENSNameHashes = funtypes.Static export const MaybeENSNameHashes = funtypes.ReadonlyArray(MaybeENSNameHash) -export type ENSNameHash = funtypes.Static -export const ENSNameHash = funtypes.ReadonlyObject({ +type ENSNameHash = funtypes.Static +const ENSNameHash = funtypes.ReadonlyObject({ nameHash: EthereumBytes32, name: funtypes.String, }) @@ -19,8 +19,8 @@ export const ENSNameHash = funtypes.ReadonlyObject({ export type ENSNameHashes = funtypes.Static export const ENSNameHashes = funtypes.ReadonlyArray(ENSNameHash) -export type ENSLabelHash = funtypes.Static -export const ENSLabelHash = funtypes.ReadonlyObject({ +type ENSLabelHash = funtypes.Static +const ENSLabelHash = funtypes.ReadonlyObject({ labelHash: EthereumBytes32, label: funtypes.String, }) diff --git a/app/ts/types/ethSimulate-types.ts b/app/ts/types/ethSimulate-types.ts index 881fb361..e9e6b6e6 100644 --- a/app/ts/types/ethSimulate-types.ts +++ b/app/ts/types/ethSimulate-types.ts @@ -56,7 +56,7 @@ export const BlockCalls = funtypes.Intersect( }) ) -export type EthSimulateV1ParamObject = funtypes.Static +type EthSimulateV1ParamObject = funtypes.Static const EthSimulateV1ParamObject = funtypes.ReadonlyObject({ blockStateCalls: funtypes.ReadonlyArray(BlockCalls), traceTransfers: funtypes.Boolean, diff --git a/app/ts/types/interceptor-messages.ts b/app/ts/types/interceptor-messages.ts index 24902ac0..736edf01 100644 --- a/app/ts/types/interceptor-messages.ts +++ b/app/ts/types/interceptor-messages.ts @@ -184,8 +184,8 @@ export const InterceptorMessageToInpage = funtypes.Intersect( funtypes.Union(InterceptedRequestForwardWithRequestId, SubscriptionReplyOrCallBack) ) -export type RefreshConfirmTransactionMetadata = funtypes.Static -export const RefreshConfirmTransactionMetadata = funtypes.ReadonlyObject({ +type RefreshConfirmTransactionMetadata = funtypes.Static +const RefreshConfirmTransactionMetadata = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_refreshConfirmTransactionMetadata') }).asReadonly() @@ -225,8 +225,8 @@ export const InterceptorAccessRefresh = funtypes.ReadonlyObject({ }), }).asReadonly() -export type RefreshInterceptorAccessMetadata = funtypes.Static -export const RefreshInterceptorAccessMetadata = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_refreshInterceptorAccessMetadata') }).asReadonly() +type RefreshInterceptorAccessMetadata = funtypes.Static +const RefreshInterceptorAccessMetadata = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_refreshInterceptorAccessMetadata') }).asReadonly() export type InterceptorAccessChangeAddress = funtypes.Static export const InterceptorAccessChangeAddress = funtypes.ReadonlyObject({ @@ -482,8 +482,8 @@ export const UpdateConfirmTransactionDialog = funtypes.ReadonlyObject({ }) }).asReadonly() -export type UpdateConfirmTransactionDialogPartial = funtypes.Static -export const UpdateConfirmTransactionDialogPartial = funtypes.ReadonlyObject({ +type UpdateConfirmTransactionDialogPartial = funtypes.Static +const UpdateConfirmTransactionDialogPartial = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_update_confirm_transaction_dialog'), data: funtypes.Unknown }).asReadonly() @@ -707,8 +707,9 @@ export const SimulateGovernanceContractExecution = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_simulateGovernanceContractExecution'), data: funtypes.ReadonlyObject({ transactionIdentifier: EthereumQuantity }) }) -export type SimulateGnosisSafeTransaction = funtypes.Static -export const SimulateGnosisSafeTransaction = funtypes.ReadonlyObject({ + +type SimulateGnosisSafeTransaction = funtypes.Static +const SimulateGnosisSafeTransaction = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_simulateGnosisSafeTransaction'), data: funtypes.ReadonlyObject({ gnosisSafeMessage: VisualizedPersonalSignRequestSafeTx, @@ -746,17 +747,6 @@ export const RetrieveWebsiteAccess = funtypes.ReadonlyObject({ data: RetrieveWebsiteAccessFilter, }).asReadonly() -export type SearchProximity = funtypes.Static -export const SearchProximity = funtypes.ReadonlyTuple(funtypes.Number, funtypes.Number) - -export type SearchMetadata = funtypes.Static -export const SearchMetadata = funtypes.Object({ - _targets: funtypes.MutableArray(funtypes.String), - closestProximity: SearchProximity, - scores: funtypes.Record(funtypes.String, SearchProximity), - targets: funtypes.Array(funtypes.String) -}) - type RetrieveWebsiteAccessReply = funtypes.Static const RetrieveWebsiteAccessReply = funtypes.ReadonlyObject({ method: funtypes.Literal('popup_retrieveWebsiteAccessReply'), diff --git a/app/ts/types/visualizer-types.ts b/app/ts/types/visualizer-types.ts index 25ae784a..19995c5c 100644 --- a/app/ts/types/visualizer-types.ts +++ b/app/ts/types/visualizer-types.ts @@ -231,8 +231,8 @@ export const NamedTokenId = funtypes.ReadonlyObject({ tokenIdName: funtypes.String }) -export type EventsForEachTransaction = funtypes.Static -export const EventsForEachTransaction = funtypes.ReadonlyArray(funtypes.ReadonlyArray(EnrichedEthereumEvent)) +type EventsForEachTransaction = funtypes.Static +const EventsForEachTransaction = funtypes.ReadonlyArray(funtypes.ReadonlyArray(EnrichedEthereumEvent)) export type CompleteVisualizedSimulation = funtypes.Static export const CompleteVisualizedSimulation = funtypes.ReadonlyObject({ diff --git a/app/ts/types/wire-types.ts b/app/ts/types/wire-types.ts index cdd6d0e8..790c31f3 100644 --- a/app/ts/types/wire-types.ts +++ b/app/ts/types/wire-types.ts @@ -214,8 +214,8 @@ const EthereumUnsignedTransaction2930 = funtypes.Intersect( }).asReadonly(), ) -export type EthereumUnsignedTransaction1559 = funtypes.Static -export const EthereumUnsignedTransaction1559 = funtypes.Intersect( +type EthereumUnsignedTransaction1559 = funtypes.Static +const EthereumUnsignedTransaction1559 = funtypes.Intersect( funtypes.ReadonlyObject({ type: funtypes.Literal('0x2').withParser(LiteralConverterParserFactory('0x2', '1559' as const)), from: EthereumAddress, diff --git a/app/ts/utils/OptionalSignal.ts b/app/ts/utils/OptionalSignal.ts index 49155a4f..cfd7a9b8 100644 --- a/app/ts/utils/OptionalSignal.ts +++ b/app/ts/utils/OptionalSignal.ts @@ -13,7 +13,7 @@ export class OptionalSignal extends Signal | undefined> implements public get deepValue() { const inner = this.value if (inner === undefined) return undefined - else return inner.value + return inner.value } public set deepValue(newValue: T | undefined) { @@ -31,10 +31,10 @@ export class OptionalSignal extends Signal | undefined> implements public readonly deepPeek = () => { const inner = this.peek() if (inner === undefined) return undefined - else return inner.peek() + return inner.peek() } - public readonly clear = () => this.value = undefined + public readonly clear = () => { this.value = undefined } // convenience function for when you want pass a setter to a function; note that this is `this` bound in the constructor public set(newValue: T | undefined) { this.deepValue = newValue } diff --git a/app/ts/utils/abi.ts b/app/ts/utils/abi.ts index 2439d5db..8ee41aa4 100644 --- a/app/ts/utils/abi.ts +++ b/app/ts/utils/abi.ts @@ -2,21 +2,6 @@ import { InterfaceAbi } from 'ethers' import { AddressBookEntry } from '../types/addressBookTypes.js' import { ETHEREUM_LOGS_LOGGER_ADDRESS } from './constants.js' -export const MulticallABI: InterfaceAbi = [ - 'function aggregate(tuple(address target, bytes callData)[] calls) returns (uint256 blockNumber, bytes[] returnData)', - 'function blockAndAggregate(tuple(address target, bytes callData)[] calls) returns (uint256 blockNumber, bytes32 blockHash, tuple(bool success, bytes returnData)[] returnData)', - 'function getBlockHash(uint256 blockNumber) view returns (bytes32 blockHash)', - 'function getBlockNumber() view returns (uint256 blockNumber)', - 'function getCurrentBlockCoinbase() view returns (address coinbase)', - 'function getCurrentBlockDifficulty() view returns (uint256 difficulty)', - 'function getCurrentBlockGasLimit() view returns (uint256 gaslimit)', - 'function getCurrentBlockTimestamp() view returns (uint256 timestamp)', - 'function getEthBalance(address addr) view returns (uint256 balance)', - 'function getLastBlockHash() view returns (bytes32 blockHash)', - 'function tryAggregate(bool requireSuccess, tuple(address target, bytes callData)[] calls) returns (tuple(bool success, bytes returnData)[] returnData)', - 'function tryBlockAndAggregate(bool requireSuccess, tuple(address target, bytes callData)[] calls) returns (uint256 blockNumber, bytes32 blockHash, tuple(bool success, bytes returnData)[] returnData)' -] - const TokenMetadataABI: InterfaceAbi = [ 'function name() external view returns(string memory)', 'function symbol() external view returns(string memory)', diff --git a/app/ts/utils/ethereum.ts b/app/ts/utils/ethereum.ts index 0f5a21e6..4d376720 100644 --- a/app/ts/utils/ethereum.ts +++ b/app/ts/utils/ethereum.ts @@ -49,7 +49,7 @@ export interface IUnsignedTransaction1559 { }[] } -export interface IOptimismDepositTransaction { +interface IOptimismDepositTransaction { readonly type: 'optimismDeposit' readonly sourceHash: bigint readonly from: bigint diff --git a/app/ts/utils/storageUtils.ts b/app/ts/utils/storageUtils.ts index 23560556..c520388d 100644 --- a/app/ts/utils/storageUtils.ts +++ b/app/ts/utils/storageUtils.ts @@ -110,9 +110,7 @@ const LocalStorageKey2 = funtypes.Union( export async function browserStorageLocalGet2(keys: LocalStorageKey2 | LocalStorageKey2[]): Promise { return LocalStorageItems2.parse(await browser.storage.local.get(Array.isArray(keys) ? keys : [keys])) } -export async function browserStorageLocalRemove2(keys: LocalStorageKey2 | LocalStorageKey2[]) { - return await browser.storage.local.remove(Array.isArray(keys) ? keys : [keys]) -} + export async function browserStorageLocalSet2(items: LocalStorageItems2) { return await browser.storage.local.set(serialize(LocalStorageItems2, items)) } diff --git a/app/ts/utils/typed-arrays.ts b/app/ts/utils/typed-arrays.ts index 67a532c5..9d26deae 100644 --- a/app/ts/utils/typed-arrays.ts +++ b/app/ts/utils/typed-arrays.ts @@ -26,23 +26,10 @@ export function stripLeadingZeros(byteArray: Uint8Array): Uint8Array { return result } -export function arrayToChunks(array: readonly Type[], chunkSize: number) { - return Array.from( - { length: Math.ceil(array.length / chunkSize) }, (_, i) => array.slice(i * chunkSize, i * chunkSize + chunkSize) - ) -} - const arePropValuesEqual = (subject: T, target: T, propNames: (keyof T)[]): boolean => propNames.every(propName => subject[propName] === target[propName]) export const getUniqueItemsByProperties = (items: T[], propNames: (keyof T)[]): T[] => items.filter((item, index, array) => index === array.findIndex(foundItem => arePropValuesEqual(foundItem, item, propNames))) -export function includesWithComparator(array: readonly T[], searchElement: T, comparator: (a: T, b: T) => boolean): boolean { - for (const element of array) { - if (comparator(element, searchElement)) return true - } - return false -} - export function replaceElementInReadonlyArray(originalArray: readonly T[], index: number, newValue: T): readonly T[] { if (index < 0 || index >= originalArray.length) throw new Error('Index is out of bounds') const newArray = [...originalArray] diff --git a/knip.jsonc b/knip.jsonc index b3cde1ae..191c72ac 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -13,8 +13,9 @@ "app/ts/interceptorAccess.ts", "app/ts/popup.ts", "app/ts/settingsView.ts", + "app/ts/components/pages/WebsiteAccess.tsx", "test/run-all.ts", - "test/tests/*.ts" + "test/tests/*.ts", ], "project": ["app/ts/**/*.{ts,tsx}", "test/**/*.{ts,tsx}"], "ignoreDependencies": [ diff --git a/test/tests/nethermindComparison.ts b/test/tests/nethermindComparison.ts index cec0ad82..dbdfdcd4 100644 --- a/test/tests/nethermindComparison.ts +++ b/test/tests/nethermindComparison.ts @@ -8,7 +8,6 @@ import * as assert from 'assert' import { assertIsObject } from '../../app/ts/utils/typescript.js' import { stringToUint8Array } from '../../app/ts/utils/bigint.js' import { areEqualUint8Arrays } from '../../app/ts/utils/typed-arrays.js' -import { EthSimulateV1Params } from '../../app/ts/types/ethSimulate-types.js' function parseRequest(data: string) { const jsonRpcResponse = JsonRpcResponse.parse(JSON.parse(data)) @@ -32,7 +31,6 @@ class MockEthereumJSONRpcRequestHandler { return parseRequest(eth_getBlockByNumber_goerli_8443561_false) } case 'eth_simulateV1': { - console.log(JSON.stringify(serialize(EthSimulateV1Params, rpcRequest))) if (areEqualUint8Arrays(rpcRequest.params[0]?.blockStateCalls[1]?.calls[0]?.input, stringToUint8Array('0x82ad56cb0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000100000000000000000000000000ca11bde05977b3631167028862be2a173976ca110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000244d2301cc000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa9604500000000000000000000000000000000000000000000000000000000000000000000000000000000ca11bde05977b3631167028862be2a173976ca110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000244d2301cc000000000000000000000000da9dfa130df4de4673b89022ee50ff26f6ea73cf00000000000000000000000000000000000000000000000000000000'))) { // get eth balance query return parseRequest(eth_simulateV1_get_eth_balance_multicall) @@ -41,7 +39,7 @@ class MockEthereumJSONRpcRequestHandler { // get eth balance query return parseRequest(eth_simulateV1_get_eth_balance_multicall) } - if (rpcRequest.params[0]?.blockStateCalls.length == 2) { + if (rpcRequest.params[0]?.blockStateCalls.length === 2) { return parseRequest(eth_simulateV1_dummy_call_result_2calls) } return parseRequest(eth_simulateV1_dummy_call_result)