Skip to content

Commit

Permalink
fix jsdocs for types
Browse files Browse the repository at this point in the history
Co-authored-by: Zachary Couchman <zcouchman@gmail.com>
  • Loading branch information
sharonsheah and ZacharyCouchman committed Nov 14, 2023
1 parent d50f1eb commit f3e0662
Showing 23 changed files with 468 additions and 220 deletions.
9 changes: 6 additions & 3 deletions packages/checkout/sdk/src/errors/checkoutError.ts
Original file line number Diff line number Diff line change
@@ -43,13 +43,16 @@ export enum CheckoutErrorType {

/**
* Represents an error object with a specific type, optional message, and optional data.
* @property {CheckoutErrorType} type - The type of the error.
* @property {string | undefined} [message] - The error message.
* @property {Object.<string, string> | undefined} [data] - Additional data associated with the error.
* @property {CheckoutErrorType} type
* @property {string | undefined} [message]
* @property {Object.<string, string> | undefined} [data]
*/
export type ErrorType = {
/** The type of the error. */
type: CheckoutErrorType;
/** The error message. */
message?: string;
/** Additional data associated with the error. */
data?: { [key: string]: string };
};

72 changes: 49 additions & 23 deletions packages/checkout/sdk/src/types/config.ts
Original file line number Diff line number Diff line change
@@ -22,41 +22,55 @@ export interface CheckoutModuleConfiguration extends ModuleConfiguration<Checkou
/**
* A type representing various remotely defined configurations which are
* accessible via the Checkout config and configured based on the Environment.
* @property {DexConfig} dex - The config used for the DEX.
* @property {OnRampConfig} onramp - The config used for the OnRamp
* @property {AllowedNetworkConfig[]} allowedNetworks - An array representing the allowed networks.
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens - The config for the tokens used to estimate gas.
* @property {DexConfig} dex
* @property {OnRampConfig} onramp
* @property {BridgeConfig} bridge
* @property {AllowedNetworkConfig[]} allowedNetworks
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens
* @property {ImxAddressConfig | undefined} imxAddressMapping
*/
export type RemoteConfiguration = {
/** The config used for the DEX. */
dex: DexConfig;
/** The config used for the OnRamp */
onramp: OnRampConfig;
/** The config used for the Bridge. */
bridge: BridgeConfig;
/** An array representing the allowed networks. */
allowedNetworks: AllowedNetworkConfig[];
/** The config for the tokens used to estimate gas. */
gasEstimateTokens?: GasEstimateTokenConfig;
/** The IMX address mappings across available networks. */
imxAddressMapping?: ImxAddressConfig;
};

/**
* A type representing the fee structure for an OnRamp provider
* @property {string | undefined} minPercentage - minimum percentage fee shown if a fee range is provided
* @property {string | undefined} maxPercentage - maximum percentage fee shown if a fee range is provided
* @property {string | undefined} feePercentage - specific fee percentage shown if there is no range provided
* @property {string | undefined} minPercentage
* @property {string | undefined} maxPercentage
* @property {string | undefined} feePercentage
*/
export type OnRampProviderFees = {
/** The minimum percentage fee shown if a fee range is provided */
minPercentage?: string;
/** The maximum percentage fee shown if a fee range is provided */
maxPercentage?: string;
/** The specific fee percentage shown if there is no range provided */
feePercentage?: string;
};

/**
* A type representing the configuration for the OnRamp for a specific provider.
* @property {string} publishableApiKey - on ramp provider publishable api-key
* @property {TokenInfo[]} tokens - allowed tokens for the OnRamp provider
* @property {OnRampProviderFees} fees - on ramp provider transaction fees
* @property {string} publishableApiKey
* @property {TokenInfo[]} tokens
* @property {OnRampProviderFees} fees
*/
export type OnRampProviderConfig = {
/** The on ramp provider publishable api-key */
publishableApiKey: string,
/** The allowed tokens for the OnRamp provider */
tokens: TokenInfo[],
/** The on ramp provider transaction fees */
fees: OnRampProviderFees
};

@@ -65,35 +79,40 @@ export enum OnRampProvider {
}
/**
* A type representing the configuration for the OnRamp.
* @property {OnRampProviderConfig} transak - OnRamp config for Transak provider
* @property {OnRampProviderConfig} transak
*/
export type OnRampConfig = {
/** OnRamp config for Transak provider */
[key: string]: OnRampProviderConfig;
};

/**
* A type representing the configuration for the DEX.
* @property {ExchangeOverrides | undefined} overrides - The DEX overrides.
* @property {TokenInfo[] | undefined} tokens - An array of tokens compatible with the DEX.
* @property {ExchangeOverrides | undefined} overrides
* @property {TokenInfo[] | undefined} tokens
*/
export type DexConfig = {
/** The DEX overrides. */
overrides?: ExchangeOverrides;
/** An array of tokens compatible with the DEX. */
tokens?: TokenInfo[];
};

/**
* A type representing the configuration for the Bridge.
* @property {TokenInfo[] | undefined} tokens - An array of tokens compatible with the Bridge.
* @property {TokenInfo[] | undefined} tokens
*/
export type BridgeConfig = {
/** An array of tokens compatible with the Bridge. */
tokens?: TokenInfo[];
};

/**
* A type representing an allowed network.
* @property {number} chainId - The network chain id.
* @property {number} chainId
*/
export type AllowedNetworkConfig = {
/** The network chain id. */
chainId: number;
};

@@ -110,33 +129,38 @@ export type ImxAddressConfig = {
* @type {{ [key: string]: { bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig, swapAddresses?: GasEstimateSwapTokenConfig } }}
* - A map of addresses for estimating gas keyed by the network chain id.
* @property {GasEstimateBridgeToL2TokenConfig | undefined} bridgeToL2Addresses
* - The type representing the addresses for a bridge to layer 2 gas estimate.
* @property {GasEstimateSwapTokenConfig | undefined} swapAddresses - The type representing the addresses for a swap gas estimate
* @property {GasEstimateSwapTokenConfig | undefined} swapAddresses
*/
export type GasEstimateTokenConfig = {
[key: string]: {
/** The type representing the addresses for a bridge to layer 2 gas estimate. */
bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig;
/** The type representing the addresses for a swap gas estimate */
swapAddresses?: GasEstimateSwapTokenConfig;
};
};

/**
* A type representing the config for a bridge to layer 2 gas estimate.
* @property {string | 'NATIVE'} gasTokenAddress - The address of the gas token.
* @property {string} fromAddress - The address of the token being bridged.
* @property {string | 'NATIVE'} gasTokenAddress
* @property {string} fromAddress
*/
export type GasEstimateBridgeToL2TokenConfig = {
/** The address of the gas token. */
gasTokenAddress: string | 'NATIVE';
/** The address of the token being bridged. */
fromAddress: string;
};

/**
* A type representing the config for a swap gas estimate.
* @property {string} inAddress - The in token address.
* @property {string} outAddress - The out token address.
* @property {string} inAddress
* @property {string} outAddress
*/
export type GasEstimateSwapTokenConfig = {
/** The in token address. */
inAddress: string;
/** The out token address. */
outAddress: string;
};

@@ -149,10 +173,12 @@ export type ChainsTokensConfig = {

/**
* A type representing all the feature flags available.
* @property {TokenInfo[] | undefined} allowed - List of allowed tokens for a given chain.
* @property {boolean | undefined} blockscout - Feature flag to enable/disable blockscout integration.
* @property {TokenInfo[] | undefined} allowed -
* @property {boolean | undefined} blockscout -
*/
export type ChainTokensConfig = {
/** List of allowed tokens for a given chain. */
allowed?: TokenInfo[];
/** Feature flag to enable/disable blockscout integration. */
blockscout?: boolean;
};
Loading

0 comments on commit f3e0662

Please sign in to comment.