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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1

steps:
- uses: actions/checkout@v4

- name: Use Node.js 24.x LTS
uses: actions/setup-node@v4
with:
node-version: '24.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Build
run: npm run build

- name: Test
run: npm test
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

- Use Conventional Commits for commit messages, PR titles, and squash merges.
- Use **Why**, **Change**, and **Validation** sections by default in PR descriptions. Explain the reason, summarize what changed, and report what was actually checked. Reserve comments for decisions, blockers, and review replies.
- Install dependencies and run builds in a fresh development VM. For frontend changes, run `npm ci`, `npm run lint`, and `npm run build` from the repository root.
- Install dependencies and run builds in a fresh development VM. For frontend changes, run `npm ci`, `npm run lint`, `npm run build`, and `npm test` from the repository root. CI runs the same checks on Node 24.
- For registry or contract-page changes, check both Mainnet and Testnet in a browser. Keep a recorded verification distinct from a match with the currently deployed code. An RPC failure must show an unknown status, never a match or mismatch.
- `npm test` runs `tests/**/*.test.cjs` with the Node test runner, which loads `.ts` modules directly (Node 22.18 or later). Put tested logic in modules whose `@/` imports are type-only.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The registry rows show recorded verifications. The contract workspace checks dep

Registry totals come from the REST API configured by `NEXT_PUBLIC_API_HOST`. IPFS source snapshots use the app's `/api/proxy-ipfs` route.

The Evidence tab names the repository and commit of the recorded snapshot: the record's own `github`, or the git checkout stored in the snapshot. The contract's NEP-330 metadata, read at the latest final block, is shown on the Build tab as current metadata. The source tree opens the folder it names, labelled as current metadata: the registry doesn't record which crate was built. The snapshot's git checkout is read only when the Evidence or Build tab is open.

## Learn More

To learn more about Next.js, take a look at the following resources:
Expand Down
37 changes: 37 additions & 0 deletions components/Common/PaneBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import StatePanel from '@/components/Common/StatePanel'
import { Button } from '@chakra-ui/react'
import { Component, ErrorInfo, ReactNode } from 'react'

/**
* Contains a render error to one workspace pane, so the verdict, tabs and
* header stay usable. Give it a `key` that changes with the pane's input to
* start over when the reader moves on.
*/
export default class PaneBoundary extends Component<{ label: string; children: ReactNode }, { failed: boolean }> {
state = { failed: false }

static getDerivedStateFromError() {
return { failed: true }
}

componentDidCatch(error: Error, info: ErrorInfo) {
console.error(`${this.props.label} failed to render`, error, info.componentStack)
}

render() {
if (!this.state.failed) return this.props.children
return (
<StatePanel
tone="error"
title={`Couldn’t display ${this.props.label}`}
action={
<Button variant="quiet" onClick={() => this.setState({ failed: false })}>
Try again
</Button>
}
>
Something in this section failed to render. The verdict and the other sections are unaffected.
</StatePanel>
)
}
}
197 changes: 150 additions & 47 deletions components/Workspace/BuildPane.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import CopyButton from '@/components/Common/CopyButton'
import ExternalTextLink from '@/components/Common/ExternalTextLink'
import GithubLink from '@/components/Common/GithubLink'
import { Field, Fields, Panel } from '@/components/Common/Panel'
import type { MetadataLoad } from '@/hooks/useContract'
import type { GithubDto } from '@/Interfaces/github/github.dto'
import { parseImageRef, registryPage } from '@/utils/buildImage'
import { Badge, Box, Code, Flex, HStack, Spinner, Stack, Text } from '@chakra-ui/react'
import type { MetadataField, MetadataLoad } from '@/utils/contractMetadata'
import { liveRelation, LiveSource, RecordedSource } from '@/utils/evidence'
import { githubTreeUrl } from '@/utils/urls'
import { Badge, Box, Button, Code, Flex, HStack, Spinner, Stack, Text } from '@chakra-ui/react'
import { ReactNode } from 'react'

