sigild 0.0.13 → 0.0.14
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 +50 -3
- package/THREAT_MODEL.md +2 -0
- package/dist/src/audit/index.d.ts +1 -1
- package/dist/src/audit/index.d.ts.map +1 -1
- package/dist/src/audit/index.js.map +1 -1
- package/dist/src/audit/log.d.ts +15 -0
- package/dist/src/audit/log.d.ts.map +1 -1
- package/dist/src/audit/log.js +2 -0
- package/dist/src/audit/log.js.map +1 -1
- package/dist/src/bin/sigil-mcp.js +68 -7
- package/dist/src/bin/sigil-mcp.js.map +1 -1
- package/dist/src/cli/paths.d.ts +2 -0
- package/dist/src/cli/paths.d.ts.map +1 -1
- package/dist/src/cli/paths.js +1 -0
- package/dist/src/cli/paths.js.map +1 -1
- package/dist/src/confirm/config.d.ts +19 -0
- package/dist/src/confirm/config.d.ts.map +1 -1
- package/dist/src/confirm/config.js +48 -0
- package/dist/src/confirm/config.js.map +1 -1
- package/dist/src/confirm/index.d.ts +1 -1
- package/dist/src/confirm/index.d.ts.map +1 -1
- package/dist/src/confirm/index.js.map +1 -1
- package/dist/src/daemon/handles.d.ts +6 -0
- package/dist/src/daemon/handles.d.ts.map +1 -1
- package/dist/src/daemon/handles.js +11 -0
- package/dist/src/daemon/handles.js.map +1 -1
- package/dist/src/daemon/index.d.ts +1 -1
- package/dist/src/daemon/index.d.ts.map +1 -1
- package/dist/src/daemon/index.js.map +1 -1
- package/dist/src/daemon/methods.d.ts +21 -0
- package/dist/src/daemon/methods.d.ts.map +1 -1
- package/dist/src/daemon/methods.js +179 -27
- package/dist/src/daemon/methods.js.map +1 -1
- package/dist/src/eth/abi.d.ts +82 -0
- package/dist/src/eth/abi.d.ts.map +1 -0
- package/dist/src/eth/abi.js +328 -0
- package/dist/src/eth/abi.js.map +1 -0
- package/dist/src/eth/index.d.ts +1 -0
- package/dist/src/eth/index.d.ts.map +1 -1
- package/dist/src/eth/index.js +1 -0
- package/dist/src/eth/index.js.map +1 -1
- package/dist/src/mcp/parent-watchdog.d.ts +31 -0
- package/dist/src/mcp/parent-watchdog.d.ts.map +1 -0
- package/dist/src/mcp/parent-watchdog.js +35 -0
- package/dist/src/mcp/parent-watchdog.js.map +1 -0
- package/dist/src/mcp/server.d.ts +7 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +13 -2
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools.d.ts.map +1 -1
- package/dist/src/mcp/tools.js +21 -1
- package/dist/src/mcp/tools.js.map +1 -1
- package/dist/src/policy/ledger.d.ts +1 -0
- package/dist/src/policy/ledger.d.ts.map +1 -1
- package/dist/src/policy/ledger.js +70 -44
- package/dist/src/policy/ledger.js.map +1 -1
- package/dist/src/policy/loader.d.ts.map +1 -1
- package/dist/src/policy/loader.js +9 -0
- package/dist/src/policy/loader.js.map +1 -1
- package/dist/src/policy/template.d.ts +2 -2
- package/dist/src/policy/template.d.ts.map +1 -1
- package/dist/src/policy/template.js +20 -0
- package/dist/src/policy/template.js.map +1 -1
- package/dist/src/policy/types.d.ts +16 -0
- package/dist/src/policy/types.d.ts.map +1 -1
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/preview/abi-dir.d.ts +50 -0
- package/dist/src/preview/abi-dir.d.ts.map +1 -0
- package/dist/src/preview/abi-dir.js +175 -0
- package/dist/src/preview/abi-dir.js.map +1 -0
- package/dist/src/preview/decode.d.ts +26 -0
- package/dist/src/preview/decode.d.ts.map +1 -0
- package/dist/src/preview/decode.js +110 -0
- package/dist/src/preview/decode.js.map +1 -0
- package/dist/src/preview/format.d.ts +45 -0
- package/dist/src/preview/format.d.ts.map +1 -0
- package/dist/src/preview/format.js +222 -0
- package/dist/src/preview/format.js.map +1 -0
- package/dist/src/preview/index.d.ts +60 -0
- package/dist/src/preview/index.d.ts.map +1 -0
- package/dist/src/preview/index.js +163 -0
- package/dist/src/preview/index.js.map +1 -0
- package/dist/src/preview/known.d.ts +74 -0
- package/dist/src/preview/known.d.ts.map +1 -0
- package/dist/src/preview/known.js +425 -0
- package/dist/src/preview/known.js.map +1 -0
- package/dist/src/preview/simulate.d.ts +156 -0
- package/dist/src/preview/simulate.d.ts.map +1 -0
- package/dist/src/preview/simulate.js +768 -0
- package/dist/src/preview/simulate.js.map +1 -0
- package/dist/src/preview/simulators.d.ts +39 -0
- package/dist/src/preview/simulators.d.ts.map +1 -0
- package/dist/src/preview/simulators.js +71 -0
- package/dist/src/preview/simulators.js.map +1 -0
- package/dist/src/preview/trust.d.ts +49 -0
- package/dist/src/preview/trust.d.ts.map +1 -0
- package/dist/src/preview/trust.js +279 -0
- package/dist/src/preview/trust.js.map +1 -0
- package/dist/src/preview/types.d.ts +69 -0
- package/dist/src/preview/types.d.ts.map +1 -0
- package/dist/src/preview/types.js +11 -0
- package/dist/src/preview/types.js.map +1 -0
- package/dist/src/preview/units.d.ts +75 -0
- package/dist/src/preview/units.d.ts.map +1 -0
- package/dist/src/preview/units.js +228 -0
- package/dist/src/preview/units.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { dirname, join } from 'node:path';
|
|
|
3
3
|
import { withFileLock, writeAllSync } from '../fs/index.js';
|
|
4
4
|
import { checkWindowCaps, DAY_MS } from './window.js';
|
|
5
5
|
export class SpendLedgerError extends Error {
|
|
6
|
+
cause;
|
|
6
7
|
constructor(message) {
|
|
7
8
|
super(message);
|
|
8
9
|
this.name = 'SpendLedgerError';
|
|
@@ -103,60 +104,85 @@ export class FileSpendLedger {
|
|
|
103
104
|
}
|
|
104
105
|
spent(handle, asset, windowMs) {
|
|
105
106
|
const path = this.pathFor(handle);
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
return ledgerIo(path, () => {
|
|
108
|
+
mkdirSync(this.#dir, { recursive: true, mode: 0o700 });
|
|
109
|
+
return withFileLock(path, () => sumWindow(readEntries(path).entries, asset, windowMs, this.#now()));
|
|
110
|
+
});
|
|
108
111
|
}
|
|
109
112
|
reserve(handle, asset, amount, caps) {
|
|
110
113
|
if (amount < 0n)
|
|
111
114
|
return NEGATIVE_REASON;
|
|
112
|
-
this.#ensureDir();
|
|
113
115
|
const path = this.pathFor(handle);
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
116
|
+
return ledgerIo(path, () => {
|
|
117
|
+
this.#ensureDir();
|
|
118
|
+
return withFileLock(path, () => {
|
|
119
|
+
const { entries, endsWithNewline, size } = readEntries(path);
|
|
120
|
+
const now = this.#now();
|
|
121
|
+
const reason = checkWindowCaps(caps, amount, (w) => sumWindow(entries, asset, w, now), asset);
|
|
122
|
+
if (reason !== null)
|
|
123
|
+
return reason;
|
|
124
|
+
if (amount === 0n)
|
|
125
|
+
return null;
|
|
126
|
+
const entry = { ts: now, asset, amount };
|
|
127
|
+
const stale = entries.filter((e) => e.ts <= now - DAY_MS).length;
|
|
128
|
+
if (stale > FileSpendLedger.COMPACT_AFTER) {
|
|
129
|
+
const live = entries.filter((e) => e.ts > now - DAY_MS);
|
|
130
|
+
live.push(entry);
|
|
131
|
+
const tmp = `${path}.tmp`;
|
|
132
|
+
const fd = openSync(tmp, 'w', 0o600);
|
|
133
|
+
try {
|
|
134
|
+
writeAllSync(fd, live.map(serialize).join(''));
|
|
135
|
+
fsyncSync(fd);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
closeSync(fd);
|
|
139
|
+
}
|
|
140
|
+
renameSync(tmp, path);
|
|
141
|
+
fsyncDirOrFail(dirname(path));
|
|
135
142
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
else {
|
|
144
|
+
const fd = openSync(path, 'a', 0o600);
|
|
145
|
+
try {
|
|
146
|
+
// Never merge with a torn fragment: start on a fresh line.
|
|
147
|
+
writeAllSync(fd, (size > 0 && !endsWithNewline ? '\n' : '') + serialize(entry));
|
|
148
|
+
fsyncSync(fd);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
closeSync(fd);
|
|
152
|
+
}
|
|
153
|
+
// The directory entry needs its own fsync, or a power cut right after
|
|
154
|
+
// a signature can lose a brand-new ledger and hand back a fresh
|
|
155
|
+
// allowance on reboot. Done on every append rather than only the
|
|
156
|
+
// first: if a previous attempt's sync failed, the file's mere
|
|
157
|
+
// existence proves nothing about durability.
|
|
158
|
+
fsyncDirOrFail(dirname(path));
|
|
145
159
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
// The directory entry needs its own fsync, or a power cut right after
|
|
150
|
-
// a signature can lose a brand-new ledger and hand back a fresh
|
|
151
|
-
// allowance on reboot. Done on every append rather than only the
|
|
152
|
-
// first: if a previous attempt's sync failed, the file's mere
|
|
153
|
-
// existence proves nothing about durability.
|
|
154
|
-
fsyncDirOrFail(dirname(path));
|
|
155
|
-
}
|
|
156
|
-
return null;
|
|
160
|
+
return null;
|
|
161
|
+
});
|
|
157
162
|
});
|
|
158
163
|
}
|
|
159
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Run a ledger operation, turning any I/O failure — read, open, write,
|
|
167
|
+
* fsync, rename, lock — into a SpendLedgerError naming the file, so the
|
|
168
|
+
* sign path records an audited deny rather than surfacing a bare
|
|
169
|
+
* filesystem error (#91). Errors that are already SpendLedgerError (parse
|
|
170
|
+
* failures, durability failures) pass through unchanged. Signing stops
|
|
171
|
+
* either way; this only makes the audit log say why.
|
|
172
|
+
*/
|
|
173
|
+
function ledgerIo(path, fn) {
|
|
174
|
+
try {
|
|
175
|
+
return fn();
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
if (err instanceof SpendLedgerError)
|
|
179
|
+
throw err;
|
|
180
|
+
const e = err;
|
|
181
|
+
const wrapped = new SpendLedgerError(`spend ledger ${path}: I/O failure (${e.code ?? e.name}: ${e.message}) — refusing to sign`);
|
|
182
|
+
wrapped.cause = err; // keep the stack and errno fields for diagnostics
|
|
183
|
+
throw wrapped;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
160
186
|
/**
|
|
161
187
|
* Test-only seam: replaces the directory fsync so a test can make it fail.
|
|
162
188
|
* Never set by production code.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/policy/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,EAAmC,MAAM,aAAa,CAAC;AA8BvF,MAAM,OAAO,gBAAiB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/policy/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,EAAmC,MAAM,aAAa,CAAC;AA8BvF,MAAM,OAAO,gBAAiB,SA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ChE,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACxE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/policy/loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAmB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAM/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/policy/loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAmB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAM/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAoLlD;AAmCD;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAmBzD;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,cAAc;;gBAEjD,SAAS,EAAE,MAAM;IAG7B,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAehC"}
|
|
@@ -37,6 +37,11 @@ export function parsePolicy(source) {
|
|
|
37
37
|
const requireConfirmAboveLamports = parseOptionalDec(raw['require_confirm_above_lamports'], 'require_confirm_above_lamports');
|
|
38
38
|
// Rolling-window caps are mode-independent too.
|
|
39
39
|
const windows = parseWindowCaps(raw);
|
|
40
|
+
// As are the transaction-preview gates.
|
|
41
|
+
const previewGates = {
|
|
42
|
+
requireSimulation: asBool(raw['require_simulation'], 'require_simulation', false),
|
|
43
|
+
signOnRevert: asBool(raw['sign_on_revert'], 'sign_on_revert', false),
|
|
44
|
+
};
|
|
40
45
|
if (mode === 'permissive') {
|
|
41
46
|
return {
|
|
42
47
|
mode: 'permissive',
|
|
@@ -52,6 +57,7 @@ export function parsePolicy(source) {
|
|
|
52
57
|
svmMaxLamports: 0n,
|
|
53
58
|
typedDataVerifyingContracts: [],
|
|
54
59
|
typedDataPrimaryTypes: [],
|
|
60
|
+
...previewGates,
|
|
55
61
|
...(requireConfirmAboveWei !== undefined ? { requireConfirmAboveWei } : {}),
|
|
56
62
|
...(requireConfirmAboveLamports !== undefined ? { requireConfirmAboveLamports } : {}),
|
|
57
63
|
...windows,
|
|
@@ -141,6 +147,7 @@ export function parsePolicy(source) {
|
|
|
141
147
|
svmMaxLamports,
|
|
142
148
|
typedDataVerifyingContracts,
|
|
143
149
|
typedDataPrimaryTypes,
|
|
150
|
+
...previewGates,
|
|
144
151
|
...(requireConfirmAboveWei !== undefined ? { requireConfirmAboveWei } : {}),
|
|
145
152
|
...(requireConfirmAboveLamports !== undefined ? { requireConfirmAboveLamports } : {}),
|
|
146
153
|
...windows,
|
|
@@ -189,6 +196,8 @@ export function permissivePolicyResolver() {
|
|
|
189
196
|
svmMaxLamports: 0n,
|
|
190
197
|
typedDataVerifyingContracts: [],
|
|
191
198
|
typedDataPrimaryTypes: [],
|
|
199
|
+
requireSimulation: false,
|
|
200
|
+
signOnRevert: false,
|
|
192
201
|
};
|
|
193
202
|
return { resolve: () => policy };
|
|
194
203
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/policy/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,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AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CACvB,kFAAkF,OAAO,CAAC,EAAE,CAC7F,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,eAAe,CACvB,8DAA8D,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CACnF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAU,EAAE,IAAY;IAChD,OAAO,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,CAAU,EAAE,IAAY;IAChD,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,eAAe,CACvB,UAAU,IAAI,sDAAsD,OAAO,CAAC,EAAE,CAC/E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,eAAe,CACvB,UAAU,IAAI,0CAA0C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* than serialized so we can include explanatory comments — TOML serializers
|
|
4
4
|
* generally strip those.
|
|
5
5
|
*/
|
|
6
|
-
export declare const PERMISSIVE_TEMPLATE = "# sigil policy file \u2014 permissive mode (default)\n#\n# This portal will sign anything the agent asks for. Your private key is\n# still encrypted at rest and never enters Claude's context, but signing\n# authority is unbounded.\n#\n# To restrict what this portal can sign, run:\n#\n# sigil portal remove <handle>\n# sigil portal add <handle> --key-file <path> --strict\n#\n# ...and edit the resulting policy file. Or just change \"permissive\" below\n# to \"strict\" and add the rules in the commented template at:\n# https://github.com/cdrn/sigil#policy-engine\n\nmode = \"permissive\"\n\n# Optional rolling-window caps on native value signed by this portal \u2014 the\n# one restriction that still makes sense on a permissive portal (\"a bot with\n# an allowance\"). Decimal strings in wei; either or both may be set; an\n# hourly cap must not exceed the daily one. Only tx.value is counted (token\n# transfers are calldata) \u2014 see the README.\n# max_value_per_hour_wei = \"100000000000000000\" # 0.1 ETH / hour\n# max_value_per_day_wei = \"1000000000000000000\" # 1 ETH / day\n#\n# Same for native SOL transfers, in lamports (1 SOL = 1000000000):\n# svm_max_lamports_per_hour = \"100000000\"\n# svm_max_lamports_per_day = \"1000000000\"\n";
|
|
7
|
-
export declare const STRICT_TEMPLATE = "# sigil policy file \u2014 strict mode\n#\n# Every sign request is checked against the rules below before the key is\n# used. Edit the values to fit your portal. Anything you leave at the\n# default-zero/empty state will deny.\n\nmode = \"strict\"\n\n# Allowed chain IDs (decimal). At least one is required.\n# 1 = ethereum mainnet\n# 8453 = base\n# 42161 = arbitrum one\n# 10 = optimism\n# 11155111 = sepolia testnet\nchain_ids = [1]\n\n# Allowed destination addresses (lowercase 0x-prefixed). Empty = no tx allowed.\n# Example:\n# allow_to = [\"0x000000000000000000000000000000000000dead\"]\nallow_to = []\n\n# Per-tx value cap in wei. Default 0 = no ETH sends allowed at all.\n# 0.1 ether = \"100000000000000000\"\n# 1 ether = \"1000000000000000000\"\n# Quoted because uint256 doesn't fit in a TOML integer.\nmax_value_wei = \"0\"\n\n# 4-byte function selectors that are callable. Empty = pure ETH sends only.\n# Common selectors:\n# \"0xa9059cbb\" ERC-20 transfer(address,uint256)\n# \"0x095ea7b3\" ERC-20 approve(address,uint256)\n# \"0x23b872dd\" ERC-20 transferFrom(address,address,uint256)\nallowed_selectors = []\n\n# Contract creation (deploys, to = null). Initcode is arbitrary code that no\n# allowlist can vet, so even when enabled every deploy still respects\n# max_value_wei and ALWAYS routes to the out-of-band confirm gate \u2014 a\n# [confirm.ntfy] block in ~/.sigil/config.toml is required, otherwise\n# sigil-mcp refuses to start.\nallow_contract_creation = false\n\n# EIP-191 personal_sign \u2014 typically safe (used by Sign-In With Ethereum and\n# similar login flows). Set true to permit.\nallow_message_signing = false\n\n# EIP-712 typed data \u2014 CAN authorize off-chain financial actions (Permit,\n# OpenSea orders, gasless approvals). Treat with the same care as signing\n# transactions. Set true to permit.\nallow_typed_data = false\n\n# When allow_typed_data = true, these refine what may be signed. Each empty\n# list means \"no restriction on that axis\". Independently, a domain that\n# must carry a chainId naming one of chain_ids above (chain-less domains are\n# refused in strict mode \u2014 they can't be checked).\n# typed_data_verifying_contracts \u2014 lowercase 0x addresses the domain's\n# verifyingContract must be one of (e.g. Permit2, an exchange).\n# typed_data_primary_types \u2014 primaryType names, e.g. [\"Permit\", \"Order\"].\ntyped_data_verifying_contracts = []\ntyped_data_primary_types = []\n\n# Optional rolling-window caps on tx.value (mode-independent). Decimal\n# strings in wei; hourly must not exceed daily. Enforced against a\n# per-portal ledger in ~/.sigil/state; see \"sigil policy spend <handle>\".\n# max_value_per_hour_wei = \"100000000000000000\" # 0.1 ETH / hour\n# max_value_per_day_wei = \"1000000000000000000\" # 1 ETH / day\n\n# Optional: above this wei amount, sigil pushes a notification to your\n# phone and waits for an explicit approve/deny tap before signing. Must be\n# strictly less than max_value_wei. Requires a [confirm.ntfy] block in\n# ~/.sigil/config.toml; without one, sigil-mcp refuses to start.\n# Example: confirm anything above 0.01 ETH.\n# require_confirm_above_wei = \"10000000000000000\"\n\n# --- Solana (SVM) ----------------------------------------------------------\n# The same key also controls a Solana (ed25519) address \u2014 see its base58 in\n# \"sigil portal list\". These rules gate signing with it.\n\n# Sign arbitrary off-chain ed25519 messages (e.g. Sign-In With Solana).\nallow_svm_message_signing = false\n\n# Allowed recipients for native SOL transfers (base58). Empty = none.\n# sigil only decodes System-Program SOL transfers offline; any Solana tx it\n# can't fully decode (SPL tokens, program calls, address-lookup-table\n# accounts) is routed to the confirm gate instead of auto-allowed.\n# Example: svm_allow_to = [\"So11111111111111111111111111111111111111112\"]\nsvm_allow_to = []\n\n# Per-tx cap on total transferred lamports (1 SOL = 1000000000). Default 0 =\n# no SOL transfers allowed. Quoted to stay clear of TOML int limits.\nsvm_max_lamports = \"0\"\n\n# Optional: above this lamport total \u2014 OR for any tx sigil can't fully decode\n# \u2014 push a confirm to your phone. Must be strictly less than svm_max_lamports.\n# Example: confirm anything above 0.1 SOL.\n# require_confirm_above_lamports = \"100000000\"\n\n# Optional rolling-window caps on decoded native SOL transfers, in lamports.\n# svm_max_lamports_per_hour = \"100000000\"\n# svm_max_lamports_per_day = \"1000000000\"\n";
|
|
6
|
+
export declare const PERMISSIVE_TEMPLATE = "# sigil policy file \u2014 permissive mode (default)\n#\n# This portal will sign anything the agent asks for. Your private key is\n# still encrypted at rest and never enters Claude's context, but signing\n# authority is unbounded.\n#\n# To restrict what this portal can sign, run:\n#\n# sigil portal remove <handle>\n# sigil portal add <handle> --key-file <path> --strict\n#\n# ...and edit the resulting policy file. Or just change \"permissive\" below\n# to \"strict\" and add the rules in the commented template at:\n# https://github.com/cdrn/sigil#policy-engine\n\nmode = \"permissive\"\n\n# Optional rolling-window caps on native value signed by this portal \u2014 the\n# one restriction that still makes sense on a permissive portal (\"a bot with\n# an allowance\"). Decimal strings in wei; either or both may be set; an\n# hourly cap must not exceed the daily one. Only tx.value is counted (token\n# transfers are calldata) \u2014 see the README.\n# max_value_per_hour_wei = \"100000000000000000\" # 0.1 ETH / hour\n# max_value_per_day_wei = \"1000000000000000000\" # 1 ETH / day\n#\n# Same for native SOL transfers, in lamports (1 SOL = 1000000000):\n# svm_max_lamports_per_hour = \"100000000\"\n# svm_max_lamports_per_day = \"1000000000\"\n\n# Transaction preview gates (see \"Transaction preview\" in the README). Both act\n# on the dry-run, which needs a [simulate.rpc] entry for the chain (or the [rpc]\n# proxy upstream serving it) in ~/.sigil/config.toml.\n# require_simulation: deny any EVM tx that could not be simulated (no RPC for\n# its chain, node down, timeout).\n# sign_on_revert: by default a tx whose simulation reverts is denied with the\n# revert reason; set true to sign it anyway.\n# require_simulation = false\n# sign_on_revert = false\n";
|
|
7
|
+
export declare const STRICT_TEMPLATE = "# sigil policy file \u2014 strict mode\n#\n# Every sign request is checked against the rules below before the key is\n# used. Edit the values to fit your portal. Anything you leave at the\n# default-zero/empty state will deny.\n\nmode = \"strict\"\n\n# Allowed chain IDs (decimal). At least one is required.\n# 1 = ethereum mainnet\n# 8453 = base\n# 42161 = arbitrum one\n# 10 = optimism\n# 11155111 = sepolia testnet\nchain_ids = [1]\n\n# Allowed destination addresses (lowercase 0x-prefixed). Empty = no tx allowed.\n# Example:\n# allow_to = [\"0x000000000000000000000000000000000000dead\"]\nallow_to = []\n\n# Per-tx value cap in wei. Default 0 = no ETH sends allowed at all.\n# 0.1 ether = \"100000000000000000\"\n# 1 ether = \"1000000000000000000\"\n# Quoted because uint256 doesn't fit in a TOML integer.\nmax_value_wei = \"0\"\n\n# 4-byte function selectors that are callable. Empty = pure ETH sends only.\n# Common selectors:\n# \"0xa9059cbb\" ERC-20 transfer(address,uint256)\n# \"0x095ea7b3\" ERC-20 approve(address,uint256)\n# \"0x23b872dd\" ERC-20 transferFrom(address,address,uint256)\nallowed_selectors = []\n\n# Contract creation (deploys, to = null). Initcode is arbitrary code that no\n# allowlist can vet, so even when enabled every deploy still respects\n# max_value_wei and ALWAYS routes to the out-of-band confirm gate \u2014 a\n# [confirm.ntfy] block in ~/.sigil/config.toml is required, otherwise\n# sigil-mcp refuses to start.\nallow_contract_creation = false\n\n# EIP-191 personal_sign \u2014 typically safe (used by Sign-In With Ethereum and\n# similar login flows). Set true to permit.\nallow_message_signing = false\n\n# EIP-712 typed data \u2014 CAN authorize off-chain financial actions (Permit,\n# OpenSea orders, gasless approvals). Treat with the same care as signing\n# transactions. Set true to permit.\nallow_typed_data = false\n\n# When allow_typed_data = true, these refine what may be signed. Each empty\n# list means \"no restriction on that axis\". Independently, a domain that\n# must carry a chainId naming one of chain_ids above (chain-less domains are\n# refused in strict mode \u2014 they can't be checked).\n# typed_data_verifying_contracts \u2014 lowercase 0x addresses the domain's\n# verifyingContract must be one of (e.g. Permit2, an exchange).\n# typed_data_primary_types \u2014 primaryType names, e.g. [\"Permit\", \"Order\"].\ntyped_data_verifying_contracts = []\ntyped_data_primary_types = []\n\n# Optional rolling-window caps on tx.value (mode-independent). Decimal\n# strings in wei; hourly must not exceed daily. Enforced against a\n# per-portal ledger in ~/.sigil/state; see \"sigil policy spend <handle>\".\n# max_value_per_hour_wei = \"100000000000000000\" # 0.1 ETH / hour\n# max_value_per_day_wei = \"1000000000000000000\" # 1 ETH / day\n\n# Optional: above this wei amount, sigil pushes a notification to your\n# phone and waits for an explicit approve/deny tap before signing. Must be\n# strictly less than max_value_wei. Requires a [confirm.ntfy] block in\n# ~/.sigil/config.toml; without one, sigil-mcp refuses to start.\n# Example: confirm anything above 0.01 ETH.\n# require_confirm_above_wei = \"10000000000000000\"\n\n# Transaction preview gates (see \"Transaction preview\" in the README). Both act\n# on the dry-run, which needs a [simulate.rpc] entry for the chain (or the [rpc]\n# proxy upstream serving it) in ~/.sigil/config.toml.\n# require_simulation: deny any EVM tx that could not be simulated (no RPC for\n# its chain, node down, timeout).\n# sign_on_revert: by default a tx whose simulation reverts is denied with the\n# revert reason; set true to sign it anyway.\n# require_simulation = false\n# sign_on_revert = false\n\n# --- Solana (SVM) ----------------------------------------------------------\n# The same key also controls a Solana (ed25519) address \u2014 see its base58 in\n# \"sigil portal list\". These rules gate signing with it.\n\n# Sign arbitrary off-chain ed25519 messages (e.g. Sign-In With Solana).\nallow_svm_message_signing = false\n\n# Allowed recipients for native SOL transfers (base58). Empty = none.\n# sigil only decodes System-Program SOL transfers offline; any Solana tx it\n# can't fully decode (SPL tokens, program calls, address-lookup-table\n# accounts) is routed to the confirm gate instead of auto-allowed.\n# Example: svm_allow_to = [\"So11111111111111111111111111111111111111112\"]\nsvm_allow_to = []\n\n# Per-tx cap on total transferred lamports (1 SOL = 1000000000). Default 0 =\n# no SOL transfers allowed. Quoted to stay clear of TOML int limits.\nsvm_max_lamports = \"0\"\n\n# Optional: above this lamport total \u2014 OR for any tx sigil can't fully decode\n# \u2014 push a confirm to your phone. Must be strictly less than svm_max_lamports.\n# Example: confirm anything above 0.1 SOL.\n# require_confirm_above_lamports = \"100000000\"\n\n# Optional rolling-window caps on decoded native SOL transfers, in lamports.\n# svm_max_lamports_per_hour = \"100000000\"\n# svm_max_lamports_per_day = \"1000000000\"\n";
|
|
8
8
|
export type PolicyMode = 'permissive' | 'strict';
|
|
9
9
|
export declare function policyTemplate(mode: PolicyMode): string;
|
|
10
10
|
//# sourceMappingURL=template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,mBAAmB,6vDAsC/B,CAAC;AAEF,eAAO,MAAM,eAAe,49JA6G3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEvD"}
|
|
@@ -31,6 +31,16 @@ mode = "permissive"
|
|
|
31
31
|
# Same for native SOL transfers, in lamports (1 SOL = 1000000000):
|
|
32
32
|
# svm_max_lamports_per_hour = "100000000"
|
|
33
33
|
# svm_max_lamports_per_day = "1000000000"
|
|
34
|
+
|
|
35
|
+
# Transaction preview gates (see "Transaction preview" in the README). Both act
|
|
36
|
+
# on the dry-run, which needs a [simulate.rpc] entry for the chain (or the [rpc]
|
|
37
|
+
# proxy upstream serving it) in ~/.sigil/config.toml.
|
|
38
|
+
# require_simulation: deny any EVM tx that could not be simulated (no RPC for
|
|
39
|
+
# its chain, node down, timeout).
|
|
40
|
+
# sign_on_revert: by default a tx whose simulation reverts is denied with the
|
|
41
|
+
# revert reason; set true to sign it anyway.
|
|
42
|
+
# require_simulation = false
|
|
43
|
+
# sign_on_revert = false
|
|
34
44
|
`;
|
|
35
45
|
export const STRICT_TEMPLATE = `# sigil policy file — strict mode
|
|
36
46
|
#
|
|
@@ -105,6 +115,16 @@ typed_data_primary_types = []
|
|
|
105
115
|
# Example: confirm anything above 0.01 ETH.
|
|
106
116
|
# require_confirm_above_wei = "10000000000000000"
|
|
107
117
|
|
|
118
|
+
# Transaction preview gates (see "Transaction preview" in the README). Both act
|
|
119
|
+
# on the dry-run, which needs a [simulate.rpc] entry for the chain (or the [rpc]
|
|
120
|
+
# proxy upstream serving it) in ~/.sigil/config.toml.
|
|
121
|
+
# require_simulation: deny any EVM tx that could not be simulated (no RPC for
|
|
122
|
+
# its chain, node down, timeout).
|
|
123
|
+
# sign_on_revert: by default a tx whose simulation reverts is denied with the
|
|
124
|
+
# revert reason; set true to sign it anyway.
|
|
125
|
+
# require_simulation = false
|
|
126
|
+
# sign_on_revert = false
|
|
127
|
+
|
|
108
128
|
# --- Solana (SVM) ----------------------------------------------------------
|
|
109
129
|
# The same key also controls a Solana (ed25519) address — see its base58 in
|
|
110
130
|
# "sigil portal list". These rules gate signing with it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/policy/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsClC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6G9B,CAAC;AAIF,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,OAAO,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,eAAe,CAAC;AACvE,CAAC"}
|
|
@@ -66,6 +66,22 @@ export interface Policy {
|
|
|
66
66
|
*/
|
|
67
67
|
typedDataVerifyingContracts: readonly string[];
|
|
68
68
|
typedDataPrimaryTypes: readonly string[];
|
|
69
|
+
/**
|
|
70
|
+
* Transaction-preview gates for EVM transactions. Mode-independent, like
|
|
71
|
+
* requireConfirmAboveWei, and both default false so a policy written
|
|
72
|
+
* before the preview existed behaves exactly as before.
|
|
73
|
+
* - requireSimulation: deny unless the tx was actually simulated — a
|
|
74
|
+
* chain with no simulation RPC configured, or a simulation that came
|
|
75
|
+
* back unavailable (node down, timeout), is a deny. Fail closed.
|
|
76
|
+
* - signOnRevert: when false, a tx whose simulation ran and reverted is
|
|
77
|
+
* denied with the decoded revert reason (it would fail on-chain and
|
|
78
|
+
* burn gas, or the agent built the wrong call). True signs anyway;
|
|
79
|
+
* the warning stays in the preview and the audit entry.
|
|
80
|
+
* Simulation is advisory input from the user's own RPC node, not proof:
|
|
81
|
+
* these gates deny on what the node says, they never allow on it.
|
|
82
|
+
*/
|
|
83
|
+
requireSimulation: boolean;
|
|
84
|
+
signOnRevert: boolean;
|
|
69
85
|
/** Allow signing arbitrary off-chain ed25519 messages with this key. */
|
|
70
86
|
allowSvmMessageSigning: boolean;
|
|
71
87
|
/** base58 recipient allowlist for native SOL transfers (strict). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9B,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,gEAAgE;IAChE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;;;;OAOG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;OASG;IACH,2BAA2B,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC9B,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,gEAAgE;IAChE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAA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E,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC7C;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,6EAA6E;IAC7E,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,0EAA0E;IAC1E,UAAU,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GACxB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAK7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/policy/types.ts"],"names":[],"mappings":"AA4JA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtB,KAAK,CAAW;IAClC,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type AbiType } from '../eth/abi.js';
|
|
2
|
+
/**
|
|
3
|
+
* User-supplied ABIs from ~/.sigil/abi/*.json, so the preview can name
|
|
4
|
+
* functions on the user's own contracts ("setFee(fee=30)" instead of
|
|
5
|
+
* "unknown function 0x69fe0e2d").
|
|
6
|
+
*
|
|
7
|
+
* Each file is either a bare ABI array or a Foundry/Hardhat artifact
|
|
8
|
+
* `{ "abi": [...] }`. Loading is presentation-only and therefore never
|
|
9
|
+
* fatal: a malformed file is skipped and recorded in `loadWarnings`, which
|
|
10
|
+
* the preview text surfaces (`abi: skipped <file>: <reason>`) so the user
|
|
11
|
+
* notices instead of silently getting less detail.
|
|
12
|
+
*
|
|
13
|
+
* Files are read once at sigil-mcp boot, in sorted filename order; the first
|
|
14
|
+
* definition of a selector wins, so a collision resolves deterministically.
|
|
15
|
+
* The directory sits inside ~/.sigil (0700) — whoever can write it can also
|
|
16
|
+
* write the policy files, so it carries no trust the policy doesn't.
|
|
17
|
+
*/
|
|
18
|
+
export interface AbiInput {
|
|
19
|
+
name: string;
|
|
20
|
+
/** Canonical type ("(address,uint256)[]" for tuple[]). */
|
|
21
|
+
type: string;
|
|
22
|
+
abiType: AbiType;
|
|
23
|
+
}
|
|
24
|
+
export interface AbiFunction {
|
|
25
|
+
selector: string;
|
|
26
|
+
signature: string;
|
|
27
|
+
name: string;
|
|
28
|
+
inputs: AbiInput[];
|
|
29
|
+
/** File the definition came from. */
|
|
30
|
+
source: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class AbiRegistry {
|
|
33
|
+
#private;
|
|
34
|
+
readonly loadWarnings: readonly string[];
|
|
35
|
+
private constructor();
|
|
36
|
+
static empty(): AbiRegistry;
|
|
37
|
+
/**
|
|
38
|
+
* Load every *.json in `dir`. A missing directory is an empty registry;
|
|
39
|
+
* an unreadable one is an empty registry with a warning.
|
|
40
|
+
*/
|
|
41
|
+
static fromDir(dir: string): AbiRegistry;
|
|
42
|
+
/** Build from in-memory file contents (tests, and fromDir's second half). */
|
|
43
|
+
static fromSources(files: readonly {
|
|
44
|
+
name: string;
|
|
45
|
+
text: string;
|
|
46
|
+
}[]): AbiRegistry;
|
|
47
|
+
lookup(selector: string): AbiFunction | undefined;
|
|
48
|
+
get size(): number;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=abi-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi-dir.d.ts","sourceRoot":"","sources":["../../../src/preview/abi-dir.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EAIb,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,qBAAa,WAAW;;IAEtB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAEzC,OAAO;IAKP,MAAM,CAAC,KAAK,IAAI,WAAW;IAI3B;;;OAGG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;IAgCxC,6EAA6E;IAC7E,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,WAAW;IAqDjF,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIjD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AbiDecodeError, canonicalType, functionSelector, parseAbiType, } from '../eth/abi.js';
|
|
4
|
+
/** Artifacts carry bytecode and can be large; anything past this is skipped. */
|
|
5
|
+
const MAX_ABI_FILE_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
export class AbiRegistry {
|
|
7
|
+
#bySelector;
|
|
8
|
+
loadWarnings;
|
|
9
|
+
constructor(bySelector, warnings) {
|
|
10
|
+
this.#bySelector = bySelector;
|
|
11
|
+
this.loadWarnings = Object.freeze([...warnings]);
|
|
12
|
+
}
|
|
13
|
+
static empty() {
|
|
14
|
+
return new AbiRegistry(new Map(), []);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load every *.json in `dir`. A missing directory is an empty registry;
|
|
18
|
+
* an unreadable one is an empty registry with a warning.
|
|
19
|
+
*/
|
|
20
|
+
static fromDir(dir) {
|
|
21
|
+
let names;
|
|
22
|
+
try {
|
|
23
|
+
names = readdirSync(dir)
|
|
24
|
+
.filter((f) => f.endsWith('.json'))
|
|
25
|
+
.sort();
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err.code === 'ENOENT')
|
|
29
|
+
return AbiRegistry.empty();
|
|
30
|
+
return new AbiRegistry(new Map(), [
|
|
31
|
+
`abi: cannot read ${dir}: ${err.code ?? err.message}`,
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
const files = [];
|
|
35
|
+
const warnings = [];
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
const path = join(dir, name);
|
|
38
|
+
try {
|
|
39
|
+
if (statSync(path).size > MAX_ABI_FILE_BYTES) {
|
|
40
|
+
warnings.push(`abi: skipped ${name}: larger than ${MAX_ABI_FILE_BYTES} bytes`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
files.push({ name, text: readFileSync(path, 'utf8') });
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
warnings.push(`abi: skipped ${name}: ${err.code ?? err.message}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const reg = AbiRegistry.fromSources(files);
|
|
50
|
+
return new AbiRegistry(new Map(reg.#bySelector), [...warnings, ...reg.loadWarnings]);
|
|
51
|
+
}
|
|
52
|
+
/** Build from in-memory file contents (tests, and fromDir's second half). */
|
|
53
|
+
static fromSources(files) {
|
|
54
|
+
const map = new Map();
|
|
55
|
+
const warnings = [];
|
|
56
|
+
for (const { name, text } of files) {
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = JSON.parse(text);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
warnings.push(`abi: skipped ${name}: invalid JSON`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const abi = Array.isArray(parsed)
|
|
66
|
+
? parsed
|
|
67
|
+
: isObject(parsed) && Array.isArray(parsed['abi'])
|
|
68
|
+
? parsed['abi']
|
|
69
|
+
: null;
|
|
70
|
+
if (abi === null) {
|
|
71
|
+
warnings.push(`abi: skipped ${name}: expected an ABI array or an artifact with "abi"`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
let unsupported = 0;
|
|
75
|
+
let badName;
|
|
76
|
+
const fns = [];
|
|
77
|
+
for (const item of abi) {
|
|
78
|
+
if (!isObject(item))
|
|
79
|
+
continue;
|
|
80
|
+
// `type` defaults to "function" per the Solidity JSON ABI spec.
|
|
81
|
+
if (item['type'] !== undefined && item['type'] !== 'function')
|
|
82
|
+
continue;
|
|
83
|
+
try {
|
|
84
|
+
fns.push(parseFunction(item));
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err instanceof AbiNameError) {
|
|
88
|
+
badName = err.message;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
unsupported++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Names are rendered into the preview the human reads; a file that
|
|
95
|
+
// smuggles anything but identifiers in them is refused whole.
|
|
96
|
+
if (badName !== undefined) {
|
|
97
|
+
warnings.push(`abi: skipped ${name}: ${badName}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
for (const f of fns)
|
|
101
|
+
if (!map.has(f.selector))
|
|
102
|
+
map.set(f.selector, { ...f, source: name });
|
|
103
|
+
if (unsupported > 0) {
|
|
104
|
+
warnings.push(`abi: ${name}: skipped ${unsupported} function${unsupported === 1 ? '' : 's'} with unsupported or malformed types`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return new AbiRegistry(map, warnings);
|
|
108
|
+
}
|
|
109
|
+
lookup(selector) {
|
|
110
|
+
return this.#bySelector.get(selector.toLowerCase());
|
|
111
|
+
}
|
|
112
|
+
get size() {
|
|
113
|
+
return this.#bySelector.size;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Solidity identifier, bounded. Anything else is refused, not rendered. */
|
|
117
|
+
const IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]{0,63}$/;
|
|
118
|
+
class AbiNameError extends Error {
|
|
119
|
+
}
|
|
120
|
+
/** An optional parameter/component name: empty or an identifier. */
|
|
121
|
+
function checkParamName(v, where) {
|
|
122
|
+
if (v === undefined || v === '')
|
|
123
|
+
return;
|
|
124
|
+
if (typeof v !== 'string' || !IDENT_RE.test(v)) {
|
|
125
|
+
throw new AbiNameError(`invalid identifier ${clip(v)} in ${where}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function clip(v) {
|
|
129
|
+
const s = JSON.stringify(typeof v === 'string' ? v : String(v)) ?? '';
|
|
130
|
+
return s.length > 40 ? s.slice(0, 40) + '…' : s;
|
|
131
|
+
}
|
|
132
|
+
function parseFunction(item) {
|
|
133
|
+
const name = item['name'];
|
|
134
|
+
if (typeof name !== 'string' || !IDENT_RE.test(name)) {
|
|
135
|
+
throw new AbiNameError(`invalid function name ${clip(name)}`);
|
|
136
|
+
}
|
|
137
|
+
const rawInputs = item['inputs'] ?? [];
|
|
138
|
+
if (!Array.isArray(rawInputs))
|
|
139
|
+
throw new AbiDecodeError('inputs');
|
|
140
|
+
const inputs = rawInputs.map((inp, i) => {
|
|
141
|
+
if (!isObject(inp))
|
|
142
|
+
throw new AbiDecodeError('input');
|
|
143
|
+
checkParamName(inp['name'], `${name}()`);
|
|
144
|
+
const type = jsonType(inp, 0);
|
|
145
|
+
const abiType = parseAbiType(type);
|
|
146
|
+
const nm = typeof inp['name'] === 'string' && inp['name'] !== '' ? inp['name'] : `arg${i}`;
|
|
147
|
+
return { name: nm, type: canonicalType(abiType), abiType };
|
|
148
|
+
});
|
|
149
|
+
const signature = `${name}(${inputs.map((i) => i.type).join(',')})`;
|
|
150
|
+
return { selector: functionSelector(signature), signature, name, inputs };
|
|
151
|
+
}
|
|
152
|
+
/** JSON ABI param → canonical type string, expanding `tuple…` via components. */
|
|
153
|
+
function jsonType(p, depth) {
|
|
154
|
+
if (depth > 32)
|
|
155
|
+
throw new AbiDecodeError('nesting');
|
|
156
|
+
const t = p['type'];
|
|
157
|
+
if (typeof t !== 'string')
|
|
158
|
+
throw new AbiDecodeError('type');
|
|
159
|
+
if (!t.startsWith('tuple'))
|
|
160
|
+
return t;
|
|
161
|
+
const comps = p['components'];
|
|
162
|
+
if (!Array.isArray(comps))
|
|
163
|
+
throw new AbiDecodeError('components');
|
|
164
|
+
const inner = comps.map((c) => {
|
|
165
|
+
if (!isObject(c))
|
|
166
|
+
throw new AbiDecodeError('component');
|
|
167
|
+
checkParamName(c['name'], 'a tuple component');
|
|
168
|
+
return jsonType(c, depth + 1);
|
|
169
|
+
});
|
|
170
|
+
return `(${inner.join(',')})${t.slice('tuple'.length)}`;
|
|
171
|
+
}
|
|
172
|
+
function isObject(v) {
|
|
173
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=abi-dir.js.map
|