@aura-protocol/cli 0.1.2 → 0.3.0
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 +84 -67
- package/bin/aura.js +0 -0
- package/dist/commands/confidential.d.ts +1 -1
- package/dist/commands/confidential.js +276 -597
- package/dist/commands/confidential.js.map +1 -1
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +26 -8
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/dashboard.d.ts +1 -1
- package/dist/commands/dashboard.js +6 -7
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/dwallet.d.ts +1 -1
- package/dist/commands/dwallet.js +52 -41
- package/dist/commands/dwallet.js.map +1 -1
- package/dist/commands/execution.d.ts +1 -1
- package/dist/commands/execution.js +111 -175
- package/dist/commands/execution.js.map +1 -1
- package/dist/commands/features.d.ts +1 -1
- package/dist/commands/features.js +15 -10
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/generated.d.ts +20 -0
- package/dist/commands/generated.js +61 -0
- package/dist/commands/generated.js.map +1 -0
- package/dist/commands/governance.d.ts +1 -1
- package/dist/commands/governance.js +113 -99
- package/dist/commands/governance.js.map +1 -1
- package/dist/commands/helpers.d.ts +5 -2
- package/dist/commands/helpers.js +79 -16
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/instruction-exec.d.ts +27 -0
- package/dist/commands/instruction-exec.js +171 -0
- package/dist/commands/instruction-exec.js.map +1 -0
- package/dist/commands/instruction.d.ts +9 -0
- package/dist/commands/instruction.js +81 -0
- package/dist/commands/instruction.js.map +1 -0
- package/dist/commands/pda.d.ts +1 -1
- package/dist/commands/pda.js +15 -7
- package/dist/commands/pda.js.map +1 -1
- package/dist/commands/treasury.d.ts +1 -1
- package/dist/commands/treasury.js +201 -186
- package/dist/commands/treasury.js.map +1 -1
- package/dist/core/config.d.ts +35 -0
- package/dist/core/config.js +97 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/context.d.ts +51 -0
- package/dist/core/context.js +60 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/errors.d.ts +38 -0
- package/dist/core/errors.js +138 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/network.d.ts +18 -0
- package/dist/core/network.js +38 -0
- package/dist/core/network.js.map +1 -0
- package/dist/core/runner.d.ts +45 -0
- package/dist/core/runner.js +219 -0
- package/dist/core/runner.js.map +1 -0
- package/dist/core/security.d.ts +28 -0
- package/dist/core/security.js +83 -0
- package/dist/core/security.js.map +1 -0
- package/dist/core/wallet.d.ts +2 -0
- package/dist/core/wallet.js +21 -0
- package/dist/core/wallet.js.map +1 -0
- package/dist/ika.d.ts +0 -9
- package/dist/ika.js +0 -48
- package/dist/ika.js.map +1 -1
- package/dist/index.js +56 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/domain.d.ts +16 -0
- package/dist/lib/domain.js +88 -0
- package/dist/lib/domain.js.map +1 -0
- package/dist/lib/ika.d.ts +81 -0
- package/dist/lib/ika.js +192 -0
- package/dist/lib/ika.js.map +1 -0
- package/dist/lib/instructions.d.ts +79 -0
- package/dist/lib/instructions.js +421 -0
- package/dist/lib/instructions.js.map +1 -0
- package/dist/lib/protocol.d.ts +99 -0
- package/dist/lib/protocol.js +327 -0
- package/dist/lib/protocol.js.map +1 -0
- package/dist/lib/treasury-view.d.ts +11 -0
- package/dist/lib/treasury-view.js +126 -0
- package/dist/lib/treasury-view.js.map +1 -0
- package/dist/output.js +0 -3
- package/dist/output.js.map +1 -1
- package/dist/program-instructions.d.ts +1 -1
- package/dist/protocol.d.ts +0 -1
- package/dist/protocol.js +0 -7
- package/dist/protocol.js.map +1 -1
- package/dist/treasury-view.js +1 -1
- package/dist/treasury-view.js.map +1 -1
- package/dist/ui/dashboard.d.ts +7 -0
- package/dist/ui/dashboard.js +99 -0
- package/dist/ui/dashboard.js.map +1 -0
- package/dist/ui/format.d.ts +9 -0
- package/dist/ui/format.js +92 -0
- package/dist/ui/format.js.map +1 -0
- package/dist/ui/output.d.ts +58 -0
- package/dist/ui/output.js +208 -0
- package/dist/ui/output.js.map +1 -0
- package/dist/ui/theme.d.ts +52 -0
- package/dist/ui/theme.js +110 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/vendor/encrypt/generated/grpc/encrypt_service.d.ts +1 -1
- package/dist/vendor/encrypt/generated/grpc/encrypt_service.js +36 -13
- package/dist/vendor/encrypt/generated/grpc/encrypt_service.js.map +1 -1
- package/dist/vendor/encrypt/grpc.d.ts +2 -2
- package/dist/vendor/encrypt/grpc.js +1 -3
- package/dist/vendor/encrypt/grpc.js.map +1 -1
- package/dist/vendor/ika/bcs-types.js +107 -50
- package/dist/vendor/ika/bcs-types.js.map +1 -1
- package/dist/vendor/ika/generated/grpc/ika_dwallet.d.ts +1 -1
- package/dist/vendor/ika/generated/grpc/ika_dwallet.js +14 -4
- package/dist/vendor/ika/generated/grpc/ika_dwallet.js.map +1 -1
- package/dist/vendor/ika/grpc.d.ts +1 -1
- package/dist/vendor/ika/grpc.js +49 -24
- package/dist/vendor/ika/grpc.js.map +1 -1
- package/package.json +16 -13
- package/dist/ascii.d.ts +0 -1
- package/dist/ascii.js +0 -2
- package/dist/ascii.js.map +0 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The secure transaction pipeline shared by every command that writes
|
|
3
|
+
* on-chain. Given built instructions and some metadata it will, in order:
|
|
4
|
+
*
|
|
5
|
+
* 1. assemble the transaction (compute-budget + optional heap frame),
|
|
6
|
+
* 2. render a human preview of exactly what will be signed,
|
|
7
|
+
* 3. guard production (mainnet) writes behind an explicit confirmation,
|
|
8
|
+
* 4. confirm sensitive instructions (authority/governance/closures),
|
|
9
|
+
* 5. preflight-simulate and surface compute units + program logs,
|
|
10
|
+
* 6. sign, send, and confirm, printing the signature + explorer link.
|
|
11
|
+
*
|
|
12
|
+
* `--dry-run` stops after the preview and emits the serialized instructions.
|
|
13
|
+
* `--json` suppresses decorative output and returns structured data.
|
|
14
|
+
* `--yes` skips confirmations (for CI). `--no-simulate` skips preflight.
|
|
15
|
+
*/
|
|
16
|
+
import { confirm } from "@inquirer/prompts";
|
|
17
|
+
import { ComputeBudgetProgram, Transaction, } from "@solana/web3.js";
|
|
18
|
+
import { emitJson, printNote, printPanel, printSuccess, serializeInstruction, startSpinner, } from "../ui/output.js";
|
|
19
|
+
import { block, style, symbol } from "../ui/theme.js";
|
|
20
|
+
import { CliError } from "./errors.js";
|
|
21
|
+
import { classifyInstructionRisk } from "./security.js";
|
|
22
|
+
const DEFAULT_COMPUTE_UNIT_LIMIT = 600_000;
|
|
23
|
+
function networkBadge(ctx) {
|
|
24
|
+
const { kind, label } = ctx.network;
|
|
25
|
+
if (kind === "mainnet")
|
|
26
|
+
return block(label.toUpperCase(), "danger");
|
|
27
|
+
if (kind === "devnet")
|
|
28
|
+
return block(label, "success");
|
|
29
|
+
if (kind === "localnet")
|
|
30
|
+
return block(label, "muted");
|
|
31
|
+
return block(label, "warn");
|
|
32
|
+
}
|
|
33
|
+
function explorerUrl(ctx, signature) {
|
|
34
|
+
const base = `https://explorer.solana.com/tx/${signature}`;
|
|
35
|
+
switch (ctx.network.kind) {
|
|
36
|
+
case "mainnet":
|
|
37
|
+
return base;
|
|
38
|
+
case "devnet":
|
|
39
|
+
return `${base}?cluster=devnet`;
|
|
40
|
+
case "testnet":
|
|
41
|
+
return `${base}?cluster=testnet`;
|
|
42
|
+
default:
|
|
43
|
+
return `${base}?cluster=custom&customUrl=${encodeURIComponent(ctx.network.rpcUrl)}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function renderPreview(ctx, instructions, meta) {
|
|
47
|
+
const lines = [];
|
|
48
|
+
lines.push(`${style.muted("network")} ${networkBadge(ctx)} ${style.dim(ctx.network.rpcUrl)}`);
|
|
49
|
+
lines.push(`${style.muted("program")} ${style.dim(ctx.programId.toBase58())}`);
|
|
50
|
+
if (ctx.wallet) {
|
|
51
|
+
lines.push(`${style.muted("payer")} ${ctx.wallet.publicKey.toBase58()}`);
|
|
52
|
+
}
|
|
53
|
+
for (const [label, value] of meta.summary ?? []) {
|
|
54
|
+
lines.push(`${style.muted(label.padEnd(9))} ${value}`);
|
|
55
|
+
}
|
|
56
|
+
lines.push(style.muted("─".repeat(40)));
|
|
57
|
+
instructions.forEach((ix, index) => {
|
|
58
|
+
const signers = ix.keys.filter((k) => k.isSigner).length;
|
|
59
|
+
const writable = ix.keys.filter((k) => k.isWritable).length;
|
|
60
|
+
lines.push(`${style.bold(`#${index + 1}`)} ${style.dim(ix.programId.toBase58())} ` +
|
|
61
|
+
style.muted(`(${ix.keys.length} accts · ${signers} signer · ${writable} writable)`));
|
|
62
|
+
});
|
|
63
|
+
printPanel(ctx.output, `${meta.action}`, lines, ctx.network.isProduction ? "danger" : "primary");
|
|
64
|
+
}
|
|
65
|
+
async function confirmOrThrow(ctx, message) {
|
|
66
|
+
if (ctx.flags.yes) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (!process.stdout.isTTY) {
|
|
70
|
+
throw new CliError(`Confirmation required: ${message}`, {
|
|
71
|
+
code: "CONFIRMATION_REQUIRED",
|
|
72
|
+
tip: "Re-run with --yes to proceed non-interactively.",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return await confirm({ message, default: false });
|
|
76
|
+
}
|
|
77
|
+
async function preflightSimulate(ctx, tx) {
|
|
78
|
+
const spinner = startSpinner(ctx.output, "Simulating transaction...");
|
|
79
|
+
try {
|
|
80
|
+
const result = await ctx.connection.simulateTransaction(tx);
|
|
81
|
+
const units = result.value.unitsConsumed;
|
|
82
|
+
if (result.value.err) {
|
|
83
|
+
const logs = (result.value.logs ?? []).join("\n");
|
|
84
|
+
spinner.fail("Simulation failed");
|
|
85
|
+
throw new CliError(`Preflight simulation failed: ${JSON.stringify(result.value.err)}`, {
|
|
86
|
+
code: "SIMULATION_FAILED",
|
|
87
|
+
tip: "Inspect the program logs above. Use --no-simulate to skip this check, or --dry-run to inspect the instruction.",
|
|
88
|
+
details: logs || undefined,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
spinner.succeed(units !== null && units !== undefined
|
|
92
|
+
? `Simulation ok (${units.toLocaleString()} compute units)`
|
|
93
|
+
: "Simulation ok");
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error instanceof CliError) {
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
spinner.fail("Simulation error");
|
|
100
|
+
throw new CliError(`Could not simulate transaction: ${error instanceof Error ? error.message : String(error)}`, {
|
|
101
|
+
code: "SIMULATION_ERROR",
|
|
102
|
+
tip: "Pass --no-simulate to skip the preflight check.",
|
|
103
|
+
cause: error,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Builds, previews, guards, simulates, signs, and sends `instructions`.
|
|
109
|
+
* Honors `--dry-run`, `--json`, `--yes`, `--no-simulate`, and `--compute-units`.
|
|
110
|
+
*/
|
|
111
|
+
export async function runInstructions(ctx, instructions, meta) {
|
|
112
|
+
if (!ctx.wallet) {
|
|
113
|
+
throw new CliError(`A wallet is required to ${meta.action.toLowerCase()}.`, {
|
|
114
|
+
code: "WALLET_REQUIRED",
|
|
115
|
+
tip: "Configure a wallet with `aura config init` or pass --wallet <path>.",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const computeUnits = ctx.flags.computeUnits ?? meta.computeUnits ?? DEFAULT_COMPUTE_UNIT_LIMIT;
|
|
119
|
+
const budgetIxns = [
|
|
120
|
+
ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnits }),
|
|
121
|
+
];
|
|
122
|
+
if (meta.heapFrameBytes) {
|
|
123
|
+
budgetIxns.unshift(ComputeBudgetProgram.requestHeapFrame({ bytes: meta.heapFrameBytes }));
|
|
124
|
+
}
|
|
125
|
+
renderPreview(ctx, instructions, meta);
|
|
126
|
+
// --- Dry run: stop before sending. ------------------------------------
|
|
127
|
+
if (ctx.dryRun) {
|
|
128
|
+
if (ctx.output.json) {
|
|
129
|
+
emitJson(ctx.output, {
|
|
130
|
+
action: meta.action,
|
|
131
|
+
dryRun: true,
|
|
132
|
+
network: ctx.network.label,
|
|
133
|
+
instructions: instructions.map(serializeInstruction),
|
|
134
|
+
...meta.result,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
printNote(ctx.output, "Dry run — transaction was not sent.");
|
|
139
|
+
}
|
|
140
|
+
return { dryRun: true, aborted: false };
|
|
141
|
+
}
|
|
142
|
+
// --- Guard rails: confirmations. --------------------------------------
|
|
143
|
+
const risk = meta.instructionName
|
|
144
|
+
? classifyInstructionRisk(meta.instructionName)
|
|
145
|
+
: { level: "normal" };
|
|
146
|
+
if (ctx.network.isProduction) {
|
|
147
|
+
printPanel(ctx.output, "Production network", [
|
|
148
|
+
style.danger(`${symbol.warn} You are about to send a transaction on MAINNET.`),
|
|
149
|
+
style.muted("This spends real funds and cannot be undone."),
|
|
150
|
+
], "danger");
|
|
151
|
+
const ok = await confirmOrThrow(ctx, "Proceed on mainnet-beta?");
|
|
152
|
+
if (!ok) {
|
|
153
|
+
printNote(ctx.output, "Aborted.");
|
|
154
|
+
return { dryRun: false, aborted: true };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (meta.confirm || risk.level !== "normal") {
|
|
158
|
+
const reason = risk.reason ? ` (${risk.reason})` : "";
|
|
159
|
+
const ok = await confirmOrThrow(ctx, `Confirm "${meta.action}"${reason}?`);
|
|
160
|
+
if (!ok) {
|
|
161
|
+
printNote(ctx.output, "Aborted.");
|
|
162
|
+
return { dryRun: false, aborted: true };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// --- Assemble + sign. -------------------------------------------------
|
|
166
|
+
const extraSigners = meta.extraSigners ?? [];
|
|
167
|
+
const tx = new Transaction().add(...budgetIxns, ...instructions);
|
|
168
|
+
tx.feePayer = ctx.wallet.publicKey;
|
|
169
|
+
const latest = await ctx.connection.getLatestBlockhash("confirmed");
|
|
170
|
+
tx.recentBlockhash = latest.blockhash;
|
|
171
|
+
tx.sign(ctx.wallet, ...extraSigners);
|
|
172
|
+
// --- Preflight simulation. --------------------------------------------
|
|
173
|
+
if (ctx.flags.simulate) {
|
|
174
|
+
await preflightSimulate(ctx, tx);
|
|
175
|
+
}
|
|
176
|
+
// --- Send + confirm. --------------------------------------------------
|
|
177
|
+
const spinner = startSpinner(ctx.output, `Sending: ${meta.action}...`);
|
|
178
|
+
let signature;
|
|
179
|
+
try {
|
|
180
|
+
signature = await ctx.connection.sendRawTransaction(tx.serialize(), {
|
|
181
|
+
preflightCommitment: "confirmed",
|
|
182
|
+
});
|
|
183
|
+
const confirmation = await ctx.connection.confirmTransaction({
|
|
184
|
+
signature,
|
|
185
|
+
blockhash: latest.blockhash,
|
|
186
|
+
lastValidBlockHeight: latest.lastValidBlockHeight,
|
|
187
|
+
}, "confirmed");
|
|
188
|
+
if (confirmation.value.err) {
|
|
189
|
+
spinner.fail("Transaction failed");
|
|
190
|
+
throw new CliError(`Transaction ${signature} failed on-chain.`, {
|
|
191
|
+
code: "TX_FAILED",
|
|
192
|
+
tip: "Re-run with --dry-run to inspect the instruction, or check the explorer link.",
|
|
193
|
+
details: explorerUrl(ctx, signature),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
spinner.succeed(`${meta.action} confirmed`);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (error instanceof CliError)
|
|
200
|
+
throw error;
|
|
201
|
+
spinner.fail("Send failed");
|
|
202
|
+
throw new CliError(`Failed to send transaction: ${error instanceof Error ? error.message : String(error)}`, { code: "SEND_FAILED", cause: error });
|
|
203
|
+
}
|
|
204
|
+
if (ctx.output.json) {
|
|
205
|
+
emitJson(ctx.output, {
|
|
206
|
+
action: meta.action,
|
|
207
|
+
signature,
|
|
208
|
+
network: ctx.network.label,
|
|
209
|
+
explorer: explorerUrl(ctx, signature),
|
|
210
|
+
...meta.result,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
printSuccess(ctx.output, `${meta.action} — ${signature}`);
|
|
215
|
+
printNote(ctx.output, explorerUrl(ctx, signature));
|
|
216
|
+
}
|
|
217
|
+
return { dryRun: false, aborted: false, signature };
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,oBAAoB,EAEpB,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAkB,MAAM,eAAe,CAAC;AAExE,MAAM,0BAA0B,GAAG,OAAO,CAAC;AA2B3C,SAAS,YAAY,CAAC,GAAe;IACnC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;IACpC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IACpE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACtD,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,KAAK,EA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IAAI,CAAC,MAAM;SACf,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;QAC1D,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security helpers: keypair file hygiene and instruction risk classification.
|
|
3
|
+
*
|
|
4
|
+
* These feed the runner's guard rails. None of them block legitimate use; they
|
|
5
|
+
* surface warnings and decide when an explicit confirmation is warranted.
|
|
6
|
+
*/
|
|
7
|
+
export type RiskLevel = "normal" | "caution" | "danger";
|
|
8
|
+
export interface InstructionRisk {
|
|
9
|
+
level: RiskLevel;
|
|
10
|
+
/** Why the instruction is sensitive — shown in the confirmation prompt. */
|
|
11
|
+
reason?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Classifies a (snake_case) instruction name by blast radius so the runner can
|
|
15
|
+
* decide whether to require confirmation. This is intentionally conservative:
|
|
16
|
+
* authority changes, recovery, shutdowns, and account closures all prompt.
|
|
17
|
+
*/
|
|
18
|
+
export declare function classifyInstructionRisk(name: string): InstructionRisk;
|
|
19
|
+
export interface WalletHygiene {
|
|
20
|
+
/** A warning to surface, or null when the file looks fine / unchecked. */
|
|
21
|
+
warning: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Checks keypair file permissions on POSIX systems. A keypair readable by group
|
|
25
|
+
* or others is a credential-leak risk. No-ops on Windows, where POSIX mode bits
|
|
26
|
+
* do not apply.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkWalletFileHygiene(walletPath: string): WalletHygiene;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security helpers: keypair file hygiene and instruction risk classification.
|
|
3
|
+
*
|
|
4
|
+
* These feed the runner's guard rails. None of them block legitimate use; they
|
|
5
|
+
* surface warnings and decide when an explicit confirmation is warranted.
|
|
6
|
+
*/
|
|
7
|
+
import { statSync } from "node:fs";
|
|
8
|
+
import { expandHome } from "./config.js";
|
|
9
|
+
/**
|
|
10
|
+
* Classifies a (snake_case) instruction name by blast radius so the runner can
|
|
11
|
+
* decide whether to require confirmation. This is intentionally conservative:
|
|
12
|
+
* authority changes, recovery, shutdowns, and account closures all prompt.
|
|
13
|
+
*/
|
|
14
|
+
export function classifyInstructionRisk(name) {
|
|
15
|
+
const n = name.toLowerCase();
|
|
16
|
+
// Highest blast radius: emergency, ownership, recovery, kill-switches.
|
|
17
|
+
if (n.includes("emergency") || n.includes("shutdown")) {
|
|
18
|
+
return {
|
|
19
|
+
level: "danger",
|
|
20
|
+
reason: "emergency action affecting treasury availability",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (n.startsWith("break_glass")) {
|
|
24
|
+
return { level: "danger", reason: "break-glass recovery override" };
|
|
25
|
+
}
|
|
26
|
+
if (n.includes("transfer_authority") ||
|
|
27
|
+
n.includes("ownership_handover") ||
|
|
28
|
+
n.startsWith("nominate_successor")) {
|
|
29
|
+
return { level: "danger", reason: "changes treasury ownership/authority" };
|
|
30
|
+
}
|
|
31
|
+
if (n.includes("dead_mans_switch")) {
|
|
32
|
+
return { level: "danger", reason: "triggers the dead-man's switch" };
|
|
33
|
+
}
|
|
34
|
+
if (n.includes("revoke") || n.includes("rotate")) {
|
|
35
|
+
return {
|
|
36
|
+
level: "danger",
|
|
37
|
+
reason: "revokes or rotates an authority/credential",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Governance and recovery configuration: sensitive but routine.
|
|
41
|
+
if (n.includes("multisig") ||
|
|
42
|
+
n.includes("override") ||
|
|
43
|
+
n.includes("recovery_destination") ||
|
|
44
|
+
n.includes("guardian") ||
|
|
45
|
+
n.startsWith("configure_trust") ||
|
|
46
|
+
n.includes("operator_role")) {
|
|
47
|
+
return { level: "caution", reason: "modifies governance / access control" };
|
|
48
|
+
}
|
|
49
|
+
// Account closures (reclaim rent, drop state) and migrations.
|
|
50
|
+
if (n.startsWith("close_") ||
|
|
51
|
+
n.startsWith("remove_") ||
|
|
52
|
+
n.startsWith("migrate_") ||
|
|
53
|
+
n === "disable_confidential_guardrails") {
|
|
54
|
+
return { level: "caution", reason: "closes or removes on-chain state" };
|
|
55
|
+
}
|
|
56
|
+
return { level: "normal" };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks keypair file permissions on POSIX systems. A keypair readable by group
|
|
60
|
+
* or others is a credential-leak risk. No-ops on Windows, where POSIX mode bits
|
|
61
|
+
* do not apply.
|
|
62
|
+
*/
|
|
63
|
+
export function checkWalletFileHygiene(walletPath) {
|
|
64
|
+
if (process.platform === "win32") {
|
|
65
|
+
return { warning: null };
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const resolved = expandHome(walletPath);
|
|
69
|
+
const mode = statSync(resolved).mode & 0o777;
|
|
70
|
+
if ((mode & 0o077) !== 0) {
|
|
71
|
+
const octal = mode.toString(8).padStart(3, "0");
|
|
72
|
+
return {
|
|
73
|
+
warning: `Keypair ${resolved} is readable by group/others (mode ${octal}). Run: chmod 600 ${resolved}`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// File missing or unreadable — surfaced elsewhere when actually loaded.
|
|
79
|
+
return { warning: null };
|
|
80
|
+
}
|
|
81
|
+
return { warning: null };
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/core/security.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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H,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;QACxE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
import { expandHome } from "./config.js";
|
|
4
|
+
export function loadKeypair(walletPath) {
|
|
5
|
+
const resolvedPath = expandHome(walletPath);
|
|
6
|
+
let secret;
|
|
7
|
+
try {
|
|
8
|
+
secret = new Uint8Array(JSON.parse(readFileSync(resolvedPath, "utf8")));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new Error(`Could not load wallet keypair from ${resolvedPath}. ` +
|
|
12
|
+
`Run 'aura config init' or pass --wallet /path/to/id.json.`);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return Keypair.fromSecretKey(secret);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new Error(`Wallet file at ${resolvedPath} is not a valid Solana keypair JSON array.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/core/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,WAAW,CAAC,UAAkB;IAC5C,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAE5C,IAAI,MAAkB,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,UAAU,CACrB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAa,CAC3D,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,sCAAsC,YAAY,IAAI;YACpD,2DAA2D,CAC9D,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,kBAAkB,YAAY,4CAA4C,CAC3E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/ika.d.ts
CHANGED
|
@@ -40,15 +40,6 @@ export declare function encryptU64(value: number | bigint, authorized: PublicKey
|
|
|
40
40
|
* Returns one pubkey per input value in the same order.
|
|
41
41
|
*/
|
|
42
42
|
export declare function encryptU64Batch(values: (number | bigint)[], authorized: PublicKey, grpcUrl?: string): Promise<PublicKey[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Encrypts an EUint64Vector input through the Ika Encrypt gRPC service.
|
|
45
|
-
*
|
|
46
|
-
* Arithmetic vectors are exactly 8,192 bytes. Values are written into leading
|
|
47
|
-
* u64 lanes and the remaining lanes are zero-filled. Passing an empty values
|
|
48
|
-
* list creates a verified zero vector, which is useful as a pre-allocated graph
|
|
49
|
-
* output account.
|
|
50
|
-
*/
|
|
51
|
-
export declare function encryptU64Vector(values: (number | bigint)[], authorized: PublicKey, grpcUrl?: string): Promise<PublicKey>;
|
|
52
43
|
/**
|
|
53
44
|
* Reads a decrypted ciphertext value from the Encrypt network.
|
|
54
45
|
*
|
package/dist/ika.js
CHANGED
|
@@ -17,10 +17,6 @@ export { ENCRYPT_GRPC_URL, IKA_GRPC_URL };
|
|
|
17
17
|
* FHE type for u64 values — matches `ENCRYPT_FHE_UINT64` in the Rust program.
|
|
18
18
|
*/
|
|
19
19
|
const FHE_TYPE_UINT64 = 4;
|
|
20
|
-
/**
|
|
21
|
-
* FHE type for EUint64Vector values — matches `ENCRYPT_FHE_VECTOR_U64`.
|
|
22
|
-
*/
|
|
23
|
-
const FHE_TYPE_UINT64_VECTOR = 35;
|
|
24
20
|
const U64_MAX = (1n << 64n) - 1n;
|
|
25
21
|
/**
|
|
26
22
|
* The 32-byte network encryption public key used by the pre-alpha Encrypt service.
|
|
@@ -113,50 +109,6 @@ export async function encryptU64Batch(values, authorized, grpcUrl = ENCRYPT_GRPC
|
|
|
113
109
|
client.close();
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Encrypts an EUint64Vector input through the Ika Encrypt gRPC service.
|
|
118
|
-
*
|
|
119
|
-
* Arithmetic vectors are exactly 8,192 bytes. Values are written into leading
|
|
120
|
-
* u64 lanes and the remaining lanes are zero-filled. Passing an empty values
|
|
121
|
-
* list creates a verified zero vector, which is useful as a pre-allocated graph
|
|
122
|
-
* output account.
|
|
123
|
-
*/
|
|
124
|
-
export async function encryptU64Vector(values, authorized, grpcUrl = ENCRYPT_GRPC_URL) {
|
|
125
|
-
if (values.length * 8 > 8192) {
|
|
126
|
-
throw new Error("encryptU64Vector values exceed the 8,192-byte EUint64Vector payload");
|
|
127
|
-
}
|
|
128
|
-
const client = createEncryptClient(grpcUrl);
|
|
129
|
-
try {
|
|
130
|
-
const ciphertextBytes = Buffer.alloc(8192);
|
|
131
|
-
values.forEach((value, index) => {
|
|
132
|
-
const bigintValue = BigInt(value);
|
|
133
|
-
if (bigintValue < 0n || bigintValue > U64_MAX) {
|
|
134
|
-
throw new Error("encryptU64Vector values must fit in u64");
|
|
135
|
-
}
|
|
136
|
-
ciphertextBytes.writeBigUInt64LE(bigintValue, index * 8);
|
|
137
|
-
});
|
|
138
|
-
const result = await client.createInput({
|
|
139
|
-
chain: EncryptChain.Solana,
|
|
140
|
-
inputs: [
|
|
141
|
-
{
|
|
142
|
-
ciphertextBytes,
|
|
143
|
-
fheType: FHE_TYPE_UINT64_VECTOR,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
proof: Buffer.alloc(0),
|
|
147
|
-
authorized: authorized.toBuffer(),
|
|
148
|
-
networkEncryptionPublicKey: ENCRYPT_NETWORK_KEY,
|
|
149
|
-
});
|
|
150
|
-
const id = result.ciphertextIdentifiers[0];
|
|
151
|
-
if (!id || id.length !== 32) {
|
|
152
|
-
throw new Error("Encrypt service returned an invalid vector ciphertext identifier");
|
|
153
|
-
}
|
|
154
|
-
return new PublicKey(id);
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
157
|
-
client.close();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
112
|
/**
|
|
161
113
|
* Reads a decrypted ciphertext value from the Encrypt network.
|
|
162
114
|
*
|
package/dist/ika.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ika.js","sourceRoot":"","sources":["../src/ika.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,IAAI,YAAY,EACrB,yBAAyB,IAAI,gBAAgB,GAC9C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,YAAY,GAAG,yCAAyC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B
|
|
1
|
+
{"version":3,"file":"ika.js","sourceRoot":"","sources":["../src/ika.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,IAAI,YAAY,EACrB,yBAAyB,IAAI,gBAAgB,GAC9C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,GAEhB,MAA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AW,EACX,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,WAAW,EACX,cAAc,CACf,CAAC;QAEF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,93 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { Command } from "commander";
|
|
2
|
-
import chalk from "chalk";
|
|
3
3
|
import { registerConfidentialCommands } from "./commands/confidential.js";
|
|
4
4
|
import { registerConfigCommands } from "./commands/config.js";
|
|
5
5
|
import { registerDashboardCommand } from "./commands/dashboard.js";
|
|
6
6
|
import { registerDwalletCommands } from "./commands/dwallet.js";
|
|
7
7
|
import { registerExecutionCommands } from "./commands/execution.js";
|
|
8
8
|
import { registerFeatureCommands } from "./commands/features.js";
|
|
9
|
+
import { registerGeneratedCommands } from "./commands/generated.js";
|
|
9
10
|
import { registerGovernanceCommands } from "./commands/governance.js";
|
|
10
|
-
import { registerInstructionCommands } from "./commands/
|
|
11
|
+
import { registerInstructionCommands } from "./commands/instruction.js";
|
|
11
12
|
import { registerPdaCommands } from "./commands/pda.js";
|
|
12
13
|
import { registerTreasuryCommands } from "./commands/treasury.js";
|
|
13
|
-
import {
|
|
14
|
+
import { resolveGlobalConfig } from "./core/context.js";
|
|
15
|
+
import { renderError } from "./core/errors.js";
|
|
16
|
+
import { checkWalletFileHygiene } from "./core/security.js";
|
|
17
|
+
import { ACTIVE_DEVELOPMENT_WARNING, printWarn } from "./ui/output.js";
|
|
18
|
+
import { block, setColorEnabled } from "./ui/theme.js";
|
|
19
|
+
// Read the version from package.json at runtime so it can never drift from the
|
|
20
|
+
// published package. Resolves to the package root from both dist/ and src/.
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
const VERSION = require("../package.json").version;
|
|
14
23
|
export function createProgram() {
|
|
15
24
|
const program = new Command();
|
|
16
25
|
program
|
|
17
26
|
.name("aura")
|
|
18
|
-
.description("Production-grade CLI for the AURA autonomous treasury program")
|
|
19
|
-
.version("
|
|
27
|
+
.description("Production-grade CLI for the AURA autonomous treasury program on Solana")
|
|
28
|
+
.version(VERSION, "-v, --version", "print the CLI version")
|
|
20
29
|
.showHelpAfterError()
|
|
21
30
|
.showSuggestionAfterError()
|
|
22
|
-
.option("--rpc-url <url>", "override RPC endpoint")
|
|
23
|
-
.option("--wallet <path>", "override keypair file path")
|
|
24
|
-
.option("--program-id <id>", "override AURA program ID")
|
|
31
|
+
.option("--rpc-url <url>", "override the RPC endpoint")
|
|
32
|
+
.option("--wallet <path>", "override the keypair file path")
|
|
33
|
+
.option("--program-id <id>", "override the AURA program ID")
|
|
25
34
|
.option("--cluster <name>", "cluster label for display")
|
|
26
35
|
.option("--json", "output machine-readable JSON")
|
|
27
36
|
.option("--quiet", "suppress non-error terminal output")
|
|
28
|
-
.option("--dry-run", "build and
|
|
29
|
-
.
|
|
37
|
+
.option("--dry-run", "build and preview the transaction without sending")
|
|
38
|
+
.option("-y, --yes", "skip confirmation prompts (non-interactive)")
|
|
39
|
+
.option("--no-simulate", "skip the preflight simulation before sending")
|
|
40
|
+
.option("--no-color", "disable colored output")
|
|
41
|
+
.option("--compute-units <n>", "override the compute-unit limit", (value) => Number(value))
|
|
42
|
+
.addHelpText("afterAll", () => `\n${block("WARNING", "warn")} ${ACTIVE_DEVELOPMENT_WARNING}`);
|
|
43
|
+
// Best-effort keypair hygiene warning before any command runs.
|
|
44
|
+
program.hook("preAction", (thisCommand) => {
|
|
45
|
+
const opts = thisCommand.opts();
|
|
46
|
+
if (opts.json === true || opts.quiet === true) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const { config } = resolveGlobalConfig(thisCommand);
|
|
51
|
+
const hygiene = checkWalletFileHygiene(config.walletPath);
|
|
52
|
+
if (hygiene.warning) {
|
|
53
|
+
printWarn({ json: false, quiet: false }, hygiene.warning);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Never let a preflight warning block a command.
|
|
58
|
+
}
|
|
59
|
+
});
|
|
30
60
|
registerConfigCommands(program);
|
|
31
61
|
registerTreasuryCommands(program);
|
|
32
62
|
registerDwalletCommands(program);
|
|
33
63
|
registerConfidentialCommands(program);
|
|
34
64
|
registerExecutionCommands(program);
|
|
35
|
-
registerFeatureCommands(program);
|
|
36
|
-
registerInstructionCommands(program);
|
|
37
65
|
registerGovernanceCommands(program);
|
|
66
|
+
registerFeatureCommands(program);
|
|
38
67
|
registerPdaCommands(program);
|
|
39
68
|
registerDashboardCommand(program);
|
|
69
|
+
registerInstructionCommands(program);
|
|
70
|
+
// Generated per-domain instruction commands provide complete coverage of
|
|
71
|
+
// every program instruction. Registered last so they merge into the
|
|
72
|
+
// ergonomic command groups above without clobbering their friendly verbs.
|
|
73
|
+
registerGeneratedCommands(program);
|
|
40
74
|
return program;
|
|
41
75
|
}
|
|
76
|
+
/** Disables color early (before help/preview render) for --no-color / --json / NO_COLOR. */
|
|
77
|
+
function configureColor(argv) {
|
|
78
|
+
if (argv.includes("--no-color") ||
|
|
79
|
+
argv.includes("--json") ||
|
|
80
|
+
process.env.NO_COLOR !== undefined) {
|
|
81
|
+
setColorEnabled(false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
42
84
|
export async function main(argv = process.argv) {
|
|
85
|
+
configureColor(argv);
|
|
43
86
|
try {
|
|
44
87
|
await createProgram().parseAsync(argv);
|
|
45
88
|
}
|
|
46
89
|
catch (error) {
|
|
47
|
-
|
|
90
|
+
renderError(error);
|
|
48
91
|
process.exitCode = 1;
|
|
49
92
|
}
|
|
50
93
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3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,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function parseChain(input: string | number): number;
|
|
2
|
+
export declare function formatChain(code: number): string;
|
|
3
|
+
export declare function parseTransactionType(input: string | number): number;
|
|
4
|
+
export declare function formatTransactionType(code: number): string;
|
|
5
|
+
export declare function formatProposalStatus(code: number): string;
|
|
6
|
+
export declare function formatViolation(code: number): string;
|
|
7
|
+
export declare function chainNameForDigest(code: number): string;
|
|
8
|
+
export declare function transactionTypeNameForDigest(code: number): string;
|
|
9
|
+
export declare function listChainChoices(): {
|
|
10
|
+
name: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function listTransactionTypeChoices(): {
|
|
14
|
+
name: string;
|
|
15
|
+
value: number;
|
|
16
|
+
}[];
|