From bb2c7224be8f68c5a67ecfa4469c37e63d4226f5 Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Tue, 15 Jul 2025 11:18:04 -0700 Subject: [PATCH] chore: update UB jsdocs to include types --- .../components/Document/AuthMethodsTabs.tsx | 2 +- packages/thirdweb/src/bridge/Buy.ts | 50 +++++++++++++++++++ packages/thirdweb/src/bridge/Chains.ts | 17 +++++++ packages/thirdweb/src/bridge/Onramp.ts | 30 +++++++++++ packages/thirdweb/src/bridge/Routes.ts | 27 ++++++++++ packages/thirdweb/src/bridge/Sell.ts | 49 ++++++++++++++++++ packages/thirdweb/src/bridge/Status.ts | 23 +++++++++ packages/thirdweb/src/bridge/Transfer.ts | 24 +++++++++ 8 files changed, 221 insertions(+), 1 deletion(-) diff --git a/apps/portal/src/components/Document/AuthMethodsTabs.tsx b/apps/portal/src/components/Document/AuthMethodsTabs.tsx index 9ccf29d2374..d4fab5fa99b 100644 --- a/apps/portal/src/components/Document/AuthMethodsTabs.tsx +++ b/apps/portal/src/components/Document/AuthMethodsTabs.tsx @@ -762,7 +762,7 @@ function AuthMethodsTabsContent() { > {method.label}
diff --git a/packages/thirdweb/src/bridge/Buy.ts b/packages/thirdweb/src/bridge/Buy.ts index ba7d5b74eeb..398215b79a2 100644 --- a/packages/thirdweb/src/bridge/Buy.ts +++ b/packages/thirdweb/src/bridge/Buy.ts @@ -155,23 +155,47 @@ export async function quote(options: quote.Options): Promise { }; } +/** + * Namespace containing types for the buy quote function. + * @namespace quote + * @bridge Buy + */ export declare namespace quote { + /** + * Options for getting a buy quote. + * @interface Options + * @bridge Buy + */ type Options = { + /** The origin chain ID */ originChainId: number; + /** The origin token address */ originTokenAddress: ox__Address.Address; + /** The destination chain ID */ destinationChainId: number; + /** The destination token address */ destinationTokenAddress: ox__Address.Address; + /** Your thirdweb client */ client: ThirdwebClient; + /** Maximum number of steps in the route */ maxSteps?: number; } & ( | { + /** The amount to buy in wei */ buyAmountWei: bigint; } | { + /** The amount to spend in wei */ amount: bigint; } ); + /** + * Result returned from getting a buy quote. + * Contains quote details and intent information. + * @interface Result + * @bridge Buy + */ type Result = Quote & { intent: { originChainId: number; @@ -404,17 +428,37 @@ export async function prepare( }; } +/** + * Namespace containing types for the buy prepare function. + * @namespace prepare + * @bridge Buy + */ export declare namespace prepare { + /** + * Options for preparing a buy transaction. + * @interface Options + * @bridge Buy + */ type Options = { + /** The origin chain ID */ originChainId: number; + /** The origin token address */ originTokenAddress: ox__Address.Address; + /** The destination chain ID */ destinationChainId: number; + /** The destination token address */ destinationTokenAddress: ox__Address.Address; + /** The sender address */ sender: ox__Address.Address; + /** The receiver address */ receiver: ox__Address.Address; + /** The amount to buy in wei */ amount: bigint; + /** Your thirdweb client */ client: ThirdwebClient; + /** Arbitrary purchase data */ purchaseData?: PurchaseData; + /** Maximum number of steps in the route */ maxSteps?: number; /** * @hidden @@ -422,6 +466,12 @@ export declare namespace prepare { paymentLinkId?: string; }; + /** + * Result returned from preparing a buy transaction. + * Contains prepared quote with transaction data and intent information. + * @interface Result + * @bridge Buy + */ type Result = PreparedQuote & { intent: { originChainId: number; diff --git a/packages/thirdweb/src/bridge/Chains.ts b/packages/thirdweb/src/bridge/Chains.ts index 3789837e46a..4ca00d147b3 100644 --- a/packages/thirdweb/src/bridge/Chains.ts +++ b/packages/thirdweb/src/bridge/Chains.ts @@ -81,10 +81,27 @@ export async function chains(options: chains.Options): Promise { ); } +/** + * Namespace containing types for the chains function. + * @namespace chains + * @bridge + */ export declare namespace chains { + /** + * Options for fetching supported bridge chains. + * @interface Options + * @bridge + */ type Options = { + /** Your thirdweb client */ client: ThirdwebClient; }; + /** + * Result returned from fetching supported bridge chains. + * Contains an array of supported chains. + * @interface Result + * @bridge + */ type Result = Chain[]; } diff --git a/packages/thirdweb/src/bridge/Onramp.ts b/packages/thirdweb/src/bridge/Onramp.ts index e356e712173..75c6e99e645 100644 --- a/packages/thirdweb/src/bridge/Onramp.ts +++ b/packages/thirdweb/src/bridge/Onramp.ts @@ -258,21 +258,45 @@ export async function prepare( }; } +/** + * Namespace containing types for the onramp prepare function. + * @namespace prepare + * @bridge Onramp + */ export declare namespace prepare { + /** + * Options for preparing an onramp transaction. + * @interface Options + * @bridge Onramp + */ export type Options = { + /** Your thirdweb client */ client: ThirdwebClient; + /** The onramp provider to use (e.g., "stripe", "coinbase", "transak") */ onramp: "stripe" | "coinbase" | "transak"; + /** The destination chain ID */ chainId: number; + /** The destination token address */ tokenAddress: ox__Address.Address; + /** The address that will receive the output token */ receiver: ox__Address.Address; + /** The desired token amount in wei */ amount?: bigint; + /** Arbitrary purchase data */ purchaseData?: PurchaseData; + /** An optional address to associate as the onramp sender */ sender?: ox__Address.Address; + /** The token to initially onramp to if the destination token is not supported by the provider */ onrampTokenAddress?: ox__Address.Address; + /** The chain ID to initially onramp to if the destination chain is not supported */ onrampChainId?: number; + /** The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD" */ currency?: string; + /** Maximum number of post-onramp steps */ maxSteps?: number; + /** Chain IDs to exclude from the route (string or array of strings) */ excludeChainIds?: string | string[]; + /** The user's country code (e.g. "US", "JP"). Defaults to "US". We highly recommend this be set (based on the user's IP address) */ country?: string; /** * @hidden @@ -280,5 +304,11 @@ export declare namespace prepare { paymentLinkId?: string; }; + /** + * Result returned from preparing an onramp transaction. + * Contains the onramp link, quote information, and routing steps. + * @interface Result + * @bridge Onramp + */ export type Result = OnrampPrepareQuoteResponseData; } diff --git a/packages/thirdweb/src/bridge/Routes.ts b/packages/thirdweb/src/bridge/Routes.ts index 2e2f27ff3c0..fbf944c22de 100644 --- a/packages/thirdweb/src/bridge/Routes.ts +++ b/packages/thirdweb/src/bridge/Routes.ts @@ -179,20 +179,47 @@ export async function routes(options: routes.Options): Promise { return data; } +/** + * Namespace containing types for the routes function. + * @namespace routes + * @bridge + */ export declare namespace routes { + /** + * Options for fetching available bridge routes. + * @interface Options + * @bridge + */ type Options = { + /** Your thirdweb client */ client: ThirdwebClient; + /** The origin chain ID to filter routes by */ originChainId?: number; + /** The origin token address to filter routes by */ originTokenAddress?: ox__Address.Address; + /** The destination chain ID to filter routes by */ destinationChainId?: number; + /** The destination token address to filter routes by */ destinationTokenAddress?: ox__Address.Address; + /** Transaction hash to filter routes by */ transactionHash?: ox__Hex.Hex; + /** Sort routes by popularity */ sortBy?: "popularity"; + /** Maximum number of steps in the route */ maxSteps?: number; + /** Whether to include price information in the response */ includePrices?: boolean; + /** Number of results to return (pagination) */ limit?: number; + /** Number of results to skip (pagination) */ offset?: number; }; + /** + * Result returned from fetching bridge routes. + * Contains an array of available routes. + * @interface Result + * @bridge + */ type Result = Route[]; } diff --git a/packages/thirdweb/src/bridge/Sell.ts b/packages/thirdweb/src/bridge/Sell.ts index 9a8fe7c5ee0..7a8e1cbf36e 100644 --- a/packages/thirdweb/src/bridge/Sell.ts +++ b/packages/thirdweb/src/bridge/Sell.ts @@ -154,17 +154,40 @@ export async function quote(options: quote.Options): Promise { }; } +/** + * Namespace containing types for the sell quote function. + * @namespace quote + * @bridge Sell + */ export declare namespace quote { + /** + * Options for getting a sell quote. + * @interface Options + * @bridge Sell + */ type Options = { + /** The origin chain ID */ originChainId: number; + /** The origin token address */ originTokenAddress: ox__Address.Address; + /** The destination chain ID */ destinationChainId: number; + /** The destination token address */ destinationTokenAddress: ox__Address.Address; + /** The amount to sell in wei */ amount: bigint; + /** Your thirdweb client */ client: ThirdwebClient; + /** Maximum number of steps in the route */ maxSteps?: number; }; + /** + * Result returned from getting a sell quote. + * Contains quote details and intent information. + * @interface Result + * @bridge Sell + */ type Result = Quote & { intent: { originChainId: number; @@ -393,17 +416,37 @@ export async function prepare( }; } +/** + * Namespace containing types for the sell prepare function. + * @namespace prepare + * @bridge Sell + */ export declare namespace prepare { + /** + * Options for preparing a sell transaction. + * @interface Options + * @bridge Sell + */ type Options = { + /** The origin chain ID */ originChainId: number; + /** The origin token address */ originTokenAddress: ox__Address.Address; + /** The destination chain ID */ destinationChainId: number; + /** The destination token address */ destinationTokenAddress: ox__Address.Address; + /** The amount to sell in wei */ amount: bigint; + /** The sender address */ sender: ox__Address.Address; + /** The receiver address */ receiver: ox__Address.Address; + /** Your thirdweb client */ client: ThirdwebClient; + /** Arbitrary purchase data */ purchaseData?: PurchaseData; + /** Maximum number of steps in the route */ maxSteps?: number; /** * @hidden @@ -411,6 +454,12 @@ export declare namespace prepare { paymentLinkId?: string; }; + /** + * Result returned from preparing a sell transaction. + * Contains prepared quote with transaction data and intent information. + * @interface Result + * @bridge Sell + */ type Result = PreparedQuote & { intent: { originChainId: number; diff --git a/packages/thirdweb/src/bridge/Status.ts b/packages/thirdweb/src/bridge/Status.ts index 0a893f6a98c..e6aec32eefa 100644 --- a/packages/thirdweb/src/bridge/Status.ts +++ b/packages/thirdweb/src/bridge/Status.ts @@ -177,18 +177,41 @@ export async function status(options: status.Options): Promise { }; } +/** + * Namespace containing types for the status function. + * @namespace status + * @bridge + */ export declare namespace status { + /** + * Options for checking transaction status. + * Can specify either chainId or chain object. + * @interface Options + * @bridge + */ type Options = | { + /** The transaction hash to check status for */ transactionHash: ox__Hex.Hex; + /** The chain ID where the transaction occurred */ chainId: number; + /** Your thirdweb client */ client: ThirdwebClient; } | { + /** The transaction hash to check status for */ transactionHash: ox__Hex.Hex; + /** The chain object where the transaction occurred */ chain: Chain; + /** Your thirdweb client */ client: ThirdwebClient; }; + /** + * Result returned from checking transaction status. + * Contains the current status and transaction details. + * @interface Result + * @bridge + */ type Result = Status; } diff --git a/packages/thirdweb/src/bridge/Transfer.ts b/packages/thirdweb/src/bridge/Transfer.ts index f0c24714f9b..d68fcb6db6b 100644 --- a/packages/thirdweb/src/bridge/Transfer.ts +++ b/packages/thirdweb/src/bridge/Transfer.ts @@ -251,15 +251,33 @@ export async function prepare( }; } +/** + * Namespace containing types for the transfer prepare function. + * @namespace prepare + * @bridge Transfer + */ export declare namespace prepare { + /** + * Options for preparing a transfer transaction. + * @interface Options + * @bridge Transfer + */ type Options = { + /** The chain ID */ chainId: number; + /** The token address */ tokenAddress: ox__Address.Address; + /** The sender address */ sender: ox__Address.Address; + /** The receiver address */ receiver: ox__Address.Address; + /** The amount to transfer in wei */ amount: bigint; + /** Your thirdweb client */ client: ThirdwebClient; + /** Arbitrary purchase data */ purchaseData?: PurchaseData; + /** Who pays the fees - sender or receiver */ feePayer?: "sender" | "receiver"; /** * @hidden @@ -267,6 +285,12 @@ export declare namespace prepare { paymentLinkId?: string; }; + /** + * Result returned from preparing a transfer transaction. + * Contains prepared quote with transaction data and intent information. + * @interface Result + * @bridge Transfer + */ type Result = PreparedQuote & { intent: { chainId: number;