Skip to content

Commit

Permalink
feat: add doc generator for class methods (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed Aug 13, 2024
1 parent 9a95628 commit 3cdea84
Show file tree
Hide file tree
Showing 128 changed files with 4,277 additions and 222 deletions.
19 changes: 2 additions & 17 deletions aa-sdk/core/src/actions/smartAccount/buildUserOperationFromTxs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ import type {
* ```ts
* import type { RpcTransactionRequest } from "viem";
* import { smartAccountClient } from "./smartAccountClient";
* // [!code focus:99]
* // buildUserOperationFromTxs converts traditional Ethereum transactions in batch and returns
* // the unsigned user operation struct after constructing the user operation struct
* // through the middleware pipeline
*
* const requests: RpcTransactionRequest[] = [
* {
* from, // ignored
Expand All @@ -50,16 +47,6 @@ import type {
* args: [arg1, arg2, ...],
* }),
* },
* ...
* {
* from, // ignored
* to,
* data: encodeFunctionData({
* abi: ContractABI.abi,
* functionName: "func",
* args: [arg1, arg2, ...],
* }),
* },
* ];
* const uoStruct = await smartAccountClient.buildUserOperationFromTxs({
* requests,
Expand All @@ -80,9 +67,7 @@ import type {
* ```
*
* @param {Client<TTransport, TChain, TAccount>} client the smart account client to use to make RPC calls
* @param {BuildTransactionParameters} args {@link BuildTransactionParameters} an object containing the requests
* to build as well as, the account if not hoisted, the context, the overrides, and
* optionally a flag to enable signing of the UO via the underlying middleware
* @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware
* @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
*/
export async function buildUserOperationFromTxs<
Expand Down
16 changes: 8 additions & 8 deletions aa-sdk/core/src/client/decorators/bundlerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export type BundlerActions = {
/**
* calls `eth_estimateUserOperationGas` and returns the result
*
* @param request - the {@link UserOperationRequest} to estimate gas for
* @param request - the UserOperationRequest to estimate gas for
* @param entryPoint - the entry point address the op will be sent to
* @param stateOverride - the state override to use for the estimation
* @returns the gas estimates for the given response (see: {@link UserOperationEstimateGasResponse})
* @returns the gas estimates for the given response
*/
estimateUserOperationGas<
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
Expand All @@ -71,7 +71,7 @@ export type BundlerActions = {
/**
* calls `eth_sendUserOperation` and returns the hash of the sent UserOperation
*
* @param request - the {@link UserOperationRequest} to send
* @param request - the UserOperationRequest to send
* @param entryPoint - the entry point address the op will be sent to
* @returns the hash of the sent UserOperation
*/
Expand All @@ -83,25 +83,25 @@ export type BundlerActions = {
): Promise<Hash>;

/**
* calls `eth_getUserOperationByHash` and returns the {@link UserOperationResponse}
* calls `eth_getUserOperationByHash` and returns the UserOperationResponse
*
* @param hash - the hash of the UserOperation to fetch
* @returns - {@link UserOperationResponse}
* @returns - the user operation if found or null
*/
getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;

/**
* calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}
* calls `eth_getUserOperationReceipt` and returns the UserOperationReceipt
*
* @param hash - the hash of the UserOperation to get the receipt for
* @returns - {@link UserOperationReceipt}
* @returns - a user operation receipt or null if not found
*/
getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;

/**
* calls `eth_supportedEntryPoints` and returns the entry points the RPC supports
*
* @returns - {@link Address}[]
* @returns - an array of the entrypoint addresses supported
*/
getSupportedEntryPoints(): Promise<Address[]>;
};
Expand Down
5 changes: 2 additions & 3 deletions aa-sdk/core/src/errors/useroperation.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { UserOperationRequest, UserOperationStruct } from "../types.js";
import { BaseError } from "./base.js";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { dropAndReplaceUserOperation } from "../actions/smartAccount/dropAndReplaceUserOperation.js";

/**
* Thrown when a {@link UserOperationStruct} is not a valid request
* Thrown when a UserOperationStruct is not a valid request
*
* extends viem BaseError
*/
Expand Down Expand Up @@ -41,7 +40,7 @@ export class InvalidUserOperationError extends BaseError {
* Error thrown when waiting for user operation request to be mined.
*
* Includes the internal error as well as the request that failed. This request
* can then be used with {@link dropAndReplaceUserOperation} to retry the operation.
* can then be used with dropAndReplaceUserOperation to retry the operation.
*/
export class WaitForUserOperationError extends BaseError {
/**
Expand Down
4 changes: 2 additions & 2 deletions aa-sdk/core/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
export type NoUndefined<T> = T extends undefined ? never : T;
// borrowed from viem
/**
* @description Checks if {@link T} is `undefined`
* @description Checks if T is `undefined`
* @param T - Type to check
* @example
* type Result = IsUndefined<undefined>
Expand All @@ -27,7 +27,7 @@ export type RequiredBy<TType, TKeys extends keyof TType> = Required<
/**
* @description Combines members of an intersection into a readable type.
*
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
* @see https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
* @example
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
* => { a: string, b: string, c: number, d: bigint }
Expand Down
20 changes: 10 additions & 10 deletions aa-sdk/core/src/utils/userop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export function isValidRequest<
}

/**
* Utility method for asserting a {@link UserOperationRequest} has valid fields for the paymaster data
* Utility method for asserting a UserOperationRequest has valid fields for the paymaster data
*
* @param {UserOperationRequest} request a {@link UserOperationRequest} to validate
* @returns {boolean} a type guard that asserts the {@link UserOperationRequest} is a {@link UserOperationRequest}
* @param {UserOperationRequest} request a UserOperationRequest to validate
* @returns {boolean} a type guard that asserts the UserOperationRequest is a UserOperationRequest
*/
export function isValidPaymasterAndData<
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
Expand All @@ -59,10 +59,10 @@ export function isValidPaymasterAndData<
}

/**
* Utility method for asserting a {@link UserOperationStruct} has valid fields for the paymaster data
* Utility method for asserting a UserOperationStruct has valid fields for the paymaster data
*
* @param {UserOperationRequest} request a {@link UserOperationRequest} to validate
* @returns {boolean} a type guard that asserts the {@link UserOperationStruct} is a {@link UserOperationRequest}
* @param {UserOperationRequest} request a UserOperationRequest to validate
* @returns {boolean} a type guard that asserts the UserOperationStruct is a UserOperationRequest
*/
export function isValidFactoryAndData<
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
Expand All @@ -80,7 +80,7 @@ export function isValidFactoryAndData<
}

/**
* Utility method for applying a {@link UserOperationOverrides} field value
* Utility method for applying a UserOperationOverrides field value
* over the current value set for the field
*
* @param {BigNumberish} value the current value of the field
Expand All @@ -106,7 +106,7 @@ export function applyUserOpOverride<TValue extends BigNumberish | undefined>(
}

/**
* Utility method for applying a {@link UserOperationFeeOptionsField} value
* Utility method for applying a UserOperationFeeOptionsField value
* over the current value set for the field
*
* @param {BigNumberish} value the current value of the field
Expand All @@ -133,8 +133,8 @@ export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
}

/**
* Utility method for applying a {@link UserOperationOverrides} field value and
* a {@link UserOperationFeeOptionsField} value over the current value set for the field,
* Utility method for applying a UserOperationOverrides field value and
* a UserOperationFeeOptionsField value over the current value set for the field,
* with the override taking precedence over the fee option
*
* @param {BigNumberish} value the current value of the field
Expand Down
2 changes: 1 addition & 1 deletion aa-sdk/ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"alchemy-sdk": "^3.0.0",
"@account-kit/smart-contracts": "4.0.0-alpha.1",
"@account-kit/smart-contracts": "4.0.0-alpha.4",
"dotenv": "^16.0.3",
"typescript": "^5.0.4",
"typescript-template": "*",
Expand Down
4 changes: 2 additions & 2 deletions aa-sdk/ethers/src/provider-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { AccountSigner } from "./account-signer.js";
import type { EthersProviderAdapterOpts } from "./types.js";

/** Lightweight Adapter for SmartAccountProvider to enable Signer Creation */
/** Lightweight Adapter for SmtAccountProvider to enable Signer Creation */
export class EthersProviderAdapter extends JsonRpcProvider {
readonly accountProvider: SmartAccountClient;

Expand Down Expand Up @@ -85,7 +85,7 @@ export class EthersProviderAdapter extends JsonRpcProvider {
* Connects the Provider to an Account and returns a Signer
*
* @param {SmartContractAccount} account - the account to connect to
* @returns {AccountSigner} an {@link AccountSigner} that can be used to sign and send user operations
* @returns {AccountSigner} an AccountSigner that can be used to sign and send user operations
*/
connectToAccount<TAccount extends SmartContractAccount>(
account: TAccount
Expand Down
2 changes: 1 addition & 1 deletion account-kit/react/src/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type AlchemyAccountsConfigWithUI = AlchemyAccountsConfig & {
*
* @param {CreateConfigProps} props for creating an alchemy account config
* @param {AlchemyAccountsUIConfig} ui the configuration to use for the Auth Components UI
* @returns an alchemy account config object containing the core and client store, as well as the UI config
* @returns {AlchemyAccountsConfigWithUI} an alchemy account config object containing the core and client store, as well as the UI config
*/
export const createConfig = (
props: CreateConfigProps,
Expand Down
2 changes: 1 addition & 1 deletion account-kit/react/src/hydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type HydrateProps = {

/**
* A react component that can be used to hydrate the client store with the provided initial state.
* This method will use {@link hydrate} to hydrate the client store with the provided initial state if one is provided.
* This method will use `hydrate` to hydrate the client store with the provided initial state if one is provided.
* If ssr is set on the account config, then it will run the onMount function within a useEffect hook. Otherwise,
* It will run onMount as soon as the compoonent is rendered.
*
Expand Down
10 changes: 3 additions & 7 deletions account-kit/signer/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
*
* @param {AlchemySignerClientParams} params the parameters required to initialize the client
* @param {ConnectionConfig} params.connection The connection details needed to connect to the service
* @param {object} params.iframeConfig The configuration details for setting up the iframe stamper
* @param {string} params.iframeConfig.iframeElementId The element ID of the iframe
* @param {string} params.iframeConfig.iframeContainerId The container ID for the iframe element
* @param {string} [params.rpId] The relying party ID, defaulting to the current hostname if not provided
* @param {{ iframeElementId?: string; iframeContainerId: string }} params.iframeConfig The configuration details for setting up the iframe stamper
* @param {string} params.rpId The relying party ID, defaulting to the current hostname if not provided
* @param {string} params.rootOrgId The root organization ID
*/
constructor(params: AlchemySignerClientParams) {
Expand Down Expand Up @@ -209,9 +207,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
* const account = await client.completeEmailAuth({ orgId: "user-org-id", bundle: "bundle-from-email" });
* ```
*
* @param {object} config The configuration object for the authentication function
* @param {string} config.bundle The credential bundle to be injected
* @param {string} config.orgId The organization ID to retrieve the user information
* @param {{ bundle: string; orgId: string }} config The configuration object for the authentication function containing the credential bundle to inject and the organization id associated with the user
* @returns {Promise<User>} A promise that resolves to the authenticated user information
*/
public completeEmailAuth = async ({
Expand Down
10 changes: 5 additions & 5 deletions account-kit/signer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export { BaseAlchemySigner } from "./base.js";
export { BaseSignerClient } from "./client/base.js";
export { AlchemySignerWebClient } from "./client/index.js";
export type * from "./client/types.js";
export { DEFAULT_SESSION_MS } from "./session/manager.js";
export type * from "./signer.js";
export { AlchemyWebSigner } from "./signer.js";

export type * from "./types.js";
export { AlchemySignerStatus } from "./types.js";

export { AlchemySignerWebClient } from "./client/index.js";
export type * from "./client/types.js";
export { DEFAULT_SESSION_MS } from "./session/manager.js";
14 changes: 7 additions & 7 deletions account-kit/signer/src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient>
* });
* ```
*
* @param {AlchemySignerParams} params_ The parameters for the Alchemy signer, including the client and session configuration
* @param {AlchemySignerParams} params The parameters for the Alchemy signer, including the client and session configuration
*/
constructor(params_: AlchemySignerParams) {
const { sessionConfig, ...params } =
AlchemySignerParamsSchema.parse(params_);
constructor(params: AlchemySignerParams) {
const { sessionConfig, ...params_ } =
AlchemySignerParamsSchema.parse(params);

let client: AlchemySignerWebClient;
if ("connection" in params.client) {
client = new AlchemySignerWebClient(params.client);
if ("connection" in params_.client) {
client = new AlchemySignerWebClient(params_.client);
} else {
client = params.client;
client = params_.client;
}
super({
client,
Expand Down
Loading

0 comments on commit 3cdea84

Please sign in to comment.