/ src / types / espresso.ts
espresso.ts
  1  export interface EspressoBlock {
  2    height: number;
  3    hash?: string;
  4    timestamp: number;
  5    size?: number;
  6    transactions?: number;
  7    proposer_id?: string[];
  8    fee_recipient?: string[];
  9    block_reward?: string[];
 10  }
 11  
 12  
 13  export interface EspressoTransaction {
 14    hash: string;
 15    block_height: number;
 16    index: number;
 17    size?: number;
 18    namespace?: number;
 19    rollup_name?: string;
 20    timestamp?: number;
 21    sender?: string;
 22    block_hash?: string;
 23    human_readable_time?: string;
 24    source?: string;
 25    tx_size_bytes?: number;
 26  }
 27  
 28  export interface EspressoNamespace {
 29    namespace: number;
 30    name?: string;
 31    transactions: EspressoTransaction[];
 32    rollup_info?: RollupInfo;
 33  }
 34  
 35  export interface RollupInfo {
 36    namespace: number;
 37    name: string;
 38    site?: string;
 39    blockScan?: string;
 40  }
 41  
 42  export interface SearchResult {
 43    id: string;
 44    type: 'block' | 'transaction' | 'rollup' | 'namespace';
 45    label: string;
 46    description?: string;
 47    time?: string;
 48    data?: EspressoBlock | EspressoTransaction | EspressoNamespace;
 49  }
 50  
 51  export interface ApiResponse<T> {
 52    success: boolean;
 53    data?: T;
 54    error?: string;
 55  }
 56  
 57  export type SearchType = 'block' | 'transaction' | 'namespace' | 'rollup_name' | 'block_hash' | 'block_or_namespace' | 'invalid';
 58  
 59  export interface NetworkInfo {
 60    name: string;
 61    baseUrl: string;
 62    version: string;
 63  }
 64  
 65  export const SEARCH_DEBOUNCE_MS = 300;
 66  export const MAX_RECENT_BLOCKS = 10;
 67  export const MAX_BLOCK_HISTORY = 1000;
 68  export const MAX_BLOCK_TIMES = 500;
 69  
 70  export const DEFAULT_BATCH_SIZE = 100;
 71  export const MAX_BATCH_SIZE = 100;
 72  export const API_TIMEOUT_MS = 2000;
 73  export const POLLING_INTERVAL_MS = 5000;
 74  export const NETWORK_STATS_REFRESH_MS = 30000;
 75  
 76  
 77  export const WS_MAX_RECONNECT_ATTEMPTS = 5;
 78  export const WS_INITIAL_RECONNECT_DELAY_MS = 1000;
 79  export const WS_MAX_RECONNECT_DELAY_MS = 10000;
 80  export const WS_RESET_DELAY_MS = 30000;
 81  
 82  export const MIN_VALID_BLOCK_TIME_SECONDS = 1;
 83  export const MAX_VALID_BLOCK_TIME_SECONDS = 300;
 84  
 85  export const BASE64_HASH_LENGTH = 44;
 86  export const HEX_HASH_LENGTH = 64;
 87  export const MAX_BLOCK_HEIGHT_DIGITS = 12;
 88  export const MIN_NAMESPACE_DIGITS = 13;
 89  export const MAX_NAMESPACE_DIGITS = 15;
 90  
 91  export const DEFAULT_HASH_DISPLAY_LENGTH = 10;
 92  export const DEFAULT_TX_DISPLAY_LENGTH = 20;
 93  export const MIN_SEARCH_LENGTH = 1;
 94  export const MIN_SEARCH_LENGTH_NON_NUMERIC = 2;
 95  
 96  export const NETWORK_NAME = 'MAINNET';
 97  export const DEFAULT_BLOCK_TIME_SECONDS = 12;
 98  
 99  export const BYTES_PER_KB = 1024;
100  export const BYTES_PER_MB = 1024 * 1024;
101  export const BYTES_PER_GB = 1024 * 1024 * 1024;