diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index 06cdb77d0..90fe28fdb 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -64,3 +64,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} ASSETS: ${{ github.workspace }}/assets + - name: Containers + shell: bash + run: npx nx run-many --target=container --configuration=production-testnet-zen -all --parallel=5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} diff --git a/README.md b/README.md index 4946af9b0..5ec30d767 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [![Sia Web](https://sia.tech/assets/banners/sia-banner-web.png)](http://sia.tech) +[![Sia Web](https://sia.tech/assets/banners/sia-banner-web.png)](http://sia.tech) # Web diff --git a/apps/explorer/app/opengraph-image.tsx b/apps/explorer/app/opengraph-image.tsx index 59597d321..631c24ba6 100644 --- a/apps/explorer/app/opengraph-image.tsx +++ b/apps/explorer/app/opengraph-image.tsx @@ -7,7 +7,7 @@ import { network, siaCentralApi } from '../config' import { humanBytes } from '@siafoundation/sia-js' import { PreviewValue } from '../components/OGImage/Preview' -export const revalidate = 60 +export const revalidate = 0 export const alt = 'Contract' export const size = { diff --git a/apps/explorer/app/page.tsx b/apps/explorer/app/page.tsx index 1be0b3f34..b05906def 100644 --- a/apps/explorer/app/page.tsx +++ b/apps/explorer/app/page.tsx @@ -2,8 +2,6 @@ import { Metadata } from 'next' import { appLink, network, siaCentralApi } from '../config' import { Home } from '../components/Home' import { - SiaCentralBlock, - getSiaCentralBlock, getSiaCentralBlockLatest, getSiaCentralExchangeRates, getSiaCentralHosts, @@ -11,6 +9,7 @@ import { } from '@siafoundation/sia-central' import { buildMetadata } from '../lib/utils' import { humanBytes } from '@siafoundation/sia-js' +import { getLastFewBlocks } from '../lib/blocks' export function generateMetadata(): Metadata { const title = 'siascan' @@ -25,7 +24,7 @@ export function generateMetadata(): Metadata { }) } -export const revalidate = 60 +export const revalidate = 0 export default async function HomePage() { const [ @@ -60,59 +59,7 @@ export default async function HomePage() { ]) const lastBlockHeight = lb?.block.height || 0 - const [one, two, three, four] = await Promise.all([ - getSiaCentralBlock({ - params: { - id: String(lastBlockHeight - 1), - }, - config: { - api: siaCentralApi, - }, - }), - getSiaCentralBlock({ - params: { - id: String(lastBlockHeight - 2), - }, - config: { - api: siaCentralApi, - }, - }), - getSiaCentralBlock({ - params: { - id: String(lastBlockHeight - 3), - }, - config: { - api: siaCentralApi, - }, - }), - getSiaCentralBlock({ - params: { - id: String(lastBlockHeight - 4), - }, - config: { - api: siaCentralApi, - }, - }), - ]) - - const blocks: SiaCentralBlock[] = [] - if (lastBlockHeight) { - if (lb) { - blocks.push(lb.block) - } - if (one.data) { - blocks.push(one.data.block) - } - if (two.data) { - blocks.push(two.data.block) - } - if (three.data) { - blocks.push(three.data.block) - } - if (four.data) { - blocks.push(four.data.block) - } - } + const blocks = await getLastFewBlocks(lb?.block) if ( metricsError || @@ -120,19 +67,13 @@ export default async function HomePage() { exchangeRatesError || hostsError || latestBlockError || - one.error || - two.error || - three.error || - four.error + blocks.error ) { console.log(new Date().toISOString(), { metricsError, latestBlockError, - blockOneError: one.error, - blockTwoError: two.error, - blockThreeError: three.error, - blockFourError: four.error, exchangeRatesError, + blocksError: blocks.error, hostsError, }) } @@ -140,10 +81,7 @@ export default async function HomePage() { console.log(new Date().toISOString(), { metrics: humanBytes(Buffer.byteLength(JSON.stringify(m || ''))), latestBlock: humanBytes(Buffer.byteLength(JSON.stringify(lb || ''))), - blockOne: humanBytes(Buffer.byteLength(JSON.stringify(one || ''))), - blockTwo: humanBytes(Buffer.byteLength(JSON.stringify(two || ''))), - blockThree: humanBytes(Buffer.byteLength(JSON.stringify(three || ''))), - blockFour: humanBytes(Buffer.byteLength(JSON.stringify(four || ''))), + blocks: humanBytes(Buffer.byteLength(JSON.stringify(blocks || ''))), exchangeRates: humanBytes(Buffer.byteLength(JSON.stringify(r || ''))), hosts: humanBytes(Buffer.byteLength(JSON.stringify(h || ''))), }) @@ -152,7 +90,7 @@ export default async function HomePage() { diff --git a/apps/explorer/lib/blocks.ts b/apps/explorer/lib/blocks.ts new file mode 100644 index 000000000..33584ce8a --- /dev/null +++ b/apps/explorer/lib/blocks.ts @@ -0,0 +1,116 @@ +import { siaCentralApi } from '../config' +import { + SiaCentralBlock, + getSiaCentralBlock, + getSiaCentralBlocks, +} from '@siafoundation/sia-central' +import { range } from 'lodash' + +export async function getLastFewBlocksOneByOne(block?: SiaCentralBlock) { + if (!block) { + return { + error: 'no block', + } + } + const lastBlockHeight = block.height || 0 + const [one, two, three, four] = await Promise.all([ + getSiaCentralBlock({ + params: { + id: String(lastBlockHeight - 1), + }, + config: { + api: siaCentralApi, + }, + }), + getSiaCentralBlock({ + params: { + id: String(lastBlockHeight - 2), + }, + config: { + api: siaCentralApi, + }, + }), + getSiaCentralBlock({ + params: { + id: String(lastBlockHeight - 3), + }, + config: { + api: siaCentralApi, + }, + }), + getSiaCentralBlock({ + params: { + id: String(lastBlockHeight - 4), + }, + config: { + api: siaCentralApi, + }, + }), + ]) + + const blocks: SiaCentralBlock[] = [] + if (one.error) { + return { + error: one.error, + } + } + if (two.error) { + return { + error: two.error, + } + } + if (three.error) { + return { + error: three.error, + } + } + if (four.error) { + return { + error: four.error, + } + } + if (block) { + blocks.push(block) + } + if (one.data) { + blocks.push(one.data.block) + } + if (two.data) { + blocks.push(two.data.block) + } + if (three.data) { + blocks.push(three.data.block) + } + if (four.data) { + blocks.push(four.data.block) + } + return { + blocks, + } +} + +export async function getLastFewBlocks(block?: SiaCentralBlock) { + if (!block) { + return { + error: 'no block', + } + } + const lastBlockHeight = block.height || 0 + const response = await getSiaCentralBlocks({ + payload: { + heights: range(lastBlockHeight - 4, lastBlockHeight), + }, + config: { + api: siaCentralApi, + }, + }) + + if (response.data?.blocks) { + return { + blocks: [block, ...response.data.blocks], + } + } + return { + error: response.data?.message, + } +} diff --git a/apps/explorer/tsconfig.json b/apps/explorer/tsconfig.json index ed52794f5..22b38e3e7 100644 --- a/apps/explorer/tsconfig.json +++ b/apps/explorer/tsconfig.json @@ -11,10 +11,7 @@ "resolveJsonModule": true, "isolatedModules": true, "incremental": true, - "types": [ - "jest", - "node" - ], + "types": ["jest", "node"], "plugins": [ { "name": "next" @@ -31,8 +28,5 @@ "../../dist/apps/explorer-testnet-zen/.next/types/**/*.ts", "../../dist/apps/explorer/.next/types/**/*.ts" ], - "exclude": [ - "node_modules", - "jest.config.ts" - ] + "exclude": ["node_modules", "jest.config.ts"] } diff --git a/apps/website/config/siteMap.ts b/apps/website/config/siteMap.ts index 0ee49f158..94ae4188e 100644 --- a/apps/website/config/siteMap.ts +++ b/apps/website/config/siteMap.ts @@ -146,14 +146,9 @@ export const menuSections = [ links: [ { link: webLinks.explore.mainnet, - title: 'Sia Foundation Explorer', + title: 'Siascan Explorer', newTab: true, }, - // { - // link: webLinks.siaStats, - // title: 'SiaStats Explorer', - // newTab: true, - // }, { link: webLinks.storageStats, title: 'Sia Central Host Explorer', diff --git a/libs/data-sources/src/lib/assets.ts b/libs/data-sources/src/lib/assets.ts index 91334479e..769cdb927 100644 --- a/libs/data-sources/src/lib/assets.ts +++ b/libs/data-sources/src/lib/assets.ts @@ -5,5 +5,5 @@ export function getAssetPath(filePath: string) { } export function getAssetsDirectory() { - return process.env['ASSETS'] || './' + return process.env['ASSETS'] || '/assets' } diff --git a/libs/design-system/src/data/webLinks.ts b/libs/design-system/src/data/webLinks.ts index 2e7779d4b..1039e04a3 100644 --- a/libs/design-system/src/data/webLinks.ts +++ b/libs/design-system/src/data/webLinks.ts @@ -52,6 +52,5 @@ export const webLinks = { storageStats: 'https://hosts.siacentral.com/', hostTroubleshoot: 'https://troubleshoot.siacentral.com/', coinmarketcap: 'https://coinmarketcap.com/currencies/siacoin/', - // siaStats: 'https://siastats.info', jobs: 'https://siafoundation.homerun.co/', } diff --git a/server/Caddyfile b/server/Caddyfile index bd196ef9d..e6eeb496a 100644 --- a/server/Caddyfile +++ b/server/Caddyfile @@ -121,12 +121,12 @@ beta.siascan.com { api.siascan.com { import cloudflare encode gzip - - # temporary, will be included in the explorer API + + # temporary, will be included in the explorer API handle_path /revenue* { uri strip_prefix /revenue reverse_proxy localhost:10005 - } + } handle_path /zen/revenue* { uri strip_prefix /zen_revenue @@ -134,7 +134,7 @@ api.siascan.com { } route * { - respond 404 + respond 404 } }