UNPKG

@ledgerhq/live-common

Version:
247 lines (241 loc) • 6.29 kB
import { MarketCurrencyData, MarketItemPerformer, MarketItemResponse, KeysPriceChange, } from "./types"; /** * Mock market performers data for testing across platforms */ export const MOCK_MARKET_PERFORMERS: MarketItemPerformer[] = [ { id: "bitcoin", name: "Bitcoin", ticker: "BTC", image: "https://example.com/btc.png", price: 45000, priceChangePercentage1h: 0.52, priceChangePercentage24h: 5.5, priceChangePercentage7d: 12.3, priceChangePercentage30d: 25.47, priceChangePercentage1y: 150.82, ledgerIds: ["bitcoin"], }, { id: "ethereum", name: "Ethereum", ticker: "ETH", image: "https://example.com/eth.png", price: 3000, priceChangePercentage1h: 0.31, priceChangePercentage24h: 3.2, priceChangePercentage7d: 8.5, priceChangePercentage30d: 15.23, priceChangePercentage1y: 80.15, ledgerIds: ["ethereum"], }, { id: "solana", name: "Solana", ticker: "SOL", image: "https://example.com/sol.png", price: 100, priceChangePercentage1h: 0.87, priceChangePercentage24h: 8.1, priceChangePercentage7d: 20.34, priceChangePercentage30d: 45.67, priceChangePercentage1y: 200.89, ledgerIds: ["solana"], }, { id: "cardano", name: "Cardano", ticker: "ADA", image: "https://example.com/ada.png", price: 0.5, priceChangePercentage1h: 0.23, priceChangePercentage24h: 2.05, priceChangePercentage7d: 5.12, priceChangePercentage30d: 10.78, priceChangePercentage1y: 50.33, ledgerIds: ["cardano"], }, { id: "polkadot", name: "Polkadot", ticker: "DOT", image: "https://example.com/dot.png", price: 7, priceChangePercentage1h: -0.15, priceChangePercentage24h: -1.5, priceChangePercentage7d: 3.42, priceChangePercentage30d: 8.91, priceChangePercentage1y: 30.56, ledgerIds: ["polkadot"], }, { id: "avalanche", name: "Avalanche", ticker: "AVAX", image: "https://example.com/avax.png", price: 35, priceChangePercentage1h: 0.64, priceChangePercentage24h: 6.28, priceChangePercentage7d: 15.73, priceChangePercentage30d: 30.19, priceChangePercentage1y: 120.45, ledgerIds: ["avalanche-c-chain"], }, { id: "chainlink", name: "Chainlink", ticker: "LINK", image: "https://example.com/link.png", price: 15, priceChangePercentage1h: 0.41, priceChangePercentage24h: 4.17, priceChangePercentage7d: 10.84, priceChangePercentage30d: 20.36, priceChangePercentage1y: 70.92, ledgerIds: ["chainlink"], }, { id: "ripple", name: "Ripple", ticker: "XRP", image: "https://example.com/xrp.png", price: 1.2, priceChangePercentage1h: 0.18, priceChangePercentage24h: 0.93, priceChangePercentage7d: 2.81, priceChangePercentage30d: 5.67, priceChangePercentage1y: 50.24, ledgerIds: ["ripple"], }, ]; /** * Mock market currency data for testing across platforms */ export const MOCK_MARKET_CURRENCY_DATA: MarketCurrencyData[] = [ { id: "bitcoin", ledgerIds: ["bitcoin"], name: "Bitcoin", image: "https://example.com/btc.png", price: 50000, marketcap: 1000000000, marketcapRank: 1, totalVolume: 50000000, high24h: 51000, low24h: 49000, ticker: "BTC", priceChangePercentage: { [KeysPriceChange.hour]: 1.5, [KeysPriceChange.day]: 2.5, [KeysPriceChange.week]: 5, [KeysPriceChange.month]: 10, [KeysPriceChange.year]: 50, }, marketCapChangePercentage24h: 2.5, circulatingSupply: 19000000, totalSupply: 21000000, maxSupply: 21000000, ath: 69000, athDate: new Date("2021-11-10"), atl: 100, atlDate: new Date("2013-07-06"), chartData: {}, }, { id: "ethereum", ledgerIds: ["ethereum"], name: "Ethereum", image: "https://example.com/eth.png", price: 3000, marketcap: 500000000, marketcapRank: 2, totalVolume: 20000000, high24h: 3100, low24h: 2900, ticker: "ETH", priceChangePercentage: { [KeysPriceChange.hour]: 0.5, [KeysPriceChange.day]: 1.5, [KeysPriceChange.week]: 3, [KeysPriceChange.month]: 8, [KeysPriceChange.year]: 40, }, marketCapChangePercentage24h: 1.5, circulatingSupply: 120000000, totalSupply: 120000000, maxSupply: 120000000, ath: 4800, athDate: new Date("2021-11-10"), atl: 50, atlDate: new Date("2015-10-20"), chartData: {}, }, ]; export const createMockMarketCurrencyData = ( overrides: Partial<MarketCurrencyData> = {}, ): MarketCurrencyData => ({ ...MOCK_MARKET_CURRENCY_DATA[0], ...overrides, }); /** * Create a mock market performer with optional overrides */ export const createMockMarketPerformer = ( overrides: Partial<MarketItemPerformer> = {}, ): MarketItemPerformer => ({ id: "bitcoin", name: "Bitcoin", image: "https://example.com/bitcoin.png", ticker: "BTC", price: 50000, priceChangePercentage1h: 0.5, priceChangePercentage24h: 5.5, priceChangePercentage7d: 10.2, priceChangePercentage30d: 15.3, priceChangePercentage1y: 120.5, ledgerIds: [], ...overrides, }); /** * Create a mock market item API response with optional overrides */ export const createMockMarketItemResponse = ( overrides: Partial<MarketItemResponse> = {}, ): MarketItemResponse => ({ id: "bitcoin", currencyId: "bitcoin", name: "Bitcoin", ticker: "BTC", image: "https://example.com/btc.png", price: 50000, marketCap: 1000000000000, marketCapRank: 1, marketCapChange24h: 5000000000, marketCapChangePercentage24h: 2.5, totalVolume: 30000000000, high24h: 51000, low24h: 49000, priceChange24h: 1000, priceChangePercentage1h: 0.5, priceChangePercentage24h: 2.0, priceChangePercentage7d: 5.0, priceChangePercentage30d: 10.0, priceChangePercentage1y: 100.0, circulatingSupply: 19500000, totalSupply: 21000000, maxSupply: 21000000, allTimeHigh: 69000, allTimeHighDate: "2021-11-10T00:00:00.000Z", allTimeLow: 67.81, allTimeLowDate: "2013-07-06T00:00:00.000Z", fullyDilutedValuation: 1050000000000, sparkline: [48000, 49000, 50000, 51000, 50500], ledgerIds: ["bitcoin"], updatedAt: new Date().toISOString(), ...overrides, });