Skip to content

TypeScript types for the wasm verifier reports - #21

Merged
samjay8 merged 1 commit into
mainfrom
feat/wasm-types
Oct 26, 2026
Merged

samjay8 merged 1 commit into
mainfrom
feat/wasm-types

Conversation

@samjay8

@samjay8 samjay8 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Closes #5.

verify and inspect returned plain objects, so the generated .d.ts typed them as any. They're typed now:

export function verify(bundle_json: string, trust_toml?: string | null, events?: boolean | null): VerifyReport | Rejection;
export function inspect(bundle_json: string): InspectReport;

A typescript_custom_section describes the following types, matching externalize_core::report field for field:

  • VerifyReport, Rejection
  • CertifiedLedger, OrgAgreement
  • TransactionClaim | InvocationClaim
  • DecodedEvent
  • InspectReport

unchecked_return_type attaches these types to the two functions. The report's shape doesn't change.

const r = verify(bundle, undefined, true);
if (r.verified) {
  for (const c of r.claims) if (c.kind === "invocation") c.decoded_events?.forEach((e) => e.contract);
} else {
  console.error(r.error);
}

Done-when from the issue

  • The generated externalize_wasm.d.ts exports the new types. node.cjs now asserts every type and both signatures, so CI's wasm job checks this.
  • crates/externalize-wasm/tests/node.cjs still passes.

Checked

  • The CI wasm job, run locally: build, wasm-bindgen --target nodejs, then node.cjs.
  • tsc --strict passes on a consumer that narrows on both unions.
  • cargo fmt --check and clippy on the crate.

verify and inspect returned plain objects, so the generated .d.ts typed
them as any. A typescript_custom_section now describes VerifyReport,
Rejection, CertifiedLedger, OrgAgreement, the two claim kinds,
DecodedEvent and InspectReport, matching externalize_core::report, and
unchecked_return_type puts them on verify (VerifyReport | Rejection) and
inspect (InspectReport). Checking report.verified narrows the union, and
claims narrow on kind.

node.cjs now asserts the .d.ts exports the types and signatures. Locally,
a strict tsc consumer that narrows both unions type-checks.

Closes #5.
@samjay8
samjay8 merged commit d05351a into main Oct 26, 2026
8 checks passed
@samjay8
samjay8 deleted the feat/wasm-types branch October 26, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement]: TypeScript types for the verification report

1 participant