UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

57 lines (53 loc) 2.01 kB
import { Address } from './types.js'; /** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */ interface NativeResource { readonly kind: 'native'; readonly chainId: number; } /** A resource declaration representing an ERC-20 token at a specific address. */ interface Erc20Resource { readonly kind: 'erc20'; readonly token: Address; readonly chainId: number; } /** A token resource — either the chain's native token or an ERC-20. */ type Resource = NativeResource | Erc20Resource; /** * Creates a native token resource declaration. * * @param chainId - The EVM chain ID the native token belongs to. * @returns A {@link NativeResource} for use in flow input schemas. * * @example * ```ts * const builder = sdk.flow(1, { * inputs: { eth: native(1) }, * }); * ``` */ declare const native: (chainId: number) => NativeResource; /** * Creates an ERC-20 token resource declaration. * * @param token - The `0x`-prefixed contract address of the ERC-20 token. * @param chainId - The EVM chain ID the token is deployed on. * @returns An {@link Erc20Resource} for use in flow input schemas. * * @example * ```ts * const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; * const builder = sdk.flow(1, { * inputs: { usdc: erc20(USDC, 1) }, * }); * ``` */ declare const erc20: (token: Address, chainId: number) => Erc20Resource; type resourcesMod_Erc20Resource = Erc20Resource; type resourcesMod_NativeResource = NativeResource; type resourcesMod_Resource = Resource; declare const resourcesMod_erc20: typeof erc20; declare const resourcesMod_native: typeof native; declare namespace resourcesMod { export { type resourcesMod_Erc20Resource as Erc20Resource, type resourcesMod_NativeResource as NativeResource, type resourcesMod_Resource as Resource, resourcesMod_erc20 as erc20, resourcesMod_native as native }; } export { type Erc20Resource as E, type NativeResource as N, type Resource as R, erc20 as e, native as n, resourcesMod as r };