Skip to content
Open
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
7 changes: 7 additions & 0 deletions .changeset/remove-dead-surface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@parity/cdm-builder": major
"@parity/cdm-env": patch
"@parity/cdm-cli": patch
---

Remove dead API surface. `@parity/cdm-builder` drops never-called exports (`ContractDeployer.deployBatch`, `getOnChainCode`, the flat toposort API `toposort`/`DeploymentOrder`/`createCrateToPackageMap`/`detectDeploymentOrder`, sync `pvmContractBuild`, `computeCid`, `normalizeCdmJson`, the solidity `readSolidityAbi`/`artifactDisplayPath`/`bytecodeSize` helpers), the never-emitted `check-cached` deploy event and `"cached"` summary status, the reserved-but-unused `waitFor`/`timeoutMs`/`gateway` deploy options, the constants re-exports (`GAS_LIMIT`/`STORAGE_DEPOSIT_LIMIT`/`CONTRACTS_REGISTRY_CRATE` — import from `@parity/cdm-utils` instead), the unused `MetadataPublisher` client constructor param, and the hardcoded fake `txHash`/`blockHash` on `publishBatch`/`publish-done`. `@parity/cdm-env` drops the unused `AssetHubConnection`/`BulletinConnection` types. `@parity/cdm-cli` sheds the unwired status-adapter observer API and unreachable UI states, stops running contract detection twice per build/deploy, and now shows where installed artifacts were saved after `cdm install`.
8 changes: 6 additions & 2 deletions src/apps/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import {
type CdmChainClient,
} from "@parity/cdm-env";
import { getAccount } from "@parity/cdm-utils/accounts";
import { ALICE_SS58, CONTRACTS_REGISTRY_PACKAGE } from "@parity/cdm-utils";
import { ContractDeployer, CONTRACTS_REGISTRY_CRATE, resolveFeatures } from "@parity/cdm-builder";
import {
ALICE_SS58,
CONTRACTS_REGISTRY_CRATE,
CONTRACTS_REGISTRY_PACKAGE,
} from "@parity/cdm-utils";
import { ContractDeployer, resolveFeatures } from "@parity/cdm-builder";
import type { HexString } from "polkadot-api";
import { ensureAccountMapped } from "../lib/account-mapping";
import { runDeployWithUI, spinner } from "../lib/ui";
Expand Down
10 changes: 2 additions & 8 deletions src/apps/cli/src/commands/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ import {
} from "@parity/cdm-builder";
import { spinner } from "../../lib/ui";
import { runInstallWithUI } from "../../lib/install-pipeline";
import type { InstallResult } from "../../lib/install-pipeline";
import { postInstallRust } from "./rust";
import { postInstallSolidity } from "./solidity";
import { postInstallTypeScript } from "./typescript";

export type { InstallResult } from "../../lib/install-pipeline";

