Skip to content

Commit 4831ab6

Browse files
authored
Merge pull request #4 from Ratio1/config-refactor
Config refactor
2 parents b9da284 + 7a667b3 commit 4831ab6

40 files changed

+164
-313
lines changed

.env.production.devnet

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NEXT_PUBLIC_ENVIRONMENT=devnet
2+
NEXT_PUBLIC_URL=https://devnet-explorer.ratio1.ai
3+
4+
NEXT_PUBLIC_BACKEND_URL=https://devnet-dapp-api.ratio1.ai
5+
NEXT_PUBLIC_ORACLES_URL=https://devnet-oracle.ratio1.ai
6+
7+
NEXT_PUBLIC_R1_CA=0x07C5678F0f4aC347496eAA8D6031b37FF3402CE5
8+
NEXT_PUBLIC_ND_CA=0x8D0CE4933728FF7C04388f0bEcC9a45676E232F7
9+
NEXT_PUBLIC_MND_CA=0x7A14Be75135a7ebdef99339CCc700C25Cda60c6E
10+
NEXT_PUBLIC_READER_CA=0x2c62a818967D3396b535De3d1EC47aF1f2B1282D
11+
NEXT_PUBLIC_EXPLORER_URL=https://sepolia.basescan.org
12+
13+
NEXT_PUBLIC_GENESIS_DATE=2025-05-23T16:00:00.000Z
14+
NEXT_PUBLIC_CONTRACTS_GENESIS_BLOCK=26124424
15+
NEXT_PUBLIC_EPOCH_DURATION_SECONDS=3600
16+
NEXT_PUBLIC_ND_LICENSE_CAP=1575188843457943924200

.env.production.mainnet

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NEXT_PUBLIC_ENVIRONMENT=mainnet
2+
NEXT_PUBLIC_URL=https://explorer.ratio1.ai
3+
4+
NEXT_PUBLIC_BACKEND_URL=https://dapp-api.ratio1.ai
5+
NEXT_PUBLIC_ORACLES_URL=https://oracle.ratio1.ai
6+
7+
NEXT_PUBLIC_R1_CA=0x6444C6c2D527D85EA97032da9A7504d6d1448ecF
8+
NEXT_PUBLIC_ND_CA=0xE658DF6dA3FB5d4FBa562F1D5934bd0F9c6bd423
9+
NEXT_PUBLIC_MND_CA=0x0C431e546371C87354714Fcc1a13365391A549E2
10+
NEXT_PUBLIC_READER_CA=0xa2fDD4c7E93790Ff68a01f01AA789D619F12c6AC
11+
NEXT_PUBLIC_EXPLORER_URL=https://basescan.org
12+
13+
NEXT_PUBLIC_GENESIS_DATE=2025-05-23T16:00:00.000Z
14+
NEXT_PUBLIC_CONTRACTS_GENESIS_BLOCK=30614094
15+
NEXT_PUBLIC_EPOCH_DURATION_SECONDS=86400
16+
NEXT_PUBLIC_ND_LICENSE_CAP=1575188843457943924200

.env.production.testnet

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NEXT_PUBLIC_ENVIRONMENT=testnet
2+
NEXT_PUBLIC_URL=https://testnet-explorer.ratio1.ai
3+
4+
NEXT_PUBLIC_BACKEND_URL=https://testnet-dapp-api.ratio1.ai
5+
NEXT_PUBLIC_ORACLES_URL=https://testnet-oracle.ratio1.ai
6+
7+
NEXT_PUBLIC_R1_CA=0xCC96f389F45Fc08b4fa8e2bC4C7DA9920292ec64
8+
NEXT_PUBLIC_ND_CA=0x18E86a5829CA1F02226FA123f30d90dCd7cFd0ED
9+
NEXT_PUBLIC_MND_CA=0xa8d7FFCE91a888872A9f5431B4Dd6c0c135055c1
10+
NEXT_PUBLIC_READER_CA=0xd1c7Dca934B37FAA402EB2EC64F6644d6957bE3b
11+
NEXT_PUBLIC_EXPLORER_URL=https://sepolia.basescan.org
12+
13+
NEXT_PUBLIC_GENESIS_DATE=2025-05-23T16:00:00.000Z
14+
NEXT_PUBLIC_CONTRACTS_GENESIS_BLOCK=26124257
15+
NEXT_PUBLIC_EPOCH_DURATION_SECONDS=86400
16+
NEXT_PUBLIC_ND_LICENSE_CAP=1575188843457943924200

