Skip to content

Commit

Permalink
chore: tsdoc - createBicoPaymasterClient
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Sep 19, 2024
1 parent d0ae8c5 commit 32d05a2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/sdk/clients/createBicoPaymasterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import {
createPaymasterClient
} from "viem/account-abstraction"

/**
* Configuration options for creating a Bico Paymaster Client.
* @typedef {Object} BicoPaymasterClientConfig
* @property {Transport} [transport] - Optional custom transport.
* @property {string} [paymasterUrl] - URL of the paymaster service.
* @property {number} [chainId] - Chain ID for the network.
* @property {string} [apiKey] - API key for authentication.
*/
type BicoPaymasterClientConfig = Omit<PaymasterClientConfig, "transport"> &
OneOf<
| {
Expand All @@ -19,6 +27,27 @@ type BicoPaymasterClientConfig = Omit<PaymasterClientConfig, "transport"> &
}
>

/**
* Creates a Bico Paymaster Client.
*
* This function sets up a client for interacting with Biconomy's paymaster service.
* It can be configured with a custom transport, a specific paymaster URL, or with a chain ID and API key.
*
* @param {BicoPaymasterClientConfig} parameters - Configuration options for the client.
* @returns {PaymasterClient} A configured Paymaster Client instance.
*
* @example
* // Create a client with a custom transport
* const client1 = createBicoPaymasterClient({ transport: customTransport })
*
* @example
* // Create a client with a specific paymaster URL
* const client2 = createBicoPaymasterClient({ paymasterUrl: 'https://example.com/paymaster' })
*
* @example
* // Create a client with chain ID and API key
* const client3 = createBicoPaymasterClient({ chainId: 1, apiKey: 'your-api-key' })
*/
export const createBicoPaymasterClient = (
parameters: BicoPaymasterClientConfig
): PaymasterClient =>
Expand Down
48 changes: 47 additions & 1 deletion src/sdk/clients/createNexusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ import {
smartAccountActions
} from "./decorators/smartAccount"

/**
* Parameters for sending a transaction
*/
export type SendTransactionParameters = {
calls: Call | Call[]
}

/**
* Nexus Client type
*/
export type NexusClient<
transport extends Transport = Transport,
chain extends Chain | undefined = Chain | undefined,
Expand All @@ -48,15 +54,36 @@ export type NexusClient<
BundlerActions<NexusAccount> &
Erc7579Actions<NexusAccount> &
SmartAccountActions<chain, NexusAccount> & {
/**
* The Nexus account associated with this client
*/
account: NexusAccount
/**
* Optional client for additional functionality
*/
client?: client | Client | undefined
/**
* Transport configuration for the bundler
*/
bundlerTransport?: BundlerClientConfig["transport"]
/**
* Optional paymaster configuration
*/
paymaster?: BundlerClientConfig["paymaster"] | undefined
/**
* Optional paymaster context
*/
paymasterContext?: BundlerClientConfig["paymasterContext"] | undefined
/**
* Optional user operation configuration
*/
userOperation?: BundlerClientConfig["userOperation"] | undefined
}
>

/**
* Configuration for creating a Nexus Client
*/
export type NexusClientConfig<
transport extends Transport = Transport,
chain extends Chain | undefined = Chain | undefined,
Expand Down Expand Up @@ -113,14 +140,33 @@ export type NexusClientConfig<
index?: bigint
/** Active module of the account. */
activeModule?: BaseValidationModule
/** Factory address of the account. */
/** Executor module of the account. */
executorModule?: BaseExecutionModule
/** Factory address of the account. */
factoryAddress?: Address
/** Owner module */
k1ValidatorAddress?: Address
}
>

/**
* Creates a Nexus Client for interacting with the Nexus smart account system.
*
* @param parameters - {@link NexusClientConfig}
* @returns Nexus Client. {@link NexusClient}
*
* @example
* import { createNexusClient } from '@biconomy/sdk'
* import { http } from 'viem'
* import { mainnet } from 'viem/chains'
*
* const nexusClient = await createNexusClient({
* chain: mainnet,
* transport: http('https://mainnet.infura.io/v3/YOUR-PROJECT-ID'),
* bundlerTransport: http('https://api.biconomy.io'),
* holder: '0x...',
* })
*/
export async function createNexusClient(
parameters: NexusClientConfig
): Promise<NexusClient> {
Expand Down

0 comments on commit 32d05a2

Please sign in to comment.