brainchain-verify 0.4.1 → 0.5.1
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.
- package/README.md +1 -1
- package/dist/cli.js +4 -2
- package/dist/deployments.js +11 -0
- package/dist/verify.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ That Jev produced the answer. BrainChain records Jev's answers, and the contract
|
|
|
113
113
|
|
|
114
114
|
## JSON
|
|
115
115
|
|
|
116
|
-
`--json` prints one object. `decisions` holds one entry, or one per decision with `--task`. `verdict` is `match`, `withheld`, `mismatch` or `unverified` (a record could not be fetched). With `withheld`, `withheldNotChecked` says what was left out, and the decision carries `withheld: true`. A grade of outside work carries `outside: true`. Each check keeps its `name` across releases, and its `status` is `ok`, `fail`, `skip` or `error`. When the tool cannot run, it prints `{ "error": "..." }` and exits 1. Trimmed to one check:
|
|
116
|
+
`--json` prints one object. `decisions` holds one entry, or one per decision with `--task`. `verdict` is `match`, `withheld`, `mismatch` or `unverified` (a record could not be fetched). With `withheld`, `withheldNotChecked` says what was left out, and the decision carries `withheld: true`. A grade of outside work carries `outside: true`. Each check keeps its `name` across releases, and its `status` is `ok`, `fail`, `skip` or `error`. When the tool cannot run, it prints `{ "error": "..." }` and exits 1, or 2 for bad arguments or an RPC that serves another chain. Trimmed to one check:
|
|
117
117
|
|
|
118
118
|
```json
|
|
119
119
|
{
|
package/dist/cli.js
CHANGED
|
@@ -27,6 +27,8 @@ const TRUST_MODEL = "https://docs.usebrainchain.com/trust-model";
|
|
|
27
27
|
// Sets before 3.0.0 named tasks by id alone, which the subject check does not model, so the package carries none.
|
|
28
28
|
const BEFORE_3 = /^(v2(-|$)|2\.|0x83b31d99fa31a9e5257955a737ef34c40f1c57bf$)/i;
|
|
29
29
|
function usage(message) {
|
|
30
|
+
if (json)
|
|
31
|
+
fail(message, 2);
|
|
30
32
|
console.error(`${message}\n\n${USAGE}`);
|
|
31
33
|
process.exit(2);
|
|
32
34
|
}
|
|
@@ -93,12 +95,12 @@ const ctx = {
|
|
|
93
95
|
set,
|
|
94
96
|
briefs: new Map(),
|
|
95
97
|
};
|
|
96
|
-
function fail(message) {
|
|
98
|
+
function fail(message, status = 1) {
|
|
97
99
|
if (json)
|
|
98
100
|
console.log(JSON.stringify({ error: clean(message) }, null, 2));
|
|
99
101
|
else
|
|
100
102
|
console.error(clean(message));
|
|
101
|
-
process.exit(
|
|
103
|
+
process.exit(status);
|
|
102
104
|
}
|
|
103
105
|
const TAGS = { ok: "ok", fail: "FAIL", skip: "skip", error: "ERROR" };
|
|
104
106
|
const tally = (checks, status) => checks.filter((c) => c.status === status).length;
|
package/dist/deployments.js
CHANGED
|
@@ -4,6 +4,17 @@ export const NETWORKS = {
|
|
|
4
4
|
"name": "BrainChain mainnet",
|
|
5
5
|
"rpc": "https://rpc.usebrainchain.com",
|
|
6
6
|
"sets": [
|
|
7
|
+
{
|
|
8
|
+
"key": "v3-5",
|
|
9
|
+
"release": "3.5.0",
|
|
10
|
+
"aliases": [
|
|
11
|
+
"v5"
|
|
12
|
+
],
|
|
13
|
+
"fromBlock": 965,
|
|
14
|
+
"board": "0x44b8464342Bbfb9B565FAE494DfDefa37D33A211",
|
|
15
|
+
"log": "0x2EF509bd9cA1e7C5FBe2C2FD7Ff25cE9F6f9cB68",
|
|
16
|
+
"executor": "0xFD268Ae2c1Ec0Db03C3C6b17E1AEDE973729FE29"
|
|
17
|
+
},
|
|
7
18
|
{
|
|
8
19
|
"key": "v3-4",
|
|
9
20
|
"release": "3.4.0",
|
package/dist/verify.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Agent as HttpAgent, request as httpRequest } from "node:http";
|
|
|
3
3
|
import { Agent as HttpsAgent, request as httpsRequest } from "node:https";
|
|
4
4
|
import { BlockList, isIP } from "node:net";
|
|
5
5
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
6
|
-
import { BaseError, decodeFunctionData, encodeAbiParameters, keccak256, pad, toBytes, toHex, } from "viem";
|
|
6
|
+
import { BaseError, decodeFunctionData, encodeAbiParameters, encodeFunctionData, keccak256, pad, toBytes, toHex, } from "viem";
|
|
7
7
|
import { decisionExecutorAbi, decisionLogAbi, modelRegistryAbi, taskBoardAbi } from "./abi.js";
|
|
8
8
|
import { canonicalStringify } from "./canonical.js";
|
|
9
9
|
const Kind = { Hire: 1, Grade: 2, Ruling: 3, Change: 4 };
|
|
@@ -104,6 +104,8 @@ function decodeChange(target, data) {
|
|
|
104
104
|
for (const abi of [taskBoardAbi, decisionExecutorAbi, modelRegistryAbi, decisionLogAbi]) {
|
|
105
105
|
try {
|
|
106
106
|
const { functionName, args } = decodeFunctionData({ abi, data });
|
|
107
|
+
if (encodeFunctionData({ abi, functionName, args }).toLowerCase() !== data.toLowerCase())
|
|
108
|
+
continue;
|
|
107
109
|
return { target, function: functionName, args: plain(args ?? []) };
|
|
108
110
|
}
|
|
109
111
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainchain-verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|