.github/workflows/release.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
name: Build Next.js App
5656
runs-on: ubuntu-latest
5757
needs: [install-dependencies, generate-version]
58+
strategy:
59+
matrix:
60+
network: [devnet, testnet, mainnet]
5861
steps:
5962
- name: Checkout repository
6063
uses: actions/checkout@v4
@@ -66,8 +69,8 @@ jobs:
6669
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
6770
restore-keys: npm-${{ runner.os }}-
6871

69-
- name: Build Next.js App
70-
run: npm run build
72+
- name: Build Next.js App app for ${{ matrix.network }}
73+
run: npm run build:${{ matrix.network }}
7174
env:
7275
NODE_ENV: production
7376
MORALIS_API_KEY: ${{ secrets.MORALIS_API_KEY }}
@@ -80,13 +83,13 @@ jobs:
8083
cp -r public .next/standalone/public
8184
8285
- name: Archive standalone build
83-
run: zip -r ratio1-explorer.zip .next/standalone
86+
run: zip -r ratio1-explorer-${{ matrix.network }}.zip .next/standalone
8487

8588
- name: Upload Build as Artifact
8689
uses: actions/upload-artifact@v4
8790
with:
88-
name: ratio1-explorer
89-
path: ratio1-explorer.zip
91+
name: ratio1-explorer-${{ matrix.network }}
92+
path: ratio1-explorer-${{ matrix.network }}.zip
9093

9194
release:
9295
name: Create GitHub Release
@@ -96,10 +99,9 @@ jobs:
9699
- name: Checkout repository
97100
uses: actions/checkout@v4
98101

99-
- name: Download Artifact
102+
- name: Download All Artifacts
100103
uses: actions/download-artifact@v4
101104
with:
102-
name: ratio1-explorer
103105
path: builds
104106

