|
41 | 41 | perl -0pi -e "s#display: 'inline-block',\n width:#display: 'block',\n margin: '0 auto',\n width:#" explorer/src/components/ad/AdBanner.vue |
42 | 42 | grep -n "const adStyle" -A6 explorer/src/components/ad/AdBanner.vue |
43 | 43 |
|
| 44 | + - name: Disable CoinGecko on testnet |
| 45 | + run: | |
| 46 | + node <<'NODE' |
| 47 | + const fs = require('fs'); |
| 48 | +
|
| 49 | + const updateFile = (path, replacements) => { |
| 50 | + let source = fs.readFileSync(path, 'utf8'); |
| 51 | + for (const [from, to] of replacements) { |
| 52 | + if (!source.includes(from)) { |
| 53 | + throw new Error(`Expected text not found in ${path}: ${from}`); |
| 54 | + } |
| 55 | + source = source.replace(from, to); |
| 56 | + } |
| 57 | + fs.writeFileSync(path, source); |
| 58 | + }; |
| 59 | +
|
| 60 | + updateFile('explorer/src/stores/useCoinGecko.ts', [ |
| 61 | + [ |
| 62 | + "const LocalStoreKey = 'currency';", |
| 63 | + "const LocalStoreKey = 'currency';\nconst disableCoingecko = window.location.hostname.includes('testnet');", |
| 64 | + ], |
| 65 | + [ |
| 66 | + "return get(`${coingeckoUrl}/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}`);", |
| 67 | + "return disableCoingecko\n ? Promise.resolve({ prices: [], market_caps: [], total_volumes: [] })\n : get(`${coingeckoUrl}/api/v3/coins/${coinId}/market_chart?vs_currency=usd&days=${days}`);", |
| 68 | + ], |
| 69 | + [ |
| 70 | + "fetchCoinPrice(ids: string[]) {", |
| 71 | + "fetchCoinPrice(ids: string[]) {\n if (disableCoingecko) return;", |
| 72 | + ], |
| 73 | + [ |
| 74 | + "return get(`${coingeckoUrl}/api/v3/coins/${coinId}`);", |
| 75 | + "return disableCoingecko ? Promise.resolve({ tickers: [] }) : get(`${coingeckoUrl}/api/v3/coins/${coinId}`);", |
| 76 | + ], |
| 77 | + ]); |
| 78 | +
|
| 79 | + updateFile('explorer/src/stores/useDashboard.ts', [ |
| 80 | + [ |
| 81 | + "loadingPrices() {", |
| 82 | + "loadingPrices() {\n if (window.location.hostname.includes('testnet')) return;", |
| 83 | + ], |
| 84 | + ]); |
| 85 | +
|
| 86 | + updateFile('explorer/src/modules/wallet/portfolio.vue', [ |
| 87 | + [ |
| 88 | + "function loadPrice() {", |
| 89 | + "function loadPrice() {\n if (window.location.hostname.includes('testnet')) return;", |
| 90 | + ], |
| 91 | + ]); |
| 92 | + NODE |
| 93 | + grep -n "disableCoingecko\|loadingPrices\|function loadPrice" explorer/src/stores/useCoinGecko.ts explorer/src/stores/useDashboard.ts explorer/src/modules/wallet/portfolio.vue |
| 94 | +
|
44 | 95 | - name: Setup Pages |
45 | 96 | uses: actions/configure-pages@v5 |
46 | 97 |
|
|
0 commit comments