create-nyquist 0.1.0 → 0.2.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 +16 -12
- package/dist/index.js +370 -244
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -218,7 +218,7 @@ var init_utils = __esm({
|
|
|
218
218
|
"../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js"() {
|
|
219
219
|
init_cryptoNode();
|
|
220
220
|
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
221
|
-
swap32IfBE = isLE ? (
|
|
221
|
+
swap32IfBE = isLE ? (u4) => u4 : byteSwap32;
|
|
222
222
|
Hash = class {
|
|
223
223
|
};
|
|
224
224
|
}
|
|
@@ -473,13 +473,13 @@ function invert(number4, modulo) {
|
|
|
473
473
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
474
474
|
let a2 = mod(number4, modulo);
|
|
475
475
|
let b = modulo;
|
|
476
|
-
let x = _0n2, y2 = _1n2,
|
|
476
|
+
let x = _0n2, y2 = _1n2, u4 = _1n2, v = _0n2;
|
|
477
477
|
while (a2 !== _0n2) {
|
|
478
478
|
const q = b / a2;
|
|
479
479
|
const r2 = b % a2;
|
|
480
|
-
const m = x -
|
|
480
|
+
const m = x - u4 * q;
|
|
481
481
|
const n3 = y2 - v * q;
|
|
482
|
-
b = a2, a2 = r2, x =
|
|
482
|
+
b = a2, a2 = r2, x = u4, y2 = v, u4 = m, v = n3;
|
|
483
483
|
}
|
|
484
484
|
const gcd = b;
|
|
485
485
|
if (gcd !== _1n2)
|
|
@@ -2139,16 +2139,16 @@ function SWUFpSqrtRatio(Fp, Z) {
|
|
|
2139
2139
|
const c5 = _2n_pow_c1_1;
|
|
2140
2140
|
const c6 = Fp.pow(Z, c2);
|
|
2141
2141
|
const c7 = Fp.pow(Z, (c2 + _1n4) / _2n2);
|
|
2142
|
-
let sqrtRatio = (
|
|
2142
|
+
let sqrtRatio = (u4, v) => {
|
|
2143
2143
|
let tv1 = c6;
|
|
2144
2144
|
let tv2 = Fp.pow(v, c4);
|
|
2145
2145
|
let tv3 = Fp.sqr(tv2);
|
|
2146
2146
|
tv3 = Fp.mul(tv3, v);
|
|
2147
|
-
let tv5 = Fp.mul(
|
|
2147
|
+
let tv5 = Fp.mul(u4, tv3);
|
|
2148
2148
|
tv5 = Fp.pow(tv5, c3);
|
|
2149
2149
|
tv5 = Fp.mul(tv5, tv2);
|
|
2150
2150
|
tv2 = Fp.mul(tv5, v);
|
|
2151
|
-
tv3 = Fp.mul(tv5,
|
|
2151
|
+
tv3 = Fp.mul(tv5, u4);
|
|
2152
2152
|
let tv4 = Fp.mul(tv3, tv2);
|
|
2153
2153
|
tv5 = Fp.pow(tv4, c5);
|
|
2154
2154
|
let isQR = Fp.eql(tv5, Fp.ONE);
|
|
@@ -2172,15 +2172,15 @@ function SWUFpSqrtRatio(Fp, Z) {
|
|
|
2172
2172
|
if (Fp.ORDER % _4n2 === _3n2) {
|
|
2173
2173
|
const c12 = (Fp.ORDER - _3n2) / _4n2;
|
|
2174
2174
|
const c22 = Fp.sqrt(Fp.neg(Z));
|
|
2175
|
-
sqrtRatio = (
|
|
2175
|
+
sqrtRatio = (u4, v) => {
|
|
2176
2176
|
let tv1 = Fp.sqr(v);
|
|
2177
|
-
const tv2 = Fp.mul(
|
|
2177
|
+
const tv2 = Fp.mul(u4, v);
|
|
2178
2178
|
tv1 = Fp.mul(tv1, tv2);
|
|
2179
2179
|
let y1 = Fp.pow(tv1, c12);
|
|
2180
2180
|
y1 = Fp.mul(y1, tv2);
|
|
2181
2181
|
const y2 = Fp.mul(y1, c22);
|
|
2182
2182
|
const tv3 = Fp.mul(Fp.sqr(y1), v);
|
|
2183
|
-
const isQR = Fp.eql(tv3,
|
|
2183
|
+
const isQR = Fp.eql(tv3, u4);
|
|
2184
2184
|
let y3 = Fp.cmov(y2, y1, isQR);
|
|
2185
2185
|
return { isValid: isQR, value: y3 };
|
|
2186
2186
|
};
|
|
@@ -2194,9 +2194,9 @@ function mapToCurveSimpleSWU(Fp, opts) {
|
|
|
2194
2194
|
const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
|
|
2195
2195
|
if (!Fp.isOdd)
|
|
2196
2196
|
throw new Error("Fp.isOdd is not implemented!");
|
|
2197
|
-
return (
|
|
2197
|
+
return (u4) => {
|
|
2198
2198
|
let tv1, tv2, tv3, tv4, tv5, tv6, x, y2;
|
|
2199
|
-
tv1 = Fp.sqr(
|
|
2199
|
+
tv1 = Fp.sqr(u4);
|
|
2200
2200
|
tv1 = Fp.mul(tv1, opts.Z);
|
|
2201
2201
|
tv2 = Fp.sqr(tv1);
|
|
2202
2202
|
tv2 = Fp.add(tv2, tv1);
|
|
@@ -2214,11 +2214,11 @@ function mapToCurveSimpleSWU(Fp, opts) {
|
|
|
2214
2214
|
tv2 = Fp.add(tv2, tv5);
|
|
2215
2215
|
x = Fp.mul(tv1, tv3);
|
|
2216
2216
|
const { isValid, value } = sqrtRatio(tv2, tv6);
|
|
2217
|
-
y2 = Fp.mul(tv1,
|
|
2217
|
+
y2 = Fp.mul(tv1, u4);
|
|
2218
2218
|
y2 = Fp.mul(y2, value);
|
|
2219
2219
|
x = Fp.cmov(x, tv3, isValid);
|
|
2220
2220
|
y2 = Fp.cmov(y2, value, isValid);
|
|
2221
|
-
const e1 = Fp.isOdd(
|
|
2221
|
+
const e1 = Fp.isOdd(u4) === Fp.isOdd(y2);
|
|
2222
2222
|
y2 = Fp.cmov(Fp.neg(y2), y2, e1);
|
|
2223
2223
|
const tv4_inv = FpInvertBatch(Fp, [tv4], true)[0];
|
|
2224
2224
|
x = Fp.mul(x, tv4_inv);
|
|
@@ -2448,7 +2448,7 @@ function hash_to_field(msg, count, options) {
|
|
|
2448
2448
|
} else {
|
|
2449
2449
|
throw new Error('expand must be "xmd" or "xof"');
|
|
2450
2450
|
}
|
|
2451
|
-
const
|
|
2451
|
+
const u4 = new Array(count);
|
|
2452
2452
|
for (let i2 = 0; i2 < count; i2++) {
|
|
2453
2453
|
const e = new Array(m);
|
|
2454
2454
|
for (let j = 0; j < m; j++) {
|
|
@@ -2456,9 +2456,9 @@ function hash_to_field(msg, count, options) {
|
|
|
2456
2456
|
const tv = prb.subarray(elm_offset, elm_offset + L);
|
|
2457
2457
|
e[j] = mod(os2ip(tv), p);
|
|
2458
2458
|
}
|
|
2459
|
-
|
|
2459
|
+
u4[i2] = e;
|
|
2460
2460
|
}
|
|
2461
|
-
return
|
|
2461
|
+
return u4;
|
|
2462
2462
|
}
|
|
2463
2463
|
function isogenyMap(field, map2) {
|
|
2464
2464
|
const coeff = map2.map((i2) => Array.from(i2).reverse());
|
|
@@ -2488,16 +2488,16 @@ function createHasher2(Point2, mapToCurve, defaults) {
|
|
|
2488
2488
|
// Encodes byte string to elliptic curve.
|
|
2489
2489
|
// hash_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3
|
|
2490
2490
|
hashToCurve(msg, options) {
|
|
2491
|
-
const
|
|
2492
|
-
const u0 = map2(
|
|
2493
|
-
const u1 = map2(
|
|
2491
|
+
const u4 = hash_to_field(msg, 2, { ...defaults, DST: defaults.DST, ...options });
|
|
2492
|
+
const u0 = map2(u4[0]);
|
|
2493
|
+
const u1 = map2(u4[1]);
|
|
2494
2494
|
return clear(u0.add(u1));
|
|
2495
2495
|
},
|
|
2496
2496
|
// Encodes byte string to elliptic curve.
|
|
2497
2497
|
// encode_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3
|
|
2498
2498
|
encodeToCurve(msg, options) {
|
|
2499
|
-
const
|
|
2500
|
-
return clear(map2(
|
|
2499
|
+
const u4 = hash_to_field(msg, 1, { ...defaults, DST: defaults.encodeDST, ...options });
|
|
2500
|
+
return clear(map2(u4[0]));
|
|
2501
2501
|
},
|
|
2502
2502
|
// Same as encodeToCurve, but without hash
|
|
2503
2503
|
mapToCurve(scalars) {
|
|
@@ -17160,6 +17160,7 @@ var require_dist = __commonJS({
|
|
|
17160
17160
|
import { parseArgs } from "node:util";
|
|
17161
17161
|
|
|
17162
17162
|
// ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
|
|
17163
|
+
import { styleText } from "node:util";
|
|
17163
17164
|
import { stdout, stdin } from "node:process";
|
|
17164
17165
|
import * as l from "node:readline";
|
|
17165
17166
|
import l__default from "node:readline";
|
|
@@ -17818,6 +17819,34 @@ var y = class {
|
|
|
17818
17819
|
}
|
|
17819
17820
|
}
|
|
17820
17821
|
};
|
|
17822
|
+
var u$1 = class u extends y {
|
|
17823
|
+
_mask = "\u2022";
|
|
17824
|
+
get cursor() {
|
|
17825
|
+
return this._cursor;
|
|
17826
|
+
}
|
|
17827
|
+
get masked() {
|
|
17828
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
17829
|
+
}
|
|
17830
|
+
get userInputWithCursor() {
|
|
17831
|
+
if (this.state === "submit" || this.state === "cancel")
|
|
17832
|
+
return this.masked;
|
|
17833
|
+
const t2 = this.userInput;
|
|
17834
|
+
if (this.cursor >= t2.length)
|
|
17835
|
+
return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
17836
|
+
const s = this.masked, r2 = s.slice(0, this.cursor), i2 = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
|
|
17837
|
+
return `${r2}${styleText("inverse", i2)}${o}`;
|
|
17838
|
+
}
|
|
17839
|
+
clear() {
|
|
17840
|
+
this._clearUserInput();
|
|
17841
|
+
}
|
|
17842
|
+
constructor({ mask: t2, ...s }) {
|
|
17843
|
+
super(s), this._mask = t2 ?? "\u2022", this.on("userInput", (r2) => {
|
|
17844
|
+
this._setValue(r2);
|
|
17845
|
+
}), this.on("finalize", () => {
|
|
17846
|
+
this.value === void 0 && (this.value = "");
|
|
17847
|
+
});
|
|
17848
|
+
}
|
|
17849
|
+
};
|
|
17821
17850
|
var n$1 = class n extends y {
|
|
17822
17851
|
options;
|
|
17823
17852
|
cursor = 0;
|
|
@@ -17848,7 +17877,7 @@ var n$1 = class n extends y {
|
|
|
17848
17877
|
};
|
|
17849
17878
|
|
|
17850
17879
|
// ../../node_modules/.pnpm/@clack+prompts@1.8.1/node_modules/@clack/prompts/dist/index.mjs
|
|
17851
|
-
import { styleText, stripVTControlCharacters } from "node:util";
|
|
17880
|
+
import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
17852
17881
|
import process$1 from "node:process";
|
|
17853
17882
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
17854
17883
|
function isUnicodeSupported() {
|
|
@@ -17889,33 +17918,33 @@ var symbol = (o) => {
|
|
|
17889
17918
|
switch (o) {
|
|
17890
17919
|
case "initial":
|
|
17891
17920
|
case "active":
|
|
17892
|
-
return
|
|
17921
|
+
return styleText2("cyan", S_STEP_ACTIVE);
|
|
17893
17922
|
case "cancel":
|
|
17894
|
-
return
|
|
17923
|
+
return styleText2("red", S_STEP_CANCEL);
|
|
17895
17924
|
case "error":
|
|
17896
|
-
return
|
|
17925
|
+
return styleText2("yellow", S_STEP_ERROR);
|
|
17897
17926
|
case "submit":
|
|
17898
|
-
return
|
|
17927
|
+
return styleText2("green", S_STEP_SUBMIT);
|
|
17899
17928
|
case "validating":
|
|
17900
|
-
return
|
|
17929
|
+
return styleText2("dim", S_STEP_ACTIVE);
|
|
17901
17930
|
}
|
|
17902
17931
|
};
|
|
17903
17932
|
var symbolBar = (o) => {
|
|
17904
17933
|
switch (o) {
|
|
17905
17934
|
case "initial":
|
|
17906
17935
|
case "active":
|
|
17907
|
-
return
|
|
17936
|
+
return styleText2("cyan", S_BAR);
|
|
17908
17937
|
case "cancel":
|
|
17909
|
-
return
|
|
17938
|
+
return styleText2("red", S_BAR);
|
|
17910
17939
|
case "error":
|
|
17911
|
-
return
|
|
17940
|
+
return styleText2("yellow", S_BAR);
|
|
17912
17941
|
case "submit":
|
|
17913
|
-
return
|
|
17942
|
+
return styleText2("green", S_BAR);
|
|
17914
17943
|
}
|
|
17915
17944
|
};
|
|
17916
17945
|
function formatInstructionFooter(o, e) {
|
|
17917
|
-
const r2 = [`${e ? `${
|
|
17918
|
-
return e && r2.push(
|
|
17946
|
+
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
|
|
17947
|
+
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
17919
17948
|
}
|
|
17920
17949
|
var I = (l2, e, w, p, b, C2 = false) => {
|
|
17921
17950
|
let r2 = e, O = 0;
|
|
@@ -17940,7 +17969,7 @@ var limitOptions = ({
|
|
|
17940
17969
|
columnPadding: C2 = 0,
|
|
17941
17970
|
rowPadding: r2 = 4
|
|
17942
17971
|
}) => {
|
|
17943
|
-
const i2 = getColumns(p) - C2, m = getRows(p), M =
|
|
17972
|
+
const i2 = getColumns(p) - C2, m = getRows(p), M = styleText2("dim", "..."), v = Math.max(m - r2, 0), a2 = Math.max(Math.min(b, v), 5);
|
|
17944
17973
|
let f = 0;
|
|
17945
17974
|
l2 >= a2 - 3 && (f = Math.max(
|
|
17946
17975
|
Math.min(l2 - a2 + 3, e.length - a2),
|
|
@@ -17965,16 +17994,16 @@ var limitOptions = ({
|
|
|
17965
17994
|
if (g > v) {
|
|
17966
17995
|
let t2 = 0, n3 = 0, o = g;
|
|
17967
17996
|
const h2 = l2 - T;
|
|
17968
|
-
let
|
|
17969
|
-
const L = () => I(s, o, 0, h2,
|
|
17997
|
+
let u4 = v;
|
|
17998
|
+
const L = () => I(s, o, 0, h2, u4), E = () => I(
|
|
17970
17999
|
s,
|
|
17971
18000
|
o,
|
|
17972
18001
|
h2 + 1,
|
|
17973
18002
|
s.length,
|
|
17974
|
-
|
|
18003
|
+
u4,
|
|
17975
18004
|
true
|
|
17976
18005
|
);
|
|
17977
|
-
d ? ({ lineCount: o, removals: t2 } = L(), o >
|
|
18006
|
+
d ? ({ lineCount: o, removals: t2 } = L(), o > u4 && (c2 || (u4 -= 1), { lineCount: o, removals: n3 } = E())) : (c2 || (u4 -= 1), { lineCount: o, removals: n3 } = E(), o > u4 && (u4 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c2 = true, s.splice(s.length - n3, n3));
|
|
17978
18007
|
}
|
|
17979
18008
|
const x = [];
|
|
17980
18009
|
d && x.push(M);
|
|
@@ -17984,19 +18013,19 @@ var limitOptions = ({
|
|
|
17984
18013
|
return c2 && x.push(M), x;
|
|
17985
18014
|
};
|
|
17986
18015
|
var MULTISELECT_INSTRUCTIONS = [
|
|
17987
|
-
`${
|
|
17988
|
-
`${
|
|
17989
|
-
`${
|
|
18016
|
+
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
18017
|
+
`${styleText2("dim", "Space:")} select`,
|
|
18018
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
17990
18019
|
];
|
|
17991
18020
|
var log = {
|
|
17992
18021
|
message: (s = [], {
|
|
17993
|
-
symbol: e =
|
|
17994
|
-
secondarySymbol: r2 =
|
|
18022
|
+
symbol: e = styleText2("gray", S_BAR),
|
|
18023
|
+
secondarySymbol: r2 = styleText2("gray", S_BAR),
|
|
17995
18024
|
output: m = process.stdout,
|
|
17996
18025
|
spacing: l2 = 1,
|
|
17997
18026
|
withGuide: c2
|
|
17998
18027
|
} = {}) => {
|
|
17999
|
-
const t2 = [], o = c2 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "",
|
|
18028
|
+
const t2 = [], o = c2 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u4 = o ? `${r2} ` : "";
|
|
18000
18029
|
for (let i2 = 0; i2 < l2; i2++)
|
|
18001
18030
|
t2.push(f);
|
|
18002
18031
|
const g = Array.isArray(s) ? s : s.split(`
|
|
@@ -18005,46 +18034,46 @@ var log = {
|
|
|
18005
18034
|
const [i2, ...y2] = g;
|
|
18006
18035
|
i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o ? e : "");
|
|
18007
18036
|
for (const p of y2)
|
|
18008
|
-
p.length > 0 ? t2.push(`${
|
|
18037
|
+
p.length > 0 ? t2.push(`${u4}${p}`) : t2.push(o ? r2 : "");
|
|
18009
18038
|
}
|
|
18010
18039
|
m.write(`${t2.join(`
|
|
18011
18040
|
`)}
|
|
18012
18041
|
`);
|
|
18013
18042
|
},
|
|
18014
18043
|
info: (s, e) => {
|
|
18015
|
-
log.message(s, { ...e, symbol:
|
|
18044
|
+
log.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
|
|
18016
18045
|
},
|
|
18017
18046
|
success: (s, e) => {
|
|
18018
|
-
log.message(s, { ...e, symbol:
|
|
18047
|
+
log.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
|
|
18019
18048
|
},
|
|
18020
18049
|
step: (s, e) => {
|
|
18021
|
-
log.message(s, { ...e, symbol:
|
|
18050
|
+
log.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
|
|
18022
18051
|
},
|
|
18023
18052
|
warn: (s, e) => {
|
|
18024
|
-
log.message(s, { ...e, symbol:
|
|
18053
|
+
log.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
|
|
18025
18054
|
},
|
|
18026
18055
|
/** alias for `log.warn()`. */
|
|
18027
18056
|
warning: (s, e) => {
|
|
18028
18057
|
log.warn(s, e);
|
|
18029
18058
|
},
|
|
18030
18059
|
error: (s, e) => {
|
|
18031
|
-
log.message(s, { ...e, symbol:
|
|
18060
|
+
log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
|
|
18032
18061
|
}
|
|
18033
18062
|
};
|
|
18034
18063
|
var cancel = (o = "", t2) => {
|
|
18035
|
-
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${
|
|
18036
|
-
i2.write(`${e}${
|
|
18064
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
18065
|
+
i2.write(`${e}${styleText2("red", o)}
|
|
18037
18066
|
|
|
18038
18067
|
`);
|
|
18039
18068
|
};
|
|
18040
18069
|
var intro = (o = "", t2) => {
|
|
18041
|
-
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${
|
|
18070
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
18042
18071
|
i2.write(`${e}${o}
|
|
18043
18072
|
`);
|
|
18044
18073
|
};
|
|
18045
18074
|
var outro = (o = "", t2) => {
|
|
18046
|
-
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${
|
|
18047
|
-
${
|
|
18075
|
+
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
18076
|
+
${styleText2("gray", S_BAR_END)} ` : "";
|
|
18048
18077
|
i2.write(`${e}${o}
|
|
18049
18078
|
|
|
18050
18079
|
`);
|
|
@@ -18055,7 +18084,7 @@ var C = (o, e, s) => {
|
|
|
18055
18084
|
hard: true,
|
|
18056
18085
|
trim: false
|
|
18057
18086
|
}, i2 = wrapAnsi(o, e, a2).split(`
|
|
18058
|
-
`), c2 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0),
|
|
18087
|
+
`), c2 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u4 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g = e - (u4 - c2);
|
|
18059
18088
|
return wrapAnsi(o, g, a2);
|
|
18060
18089
|
};
|
|
18061
18090
|
var note = (o = "", e = "", s) => {
|
|
@@ -18067,21 +18096,57 @@ var note = (o = "", e = "", s) => {
|
|
|
18067
18096
|
}, 0),
|
|
18068
18097
|
n3
|
|
18069
18098
|
) + 2, h2 = g.map(
|
|
18070
|
-
(m) => `${
|
|
18099
|
+
(m) => `${styleText2("gray", S_BAR)} ${m}${" ".repeat(t2 - dist_default2(m))}${styleText2("gray", S_BAR)}`
|
|
18071
18100
|
).join(`
|
|
18072
|
-
`), T = i2 ? `${
|
|
18101
|
+
`), T = i2 ? `${styleText2("gray", S_BAR)}
|
|
18073
18102
|
` : "", l$1 = i2 ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
18074
18103
|
a2.write(
|
|
18075
|
-
`${T}${
|
|
18104
|
+
`${T}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2(
|
|
18076
18105
|
"gray",
|
|
18077
18106
|
S_BAR_H.repeat(Math.max(t2 - n3 - 1, 1)) + S_CORNER_TOP_RIGHT
|
|
18078
18107
|
)}
|
|
18079
18108
|
${h2}
|
|
18080
|
-
${
|
|
18109
|
+
${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
18081
18110
|
`
|
|
18082
18111
|
);
|
|
18083
18112
|
};
|
|
18084
|
-
var
|
|
18113
|
+
var password = (e) => new u$1({
|
|
18114
|
+
validate: e.validate,
|
|
18115
|
+
mask: e.mask ?? S_PASSWORD_MASK,
|
|
18116
|
+
signal: e.signal,
|
|
18117
|
+
input: e.input,
|
|
18118
|
+
output: e.output,
|
|
18119
|
+
render() {
|
|
18120
|
+
const r2 = e.withGuide ?? settings.withGuide, o = `${r2 ? `${styleText2("gray", S_BAR)}
|
|
18121
|
+
` : ""}${symbol(this.state)} ${e.message}
|
|
18122
|
+
`, m = this.userInputWithCursor, i2 = this.masked;
|
|
18123
|
+
switch (this.state) {
|
|
18124
|
+
case "error": {
|
|
18125
|
+
const s = r2 ? `${styleText2("yellow", S_BAR)} ` : "", n3 = r2 ? `${styleText2("yellow", S_BAR_END)} ` : "", d = i2 ?? "";
|
|
18126
|
+
return e.clearOnError && this.clear(), `${o.trim()}
|
|
18127
|
+
${s}${d}
|
|
18128
|
+
${n3}${styleText2("yellow", this.error)}
|
|
18129
|
+
`;
|
|
18130
|
+
}
|
|
18131
|
+
case "submit": {
|
|
18132
|
+
const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2("dim", i2) : "";
|
|
18133
|
+
return `${o}${s}${n3}`;
|
|
18134
|
+
}
|
|
18135
|
+
case "cancel": {
|
|
18136
|
+
const s = r2 ? `${styleText2("gray", S_BAR)} ` : "", n3 = i2 ? styleText2(["strikethrough", "dim"], i2) : "";
|
|
18137
|
+
return `${o}${s}${n3}${i2 && r2 ? `
|
|
18138
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
18139
|
+
}
|
|
18140
|
+
default: {
|
|
18141
|
+
const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = r2 ? styleText2("cyan", S_BAR_END) : "";
|
|
18142
|
+
return `${o}${s}${m}
|
|
18143
|
+
${n3}
|
|
18144
|
+
`;
|
|
18145
|
+
}
|
|
18146
|
+
}
|
|
18147
|
+
}
|
|
18148
|
+
}).prompt();
|
|
18149
|
+
var W = (l2) => styleText2("magenta", l2);
|
|
18085
18150
|
var spinner = ({
|
|
18086
18151
|
indicator: l2 = "dots",
|
|
18087
18152
|
onCancel: h2,
|
|
@@ -18093,7 +18158,7 @@ var spinner = ({
|
|
|
18093
18158
|
signal: m,
|
|
18094
18159
|
...I2
|
|
18095
18160
|
} = {}) => {
|
|
18096
|
-
const
|
|
18161
|
+
const u4 = isCI();
|
|
18097
18162
|
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
18098
18163
|
const x = getColumns(n3), k = I2?.styleFrame ?? W, g = (e) => {
|
|
18099
18164
|
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
@@ -18104,7 +18169,7 @@ var spinner = ({
|
|
|
18104
18169
|
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m && m.removeEventListener("abort", i2);
|
|
18105
18170
|
}, y2 = () => {
|
|
18106
18171
|
if (p === void 0) return;
|
|
18107
|
-
|
|
18172
|
+
u4 && n3.write(`
|
|
18108
18173
|
`);
|
|
18109
18174
|
const r2 = wrapAnsi(p, x, {
|
|
18110
18175
|
hard: true,
|
|
@@ -18116,16 +18181,16 @@ var spinner = ({
|
|
|
18116
18181
|
const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
|
|
18117
18182
|
return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
|
|
18118
18183
|
}, N = I2.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
18119
|
-
d = true, M = block({ output: n3 }), s = C2(e), w = performance.now(), N && n3.write(`${
|
|
18184
|
+
d = true, M = block({ output: n3 }), s = C2(e), w = performance.now(), N && n3.write(`${styleText2("gray", S_BAR)}
|
|
18120
18185
|
`);
|
|
18121
18186
|
let r2 = 0, t2 = 0;
|
|
18122
18187
|
A(), T = setInterval(() => {
|
|
18123
|
-
if (
|
|
18188
|
+
if (u4 && s === p)
|
|
18124
18189
|
return;
|
|
18125
18190
|
y2(), p = s;
|
|
18126
18191
|
const o = k(E[r2]);
|
|
18127
18192
|
let v;
|
|
18128
|
-
if (
|
|
18193
|
+
if (u4)
|
|
18129
18194
|
v = `${o} ${s}...`;
|
|
18130
18195
|
else if (l2 === "timer")
|
|
18131
18196
|
v = `${o} ${s} ${_(w)}`;
|
|
@@ -18142,7 +18207,7 @@ var spinner = ({
|
|
|
18142
18207
|
}, a2 = (e = "", r2 = 0, t2 = false) => {
|
|
18143
18208
|
if (!d) return;
|
|
18144
18209
|
d = false, clearInterval(T), y2();
|
|
18145
|
-
const o = r2 === 0 ?
|
|
18210
|
+
const o = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
18146
18211
|
s = e ?? s, t2 || (l2 === "timer" ? n3.write(`${o} ${s} ${_(w)}
|
|
18147
18212
|
`) : n3.write(`${o} ${s}
|
|
18148
18213
|
`)), H(), M();
|
|
@@ -18161,14 +18226,14 @@ var spinner = ({
|
|
|
18161
18226
|
}
|
|
18162
18227
|
};
|
|
18163
18228
|
};
|
|
18164
|
-
var
|
|
18229
|
+
var u3 = {
|
|
18165
18230
|
light: unicodeOr("\u2500", "-"),
|
|
18166
18231
|
heavy: unicodeOr("\u2501", "="),
|
|
18167
18232
|
block: unicodeOr("\u2588", "#")
|
|
18168
18233
|
};
|
|
18169
18234
|
var SELECT_INSTRUCTIONS = [
|
|
18170
|
-
`${
|
|
18171
|
-
`${
|
|
18235
|
+
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
18236
|
+
`${styleText2("dim", "Enter:")} confirm`
|
|
18172
18237
|
];
|
|
18173
18238
|
var c = (t2, o) => t2.includes(`
|
|
18174
18239
|
`) ? t2.split(`
|
|
@@ -18181,15 +18246,15 @@ var select = (t2) => {
|
|
|
18181
18246
|
const s = n3.label ?? String(n3.value);
|
|
18182
18247
|
switch (m) {
|
|
18183
18248
|
case "disabled":
|
|
18184
|
-
return `${
|
|
18249
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
|
|
18185
18250
|
case "selected":
|
|
18186
|
-
return `${c(s, (i2) =>
|
|
18251
|
+
return `${c(s, (i2) => styleText2("dim", i2))}`;
|
|
18187
18252
|
case "active":
|
|
18188
|
-
return `${
|
|
18253
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
|
|
18189
18254
|
case "cancelled":
|
|
18190
|
-
return `${c(s, (i2) =>
|
|
18255
|
+
return `${c(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
|
|
18191
18256
|
default:
|
|
18192
|
-
return `${
|
|
18257
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("dim", i2))}`;
|
|
18193
18258
|
}
|
|
18194
18259
|
}, d = t2.showInstructions ?? true;
|
|
18195
18260
|
return new n$1({
|
|
@@ -18204,32 +18269,32 @@ var select = (t2) => {
|
|
|
18204
18269
|
t2.message,
|
|
18205
18270
|
s,
|
|
18206
18271
|
m
|
|
18207
|
-
),
|
|
18272
|
+
), u4 = `${n3 ? `${styleText2("gray", S_BAR)}
|
|
18208
18273
|
` : ""}${i2}
|
|
18209
18274
|
`;
|
|
18210
18275
|
switch (this.state) {
|
|
18211
18276
|
case "submit": {
|
|
18212
|
-
const r2 = n3 ? `${
|
|
18277
|
+
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
|
|
18213
18278
|
t2.output,
|
|
18214
18279
|
o(this.options[this.cursor], "selected"),
|
|
18215
18280
|
r2
|
|
18216
18281
|
);
|
|
18217
|
-
return `${
|
|
18282
|
+
return `${u4}${a2}`;
|
|
18218
18283
|
}
|
|
18219
18284
|
case "cancel": {
|
|
18220
|
-
const r2 = n3 ? `${
|
|
18285
|
+
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
|
|
18221
18286
|
t2.output,
|
|
18222
18287
|
o(this.options[this.cursor], "cancelled"),
|
|
18223
18288
|
r2
|
|
18224
18289
|
);
|
|
18225
|
-
return `${
|
|
18226
|
-
${
|
|
18290
|
+
return `${u4}${a2}${n3 ? `
|
|
18291
|
+
${styleText2("gray", S_BAR)}` : ""}`;
|
|
18227
18292
|
}
|
|
18228
18293
|
default: {
|
|
18229
|
-
const r2 = n3 ? `${
|
|
18230
|
-
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [
|
|
18294
|
+
const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u4.split(`
|
|
18295
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
|
|
18231
18296
|
`), b = p.length + 1;
|
|
18232
|
-
return `${
|
|
18297
|
+
return `${u4}${r2}${limitOptions({
|
|
18233
18298
|
output: t2.output,
|
|
18234
18299
|
cursor: this.cursor,
|
|
18235
18300
|
options: this.options,
|
|
@@ -18246,7 +18311,7 @@ ${f}
|
|
|
18246
18311
|
}
|
|
18247
18312
|
}).prompt();
|
|
18248
18313
|
};
|
|
18249
|
-
var i = `${
|
|
18314
|
+
var i = `${styleText2("gray", S_BAR)} `;
|
|
18250
18315
|
|
|
18251
18316
|
// ../../packages/agent/src/errors.ts
|
|
18252
18317
|
var WalletError = class extends Error {
|
|
@@ -27252,7 +27317,6 @@ init_concat();
|
|
|
27252
27317
|
init_toBytes();
|
|
27253
27318
|
init_keccak256();
|
|
27254
27319
|
init_toEventSelector();
|
|
27255
|
-
init_toFunctionSelector();
|
|
27256
27320
|
init_formatEther();
|
|
27257
27321
|
|
|
27258
27322
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
@@ -32437,9 +32501,9 @@ var memo = {
|
|
|
32437
32501
|
if (!bucket)
|
|
32438
32502
|
return empty;
|
|
32439
32503
|
handoff = void 0;
|
|
32440
|
-
const
|
|
32441
|
-
bucket.set(payload.value,
|
|
32442
|
-
open2.push(
|
|
32504
|
+
const entry2 = { value: empty, issues: null };
|
|
32505
|
+
bucket.set(payload.value, entry2);
|
|
32506
|
+
open2.push(entry2);
|
|
32443
32507
|
return empty;
|
|
32444
32508
|
},
|
|
32445
32509
|
guard(inst) {
|
|
@@ -32513,16 +32577,16 @@ var memo = {
|
|
|
32513
32577
|
const depth = open2.length;
|
|
32514
32578
|
const result = base(payload, ctx);
|
|
32515
32579
|
handoff = void 0;
|
|
32516
|
-
const
|
|
32580
|
+
const entry2 = open2.length > depth ? open2.pop() : void 0;
|
|
32517
32581
|
if (result instanceof Promise) {
|
|
32518
32582
|
return result.then((r2) => {
|
|
32519
|
-
if (
|
|
32520
|
-
|
|
32583
|
+
if (entry2)
|
|
32584
|
+
entry2.issues = r2.issues.length ? cloneIssues(r2.issues) : NO_ISSUES;
|
|
32521
32585
|
return r2;
|
|
32522
32586
|
});
|
|
32523
32587
|
}
|
|
32524
|
-
if (
|
|
32525
|
-
|
|
32588
|
+
if (entry2)
|
|
32589
|
+
entry2.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
32526
32590
|
return result;
|
|
32527
32591
|
};
|
|
32528
32592
|
inst._zod.parse = wrapped;
|
|
@@ -42928,42 +42992,42 @@ function extractDefs(ctx, schema) {
|
|
|
42928
42992
|
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)
|
|
42929
42993
|
return;
|
|
42930
42994
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
42931
|
-
for (const
|
|
42932
|
-
const id = ctx.metadataRegistry.get(
|
|
42995
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
42996
|
+
const id = ctx.metadataRegistry.get(entry2[0])?.id;
|
|
42933
42997
|
if (id) {
|
|
42934
42998
|
const existing = idToSchema.get(id);
|
|
42935
|
-
if (existing && existing !==
|
|
42999
|
+
if (existing && existing !== entry2[0]) {
|
|
42936
43000
|
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
42937
43001
|
}
|
|
42938
|
-
idToSchema.set(id,
|
|
43002
|
+
idToSchema.set(id, entry2[0]);
|
|
42939
43003
|
}
|
|
42940
43004
|
}
|
|
42941
|
-
const makeURI = (
|
|
43005
|
+
const makeURI = (entry2) => {
|
|
42942
43006
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
42943
43007
|
if (ctx.external) {
|
|
42944
|
-
const externalId = ctx.external.registry.get(
|
|
43008
|
+
const externalId = ctx.external.registry.get(entry2[0])?.id;
|
|
42945
43009
|
const uriGenerator = ctx.external.uri ?? ((id2) => id2);
|
|
42946
43010
|
if (externalId) {
|
|
42947
43011
|
return { ref: uriGenerator(externalId) };
|
|
42948
43012
|
}
|
|
42949
|
-
const id =
|
|
42950
|
-
|
|
43013
|
+
const id = entry2[1].defId ?? entry2[1].schema.id ?? `schema${ctx.counter++}`;
|
|
43014
|
+
entry2[1].defId = id;
|
|
42951
43015
|
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}` };
|
|
42952
43016
|
}
|
|
42953
43017
|
const uriPrefix = `#`;
|
|
42954
43018
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
42955
|
-
if (
|
|
43019
|
+
if (entry2[1] === root && !entry2[1].schema.id) {
|
|
42956
43020
|
return { ref: uriPrefix };
|
|
42957
43021
|
}
|
|
42958
|
-
const defId =
|
|
43022
|
+
const defId = entry2[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
42959
43023
|
return { defId, ref: defUriPrefix + encodeJSONPointerSegment(defId) };
|
|
42960
43024
|
};
|
|
42961
|
-
const extractToDef = (
|
|
42962
|
-
if (
|
|
43025
|
+
const extractToDef = (entry2) => {
|
|
43026
|
+
if (entry2[1].schema.$ref) {
|
|
42963
43027
|
return;
|
|
42964
43028
|
}
|
|
42965
|
-
const seen =
|
|
42966
|
-
const { ref, defId } = makeURI(
|
|
43029
|
+
const seen = entry2[1];
|
|
43030
|
+
const { ref, defId } = makeURI(entry2);
|
|
42967
43031
|
seen.def = { ...seen.schema };
|
|
42968
43032
|
if (defId)
|
|
42969
43033
|
seen.defId = defId;
|
|
@@ -42974,8 +43038,8 @@ function extractDefs(ctx, schema) {
|
|
|
42974
43038
|
schema2.$ref = ref;
|
|
42975
43039
|
};
|
|
42976
43040
|
if (ctx.cycles === "throw") {
|
|
42977
|
-
for (const
|
|
42978
|
-
const seen =
|
|
43041
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
43042
|
+
const seen = entry2[1];
|
|
42979
43043
|
if (seen.cycle) {
|
|
42980
43044
|
throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
42981
43045
|
|
|
@@ -42983,31 +43047,31 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
42983
43047
|
}
|
|
42984
43048
|
}
|
|
42985
43049
|
}
|
|
42986
|
-
for (const
|
|
42987
|
-
const seen =
|
|
42988
|
-
if (schema ===
|
|
42989
|
-
extractToDef(
|
|
43050
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
43051
|
+
const seen = entry2[1];
|
|
43052
|
+
if (schema === entry2[0]) {
|
|
43053
|
+
extractToDef(entry2);
|
|
42990
43054
|
continue;
|
|
42991
43055
|
}
|
|
42992
43056
|
if (ctx.external) {
|
|
42993
|
-
const ext = ctx.external.registry.get(
|
|
42994
|
-
if (schema !==
|
|
42995
|
-
extractToDef(
|
|
43057
|
+
const ext = ctx.external.registry.get(entry2[0])?.id;
|
|
43058
|
+
if (schema !== entry2[0] && ext) {
|
|
43059
|
+
extractToDef(entry2);
|
|
42996
43060
|
continue;
|
|
42997
43061
|
}
|
|
42998
43062
|
}
|
|
42999
|
-
const id = ctx.metadataRegistry.get(
|
|
43063
|
+
const id = ctx.metadataRegistry.get(entry2[0])?.id;
|
|
43000
43064
|
if (id) {
|
|
43001
|
-
extractToDef(
|
|
43065
|
+
extractToDef(entry2);
|
|
43002
43066
|
continue;
|
|
43003
43067
|
}
|
|
43004
43068
|
if (seen.cycle) {
|
|
43005
|
-
extractToDef(
|
|
43069
|
+
extractToDef(entry2);
|
|
43006
43070
|
continue;
|
|
43007
43071
|
}
|
|
43008
43072
|
if (seen.count > 1) {
|
|
43009
43073
|
if (ctx.reused === "ref") {
|
|
43010
|
-
extractToDef(
|
|
43074
|
+
extractToDef(entry2);
|
|
43011
43075
|
}
|
|
43012
43076
|
}
|
|
43013
43077
|
}
|
|
@@ -43189,12 +43253,12 @@ function finalize(ctx, schema) {
|
|
|
43189
43253
|
});
|
|
43190
43254
|
};
|
|
43191
43255
|
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
43192
|
-
for (const
|
|
43193
|
-
flattenRef(
|
|
43256
|
+
for (const entry2 of [...ctx.seen.entries()].reverse()) {
|
|
43257
|
+
flattenRef(entry2[0]);
|
|
43194
43258
|
}
|
|
43195
43259
|
if (ctx.target !== "openapi-3.0") {
|
|
43196
|
-
for (const
|
|
43197
|
-
compactTypeUnion(
|
|
43260
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
43261
|
+
compactTypeUnion(entry2[1].def ?? entry2[1].schema);
|
|
43198
43262
|
}
|
|
43199
43263
|
}
|
|
43200
43264
|
for (const rewrite of ctx.deferred)
|
|
@@ -43241,8 +43305,8 @@ function finalize(ctx, schema) {
|
|
|
43241
43305
|
delete result.id;
|
|
43242
43306
|
const defs = ctx.external?.defs ?? {};
|
|
43243
43307
|
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
43244
|
-
for (const
|
|
43245
|
-
const seen =
|
|
43308
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
43309
|
+
const seen = entry2[1];
|
|
43246
43310
|
if (seen.def && seen.defId) {
|
|
43247
43311
|
if (seen.def.id === seen.defId)
|
|
43248
43312
|
delete seen.def.id;
|
|
@@ -43854,9 +43918,9 @@ function stringifyKeyNames(bySchema, json3, visited) {
|
|
|
43854
43918
|
var pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
43855
43919
|
function rewriteKeyNames(ctx) {
|
|
43856
43920
|
const bySchema = /* @__PURE__ */ new Map();
|
|
43857
|
-
for (const
|
|
43858
|
-
if (
|
|
43859
|
-
bySchema.set(
|
|
43921
|
+
for (const entry2 of ctx.seen.values()) {
|
|
43922
|
+
if (entry2.def && !bySchema.has(entry2.schema))
|
|
43923
|
+
bySchema.set(entry2.schema, entry2);
|
|
43860
43924
|
}
|
|
43861
43925
|
const rewrites = /* @__PURE__ */ new Map();
|
|
43862
43926
|
for (const record2 of pendingRecords.get(ctx) ?? []) {
|
|
@@ -43870,8 +43934,8 @@ function rewriteKeyNames(ctx) {
|
|
|
43870
43934
|
}
|
|
43871
43935
|
if (!rewrites.size)
|
|
43872
43936
|
return;
|
|
43873
|
-
for (const
|
|
43874
|
-
for (const carrier of [
|
|
43937
|
+
for (const entry2 of ctx.seen.values()) {
|
|
43938
|
+
for (const carrier of [entry2.schema, entry2.def]) {
|
|
43875
43939
|
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
43876
43940
|
if (rewritten)
|
|
43877
43941
|
carrier.propertyNames = rewritten;
|
|
@@ -44065,8 +44129,8 @@ function toJSONSchema(input2, params) {
|
|
|
44065
44129
|
const registry2 = input2;
|
|
44066
44130
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
44067
44131
|
const defs = {};
|
|
44068
|
-
for (const
|
|
44069
|
-
const [_, schema] =
|
|
44132
|
+
for (const entry2 of registry2._idmap.entries()) {
|
|
44133
|
+
const [_, schema] = entry2;
|
|
44070
44134
|
processSchema(schema, ctx2);
|
|
44071
44135
|
}
|
|
44072
44136
|
const schemas = {};
|
|
@@ -44076,8 +44140,8 @@ function toJSONSchema(input2, params) {
|
|
|
44076
44140
|
defs
|
|
44077
44141
|
};
|
|
44078
44142
|
ctx2.external = external;
|
|
44079
|
-
for (const
|
|
44080
|
-
const [key, schema] =
|
|
44143
|
+
for (const entry2 of registry2._idmap.entries()) {
|
|
44144
|
+
const [key, schema] = entry2;
|
|
44081
44145
|
extractDefs(ctx2, schema);
|
|
44082
44146
|
assignProp(schemas, key, finalize(ctx2, schema));
|
|
44083
44147
|
}
|
|
@@ -46924,11 +46988,20 @@ function date4(params) {
|
|
|
46924
46988
|
}
|
|
46925
46989
|
|
|
46926
46990
|
// ../../packages/env/src/config.ts
|
|
46927
|
-
var ENVIRONMENTS = ["development", "production"];
|
|
46991
|
+
var ENVIRONMENTS = ["development", "production", "mainnet"];
|
|
46928
46992
|
var SEPOLIA = {
|
|
46929
46993
|
id: 11155111,
|
|
46930
46994
|
name: "Sepolia",
|
|
46931
|
-
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com"
|
|
46995
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
46996
|
+
ethUsdFeed: { address: "0x694AA1769357215DE4FAC081bf1f309aDC325306", decimals: 8 }
|
|
46997
|
+
};
|
|
46998
|
+
var MAINNET_FEE_BPS = 500;
|
|
46999
|
+
var MAINNET = {
|
|
47000
|
+
id: 1,
|
|
47001
|
+
name: "Ethereum",
|
|
47002
|
+
rpcUrl: "https://ethereum-rpc.publicnode.com",
|
|
47003
|
+
sendRpcUrl: "https://rpc.flashbots.net/fast",
|
|
47004
|
+
ethUsdFeed: { address: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419", decimals: 8 }
|
|
46932
47005
|
};
|
|
46933
47006
|
var SAFE_V1_4_1 = {
|
|
46934
47007
|
version: "1.4.1",
|
|
@@ -46960,41 +47033,60 @@ var SHARED = {
|
|
|
46960
47033
|
gasPriceMultiplier: 2,
|
|
46961
47034
|
// Safe を作るときに setup の payment でリレイヤーに払ってもらう額。
|
|
46962
47035
|
// 作成時点のガス代がこれを超えるなら、下がるまで作成を待つ。
|
|
47036
|
+
// 0 にすると、Safe の作成と最初の送金を1つの tx にまとめ、作成のガスをその送金の払い戻しに含める。
|
|
47037
|
+
// 作成費用がそのときのガス代に合う。Safe のアドレスはこの値で決まるので、登録済みのエージェントの分は変えられない。
|
|
46963
47038
|
deploymentFeeWei: "2000000000000000",
|
|
46964
47039
|
// Sepolia の ETH には価値がないので、テストネットでは取らない。
|
|
46965
47040
|
feeBps: 0
|
|
46966
47041
|
},
|
|
46967
|
-
|
|
46968
|
-
|
|
46969
|
-
|
|
46970
|
-
|
|
46971
|
-
|
|
46972
|
-
|
|
46973
|
-
nonceTtlSeconds: 300
|
|
46974
|
-
},
|
|
46975
|
-
tenant: {
|
|
46976
|
-
maxAccountPerUser: 5,
|
|
46977
|
-
maxMemberPerAccount: 20,
|
|
46978
|
-
maxAgentPerAccount: 50,
|
|
46979
|
-
maxEnrollmentUses: 100,
|
|
46980
|
-
maxEnrollmentTtlSeconds: 30 * 86400
|
|
47042
|
+
// プロンプトインジェクションを受けたエージェントが、残高をすべて送れないようにする。
|
|
47043
|
+
// メインネットの ETH/USD のフィードは1時間ごとに更新されるので、2時間までの古さを認める。
|
|
47044
|
+
spending: {
|
|
47045
|
+
perTransactionUsd: 100,
|
|
47046
|
+
perDayUsd: 500,
|
|
47047
|
+
maxPriceAgeSeconds: 7200
|
|
46981
47048
|
}
|
|
46982
47049
|
};
|
|
46983
47050
|
var CONFIG = {
|
|
46984
|
-
development: {
|
|
47051
|
+
development: {
|
|
47052
|
+
...SHARED,
|
|
47053
|
+
apiUrl: "http://localhost:8787",
|
|
47054
|
+
relayerAddress: "0x947C75672A5c4c1bD1Fb5243D4d6B4Dc3b6B6bB0",
|
|
47055
|
+
chain: SEPOLIA,
|
|
47056
|
+
registration: "open",
|
|
47057
|
+
// メインネットと同じく、作成と最初の送金をまとめる。
|
|
47058
|
+
relayer: { ...SHARED.relayer, deploymentFeeWei: "0" }
|
|
47059
|
+
},
|
|
46985
47060
|
// Cloudflare の Original SIN Architecture アカウントにデプロイしている。Issue #9 を参照。
|
|
46986
47061
|
production: {
|
|
46987
47062
|
...SHARED,
|
|
46988
47063
|
apiUrl: "https://nyquist-api-production.original-sin-architecture.workers.dev",
|
|
46989
47064
|
relayerAddress: "0x2d7A951dbDFeA17E2c3EecA87cFde15a205c1174",
|
|
46990
|
-
chain: SEPOLIA
|
|
47065
|
+
chain: SEPOLIA,
|
|
47066
|
+
registration: "open"
|
|
47067
|
+
// 登録済みの Safe のアドレスを変えないよう、作成費用を決めて払ってもらう方式のままにする。
|
|
47068
|
+
// 本番で作成と送金をまとめる方式は、非公開の送信経路があるチェーンでだけ使う。公開の mempool では、
|
|
47069
|
+
// 先に Safe を作られてまとめた tx が revert すると、渡したガスをほぼ全部リレイヤーが払うことになる。
|
|
47070
|
+
},
|
|
47071
|
+
// Sepolia とは別の Worker、別のリレイヤーで動かす。法的確認は済み、登録を誰にでも開いている。Issue #72 を参照。
|
|
47072
|
+
// 招待制に戻すときは registration を invite にする。招待コードは .env.mainnet の REGISTRATION_INVITE にある。
|
|
47073
|
+
mainnet: {
|
|
47074
|
+
...SHARED,
|
|
47075
|
+
apiUrl: "https://nyquist-api-mainnet.original-sin-architecture.workers.dev",
|
|
47076
|
+
relayerAddress: "0xF6389d891c5761fE74DC3474272eA7C52A9ae5F2",
|
|
47077
|
+
chain: MAINNET,
|
|
47078
|
+
registration: "open",
|
|
47079
|
+
// Safe の作成は最初の送金とまとめ、そのときのガス代で払ってもらう。
|
|
47080
|
+
relayer: { ...SHARED.relayer, feeBps: MAINNET_FEE_BPS, deploymentFeeWei: "0" }
|
|
46991
47081
|
}
|
|
46992
47082
|
};
|
|
46993
47083
|
|
|
46994
47084
|
// ../../packages/env/src/index.ts
|
|
46995
47085
|
var privateKey = external_exports.string().regex(/^0x[0-9a-fA-F]{64}$/).transform((value) => value);
|
|
46996
47086
|
var secretSchema = external_exports.object({
|
|
46997
|
-
RELAYER_PRIVATE_KEY: privateKey
|
|
47087
|
+
RELAYER_PRIVATE_KEY: privateKey,
|
|
47088
|
+
// 登録が招待制の環境で、登録に添えてもらう招待コード。
|
|
47089
|
+
REGISTRATION_INVITE: external_exports.string().min(24).optional()
|
|
46998
47090
|
});
|
|
46999
47091
|
var runtimeSchema = external_exports.object({
|
|
47000
47092
|
APP_ENV: external_exports.enum(ENVIRONMENTS),
|
|
@@ -47015,7 +47107,8 @@ function loadSettings(env = process.env) {
|
|
|
47015
47107
|
rpcUrl: env.NYQUIST_RPC_URL ?? config2.chain.rpcUrl,
|
|
47016
47108
|
home: env.NYQUIST_HOME ?? join2(homedir(), ".nyquist"),
|
|
47017
47109
|
// 1回の送金で Safe から払い戻すガス代の上限。これを超える見積もりには署名しない。
|
|
47018
|
-
maxFeeWei: env.NYQUIST_MAX_FEE_WEI ? BigInt(env.NYQUIST_MAX_FEE_WEI) : parseEther("0.01")
|
|
47110
|
+
maxFeeWei: env.NYQUIST_MAX_FEE_WEI ? BigInt(env.NYQUIST_MAX_FEE_WEI) : parseEther("0.01"),
|
|
47111
|
+
...env.NYQUIST_INVITE ? { invite: env.NYQUIST_INVITE } : {}
|
|
47019
47112
|
};
|
|
47020
47113
|
}
|
|
47021
47114
|
|
|
@@ -47120,6 +47213,19 @@ var SAFE_ABI = [
|
|
|
47120
47213
|
outputs: [{ name: "", type: "bytes32" }]
|
|
47121
47214
|
}
|
|
47122
47215
|
];
|
|
47216
|
+
var PROXY_FACTORY_ABI = [
|
|
47217
|
+
{
|
|
47218
|
+
type: "function",
|
|
47219
|
+
name: "createProxyWithNonce",
|
|
47220
|
+
stateMutability: "nonpayable",
|
|
47221
|
+
inputs: [
|
|
47222
|
+
{ name: "_singleton", type: "address" },
|
|
47223
|
+
{ name: "initializer", type: "bytes" },
|
|
47224
|
+
{ name: "saltNonce", type: "uint256" }
|
|
47225
|
+
],
|
|
47226
|
+
outputs: [{ name: "proxy", type: "address" }]
|
|
47227
|
+
}
|
|
47228
|
+
];
|
|
47123
47229
|
var SAFE_TX_TYPES = {
|
|
47124
47230
|
SafeTx: [
|
|
47125
47231
|
{ name: "to", type: "address" },
|
|
@@ -47181,15 +47287,7 @@ function encodeSetup(owners, threshold, fallbackHandler, payment = { amount: 0n,
|
|
|
47181
47287
|
args: [owners, BigInt(threshold), zeroAddress, "0x", fallbackHandler, zeroAddress, payment.amount, payment.receiver]
|
|
47182
47288
|
});
|
|
47183
47289
|
}
|
|
47184
|
-
function encodeAddOwner(owner, threshold) {
|
|
47185
|
-
return encodeFunctionData({
|
|
47186
|
-
abi: SAFE_ABI,
|
|
47187
|
-
functionName: "addOwnerWithThreshold",
|
|
47188
|
-
args: [owner, BigInt(threshold)]
|
|
47189
|
-
});
|
|
47190
|
-
}
|
|
47191
47290
|
var GUARD_STORAGE_SLOT = keccak256(toBytes2("guard_manager.guard.address"));
|
|
47192
|
-
var ADD_OWNER_SELECTOR = toFunctionSelector("addOwnerWithThreshold(address,uint256)");
|
|
47193
47291
|
function calldataGas(data) {
|
|
47194
47292
|
let gas = 0n;
|
|
47195
47293
|
for (const byte of toBytes2(data)) gas += byte === 0 ? 4n : 16n;
|
|
@@ -47202,6 +47300,13 @@ function calldataFloorGas(data) {
|
|
|
47202
47300
|
}
|
|
47203
47301
|
var EXECUTION_SUCCESS = toEventSelector("ExecutionSuccess(bytes32,uint256)");
|
|
47204
47302
|
var EXECUTION_FAILURE = toEventSelector("ExecutionFailure(bytes32,uint256)");
|
|
47303
|
+
function encodeCreateProxy(singleton, initializer3, saltNonce2) {
|
|
47304
|
+
return encodeFunctionData({
|
|
47305
|
+
abi: PROXY_FACTORY_ABI,
|
|
47306
|
+
functionName: "createProxyWithNonce",
|
|
47307
|
+
args: [singleton, initializer3, saltNonce2]
|
|
47308
|
+
});
|
|
47309
|
+
}
|
|
47205
47310
|
var PROXY_CREATION_CODE = "0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564";
|
|
47206
47311
|
function predictSafeAddress(proxyFactory, singleton, initializer3, nonce) {
|
|
47207
47312
|
return getContractAddress2({
|
|
@@ -47219,7 +47324,6 @@ function saltNonce(seed) {
|
|
|
47219
47324
|
var CHAIN_BASE = { nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 } };
|
|
47220
47325
|
var HASH = /^0x[0-9a-fA-F]{64}$/;
|
|
47221
47326
|
var DECIMAL = /^(0|[1-9][0-9]{0,77})$/;
|
|
47222
|
-
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
47223
47327
|
var STATUSES = ["pending", "success", "failed", "reverted", "dropped"];
|
|
47224
47328
|
function malformed() {
|
|
47225
47329
|
throw new WalletError("nyquist \u306E\u5FDC\u7B54\u306E\u5F62\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093");
|
|
@@ -47240,19 +47344,16 @@ function parseAgent(json3) {
|
|
|
47240
47344
|
if (typeof json3 !== "object" || json3 === null) malformed();
|
|
47241
47345
|
const value = json3;
|
|
47242
47346
|
if (typeof value.id !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(value.id)) malformed();
|
|
47243
|
-
if (value.accountId !== null && (typeof value.accountId !== "string" || !UUID.test(value.accountId))) malformed();
|
|
47244
47347
|
if (value.status !== "active" && value.status !== "suspended") malformed();
|
|
47245
47348
|
if (!Array.isArray(value.owners) || typeof value.threshold !== "number" || !Number.isInteger(value.threshold)) malformed();
|
|
47246
47349
|
if (typeof value.deployed !== "boolean" || typeof value.createdAt !== "string") malformed();
|
|
47247
47350
|
return {
|
|
47248
47351
|
id: value.id,
|
|
47249
|
-
accountId: value.accountId,
|
|
47250
47352
|
status: value.status,
|
|
47251
47353
|
signer: address(value.signer),
|
|
47252
47354
|
safe: address(value.safe),
|
|
47253
47355
|
owners: value.owners.map(address),
|
|
47254
47356
|
threshold: value.threshold,
|
|
47255
|
-
recoveryOwner: value.recoveryOwner === null ? null : address(value.recoveryOwner),
|
|
47256
47357
|
deployed: value.deployed,
|
|
47257
47358
|
balanceWei: decimal(value.balanceWei),
|
|
47258
47359
|
nonce: decimal(value.nonce),
|
|
@@ -47333,11 +47434,14 @@ var Wallet = class {
|
|
|
47333
47434
|
// Safe の作成費用はリレイヤーに払うので、そのアドレスと額も初期化の内容に入る。
|
|
47334
47435
|
#expectedSafe(keys) {
|
|
47335
47436
|
const { config: config2 } = this.#settings;
|
|
47336
|
-
|
|
47437
|
+
return predictSafeAddress(config2.safe.proxyFactory, config2.safe.singleton, this.#initializer(keys), saltNonce(keys.agentId));
|
|
47438
|
+
}
|
|
47439
|
+
#initializer(keys) {
|
|
47440
|
+
const { config: config2 } = this.#settings;
|
|
47441
|
+
return encodeSetup([keys.signer.address], 1, config2.safe.fallbackHandler, {
|
|
47337
47442
|
amount: BigInt(config2.relayer.deploymentFeeWei),
|
|
47338
47443
|
receiver: config2.relayerAddress
|
|
47339
47444
|
});
|
|
47340
|
-
return predictSafeAddress(config2.safe.proxyFactory, config2.safe.singleton, initializer3, saltNonce(keys.agentId));
|
|
47341
47445
|
}
|
|
47342
47446
|
async #keys() {
|
|
47343
47447
|
const keys = await this.#keystore.load();
|
|
@@ -47345,7 +47449,7 @@ var Wallet = class {
|
|
|
47345
47449
|
return keys;
|
|
47346
47450
|
}
|
|
47347
47451
|
// 鍵がなければ作り、未登録なら登録する。何度呼んでも同じウォレットを返す。
|
|
47348
|
-
async setup(
|
|
47452
|
+
async setup() {
|
|
47349
47453
|
const { keys, created } = await this.#keystore.loadOrCreate();
|
|
47350
47454
|
const expected = this.#expectedSafe(keys);
|
|
47351
47455
|
if (keys.registration) {
|
|
@@ -47360,7 +47464,7 @@ var Wallet = class {
|
|
|
47360
47464
|
await this.#request(keys, "POST", "/api/v1/agent", {
|
|
47361
47465
|
publicKey: keys.publicKey,
|
|
47362
47466
|
signer: keys.signer.address,
|
|
47363
|
-
...
|
|
47467
|
+
...this.#settings.invite ? { invite: this.#settings.invite } : {}
|
|
47364
47468
|
})
|
|
47365
47469
|
);
|
|
47366
47470
|
} catch (error62) {
|
|
@@ -47383,9 +47487,6 @@ var Wallet = class {
|
|
|
47383
47487
|
const keys = await this.#keys();
|
|
47384
47488
|
return parseAgent(await this.#request(keys, "GET", "/api/v1/agent"));
|
|
47385
47489
|
}
|
|
47386
|
-
async claim() {
|
|
47387
|
-
return this.#request(await this.#keys(), "POST", "/api/v1/agent/claim");
|
|
47388
|
-
}
|
|
47389
47490
|
async transaction(hash5) {
|
|
47390
47491
|
return parseTransaction(await this.#request(await this.#keys(), "GET", `/api/v1/transaction/${hash5}`));
|
|
47391
47492
|
}
|
|
@@ -47405,7 +47506,7 @@ var Wallet = class {
|
|
|
47405
47506
|
value: call2.value.toString(),
|
|
47406
47507
|
data: call2.data
|
|
47407
47508
|
}));
|
|
47408
|
-
const tx = await this.#verify(quote2,
|
|
47509
|
+
const tx = await this.#verify(quote2, keys, call2);
|
|
47409
47510
|
const signature = await keys.signer.signTypedData(safeTypedData(this.#settings.config.chain.id, safe, tx));
|
|
47410
47511
|
const result = parseTransaction(await this.#request(keys, "POST", "/api/v1/transaction", {
|
|
47411
47512
|
to: tx.to,
|
|
@@ -47424,25 +47525,6 @@ var Wallet = class {
|
|
|
47424
47525
|
serviceFeeLimitWei: (BigInt(quote2.feeGas) * tx.gasPrice).toString()
|
|
47425
47526
|
};
|
|
47426
47527
|
}
|
|
47427
|
-
// 引き取ったアカウントの owner を、Safe の復旧用オーナーに加える。
|
|
47428
|
-
// 加える相手は、人間から直接受け取ったアドレス(expected)で決める。サーバーの申告だけで決めると、
|
|
47429
|
-
// 乗っ取られたサーバーが自分のアドレスを返して Safe のオーナーに入り込める。
|
|
47430
|
-
async addRecoveryOwner(expected) {
|
|
47431
|
-
const keys = await this.#keys();
|
|
47432
|
-
const safe = keys.registration.safe;
|
|
47433
|
-
const owner = getAddress(expected);
|
|
47434
|
-
const agent = await this.info();
|
|
47435
|
-
if (!agent.recoveryOwner || !isAddressEqual(agent.recoveryOwner, owner)) {
|
|
47436
|
-
throw new WalletError("\u4EBA\u9593\u304B\u3089\u53D7\u3051\u53D6\u3063\u305F\u30A2\u30C9\u30EC\u30B9\u304C\u3001nyquist \u306B\u767B\u9332\u3055\u308C\u305F\u5FA9\u65E7\u7528\u30AA\u30FC\u30CA\u30FC\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093");
|
|
47437
|
-
}
|
|
47438
|
-
const owners = await this.#owners(safe);
|
|
47439
|
-
if (owners.some((address2) => isAddressEqual(address2, owner))) {
|
|
47440
|
-
throw new WalletError(`${owner} \u306F\u3059\u3067\u306B Safe \u306E\u30AA\u30FC\u30CA\u30FC\u3067\u3059`);
|
|
47441
|
-
}
|
|
47442
|
-
const result = await this.#send(keys, { to: safe, value: 0n, data: encodeAddOwner(owner, 1) });
|
|
47443
|
-
return { ...result, owner };
|
|
47444
|
-
}
|
|
47445
|
-
// Safe のオーナーをチェーンから読む。作成前は自分の signer だけ。
|
|
47446
47528
|
// Safe のオーナーと閾値をチェーンから読む。サーバーの申告は使わない。作成前は自分の signer だけ。
|
|
47447
47529
|
// サーバーの申告をそのままエージェントに見せると、乗っ取られたサーバーが攻撃者のアドレスを混ぜられる。
|
|
47448
47530
|
async onchain() {
|
|
@@ -47457,15 +47539,10 @@ var Wallet = class {
|
|
|
47457
47539
|
]);
|
|
47458
47540
|
return { safe, owners: owners.map((owner) => getAddress(owner)), threshold: Number(threshold), deployed: true };
|
|
47459
47541
|
}
|
|
47460
|
-
async #owners(safe) {
|
|
47461
|
-
const client = this.#client();
|
|
47462
|
-
const code = await client.getCode({ address: safe });
|
|
47463
|
-
if (code === void 0 || code === "0x") return [];
|
|
47464
|
-
return client.readContract({ address: safe, abi: SAFE_ABI, functionName: "getOwners" });
|
|
47465
|
-
}
|
|
47466
47542
|
// サーバーを信じきらず、署名する内容を手元で組み立てて確かめる。
|
|
47467
|
-
async #verify(quote2,
|
|
47543
|
+
async #verify(quote2, keys, call2) {
|
|
47468
47544
|
const { config: config2, maxFeeWei } = this.#settings;
|
|
47545
|
+
const safe = keys.registration.safe;
|
|
47469
47546
|
if (quote2.chainId !== config2.chain.id) throw new QuoteRejected(`chainId \u304C ${config2.chain.id} \u3067\u306F\u3042\u308A\u307E\u305B\u3093`);
|
|
47470
47547
|
if (!isAddressEqual(quote2.safe, safe)) throw new QuoteRejected("\u898B\u7A4D\u3082\u308A\u306E Safe \u304C\u767B\u9332\u6642\u306E Safe \u3068\u9055\u3044\u307E\u3059");
|
|
47471
47548
|
if (!isAddressEqual(quote2.gasToken, zeroAddress)) throw new QuoteRejected("\u30AC\u30B9\u4EE3\u306F ETH \u4EE5\u5916\u3067\u6255\u3048\u307E\u305B\u3093");
|
|
@@ -47486,15 +47563,6 @@ var Wallet = class {
|
|
|
47486
47563
|
if (safeTxHash(config2.chain.id, safe, tx) !== quote2.safeTxHash) {
|
|
47487
47564
|
throw new QuoteRejected("SafeTx \u306E\u30CF\u30C3\u30B7\u30E5\u304C\u624B\u5143\u306E\u8A08\u7B97\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093");
|
|
47488
47565
|
}
|
|
47489
|
-
const calldata = encodeExecTransaction({ ...tx, safeTxGas: 0n, baseGas: 0n, gasPrice: 0n }, `0x${"ff".repeat(65)}`);
|
|
47490
|
-
const intrinsic = 21000n + calldataGas(calldata);
|
|
47491
|
-
const floor = calldataFloorGas(calldata);
|
|
47492
|
-
const overhead = BigInt(config2.relayer.baseGasOverhead) + BigInt(config2.relayer.firstExecutionGas);
|
|
47493
|
-
const gasLimit = (intrinsic > floor ? intrinsic : floor) + overhead * 2n;
|
|
47494
|
-
const feeLimit = (tx.safeTxGas + gasLimit) * BigInt(config2.relayer.feeBps) / 10000n;
|
|
47495
|
-
if (BigInt(quote2.feeGas) > feeLimit) throw new QuoteRejected("\u624B\u6570\u6599\u304C\u516C\u958B\u3057\u3066\u3044\u308B\u5272\u5408\u3092\u8D85\u3048\u3066\u3044\u307E\u3059");
|
|
47496
|
-
const baseGasLimit = gasLimit + feeLimit;
|
|
47497
|
-
if (tx.baseGas > baseGasLimit) throw new QuoteRejected(`baseGas \u304C\u5927\u304D\u3059\u304E\u307E\u3059\u3002\u4E0A\u9650\u306F ${baseGasLimit} \u3067\u3059`);
|
|
47498
47566
|
if (tx.safeTxGas > BigInt(config2.relayer.gasLimitCap)) throw new QuoteRejected("safeTxGas \u304C\u5927\u304D\u3059\u304E\u307E\u3059");
|
|
47499
47567
|
const client = this.#client();
|
|
47500
47568
|
const code = await client.getCode({ address: safe });
|
|
@@ -47508,6 +47576,27 @@ var Wallet = class {
|
|
|
47508
47576
|
throw new QuoteRejected("Safe \u304B\u3089\u547C\u3073\u51FA\u3059\u3068 revert \u3057\u307E\u3059\u3002\u5B9B\u5148\u3001\u91D1\u984D\u3001Safe \u306E\u6B8B\u9AD8\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
47509
47577
|
}
|
|
47510
47578
|
if (tx.safeTxGas < needed) throw new QuoteRejected(`safeTxGas \u304C\u5C0F\u3055\u3059\u304E\u307E\u3059\u3002${needed} \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059`);
|
|
47579
|
+
const undeployed = deployed ? 0n : BigInt(config2.relayer.undeployedSafeTxGas);
|
|
47580
|
+
const safeTxGasLimit = needed * 2n > undeployed ? needed * 2n : undeployed;
|
|
47581
|
+
if (tx.safeTxGas > safeTxGasLimit) throw new QuoteRejected(`safeTxGas \u304C\u5927\u304D\u3059\u304E\u307E\u3059\u3002\u4E0A\u9650\u306F ${safeTxGasLimit} \u3067\u3059`);
|
|
47582
|
+
let deploymentGas = 0n;
|
|
47583
|
+
if (!deployed && BigInt(config2.relayer.deploymentFeeWei) === 0n) {
|
|
47584
|
+
const estimated = await client.estimateGas({
|
|
47585
|
+
account: config2.relayerAddress,
|
|
47586
|
+
to: config2.safe.proxyFactory,
|
|
47587
|
+
data: encodeCreateProxy(config2.safe.singleton, this.#initializer(keys), saltNonce(keys.agentId))
|
|
47588
|
+
});
|
|
47589
|
+
deploymentGas = estimated * 12n / 10n;
|
|
47590
|
+
}
|
|
47591
|
+
const calldata = encodeExecTransaction({ ...tx, safeTxGas: 0n, baseGas: 0n, gasPrice: 0n }, `0x${"ff".repeat(65)}`);
|
|
47592
|
+
const intrinsic = 21000n + calldataGas(calldata);
|
|
47593
|
+
const floor = calldataFloorGas(calldata);
|
|
47594
|
+
const overhead = BigInt(config2.relayer.baseGasOverhead) + BigInt(config2.relayer.firstExecutionGas);
|
|
47595
|
+
const gasLimit = (intrinsic > floor ? intrinsic : floor) + overhead * 2n + deploymentGas;
|
|
47596
|
+
const feeLimit = (tx.safeTxGas + gasLimit) * BigInt(config2.relayer.feeBps) / 10000n;
|
|
47597
|
+
if (BigInt(quote2.feeGas) > feeLimit) throw new QuoteRejected("\u624B\u6570\u6599\u304C\u516C\u958B\u3057\u3066\u3044\u308B\u5272\u5408\u3092\u8D85\u3048\u3066\u3044\u307E\u3059");
|
|
47598
|
+
const baseGasLimit = gasLimit + feeLimit;
|
|
47599
|
+
if (tx.baseGas > baseGasLimit) throw new QuoteRejected(`baseGas \u304C\u5927\u304D\u3059\u304E\u307E\u3059\u3002\u4E0A\u9650\u306F ${baseGasLimit} \u3067\u3059`);
|
|
47511
47600
|
const { maxFeePerGas } = await client.estimateFeesPerGas();
|
|
47512
47601
|
const priceLimit = maxFeePerGas * BigInt(config2.relayer.gasPriceMultiplier + 1);
|
|
47513
47602
|
if (tx.gasPrice > priceLimit) throw new QuoteRejected("gasPrice \u304C\u73FE\u5728\u306E\u30AC\u30B9\u4EE3\u306B\u6BD4\u3079\u3066\u9AD8\u3059\u304E\u307E\u3059");
|
|
@@ -47528,7 +47617,7 @@ import { readFile as readFile2, rename as rename2, stat, writeFile as writeFile2
|
|
|
47528
47617
|
import { homedir as homedir2 } from "node:os";
|
|
47529
47618
|
import { dirname, join as join3 } from "node:path";
|
|
47530
47619
|
var MCP_PACKAGE = "nyquist-mcp";
|
|
47531
|
-
var MCP_VERSION = true ? "0.
|
|
47620
|
+
var MCP_VERSION = true ? "0.2.0" : "latest";
|
|
47532
47621
|
var MCP_SPEC = `${MCP_PACKAGE}@${MCP_VERSION}`;
|
|
47533
47622
|
var AGENTS = [
|
|
47534
47623
|
{ value: "claude-code", label: "Claude Code" },
|
|
@@ -47537,9 +47626,12 @@ var AGENTS = [
|
|
|
47537
47626
|
{ value: "grok", label: "Grok Bot", hint: "runs in the cloud" },
|
|
47538
47627
|
{ value: "other", label: "Other MCP client" }
|
|
47539
47628
|
];
|
|
47540
|
-
function server(env, prefix, spec) {
|
|
47629
|
+
function server(name, env, prefix, spec) {
|
|
47541
47630
|
const args = [`--prefix=${prefix}`, "-y", "--package", spec ?? MCP_SPEC, MCP_PACKAGE];
|
|
47542
|
-
return { command: "npx", args, env };
|
|
47631
|
+
return { name, command: "npx", args, env };
|
|
47632
|
+
}
|
|
47633
|
+
function entry(value) {
|
|
47634
|
+
return { command: value.command, args: value.args, ...Object.keys(value.env).length ? { env: value.env } : {} };
|
|
47543
47635
|
}
|
|
47544
47636
|
function has(command) {
|
|
47545
47637
|
return spawnSync(command, ["--version"], { stdio: "ignore" }).status === 0;
|
|
@@ -47552,23 +47644,22 @@ function quote(argument) {
|
|
|
47552
47644
|
return /^[A-Za-z0-9_@%+=:,./-]+$/.test(argument) ? argument : `'${argument.replaceAll("'", `'\\''`)}'`;
|
|
47553
47645
|
}
|
|
47554
47646
|
function json2(value) {
|
|
47555
|
-
|
|
47556
|
-
return JSON.stringify({ nyquist: Object.keys(env).length ? value : rest }, null, 2);
|
|
47647
|
+
return JSON.stringify({ [value.name]: entry(value) }, null, 2);
|
|
47557
47648
|
}
|
|
47558
47649
|
function claudeCode(value) {
|
|
47559
47650
|
const envArgs = Object.entries(value.env).flatMap(([key, v]) => ["-e", `${key}=${v}`]);
|
|
47560
|
-
const args = ["mcp", "add",
|
|
47651
|
+
const args = ["mcp", "add", value.name, "--scope", "user", ...envArgs, "--", value.command, ...value.args];
|
|
47561
47652
|
if (!has("claude")) {
|
|
47562
47653
|
return { kind: "manual", message: "Claude Code's CLI was not found. Run this to add nyquist:", snippet: `claude ${args.map(quote).join(" ")}` };
|
|
47563
47654
|
}
|
|
47564
|
-
if (run("claude", ["mcp", "get",
|
|
47565
|
-
return { kind: "exists", message:
|
|
47655
|
+
if (run("claude", ["mcp", "get", value.name]).ok) {
|
|
47656
|
+
return { kind: "exists", message: `Claude Code already has an MCP server called ${value.name}` };
|
|
47566
47657
|
}
|
|
47567
47658
|
const added = run("claude", args);
|
|
47568
47659
|
if (!added.ok) throw new Error(`claude mcp add failed: ${added.output}`);
|
|
47569
|
-
return { kind: "added", message:
|
|
47660
|
+
return { kind: "added", message: `Added ${value.name} to Claude Code's MCP settings`, next: "Start a new Claude Code session to load it." };
|
|
47570
47661
|
}
|
|
47571
|
-
function
|
|
47662
|
+
function openClawHas(output2, name) {
|
|
47572
47663
|
let parsed;
|
|
47573
47664
|
try {
|
|
47574
47665
|
parsed = JSON.parse(output2);
|
|
@@ -47576,32 +47667,31 @@ function openClawHasNyquist(output2) {
|
|
|
47576
47667
|
return void 0;
|
|
47577
47668
|
}
|
|
47578
47669
|
const servers = typeof parsed === "object" && parsed !== null && "servers" in parsed ? parsed.servers : parsed;
|
|
47579
|
-
if (Array.isArray(servers)) return servers.some((server2) => typeof server2 === "object" && server2 !== null && server2.name ===
|
|
47580
|
-
if (typeof servers === "object" && servers !== null) return Object.hasOwn(servers,
|
|
47670
|
+
if (Array.isArray(servers)) return servers.some((server2) => typeof server2 === "object" && server2 !== null && server2.name === name);
|
|
47671
|
+
if (typeof servers === "object" && servers !== null) return Object.hasOwn(servers, name);
|
|
47581
47672
|
return void 0;
|
|
47582
47673
|
}
|
|
47583
47674
|
function openClaw(value) {
|
|
47584
|
-
const body = JSON.stringify(
|
|
47675
|
+
const body = JSON.stringify(entry(value));
|
|
47585
47676
|
if (!has("openclaw")) {
|
|
47586
47677
|
return { kind: "manual", message: "OpenClaw's CLI was not found. Add this under mcp.servers in OpenClaw's config:", snippet: json2(value) };
|
|
47587
47678
|
}
|
|
47588
47679
|
const listed = run("openclaw", ["mcp", "list", "--json"]);
|
|
47589
|
-
const existing = listed.ok ?
|
|
47590
|
-
if (existing === true) return { kind: "exists", message:
|
|
47680
|
+
const existing = listed.ok ? openClawHas(listed.output, value.name) : void 0;
|
|
47681
|
+
if (existing === true) return { kind: "exists", message: `OpenClaw already has an MCP server called ${value.name}` };
|
|
47591
47682
|
if (existing === void 0) {
|
|
47592
47683
|
return { kind: "manual", message: "Could not read OpenClaw's MCP settings. Add this under mcp.servers in OpenClaw's config:", snippet: json2(value) };
|
|
47593
47684
|
}
|
|
47594
|
-
const added = run("openclaw", ["mcp", "set",
|
|
47685
|
+
const added = run("openclaw", ["mcp", "set", value.name, body]);
|
|
47595
47686
|
if (!added.ok) throw new Error(`openclaw mcp set failed: ${added.output}`);
|
|
47596
|
-
return { kind: "added", message:
|
|
47687
|
+
return { kind: "added", message: `Added ${value.name} to OpenClaw's MCP settings`, next: "Restart the OpenClaw gateway to load it." };
|
|
47597
47688
|
}
|
|
47598
47689
|
async function hermes(value) {
|
|
47599
47690
|
const home = process.env.HERMES_HOME ?? join3(homedir2(), ".hermes");
|
|
47600
47691
|
const path = join3(home, "config.yaml");
|
|
47601
|
-
const entry = { command: value.command, args: value.args, ...Object.keys(value.env).length ? { env: value.env } : {} };
|
|
47602
47692
|
if (!existsSync(path)) {
|
|
47603
47693
|
const snippet = (0, import_yaml.parseDocument)("mcp_servers: {}");
|
|
47604
|
-
snippet.setIn(["mcp_servers",
|
|
47694
|
+
snippet.setIn(["mcp_servers", value.name], entry(value));
|
|
47605
47695
|
return { kind: "manual", message: `${path} was not found. Add this to Hermes Agent's config.yaml:`, snippet: snippet.toString({ flowCollectionPadding: false }) };
|
|
47606
47696
|
}
|
|
47607
47697
|
const document = (0, import_yaml.parseDocument)(await readFile2(path, "utf8"));
|
|
@@ -47610,15 +47700,15 @@ async function hermes(value) {
|
|
|
47610
47700
|
if (servers === void 0 || servers === null || (0, import_yaml.isScalar)(servers) && servers.value === null) {
|
|
47611
47701
|
document.set("mcp_servers", document.createNode({}));
|
|
47612
47702
|
} else if (!(0, import_yaml.isMap)(servers)) {
|
|
47613
|
-
throw new Error(`mcp_servers in ${path} is not a map. Add
|
|
47614
|
-
} else if (servers.has(
|
|
47615
|
-
return { kind: "exists", message: `${path} already has an MCP server called
|
|
47703
|
+
throw new Error(`mcp_servers in ${path} is not a map. Add ${value.name} to it by hand.`);
|
|
47704
|
+
} else if (servers.has(value.name)) {
|
|
47705
|
+
return { kind: "exists", message: `${path} already has an MCP server called ${value.name}` };
|
|
47616
47706
|
}
|
|
47617
|
-
document.setIn(["mcp_servers",
|
|
47707
|
+
document.setIn(["mcp_servers", value.name], document.createNode(entry(value)));
|
|
47618
47708
|
const temporary = join3(dirname(path), `.config.yaml.${randomUUID2()}.tmp`);
|
|
47619
47709
|
await writeFile2(temporary, document.toString({ flowCollectionPadding: false }), { mode: (await stat(path)).mode & 511, flag: "wx" });
|
|
47620
47710
|
await rename2(temporary, path);
|
|
47621
|
-
return { kind: "added", message: `Added
|
|
47711
|
+
return { kind: "added", message: `Added ${value.name} to ${path}`, next: "Run /reload-mcp in Hermes, or start a new session." };
|
|
47622
47712
|
}
|
|
47623
47713
|
async function install(agent, value) {
|
|
47624
47714
|
switch (agent) {
|
|
@@ -47629,7 +47719,7 @@ async function install(agent, value) {
|
|
|
47629
47719
|
case "hermes":
|
|
47630
47720
|
return hermes(value);
|
|
47631
47721
|
case "other":
|
|
47632
|
-
return { kind: "manual", message:
|
|
47722
|
+
return { kind: "manual", message: `Register ${value.name} as a stdio MCP server in your client:`, snippet: json2(value) };
|
|
47633
47723
|
}
|
|
47634
47724
|
}
|
|
47635
47725
|
|
|
@@ -47637,14 +47727,14 @@ async function install(agent, value) {
|
|
|
47637
47727
|
var HELP = `Usage: npm create nyquist [-- options]
|
|
47638
47728
|
|
|
47639
47729
|
Options:
|
|
47730
|
+
--network <name> mainnet or sepolia
|
|
47640
47731
|
--agent <id> claude-code, hermes, openclaw, grok, or other
|
|
47641
|
-
--enrollment <token> Join an organization with an enrollment token
|
|
47642
47732
|
-h, --help Show this help`;
|
|
47643
47733
|
var PASSED_ENV = ["NYQUIST_ENV", "NYQUIST_API_URL", "NYQUIST_RPC_URL", "NYQUIST_HOME", "NYQUIST_MAX_FEE_WEI"];
|
|
47644
47734
|
var { values } = parseArgs({
|
|
47645
47735
|
options: {
|
|
47736
|
+
network: { type: "string" },
|
|
47646
47737
|
agent: { type: "string" },
|
|
47647
|
-
enrollment: { type: "string" },
|
|
47648
47738
|
help: { type: "boolean", short: "h" }
|
|
47649
47739
|
}
|
|
47650
47740
|
});
|
|
@@ -47668,14 +47758,51 @@ async function chooseAgent() {
|
|
|
47668
47758
|
}
|
|
47669
47759
|
return answer;
|
|
47670
47760
|
}
|
|
47761
|
+
var NETWORKS = [
|
|
47762
|
+
{ value: "mainnet", label: "Ethereum mainnet", hint: "real ETH" },
|
|
47763
|
+
{ value: "sepolia", label: "Sepolia testnet", hint: "test ETH, no fees" }
|
|
47764
|
+
];
|
|
47765
|
+
var NETWORK = {
|
|
47766
|
+
mainnet: { environment: "mainnet", name: "nyquist-mainnet" },
|
|
47767
|
+
sepolia: { environment: "production", name: "nyquist" }
|
|
47768
|
+
};
|
|
47769
|
+
async function chooseNetwork() {
|
|
47770
|
+
if (process.env.NYQUIST_ENV) {
|
|
47771
|
+
if (values.network) throw new Error("Use either --network or NYQUIST_ENV, not both");
|
|
47772
|
+
return null;
|
|
47773
|
+
}
|
|
47774
|
+
if (values.network) {
|
|
47775
|
+
const found = NETWORKS.find((network) => network.value === values.network);
|
|
47776
|
+
if (!found) throw new Error(`Unknown network "${values.network}". Use one of: ${NETWORKS.map((network) => network.value).join(", ")}`);
|
|
47777
|
+
return found.value;
|
|
47778
|
+
}
|
|
47779
|
+
const answer = await select({ message: "Which network?", options: NETWORKS });
|
|
47780
|
+
if (isCancel(answer)) {
|
|
47781
|
+
cancel("Cancelled");
|
|
47782
|
+
process.exit(0);
|
|
47783
|
+
}
|
|
47784
|
+
return answer;
|
|
47785
|
+
}
|
|
47671
47786
|
async function main() {
|
|
47672
47787
|
intro("nyquist");
|
|
47788
|
+
const network = await chooseNetwork();
|
|
47789
|
+
if (network === "mainnet") process.env.NYQUIST_ENV = NETWORK.mainnet.environment;
|
|
47790
|
+
const name = process.env.NYQUIST_ENV === "mainnet" ? NETWORK.mainnet.name : NETWORK.sepolia.name;
|
|
47673
47791
|
const agent = await chooseAgent();
|
|
47674
47792
|
if (agent === "grok") {
|
|
47675
|
-
|
|
47793
|
+
const env2 = process.env.NYQUIST_ENV === "mainnet" ? ", with the environment variable NYQUIST_ENV=mainnet" : "";
|
|
47794
|
+
note(`Add an MCP server called ${name} that runs: npx -y ${MCP_SPEC}${env2}`, "Ask Grok Bot in chat");
|
|
47676
47795
|
outro("Grok Bot creates the keys on its own computer. Then ask it to call nyquist_setup.");
|
|
47677
47796
|
return;
|
|
47678
47797
|
}
|
|
47798
|
+
if (process.env.NYQUIST_ENV === "mainnet" && !process.env.NYQUIST_INVITE && loadSettings().config.registration === "invite") {
|
|
47799
|
+
const invite = await password({ message: "Invite code (registration is invite-only for now)" });
|
|
47800
|
+
if (isCancel(invite)) {
|
|
47801
|
+
cancel("Cancelled");
|
|
47802
|
+
process.exit(0);
|
|
47803
|
+
}
|
|
47804
|
+
process.env.NYQUIST_INVITE = invite;
|
|
47805
|
+
}
|
|
47679
47806
|
const settings2 = loadSettings();
|
|
47680
47807
|
const keystore = new Keystore(settings2.home, settings2.environment);
|
|
47681
47808
|
const wallet = new Wallet(settings2, keystore);
|
|
@@ -47688,7 +47815,7 @@ async function main() {
|
|
|
47688
47815
|
let safe;
|
|
47689
47816
|
let feeWei;
|
|
47690
47817
|
try {
|
|
47691
|
-
const { agent: registered } = await wallet.setup(
|
|
47818
|
+
const { agent: registered } = await wallet.setup();
|
|
47692
47819
|
safe = registered.safe;
|
|
47693
47820
|
feeWei = registered.deploymentFeeWei;
|
|
47694
47821
|
} catch (error62) {
|
|
@@ -47697,7 +47824,7 @@ async function main() {
|
|
|
47697
47824
|
}
|
|
47698
47825
|
register.stop(`Registered the wallet Safe ${short(safe)}`);
|
|
47699
47826
|
const env = Object.fromEntries(PASSED_ENV.flatMap((key) => process.env[key] ? [[key, process.env[key]]] : []));
|
|
47700
|
-
const result = await install(agent, server(env, settings2.home, process.env.NYQUIST_MCP_PACKAGE));
|
|
47827
|
+
const result = await install(agent, server(name, env, settings2.home, process.env.NYQUIST_MCP_PACKAGE));
|
|
47701
47828
|
if (result.kind === "manual") {
|
|
47702
47829
|
log.warn(result.message);
|
|
47703
47830
|
note(result.snippet);
|
|
@@ -47711,8 +47838,7 @@ async function main() {
|
|
|
47711
47838
|
`Chain ${settings2.config.chain.name}`,
|
|
47712
47839
|
`Key file ${keystore.path}`,
|
|
47713
47840
|
"",
|
|
47714
|
-
`Fund the Safe with at least ${formatEther2(BigInt(feeWei))} ETH for its creation,`,
|
|
47715
|
-
"plus what you want to send. Then ask your agent:",
|
|
47841
|
+
...BigInt(feeWei) === 0n ? ["Fund the Safe with what you want to send, plus gas.", "The first send also creates the Safe. Then ask your agent:"] : [`Fund the Safe with at least ${formatEther2(BigInt(feeWei))} ETH for its creation,`, "plus what you want to send. Then ask your agent:"],
|
|
47716
47842
|
'"Send 0.01 ETH to 0x\u2026"'
|
|
47717
47843
|
].join("\n"),
|
|
47718
47844
|
"Next"
|