diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index aef00342e..6e2e2a63f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: push: branches: - - main + - develop permissions: contents: write diff --git a/README.md b/README.md index c199e0c31..c7ea173bc 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/accounts/actions/index.ts b/src/accounts/actions/index.ts new file mode 100644 index 000000000..f85767684 --- /dev/null +++ b/src/accounts/actions/index.ts @@ -0,0 +1,6 @@ +export * from "./prepareUserOperationRequest" +export * from "./sendTransaction" +export * from "./sendUserOperation" +export * from "./sendTransactions" +export * from "./signMessage" +export * from "./signTypedData" diff --git a/src/accounts/actions/sendTransaction.ts b/src/accounts/actions/sendTransaction.ts index 91ffddf2a..a13eda296 100644 --- a/src/accounts/actions/sendTransaction.ts +++ b/src/accounts/actions/sendTransaction.ts @@ -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 diff --git a/src/accounts/actions/sendTransactions.ts b/src/accounts/actions/sendTransactions.ts index 3849a63ac..6ca513d6d 100644 --- a/src/accounts/actions/sendTransactions.ts +++ b/src/accounts/actions/sendTransactions.ts @@ -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" @@ -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 diff --git a/src/accounts/actions/sendUserOperation.ts b/src/accounts/actions/sendUserOperation.ts index caef85a06..a670d716a 100644 --- a/src/accounts/actions/sendUserOperation.ts +++ b/src/accounts/actions/sendUserOperation.ts @@ -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, @@ -51,7 +51,7 @@ export async function sendUserOperation< userOperation as UserOperationStruct ) - return sendUserOperationBundler(client, { + return sendUserOperationWithBundler(client, { userOperation: userOperation as UserOperationStruct }) } diff --git a/src/accounts/biconomyV2/signerToSmartAccount.ts b/src/accounts/biconomyV2/signerToSmartAccount.ts index 745c8e6f1..2c2c7175d 100644 --- a/src/accounts/biconomyV2/signerToSmartAccount.ts +++ b/src/accounts/biconomyV2/signerToSmartAccount.ts @@ -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, diff --git a/src/accounts/index.ts b/src/accounts/index.ts index 15819102b..dfaa6fe7c 100644 --- a/src/accounts/index.ts +++ b/src/accounts/index.ts @@ -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" diff --git a/src/bundler/actions/index.ts b/src/bundler/actions/index.ts new file mode 100644 index 000000000..3896ace58 --- /dev/null +++ b/src/bundler/actions/index.ts @@ -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 diff --git a/src/bundler/actions/sendUserOperation.ts b/src/bundler/actions/sendUserOperation.ts index 80bfb6c9a..c8db43503 100644 --- a/src/bundler/actions/sendUserOperation.ts +++ b/src/bundler/actions/sendUserOperation.ts @@ -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 * diff --git a/src/bundler/index.ts b/src/bundler/index.ts index 97c607f72..0d8a3808b 100644 --- a/src/bundler/index.ts +++ b/src/bundler/index.ts @@ -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" diff --git a/src/bundler/utils/helpers.ts b/src/bundler/utils/helpers.ts index e89642605..1e5b3466f 100644 --- a/src/bundler/utils/helpers.ts +++ b/src/bundler/utils/helpers.ts @@ -25,8 +25,8 @@ 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 +export type Callback = ((...args: any[]) => any) | undefined +export type Callbacks = Record export const listenersCache = /*#__PURE__*/ new Map< string, @@ -34,7 +34,7 @@ export const listenersCache = /*#__PURE__*/ new Map< >() export const cleanupCache = /*#__PURE__*/ new Map void>() -type EmitFunction = ( +export type EmitFunction = ( emit: TCallbacks // biome-ignore lint/suspicious/noConfusingVoidType: ) => MaybePromise void)> diff --git a/src/bundler/utils/types.ts b/src/bundler/utils/types.ts index 7e6fd7fb1..815842bea 100644 --- a/src/bundler/utils/types.ts +++ b/src/bundler/utils/types.ts @@ -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 = { @@ -122,10 +110,6 @@ export type UserOpReceipt = { receipt: any } -export type GetUserOperationByHashParameters = { - hash: Hash -} - export type GetGasFeeValuesReturnType = GasFeeValues export type GasFeeValues = { diff --git a/src/client/createSmartAccountClient.ts b/src/client/createSmartAccountClient.ts index 4814b7c39..8403e950e 100644 --- a/src/client/createSmartAccountClient.ts +++ b/src/client/createSmartAccountClient.ts @@ -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" diff --git a/src/client/decorators/bundler.ts b/src/client/decorators/bundler.ts index f23b79332..da3e5036f 100644 --- a/src/client/decorators/bundler.ts +++ b/src/client/decorators/bundler.ts @@ -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" @@ -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 = { @@ -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 diff --git a/src/client/decorators/index.ts b/src/client/decorators/index.ts new file mode 100644 index 000000000..cd790d044 --- /dev/null +++ b/src/client/decorators/index.ts @@ -0,0 +1,3 @@ +export * from "./bundler" +export * from "./paymaster" +export * from "./smartAccount" diff --git a/src/client/decorators/smartAccount.ts b/src/client/decorators/smartAccount.ts index 3496649e2..a963b3738 100644 --- a/src/client/decorators/smartAccount.ts +++ b/src/client/decorators/smartAccount.ts @@ -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" diff --git a/src/client/index.ts b/src/client/index.ts index 41a14dd9a..d4fae98b8 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -1 +1,3 @@ export * from "./createSmartAccountClient.js" +export * from "./decorators/index.js" +export * from "./utils/types" diff --git a/src/client/utils/types.ts b/src/client/utils/types.ts index 44796f0c2..77a3763be 100644 --- a/src/client/utils/types.ts +++ b/src/client/utils/types.ts @@ -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, @@ -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[] + }[] +} diff --git a/src/errors/index.ts b/src/errors/index.ts new file mode 100644 index 000000000..87cd4b2bf --- /dev/null +++ b/src/errors/index.ts @@ -0,0 +1,2 @@ +export * from "./getters" +export * from "./models" diff --git a/src/index.ts b/src/index.ts index b29b741af..3047e3a48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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" diff --git a/src/modules/index.ts b/src/modules/index.ts index 0178dc9ec..20d742817 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -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" diff --git a/src/paymaster/index.ts b/src/paymaster/index.ts index af0aa1897..827891827 100644 --- a/src/paymaster/index.ts +++ b/src/paymaster/index.ts @@ -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"