Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build_devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
push: true
platforms: linux/amd64
build-args: |
MORALIS_API_KEY=${{ secrets.MORALIS_API_KEY }}
ALCHEMY_API_KEY=${{ secrets.ALCHEMY_API_KEY }}
NEXT_PUBLIC_COMMIT_HASH=${{ github.sha }}
tags: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build_testnet_mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
push: true
platforms: linux/amd64
build-args: |
MORALIS_API_KEY=${{ secrets.MORALIS_API_KEY }}
ALCHEMY_API_KEY=${{ secrets.ALCHEMY_API_KEY }}
NEXT_PUBLIC_APP_VERSION=${{ needs.generate-version.outputs.version }}
tags: |
Expand All @@ -72,7 +71,6 @@ jobs:
push: true
platforms: linux/amd64
build-args: |
MORALIS_API_KEY=${{ secrets.MORALIS_API_KEY }}
ALCHEMY_API_KEY=${{ secrets.ALCHEMY_API_KEY }}
NEXT_PUBLIC_APP_VERSION=${{ needs.generate-version.outputs.version }}
tags: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ jobs:
run: npm run build:${{ matrix.network }}
env:
NODE_ENV: production
MORALIS_API_KEY: ${{ secrets.MORALIS_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
NEXT_PUBLIC_APP_VERSION: ${{ needs.generate-version.outputs.version }}

Expand Down
2 changes: 0 additions & 2 deletions Dockerfile_devnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM node:18-alpine AS builder
WORKDIR /app

ARG MORALIS_API_KEY
ARG ALCHEMY_API_KEY
ARG NEXT_PUBLIC_COMMIT_HASH

Expand All @@ -13,7 +12,6 @@ COPY . .

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
MORALIS_API_KEY=$MORALIS_API_KEY \
ALCHEMY_API_KEY=$ALCHEMY_API_KEY \
NEXT_PUBLIC_COMMIT_HASH=$NEXT_PUBLIC_COMMIT_HASH

Expand Down
2 changes: 0 additions & 2 deletions Dockerfile_mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM node:18-alpine AS builder
WORKDIR /app

ARG MORALIS_API_KEY
ARG ALCHEMY_API_KEY
ARG NEXT_PUBLIC_APP_VERSION

Expand All @@ -13,7 +12,6 @@ COPY . .

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
MORALIS_API_KEY=$MORALIS_API_KEY \
ALCHEMY_API_KEY=$ALCHEMY_API_KEY \
NEXT_PUBLIC_APP_VERSION=$NEXT_PUBLIC_APP_VERSION

Expand Down
2 changes: 0 additions & 2 deletions Dockerfile_testnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM node:18-alpine AS builder
WORKDIR /app

ARG MORALIS_API_KEY
ARG ALCHEMY_API_KEY
ARG NEXT_PUBLIC_APP_VERSION

Expand All @@ -13,7 +12,6 @@ COPY . .

ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
MORALIS_API_KEY=$MORALIS_API_KEY \
ALCHEMY_API_KEY=$ALCHEMY_API_KEY \
NEXT_PUBLIC_APP_VERSION=$NEXT_PUBLIC_APP_VERSION

Expand Down
30 changes: 0 additions & 30 deletions app/api/license-holders/route.ts

This file was deleted.

32 changes: 8 additions & 24 deletions app/node-operators/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ErrorComponent from '@/app/server-components/shared/ErrorComponent';
import config from '@/config';
import { getSSURL } from '@/lib/actions';
import { getAllLicenseHolders } from '@/lib/api/blockchain';
import * as types from '@/typedefs/blockchain';
import { LicenseItem } from '@/typedefs/general';
import { unstable_cache } from 'next/cache';
import List from '../server-components/NodeOperators/List';
import { BorderedCard } from '../server-components/shared/cards/BorderedCard';
import { CardHorizontal } from '../server-components/shared/cards/CardHorizontal';
Expand All @@ -23,25 +23,7 @@ export async function generateMetadata({ searchParams }: { searchParams?: Promis
};
}

const fetchLicenseHolders = async (environment: 'mainnet' | 'testnet' | 'devnet') => {
const url = await getSSURL(`license-holders?env=${environment}`);

const res = await fetch(url, {
next: { revalidate: 300 }, // Cache for 5 minutes
});

const data: {
ndHolders: {
ethAddress: types.EthAddress;
licenseId: number;
}[];
mndHolders: {
ethAddress: types.EthAddress;
licenseId: number;
}[];
} = await res.json();
return data;
};
const getCachedLicenseHolders = unstable_cache(getAllLicenseHolders, ['license-holders'], { revalidate: 300 });

export default async function NodeOperatorsPage(props: {
searchParams?: Promise<{
Expand All @@ -54,10 +36,12 @@ export default async function NodeOperatorsPage(props: {
let ndHolders: {
ethAddress: types.EthAddress;
licenseId: number;
licenseType: 'ND';
}[],
mndHolders: {
ethAddress: types.EthAddress;
licenseId: number;
licenseType: 'MND' | 'GND';
}[];

const holders: {
Expand All @@ -70,13 +54,13 @@ export default async function NodeOperatorsPage(props: {
}[];

try {
({ ndHolders, mndHolders } = await fetchLicenseHolders(config.environment));
({ ndHolders, mndHolders } = await getCachedLicenseHolders());

Comment thread
aledefra marked this conversation as resolved.
ndHolders.forEach((holder) => {
if (!holders[holder.ethAddress]) {
holders[holder.ethAddress] = [];
}
holders[holder.ethAddress].push({ licenseId: holder.licenseId, licenseType: 'ND' });
holders[holder.ethAddress].push({ licenseId: holder.licenseId, licenseType: holder.licenseType });
});

mndHolders.forEach((holder) => {
Expand All @@ -85,7 +69,7 @@ export default async function NodeOperatorsPage(props: {
}
holders[holder.ethAddress].push({
licenseId: holder.licenseId,
licenseType: holder.licenseId === 1 ? 'GND' : 'MND',
licenseType: holder.licenseType,
});
});

Expand Down
12 changes: 6 additions & 6 deletions app/node/[nodeAddr]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function generateMetadata({ params }) {
},
};

let nodeResponse: types.OraclesAvailabilityResult & types.OraclesDefaultResult;
let nodeResponse: types.OraclesAvailabilityResult;

try {
({ nodeResponse } = await fetchLicenseDetailsAndNodeAvailability(resolvedNodeEthAddr, config.environment));
Expand All @@ -80,10 +80,10 @@ const fetchLicenseDetailsAndNodeAvailability = async (
_environment: 'mainnet' | 'testnet' | 'devnet',
): Promise<{
license: types.License;
licenseId: bigint;
licenseType: 'ND' | 'MND' | 'GND';
owner: types.EthAddress;
nodeResponse: types.OraclesAvailabilityResult & types.OraclesDefaultResult;
licenseId: bigint;
licenseType: 'ND' | 'MND' | 'GND';
owner: types.EthAddress;
nodeResponse: types.OraclesAvailabilityResult;
}> => {
let nodeAddress: types.EthAddress,
totalAssignedAmount: bigint,
Expand Down Expand Up @@ -165,7 +165,7 @@ export default async function NodePage({ params }) {
let licenseId: bigint;
let licenseType: 'ND' | 'MND' | 'GND';
let owner: types.EthAddress;
let nodeResponse: types.OraclesAvailabilityResult & types.OraclesDefaultResult;
let nodeResponse: types.OraclesAvailabilityResult;

try {
({ license, licenseId, licenseType, owner, nodeResponse } = await fetchLicenseDetailsAndNodeAvailability(
Expand Down
80 changes: 79 additions & 1 deletion app/playwright-preview/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import LicenseRewardsPoA from '@/app/server-components/Licenses/LicenseRewardsPoA';
import NodeCard from '@/app/server-components/main-cards/NodeCard';
import NodePerformanceCard from '@/app/server-components/main-cards/NodePerformanceCard';
import { BorderedCard } from '@/app/server-components/shared/cards/BorderedCard';
import SyncingOraclesTag from '@/app/server-components/shared/SyncingOraclesTag';
import { getEpochStartTimestamp } from '@/config';
import * as types from '@/typedefs/blockchain';
import { notFound } from 'next/navigation';

/*
Expand All @@ -13,9 +20,80 @@ export default function PlaywrightPreviewPage() {
notFound();
}

const assignTimestamp = BigInt(Math.floor(getEpochStartTimestamp(1).getTime() / 1000));
const nodeEthAddress = '0x1111111111111111111111111111111111111111' as types.EthAddress;
const ownerAddress = '0x2222222222222222222222222222222222222222' as types.EthAddress;
const nodeResponse = {
node: '0xai_mocked_preview_node_address_000000000000000000',
node_alias: 'Mock Syncing Node',
node_eth_address: nodeEthAddress,
epochs: [],
epochs_vals: [],
error: 'No epochs found for the given node',
eth_signed_data: {
input: [],
signature_field: '',
},
eth_signatures: [],
eth_addresses: [],
node_is_online: true,
node_is_oracle: false,
node_version: 'ratio1-node|2.4.1|preview',
node_last_seen_sec: 76,
resources: {
cpu_cores: 16,
cpu_cores_avail: 12.5,
default_cuda: {
cpu: 0,
'cuda:0': 0,
},
disk_avail: 415.4,
disk_total: 512,
mem_avail: 48.3,
mem_total: 64,
},
tags: ['preview', 'syncing'],
availability_status: 'syncing',
server_current_epoch: 10,
server_last_synced_epoch: 8,
} satisfies types.OraclesAvailabilityResult;
const license = {
nodeAddress: nodeEthAddress,
totalAssignedAmount: 1_000_000n * 10n ** 18n,
totalClaimedAmount: 125_000n * 10n ** 18n,
awbBalance: 0n,
lastClaimEpoch: 2n,
assignTimestamp,
lastClaimOracle: ownerAddress,
isBanned: false,
owner: ownerAddress,
r1PoaiRewards: 0n,
usdcPoaiRewards: 0n,
} satisfies types.License;

return (
<main className="col mx-auto w-full max-w-5xl gap-6 p-4 md:p-8">
<section id="playwright-preview"></section>
<section id="playwright-preview" className="responsive-col">
<BorderedCard>
<div className="row flex-wrap items-center gap-2.5">
<div className="card-title font-bold">Direct tag</div>
<SyncingOraclesTag />
</div>
</BorderedCard>

<NodeCard nodeResponse={nodeResponse} />
<NodePerformanceCard nodeResponse={nodeResponse} />

<BorderedCard>
<div className="card-title font-bold">PoA rewards</div>
<LicenseRewardsPoA
license={license}
licenseType="ND"
licenseId="42"
getNodeAvailability={() => Promise.resolve(nodeResponse)}
/>
</BorderedCard>
</section>
</main>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { Alert } from '../shared/Alert';
export default async function LicensePageNodeCardWrapper({
cachedGetNodeAvailability,
}: {
cachedGetNodeAvailability: () => Promise<(types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined>;
cachedGetNodeAvailability: () => Promise<types.OraclesAvailabilityResult | undefined>;
}) {
try {
const nodeResponse: (types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined =
await cachedGetNodeAvailability();
const nodeResponse: types.OraclesAvailabilityResult | undefined = await cachedGetNodeAvailability();

if (!nodeResponse) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import NodePerformanceCard from '../main-cards/NodePerformanceCard';
export default async function LicensePageNodePerformanceCardWrapper({
cachedGetNodeAvailability,
}: {
cachedGetNodeAvailability: () => Promise<(types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined>;
cachedGetNodeAvailability: () => Promise<types.OraclesAvailabilityResult | undefined>;
}) {
const nodeResponse: (types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined =
await cachedGetNodeAvailability();
const nodeResponse: types.OraclesAvailabilityResult | undefined = await cachedGetNodeAvailability();

if (!nodeResponse) {
return null;
Expand Down
20 changes: 14 additions & 6 deletions app/server-components/Licenses/LicenseRewardsPoA.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { getLicenseFirstCheckEpoch } from '@/config';
import { isOraclesSyncing } from '@/lib/oracles';
import { getLicenseRewardsBreakdown } from '@/lib/api/blockchain';
import * as types from '@/typedefs/blockchain';
import { formatUnits } from 'viem';
import { CardHorizontal } from '../shared/cards/CardHorizontal';
import { SmallTag } from '../shared/SmallTag';
import SyncingOraclesTag from '../shared/SyncingOraclesTag';

export default async function LicenseRewardsPoA({
license,
Expand All @@ -14,11 +16,10 @@ export default async function LicenseRewardsPoA({
license: types.License;
licenseType: 'ND' | 'MND' | 'GND';
licenseId: string;
getNodeAvailability: () => Promise<(types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined>;
getNodeAvailability: () => Promise<types.OraclesAvailabilityResult | undefined>;
}) {
try {
const nodeResponse: (types.OraclesAvailabilityResult & types.OraclesDefaultResult) | undefined =
await getNodeAvailability();
const nodeResponse: types.OraclesAvailabilityResult | undefined = await getNodeAvailability();

if (!nodeResponse) {
return null;
Expand All @@ -36,6 +37,7 @@ export default async function LicenseRewardsPoA({
);

const rewards = rewardsBreakdown.claimableAmount;
const syncingOracles = isOraclesSyncing(nodeResponse);
const showMndBreakdown =
licenseType !== 'ND' &&
rewardsBreakdown.claimableAmount !== undefined &&
Expand All @@ -47,9 +49,15 @@ export default async function LicenseRewardsPoA({
value={
<div className="col items-end gap-1.5">
<div className="text-primary">
{rewards === undefined
? '...'
: parseFloat(Number(formatUnits(rewards ?? 0n, 18)).toFixed(2)).toLocaleString()}
{rewards === undefined ? (
syncingOracles ? (
<SyncingOraclesTag />
) : (
'...'
)
) : (
parseFloat(Number(formatUnits(rewards ?? 0n, 18)).toFixed(2)).toLocaleString()
)}
{!!rewards ? ' $R1' : ''}
</div>

Expand Down
Loading
Loading