UNPKG

@keyban/sdk-base

Version:

Keyban Javascript SDK provides core functionalities for the MPC wallet solution, supporting web and Node.js apps with TypeScript, custom storage, and Ethereum blockchain integration.

912 lines (899 loc) 35.1 kB
import { GqlKeybanClient_TokenContractFragment, GqlKeybanClient_OrderFragment } from './graphql.mjs'; import { NormalizedCacheObject } from '@apollo/client/cache'; import { ApolloClient } from '@apollo/client/core'; import './SdkError-DzGadnVF.mjs'; import '@graphql-typed-document-node/core'; type Hex$1 = `0x${string}`; type PasswordLoginInput = { usernameInputName: string; passwordInputName: string; }; type PasswordlessStartInput = { connection: "email"; emailInputName: string; } | { connection: "sms"; phoneCallingCode: string; phoneInputName: string; }; type PasswordlessLoginInput = PasswordlessStartInput & { otpInputName: string | string[]; }; interface IKeybanAuth { isAuthenticated(): Promise<boolean>; getUser(): Promise<KeybanUser | null>; getLoginUrl(connection?: AuthConnection): Promise<string>; getLogoutUrl(redirect?: string): Promise<string>; passwordLogin(input: PasswordLoginInput): Promise<void>; passwordlessStart(input: PasswordlessStartInput): Promise<void>; passwordlessLogin(input: PasswordlessLoginInput): Promise<void>; } interface IKeybanSigner { dkg(): Promise<string>; sign(clientShare: string, message: string): Promise<Hex$1>; publicKey(clientShare: string): Promise<Hex$1>; } interface IKeybanAccount { getAddress(): Promise<string>; } interface IKeybanLoyalty { initAccountSetup(): Promise<string>; initAccountDestroy(): Promise<string>; submitAccountSetup(rawTransaction: string): Promise<void>; submitAccountDestroy(rawTransaction: string): Promise<void>; } interface IKeybanClientShareStorage { get(key: string): Promise<string | null>; set(key: string, clientShare: string): Promise<void>; } interface IKeybanDpp { claim(dppId: string, recipient: string): Promise<{ transactionHash: string; }>; } type CastFn<T> = T extends (...args: any[]) => any ? T : never; interface IRpc { auth: IKeybanAuth; ecdsa: IKeybanSigner; eddsa: IKeybanSigner; account: IKeybanAccount; loyalty: IKeybanLoyalty; clientShareStorage: IKeybanClientShareStorage; dpp: IKeybanDpp; } type Service = keyof IRpc; type Method<S extends Service> = keyof IRpc[S] & string; type ClassMethod<S extends Service, M extends Method<S>> = CastFn<IRpc[S][M]>; declare abstract class RpcServer implements IRpc { #private; abstract auth: IKeybanAuth; abstract ecdsa: IKeybanSigner; abstract eddsa: IKeybanSigner; abstract account: IKeybanAccount; abstract loyalty: IKeybanLoyalty; abstract clientShareStorage: IKeybanClientShareStorage; abstract dpp: IKeybanDpp; constructor(); abstract checkEventOrigin(eventOrigin: string): Promise<boolean>; } type RpcClientOptions = { apiUrl: URL | string; appId: string; network: KeybanNetwork; }; declare class RpcClient { #private; static getInstance(options: RpcClientOptions): RpcClient; private constructor(); destroy(): void; call<S extends Service, M extends Method<S>, CM extends ClassMethod<S, M> = ClassMethod<S, M>>(service: S, method: M, ...params: Parameters<CM>): Promise<Awaited<ReturnType<CM>>>; } type EvmFeeDetails = { /** * The maximum fee per unit of gas. */ maxFeePerGas: bigint; /** * The maximum priority fee per unit of gas. */ maxPriorityFeePerGas: bigint; }; /** * Represents the fee details for Stellar transactions. * It corresponds to the fees per operation to be paid in case of a network congestion. * Otherwise it is always the base fee of 100 stroops (0.00001 XLM) per operation. */ type StellarFeeDetails = string; /** * @module Account */ type FeeDetails = EvmFeeDetails | StellarFeeDetails; /** * Represents the estimation of fees for a transaction. * @see {@link KeybanAccount#estimateTransfer} */ type FeesEstimation = { /** * The total maximum fees for the transaction. */ maxFees: bigint; details: FeeDetails; }; /** * Represents the parameters for transferring ERC20 tokens. * @property {Address} contractAddress - The address of the ERC20 token contract * @property {Address} to - The recipient's address * @property {bigint} value - The transfer amount in the smallest token unit * @property {FeeDetails} fees - The transaction fees details * @see {@link KeybanAccount#transferERC20} */ type TransferERC20Params<TFeeDetails = FeeDetails> = { contractAddress: Address; to: Address; value: bigint; fees?: TFeeDetails; }; /** * Represents the parameters for transferring ERC721 and ERC1155 tokens. * @property {Address} contractAddress - The address of the NFT contract * @property {bigint} tokenId - The ID of the token * @property {Address} to - The recipient's address * @property {bigint} value - The transfer amount (for ERC1155 tokens) * @property {FeeDetails} fees - The transaction fees details * @property {string} standard - The token standard (ERC721 or ERC1155) * @see {@link KeybanAccount#transferNft} */ type TransferNftParams<TFeeDetails = FeeDetails> = { contractAddress: Address; tokenId: bigint; to: Address; value?: bigint; standard: "ERC721" | "ERC1155"; fees?: TFeeDetails; }; /** * Represents the parameters required to estimate an ERC20 token transfer, * excluding the fee details. * * This type is derived from `TransferERC20Params` by omitting the `fees` property. */ type EstimateERC20TransferParams = Omit<TransferERC20Params, "fees">; /** * Parameters required to estimate the transfer of an NFT, excluding the fee details. * * This type is derived from `TransferNftParams` by omitting the `fees` property. * @see {@link TransferNftParams} */ type EstimateNftTransferParams = Omit<TransferNftParams, "fees">; /** * A `KeybanAccount` represents a user's account in the Keyban system. * It provides methods to interact with the blockchain, including signing messages, * fetching balances, transferring tokens, and estimating transaction costs. */ declare abstract class KeybanAccount { /** * The blockchain address associated with the account. */ abstract address: Address; /** * The public key associated with the account. */ abstract publicKey: string; protected rpcClient: RpcClient; /** * KeybanAccount constructor * @param rpcClient - the keyban rpc client * @private */ constructor(rpcClient: RpcClient); /** * Signs an Ethereum message. * @param message - The message to be signed. * @returns - The signed message as a hex string. * @throws {Error} If the message is empty or there is an issue during signing. */ abstract signMessage(message: string): Promise<Hex | string | string[]>; /** * Signs a transaction hash. * @param txHash - The transaction hash to be signed in hex string format. * @returns - The signed transaction as a hex string or an array of hex strings. * @throws {Error} If the transaction hash is invalid or there is an issue during signing. * @internal */ abstract signTransaction(txHash: string): Promise<Hex | string | string[]>; /** * Transfers native tokens to another address. * @param to - The recipient's address. * @param value - The transfer amount in wei (must be greater than 0). * @param fees - Optional transaction fees. * @returns - A promise that resolves to the transaction hash. * @throws {SdkError} If the recipient's address is invalid or the transfer amount is invalid. * @example * ```ts * const handleTransfer = async () => { * // amount, account, recipient, setTransactionHash are state variables * try { * const valueInWei = BigInt(Number(amount) * 1e18); * const txHash = await account.transfer(recipient as Address, valueInWei); * setTransactionHash(txHash); * } catch (err) { * console.log(err); * } * }; * ``` */ abstract transfer(to: Address, value: bigint, fees?: FeeDetails): Promise<Hash | string>; /** * Estimates the cost of transferring native tokens to another address. * @param to - The recipient's address. * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details. * @throws {Error} If there is an issue with estimating the gas or fees. */ abstract estimateTransfer(to: Address): Promise<FeesEstimation>; /** * Transfers ERC20 tokens to another address. * @param params - The parameters for the ERC20 transfer. * @returns - A promise that resolves to the transaction hash. * @throws {SdkError} If the recipient's address is invalid, the contract address is invalid, or the transfer amount is invalid. * @example * ```ts * const handleTransfer = async () => { * // amount, account, recipient, contractAddress, setTransactionHash are state variables * try { * const valueInWei = BigInt(Number(amount) * 1e18); * const txHash = await account.transferERC20({ * contractAddress: contractAddress as Address, * to: recipient as Address, * value: valueInWei, * }); * setTransactionHash(txHash); * } catch (err) { * console.log(err); * } * }; * ``` */ abstract transferERC20(params: TransferERC20Params): Promise<Hash | string>; /** * Estimates the cost of transferring ERC20 tokens to another address. * @param params - The parameters for estimating the ERC20 transfer. * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details. * @throws {Error} If there is an issue with estimating the gas or fees. * @example * ```ts * const handleEstimate = async () => { * // account, recipient, contractAddress, amount, setTransferCost are state variables * try { * const valueInWei = BigInt(Number(amount) * 1e18); * const estimation = await account.estimateTransferERC20({ * contractAddress: contractAddress as Address, * to: recipient as Address, * value: valueInWei, * }); * setTransferCost(estimation.maxFees.toString()); * } catch (err) { * console.log(err); * } * }; * ``` */ abstract estimateERC20Transfer(params: EstimateERC20TransferParams): Promise<FeesEstimation>; /** * Transfers ERC721 and ERC1155 tokens to another address. * @param params - The parameters for the NFT transfer. * @returns - A promise that resolves to the transaction hash. * @throws {SdkError} If the recipient's address is invalid, the contract address is invalid, the transfer amount is invalid, or the token standard is invalid. * @example * ```ts * const handleTransfer = async () => { * // account, recipient, contractAddress, tokenId, amount, standard, setTransactionHash are state variables * try { * const value = BigInt(amount); * const txHash = await account.transferNft({ * contractAddress: contractAddress as Address, * tokenId: tokenId as bigint, * to: recipient as Address, * value: value, * standard: standard as 'ERC721' | 'ERC1155', * }); * setTransactionHash(txHash); * } catch (err) { * console.log(err); * } * }; * ``` */ abstract transferNft(params: TransferNftParams): Promise<Hash>; /** * Estimates the cost of transferring ERC721 and ERC1155 tokens to another address. * @param params - The parameters for estimating the NFT transfer. * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details. * @throws {Error} If there is an issue with estimating the gas or fees. * @example * ```ts * const handleEstimate = async () => { * // account, recipient, contractAddress, tokenId, amount, standard, setTransferCost are state variables * try { * const value = BigInt(amount); * const estimation = await account.estimateNftTransfer({ * contractAddress: contractAddress as Address, * tokenId: tokenId as bigint, * to: recipient as Address, * value: value, * standard: standard as 'ERC721' | 'ERC1155', * }); * setTransferCost(estimation.maxFees.toString()); * } catch (err) { * console.log(err); * } * }; * ``` */ abstract estimateNftTransfer(params: EstimateNftTransferParams): Promise<FeesEstimation>; /** * Claims a DPP for a given recipient. * @param dppId - The identifier of the Tokenized Product Passport (DPP) to claim. * @returns A promise that resolves with the result of the RPC call. */ dppClaim(dppId: string): Promise<{ transactionHash: string; }>; /** * Sets up the account for the loyalty application. * This method signs a setup transaction and submits it to the network. * It makes the account ready to be used with the loyalty application. * It depends on the blockchain network. * @returns A promise that resolves when the setup is complete. */ loyaltySetup(): Promise<void>; /** * Destroys the loyalty setup for the account. * @internal * @returns A promise that resolves when the loyalty setup is destroyed. */ loyaltyDestroy(): Promise<void>; } /** * @module API */ /** * Represents the status of the Keyban API. */ type KeybanApiStatus = "operational" | "down"; /** * @module Chains */ /** * @enum {string} * The `KeybanNetwork` enumeration defines the various blockchain networks supported by the Keyban SDK. * Each member of the enumeration represents a specific blockchain network identified by its unique name. * @remarks * Use this enumeration to specify the blockchain network you wish to interact with when utilizing * the different functionalities of the Keyban SDK, such as account management, transactions, and NFTs. * @example * ```typescript * import { KeybanClient, KeybanNetwork } from '@keyban/sdk'; * * const client = new KeybanClient({ * apiUrl: "https://api.prod.keyban.io", * appId: "your-app-id", * network: KeybanNetwork.EthereumAnvil, * }); * ``` */ declare enum KeybanNetwork { /** * Ethereum Anvil Chain. * Primarily used for development and testing purposes. This chain allows simulation of * transactions and interactions without affecting the main chain. */ EthereumAnvil = "EthereumAnvil", /** * Polygon Amoy Chain. * Represents the Polygon Amoy mainnet, offering fast transactions and reduced fees. * Ideal for production applications requiring high performance. */ PolygonAmoy = "PolygonAmoy", /** * Starknet Devnet Chain. */ StarknetDevnet = "StarknetDevnet", /** * Starknet Sepolia Chain. */ StarknetSepolia = "StarknetSepolia", /** * Starknet Mainnet Chain. */ StarknetMainnet = "StarknetMainnet", /** * Stellar Quickstart Chain. */ StellarQuickstart = "StellarQuickstart", /** * Stellar Testnet Chain. */ StellarTestnet = "StellarTestnet", /** * Stellar Mainnet Chain. */ StellarMainnet = "StellarMainnet" } /** * Represents the unit of fees in a specific blockchain. * @property {string} symbol - The symbol of the fee unit (e.g., "gwei"). * @property {number} decimals - The number of decimal places for the fee unit. */ type FeesUnit = { symbol: string; decimals: number; }; /** * Represents the native currency of a blockchain network. * @property {string} name - The name of the native currency (e.g., "Ether"). * @property {string} symbol - The symbol of the native currency (e.g., "ETH"). * @property {number} decimals - The number of decimal places the currency can be divided into. * @example * const nativeCurrency = { * name: "Ether", * symbol: "ETH", * decimals: 18 * }; * @example * const nativeCurrency = { * name: "Bitcoin", * symbol: "BTC", * decimals: 8 * }; */ type NativeCurrency = { name: string; symbol: string; decimals: number; }; /** * Represents a storage provider for the client share. * * The purpose of `ClientShareProvider` is to provide an interface that allows integrators * to save and restore the client share of their customers. The integrator has the * responsibility to securely store the client share. * @remarks * The client share is not considered sensitive data because only the client * can use it, and its usage is secured by strong authentication between the client * and the Keyban services. * * ### Example Implementation * * Below is a basic implementation of a `CustomClientShareProvider` using a fetch-based provider: * * ```typescript * class CustomClientShareProvider implements ClientShareProvider { * // Retrieves the client share data. * // @returns - A promise resolving to the client share string or `null` if unavailable. * async get(): Promise<string | null> { * try { * const response = await fetch("/api/clientShare", { * method: "GET", * headers: { "Content-Type": "application/json" }, * }); * * if (!response.ok) { * console.error("Failed to fetch client share:", response.statusText); * return null; * } * * return response.text(); * } catch (error) { * console.error("Error retrieving client share:", error); * return null; * } * } * * * // Saves the client share data. * // @param clientShare - The client share string to store. * // @returns - A promise that resolves when the operation is complete. * async set(clientShare: string): Promise<void> { * try { * const response = await fetch("/api/clientShare", { * method: "POST", * headers: { "Content-Type": "application/json" }, * body: JSON.stringify({ clientShare }), * }); * * if (!response.ok) { * throw new Error(`Failed to save client share: ${response.statusText}`); * } * } catch (error) { * console.error("Error saving client share:", error); * throw error; * } * } * } * ``` * * This implementation assumes the existence of an API endpoint `/api/clientShare` * to manage the client share on the server side. The integrator should ensure that * the endpoint is appropriately secured. */ interface ClientShareProvider { /** * Retrieves the client share information. * @param key - The key associated with the client share. * @returns - A promise that resolves to a string containing the client share, or null if not available. */ get(key: string): Promise<string | null>; /** * Sets the client share information. * @param key - The key associated with the client share. * @param clientShare - The client share string to set. * @returns - A promise that resolves when the client share has been set. */ set(key: string, clientShare: string): Promise<unknown>; } /** * Configuration options for initializing the Keyban client. */ type KeybanClientConfig = { /** * The base URL of the API. Optional. Defaults to "https://api.prod.keyban.io" if not provided. */ apiUrl?: URL | string; /** * The application ID. */ appId: string; /** * The blockchain configuration for Keyban. */ network: KeybanNetwork; /** * The client share provider. */ clientShareProvider: ClientShareProvider; }; type MetadataConfig = { network: { rpcUrl: string; indexerUrl: string; horizonUrl?: string; }; auth: { domain: string; clientId: string; }; }; declare abstract class KeybanClientBase { /** * The Keyban API URL, defaulting to "https://api.prod.keyban.io". */ apiUrl: URL; /** * The application ID used for authentication with the Keyban API. */ appId: string; /** * The blockchain used by Keyban. */ network: KeybanNetwork; /** * The Apollo GraphQL client used for making API requests. */ apolloClient: ApolloClient<NormalizedCacheObject>; protected clientShareProvider: ClientShareProvider; protected metadataConfig: Promise<MetadataConfig>; constructor(config: KeybanClientConfig, metadataConfig?: Promise<MetadataConfig>); protected get rpcClient(): RpcClient; /** * Retrieves the native currency details associated with the current chain. * * This getter returns an object that includes the native currency's name, symbol, and decimal precision for the respective blockchain * as defined by the `this.chain` property. Each blockchain in the supported list (e.g., EthereumAnvil, PolygonAmoy, StarknetDevnet, etc.) * has its unique configuration, which is used to construct the returned object. * @returns The native currency information for the current chain. */ get nativeCurrency(): NativeCurrency; /** * Retrieves the fee unit configuration based on the current blockchain chain. * * This getter returns an object that maps supported blockchain chains to their respective * fee unit details, including the currency symbol and the number of decimal places. * The fee unit is selected according to the chain specified in `this.chain`. * @remarks * Supported configurations include: * - EthereumAnvil & PolygonAmoy with unit "gwei" and 9 decimals. * - StarknetDevnet, StarknetSepolia, & StarknetMainnet with unit "FRI" and 18 decimals. * - StellarTestnet with unit "stroop" and 6 decimals. * @returns An object containing the fee unit configuration for the active chain. */ get feesUnit(): FeesUnit; /** * Performs a health check on the Keyban API to determine its operational status. * @returns - A promise resolving to the API status, either `"operational"` or `"down"`. * @example * ```typescript * const status = await client.apiStatus(); * console.log(`API Status: ${status}`); * ``` * @throws {Error} Throws an error if the health check request fails. * @see {@link KeybanApiStatus} */ apiStatus(): Promise<KeybanApiStatus>; /** * Checks whether the client is authenticated. * @returns A Promise that resolves to the result of the authentication check. */ isAuthenticated(): Promise<boolean>; /** * Retrieves the current user information. * @returns A Promise resolving with the user data retrieved from the server. */ getUser(): Promise<KeybanUser | null>; passwordLogin(input: PasswordLoginInput): Promise<void>; passwordlessStart(input: PasswordlessStartInput): Promise<void>; passwordlessLogin(input: PasswordlessLoginInput): Promise<void>; /** * Initiates the login process by opening a popup window for user authentication. * @param [connection] - Optional authentication connection details. * @returns - A promise that resolves when the user is authenticated or the popup is closed. */ login(connection?: AuthConnection): Promise<void>; logout(): Promise<void>; /** * Initializes a `KeybanAccount` associated with the current client. * This method sets up the account by retrieving or generating the client share, * and prepares the account for transactions and other operations. * @returns - A promise that resolves to an instance of `KeybanAccount`. * @throws {SdkError} If initialization fails due to signing errors. * @example * ```typescript * const account = await client.initialize(); * console.log(`Account address: ${account.address}`); * ``` * @see {@link KeybanAccount} */ abstract initialize(): Promise<KeybanAccount>; } /** * Main client for interacting with the Keyban API and associated services. * This class provides methods to initialize accounts, retrieve balances, query NFTs, * and interact with the Keyban blockchain. * @remarks * The `KeybanClient` serves as the primary interface for developers to interact with * the Keyban ecosystem. It handles authentication, communication with the Keyban API, * and provides utility methods for common tasks. * @example * ```typescript * // Initialize the client * const client = new KeybanClient({ * apiUrl: "https://api.prod.keyban.io", * appId: "your-app-id", * network: KeybanNetwork.EthereumAnvil, * }); * * // Initialize an account * const account = await client.initialize(); * ``` * @see {@link KeybanAccount} */ declare class KeybanClient extends KeybanClientBase { #private; /** * Creates a new instance of `KeybanClient`. * @param config - The configuration object to initialize the client. * @throws {SdkError} If the configuration is invalid. * @example * ```typescript * const client = new KeybanClient({ * apiUrl: "https://api.prod.keyban.io", * appId: "your-app-id", * network: KeybanNetwork.EthereumAnvil, * }); * ``` */ constructor(config: KeybanClientConfig); initialize(): Promise<KeybanAccount>; } /** * A client share provider implementation for the Keyban client. * * The `KeybanClientShareProvider` class provides methods to get and set the client share. * This class is used to interact with the client share storage on the server side. * @remarks * The client share is saved in a service provided by Keyban, ensuring secure storage * and retrieval of the client share information. */ declare class KeybanClientShareProvider implements ClientShareProvider { #private; /** * Internal use only. * @param client - A keyban client * @private */ registerClient(client: KeybanClientBase): void; /** * Retrieves the client share information. * @param key - The key associated with the client share. * @returns - A promise that resolves to a string containing the client share, or null if not available. */ get(key: string): Promise<string | null>; /** * Sets the client share information. * @param key - The key associated with the client share. * @param clientShare - The client share string to set. * @returns - A promise that resolves when the client share has been set. */ set(key: string, clientShare: string): Promise<unknown>; } /** * Represents a balance with optional metadata. * @example * // Example of a balance in native currency with fees * const balance: Balance = { * raw: '1000000000000000000', * decimals: 18, * symbol: 'ETH', * isNative: true, * isFees: true * }; * @example * // Example of a balance in a token * const tokenBalance: Balance = { * raw: BigInt('500000000000000000'), * decimals: 18, * symbol: 'DAI' * }; */ type Balance = { /** The raw balance value. */ raw: string | bigint; /** The number of decimal places for the balance. */ decimals?: number; /** The symbol of the currency. */ symbol?: string; /** Indicates if the balance is in the native currency. */ isNative?: boolean; /** Indicates if the balance is used for fees. */ isFees?: boolean; }; /** * Formats the balance into a human-readable string with the appropriate decimals and symbol. * @param client - The KeybanClient instance which provides information about fees and native currency. * @param balance - The balance object containing raw balance, decimals, symbol, and flags indicating if it's fees or native currency. * @param [token] - (Optional) The KeybanToken object which provides token-specific decimals and symbol. * @returns - A formatted string representing the balance with the appropriate decimals and symbol. * * test * @example * ```typescript * const client = new KeybanClient(...); * const balance = { raw: 1000000000000000000n, decimals: 18, isNative: true }; * console.log(formatBalance(client, balance)); // "1 ETH" * * const balanceWithToken = { raw: 1000000n }; * const token = { * id: '1', * type: 'ERC20', * name: 'Tether', * symbol: 'USDT', * decimals: 6, * iconUrl: 'https://example.com/usdt-icon.png' * }; * console.log(formatBalance(client, balanceWithToken, token)); // "1 USDT" * * const feeBalance = { raw: 1000n, isFees: true }; * console.log(formatBalance(client, feeBalance)); // "0.000001 gwei" * ``` */ declare function formatBalance(client: KeybanClient, balance: Balance, token?: GqlKeybanClient_TokenContractFragment): string; type Prettify<T> = { [K in keyof T]: T[K]; } & {}; type OrderItem = { id: number; itemId: number; name: string; price: number; }; type Order = Prettify<Omit<GqlKeybanClient_OrderFragment, "items"> & { items: OrderItem[]; }>; /** * Represents an Ethereum address in hexadecimal format. * @remarks * An Ethereum address is a 42-character string that uniquely identifies an account on the Ethereum blockchain. * It consists of the prefix `"0x"` followed by 40 hexadecimal characters (digits 0-9 and letters a-f). * Ethereum addresses are case-insensitive, but it is recommended to use the checksum address format * (mix of uppercase and lowercase letters) for better error detection. * * **Format:** * - **Prefix:** Must start with `"0x"`. * - **Length:** Total of 42 characters (including the `"0x"` prefix). * - **Characters:** The following 40 characters should be valid hexadecimal digits (`0-9`, `a-f`, `A-F`). * - **Example without checksum:** `"0x742d35cc6634c0532925a3b844bc454e4438f44e"` * - **Example with checksum:** `"0x742d35Cc6634C0532925a3b844Bc454e4438f44e"` * * **Usage:** * This type alias enforces that any variable of type `Address` must be a string that adheres to the Ethereum address format. * It is used throughout the SDK to represent addresses in a type-safe manner, reducing errors related to address handling. */ type Address = string; /** * Represents a cryptographic hash value in hexadecimal format. * @remarks * A `Hash` is typically a 66-character hexadecimal string used to uniquely identify * transactions, blocks, or other data in the blockchain. It is the result of a hash * function (like SHA-256 or Keccak-256) applied to some data. * * **Format:** * - **Prefix:** Must start with `"0x"`. * - **Length:** Usually 66 characters (including the `"0x"` prefix), representing 32 bytes of data. * - **Characters:** The following characters should be valid hexadecimal digits (`0-9`, `a-f`, `A-F`). * - **Example:** `"0x5e1d3a76f95b1f9ed1e7f8e0e9a2b2e4b6d4c8d5e3a7b9f1c2d3e4f5a6b7c8d9"` * * **Usage:** * The `Hash` type alias ensures that any variable representing a hash value conforms to the expected format. * Hashes are used throughout blockchain operations to reference specific transactions, blocks, or data. * * **Common Use Cases:** * - **Transaction Hashes:** Identifying specific transactions on the blockchain. * - **Block Hashes:** Referencing specific blocks in the blockchain. * - **Data Integrity Checks:** Verifying that data has not been tampered with by comparing hash values. */ type Hash = `0x${string}`; /** * Represents a hexadecimal value in blockchain-related contexts. * @remarks * The `Hex` type is a string that starts with the `"0x"` prefix, followed by a sequence of hexadecimal characters. * It is commonly used to represent various types of data in hexadecimal format, such as public keys, signed messages, * transaction data, and more. The length of the hexadecimal string can vary depending on what it represents. * * **Format:** * - **Prefix:** Must start with `"0x"`. * - **Characters:** The characters following the prefix should be valid hexadecimal digits (`0-9`, `a-f`, `A-F`). * - **Length:** Variable length, depending on the data being represented. * - **Examples:** * - **Public Key (uncompressed):** Typically 130 characters (representing 65 bytes). * - Example: `"0x04bfcab42e267cde6bf56789237f24e63bb1b2c4a7a2938a1df47f8e0e3d1b45ae9ef1e3b5a72f2df9f3e6f7d8c1a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8"` * - **Signed Message:** Length can vary depending on the signature algorithm. * - Example: `"0x1b8e0a12f31f3b5c3c1b6e9f0d4a7f5e6b7d8c9a0e1f2a3b4c5d6e7f8e9f0a1b"` * * **Usage:** * The `Hex` type alias ensures that any variable representing a hexadecimal value conforms to the expected format. * It is used throughout the SDK to represent binary data in a human-readable hexadecimal string format. * This is especially important for serialization, storage, and transmission of data in blockchain applications. * * **Common Use Cases:** * - **Public Keys:** Representing public keys in hexadecimal format for cryptographic operations. * - **Signatures:** Storing and transmitting digital signatures. * - **Transaction Data:** Encoding transaction payloads or other binary data. * - **Hashes and Digests:** While specific types like `Hash` exist, `Hex` can be used for general-purpose hexadecimal data. */ type Hex = string; /** * Arguments for paginating a collection. * @property {number} first - The maximum number of items to retrieve in the current page. */ type PaginationArgs = { /** The maximum number of items to retrieve in the current page. */ first?: number; /** A cursor representing the starting point for the next page */ after?: string; }; /** * Represents the types of authentication connections available. * @type {("username-password" | "google-oauth2")} * @property {"username-password"} username-password - Standard username and password authentication. * @property {"email"} email - One time password send through email. * @property {"sms"} sms - One time password send through sms. * @property {"google-oauth2"} google-oauth2 - Google OAuth 2.0 authentication. */ type AuthConnection = "username-password" | "email" | "sms" | "google-oauth2"; type KeybanUser = { sub: string; name?: string; avatar?: string; email?: string; phoneNumber?: string; }; export { type Address as A, type Balance as B, type ClientShareProvider as C, type EstimateERC20TransferParams as E, type FeeDetails as F, type Hash as H, type IKeybanAccount, type IKeybanAuth, type IKeybanClientShareStorage, type IKeybanDpp, type IKeybanLoyalty, type IKeybanSigner, type KeybanUser as K, type NativeCurrency as N, type OrderItem as O, type PaginationArgs as P, type PasswordLoginInput, type PasswordlessLoginInput, type PasswordlessStartInput, RpcClient, RpcServer, type TransferERC20Params as T, type Order as a, type Hex as b, type AuthConnection as c, type EstimateNftTransferParams as d, type FeesEstimation as e, KeybanAccount as f, type TransferNftParams as g, type KeybanApiStatus as h, KeybanClient as i, type KeybanClientConfig as j, KeybanClientShareProvider as k, type FeesUnit as l, KeybanNetwork as m, formatBalance as n };