brainchain-verify 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare function canonicalStringify(value: unknown): string;
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js CHANGED
@@ -124,7 +124,7 @@ function report(reports, header, task) {
124
124
  errors,
125
125
  skipped,
126
126
  decisions,
127
- notChecked: "That Jev produced the answer. The chain trusts the brain key to record Jev's answers faithfully.",
127
+ notChecked: "That Jev produced the answer. BrainChain records Jev's answers, and the contracts bound what a recorded answer can do.",
128
128
  trustModel: TRUST_MODEL,
129
129
  };
130
130
  console.log(JSON.stringify(out, null, 2));
@@ -137,7 +137,7 @@ function report(reports, header, task) {
137
137
  console.log(` ${TAGS[c.status].padEnd(5)} ${c.message}`);
138
138
  }
139
139
  console.log(`\n${verdict(failed, errors, skipped, reports.length > 1)}`);
140
- console.log(`Not checked: that Jev produced the answer. The chain trusts the brain key for that: ${TRUST_MODEL}`);
140
+ console.log(`Not checked: that Jev produced the answer. See ${TRUST_MODEL}`);
141
141
  process.exit(failed + errors > 0 ? 1 : 0);
142
142
  }
143
143
  try {
@@ -0,0 +1,18 @@
1
+ import type { Address } from "viem";
2
+ export interface ContractSet {
3
+ /** As in a decision page's address: v3 for 3.0.0, v3-1 for 3.1.0. */
4
+ key: string;
5
+ release: string;
6
+ fromBlock: number;
7
+ board: Address;
8
+ log: Address;
9
+ executor: Address;
10
+ }
11
+ export interface Network {
12
+ chainId: number;
13
+ name: string;
14
+ rpc: string;
15
+ /** The active set first, then the retired ones, newest first. */
16
+ sets: ContractSet[];
17
+ }
18
+ export declare const NETWORKS: Record<"mainnet" | "testnet", Network>;
@@ -0,0 +1,39 @@
1
+ import { type PublicClient } from "viem";
2
+ import type { ContractSet, Network } from "./deployments.js";
3
+ /** `error` is a check that could not complete, such as a record host that did not answer. */
4
+ export type Status = "ok" | "fail" | "skip" | "error";
5
+ export interface Check {
6
+ /** Stable across releases, so a script can pick out one check. */
7
+ name: string;
8
+ status: Status;
9
+ message: string;
10
+ }
11
+ export interface DecisionReport {
12
+ id: number;
13
+ kind?: string;
14
+ task?: number;
15
+ block?: number;
16
+ recordedAt?: string;
17
+ confidenceBps?: number;
18
+ payloadURI?: string;
19
+ checks: Check[];
20
+ }
21
+ export interface Context {
22
+ client: PublicClient;
23
+ network: Network;
24
+ set: ContractSet;
25
+ briefs: Map<bigint, Promise<Brief>>;
26
+ }
27
+ interface Brief {
28
+ title: string;
29
+ brief: string;
30
+ /** Best first. */
31
+ levels: string[];
32
+ /** Index into `levels` of the lowest level that still gets paid. */
33
+ passIndex: number;
34
+ }
35
+ export declare function errorMessage(error: unknown): string;
36
+ /** Decision ids about one task on the set's board, oldest first. */
37
+ export declare function decisionsOf({ client, network, set }: Context, task: bigint): Promise<bigint[]>;
38
+ export declare function verifyDecision(ctx: Context, id: bigint): Promise<DecisionReport>;
39
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainchain-verify",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Check a BrainChain decision against the chain: the published record, its hashes, its confidence and the thresholds the contracts applied.",
5
5
  "license": "MIT",
6
6
  "author": "BrainChain",
@@ -11,11 +11,30 @@
11
11
  "directory": "tools/verify-decision"
12
12
  },
13
13
  "bugs": "https://github.com/usebrainchain/brainchain/issues",
14
- "keywords": ["brainchain", "jev", "verify", "decision", "onchain"],
14
+ "keywords": [
15
+ "brainchain",
16
+ "jev",
17
+ "verify",
18
+ "decision",
19
+ "onchain"
20
+ ],
15
21
  "type": "module",
16
22
  "bin": {
17
23
  "brainchain-verify": "dist/cli.js"
18
24
  },
25
+ "main": "dist/verify.js",
26
+ "types": "dist/verify.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/verify.d.ts",
30
+ "default": "./dist/verify.js"
31
+ },
32
+ "./deployments": {
33
+ "types": "./dist/deployments.d.ts",
34
+ "default": "./dist/deployments.js"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
19
38
  "files": [
20
39
  "dist",
21
40
  "README.md"