@edgex-web/components
Version:
EdgeX Universal UI Components Library - Reusable React components for deposit, withdraw and other common UI patterns
135 lines (134 loc) • 3.56 kB
TypeScript
import { SupportedLocale } from '../locales';
declare global {
interface Window {
ENV?: Record<string, string>;
}
}
export interface ComponentConfig {
theme?: 'light' | 'dark';
locale?: SupportedLocale | string;
apiBaseUrl?: string;
debug?: boolean;
}
export interface DepositConfig {
symbol: string;
onSuccess?: (result: DepositResult) => void;
onError?: (error: Error) => void;
onCancel?: () => void;
}
export interface WithdrawConfig {
symbol: string;
onSuccess?: (result: WithdrawResult) => void;
onError?: (error: Error) => void;
onCancel?: () => void;
}
export interface DepositResult {
transactionId: string;
amount: string;
symbol: string;
status: 'pending' | 'completed' | 'failed';
}
export interface WithdrawResult {
transactionId: string;
amount: string;
symbol: string;
status: 'pending' | 'completed' | 'failed';
}
export interface EventCallbacks {
onSuccess?: (result: DepositResult | WithdrawResult) => void;
onError?: (error: Error) => void;
onCancel?: () => void;
}
export interface GlobalEventData {
type: 'deposit' | 'withdraw';
config: DepositConfig | WithdrawConfig;
}
export interface EventEmitter {
emit: (event: string, data: GlobalEventData) => void;
on: (event: string, callback: (data: GlobalEventData) => void) => void;
off: (event: string, callback: (data: GlobalEventData) => void) => void;
}
export type WalletType = 'mpc' | 'evm';
export interface BaseWallet {
type: WalletType;
address: string;
isConnected: boolean;
}
export interface MPCWallet extends BaseWallet {
type: 'mpc';
smartWalletAddress: string;
aaWalletAddress: string;
}
export interface EVMWallet extends BaseWallet {
type: 'evm';
chainId: number;
balance: string;
allowance: string;
isApproved: boolean;
}
export interface TokenInfo {
token: string;
symbol: string;
decimals: number;
iconUrl: string;
tokenAddress: string;
contractAddress?: string;
balance?: {
formatted: string;
raw: string;
};
allowance?: {
formatted: string;
raw: string;
};
minDeposit?: string;
maxDeposit?: string;
isActive?: boolean;
withdrawEnable?: boolean;
pullOff?: boolean;
coinName?: string;
}
export interface ChainInfo {
chainId: number;
chain: string;
chainIconUrl: string;
blockTime: number;
txConfirm: number;
allowDeposit: boolean;
contractAddress?: string;
tokenList: TokenInfo[];
rpcUrl?: string;
explorerUrl?: string;
nativeCurrency?: {
name: string;
symbol: string;
decimals: number;
};
}
export interface DepositChainList extends ChainInfo {
}
export interface AssetInfo extends TokenInfo {
}
export interface WalletOperations {
connect(): Promise<void>;
disconnect(): Promise<void>;
switchChain(chainId: number): Promise<void>;
getBalance(tokenAddress?: string): Promise<string>;
approve(tokenAddress: string, amount: string): Promise<string>;
deposit(amount: string, tokenAddress: string): Promise<string>;
signMessage(message: string): Promise<string>;
}
export interface DepositState {
isLoading: boolean;
isApproving: boolean;
isDepositing: boolean;
error: string | null;
txHash: string | null;
}
export interface DepositFormData {
amount: string;
selectedChainId: number;
selectedTokenAddress: string;
slippage: number;
}
//# sourceMappingURL=index.d.ts.map