Skip to content

Commit

Permalink
Smash a bunch of type/linter errors introduced by dependency changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowfiend committed May 27, 2023
1 parent 43399b8 commit 7e6afc9
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 30 deletions.
12 changes: 5 additions & 7 deletions __mocks__/uuid.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const uuidMock = jest.createMockFromModule<typeof import("uuid")>("uuid")
const uuidActual = jest.mock<typeof import("uuid")>("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,
}
2 changes: 1 addition & 1 deletion background/lib/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function getBalance(
provider: BaseProvider,
tokenAddress: string,
account: string
): Promise<BigInt> {
): Promise<bigint> {
const token = new ethers.Contract(tokenAddress, ERC20_ABI, provider)

return BigInt((await token.balanceOf(account)).toString())
Expand Down
2 changes: 1 addition & 1 deletion background/lib/token-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/migrations/to-14.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export default (
prevState: Record<string, unknown>
): Record<string, unknown> => {
const { assets, ...newState } = prevState
const { assets: _, ...newState } = prevState

// Clear assets collection; these should be immediately repopulated by the
// IndexingService in startService.
Expand Down
7 changes: 5 additions & 2 deletions background/redux-slices/migrations/to-16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ export default (prevState: Record<string, unknown>): NewState => {
: {},
}

const { spenderName, spenderAddress, ...oldAnnotationProps } =
annotation
const {
spenderName: __,
spenderAddress: ___,
...oldAnnotationProps
} = annotation

newState.activities[address][chainID].entities[
activityItem.hash
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/migrations/to-19.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default (
prevState: Record<string, unknown>
): Record<string, unknown> => {
const { activities, ...newState } = prevState
const { activities: _, ...newState } = prevState

// Clear activities slice as we now have new activities slice instead
newState.activities = {}
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/migrations/to-22.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export default (
prevState: Record<string, unknown>
): Record<string, unknown> => {
const { assets, ...newState } = prevState
const { assets: _, ...newState } = prevState

// Clear assets collection; these should be immediately repopulated by the
// IndexingService in startService.
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/migrations/to-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export default (
prevState: Record<string, unknown>
): Record<string, unknown> => {
const { assets, ...newState } = prevState
const { assets: _, ...newState } = prevState

// Clear assets collection; these should be immediately repopulated by the
// IndexingService in startService.
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/migrations/to-4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default (
},
}

const { blocks, ...oldStateAccountWithoutBlocks } = oldState.account ?? {
const { blocks: _, ...oldStateAccountWithoutBlocks } = oldState.account ?? {
blocks: undefined,
}

Expand Down
3 changes: 3 additions & 0 deletions background/services/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,9 @@ export default class ChainService extends BaseService<Events> {
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
}
}
Expand Down
2 changes: 1 addition & 1 deletion background/services/doggo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HexString } from "../../types"
export interface Eligible {
index: HexString
account: HexString
amount: BigInt
amount: bigint
proof: HexString[]
}

Expand Down
2 changes: 1 addition & 1 deletion background/services/keyring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export default class KeyringService extends BaseService<Events> {
// 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,
Expand Down
4 changes: 2 additions & 2 deletions background/services/ledger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export default class LedgerService extends BaseService<Events> {

if (!isEIP1559TransactionRequest(ethersTx)) {
// Ethers does not permit "from" field when serializing legacy transaction requests
const { from, ...fieldsWithoutFrom } = ethersTx
const { from: _, ...fieldsWithoutFrom } = ethersTx
serializableEthersTx = fieldsWithoutFrom
}

Expand Down Expand Up @@ -484,7 +484,7 @@ export default class LedgerService extends BaseService<Events> {
}

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)
Expand Down
7 changes: 3 additions & 4 deletions background/services/wallet-connect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ export default class WalletConnectService extends BaseService<Events> {
}

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions ui/pages/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
SECOND,
} from "@tallyho/tally-background/constants"

import { AsyncThunkFulfillmentType } from "@tallyho/tally-background/redux-slices/utils"
import {
selectLatestQuoteRequest,
selectSwapBuyAssets,
Expand Down Expand Up @@ -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<typeof fetchSwapQuote>
const finalQuote = await dispatch(fetchSwapQuote(quote.quoteRequest))

if (finalQuote) {
const { gasPrice, ...quoteWithoutGasPrice } = finalQuote
Expand Down

0 comments on commit 7e6afc9

Please sign in to comment.