const Mono = (props: { children: ReactNode }) => (
Expand All @@ -12,6 +16,12 @@ const Mono = (props: { children: ReactNode }) => (
</Text>
)
const NotSet = (props: { children: ReactNode }) => <Text as="span" color="muted">{props.children}</Text>
/** A field the contract published with the wrong type: flagged, never rendered. */
const Flagged = (props: { children: ReactNode }) => (
<Text as="span" color="status.warn">
{props.children}
</Text>
)

/**
* The exact image reference from the metadata (tag and digest included), with a
Expand Down Expand Up @@ -46,59 +56,152 @@ function BuildImage(props: { value: string }) {
)
}

export default function BuildPane(props: { metadata: MetadataLoad }) {
const TITLE = 'Current build metadata (NEP-330)'

/** The folder on GitHub, or null when the path can't be put into a URL. */
function githubFolderUrl(g: GithubDto, dir: string): string | null {
try {
return `${githubTreeUrl(g)}/${dir.split('/').map(encodeURIComponent).join('/')}`
} catch {
return null
}
}

const ABSENT: Record<Extract<MetadataLoad, { status: 'absent' }>['reason'], string> = {
no_method: 'The deployed contract doesn’t expose contract_source_metadata, so no build metadata is published on-chain.',
no_code: 'No contract code is deployed on this account at the latest final block, so there is no build metadata.',
no_account: 'This account doesn’t exist at the latest final block, so there is no build metadata.',
null: 'The deployed contract’s contract_source_metadata returns null, so no build metadata is published.',
}

function Status(props: { tone?: 'muted' | 'warn'; children: ReactNode }) {
return (
<Panel title={TITLE}>
<Box px={{ base: 4, md: 5 }} py={4} fontSize="sm" color={props.tone === 'warn' ? 'status.warn' : 'muted'} role="status">
{props.children}
</Box>
</Panel>
)
}

/** The contract's NEP-330 metadata as read now, labelled as describing the code deployed now. */
export default function BuildPane(props: { metadata: MetadataLoad; onRetry: () => void; recorded: RecordedSource; live: LiveSource }) {
const { metadata } = props
if (metadata.status !== 'ready')
if (metadata.status === 'loading')
return (
<Panel title="Build metadata (NEP-330)">
<Text px={{ base: 4, md: 5 }} py={4} fontSize="sm" color={metadata.status === 'error' ? 'status.warn' : 'muted'} role="status">
{metadata.status === 'loading' ? (
<HStack as="span">
<Spinner size="xs" />
<span>Loading contract_source_metadata…</span>
</HStack>
) : metadata.status === 'missing' ? (
'This contract doesn’t expose contract_source_metadata, so no build metadata is published on-chain.'
) : (
'Couldn’t load the contract metadata from the RPC.'
)}
</Text>
</Panel>
<Status>
<HStack as="span">
<Spinner size="xs" />
<span>Loading contract_source_metadata…</span>
</HStack>
</Status>
)
if (metadata.status === 'unknown')
return (
<Status tone="warn">
<Flex gap={3} align="center" justify="space-between" wrap="wrap">
<Text>Couldn’t read contract_source_metadata: the RPC request failed or the call returned an error. The build metadata is unknown.</Text>
<Button size="sm" variant="quiet" onClick={props.onRetry}>
Try again
</Button>
</Flex>
</Status>
)
if (metadata.status === 'absent') return <Status>{ABSENT[metadata.reason]}</Status>
if (metadata.status === 'invalid')
return <Status tone="warn">The deployed contract’s contract_source_metadata returns a value that isn’t a NEP-330 metadata object, so it isn’t shown.</Status>

const m = metadata.metadata
const build = m.build_info
const env = typeof build?.build_environment === 'string' ? build.build_environment.trim() : ''
const standards = Array.isArray(m.standards) ? m.standards : []
const command = Array.isArray(build?.build_command) ? build?.build_command ?? [] : []
const build = m.buildInfo
const bad = (field: MetadataField) => m.invalid.includes(field)
const wrongType = <Flagged>Published with the wrong type; not shown</Flagged>
const env = build?.buildEnvironment?.trim() ?? ''
const relation = liveRelation(props.recorded, props.live)
const liveGithub = props.live.status === 'ready' ? props.live.github : null
const folderUrl = liveGithub && build?.contractDir ? githubFolderUrl(liveGithub, build.contractDir) : null

return (
<Panel title="Build metadata (NEP-330)">
<Panel title={TITLE}>
<Text px={{ base: 4, md: 5 }} py={3} fontSize="sm" color="muted" borderBottom="1px solid" borderColor="rule">
Read from the deployed contract at the latest final block. It describes the code deployed now, which can differ from the verified build.
</Text>
<Fields>
<Field label="Version">{m.version ? <Mono>{m.version}</Mono> : <NotSet>Not specified</NotSet>}</Field>
<Field label="Version">{bad('version') ? wrongType : m.version ? <Mono>{m.version}</Mono> : <NotSet>Not specified</NotSet>}</Field>
<Field label="Standards">
{standards.length ? (
<Flex gap={1.5} wrap="wrap">
{standards.map((s) => (
<Badge key={`${s.standard}:${s.version}`} textTransform="none" bg="subtle" color="ink" fontWeight="500" fontFamily="mono">
{s.standard} {s.version}
</Badge>
))}
</Flex>
) : (
<NotSet>None declared</NotSet>
)}
</Field>
<Field label="Build command">
{command.length ? (
<Code display="block" whiteSpace="pre-wrap" wordBreak="break-all" bg="subtle" color="ink" px={2} py={1.5} fontSize="13px" rounded="md">
{command.join(' ')}
</Code>
) : (
<NotSet>Not specified</NotSet>
)}
<Stack spacing={1.5}>
{m.standards.length ? (
<Flex gap={1.5} wrap="wrap">
{m.standards.map((s) => (
<Badge key={JSON.stringify([s.standard, s.version])} textTransform="none" bg="subtle" color="ink" fontWeight="500" fontFamily="mono">
{s.standard} {s.version}
</Badge>
))}
</Flex>
) : (
!bad('standards') && <NotSet>None declared</NotSet>
)}
{bad('standards') && <Flagged>Entries that aren’t a standard and version string were ignored.</Flagged>}
</Stack>
</Field>
<Field label="Build environment">{env ? <BuildImage value={env} /> : <NotSet>Not specified</NotSet>}</Field>
<Field label="Contract path">{build?.contract_path ? <Mono>{build.contract_path}</Mono> : <NotSet>/ (repository root)</NotSet>}</Field>
<Field label="Source snapshot">{build?.source_code_snapshot ? <Mono>{build.source_code_snapshot}</Mono> : <NotSet>Not specified</NotSet>}</Field>
{bad('build_info') || !build ? (
<Field label="Build info">{bad('build_info') ? wrongType : <NotSet>Not published</NotSet>}</Field>
) : (
<>
<Field label="Build command">
{bad('build_command') ? (
<Flagged>Not a list of strings; not shown</Flagged>
) : build.buildCommand?.length ? (
<Code display="block" whiteSpace="pre-wrap" wordBreak="break-all" bg="subtle" color="ink" px={2} py={1.5} fontSize="13px" rounded="md">
{build.buildCommand.join(' ')}
</Code>
) : (
<NotSet>Not specified</NotSet>
)}
</Field>
<Field label="Build environment">{bad('build_environment') ? wrongType : env ? <BuildImage value={env} /> : <NotSet>Not specified</NotSet>}</Field>
<Field label="Contract path">
{build.contractPath ? (
<Stack spacing={1}>
<Mono>{build.contractPath}</Mono>
{bad('contract_path') && <Flagged>Not a relative folder inside the source, so it isn’t used to open the source.</Flagged>}
{folderUrl && (
<Text as="div" fontSize="13px">
<ExternalTextLink href={folderUrl} srSuffix="on GitHub, at the commit in the current metadata">
This folder on GitHub at the current metadata’s commit
</ExternalTextLink>
</Text>
)}
</Stack>
) : bad('contract_path') ? (
wrongType
) : (
<NotSet>/ (repository root)</NotSet>
)}
</Field>
<Field label="Source snapshot">
{bad('source_code_snapshot') ? (
wrongType
) : build.sourceCodeSnapshot ? (
<Stack spacing={1}>
<Mono>{build.sourceCodeSnapshot}</Mono>
{liveGithub && <GithubLink github={liveGithub} />}
{relation === 'same' && (
<Text fontSize="13px" color="muted">
Same repository and commit as the verified snapshot.
</Text>
)}
{relation === 'different' && (
<Text fontSize="13px" color="status.warn">
Not the repository and commit of the verified snapshot; the Evidence tab shows the verified one.
</Text>
)}
</Stack>
) : (
<NotSet>Not specified</NotSet>
)}
</Field>
</>
)}
</Fields>
</Panel>
)
Expand Down
Loading
Loading