UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

48 lines • 1.57 kB
import { Address } from "./types.cjs"; declare namespace resources_d_exports { export { Erc20Resource, NativeResource, Resource, erc20, native }; } /** A resource declaration representing the chain's native token (e.g. ETH, MATIC). */ export interface NativeResource { readonly kind: "native"; readonly chainId: number; } /** A resource declaration representing an ERC-20 token at a specific address. */ export interface Erc20Resource { readonly kind: "erc20"; readonly token: Address; readonly chainId: number; } /** A token resource — either the chain's native token or an ERC-20. */ export 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) }, * }); * ``` */ export 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) }, * }); * ``` */ export declare const erc20: (token: Address, chainId: number) => Erc20Resource; export { resources_d_exports };