diff --git a/packages/.eslintrc.json b/packages/.eslintrc.json index 7654e02a4c00..a06fafd88039 100644 --- a/packages/.eslintrc.json +++ b/packages/.eslintrc.json @@ -83,7 +83,6 @@ "@dimensiondev/type/no-instanceof-wrapper": "error", "@dimensiondev/type/no-wrapper-type-reference": "error", "@dimensiondev/unicode/specific-set": "error", - "@typescript-eslint/array-type": ["error", { "default": "array-simple" }], "@typescript-eslint/await-thenable": "error", "@typescript-eslint/no-base-to-string": "off", "@typescript-eslint/no-implied-eval": "error", diff --git a/packages/backup-format/src/utils/hex2buffer.ts b/packages/backup-format/src/utils/hex2buffer.ts index b4fa7099a733..4b8f76f2e0c2 100644 --- a/packages/backup-format/src/utils/hex2buffer.ts +++ b/packages/backup-format/src/utils/hex2buffer.ts @@ -22,7 +22,7 @@ export function hex2buffer(hexString: string, padded?: boolean) { } /** @internal */ -function concat(...buf: Array) { +function concat(...buf: (Uint8Array | number[])[]) { const res = new Uint8Array(sum(buf.map((item) => item.length))) let offset = 0 buf.forEach((item) => { diff --git a/packages/backup-format/src/version-1/index.ts b/packages/backup-format/src/version-1/index.ts index 4f001c0dc895..7abf0376c303 100644 --- a/packages/backup-format/src/version-1/index.ts +++ b/packages/backup-format/src/version-1/index.ts @@ -89,16 +89,16 @@ interface BackupJSONFileVersion1 { publicKey: EC_Public_JsonWebKey privateKey: EC_Private_JsonWebKey localKey: AESJsonWebKey - previousIdentifiers?: Array<{ network: string; userId: string }> + previousIdentifiers?: { network: string; userId: string }[] nickname?: string }> people?: Array<{ network: string userId: string publicKey: EC_Public_JsonWebKey - previousIdentifiers?: Array<{ network: string; userId: string }> + previousIdentifiers?: { network: string; userId: string }[] nickname?: string - groups?: Array<{ network: string; groupID: string; virtualGroupOwner: string | null }> + groups?: { network: string; groupID: string; virtualGroupOwner: string | null }[] // Note: those props are not existed in the backup, just to make the code more readable privateKey?: EC_Private_JsonWebKey diff --git a/packages/backup-format/src/version-2/index.ts b/packages/backup-format/src/version-2/index.ts index 7a9da8856975..2ed7c710d425 100644 --- a/packages/backup-format/src/version-2/index.ts +++ b/packages/backup-format/src/version-2/index.ts @@ -322,7 +322,7 @@ interface BackupJSONFileVersion2 { privateKey?: JsonWebKey localKey?: JsonWebKey nickname?: string - linkedProfiles: Array<[/** ProfileIdentifier.toText() */ string, LinkedProfileDetails]> + linkedProfiles: [/** ProfileIdentifier.toText() */ string, LinkedProfileDetails][] createdAt: number // Unix timestamp updatedAt: number // Unix timestamp }> @@ -345,7 +345,7 @@ interface BackupJSONFileVersion2 { postBy: string // ProfileIdentifier.toText() identifier: string // PostIVIdentifier.toText() postCryptoKey?: JsonWebKey - recipients: 'everyone' | Array<[/** ProfileIdentifier.toText() */ string, { reason: RecipientReasonJSON[] }]> + recipients: 'everyone' | [/** ProfileIdentifier.toText() */ string, { reason: RecipientReasonJSON[] }][] /** @deprecated */ recipientGroups: never[] foundAt: number // Unix timestamp diff --git a/packages/dashboard/src/components/CreateWalletForm/index.tsx b/packages/dashboard/src/components/CreateWalletForm/index.tsx index 2a5df398e1a0..ddb77638de16 100644 --- a/packages/dashboard/src/components/CreateWalletForm/index.tsx +++ b/packages/dashboard/src/components/CreateWalletForm/index.tsx @@ -31,11 +31,11 @@ const useStyles = makeStyles()((theme) => ({ // TODO: actions, and icon may be an img url export interface CreateWalletFormProps { - options: Array<{ + options: { label: string icon: React.ReactNode value: number - }> + }[] } export function CreateWalletForm(props: CreateWalletFormProps) { diff --git a/packages/dashboard/src/pages/Wallets/components/FungibleTokenTable/index.tsx b/packages/dashboard/src/pages/Wallets/components/FungibleTokenTable/index.tsx index e2236f600657..dd7a4a744d6a 100644 --- a/packages/dashboard/src/pages/Wallets/components/FungibleTokenTable/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/FungibleTokenTable/index.tsx @@ -125,7 +125,7 @@ export const FungibleTokenTable = memo(({ selectedChainId }) => export interface TokenTableUIProps { isLoading: boolean isEmpty: boolean - dataSource: Array> + dataSource: Web3Plugin.Asset[] onSwap(token: Web3Plugin.FungibleToken): void onSend(token: Web3Plugin.FungibleToken): void } diff --git a/packages/encryption/src/encryption/Decryption.ts b/packages/encryption/src/encryption/Decryption.ts index ba50cec0ba9f..ca41d207507e 100644 --- a/packages/encryption/src/encryption/Decryption.ts +++ b/packages/encryption/src/encryption/Decryption.ts @@ -167,7 +167,7 @@ async function* v38To40StaticECDH( } type StaticV38OrOlderECDH = { type: 'static-v38-or-older' - derive: (postKeyIV: Uint8Array) => Promise> + derive: (postKeyIV: Uint8Array) => Promise<(readonly [key: AESCryptoKey, iv: Uint8Array])[]> } type EphemeralECDH = { type: 'ephemeral' diff --git a/packages/encryption/src/encryption/v38-ecdh.ts b/packages/encryption/src/encryption/v38-ecdh.ts index 91e82cba52db..e01036308290 100644 --- a/packages/encryption/src/encryption/v38-ecdh.ts +++ b/packages/encryption/src/encryption/v38-ecdh.ts @@ -27,7 +27,7 @@ export async function deriveAESByECDH_version38OrOlderExtraSteps( deriveAESByECDH: (key: EC_Public_CryptoKey) => Promise, pub: EC_Public_CryptoKey, iv: Uint8Array, -): Promise> { +): Promise<(readonly [key: AESCryptoKey, iv: Uint8Array])[]> { const deriveResult = await deriveAESByECDH(pub) const extraSteps = deriveResult.map(async (key) => { const derivedKeyRaw = await crypto.subtle.exportKey('raw', key) diff --git a/packages/injected-script/main/EventListenerPatch/capture.ts b/packages/injected-script/main/EventListenerPatch/capture.ts index 30c231554d85..a70a3e4e0556 100644 --- a/packages/injected-script/main/EventListenerPatch/capture.ts +++ b/packages/injected-script/main/EventListenerPatch/capture.ts @@ -1,7 +1,7 @@ import { clone_into, redefineEventTargetPrototype, unwrapXRay_CPPBindingObject } from '../utils' import { apply, error, no_xray_Proxy, warn, xray_Map } from '../intrinsic' -const CapturingEvents: Set = new Set(['keyup', 'input', 'paste', 'change'] as Array) +const CapturingEvents: Set = new Set(['keyup', 'input', 'paste', 'change'] as (keyof DocumentEventMap)[]) type EventListenerDescriptor = { once: boolean; passive: boolean; capture: boolean } const CapturedListeners = new WeakMap>>() diff --git a/packages/mask/background/database/avatar-cache/avatar.ts b/packages/mask/background/database/avatar-cache/avatar.ts index cf993a959ba3..1488e8bf04f1 100644 --- a/packages/mask/background/database/avatar-cache/avatar.ts +++ b/packages/mask/background/database/avatar-cache/avatar.ts @@ -19,7 +19,7 @@ async function nativeImpl(identifiers: IdentifierWithAvatar[]): Promise> { - const promises: Array> = [] + const promises: Promise[] = [] const map = new Map() const t = createTransaction(await createAvatarDBAccess(), 'readonly')('avatars') diff --git a/packages/mask/background/database/post/dbType.ts b/packages/mask/background/database/post/dbType.ts index 890481c1d85a..4ccf9e3490ad 100644 --- a/packages/mask/background/database/post/dbType.ts +++ b/packages/mask/background/database/post/dbType.ts @@ -7,7 +7,7 @@ export declare namespace PostDB_HistoryTypes { postBy: { userId: string; network: string } | undefined identifier: string recipientGroups?: unknown - recipients?: Array<{ userId: string; network: string }> + recipients?: { userId: string; network: string }[] foundAt: Date postCryptoKey?: CryptoKey } diff --git a/packages/mask/background/database/utils/openDB.ts b/packages/mask/background/database/utils/openDB.ts index 4c5c9fcc5e65..1581315ca75b 100644 --- a/packages/mask/background/database/utils/openDB.ts +++ b/packages/mask/background/database/utils/openDB.ts @@ -109,7 +109,7 @@ export function createDBAccessWithAsyncUpgrade> = Array>, + TxStores extends StoreNames[] = StoreNames[], StoreName extends StoreNames = StoreNames, Writable extends boolean = boolean, > extends Pick< @@ -170,14 +170,14 @@ export interface IDBPSafeObjectStore< } export type IDBPSafeTransaction< DBTypes extends DBSchema, - TxStores extends Array>, + TxStores extends StoreNames[], Mode extends IDBTransactionMode = 'readonly', > = Omit, 'mode' | 'objectStoreNames' | 'objectStore' | 'store'> & { readonly objectStoreNames: TypedDOMStringList & string> readonly mode: IDBTransactionMode readonly __writable__?: Mode extends 'readwrite' ? true : boolean readonly __stores__?: Record< - TxStores extends ReadonlyArray + TxStores extends readonly (infer ValueOfUsedStoreName)[] ? ValueOfUsedStoreName extends string | number | symbol ? ValueOfUsedStoreName : never @@ -194,7 +194,7 @@ export function createTransaction> = []>(...storeNames: UsedStoreName) => { + return [] = []>(...storeNames: UsedStoreName) => { return db.transaction(storeNames, mode) as IDBPSafeTransaction } } diff --git a/packages/mask/background/services/__utils__/convert.ts b/packages/mask/background/services/__utils__/convert.ts index 88814d3f4c27..dcbb60a43f30 100644 --- a/packages/mask/background/services/__utils__/convert.ts +++ b/packages/mask/background/services/__utils__/convert.ts @@ -25,8 +25,8 @@ export function toProfileInformation(profiles: ProfileRecord[]) { /** @internal */ export function toPersonaInformation(personas: PersonaRecord[], t: FullPersonaDBTransaction<'readonly'>) { const personaInfo: PersonaInformation[] = [] - const dbQueryPass2: Array> = [] - const dbQuery: Array> = personas.map(async (persona) => { + const dbQueryPass2: Promise[] = [] + const dbQuery: Promise[] = personas.map(async (persona) => { const map: ProfileInformation[] = [] personaInfo.push({ nickname: persona.nickname, diff --git a/packages/mask/background/services/backup/restore.ts b/packages/mask/background/services/backup/restore.ts index 4471113809e9..4153d80322c8 100644 --- a/packages/mask/background/services/backup/restore.ts +++ b/packages/mask/background/services/backup/restore.ts @@ -44,7 +44,7 @@ export async function addUnconfirmedBackup(raw: string): Promise }> { +): Promise { if (!unconfirmedBackup.has(id)) return undefined const backup = unconfirmedBackup.get(id)! return { diff --git a/packages/mask/background/services/helper/deprecated-storage.ts b/packages/mask/background/services/helper/deprecated-storage.ts index a55a66364678..9e618ad9e031 100644 --- a/packages/mask/background/services/helper/deprecated-storage.ts +++ b/packages/mask/background/services/helper/deprecated-storage.ts @@ -5,7 +5,7 @@ import { timeout } from '@dimensiondev/kit' * Make sure that the storage is used serially. */ class MutexStorage { - private tasks: Array<() => void> = [] + private tasks: (() => void)[] = [] private locked = false private lock() { diff --git a/packages/mask/src/UIRoot.tsx b/packages/mask/src/UIRoot.tsx index 9d7c5eefe82b..e820a9a59f6a 100644 --- a/packages/mask/src/UIRoot.tsx +++ b/packages/mask/src/UIRoot.tsx @@ -16,7 +16,7 @@ import { isTwitter } from './social-network-adaptor/twitter.com/base' import { MaskThemeProvider } from '@masknet/theme' const identity = (jsx: React.ReactNode) => jsx as JSX.Element -function compose(init: React.ReactNode, ...f: Array<(children: React.ReactNode) => JSX.Element>) { +function compose(init: React.ReactNode, ...f: ((children: React.ReactNode) => JSX.Element)[]) { // eslint-disable-next-line unicorn/no-array-reduce return f.reduceRight((prev, curr) => curr(prev), <>{init}) } diff --git a/packages/mask/src/components/InjectedComponents/DecryptedPost/DecryptedPost.tsx b/packages/mask/src/components/InjectedComponents/DecryptedPost/DecryptedPost.tsx index 04c7deb6aa61..1ab0de6a8474 100644 --- a/packages/mask/src/components/InjectedComponents/DecryptedPost/DecryptedPost.tsx +++ b/packages/mask/src/components/InjectedComponents/DecryptedPost/DecryptedPost.tsx @@ -15,7 +15,7 @@ import { type PostContext, usePostInfoDetails, usePostInfo } from '@masknet/plug import { Some } from 'ts-results' function progressReducer( - state: Array<{ key: string; progress: SuccessDecryption | FailureDecryption | DecryptionProgress }>, + state: { key: string; progress: SuccessDecryption | FailureDecryption | DecryptionProgress }[], payload: { type: 'refresh' key: string diff --git a/packages/mask/src/components/shared/AbstractTab.tsx b/packages/mask/src/components/shared/AbstractTab.tsx index fc124d5bbcfc..6b6d5c8dbc73 100644 --- a/packages/mask/src/components/shared/AbstractTab.tsx +++ b/packages/mask/src/components/shared/AbstractTab.tsx @@ -23,13 +23,11 @@ interface TabPanelProps extends BoxProps { export interface AbstractTabProps extends withClasses<'tab' | 'tabs' | 'tabPanel' | 'indicator' | 'focusTab' | 'tabPaper' | 'flexContainer'> { - tabs: Array< - Omit & { - cb?: () => void - disableFocusRipple?: boolean - disableRipple?: boolean - } - > + tabs: (Omit & { + cb?: () => void + disableFocusRipple?: boolean + disableRipple?: boolean + })[] state?: readonly [number, (next: number) => void] index?: number disableFocusRipple?: boolean diff --git a/packages/mask/src/database/helpers/pagination.ts b/packages/mask/src/database/helpers/pagination.ts index ea6f4619e7c6..9d267b7a5ca3 100644 --- a/packages/mask/src/database/helpers/pagination.ts +++ b/packages/mask/src/database/helpers/pagination.ts @@ -3,7 +3,7 @@ import type { IDBPSafeTransaction } from '../../../background/database/utils/ope export async function queryTransactionPaged< DBType extends DBSchema, - TxStores extends Array>, + TxStores extends StoreNames[], Mode extends 'readonly' | 'readwrite', RecordType extends IDBPCursorWithValueIteratorValue['value'], >( diff --git a/packages/mask/src/extension/background-script/EthereumServices/nonce.ts b/packages/mask/src/extension/background-script/EthereumServices/nonce.ts index 54a828312be7..4963d8a79965 100644 --- a/packages/mask/src/extension/background-script/EthereumServices/nonce.ts +++ b/packages/mask/src/extension/background-script/EthereumServices/nonce.ts @@ -7,7 +7,7 @@ class NonceManager { constructor(private address: string) {} private nonce = NonceManager.INITIAL_NONCE private locked = false - private tasks: Array<() => void> = [] + private tasks: (() => void)[] = [] private lock() { this.locked = true diff --git a/packages/mask/src/extension/background-script/EthereumServices/providers/WalletConnect.ts b/packages/mask/src/extension/background-script/EthereumServices/providers/WalletConnect.ts index 14e20bc09ccb..b5f1133b1544 100644 --- a/packages/mask/src/extension/background-script/EthereumServices/providers/WalletConnect.ts +++ b/packages/mask/src/extension/background-script/EthereumServices/providers/WalletConnect.ts @@ -92,10 +92,10 @@ const onConnect = () => onUpdate(null) const onUpdate = async ( error: Error | null, payload?: { - params: Array<{ + params: { chainId: number accounts: string[] - }> + }[] }, ) => { if (error) return diff --git a/packages/mask/src/extension/background-script/EthereumServices/rpc/abi.ts b/packages/mask/src/extension/background-script/EthereumServices/rpc/abi.ts index 0bf230349bc6..5460b661eaa2 100644 --- a/packages/mask/src/extension/background-script/EthereumServices/rpc/abi.ts +++ b/packages/mask/src/extension/background-script/EthereumServices/rpc/abi.ts @@ -16,10 +16,10 @@ const coder = ABICoder as unknown as ABICoder.AbiCoder type InternalItem = { name: string - parameters: Array<{ + parameters: { name: string type: string - }> + }[] } const ABI_MAP: Map = new Map() diff --git a/packages/mask/src/extension/popups/pages/Wallet/Transfer/Prior1559Transfer.tsx b/packages/mask/src/extension/popups/pages/Wallet/Transfer/Prior1559Transfer.tsx index 10ef1fda1fa4..1bfc6b0934a3 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/Transfer/Prior1559Transfer.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/Transfer/Prior1559Transfer.tsx @@ -146,7 +146,7 @@ const useStyles = makeStyles()({ export interface Prior1559TransferProps { selectedAsset?: Asset - otherWallets: Array<{ name: string; address: string }> + otherWallets: { name: string; address: string }[] openAssetMenu: (anchorElOrEvent: HTMLElement | SyntheticEvent) => void } diff --git a/packages/mask/src/extension/popups/pages/Wallet/Transfer/Transfer1559.tsx b/packages/mask/src/extension/popups/pages/Wallet/Transfer/Transfer1559.tsx index b250aa196786..7cbfe4f51144 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/Transfer/Transfer1559.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/Transfer/Transfer1559.tsx @@ -176,7 +176,7 @@ const useStyles = makeStyles()({ const MIN_GAS_LIMIT = 21000 export interface Transfer1559Props { selectedAsset?: Asset - otherWallets: Array<{ name: string; address: string }> + otherWallets: { name: string; address: string }[] openAssetMenu: (anchorElOrEvent: HTMLElement | SyntheticEvent) => void } diff --git a/packages/mask/src/extension/popups/pages/Wallet/components/DeriveWalletTable/index.tsx b/packages/mask/src/extension/popups/pages/Wallet/components/DeriveWalletTable/index.tsx index 0c625ce957aa..c5fd78aead04 100644 --- a/packages/mask/src/extension/popups/pages/Wallet/components/DeriveWalletTable/index.tsx +++ b/packages/mask/src/extension/popups/pages/Wallet/components/DeriveWalletTable/index.tsx @@ -41,7 +41,7 @@ const useStyles = makeStyles()({ export interface DeriveWalletTableProps { loading: boolean - dataSource?: Array<{ address: string; added: boolean; selected: boolean }> + dataSource?: { address: string; added: boolean; selected: boolean }[] onCheck: (checked: boolean, index: number) => void confirmLoading: boolean } diff --git a/packages/mask/src/plugins/Collectible/types/opensea.ts b/packages/mask/src/plugins/Collectible/types/opensea.ts index 929bccf9b03d..98bbd2557b12 100644 --- a/packages/mask/src/plugins/Collectible/types/opensea.ts +++ b/packages/mask/src/plugins/Collectible/types/opensea.ts @@ -216,10 +216,10 @@ export interface OpenSeaResponse extends Asset { background_color: string | null transfer_fee: string | null transfer_fee_payment_token: OpenSeaFungibleToken | null - top_ownerships: Array<{ + top_ownerships: { owner: OpenSeaCustomAccount quantity: string - }> + }[] creator: OpenSeaCustomAccount endTime: string } diff --git a/packages/mask/src/plugins/Collectible/types/rarible.ts b/packages/mask/src/plugins/Collectible/types/rarible.ts index 772dc83e6877..28387ada41c6 100644 --- a/packages/mask/src/plugins/Collectible/types/rarible.ts +++ b/packages/mask/src/plugins/Collectible/types/rarible.ts @@ -60,10 +60,10 @@ export interface Creator { export interface Meta { name: string description: string - attributes: Array<{ + attributes: { key: string value: string - }> + }[] image: { meta: { PREVIEW: { diff --git a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts index 31feb1eb43ff..0b11a8f2617e 100644 --- a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts +++ b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts @@ -136,13 +136,13 @@ export const getFungibleAssetsFn = const tokenUnavailableFromDebankResults = (await Promise.allSettled(allRequest)) .map((x) => (x.status === 'fulfilled' ? x.value : null)) - .filter((x) => Boolean(x)) as Array<{ + .filter((x) => Boolean(x)) as { chainId: ChainId balance: string price: PriceRecord - }> + }[] - const nativeTokens: Array> = networks + const nativeTokens: Web3Plugin.Asset[] = networks .filter( (t) => t.isMainnet && diff --git a/packages/mask/src/plugins/FindTruman/SNSAdaptor/ConstPromise.ts b/packages/mask/src/plugins/FindTruman/SNSAdaptor/ConstPromise.ts index 1c654cd8ab02..0d303203dda1 100644 --- a/packages/mask/src/plugins/FindTruman/SNSAdaptor/ConstPromise.ts +++ b/packages/mask/src/plugins/FindTruman/SNSAdaptor/ConstPromise.ts @@ -20,8 +20,8 @@ export default class FindTrumanConstPromise { value?: FindTrumanConst err?: any - successCallback: Array<(value?: FindTrumanConst) => void> = [] - failCallback: Array<(err: any) => void> = [] + successCallback: ((value?: FindTrumanConst) => void)[] = [] + failCallback: ((err: any) => void)[] = [] resolve = (value: FindTrumanConst) => { if (this.status !== Status.PENDING) return diff --git a/packages/mask/src/plugins/FindTruman/types.ts b/packages/mask/src/plugins/FindTruman/types.ts index 92ead19e5538..349cd201ae53 100644 --- a/packages/mask/src/plugins/FindTruman/types.ts +++ b/packages/mask/src/plugins/FindTruman/types.ts @@ -235,7 +235,7 @@ export interface SubmitPollParams { export interface SubmitCompletionParams { timestamp: number quesId: string - answers: Array<{ id: string; answer: string }> + answers: { id: string; answer: string }[] } export enum ClueConditionType { diff --git a/packages/mask/src/plugins/Gitcoin/hooks/useDonateCallback.ts b/packages/mask/src/plugins/Gitcoin/hooks/useDonateCallback.ts index c85572035151..66e006227cc1 100644 --- a/packages/mask/src/plugins/Gitcoin/hooks/useDonateCallback.ts +++ b/packages/mask/src/plugins/Gitcoin/hooks/useDonateCallback.ts @@ -24,7 +24,7 @@ export function useDonateCallback(address: string, amount: string, token?: Fungi const account = useAccount() - const donations = useMemo((): Array<[string, string, string]> => { + const donations = useMemo((): [string, string, string][] => { if (!address || !token) return [] if (!GITCOIN_ETH_ADDRESS || !GITCOIN_TIP_PERCENTAGE) return [] const tipAmount = new BigNumber(GITCOIN_TIP_PERCENTAGE / 100).multipliedBy(amount) diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/NftAirdropCard.tsx b/packages/mask/src/plugins/ITO/SNSAdaptor/NftAirdropCard.tsx index 240ddc8a2edc..7190867404a9 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/NftAirdropCard.tsx +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/NftAirdropCard.tsx @@ -159,13 +159,13 @@ const useStyles = makeStyles()((theme) => ({ })) interface NftAirdropCardProps { - campaignInfos: Array<{ + campaignInfos: { campaignInfo: CampaignInfo claimableInfo: { claimable: boolean claimed: boolean } - }> + }[] loading: boolean retry: () => void } diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useFill.ts b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useFill.ts index e65395a050c6..5f739678c5bc 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useFill.ts +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useFill.ts @@ -49,7 +49,7 @@ type paramsObjType = { total: string limit: string qualificationAddress: string - exchangeAmountsDivided: Array + exchangeAmountsDivided: (readonly [BigNumber, BigNumber])[] now: number invalidTokenAt: number exchangeAmounts: string[] diff --git a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useRegion.ts b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useRegion.ts index 04de368b83af..e283feedbd78 100644 --- a/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useRegion.ts +++ b/packages/mask/src/plugins/ITO/SNSAdaptor/hooks/useRegion.ts @@ -300,9 +300,9 @@ export function useIPRegion(): AsyncStateRetry { return useAsyncRetry(IPGeoResolver) } -export function useRegionList(): Region[] { +export function useRegionList(): Array { // TODO return name by i18n - return regions as Region[] + return regions as Array } export function useRegionSelect(initRegionCodes?: RegionCode[]) { diff --git a/packages/mask/src/plugins/ITO/Worker/apis/spaceStationGalaxy.ts b/packages/mask/src/plugins/ITO/Worker/apis/spaceStationGalaxy.ts index 9380fb990c71..9a3cc8b4a9c6 100644 --- a/packages/mask/src/plugins/ITO/Worker/apis/spaceStationGalaxy.ts +++ b/packages/mask/src/plugins/ITO/Worker/apis/spaceStationGalaxy.ts @@ -58,7 +58,7 @@ export async function getCampaignInfo(id: number): Promise { endTime: number startTime: number gamification: { - nfts: Array<{ nft: { image: string } }> + nfts: { nft: { image: string } }[] } } }>(` diff --git a/packages/mask/src/plugins/ITO/Worker/apis/subgraph.ts b/packages/mask/src/plugins/ITO/Worker/apis/subgraph.ts index 9cba129fa129..4f6ab889688c 100644 --- a/packages/mask/src/plugins/ITO/Worker/apis/subgraph.ts +++ b/packages/mask/src/plugins/ITO/Worker/apis/subgraph.ts @@ -68,7 +68,7 @@ async function fetchFromMarketSubgraph(query: string, chainId?: ChainId) { export async function getTradeInfo(pid: string, trader: string) { const data = await fetchFromMarketSubgraph<{ - buyInfos: Array<{ + buyInfos: { buyer: { address: string name: string @@ -77,23 +77,23 @@ export async function getTradeInfo(pid: string, trader: string) { amount: string amount_sold: string amount_bought: string - }> - sellInfos: Array<{ + }[] + sellInfos: { buyer: { address: string name: string } token: JSON_PayloadOutMask['token'] amount: string - }> - destructInfos: Array<{ + }[] + destructInfos: { buyer: { address: string name: string } token: JSON_PayloadOutMask['token'] amount: string - }> + }[] }>(` { buyInfos (where: { pool: "${pid.toLowerCase()}", buyer: "${trader.toLowerCase()}" }) { @@ -147,12 +147,12 @@ export async function getPool(pid: string) { export async function getAllPoolsAsSeller(address: string, page: number, chainId: ChainId) { const data = await fetchFromMarketSubgraph<{ - sellInfos: Array<{ + sellInfos: { pool: JSON_PayloadOutMask & { exchange_in_volumes: string[] exchange_out_volumes: string[] } - }> + }[] }>( ` { @@ -183,12 +183,12 @@ export async function getAllPoolsAsSeller(address: string, page: number, chainId export async function getAllPoolsAsBuyer(address: string, chainId: ChainId) { const data = await fetchFromMarketSubgraph<{ - buyInfos: Array<{ + buyInfos: { pool: JSON_PayloadOutMask & { exchange_in_volumes: string[] exchange_out_volumes: string[] } - }> + }[] }>( ` { diff --git a/packages/mask/src/plugins/ITO/types.ts b/packages/mask/src/plugins/ITO/types.ts index 7e7649c54dae..abe216b9556f 100644 --- a/packages/mask/src/plugins/ITO/types.ts +++ b/packages/mask/src/plugins/ITO/types.ts @@ -57,7 +57,7 @@ export interface JSON_PayloadOutMask extends Omit { token: string - exchange_tokens: Array<{ address: string }> + exchange_tokens: { address: string }[] } export enum ITO_Status { @@ -113,7 +113,7 @@ export interface CampaignInfo { chain: string endTime: number startTime: number - nfts: Array<{ image: string }> + nfts: { image: string }[] } export interface ClaimParams { diff --git a/packages/mask/src/plugins/MaskBox/type.ts b/packages/mask/src/plugins/MaskBox/type.ts index 063518d7aac7..ac12d96c65a3 100644 --- a/packages/mask/src/plugins/MaskBox/type.ts +++ b/packages/mask/src/plugins/MaskBox/type.ts @@ -76,8 +76,8 @@ export interface BoxMetadata { name: string mediaType: MediaType mediaUrl: string - activities: Array<{ + activities: { title: string body: string - }> + }[] } diff --git a/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts b/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts index 33d07a7d27e7..c3a96cc598f8 100644 --- a/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts +++ b/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts @@ -57,7 +57,7 @@ const RED_PACKET_FIELDS = ` type RedpacketFromSubgraphType = { chain_id: ChainId - claimers: Array<{ name: string; address: string }> + claimers: { name: string; address: string }[] contract_address: string contract_version: number block_number: number diff --git a/packages/mask/src/plugins/RedPacket/types.ts b/packages/mask/src/plugins/RedPacket/types.ts index 4d94b4e98a59..824649e80d42 100644 --- a/packages/mask/src/plugins/RedPacket/types.ts +++ b/packages/mask/src/plugins/RedPacket/types.ts @@ -62,7 +62,7 @@ export interface RedPacketJSONPayload extends RedPacketBasic { token_type?: EthereumTokenType.Native | EthereumTokenType.ERC20 token?: FungibleTokenDetailed token_address?: string - claimers?: Array<{ address: string; name: string }> + claimers?: { address: string; name: string }[] total_remaining?: string } @@ -126,10 +126,10 @@ export interface NftRedPacketSubgraphInMask extends Omit + }[] creator: { name: string address: string diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index 83f06963c5e3..4f800312198b 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -3,14 +3,14 @@ import { ChainId, createERC20Tokens, createNativeToken, FungibleTokenDetailed } export const SAVINGS_PLUGIN_NAME = 'Savings' export const SAVINGS_PLUGIN_ID = 'com.savings' -export const LDO_PAIRS: Array<[FungibleTokenDetailed, FungibleTokenDetailed]> = [ +export const LDO_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ [ createNativeToken(ChainId.Mainnet), createERC20Tokens('LDO_stETH_ADDRESS', 'Liquid staked Ether 2.0', 'stETH', 18)[ChainId.Mainnet], ], ] -export const AAVE_PAIRS: Array<[FungibleTokenDetailed, FungibleTokenDetailed]> = [ +export const AAVE_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ [ createERC20Tokens('USDT_ADDRESS', 'Tether USD', 'USDT', 6)[ChainId.Mainnet], createERC20Tokens('aUSDT_ADDRESS', 'Aave Interest bearing USDT', 'aUSDT', 6)[ChainId.Mainnet], diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 9290417d100f..2c684f3d64e9 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -78,13 +78,13 @@ export class AAVEProtocol implements SavingsProtocol { }) const fullResponse: { data: { - reserves: Array<{ + reserves: { id: string name: string decimals: number underlyingAsset: string liquidityRate: number - }> + }[] } } = await response.json() const liquidityRate = +fullResponse.data.reserves[0].liquidityRate @@ -129,11 +129,11 @@ export class AAVEProtocol implements SavingsProtocol { const fullResponse: { data: { - reserves: Array<{ + reserves: { aToken: { id: string } - }> + }[] } } = await response.json() diff --git a/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts b/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts index 5f266290aedf..64411842eb66 100644 --- a/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts +++ b/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts @@ -113,7 +113,7 @@ export async function getScores( space: string, strategies: Strategy[], ) { - const scores: Array<{ [key in string]: number }> = await ss.utils.getScores( + const scores: { [key in string]: number }[] = await ss.utils.getScores( space, strategies, network, diff --git a/packages/mask/src/plugins/Snapshot/types.ts b/packages/mask/src/plugins/Snapshot/types.ts index d57fded9f0a8..5959e80fad7d 100644 --- a/packages/mask/src/plugins/Snapshot/types.ts +++ b/packages/mask/src/plugins/Snapshot/types.ts @@ -89,11 +89,11 @@ export interface VoteItem { choice: string | undefined totalWeight: number | undefined choices: - | Array<{ + | { index: number weight: number name: string - }> + }[] | undefined address: string authorIpfsHash: string @@ -115,10 +115,10 @@ export type VoteItemList = { export interface ProposalResult { choice: string - powerDetail: Array<{ + powerDetail: { power: number name: string - }> + }[] power: number percentage: number } diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx index 5193d749fe21..7e77157fcb48 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx @@ -63,7 +63,7 @@ export function CoinMetadataTable(props: CoinMetadataTableProps) { ['Tech Docs', trending.coin.tech_docs_urls], ['Source Code', trending.coin.source_code_urls], ['Community', trending.coin.community_urls], - ] as Array<[string, string[] | undefined]> + ] as [string, string[] | undefined][] return ( diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx index baae9010c044..20f7dca725ae 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx @@ -15,7 +15,7 @@ const DEFAULT_DIMENSION: Dimension = { } export interface PriceChartProps extends withClasses<'root'> { - data: Array<{ date: Date; value: number }> + data: { date: Date; value: number }[] width?: number height?: number currency: Currency diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx index 77b758e5c011..21e3693aae00 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx @@ -56,7 +56,7 @@ export function PriceChangedTable({ market }: PriceChangedTableProps) { }, ] - const filteredRecords = records.filter((record) => typeof record.percentage === 'number') as Array> + const filteredRecords = records.filter((record) => typeof record.percentage === 'number') as Required[] return ( diff --git a/packages/mask/src/plugins/Trader/apis/LBP/index.ts b/packages/mask/src/plugins/Trader/apis/LBP/index.ts index 5f3aa16d4f09..6f9e848c3aa2 100644 --- a/packages/mask/src/plugins/Trader/apis/LBP/index.ts +++ b/packages/mask/src/plugins/Trader/apis/LBP/index.ts @@ -18,10 +18,10 @@ async function fetchFromBalancerPoolSubgraph(query: string) { export async function fetchLBP_PoolsByTokenAddress(address: string) { const data = await fetchFromBalancerPoolSubgraph<{ - pools: Array<{ + pools: { id: string createTime: number - }> + }[] }>(` { pools( @@ -53,7 +53,7 @@ export async function fetchLBP_PoolTokenPrices(poolId: string, address: string, } `, ) - const data = await fetchFromBalancerPoolSubgraph>>(` + const data = await fetchFromBalancerPoolSubgraph>(` query tokenPrices { ${queries.join('\n')} } diff --git a/packages/mask/src/plugins/Trader/apis/coingecko/index.ts b/packages/mask/src/plugins/Trader/apis/coingecko/index.ts index a0735a045a5e..9c73bf402fee 100644 --- a/packages/mask/src/plugins/Trader/apis/coingecko/index.ts +++ b/packages/mask/src/plugins/Trader/apis/coingecko/index.ts @@ -77,7 +77,7 @@ export interface CoinInfo { platforms: Record name: string symbol: string - tickers: Array<{ + tickers: { base: string target: string market: { @@ -108,7 +108,7 @@ export interface CoinInfo { trade_url: string coin_id: string target_coin_id?: string - }> + }[] } export async function getCoinInfo(coinId: string) { diff --git a/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts b/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts index a59243a21705..959e6798fd54 100644 --- a/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts +++ b/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts @@ -20,14 +20,14 @@ export async function fetchLatestBlocks() { type status = { synced: string health: string - chains: Array<{ + chains: { chainHeadBlock: { number: number } latestBlock: { number: number } - }> + }[] } const response = await fetchFromUniswapV2Health<{ indexingStatusForCurrentVersion: status diff --git a/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts b/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts index b70283cbc0ff..dd59d68420f9 100644 --- a/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts +++ b/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts @@ -182,7 +182,7 @@ export async function fetchTokenDayData(address: string, date: Date) { const utcTimestamp = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()) const data = await fetchFromUniswapV2Subgraph<{ data: { - tokenDayData: Array<{ + tokenDayData: { id: string date: number priceUSD: string @@ -192,7 +192,7 @@ export async function fetchTokenDayData(address: string, date: Date) { dailyVolumeETH: number dailyVolumeToken: number dailyVolumeUSD: number - }> + }[] } }>(` { @@ -317,7 +317,7 @@ export async function fetchPairData(pairAddress: string, blockNumber?: string) { */ export async function fetchPricesByBlocks( tokenAddress: string, - blocks: Array<{ blockNumber?: string; timestamp: number }>, + blocks: { blockNumber?: string; timestamp: number }[], skipCount = 50, ) { // avoiding request entity too large diff --git a/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts b/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts index 59296bedbfde..e6a8cd169539 100644 --- a/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts +++ b/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts @@ -5,7 +5,7 @@ import type { Dimension } from './useDimension' export function usePriceLineChart( svgRef: RefObject, - data: Array<{ date: Date; value: number }>, + data: { date: Date; value: number }[], dimension: Dimension, id: string, color = 'steelblue', diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts index ac7928175153..04220f26f898 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts @@ -24,8 +24,8 @@ export function useAllCurrencyCombinations(tradeProvider: TradeProvider, currenc return [...common, ...additionalA, ...additionalB].map((x) => toUniswapToken(chainId, x)) }, [chainId, chainIdValid, tokenA?.address, tokenB?.address]) - const basePairs: Array<[Token, Token]> = useMemo( - () => flatMap(bases, (base): Array<[Token, Token]> => bases.map((otherBase) => [base, otherBase])), + const basePairs: [Token, Token][] = useMemo( + () => flatMap(bases, (base): [Token, Token][] => bases.map((otherBase) => [base, otherBase])), [bases], ) @@ -73,7 +73,7 @@ export function useAllCommonPairs(tradeProvider: TradeProvider, currencyA?: Curr // only pass along valid pairs, non-duplicated pairs const allPairs_ = useMemo(() => { const filtered = new Map() - for (const [state, pair] of allPairs as Array<[PairState.EXISTS, Pair]>) { + for (const [state, pair] of allPairs as [PairState.EXISTS, Pair][]) { // filter out invalid pairs if (state !== PairState.EXISTS) continue if (!pair) continue diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts index 6d2dff736c20..b0d496ab37c2 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts @@ -11,10 +11,10 @@ function computeAllRoutes( pools: Pool[], chainId: number, currentPath: Pool[] = [], - allPaths: Array> = [], + allPaths: Route[] = [], startCurrencyIn: Currency = currencyIn, maxHops = 2, -): Array> { +): Route[] { const tokenIn = currencyIn?.wrapped const tokenOut = currencyOut?.wrapped if (!tokenIn || !tokenOut) throw new Error('Missing tokenIn/tokenOut') @@ -54,7 +54,7 @@ function computeAllRoutes( export function useAllV3Routes( currencyIn?: Currency, currencyOut?: Currency, -): { loading: boolean; routes: Array> } { +): { loading: boolean; routes: Route[] } { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const { pools, loading: poolsLoading } = useV3SwapPools(currencyIn, currencyOut) const singleHopOnly = useSingleHopOnly() diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts b/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts index 5614c9170847..79640191d3db 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts @@ -19,12 +19,12 @@ export enum PoolState { export function usePools( tradeProvider: TradeProvider, - poolKeys: Array<[Currency | undefined, Currency | undefined, FeeAmount | undefined]>, -): Array<[PoolState, Pool | null]> { + poolKeys: [Currency | undefined, Currency | undefined, FeeAmount | undefined][], +): [PoolState, Pool | null][] { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const context = useGetTradeContext(tradeProvider) - const transformed: Array<[Token, Token, FeeAmount] | null> = useMemo(() => { + const transformed: ([Token, Token, FeeAmount] | null)[] = useMemo(() => { return poolKeys.map(([currencyA, currencyB, feeAmount]) => { if (!chainId || !currencyA || !currencyB || !feeAmount) return null @@ -111,7 +111,7 @@ export function usePool( currencyB: Currency | undefined, feeAmount: FeeAmount | undefined, ): [PoolState, Pool | null] { - const poolKeys: Array<[Currency | undefined, Currency | undefined, FeeAmount | undefined]> = useMemo( + const poolKeys: [Currency | undefined, Currency | undefined, FeeAmount | undefined][] = useMemo( () => [[currencyA, currencyB, feeAmount]], [currencyA, currencyB, feeAmount], ) diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts index 059f68186f7b..4e8d6591b71a 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts @@ -19,7 +19,7 @@ export function useV3SwapPools( } { const allCurrencyCombinations = useAllCurrencyCombinations(TradeProvider.UNISWAP_V3, currencyIn, currencyOut) - const allCurrencyCombinationsWithAllFees: Array<[Token, Token, FeeAmount]> = useMemo( + const allCurrencyCombinationsWithAllFees: [Token, Token, FeeAmount][] = useMemo( () => allCurrencyCombinations.flatMap<[Token, Token, FeeAmount]>(([tokenA, tokenB]) => [ [tokenA, tokenB, FeeAmount.LOW], diff --git a/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts b/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts index c71eef46e687..bfa644cd3812 100644 --- a/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts +++ b/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts @@ -3,12 +3,12 @@ import { DataProvider } from '@masknet/public-api' const CURRENCIES_MAP: Record< DataProvider, | undefined - | Array<{ + | { id: string name: string symbol: string description: string - }> + }[] > = { [DataProvider.COIN_GECKO]: [ { diff --git a/packages/mask/src/plugins/Trader/types/0x.ts b/packages/mask/src/plugins/Trader/types/0x.ts index 5175a9d86ed0..5d7ad2e8c5f6 100644 --- a/packages/mask/src/plugins/Trader/types/0x.ts +++ b/packages/mask/src/plugins/Trader/types/0x.ts @@ -76,11 +76,11 @@ export interface SwapQuoteResponse { export interface SwapValidationErrorResponse { code: number reason: string - validationErrors: Array<{ + validationErrors: { code: number field: string reason: string - }> + }[] } export interface SwapServerErrorResponse { diff --git a/packages/mask/src/plugins/Trader/types/trader.ts b/packages/mask/src/plugins/Trader/types/trader.ts index 20fa860c5e49..956f1a8fc0f7 100644 --- a/packages/mask/src/plugins/Trader/types/trader.ts +++ b/packages/mask/src/plugins/Trader/types/trader.ts @@ -92,9 +92,7 @@ export interface TradeComputed { maximumSold: BigNumber minimumReceived: BigNumber fee: BigNumber - path?: Array< - Array | PartialRequired> - > + path?: (PartialRequired | PartialRequired)[][] trade_?: T } diff --git a/packages/mask/src/plugins/UnlockProtocol/Services.ts b/packages/mask/src/plugins/UnlockProtocol/Services.ts index 5a3329a0095d..f18ca77677b2 100644 --- a/packages/mask/src/plugins/UnlockProtocol/Services.ts +++ b/packages/mask/src/plugins/UnlockProtocol/Services.ts @@ -10,15 +10,15 @@ for (const [key, url] of Object.entries(graphEndpointKeyVal)) { } export interface verifyHolderResponse { - keyHolders: Array<{ - keys: Array<{ + keyHolders: { + keys: { expiration: number keyId: string lock: { address: string } - }> - }> + }[] + }[] } const verifyHolder = async (_lockAddress: string, _holder: string, _chain: number) => { diff --git a/packages/mask/src/plugins/Wallet/apis/ens.ts b/packages/mask/src/plugins/Wallet/apis/ens.ts index 48ec09c400c9..a422c0cdb61a 100644 --- a/packages/mask/src/plugins/Wallet/apis/ens.ts +++ b/packages/mask/src/plugins/Wallet/apis/ens.ts @@ -17,10 +17,10 @@ export async function fetchAddressNamesByTwitterId(twitterId: string) { if (!twitterId) return [] const data = await fetchFromENSTextResolverSubgraph<{ twitterHandle?: { - domains: Array<{ + domains: { id: string owner: string - }> + }[] } }>(` query twitterHandle { diff --git a/packages/mask/src/plugins/Wallet/services/wallet/index.ts b/packages/mask/src/plugins/Wallet/services/wallet/index.ts index 96c990f49f0c..29ef45a18c76 100644 --- a/packages/mask/src/plugins/Wallet/services/wallet/index.ts +++ b/packages/mask/src/plugins/Wallet/services/wallet/index.ts @@ -51,13 +51,11 @@ export async function getWallet(address?: string) { } export async function getWallets(providerType?: ProviderType): Promise< - Array< - Omit & { - configurable: boolean - hasStoredKeyInfo: boolean - hasDerivationPath: boolean - } - > + (Omit & { + configurable: boolean + hasStoredKeyInfo: boolean + hasDerivationPath: boolean + })[] > { if (hasNativeAPI) { if (providerType && providerType !== ProviderType.MaskWallet) return [] @@ -114,11 +112,11 @@ export async function getDerivableAccounts(mnemonic: string, page: number, pageS }) if (!imported?.StoredKey) throw new Error('Failed to import the wallet.') - const accounts: Array<{ + const accounts: { index: number address: string derivationPath: string - }> = [] + }[] = [] for (let i = pageSize * page; i < pageSize * (page + 1); i += 1) { const derivationPath = `${HD_PATH_WITHOUT_INDEX_ETHEREUM}/${i}` diff --git a/packages/mask/src/plugins/hooks/useLineChart.ts b/packages/mask/src/plugins/hooks/useLineChart.ts index 3555285d7133..bd35c37089db 100644 --- a/packages/mask/src/plugins/hooks/useLineChart.ts +++ b/packages/mask/src/plugins/hooks/useLineChart.ts @@ -5,7 +5,7 @@ import type { Dimension } from './useDimension' export function useLineChart( svgRef: RefObject, - data: Array<{ date: Date; value: number }>, + data: { date: Date; value: number }[], dimension: Dimension, id: string, opts: { color?: string; tickFormat?: string; formatTooltip?: Function }, diff --git a/packages/mask/src/plugins/hooks/usePriceLineChart.ts b/packages/mask/src/plugins/hooks/usePriceLineChart.ts index 89998fc0966b..f173a19c7e52 100644 --- a/packages/mask/src/plugins/hooks/usePriceLineChart.ts +++ b/packages/mask/src/plugins/hooks/usePriceLineChart.ts @@ -5,7 +5,7 @@ import { useLineChart } from './useLineChart' export function usePriceLineChart( svgRef: RefObject, - data: Array<{ date: Date; value: number }>, + data: { date: Date; value: number }[], dimension: Dimension, id: string, opts: { color?: string; sign?: string }, diff --git a/packages/mask/src/social-network/utils/create-post-context.ts b/packages/mask/src/social-network/utils/create-post-context.ts index 25650d2d0b90..240cf305a258 100644 --- a/packages/mask/src/social-network/utils/create-post-context.ts +++ b/packages/mask/src/social-network/utils/create-post-context.ts @@ -33,7 +33,7 @@ import { difference } from 'lodash-unified' export function createSNSAdaptorSpecializedPostContext(create: PostContextSNSActions) { return function createPostContext(opt: PostContextCreation): PostContext { - const cancel: Array = [] + const cancel: (Function | undefined)[] = [] opt.signal?.addEventListener('abort', () => cancel.forEach((fn) => fn?.())) // #region Mentioned links diff --git a/packages/mask/src/utils/hooks/useSuspense.ts b/packages/mask/src/utils/hooks/useSuspense.ts index 5b981f27dddd..9903775e2679 100644 --- a/packages/mask/src/utils/hooks/useSuspense.ts +++ b/packages/mask/src/utils/hooks/useSuspense.ts @@ -1,6 +1,6 @@ import { useUpdate } from 'react-use' -export function useSuspense( +export function useSuspense>( id: string, args: U, cache: Map] | [1, T] | [2, Error]>, diff --git a/packages/mask/src/utils/shadow-root/renderInShadowRoot.tsx b/packages/mask/src/utils/shadow-root/renderInShadowRoot.tsx index b43757e4740e..f0166037968c 100644 --- a/packages/mask/src/utils/shadow-root/renderInShadowRoot.tsx +++ b/packages/mask/src/utils/shadow-root/renderInShadowRoot.tsx @@ -2,7 +2,7 @@ import { createReactRootShadowedPartial, setupPortalShadowRoot, CSSVariableInjec import { MaskUIRoot } from '../../UIRoot' import { useClassicMaskSNSTheme } from '../theme' -const captureEvents: Array = [ +const captureEvents: (keyof HTMLElementEventMap)[] = [ 'paste', 'keydown', 'keypress', diff --git a/packages/plugin-infra/src/web3-types.ts b/packages/plugin-infra/src/web3-types.ts index 057cd24024b2..fcc289bd62a6 100644 --- a/packages/plugin-infra/src/web3-types.ts +++ b/packages/plugin-infra/src/web3-types.ts @@ -281,7 +281,7 @@ export declare namespace Web3Plugin { providerType: string, network: NetworkDescriptor, pagination?: Pagination, - ) => Promise>> + ) => Promise[]> /** Get non-fungible assets of given account. */ getNonFungibleAssets?: ( address: string, diff --git a/packages/plugins/Flow/src/apis/getFungibleAssets.ts b/packages/plugins/Flow/src/apis/getFungibleAssets.ts index 8888c2d0fb8f..a1335e23a821 100644 --- a/packages/plugins/Flow/src/apis/getFungibleAssets.ts +++ b/packages/plugins/Flow/src/apis/getFungibleAssets.ts @@ -103,14 +103,14 @@ export async function getFungibleAssets( provider: string, network: Web3Plugin.NetworkDescriptor, pagination?: Pagination, -): Promise>> { +): Promise[]> { const allSettled = await Promise.allSettled([ getAssetFLOW(network.chainId, address), getAssetFUSD(network.chainId, address), getAssetTether(network.chainId, address), ]) - return allSettled.map((x) => (x.status === 'fulfilled' ? x.value : null)).filter(Boolean) as Array< - Web3Plugin.Asset - > + return allSettled + .map((x) => (x.status === 'fulfilled' ? x.value : null)) + .filter(Boolean) as Web3Plugin.Asset[] } diff --git a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx index b012d9304989..3e6b365975ee 100644 --- a/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx +++ b/packages/plugins/RSS3/src/SNSAdaptor/components/DonationCard.tsx @@ -8,10 +8,10 @@ export interface DonationCardProps extends HTMLProps { imageUrl: string name: string contribCount: number - contribDetails: Array<{ + contribDetails: { token: string amount: string - }> + }[] } const useStyles = makeStyles()((theme) => ({ diff --git a/packages/plugins/RSS3/src/types.ts b/packages/plugins/RSS3/src/types.ts index fbd9d744ac23..5a94d76053a5 100644 --- a/packages/plugins/RSS3/src/types.ts +++ b/packages/plugins/RSS3/src/types.ts @@ -23,10 +23,10 @@ export interface GeneralAsset { animation_original_url?: string | null title?: string total_contribs?: number - token_contribs?: Array<{ + token_contribs?: { token: string amount: string - }> + }[] start_date?: string end_date?: string country?: string diff --git a/packages/plugins/Solana/src/apis/getFungibleAssets.ts b/packages/plugins/Solana/src/apis/getFungibleAssets.ts index fb8073a36ca9..7859f6a017ca 100644 --- a/packages/plugins/Solana/src/apis/getFungibleAssets.ts +++ b/packages/plugins/Solana/src/apis/getFungibleAssets.ts @@ -68,7 +68,7 @@ export async function getFungibleAssets( provider: string, network: Web3Plugin.NetworkDescriptor, pagination?: Pagination, -): Promise>> { +): Promise[]> { const allSettled = await Promise.allSettled([ getSolanaBalance(network.chainId, address).then((x) => [x]), getSplTokenList(network.chainId, address), @@ -77,5 +77,5 @@ export async function getFungibleAssets( return allSettled .map((x) => (x.status === 'fulfilled' ? x.value : null)) .flat() - .filter(Boolean) as Array> + .filter(Boolean) as Web3Plugin.Asset[] } diff --git a/packages/plugins/Solana/src/apis/shared.ts b/packages/plugins/Solana/src/apis/shared.ts index 20b57481355d..54aa78d0697e 100644 --- a/packages/plugins/Solana/src/apis/shared.ts +++ b/packages/plugins/Solana/src/apis/shared.ts @@ -49,7 +49,7 @@ export interface ProgramAccount { pubkey: string } -export type GetProgramAccountsResponse = RpcResponse +export type GetProgramAccountsResponse = RpcResponse> let id = 0 export async function requestRPC(chainId: ChainId, options: RpcOptions): Promise { diff --git a/packages/plugins/example/src/Worker/index.ts b/packages/plugins/example/src/Worker/index.ts index f336e4386a26..c9a0027ae6d5 100644 --- a/packages/plugins/example/src/Worker/index.ts +++ b/packages/plugins/example/src/Worker/index.ts @@ -10,7 +10,7 @@ interface File { interface Folder { type: 'folder' id: string - files: Array + files: File['id'][] } let storage: Plugin.Worker.DatabaseStorage | undefined const worker: Plugin.Worker.Definition = { diff --git a/packages/shared-base/src/Identifier/map.ts b/packages/shared-base/src/Identifier/map.ts index 18b4311d65c3..531ee0814f62 100644 --- a/packages/shared-base/src/Identifier/map.ts +++ b/packages/shared-base/src/Identifier/map.ts @@ -7,10 +7,10 @@ import { PostIVIdentifier as D } from './post-iv' type I = Iterable // you're free to add a new overload... -export function convertRawMapToIdentifierMap(it: I, ...of: Array): Map -export function convertRawMapToIdentifierMap(it: I, ...of: Array): Map -export function convertRawMapToIdentifierMap(it: I, ...of: Array): Map -export function convertRawMapToIdentifierMap(it: I, ...of: Array): Map +export function convertRawMapToIdentifierMap(it: I, ...of: typeof A[]): Map +export function convertRawMapToIdentifierMap(it: I, ...of: typeof B[]): Map +export function convertRawMapToIdentifierMap(it: I, ...of: typeof C[]): Map +export function convertRawMapToIdentifierMap(it: I, ...of: typeof D[]): Map export function convertRawMapToIdentifierMap(it: I, ...of: unknown[]): Map { const hasProfileIdentifier = of.includes(A) const hasECKeyIdentifier = of.includes(B) diff --git a/packages/shared-base/src/NextID/type.ts b/packages/shared-base/src/NextID/type.ts index e6ab5e2d52bc..17c8f914b586 100644 --- a/packages/shared-base/src/NextID/type.ts +++ b/packages/shared-base/src/NextID/type.ts @@ -61,7 +61,7 @@ export interface NextIDStoragePayload { } export interface NextIDStorageInfo { persona: string - proofs: Array> + proofs: NextIDStorageProofs[] } export interface NextIDStorageProofs { content: { diff --git a/packages/shared/src/UI/components/ConcealableTabs/index.tsx b/packages/shared/src/UI/components/ConcealableTabs/index.tsx index dc4c95a7ef59..6ea0aa321f2a 100644 --- a/packages/shared/src/UI/components/ConcealableTabs/index.tsx +++ b/packages/shared/src/UI/components/ConcealableTabs/index.tsx @@ -106,7 +106,7 @@ interface TabOption { } export interface ConcealableTabsProps extends Omit, 'onChange'> { - tabs: Array> + tabs: TabOption[] selectedId?: T onChange?(id: T): void tail?: ReactNode diff --git a/packages/shared/src/UI/components/MiniNetworkSelector/index.tsx b/packages/shared/src/UI/components/MiniNetworkSelector/index.tsx index aa64050dcd92..c3498dc4b812 100644 --- a/packages/shared/src/UI/components/MiniNetworkSelector/index.tsx +++ b/packages/shared/src/UI/components/MiniNetworkSelector/index.tsx @@ -44,13 +44,13 @@ export interface NetworkSelectorMinProps { ID: string chainId: number } | null - networks: Array<{ + networks: { ID: string isMainnet: boolean chainId: number icon: URL iconColor: string - }> + }[] onSelect(network: { chainId: number } | null): void hideAllNetworkButton?: boolean disabledNonCurrentNetwork?: boolean diff --git a/packages/theme/src/ShadowRoot/Contexts.ts b/packages/theme/src/ShadowRoot/Contexts.ts index 91515aa2e9b8..fef9cfa0b3d3 100644 --- a/packages/theme/src/ShadowRoot/Contexts.ts +++ b/packages/theme/src/ShadowRoot/Contexts.ts @@ -4,6 +4,6 @@ import type { StyleSheet } from './ShadowRootStyleSheet' /** @internal */ export const StyleSheetsContext = createContext(null!) /** @internal */ -export const PreventEventPropagationListContext = createContext>([]) +export const PreventEventPropagationListContext = createContext<(keyof HTMLElementEventMap)[]>([]) /** This context does not join any ShadowRoot related feature. */ export const DisableShadowRootContext = createContext(false) diff --git a/packages/theme/src/ShadowRoot/createReactRootShadowed.tsx b/packages/theme/src/ShadowRoot/createReactRootShadowed.tsx index 66949d641135..32535b1a52af 100644 --- a/packages/theme/src/ShadowRoot/createReactRootShadowed.tsx +++ b/packages/theme/src/ShadowRoot/createReactRootShadowed.tsx @@ -20,7 +20,7 @@ export interface CreateRenderInShadowRootHostConfig { * * ! This is not a security boundary ! */ - preventEventPropagationList: Array + preventEventPropagationList: (keyof HTMLElementEventMap)[] wrapJSX?(jsx: React.ReactChild): React.ReactChild } export interface ReactRootShadowed { diff --git a/packages/theme/src/Theme/Provider.tsx b/packages/theme/src/Theme/Provider.tsx index 7ab86e6dcacf..2260bdc1a4d2 100644 --- a/packages/theme/src/Theme/Provider.tsx +++ b/packages/theme/src/Theme/Provider.tsx @@ -2,7 +2,7 @@ import { CssBaseline, Theme, ThemeProvider } from '@mui/material' import { MaskIconPalette, MaskIconPaletteContext } from '@masknet/icons' import { CustomSnackbarProvider } from '../Components' -function compose(init: React.ReactNode, ...f: Array<(children: React.ReactNode) => JSX.Element>) { +function compose(init: React.ReactNode, ...f: ((children: React.ReactNode) => JSX.Element)[]) { // eslint-disable-next-line unicorn/no-array-reduce return f.reduceRight((prev, curr) => curr(prev), <>{init}) } diff --git a/packages/theme/src/UIHelper/custom-ui-helper.tsx b/packages/theme/src/UIHelper/custom-ui-helper.tsx index 233d13ffcf70..db8ed7aba8cd 100644 --- a/packages/theme/src/UIHelper/custom-ui-helper.tsx +++ b/packages/theme/src/UIHelper/custom-ui-helper.tsx @@ -11,7 +11,7 @@ export function useStylesExtends> | undefined>): Partial> { +export function mergeClasses(...args: (Partial> | undefined)[]): Partial> { args = args.filter(Boolean) if (args.length === 1) return args[0]! const result = {} as Partial> diff --git a/packages/theme/stories/utils/Material-UI.ts b/packages/theme/stories/utils/Material-UI.ts index 2bc1c3fd4dc3..94ef7291de68 100644 --- a/packages/theme/stories/utils/Material-UI.ts +++ b/packages/theme/stories/utils/Material-UI.ts @@ -2,9 +2,7 @@ import type { ButtonProps, SelectProps, TextFieldProps } from '@mui/material' import type { ArgType, ArgTypes } from '@storybook/addons' import { argsOfArr, ControlType } from './args' function enumIn(enums: { - [Prop in keyof T]?: ( - argsFromEnum: (enumString: Array>, type?: ControlType) => ArgType, - ) => ArgType + [Prop in keyof T]?: (argsFromEnum: (enumString: NonNullable[], type?: ControlType) => ArgType) => ArgType }): ArgTypes { for (const key of Object.keys(enums) as Array) { enums[key] = (enums[key] as any)(argsOfArr) diff --git a/packages/theme/stories/utils/args.ts b/packages/theme/stories/utils/args.ts index 9561b40cc1c1..01a6609863f2 100644 --- a/packages/theme/stories/utils/args.ts +++ b/packages/theme/stories/utils/args.ts @@ -1,5 +1,5 @@ export type ControlType = 'radio' | 'inline-radio' | 'check' | 'inline-check' | 'select' | 'multi-select' -export function argsOfArr(keys: Array>, type?: ControlType) { +export function argsOfArr(keys: NonNullable[], type?: ControlType) { if (type === undefined) { if (keys.length <= 6) type = 'inline-radio' else type = 'select' diff --git a/packages/typed-message/base/utils/extract.ts b/packages/typed-message/base/utils/extract.ts index 2e1e5ba38ddc..5a1220fe216a 100644 --- a/packages/typed-message/base/utils/extract.ts +++ b/packages/typed-message/base/utils/extract.ts @@ -27,10 +27,10 @@ export function extractTextFromTypedMessage( if (text.length) return Some(text.join(' ')) return None } -export function extractImageFromTypedMessage(message: TypedMessage | null): Array { +export function extractImageFromTypedMessage(message: TypedMessage | null): (string | Blob)[] { if (!message) return [] - const image: Array = [] + const image: (string | Blob)[] = [] function visitor(message: TypedMessage): void { if (isTypedMessageImage(message)) return void image.push(message.image) return forEachTypedMessageChild(message, visitor) diff --git a/packages/typed-message/base/utils/internal.ts b/packages/typed-message/base/utils/internal.ts index eda1b255c5ea..cd9523604cdb 100644 --- a/packages/typed-message/base/utils/internal.ts +++ b/packages/typed-message/base/utils/internal.ts @@ -8,11 +8,11 @@ export function createIsType(x: T['type'], version?: num } } /** @internal */ -export function composeSome(...fns: Array<(...args: Args) => boolean>) { +export function composeSome(...fns: ((...args: Args) => boolean)[]) { return (...args: Args) => fns.some((f) => f(...args)) } /** @internal */ -export function composeEvery(...fns: Array<(...args: Args) => boolean>) { +export function composeEvery(...fns: ((...args: Args) => boolean)[]) { return (...args: Args) => fns.every((f) => f(...args)) } diff --git a/packages/web3-constants/compile-constants.ts b/packages/web3-constants/compile-constants.ts index ef2c95494704..ab288a6150c3 100644 --- a/packages/web3-constants/compile-constants.ts +++ b/packages/web3-constants/compile-constants.ts @@ -11,7 +11,7 @@ async function compileConstants(folderPath: string, names: string[]) { for (const name of Object.keys(constants)) { const values = constants[name] const defaultValue = getDefaultValue(Object.values(values)[0]) - const pairs: Array<[string, unknown]> = [] + const pairs: [string, unknown][] = [] for (const name of names) { pairs.push([name, values[name] ?? defaultValue]) } diff --git a/packages/web3-contracts/compile-contracts.ts b/packages/web3-contracts/compile-contracts.ts index 494476eb1c5d..24911661fd24 100644 --- a/packages/web3-contracts/compile-contracts.ts +++ b/packages/web3-contracts/compile-contracts.ts @@ -6,7 +6,7 @@ import { run } from './utils' const ABIS_PATH = path.join(__dirname, 'abis') const GENERATED_PATH = path.join(__dirname, 'types') -async function replaceFileAll(file: string, pairs: Array<[string, string]>) { +async function replaceFileAll(file: string, pairs: [string, string][]) { let content = await fs.readFile(file, 'utf-8') for (const [pattern, value] of pairs) { content = content.replace(new RegExp(pattern, 'img'), value) diff --git a/packages/web3-providers/src/opensea/types.ts b/packages/web3-providers/src/opensea/types.ts index efd8ce281dc2..9ee7062c7b14 100644 --- a/packages/web3-providers/src/opensea/types.ts +++ b/packages/web3-providers/src/opensea/types.ts @@ -80,11 +80,11 @@ export interface OpenSeaCollection extends OpenSeaFees { wiki_link?: string safelist_request_status: string owned_asset_count: number - primary_asset_contracts: Array<{ + primary_asset_contracts: { address: string asset_contract_type: string symbol: string - }> + }[] } export interface OpenSeaResponse extends Asset { @@ -104,19 +104,19 @@ export interface OpenSeaResponse extends Asset { image_thumbnail_url: string opensea_link: string external_link: string - traits: Array<{ + traits: { trait_type: string value: string - }> + }[] num_sales: number last_sale: NonFungibleTokenAPI.AssetEvent | null background_color: string | null transfer_fee: string | null transfer_fee_payment_token: OpenSeaFungibleToken | null - top_ownerships: Array<{ + top_ownerships: { owner: OpenSeaCustomAccount quantity: string - }> + }[] creator: OpenSeaCustomAccount endTime: string } diff --git a/packages/web3-providers/src/rarible/index.ts b/packages/web3-providers/src/rarible/index.ts index cdd1b548266e..4d660764186e 100644 --- a/packages/web3-providers/src/rarible/index.ts +++ b/packages/web3-providers/src/rarible/index.ts @@ -36,7 +36,7 @@ async function fetchFromRarible(url: string, path: string, init?: RequestInit return response.json() as Promise } -function getProfilesFromRarible(addresses: Array) { +function getProfilesFromRarible(addresses: (string | undefined)[]) { return fetchFromRarible(RaribleMainnetURL, '/profiles/list', { method: 'POST', body: JSON.stringify(addresses), diff --git a/packages/web3-providers/src/rarible/types.ts b/packages/web3-providers/src/rarible/types.ts index 7616b1d8e9a1..d772dcabc1d0 100644 --- a/packages/web3-providers/src/rarible/types.ts +++ b/packages/web3-providers/src/rarible/types.ts @@ -58,10 +58,10 @@ export interface Creator { export interface Meta { name: string description: string - attributes: Array<{ + attributes: { key: string value: string - }> + }[] image?: { meta: { PREVIEW: { diff --git a/packages/web3-providers/src/types.ts b/packages/web3-providers/src/types.ts index ca204bd3db7e..e33ba8eed336 100644 --- a/packages/web3-providers/src/types.ts +++ b/packages/web3-providers/src/types.ts @@ -40,10 +40,10 @@ export namespace RSS3BaseAPI { animation_original_url?: string | null title?: string total_contribs?: number - token_contribs?: Array<{ + token_contribs?: { token: string amount: string - }> + }[] start_date?: string end_date?: string country?: string @@ -204,13 +204,13 @@ export namespace NonFungibleTokenAPI { collection_name: string animation_url?: string end_time: Date | null - order_payment_tokens: Array - offer_payment_tokens: Array + order_payment_tokens: (ERC20TokenDetailed | NativeTokenDetailed)[] + offer_payment_tokens: (ERC20TokenDetailed | NativeTokenDetailed)[] slug: string | null desktopOrder?: AssetOrder - top_ownerships: Array<{ + top_ownerships: { owner: AssetOwner - }> + }[] last_sale: AssetEvent | null response_: any } @@ -464,10 +464,10 @@ export namespace TwitterBaseAPI { name: string } } - traits: Array<{ + traits: { trait_type: string value: string - }> + }[] } } export interface AvatarInfo { diff --git a/packages/web3-shared/evm/constants/getContractOwnerDomain.ts b/packages/web3-shared/evm/constants/getContractOwnerDomain.ts index b38f5de4fe91..ae6757dc5d64 100644 --- a/packages/web3-shared/evm/constants/getContractOwnerDomain.ts +++ b/packages/web3-shared/evm/constants/getContractOwnerDomain.ts @@ -13,10 +13,7 @@ import RedPacket from '@masknet/web3-constants/evm/red-packet.json' import Trader from '@masknet/web3-constants/evm/trader.json' import { filter, flatten, pick, uniq, values } from 'lodash-unified' -const collect = >>( - data: T, - fields: Array, -): string[] => { +const collect = >>(data: T, fields: (keyof T)[]): string[] => { const groupedByFields = values(pick(data, fields)) const listOfAddresses = groupedByFields.map((v) => values(v)) const listOfAddress = flatten(listOfAddresses) diff --git a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts index 5577105a6757..6fad5daaf80e 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts @@ -25,10 +25,7 @@ export function useERC20TokenDetailed(address?: string, token?: Partial>, - _chainId?: ChainId, -) { +export function useFungibleTokensDetailed(listOfToken: Pick[], _chainId?: ChainId) { const currentChainId = useChainId() const chainId = _chainId ? _chainId : currentChainId const listOfAddress = useMemo(() => listOfToken.map((t) => t.address), [JSON.stringify(listOfToken)]) diff --git a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts index d3c38f381bfd..81a63449bb6c 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts @@ -12,9 +12,9 @@ import { EMPTY_LIST } from '@masknet/shared-base' export function useERC20TokensDetailedFromTokenLists( lists?: string[], keyword = '', - additionalTokens: Array = EMPTY_LIST, + additionalTokens: (ERC20TokenDetailed | NativeTokenDetailed)[] = EMPTY_LIST, targetChainId?: ChainId, -): AsyncStateRetry> { +): AsyncStateRetry<(ERC20TokenDetailed | NativeTokenDetailed)[]> { // #region fetch token lists const currentChainId = useChainId() const chainId = targetChainId ?? currentChainId diff --git a/packages/web3-shared/evm/hooks/useERC721TokenDetailed.ts b/packages/web3-shared/evm/hooks/useERC721TokenDetailed.ts index 41b177ef1d99..cc9397ca4313 100644 --- a/packages/web3-shared/evm/hooks/useERC721TokenDetailed.ts +++ b/packages/web3-shared/evm/hooks/useERC721TokenDetailed.ts @@ -39,7 +39,7 @@ export async function getERC721TokenDetailedFromOpensea( description: string image_url: string animation_url: string - top_ownerships: Array<{ owner: { address: string } }> + top_ownerships: { owner: { address: string } }[] } if (response.ok) { diff --git a/packages/web3-shared/evm/hooks/useMulticall.ts b/packages/web3-shared/evm/hooks/useMulticall.ts index f05a80aecb2a..323d362272e2 100644 --- a/packages/web3-shared/evm/hooks/useMulticall.ts +++ b/packages/web3-shared/evm/hooks/useMulticall.ts @@ -192,7 +192,7 @@ export function useMulticallStateDecoded< export function useSingleContractMultipleData( contract: T | null, names: K[], - callDatas: Array>, + callDatas: Parameters[], gasLimit = DEFAULT_GAS_LIMIT, chainId?: ChainId, blockNumber?: number, @@ -241,7 +241,7 @@ export function useMultipleContractSingleData( contracts: T[], names: K[], - callDatas: Array>, + callDatas: Parameters[], gasLimit = DEFAULT_GAS_LIMIT, chainId?: ChainId, ) {