diff --git a/__mocks__/uuid.ts b/__mocks__/uuid.ts index 7cf0d10307..4e74b93aa2 100644 --- a/__mocks__/uuid.ts +++ b/__mocks__/uuid.ts @@ -1,12 +1,10 @@ const uuidMock = jest.createMockFromModule("uuid") -const uuidActual = jest.mock("uuid", () => ({ - ...jest.requireActual("uuid"), - v4: jest.fn().mockImplementation(() => { - jest.requireActual("uuid").v4() - }), -})) + +const v4Mock = jest + .fn() + .mockImplementation(() => jest.requireActual("uuid").v4()) module.exports = { ...uuidMock, - v4: uuidActual.v4, + v4: v4Mock, } diff --git a/background/lib/erc20.ts b/background/lib/erc20.ts index 055867c8d0..6dd21c0f6c 100644 --- a/background/lib/erc20.ts +++ b/background/lib/erc20.ts @@ -75,7 +75,7 @@ export async function getBalance( provider: BaseProvider, tokenAddress: string, account: string -): Promise { +): Promise { const token = new ethers.Contract(tokenAddress, ERC20_ABI, provider) return BigInt((await token.balanceOf(account)).toString()) diff --git a/background/lib/token-lists.ts b/background/lib/token-lists.ts index b19dc97730..c8e7cdeb8c 100644 --- a/background/lib/token-lists.ts +++ b/background/lib/token-lists.ts @@ -22,7 +22,7 @@ import { DeepWriteable } from "../types" const cleanTokenListResponse = (json: any, url: string) => { if (url.includes("api-polygon-tokens.polygon.technology")) { if (typeof json === "object" && json !== null && "tags" in json) { - const { tags, ...cleanedJson } = json + const { tags: _, ...cleanedJson } = json return cleanedJson } } diff --git a/background/main.ts b/background/main.ts index a28950a611..d1ccd555e1 100644 --- a/background/main.ts +++ b/background/main.ts @@ -228,7 +228,7 @@ const reduxCache: Middleware = (store) => (next) => (action) => { // Declared out here so ReduxStoreType can be used in Main.store type // declaration. -const initializeStore = (preloadedState = {}, main: Main) => +const initializeStore = (preloadedState: object, main: Main) => configureStore({ preloadedState, reducer: rootReducer, diff --git a/background/redux-slices/migrations/to-14.ts b/background/redux-slices/migrations/to-14.ts index 3ebc42843c..3495855d80 100644 --- a/background/redux-slices/migrations/to-14.ts +++ b/background/redux-slices/migrations/to-14.ts @@ -5,7 +5,7 @@ export default ( prevState: Record ): Record => { - const { assets, ...newState } = prevState + const { assets: _, ...newState } = prevState // Clear assets collection; these should be immediately repopulated by the // IndexingService in startService. diff --git a/background/redux-slices/migrations/to-16.ts b/background/redux-slices/migrations/to-16.ts index d409011a43..94d359c9d4 100644 --- a/background/redux-slices/migrations/to-16.ts +++ b/background/redux-slices/migrations/to-16.ts @@ -96,8 +96,11 @@ export default (prevState: Record): NewState => { : {}, } - const { spenderName, spenderAddress, ...oldAnnotationProps } = - annotation + const { + spenderName: __, + spenderAddress: ___, + ...oldAnnotationProps + } = annotation newState.activities[address][chainID].entities[ activityItem.hash diff --git a/background/redux-slices/migrations/to-19.ts b/background/redux-slices/migrations/to-19.ts index 236d36caf6..f2be1db7c5 100644 --- a/background/redux-slices/migrations/to-19.ts +++ b/background/redux-slices/migrations/to-19.ts @@ -1,7 +1,7 @@ export default ( prevState: Record ): Record => { - const { activities, ...newState } = prevState + const { activities: _, ...newState } = prevState // Clear activities slice as we now have new activities slice instead newState.activities = {} diff --git a/background/redux-slices/migrations/to-22.ts b/background/redux-slices/migrations/to-22.ts index 3ebc42843c..3495855d80 100644 --- a/background/redux-slices/migrations/to-22.ts +++ b/background/redux-slices/migrations/to-22.ts @@ -5,7 +5,7 @@ export default ( prevState: Record ): Record => { - const { assets, ...newState } = prevState + const { assets: _, ...newState } = prevState // Clear assets collection; these should be immediately repopulated by the // IndexingService in startService. diff --git a/background/redux-slices/migrations/to-3.ts b/background/redux-slices/migrations/to-3.ts index 3ebc42843c..3495855d80 100644 --- a/background/redux-slices/migrations/to-3.ts +++ b/background/redux-slices/migrations/to-3.ts @@ -5,7 +5,7 @@ export default ( prevState: Record ): Record => { - const { assets, ...newState } = prevState + const { assets: _, ...newState } = prevState // Clear assets collection; these should be immediately repopulated by the // IndexingService in startService. diff --git a/background/redux-slices/migrations/to-4.ts b/background/redux-slices/migrations/to-4.ts index 39907c8ac5..2fc70507d8 100644 --- a/background/redux-slices/migrations/to-4.ts +++ b/background/redux-slices/migrations/to-4.ts @@ -39,7 +39,7 @@ export default ( }, } - const { blocks, ...oldStateAccountWithoutBlocks } = oldState.account ?? { + const { blocks: _, ...oldStateAccountWithoutBlocks } = oldState.account ?? { blocks: undefined, } diff --git a/background/services/chain/index.ts b/background/services/chain/index.ts index 1b5e214649..f59d7177ca 100644 --- a/background/services/chain/index.ts +++ b/background/services/chain/index.ts @@ -1706,6 +1706,9 @@ export default class ChainService extends BaseService { logger.error(`Error emitting tx ${finalTransaction}`, error) } if (error) { + // We don't control the errors in the whole stack, but we do want to + // rethrow them regardless. + // eslint-disable-next-line @typescript-eslint/no-throw-literal throw error } } diff --git a/background/services/doggo/types.ts b/background/services/doggo/types.ts index b39ea1179c..8f84aea037 100644 --- a/background/services/doggo/types.ts +++ b/background/services/doggo/types.ts @@ -3,7 +3,7 @@ import { HexString } from "../../types" export interface Eligible { index: HexString account: HexString - amount: BigInt + amount: bigint proof: HexString[] } diff --git a/background/services/keyring/index.ts b/background/services/keyring/index.ts index 793d6292e2..c28be40254 100644 --- a/background/services/keyring/index.ts +++ b/background/services/keyring/index.ts @@ -594,7 +594,7 @@ export default class KeyringService extends BaseService { // find the keyring using a linear search const keyring = await this.#findKeyring(account) // When signing we should not include EIP712Domain type - const { EIP712Domain, ...typesForSigning } = types + const { EIP712Domain: _, ...typesForSigning } = types try { const signature = await keyring.signTypedData( account, diff --git a/background/services/ledger/index.ts b/background/services/ledger/index.ts index 987465b3bd..5da3a01586 100644 --- a/background/services/ledger/index.ts +++ b/background/services/ledger/index.ts @@ -388,7 +388,7 @@ export default class LedgerService extends BaseService { if (!isEIP1559TransactionRequest(ethersTx)) { // Ethers does not permit "from" field when serializing legacy transaction requests - const { from, ...fieldsWithoutFrom } = ethersTx + const { from: _, ...fieldsWithoutFrom } = ethersTx serializableEthersTx = fieldsWithoutFrom } @@ -484,7 +484,7 @@ export default class LedgerService extends BaseService { } const eth = new Eth(this.transport) - const { EIP712Domain, ...typesForSigning } = typedData.types + const { EIP712Domain: _, ...typesForSigning } = typedData.types const hashedDomain = _TypedDataEncoder.hashDomain(typedData.domain) const hashedMessage = _TypedDataEncoder .from(typesForSigning) diff --git a/background/services/wallet-connect/index.ts b/background/services/wallet-connect/index.ts index 2687ff8692..12effd8a37 100644 --- a/background/services/wallet-connect/index.ts +++ b/background/services/wallet-connect/index.ts @@ -178,10 +178,9 @@ export default class WalletConnectService extends BaseService { } const namespaces: SessionTypes.Namespaces = {} - const accounts: string[] = [] - ethNamespace.chains.forEach((chain) => { - selectedAccounts.map((acc) => accounts.push(`${chain}:${acc}`)) - }) + const accounts = (ethNamespace.chains ?? []).flatMap((chain) => + selectedAccounts.map((selectedAccount) => `${chain}:${selectedAccount}`) + ) namespaces[ethNamespaceKey] = { accounts, methods: requiredNamespaces[ethNamespaceKey].methods, diff --git a/ui/components/Signing/Signer/SignerLedger/SignerLedgerSigning/index.tsx b/ui/components/Signing/Signer/SignerLedger/SignerLedgerSigning/index.tsx index f3051d576b..ae59a7bafd 100644 --- a/ui/components/Signing/Signer/SignerLedger/SignerLedgerSigning/index.tsx +++ b/ui/components/Signing/Signer/SignerLedger/SignerLedgerSigning/index.tsx @@ -55,7 +55,7 @@ function SignerLedgerSigningTypedData({ }: { typedData: EIP712TypedData }): ReactElement { - const { EIP712Domain, ...typesForSigning } = typedData.types + const { EIP712Domain: _, ...typesForSigning } = typedData.types const domainHash = _TypedDataEncoder .hashDomain(typedData.domain) .toUpperCase() diff --git a/ui/package.json b/ui/package.json index 16b704ee83..b3fd6f1b4b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -54,6 +54,7 @@ "zxcvbn": "^4.4.2" }, "devDependencies": { + "@reduxjs/toolkit": "^1.9.4", "@types/react-transition-group": "^4.4.4", "@types/zxcvbn": "^4.4.1", "webext-redux": "^2.1.7" diff --git a/ui/pages/Swap.tsx b/ui/pages/Swap.tsx index 9cb123320e..05583ffa9b 100644 --- a/ui/pages/Swap.tsx +++ b/ui/pages/Swap.tsx @@ -27,7 +27,6 @@ import { SECOND, } from "@tallyho/tally-background/constants" -import { AsyncThunkFulfillmentType } from "@tallyho/tally-background/redux-slices/utils" import { selectLatestQuoteRequest, selectSwapBuyAssets, @@ -343,9 +342,7 @@ export default function Swap(): ReactElement { const handleExecuteSwap = useCallback(async () => { if (sellAsset && buyAsset && quote) { - const finalQuote = (await dispatch( - fetchSwapQuote(quote.quoteRequest) - )) as unknown as AsyncThunkFulfillmentType + const finalQuote = await dispatch(fetchSwapQuote(quote.quoteRequest)) if (finalQuote) { const { gasPrice, ...quoteWithoutGasPrice } = finalQuote