105107
- name: List downloaded files
@@ -112,6 +114,6 @@ jobs:
112114
name: v${{ needs.generate-version.outputs.version }}
113115
draft: false
114116
prerelease: false
115-
files: builds/ratio1-explorer.zip
117+
files: builds/**/*
116118
env:
117119
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/account/[ownerEthAddr]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CardHorizontal } from '@/app/server-components/shared/cards/CardHorizon
44
import UsageStats from '@/app/server-components/shared/Licenses/UsageStats';
55
import ClientWrapper from '@/components/shared/ClientWrapper';
66
import { CopyableAddress } from '@/components/shared/CopyableValue';
7-
import { getServerConfig } from '@/config/serverConfig';
7+
import config from '@/config';
88
import { fetchErc20Balance, getLicenses } from '@/lib/api/blockchain';
99
import { cachedGetENSName, fBI, getShortAddress, isEmptyETHAddr } from '@/lib/utils';
1010
import * as types from '@/typedefs/blockchain';
@@ -35,7 +35,6 @@ export async function generateMetadata({ params }) {
3535

3636
export default async function OwnerPage({ params }) {
3737
const { ownerEthAddr } = await params;
38-
const { config } = await getServerConfig();
3938

4039
if (!ownerEthAddr || !isAddress(ownerEthAddr) || isEmptyETHAddr(ownerEthAddr)) {
4140
console.log(`[Account Page] Invalid owner address: ${ownerEthAddr}`);

app/accounts/loading.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Skeleton } from '@heroui/skeleton';
33
export default function Loading() {
44
return (
55
<div className="responsive-col">
6-
<Skeleton className="min-h-[176px] w-full rounded-2xl" />
6+
<Skeleton className="min-h-[180px] w-full rounded-2xl" />
77

88
<div className="col w-full gap-2">
99
<Skeleton className="only-lg min-h-[56px] w-full rounded-2xl" />
@@ -12,6 +12,8 @@ export default function Loading() {
1212
<Skeleton className="min-h-[68px] w-full rounded-2xl lg:min-h-[56px]" />
1313
<Skeleton className="min-h-[68px] w-full rounded-2xl lg:min-h-[56px]" />
1414
<Skeleton className="min-h-[68px] w-full rounded-2xl lg:min-h-[56px]" />
15+
<Skeleton className="min-h-[68px] w-full rounded-2xl lg:min-h-[56px]" />
16+
<Skeleton className="min-h-[68px] w-full rounded-2xl lg:min-h-[56px]" />
1517
</div>
1618
</div>
1719
);

app/accounts/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getServerConfig } from '@/config/serverConfig';
1+
import config from '@/config';
22
import { getSSURL } from '@/lib/actions';
33
import * as types from '@/typedefs/blockchain';
44
import { LicenseItem } from '@/typedefs/general';
@@ -45,8 +45,6 @@ export default async function AccountsPage(props: {
4545
const searchParams = await props.searchParams;
4646
const currentPage = Number(searchParams?.page) || 1;
4747

48-
const { config } = await getServerConfig();
49-
5048
let ndHolders: {
5149
ethAddress: types.EthAddress;
5250
licenseId: number;

app/api/r1-minted-last-epoch/route.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { getCurrentEpoch, getEpochStartTimestamp } from '@/config';
2-
import { getServerConfig } from '@/config/serverConfig';
1+
import config, { getCurrentEpoch, getEpochStartTimestamp } from '@/config';
32
import { getBlockByTimestamp } from '@/lib/api/blockchain';
43
import { NextResponse } from 'next/server';
54

65
// export const dynamic = 'force-dynamic'; // Ensure API route is not cached
76

87
async function fetchR1MintedLastEpoch() {
9-
const { config } = await getServerConfig();
10-
11-
const currentEpoch = getCurrentEpoch(config);
12-
const lastEpochStartTimestamp = getEpochStartTimestamp(config, currentEpoch - 1);
13-
const lastEpochEndTimestamp = getEpochStartTimestamp(config, currentEpoch);
8+
const currentEpoch = getCurrentEpoch();
9+
const lastEpochStartTimestamp = getEpochStartTimestamp(currentEpoch - 1);
10+
const lastEpochEndTimestamp = getEpochStartTimestamp(currentEpoch);
1411

1512
const fromBlock = await getBlockByTimestamp(lastEpochStartTimestamp.getTime() / 1000);
1613
const toBlock = await getBlockByTimestamp(lastEpochEndTimestamp.getTime() / 1000);

app/layout.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getServerURL } from '@/config/serverConfig';
1+
import config from '@/config';
22
import '@/lib/api/blockchain';
33
import { buildMetadata } from '@/lib/utils';
44
import { monaSans, robotoMono } from '@/styles/fonts';
@@ -17,12 +17,10 @@ export const viewport: Viewport = {
1717
};
1818

1919
export async function generateMetadata(): Promise<Metadata> {
20-
const url = await getServerURL();
21-
2220
return buildMetadata(
2321
'Ratio1 Explorer',
2422
'Experience the power of Ratio1 AI OS, built on Ratio1 Protocol and powered by blockchain, democratizing AI to empower limitless innovation.',
25-
url,
23+
config.publicUrl,
2624
);
2725
}
2826

app/license/[licenseType]/[licenseId]/loading.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Skeleton } from '@heroui/skeleton';
33
export default function Loading() {
44
return (
55
<div className="responsive-col">
6-
<Skeleton className="min-h-[359px] w-full rounded-2xl" />
7-
<Skeleton className="min-h-[310px] w-full rounded-2xl" />
8-
<Skeleton className="min-h-[276px] w-full rounded-2xl" />
6+
<Skeleton className="min-h-[348px] w-full rounded-2xl" />
7+
<Skeleton className="min-h-[242.5px] w-full rounded-2xl" />
8+
<Skeleton className="min-h-[272px] w-full rounded-2xl" />
99
</div>
1010
);
1111
}

0 commit comments

Comments
 (0)