diff --git a/apps/iframe/src/components/interface/AddressInfo.tsx b/apps/iframe/src/components/interface/AddressInfo.tsx index 6c228a35a9..f64c073914 100644 --- a/apps/iframe/src/components/interface/AddressInfo.tsx +++ b/apps/iframe/src/components/interface/AddressInfo.tsx @@ -1,5 +1,5 @@ import { Clipboard as ArkClipboard, useClipboard } from "@ark-ui/react/clipboard" -import { shortenAddress } from "@happy.tech/wallet-common" +import { shortenAddress } from "@happy.tech/common" import { CheckIcon, CopyIcon } from "@phosphor-icons/react" import type { Address } from "viem" diff --git a/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntry.tsx b/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntry.tsx index 931046faa7..2202e0b34a 100644 --- a/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntry.tsx +++ b/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntry.tsx @@ -1,5 +1,5 @@ import { Onchain } from "@happy.tech/boop-sdk" -import { shortenAddress } from "@happy.tech/wallet-common" +import { shortenAddress } from "@happy.tech/common" import { ArrowUpIcon, LightningIcon, diff --git a/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntrySkeleton.tsx b/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntrySkeleton.tsx index 7012626f18..f3db463c2e 100644 --- a/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntrySkeleton.tsx +++ b/apps/iframe/src/components/interface/home/tabs/views/activity/BoopEntrySkeleton.tsx @@ -1,4 +1,4 @@ -import { shortenAddress } from "@happy.tech/wallet-common" +import { shortenAddress } from "@happy.tech/common" import { CircleNotchIcon } from "@phosphor-icons/react" import type { Hash } from "viem" diff --git a/apps/iframe/src/components/requests/HappyLoadAbi.tsx b/apps/iframe/src/components/requests/HappyLoadAbi.tsx index da9abad649..0b141fd267 100644 --- a/apps/iframe/src/components/requests/HappyLoadAbi.tsx +++ b/apps/iframe/src/components/requests/HappyLoadAbi.tsx @@ -1,4 +1,4 @@ -import type { HappyMethodNames } from "@happy.tech/common" +import type { HappyMethodNames } from "@happy.tech/wallet-common" import { formatAbiItem } from "abitype" import { useSmartContract } from "#src/hooks/useBlockExplorer" import { useClassifyAbi } from "#src/hooks/useClassifyAbiSections" diff --git a/apps/iframe/src/components/requests/HappyRequestSessionKey.tsx b/apps/iframe/src/components/requests/HappyRequestSessionKey.tsx index 1b979fdc9e..138f23b5f4 100644 --- a/apps/iframe/src/components/requests/HappyRequestSessionKey.tsx +++ b/apps/iframe/src/components/requests/HappyRequestSessionKey.tsx @@ -1,4 +1,4 @@ -import type { HappyMethodNames } from "@happy.tech/common" +import type { HappyMethodNames } from "@happy.tech/wallet-common" import type { Address } from "viem" import { getAppURL } from "#src/utils/appURL" import { diff --git a/apps/iframe/src/components/requests/common/Layout.tsx b/apps/iframe/src/components/requests/common/Layout.tsx index 43bc01a537..c3b92120ae 100644 --- a/apps/iframe/src/components/requests/common/Layout.tsx +++ b/apps/iframe/src/components/requests/common/Layout.tsx @@ -1,4 +1,4 @@ -import { shortenAddress } from "@happy.tech/wallet-common" +import { shortenAddress } from "@happy.tech/common" import { cva } from "class-variance-authority" import { useAtomValue } from "jotai" import type { PropsWithChildren } from "react" diff --git a/apps/iframe/src/components/requests/utils/transactionTypes.ts b/apps/iframe/src/components/requests/utils/transactionTypes.ts index 687e3317d9..23b02b1b18 100644 --- a/apps/iframe/src/components/requests/utils/transactionTypes.ts +++ b/apps/iframe/src/components/requests/utils/transactionTypes.ts @@ -1,6 +1,23 @@ -import { TransactionType } from "@happy.tech/common" import type { RpcTransactionRequest } from "viem" +export enum TransactionType { + /** + * Legacy tx include both pre- and post-EIP155 (replay protection) transactions. These are indistinguishable, they + * only vary in how they generated their signatures (post-EIP-155 signs a hash that also encompasses the chain ID). + * + * This is the only transaction type that doesn't really have a type encoded in the tx itself (so the number + * 0x0 here is arbitrary), that concepts comes from "types transaction envelopes introduced in EIP-2718. + */ + Legacy = "0x0", + /** + * Defined in EIP2930, but few people know that number, hence "access list". + */ + AccessList = "0x1", + EIP1559 = "0x2", + EIP4844 = "0x3", + EIP7702 = "0x4", +} + /** * Classify a transaction into its type. * diff --git a/apps/iframe/src/components/requests/utils/useTxFees.ts b/apps/iframe/src/components/requests/utils/useTxFees.ts index 35675c7264..b8582b3eef 100644 --- a/apps/iframe/src/components/requests/utils/useTxFees.ts +++ b/apps/iframe/src/components/requests/utils/useTxFees.ts @@ -1,6 +1,7 @@ -import { TransactionType, parseBigInt } from "@happy.tech/common" +import { parseBigInt } from "@happy.tech/common" import type { RpcTransactionRequest } from "viem" import { type UseEstimateFeesPerGasReturnType, useEstimateFeesPerGas } from "wagmi" +import { TransactionType } from "./transactionTypes" export type UseTxFeesArgs = { tx: RpcTransactionRequest diff --git a/apps/iframe/src/connections/firebase/workers/web3auth.sw.ts b/apps/iframe/src/connections/firebase/workers/web3auth.sw.ts index 925899fff1..8fa10a117e 100644 --- a/apps/iframe/src/connections/firebase/workers/web3auth.sw.ts +++ b/apps/iframe/src/connections/firebase/workers/web3auth.sw.ts @@ -2,7 +2,7 @@ import "./web3auth/polyfill" import type { Address } from "@happy.tech/common" -import { waitForCondition } from "@happy.tech/wallet-common" +import { waitForCondition } from "@happy.tech/common" import { COREKIT_STATUS, type JWTLoginParams } from "@web3auth/mpc-core-kit" import { web3Auth } from "./web3auth/mpc-core-kit" import { ethereumSigningProvider } from "./web3auth/signingProvider" diff --git a/apps/iframe/src/constants/contracts.ts b/apps/iframe/src/constants/contracts.ts index ca4711d917..fbf60f2ddc 100644 --- a/apps/iframe/src/constants/contracts.ts +++ b/apps/iframe/src/constants/contracts.ts @@ -1,10 +1,11 @@ +import { shortenAddress } from "@happy.tech/common" import { abis as boopStagingAbis, deployment as boopStagingDeployment, } from "@happy.tech/contracts/boop-staging/sepolia" import { abis as boopAnvilAbis, deployment as boopAnvilDeployment } from "@happy.tech/contracts/boop/anvil" import { abis as boopSepoliaAbis, deployment as boopSepoliaDeployment } from "@happy.tech/contracts/boop/sepolia" -import { anvil, happyChainSepolia, shortenAddress } from "@happy.tech/wallet-common" +import { anvil, happyChainSepolia } from "@happy.tech/wallet-common" import { type Address, isAddressEqual } from "viem" // Default chain ID, used for deployment addresses and ABIs. The iframe might (or might not — unsupported) diff --git a/apps/iframe/src/constants/requestLabels.ts b/apps/iframe/src/constants/requestLabels.ts index 13ff434445..5d797d48ff 100644 --- a/apps/iframe/src/constants/requestLabels.ts +++ b/apps/iframe/src/constants/requestLabels.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import { Permissions } from "./permissions" export const requestLabels = { diff --git a/apps/iframe/src/requests/handlers/approved.ts b/apps/iframe/src/requests/handlers/approved.ts index 609cae2b62..48d60aebf3 100644 --- a/apps/iframe/src/requests/handlers/approved.ts +++ b/apps/iframe/src/requests/handlers/approved.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import { EIP1193SwitchChainError, EIP1474InvalidInput, type Msgs, type PopupMsgs } from "@happy.tech/wallet-common" import { type SendBoopArgs, sendBoop } from "#src/requests/utils/boop" import { checkAndChecksumAddress, checkedTx, checkedWatchedAsset } from "#src/requests/utils/checks" diff --git a/apps/iframe/src/requests/handlers/injected.ts b/apps/iframe/src/requests/handlers/injected.ts index 4379fe7d24..be0a4d4bec 100644 --- a/apps/iframe/src/requests/handlers/injected.ts +++ b/apps/iframe/src/requests/handlers/injected.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import { EIP1193SwitchChainError, EIP1193UnauthorizedError, diff --git a/apps/iframe/src/requests/handlers/permissionless.ts b/apps/iframe/src/requests/handlers/permissionless.ts index 92d555ed34..653413a01e 100644 --- a/apps/iframe/src/requests/handlers/permissionless.ts +++ b/apps/iframe/src/requests/handlers/permissionless.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import { EIP1193SwitchChainError, EIP1193UserRejectedRequestError, diff --git a/apps/iframe/src/routes/request.lazy.tsx b/apps/iframe/src/routes/request.lazy.tsx index b2a3f7b4be..0d34a9f047 100644 --- a/apps/iframe/src/routes/request.lazy.tsx +++ b/apps/iframe/src/routes/request.lazy.tsx @@ -1,5 +1,11 @@ -import { HappyMethodNames, decodeUrlSafeBase64 } from "@happy.tech/common" -import { EIP1193UserRejectedRequestError, Msgs, type PopupMsgs, serializeRpcError } from "@happy.tech/wallet-common" +import { decodeUrlSafeBase64 } from "@happy.tech/common" +import { + EIP1193UserRejectedRequestError, + HappyMethodNames, + Msgs, + type PopupMsgs, + serializeRpcError, +} from "@happy.tech/wallet-common" import { createLazyFileRoute } from "@tanstack/react-router" import { useAtomValue } from "jotai" import { useCallback, useEffect, useState } from "react" diff --git a/apps/iframe/src/utils/checkIfRequestRequiresConfirmation.ts b/apps/iframe/src/utils/checkIfRequestRequiresConfirmation.ts index 7a8b5031fa..a831e71ef8 100644 --- a/apps/iframe/src/utils/checkIfRequestRequiresConfirmation.ts +++ b/apps/iframe/src/utils/checkIfRequestRequiresConfirmation.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import type { Msgs, ProviderMsgsFromApp } from "@happy.tech/wallet-common" import { requiresApproval } from "@happy.tech/wallet-common" import { Permissions } from "#src/constants/permissions" diff --git a/apps/iframe/src/utils/createHappyUserFromWallet.ts b/apps/iframe/src/utils/createHappyUserFromWallet.ts index f05fabe523..1139181c53 100644 --- a/apps/iframe/src/utils/createHappyUserFromWallet.ts +++ b/apps/iframe/src/utils/createHappyUserFromWallet.ts @@ -1,5 +1,5 @@ -import type { Address } from "@happy.tech/common" -import { type HappyUser, WalletType, shortenAddress } from "@happy.tech/wallet-common" +import { type Address, shortenAddress } from "@happy.tech/common" +import { type HappyUser, WalletType } from "@happy.tech/wallet-common" import { getBoopAccountAddress } from "#src/connections/boopAccount" export async function createHappyUserFromWallet(providerId: string, address: Address): Promise { diff --git a/apps/iframe/src/wagmi/provider.ts b/apps/iframe/src/wagmi/provider.ts index 84f1c42d07..5caf349495 100644 --- a/apps/iframe/src/wagmi/provider.ts +++ b/apps/iframe/src/wagmi/provider.ts @@ -1,12 +1,6 @@ -import type { UUID } from "@happy.tech/common" +import { type UUID, waitForCondition } from "@happy.tech/common" import type { EIP1193RequestParameters } from "@happy.tech/wallet-common" -import { - AuthState, - BasePopupProvider, - EIP1193UserRejectedRequestError, - WalletType, - waitForCondition, -} from "@happy.tech/wallet-common" +import { AuthState, BasePopupProvider, EIP1193UserRejectedRequestError, WalletType } from "@happy.tech/wallet-common" import type { EIP1193Provider } from "viem" import { addBanner } from "#src/state/banner" import { getCurrentChain } from "#src/state/chains" diff --git a/apps/submitter/lib/services/BlockService.ts b/apps/submitter/lib/services/BlockService.ts index 446bd60ad7..943b868877 100644 --- a/apps/submitter/lib/services/BlockService.ts +++ b/apps/submitter/lib/services/BlockService.ts @@ -1,6 +1,7 @@ import { exit } from "node:process" import { type Hash, + LruCache, Mutex, type RejectType, filterMap, @@ -16,7 +17,6 @@ import { http, createPublicClient, webSocket } from "viem" import { env } from "#lib/env" import { alert } from "#lib/policies/alerting.ts" import { currentBlockGauge } from "#lib/telemetry/metrics.ts" -import { LruCache } from "#lib/utils/LruCache" import { chain, publicClient, rpcUrls, stringify } from "#lib/utils/clients" import { blockLogger } from "#lib/utils/logger" import { Bytes } from "#lib/utils/validation/ark" diff --git a/apps/submitter/lib/services/index.ts b/apps/submitter/lib/services/index.ts index ae8bbf006b..4130830a42 100644 --- a/apps/submitter/lib/services/index.ts +++ b/apps/submitter/lib/services/index.ts @@ -1,9 +1,8 @@ -import type { Hash } from "@happy.tech/common" +import { type Hash, LruCache } from "@happy.tech/common" import { db } from "#lib/database" import { env } from "#lib/env" import type { SimulateOutput } from "#lib/handlers/simulate" import { EvmReceiptService } from "#lib/services/EvmReceiptService" -import { LruCache } from "#lib/utils/LruCache" import { BlockService } from "./BlockService" import { BoopNonceManager } from "./BoopNonceManager" import { BoopReceiptService } from "./BoopReceiptService" diff --git a/packages/core/lib/functions.ts b/packages/core/lib/functions.ts index 8c897d31ad..933c437ce7 100644 --- a/packages/core/lib/functions.ts +++ b/packages/core/lib/functions.ts @@ -1,5 +1,5 @@ -import { HappyMethodNames } from "@happy.tech/common" import type { Address } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import type { HappyUser } from "@happy.tech/wallet-common" import type { Abi } from "viem" import { internalProvider } from "./happyProvider" diff --git a/packages/core/lib/happyProvider/happyProviderImplem.ts b/packages/core/lib/happyProvider/happyProviderImplem.ts index 70202e1990..744c7dc859 100644 --- a/packages/core/lib/happyProvider/happyProviderImplem.ts +++ b/packages/core/lib/happyProvider/happyProviderImplem.ts @@ -1,4 +1,11 @@ -import { type TaggedLogger, type UUID, createUUID, happyProviderInfo, injectedProviderInfo } from "@happy.tech/common" +import { + type TaggedLogger, + type UUID, + createUUID, + happyProviderInfo, + injectedProviderInfo, + waitForCondition, +} from "@happy.tech/common" import { AuthState, type EIP1193RequestParameters, @@ -17,7 +24,6 @@ import { SafeEventEmitter, WalletDisplayAction, WalletType, - waitForCondition, } from "@happy.tech/wallet-common" import { announceProvider, createStore } from "mipd" import type { EIP1193Provider } from "viem" diff --git a/packages/core/lib/viem.ts b/packages/core/lib/viem.ts index b97be48d05..dc3f360ad8 100644 --- a/packages/core/lib/viem.ts +++ b/packages/core/lib/viem.ts @@ -1,6 +1,6 @@ -import type { Address } from "@happy.tech/common" +import { type Address, waitForCondition } from "@happy.tech/common" import type { Chain, HappyUser } from "@happy.tech/wallet-common" -import { defaultChain, waitForCondition } from "@happy.tech/wallet-common" +import { defaultChain } from "@happy.tech/wallet-common" import { type CustomTransport, type ParseAccount, diff --git a/apps/submitter/lib/utils/LruCache.ts b/support/common/lib/collections/LruCache.ts similarity index 100% rename from apps/submitter/lib/utils/LruCache.ts rename to support/common/lib/collections/LruCache.ts diff --git a/support/common/lib/index.ts b/support/common/lib/index.ts index 64050ca951..f8527c5cfe 100644 --- a/support/common/lib/index.ts +++ b/support/common/lib/index.ts @@ -9,6 +9,7 @@ export { Map2 } from "./collections/map2" export { FIFOCache } from "./collections/fifoCache" export { Stream } from "./collections/stream" export { Heap, IndexedHeap } from "./collections/heap" +export { LruCache } from "./collections/LruCache" // === UTILS ======================================================================================= @@ -86,11 +87,10 @@ export type { export { isHttpString, isDef, isNullish } from "./utils/types" -export { isAddress } from "./utils/address" +export { isAddress, shortenAddress } from "./utils/address" export { array, uniques, last } from "./utils/arrays" export { type AssertionError, assertDef, assertType } from "./utils/assertions" export { With } from "./utils/classes" -export { HappyMethodNames, TransactionType } from "./utils/constants" export { nowInSeconds } from "./utils/date" export { debounce } from "./utils/debounce" export { unknownToError, tryCatch, tryCatchAsync, tryCatchU, tryCatchAsyncU, type Result } from "./utils/error" diff --git a/support/common/lib/utils/address.ts b/support/common/lib/utils/address.ts index f6c5892962..e8ca18d411 100644 --- a/support/common/lib/utils/address.ts +++ b/support/common/lib/utils/address.ts @@ -10,3 +10,12 @@ import type { Address } from "./types" export function isAddress(str: string): str is Address { return viemIsAddress(str, { strict: false }) } + +/** + * Truncates an address into a shorter representation by displaying the first `digits` characters + * and the last `digits` characters. + */ +export const shortenAddress = (address?: Address, digits = 5) => { + if (!address) return "" + return `${address.substring(0, digits + 2)}...${address.substring(address.length - digits)}` +} diff --git a/support/common/lib/utils/constants.ts b/support/common/lib/utils/constants.ts deleted file mode 100644 index 2f786e111a..0000000000 --- a/support/common/lib/utils/constants.ts +++ /dev/null @@ -1,23 +0,0 @@ -export enum HappyMethodNames { - USER = "happy_user", - LOAD_ABI = "happy_loadAbi", - REQUEST_SESSION_KEY = "happy_requestSessionKey", -} - -export enum TransactionType { - /** - * Legacy tx include both pre- and post-EIP155 (replay protection) transactions. These are indistinguishable, they - * only vary in how they generated their signatures (post-EIP-155 signs a hash that also encompasses the chain ID). - * - * This is the only transaction type that doesn't really have a type encoded in the tx itself (so the number - * 0x0 here is arbitrary), that concepts comes from "types transaction envelopes introduced in EIP-2718. - */ - Legacy = "0x0", - /** - * Defined in EIP2930, but few people know that number, hence "access list". - */ - AccessList = "0x1", - EIP1559 = "0x2", - EIP4844 = "0x3", - EIP7702 = "0x4", -} diff --git a/support/testing/ProxyServer.ts b/support/testing/ProxyServer.ts index a37e267dc0..434577694b 100644 --- a/support/testing/ProxyServer.ts +++ b/support/testing/ProxyServer.ts @@ -1,7 +1,7 @@ import type { Server } from "node:http" import type { Http2SecureServer, Http2Server } from "node:http2" import { type Logger, type TaggedLogger, stringify } from "@happy.tech/common" -import { waitForCondition } from "@happy.tech/wallet-common" +import { waitForCondition } from "@happy.tech/common" import { serve } from "@hono/node-server" import { createNodeWebSocket } from "@hono/node-ws" import { Hono } from "hono" diff --git a/support/testing/utils.ts b/support/testing/utils.ts index 874d76a3f5..c0cb17e504 100644 --- a/support/testing/utils.ts +++ b/support/testing/utils.ts @@ -1,11 +1,10 @@ import { randomBytes } from "node:crypto" -import { type UUID, createUUID } from "@happy.tech/common" +import { type UUID, createUUID, shortenAddress } from "@happy.tech/common" import { type EIP1193RequestParameters, type HappyUser, type ProviderEventPayload, WalletType, - shortenAddress, } from "@happy.tech/wallet-common" import { getAddress } from "viem" diff --git a/support/wallet-common/lib/index.ts b/support/wallet-common/lib/index.ts index 3c9c27c44d..ab0966379b 100644 --- a/support/wallet-common/lib/index.ts +++ b/support/wallet-common/lib/index.ts @@ -12,15 +12,12 @@ export { AuthState, WalletType } from "./interfaces/happyUser" export * from "./errors" +export { HappyMethodNames } from "./interfaces/eip1193" export { permissionsLists, requiresApproval } from "./interfaces/permissions" // services export { EventBus, EventBusMode } from "./services/eventBus" -// utils -export { waitForCondition } from "./utils/waitForCondition" -export { shortenAddress } from "./utils/shortenAddress" - // === TYPES ======================================================================================= export type { Chain, ChainBlockExplorer, ChainContract, ChainRpcUrls, ChainNativeCurrency } from "./chains/viem" diff --git a/support/wallet-common/lib/interfaces/eip1193.ts b/support/wallet-common/lib/interfaces/eip1193.ts index edcc664698..eb3dbea745 100644 --- a/support/wallet-common/lib/interfaces/eip1193.ts +++ b/support/wallet-common/lib/interfaces/eip1193.ts @@ -1,7 +1,13 @@ -import type { Address, HappyMethodNames } from "@happy.tech/common" +import type { Address } from "@happy.tech/common" import type { Abi, EIP1193EventMap, EIP1193Parameters, PublicRpcSchema, WalletRpcSchema } from "viem" import type { HappyUser } from "./happyUser" +export enum HappyMethodNames { + USER = "happy_user", + LOAD_ABI = "happy_loadAbi", + REQUEST_SESSION_KEY = "happy_requestSessionKey", +} + export type RecordAbiPayload = { address: Address abi: Abi diff --git a/support/wallet-common/lib/interfaces/permissions.ts b/support/wallet-common/lib/interfaces/permissions.ts index 50461470ef..37546c95c7 100644 --- a/support/wallet-common/lib/interfaces/permissions.ts +++ b/support/wallet-common/lib/interfaces/permissions.ts @@ -1,4 +1,4 @@ -import { HappyMethodNames } from "@happy.tech/common" +import { HappyMethodNames } from "@happy.tech/wallet-common" import type { EIP1193Parameters } from "viem" // https://eips.ethereum.org/EIPS/eip-1474 diff --git a/support/wallet-common/lib/services/eventBus.ts b/support/wallet-common/lib/services/eventBus.ts index 656284dc65..58da287a71 100644 --- a/support/wallet-common/lib/services/eventBus.ts +++ b/support/wallet-common/lib/services/eventBus.ts @@ -1,5 +1,4 @@ -import { LogLevel, Logger, type TaggedLogger } from "@happy.tech/common" -import { waitForCondition } from "../utils/waitForCondition" +import { LogLevel, Logger, type TaggedLogger, waitForCondition } from "@happy.tech/common" const silentLogger = Logger.create("silent", { level: LogLevel.OFF }) diff --git a/support/wallet-common/lib/utils/shortenAddress.ts b/support/wallet-common/lib/utils/shortenAddress.ts deleted file mode 100644 index 41abbfc247..0000000000 --- a/support/wallet-common/lib/utils/shortenAddress.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { Address } from "@happy.tech/common" - -/** - * Truncates an address into a shorter representation by displaying the first `digits` characters - * and the last `digits` characters. - */ -export const shortenAddress = (address?: Address, digits = 5) => { - if (!address) return "" - return `${address.substring(0, digits + 2)}...${address.substring(address.length - digits)}` -} diff --git a/support/wallet-common/lib/utils/waitForCondition.ts b/support/wallet-common/lib/utils/waitForCondition.ts deleted file mode 100644 index 6a43d677f1..0000000000 --- a/support/wallet-common/lib/utils/waitForCondition.ts +++ /dev/null @@ -1,25 +0,0 @@ -export async function waitForCondition( - // `unknown` return type so that we can wait for things to be truthy - callback: (...args: unknown[]) => unknown | Promise, - maxPollTimeMs = 30_000, - pollIntervalMs = 50, -) { - const done = await callback() - if (done) return - - const start = Date.now() - return new Promise((resolve, reject) => { - const pollForCondition = async () => { - if (await callback()) { - return resolve(true) - } - - if (Date.now() - start > maxPollTimeMs) { - return reject() - } - setTimeout(pollForCondition, pollIntervalMs) - } - - pollForCondition() - }) -}