@crediolabs/policy-builder-cli 0.1.3 → 0.1.5

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.
@@ -8,6 +8,7 @@
8
8
  // [--json] [--quiet] [--out <path>]
9
9
  // policy-builder synthesize --recorded-tx <path.json> --network <mainnet|testnet>
10
10
  // [--responses <path.json>]
11
+ // [--smart-account <C...>] [--install-nonce <n>]
11
12
  // [--json] [--quiet] [--out <path>]
12
13
  //
13
14
  // The router is hand-rolled (no commander / yargs dep). It splits argv into
@@ -61,12 +62,18 @@ Usage:
61
62
  [--json] [--quiet] [--out <path>]
62
63
  policy-builder synthesize --recorded-tx <path.json> --network <mainnet|testnet>
63
64
  [--responses <path.json>]
65
+ [--smart-account <C...>] [--install-nonce <n>]
64
66
  [--json] [--quiet] [--out <path>]
65
67
 
66
68
  Flags:
67
- --json emit machine-readable JSON on stdout
68
- --quiet suppress progress / non-error output
69
- --out write artefact to file (JSON)
69
+ --json emit machine-readable JSON on stdout
70
+ --quiet suppress progress / non-error output
71
+ --out write artefact to file (JSON)
72
+ --smart-account C... account to opt into the interpreter adapter, so
73
+ non-OZ constraints (per-method scoping, invocation-count
74
+ windows, oracle bounds, exact hop paths) lower to a real
75
+ predicate document instead of warnings
76
+ --install-nonce per-rule install nonce for the interpreter policy (default 1)
70
77
  `);
71
78
  }
72
79
  await main();
@@ -27,7 +27,13 @@ export async function runSynthesizeCommand(argv, flags) {
27
27
  return formatToolResponse(res, flags, 'synthesize(mandate)');
28
28
  }
29
29
  // hasRecorded
30
- const recordedTx = readJsonFile(pairs['recorded-tx']);
30
+ const recordedFile = readJsonFile(pairs['recorded-tx']);
31
+ // Accept either a bare RecordedTransaction or the `{ ok, data }` artifact that
32
+ // `record --out` writes (same shape as `--json`), so `record --out X` followed
33
+ // by `synthesize --recorded-tx X` works end to end.
34
+ const recordedTx = recordedFile?.ok === true && typeof recordedFile.data === 'object' && recordedFile.data !== null
35
+ ? recordedFile.data
36
+ : recordedFile;
31
37
  const network = pairs.network;
32
38
  if (!network) {
33
39
  throw new CliError({
@@ -41,6 +47,17 @@ export async function runSynthesizeCommand(argv, flags) {
41
47
  if (pairs.responses) {
42
48
  args.userResponses = readJsonFile(pairs.responses);
43
49
  }
50
+ // --smart-account <C...> opts into the interpreter adapter, so constraints OZ
51
+ // cannot express (per-method scoping, invocation-count windows, oracle bounds,
52
+ // exact hop paths) lower to a real predicate document instead of just warnings.
53
+ // The core validates the address and installNonce; a bad value surfaces there.
54
+ if (pairs['smart-account']) {
55
+ const interpreter = { smartAccountAddress: pairs['smart-account'] };
56
+ if (pairs['install-nonce']) {
57
+ interpreter.installNonce = Number(pairs['install-nonce']);
58
+ }
59
+ args.interpreter = interpreter;
60
+ }
44
61
  const res = await runSynthesizePolicy(args);
45
62
  return formatToolResponse(res, flags, 'synthesize(recording)');
46
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crediolabs/policy-builder-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "description": "CLI wrapper around the OZ policy-synth core (record + synthesize) for solo-dev and CI workflows.",
6
6
  "type": "module",
@@ -35,7 +35,14 @@ export async function runSynthesizeCommand(
35
35
  }
36
36
 
37
37
  // hasRecorded
38
- const recordedTx = readJsonFile(pairs['recorded-tx'] as string) as Record<string, unknown>
38
+ const recordedFile = readJsonFile(pairs['recorded-tx'] as string) as Record<string, unknown>
39
+ // Accept either a bare RecordedTransaction or the `{ ok, data }` artifact that
40
+ // `record --out` writes (same shape as `--json`), so `record --out X` followed
41
+ // by `synthesize --recorded-tx X` works end to end.
42
+ const recordedTx =
43
+ recordedFile?.ok === true && typeof recordedFile.data === 'object' && recordedFile.data !== null
44
+ ? (recordedFile.data as Record<string, unknown>)
45
+ : recordedFile
39
46
  const network = pairs.network
40
47
  if (!network) {
41
48
  throw new CliError({
@@ -49,6 +56,17 @@ export async function runSynthesizeCommand(
49
56
  if (pairs.responses) {
50
57
  args.userResponses = readJsonFile(pairs.responses)
51
58
  }
59
+ // --smart-account <C...> opts into the interpreter adapter, so constraints OZ
60
+ // cannot express (per-method scoping, invocation-count windows, oracle bounds,
61
+ // exact hop paths) lower to a real predicate document instead of just warnings.
62
+ // The core validates the address and installNonce; a bad value surfaces there.
63
+ if (pairs['smart-account']) {
64
+ const interpreter: Record<string, unknown> = { smartAccountAddress: pairs['smart-account'] }
65
+ if (pairs['install-nonce']) {
66
+ interpreter.installNonce = Number(pairs['install-nonce'])
67
+ }
68
+ args.interpreter = interpreter
69
+ }
52
70
  const res = await runSynthesizePolicy(args)
53
71
  return formatToolResponse(res, flags, 'synthesize(recording)')
54
72
  }