function detectProjectType(dir: string): {
hasRust: boolean;
hasSolidity: boolean;
Expand Down Expand Up @@ -184,11 +180,9 @@ install.action(async (libraries: string[], rawOpts: InstallOptions) => {

writeCdmJson(cdmJson);

// Run post-install hooks and update status line
// Run post-install hooks and update status line. Rust projects need no
// post-install step: cdm.json (written above) is all cdm::import! reads.
if (results.length > 0) {
if (projectType.hasRust) {
await postInstallRust();
}
if (projectType.hasSolidity) {
await postInstallSolidity();
}
Expand Down
1 change: 0 additions & 1 deletion src/apps/cli/src/commands/install/rust.ts

This file was deleted.

80 changes: 16 additions & 64 deletions src/apps/cli/src/lib/components/DeployTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { Box, Text } from "ink";
import type { ContractStatus, PhaseInfo } from "../deploy-pipeline";
import type { ContractStatus } from "../deploy-pipeline";
import {
Link,
LinkLine,
Expand All @@ -12,7 +12,6 @@ import {
Idle,
Done,
Failed,
Cached,
LogTail,
truncateAddress,
shortHash,
Expand All @@ -26,11 +25,9 @@ const COL_PHASE = 5;
const COL_ADDR = 14;

/** Infer which phase failed based on what fields exist on the status */
function errorPhase(s: ContractStatus): "build" | "deploy" | "metadata" | "register" {
// Register failed: both deploy and publish completed, error during register
if (s.address && s.publishTxHash) return "register";
// Deploy completed but publish didn't: metadata/publish failure
if (s.address && !s.publishTxHash && s.cid) return "metadata";
function errorPhase(s: ContractStatus): "build" | "deploy" | "metadata" {
// Deploy completed: metadata/publish failure
if (s.address && s.cid) return "metadata";
if (s.bytecodeSize !== undefined) return "deploy";
// Build completed: deploy phase (or parallel deploy+publish) failed
if (
Expand Down Expand Up @@ -81,9 +78,9 @@ function ContractRow({
} else if (state === "waiting") {
buildCell = <EmptyBar />;
} else {
// built/deploying/deployed/publishing/registering/done — show completed bar
// plus the compiled bytecode size (base-10 kB/MB) if the library
// populated `bytecodeSize` on the status.
// built/deploying/done — show completed bar plus the compiled
// bytecode size (base-10 kB/MB) if the library populated
// `bytecodeSize` on the status.
const bp = s?.buildProgress;
if (bp?.total && bp.total > 0) {
buildCell = (
Expand All @@ -109,52 +106,19 @@ function ContractRow({
);
}

// Cached state — show cache indicator across all deploy columns
if (state === "cached") {
return (
<Box>
<Cell width={COL_CONTRACT}>
<Text bold wrap="truncate">
{name}
</Text>
</Cell>
<Cell width={COL_BUILD}>{buildCell}</Cell>
<Cell width={COL_PHASE}>
<Cached />
</Cell>
<Cell width={COL_PHASE}>
<Cached />
</Cell>
<Cell width={COL_PHASE}>
<Cached />
</Cell>
<Cell width={COL_ADDR}>
{s?.address ? <Text dimColor>{truncateAddress(s.address)}</Text> : <Idle />}
</Cell>
</Box>
);
}

// Deploy column — use deployInProgress flag for spinner
let deployCell: React.ReactNode;
if (state === "checking") {
deployCell = <Spinner tick={tick} />;
} else if (s?.deployInProgress) {
if (s?.deployInProgress) {
deployCell = <Spinner tick={tick} />;
} else if (state === "error" && errorPhase(s!) === "deploy") {
deployCell = <Failed />;
} else if (
["registering", "done"].includes(state) &&
s?.deployTxHash &&
s?.deployBlockHash &&
assethubUrl
) {
} else if (state === "done" && s?.deployTxHash && s?.deployBlockHash && assethubUrl) {
deployCell = (
<Link url={pjsExplorerUrl(assethubUrl, s.deployBlockHash)}>
<Text color="green">{shortHash(s.deployTxHash)}</Text>
</Link>
);
} else if (["registering", "done"].includes(state)) {
} else if (state === "done") {
deployCell = <Done />;
} else {
deployCell = <Idle />;
Expand All @@ -166,14 +130,12 @@ function ContractRow({
metaCell = <Spinner tick={tick} />;
} else if (state === "error" && errorPhase(s!) === "metadata") {
metaCell = <Failed />;
} else if (["registering", "done"].includes(state) && s?.cid && ipfsGatewayUrl) {
} else if (state === "done" && s?.cid && ipfsGatewayUrl) {
metaCell = (
<Link url={ipfsUrl(ipfsGatewayUrl, s.cid)}>
<Text color="green">{shortHash(s.cid)}</Text>
</Link>
);
} else if (["registering", "done"].includes(state) && s?.publishTxHash) {
metaCell = <Done />;
} else {
metaCell = <Idle />;
}
Expand All @@ -182,8 +144,6 @@ function ContractRow({
let registerCell: React.ReactNode;
if (s?.registerInProgress) {
registerCell = <Spinner tick={tick} />;
} else if (state === "error" && errorPhase(s!) === "register") {
registerCell = <Failed />;
} else if (state === "done" && s?.registerTxHash && s?.registerBlockHash && assethubUrl) {
registerCell = (
<Link url={pjsExplorerUrl(assethubUrl, s.registerBlockHash)}>
Expand Down Expand Up @@ -226,15 +186,10 @@ function ContractRow({
// full link on its own line below the row. Conditions mirror the cell
// rendering above so an inline line appears iff a cell shows a link.
const linkDefs: { label: string; url: string }[] = [];
if (
["registering", "done"].includes(state) &&
s?.deployTxHash &&
s?.deployBlockHash &&
assethubUrl
) {
if (state === "done" && s?.deployTxHash && s?.deployBlockHash && assethubUrl) {
linkDefs.push({ label: "deploy", url: pjsExplorerUrl(assethubUrl, s.deployBlockHash) });
}
if (["registering", "done"].includes(state) && s?.cid && ipfsGatewayUrl) {
if (state === "done" && s?.cid && ipfsGatewayUrl) {
linkDefs.push({ label: "metadata", url: ipfsUrl(ipfsGatewayUrl, s.cid) });
}
if (state === "done" && s?.registerTxHash && s?.registerBlockHash && assethubUrl) {
Expand All @@ -261,7 +216,6 @@ function ContractRow({
export interface DeployTableProps {
statuses: Map<string, ContractStatus>;
displayNames: Map<string, string>;
crates: string[];
buildOnly: boolean;
assethubUrl?: string;
bulletinUrl?: string;
Expand All @@ -273,7 +227,6 @@ export interface DeployTableProps {
export function DeployTable({
statuses,
displayNames,
crates,
buildOnly,
assethubUrl,
ipfsGatewayUrl,
Expand All @@ -287,10 +240,9 @@ export function DeployTable({
return () => clearInterval(timer);
}, []);

const rowCrates = [
...crates,
...Array.from(statuses.keys()).filter((crate) => !crates.includes(crate)),
];
// Row order comes from `statuses` insertion order, which the adapter
// fills in layered deployment order on the `detect` event.
const rowCrates = Array.from(statuses.keys());

// Collect and group errors for display below table. Toolchain-level
// failures often apply to every contract in a build batch, and printing
Expand Down
12 changes: 9 additions & 3 deletions src/apps/cli/src/lib/components/InstallTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react";
import { relative } from "node:path";
import { Box, Text } from "ink";
import type { InstallStatus } from "../install-pipeline";
import {
Expand Down Expand Up @@ -87,12 +88,17 @@ function InstallRow({

// When OSC 8 hyperlinks aren't available, the metadata cell only shows the
// short CID hash; surface the full link on its own line below the row.
const hasLink = state === "done" && s?.metadataCid && ipfsGatewayUrl;
if (hyperlinksSupported || !hasLink) return row;
const showLinkLine =
!hyperlinksSupported && state === "done" && s?.metadataCid && ipfsGatewayUrl;
// After a successful install, show where the artifacts landed.
const savedPath =
state === "done" && s?.savedPath ? relative(process.cwd(), s.savedPath) : null;
if (!showLinkLine && !savedPath) return row;
return (
<Box flexDirection="column">
{row}
<LinkLine url={ipfsUrl(ipfsGatewayUrl!, s!.metadataCid!)} />
{showLinkLine && <LinkLine url={ipfsUrl(ipfsGatewayUrl!, s!.metadataCid!)} />}
{savedPath && <Text dimColor>{` ↳ ${savedPath}`}</Text>}
</Box>
);
}
Expand Down
4 changes: 0 additions & 4 deletions src/apps/cli/src/lib/components/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ export function Failed() {
return <Text color="red">✖</Text>;
}

export function Cached() {
return <Text color="blue">~</Text>;
}

export function LogTail({
lines,
height,
Expand Down
Loading
Loading