Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/iframe/src/components/interface/AddressInfo.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/components/requests/HappyLoadAbi.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/components/requests/common/Layout.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 18 additions & 1 deletion apps/iframe/src/components/requests/utils/transactionTypes.ts
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down
3 changes: 2 additions & 1 deletion apps/iframe/src/components/requests/utils/useTxFees.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion apps/iframe/src/constants/contracts.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/constants/requestLabels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HappyMethodNames } from "@happy.tech/common"
import { HappyMethodNames } from "@happy.tech/wallet-common"
import { Permissions } from "./permissions"

export const requestLabels = {
Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/requests/handlers/approved.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/requests/handlers/injected.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HappyMethodNames } from "@happy.tech/common"
import { HappyMethodNames } from "@happy.tech/wallet-common"
import {
EIP1193SwitchChainError,
EIP1193UnauthorizedError,
Expand Down
2 changes: 1 addition & 1 deletion apps/iframe/src/requests/handlers/permissionless.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HappyMethodNames } from "@happy.tech/common"
import { HappyMethodNames } from "@happy.tech/wallet-common"
import {
EIP1193SwitchChainError,
EIP1193UserRejectedRequestError,
Expand Down
10 changes: 8 additions & 2 deletions apps/iframe/src/routes/request.lazy.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions apps/iframe/src/utils/createHappyUserFromWallet.ts
Original file line number Diff line number Diff line change
@@ -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<HappyUser> {
Expand Down
10 changes: 2 additions & 8 deletions apps/iframe/src/wagmi/provider.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion apps/submitter/lib/services/BlockService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { exit } from "node:process"
import {
type Hash,
LruCache,
Mutex,
type RejectType,
filterMap,
Expand All @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions apps/submitter/lib/services/index.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/lib/functions.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 8 additions & 2 deletions packages/core/lib/happyProvider/happyProviderImplem.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -17,7 +24,6 @@ import {
SafeEventEmitter,
WalletDisplayAction,
WalletType,
waitForCondition,
} from "@happy.tech/wallet-common"
import { announceProvider, createStore } from "mipd"
import type { EIP1193Provider } from "viem"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/lib/viem.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions support/common/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =======================================================================================

Expand Down Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions support/common/lib/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
}
23 changes: 0 additions & 23 deletions support/common/lib/utils/constants.ts

This file was deleted.

2 changes: 1 addition & 1 deletion support/testing/ProxyServer.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 1 addition & 2 deletions support/testing/utils.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
5 changes: 1 addition & 4 deletions support/wallet-common/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion support/wallet-common/lib/interfaces/eip1193.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion support/wallet-common/lib/interfaces/permissions.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions support/wallet-common/lib/services/eventBus.ts
Original file line number Diff line number Diff line change
@@ -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 })

Expand Down
10 changes: 0 additions & 10 deletions support/wallet-common/lib/utils/shortenAddress.ts

This file was deleted.

25 changes: 0 additions & 25 deletions support/wallet-common/lib/utils/waitForCondition.ts

This file was deleted.