Skip to content

Commit

Permalink
chore: sma-747 tsdoc fixes (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Mar 25, 2024
1 parent 808aa5d commit 2bafd6d
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:
push:
branches:
- main
- develop

permissions:
contents: write
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ This repository serves as a comprehensive foundation for typescript account abst

## 📚 Table of Contents

- [SDK 🚀](#sdk-🚀)
- [📚 Table of Contents](#-📚-table-of-contents)
- [SDK 🚀](#sdk-)
- [📚 Table of Contents](#-table-of-contents)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [🛠️ Essential Scripts](#-🛠️-essential-scripts)
- [🧪 Run Tests](#-🧪-run-tests)
- [📊 Coverage Report](#-📊-coverage-report)
- [🛠️ Essential Scripts](#️-essential-scripts)
- [🧪 Run Tests](#-run-tests)
- [📊 Coverage Report](#-coverage-report)
- [📄 Documentation](https://bcnmy.github.io/sdk)
- [🎨 Lint Code](#-🖌️-auto-fix-linting-issues)
- [🎨 Lint Code](#-lint-code)
- [🖌️ Auto-fix Linting Issues](#️-auto-fix-linting-issues)
- [Documentation and Resources](#-documentation-and-resources)
- [License](#license)
Expand Down
6 changes: 6 additions & 0 deletions src/accounts/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from "./prepareUserOperationRequest"
export * from "./sendTransaction"
export * from "./sendUserOperation"
export * from "./sendTransactions"
export * from "./signMessage"
export * from "./signTypedData"
1 change: 0 additions & 1 deletion src/accounts/actions/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type SendTransactionWithPaymasterParameters<
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
*
* @param client - Client to use
* @param parameters - {@link SendTransactionParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.
*
* @example
Expand Down
11 changes: 1 addition & 10 deletions src/accounts/actions/sendTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import type {
Address,
Chain,
Client,
Hash,
Hex,
SendTransactionParameters,
Transport
} from "viem"
import type { Address, Chain, Client, Hash, Hex, Transport } from "viem"
import type { Prettify } from "viem/chains"
import { waitForUserOperationReceipt } from "../../bundler/actions/waitForUserOperationReceipt"
import { getAction, parseAccount } from "../utils/helpers"
Expand All @@ -33,7 +25,6 @@ export type SendTransactionsWithPaymasterParameters<
* This function also allows you to sponsor this transaction if sender is a smartAccount
*
* @param client - Client to use
* @param parameters - {@link SendTransactionParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.
*
* @example
Expand Down
4 changes: 2 additions & 2 deletions src/accounts/actions/sendUserOperation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Chain, Client, Hash, Transport } from "viem"
import type { PartialBy, Prettify } from "viem/chains"
import { sendUserOperation as sendUserOperationBundler } from "../../bundler/index"
import { sendUserOperationWithBundler } from "../../bundler"
import { getAction, parseAccount } from "../utils/helpers"
import type {
GetAccountParameter,
Expand Down Expand Up @@ -51,7 +51,7 @@ export async function sendUserOperation<
userOperation as UserOperationStruct
)

return sendUserOperationBundler(client, {
return sendUserOperationWithBundler(client, {
userOperation: userOperation as UserOperationStruct
})
}
10 changes: 0 additions & 10 deletions src/accounts/biconomyV2/signerToSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,6 @@ export type SignerToBiconomySmartAccountParameters<
activeValidationModule?: BaseValidationModule
}>

/**
* Build a Biconomy modular smart account from a private key, that use the ECDSA signer behind the scene
* @param client
* @param privateKey
* @param index
* @param factoryAddress
* @param accountLogicAddress
* @param defaultValidationModule
* @param activeValidationModule
*/
export async function signerToSmartAccount<
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
Expand Down
6 changes: 3 additions & 3 deletions src/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { signerToSmartAccount } from "./biconomyV2/signerToSmartAccount.js"

export { type UserOperationStruct } from "./utils/types.js"
export * from "./biconomyV2/signerToSmartAccount.js"
export * from "./utils/types"
export * from "./actions"
8 changes: 8 additions & 0 deletions src/bundler/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from "./chainId"
export * from "./estimateUserOperationGas"
export * from "./getGasFeeValues"
export * from "./getUserOperationByHash"
export * from "./getUserOperationReceipt"
export * from "./getUserOperationStatus"
export * from "./waitForUserOperationReceipt"
export { sendUserOperation as sendUserOperationWithBundler } from "./sendUserOperation" // Explicitly re-export the necessary member
9 changes: 4 additions & 5 deletions src/bundler/actions/sendUserOperation.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import type { Account, Chain, Client, Hash, Transport } from "viem"
import type { BaseError } from "viem"
import type { Prettify } from "viem/chains"
import type { UserOperationStruct } from "../../accounts"
import type {
SendUserOperationParameters,
UserOperationStruct
} from "../../accounts"
import { ENTRYPOINT_ADDRESS_V06 } from "../../accounts/utils/constants"
import { getSendUserOperationError } from "../../errors/getters"
import type { BundlerRpcSchema } from "../utils/types"

export type SendUserOperationParameters = {
userOperation: UserOperationStruct
}

/**
* Sends user operation to the bundler
*
Expand Down
8 changes: 4 additions & 4 deletions src/bundler/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { sendUserOperation } from "./actions/sendUserOperation.js"
export { estimateUserOperationGas } from "./actions/estimateUserOperationGas.js"
export { extractChainIdFromBundlerUrl } from "./utils/helpers.js"
export { createBundlerClient } from "./createBundlerClient.js"
export * from "./utils/helpers.js"
export * from "./createBundlerClient.js"
export * from "./utils/types"
export * from "./actions"
6 changes: 3 additions & 3 deletions src/bundler/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ export const transactionReceiptStatus = {
} as const

// biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type
type Callback = ((...args: any[]) => any) | undefined
type Callbacks = Record<string, Callback>
export type Callback = ((...args: any[]) => any) | undefined
export type Callbacks = Record<string, Callback>

export const listenersCache = /*#__PURE__*/ new Map<
string,
{ id: number; fns: Callbacks }[]
>()
export const cleanupCache = /*#__PURE__*/ new Map<string, () => void>()

type EmitFunction<TCallbacks extends Callbacks> = (
export type EmitFunction<TCallbacks extends Callbacks> = (
emit: TCallbacks
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
) => MaybePromise<void | (() => void)>
Expand Down
16 changes: 0 additions & 16 deletions src/bundler/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ export type EstimateUserOperationGasParameters = {
userOperation: UserOperationStruct
}

export type WaitForUserOperationReceiptParameters = {
/** The hash of the transaction. */
hash: Hash
/**
* Polling frequency (in ms). Defaults to the client's pollingInterval config.
* @default client.pollingInterval
*/
pollingInterval?: number
/** Optional timeout (in milliseconds) to wait before stopping polling. */
timeout?: number
}

export type TStatus = "success" | "reverted"

export type UserOpReceipt = {
Expand All @@ -122,10 +110,6 @@ export type UserOpReceipt = {
receipt: any
}

export type GetUserOperationByHashParameters = {
hash: Hash
}

export type GetGasFeeValuesReturnType = GasFeeValues

export type GasFeeValues = {
Expand Down
8 changes: 7 additions & 1 deletion src/client/createSmartAccountClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { type Chain, type Client, type Transport, createClient } from "viem"
import {
type Chain,
type Client,
type Transport,
type WalletClientConfig,
createClient
} from "viem"
import type { Prettify } from "viem/chains"

import type { SmartAccount } from "../accounts/utils/types.js"
Expand Down
16 changes: 8 additions & 8 deletions src/client/decorators/bundler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { Client, Hash } from "viem"
import type { Prettify } from "viem/chains"
import type { SendUserOperationParameters } from "../../accounts/actions/sendUserOperation"
import { ENTRYPOINT_ADDRESS_V06 } from "../../accounts/utils/constants"
import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../accounts/utils/types"
import { estimateUserOperationGas } from "../../bundler"
import { chainId } from "../../bundler/actions/chainId"
import { getGasFeeValues } from "../../bundler/actions/getGasFeeValues"
import {
type GetUserOperationByHashParameters,
type GetUserOperationByHashReturnType,
getUserOperationByHash
} from "../../bundler/actions/getUserOperationByHash"
Expand All @@ -14,20 +16,18 @@ import {
getUserOperationReceipt
} from "../../bundler/actions/getUserOperationReceipt"
import { getUserOpStatus } from "../../bundler/actions/getUserOperationStatus"
import { sendUserOperation } from "../../bundler/actions/sendUserOperation"
import {
type SendUserOperationParameters,
sendUserOperation
} from "../../bundler/actions/sendUserOperation"
import { waitForUserOperationReceipt } from "../../bundler/actions/waitForUserOperationReceipt"
type WaitForUserOperationReceiptParameters,
waitForUserOperationReceipt
} from "../../bundler/actions/waitForUserOperationReceipt"
import type { BundlerClient } from "../../bundler/createBundlerClient"
import type {
EstimateUserOperationGasParameters,
GetGasFeeValuesReturnType,
GetUserOperationByHashParameters,
StateOverrides,
UserOpReceipt,
UserOpStatus,
WaitForUserOperationReceiptParameters
UserOpStatus
} from "../../bundler/utils/types"

export type BundlerActions = {
Expand Down Expand Up @@ -144,7 +144,7 @@ export type BundlerActions = {
*
* - Docs: https://docs.biconomy.io/... // TODO
*
* @param args {@link GetUserOperationByHash} UserOpHash that was returned by {@link sendUserOperation}
* @param args UserOpHash that was returned by {@link sendUserOperation}
* @returns userOperation along with entryPoint, transactionHash, blockHash, blockNumber if found or null
*
* @example
Expand Down
3 changes: 3 additions & 0 deletions src/client/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./bundler"
export * from "./paymaster"
export * from "./smartAccount"
8 changes: 7 additions & 1 deletion src/client/decorators/smartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import type {
DeployContractParameters,
Hash,
SendTransactionParameters,
SendTransactionReturnType,
SignMessageParameters,
SignMessageReturnType,
SignTypedDataParameters,
SignTypedDataReturnType,
Transport,
TypedData,
WriteContractParameters
WriteContractParameters,
WriteContractReturnType
} from "viem"
// import { signTypedData } from "../../accounts/actions/sygnTypedData"
import type { Prettify } from "viem/chains"
Expand Down
2 changes: 2 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from "./createSmartAccountClient.js"
export * from "./decorators/index.js"
export * from "./utils/types"
42 changes: 41 additions & 1 deletion src/client/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Chain, ClientConfig, Transport } from "viem"
import type { Address, Chain, ClientConfig, Hash, Hex, Transport } from "viem"
import type { Prettify } from "viem/chains"
import type { Middleware, SmartAccount } from "../../accounts/utils/types"
import type { TStatus } from "../../bundler"

export type SmartAccountClientConfig<
transport extends Transport = Transport,
Expand All @@ -16,3 +17,42 @@ export type SmartAccountClientConfig<
bundlerTransport: Transport
}
>

export type EstimateUserOperationGasReturnType = {
preVerificationGas: bigint
verificationGasLimit: bigint
callGasLimit: bigint
}

export type GetUserOperationReceiptReturnType = {
userOpHash: Hash
sender: Address
nonce: bigint
actualGasUsed: bigint
actualGasCost: bigint
success: boolean
receipt: {
transactionHash: Hex
transactionIndex: bigint
blockHash: Hash
blockNumber: bigint
from: Address
to: Address | null
cumulativeGasUsed: bigint
status: TStatus
gasUsed: bigint
contractAddress: Address | null
logsBloom: Hex
effectiveGasPrice: bigint
}
logs: {
data: Hex
blockNumber: bigint
blockHash: Hash
transactionHash: Hash
logIndex: bigint
transactionIndex: bigint
address: Address
topics: Hex[]
}[]
}
2 changes: 2 additions & 0 deletions src/errors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./getters"
export * from "./models"
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { signerToSmartAccount } from "./accounts/index.js"

export { createSmartAccountClient } from "./client/index.js"

// TODO import from the rest of the files in the core package
export * from "./accounts"
export * from "./errors"
export * from "./bundler"
export * from "./paymaster"
export * from "./client"
export * from "./modules"
9 changes: 2 additions & 7 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export type {
BaseValidationModule,
BaseValidationModuleConfig,
ModuleInfo
} from "./utils/types.js"

export { createECDSAOwnershipModule } from "./ecdsaOwnershipValidationModule/createECDSAOwnershipModule.js"
export * from "./utils/types"
export * from "./ecdsaOwnershipValidationModule/createECDSAOwnershipModule.js"
5 changes: 2 additions & 3 deletions src/paymaster/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export type { PaymasterRpcSchema } from "./utils/types.js"
export { type PaymasterClientActions } from "../client/decorators/paymaster.js"
export { createPaymasterClient } from "./createPaymasterClient.js"
export * from "./utils/types.js"
export * from "./createPaymasterClient.js"

0 comments on commit 2bafd6d

Please sign in to comment.