@settlemint/sdk-cli 2.3.14 → 2.4.0-main1ce5f55f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +1583 -650
- package/dist/cli.js.map +100 -65
- package/package.json +14 -11
package/dist/cli.js
CHANGED
@@ -5149,7 +5149,7 @@ var require_sha2 = __commonJS((exports) => {
|
|
5149
5149
|
exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224);
|
5150
5150
|
});
|
5151
5151
|
|
5152
|
-
// ../../node_modules/@noble/curves/abstract/utils.js
|
5152
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/utils.js
|
5153
5153
|
var require_utils5 = __commonJS((exports) => {
|
5154
5154
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
5155
5155
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -5423,7 +5423,7 @@ var require_utils5 = __commonJS((exports) => {
|
|
5423
5423
|
}
|
5424
5424
|
});
|
5425
5425
|
|
5426
|
-
// ../../node_modules/@noble/curves/abstract/modular.js
|
5426
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/modular.js
|
5427
5427
|
var require_modular = __commonJS((exports) => {
|
5428
5428
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5429
5429
|
exports.isNegativeLE = undefined;
|
@@ -5753,7 +5753,7 @@ var require_modular = __commonJS((exports) => {
|
|
5753
5753
|
}
|
5754
5754
|
});
|
5755
5755
|
|
5756
|
-
// ../../node_modules/@noble/curves/abstract/curve.js
|
5756
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/curve.js
|
5757
5757
|
var require_curve = __commonJS((exports) => {
|
5758
5758
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5759
5759
|
exports.wNAF = wNAF;
|
@@ -6002,7 +6002,7 @@ var require_curve = __commonJS((exports) => {
|
|
6002
6002
|
}
|
6003
6003
|
});
|
6004
6004
|
|
6005
|
-
// ../../node_modules/@noble/curves/abstract/edwards.js
|
6005
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/edwards.js
|
6006
6006
|
var require_edwards = __commonJS((exports) => {
|
6007
6007
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6008
6008
|
exports.twistedEdwards = twistedEdwards;
|
@@ -6361,7 +6361,7 @@ var require_edwards = __commonJS((exports) => {
|
|
6361
6361
|
}
|
6362
6362
|
});
|
6363
6363
|
|
6364
|
-
// ../../node_modules/@noble/curves/abstract/hash-to-curve.js
|
6364
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/hash-to-curve.js
|
6365
6365
|
var require_hash_to_curve = __commonJS((exports) => {
|
6366
6366
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6367
6367
|
exports.expand_message_xmd = expand_message_xmd;
|
@@ -6514,7 +6514,7 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6514
6514
|
}
|
6515
6515
|
});
|
6516
6516
|
|
6517
|
-
// ../../node_modules/@noble/curves/abstract/montgomery.js
|
6517
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/montgomery.js
|
6518
6518
|
var require_montgomery = __commonJS((exports) => {
|
6519
6519
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6520
6520
|
exports.montgomery = montgomery;
|
@@ -6621,7 +6621,7 @@ var require_montgomery = __commonJS((exports) => {
|
|
6621
6621
|
}
|
6622
6622
|
});
|
6623
6623
|
|
6624
|
-
// ../../node_modules/@noble/curves/ed25519.js
|
6624
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/ed25519.js
|
6625
6625
|
var require_ed25519 = __commonJS((exports) => {
|
6626
6626
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6627
6627
|
exports.hash_to_ristretto255 = exports.hashToRistretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.ed25519_hasher = exports.edwardsToMontgomery = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = undefined;
|
@@ -7061,7 +7061,7 @@ var require_hmac = __commonJS((exports) => {
|
|
7061
7061
|
exports.hmac.create = (hash, key) => new HMAC(hash, key);
|
7062
7062
|
});
|
7063
7063
|
|
7064
|
-
// ../../node_modules/@noble/curves/abstract/weierstrass.js
|
7064
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/weierstrass.js
|
7065
7065
|
var require_weierstrass = __commonJS((exports) => {
|
7066
7066
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7067
7067
|
exports.DER = exports.DERErr = undefined;
|
@@ -7980,7 +7980,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7980
7980
|
}
|
7981
7981
|
});
|
7982
7982
|
|
7983
|
-
// ../../node_modules/@noble/curves/_shortw_utils.js
|
7983
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/_shortw_utils.js
|
7984
7984
|
var require__shortw_utils = __commonJS((exports) => {
|
7985
7985
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7986
7986
|
exports.getHash = getHash;
|
@@ -8002,7 +8002,7 @@ var require__shortw_utils = __commonJS((exports) => {
|
|
8002
8002
|
}
|
8003
8003
|
});
|
8004
8004
|
|
8005
|
-
// ../../node_modules/@noble/curves/secp256k1.js
|
8005
|
+
// ../../node_modules/eciesjs/node_modules/@noble/curves/secp256k1.js
|
8006
8006
|
var require_secp256k1 = __commonJS((exports) => {
|
8007
8007
|
Object.defineProperty(exports, "__esModule", { value: true });
|
8008
8008
|
exports.encodeToCurve = exports.hashToCurve = exports.secp256k1_hasher = exports.schnorr = exports.secp256k1 = undefined;
|
@@ -48857,7 +48857,7 @@ var require_typescript = __commonJS((exports, module) => {
|
|
48857
48857
|
tryGetPropertyNameOfBindingOrAssignmentElement: () => tryGetPropertyNameOfBindingOrAssignmentElement,
|
48858
48858
|
tryGetSourceMappingURL: () => tryGetSourceMappingURL,
|
48859
48859
|
tryGetTextOfPropertyName: () => tryGetTextOfPropertyName,
|
48860
|
-
tryParseJson: () =>
|
48860
|
+
tryParseJson: () => tryParseJson5,
|
48861
48861
|
tryParsePattern: () => tryParsePattern,
|
48862
48862
|
tryParsePatterns: () => tryParsePatterns,
|
48863
48863
|
tryParseRawSourceMap: () => tryParseRawSourceMap,
|
@@ -66862,7 +66862,7 @@ ${lanes.join(`
|
|
66862
66862
|
function readJson(path7, host) {
|
66863
66863
|
return readJsonOrUndefined(path7, host) || {};
|
66864
66864
|
}
|
66865
|
-
function
|
66865
|
+
function tryParseJson5(text) {
|
66866
66866
|
try {
|
66867
66867
|
return JSON.parse(text);
|
66868
66868
|
} catch {
|
@@ -92927,7 +92927,7 @@ ${lanes.join(`
|
|
92927
92927
|
if (isMissingPackageJsonInfo(cachedPackageJson) || !host.fileExists(packageJsonPath)) {
|
92928
92928
|
return;
|
92929
92929
|
}
|
92930
|
-
const packageJsonContent = (cachedPackageJson == null ? undefined : cachedPackageJson.contents.packageJsonContent) ||
|
92930
|
+
const packageJsonContent = (cachedPackageJson == null ? undefined : cachedPackageJson.contents.packageJsonContent) || tryParseJson5(host.readFile(packageJsonPath));
|
92931
92931
|
const imports = packageJsonContent == null ? undefined : packageJsonContent.imports;
|
92932
92932
|
if (!imports) {
|
92933
92933
|
return;
|
@@ -93013,7 +93013,7 @@ ${lanes.join(`
|
|
93013
93013
|
let maybeBlockedByTypesVersions = false;
|
93014
93014
|
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? undefined : _a.call(host)) == null ? undefined : _b.getPackageJsonInfo(packageJsonPath);
|
93015
93015
|
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
93016
|
-
const packageJsonContent = (cachedPackageJson == null ? undefined : cachedPackageJson.contents.packageJsonContent) ||
|
93016
|
+
const packageJsonContent = (cachedPackageJson == null ? undefined : cachedPackageJson.contents.packageJsonContent) || tryParseJson5(host.readFile(packageJsonPath));
|
93017
93017
|
const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
|
93018
93018
|
if (getResolvePackageJsonExports(options)) {
|
93019
93019
|
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
@@ -166185,7 +166185,7 @@ ${lanes.join(`
|
|
166185
166185
|
}
|
166186
166186
|
const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
166187
166187
|
const stringContent = host.readFile(fileName) || "";
|
166188
|
-
const content =
|
166188
|
+
const content = tryParseJson5(stringContent);
|
166189
166189
|
const info = {};
|
166190
166190
|
if (content) {
|
166191
166191
|
for (const key2 of dependencyKeys) {
|
@@ -204120,7 +204120,7 @@ ${options.prefix}` : `
|
|
204120
204120
|
tryGetPropertyNameOfBindingOrAssignmentElement: () => tryGetPropertyNameOfBindingOrAssignmentElement,
|
204121
204121
|
tryGetSourceMappingURL: () => tryGetSourceMappingURL,
|
204122
204122
|
tryGetTextOfPropertyName: () => tryGetTextOfPropertyName,
|
204123
|
-
tryParseJson: () =>
|
204123
|
+
tryParseJson: () => tryParseJson5,
|
204124
204124
|
tryParsePattern: () => tryParsePattern,
|
204125
204125
|
tryParsePatterns: () => tryParsePatterns,
|
204126
204126
|
tryParseRawSourceMap: () => tryParseRawSourceMap,
|
@@ -231623,7 +231623,7 @@ function size(value4) {
|
|
231623
231623
|
var init_size = () => {};
|
231624
231624
|
|
231625
231625
|
// ../../node_modules/viem/_esm/errors/version.js
|
231626
|
-
var version5 = "2.31.
|
231626
|
+
var version5 = "2.31.6";
|
231627
231627
|
|
231628
231628
|
// ../../node_modules/viem/_esm/errors/base.js
|
231629
231629
|
function walk(err, fn) {
|
@@ -232421,6 +232421,46 @@ function byteSwap32(arr) {
|
|
232421
232421
|
}
|
232422
232422
|
return arr;
|
232423
232423
|
}
|
232424
|
+
function bytesToHex2(bytes) {
|
232425
|
+
abytes(bytes);
|
232426
|
+
if (hasHexBuiltin)
|
232427
|
+
return bytes.toHex();
|
232428
|
+
let hex = "";
|
232429
|
+
for (let i6 = 0;i6 < bytes.length; i6++) {
|
232430
|
+
hex += hexes2[bytes[i6]];
|
232431
|
+
}
|
232432
|
+
return hex;
|
232433
|
+
}
|
232434
|
+
function asciiToBase16(ch) {
|
232435
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
232436
|
+
return ch - asciis._0;
|
232437
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
232438
|
+
return ch - (asciis.A - 10);
|
232439
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
232440
|
+
return ch - (asciis.a - 10);
|
232441
|
+
return;
|
232442
|
+
}
|
232443
|
+
function hexToBytes2(hex) {
|
232444
|
+
if (typeof hex !== "string")
|
232445
|
+
throw new Error("hex string expected, got " + typeof hex);
|
232446
|
+
if (hasHexBuiltin)
|
232447
|
+
return Uint8Array.fromHex(hex);
|
232448
|
+
const hl = hex.length;
|
232449
|
+
const al = hl / 2;
|
232450
|
+
if (hl % 2)
|
232451
|
+
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
232452
|
+
const array4 = new Uint8Array(al);
|
232453
|
+
for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
|
232454
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
232455
|
+
const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
|
232456
|
+
if (n1 === undefined || n22 === undefined) {
|
232457
|
+
const char = hex[hi] + hex[hi + 1];
|
232458
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
232459
|
+
}
|
232460
|
+
array4[ai] = n1 * 16 + n22;
|
232461
|
+
}
|
232462
|
+
return array4;
|
232463
|
+
}
|
232424
232464
|
function utf8ToBytes(str) {
|
232425
232465
|
if (typeof str !== "string")
|
232426
232466
|
throw new Error("string expected");
|
@@ -232467,12 +232507,15 @@ function randomBytes(bytesLength = 32) {
|
|
232467
232507
|
}
|
232468
232508
|
throw new Error("crypto.getRandomValues must be defined");
|
232469
232509
|
}
|
232470
|
-
var isLE, swap32IfBE;
|
232510
|
+
var isLE, swap32IfBE, hasHexBuiltin, hexes2, asciis;
|
232471
232511
|
var init_utils2 = __esm(() => {
|
232472
232512
|
init_cryptoNode();
|
232473
232513
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
232474
232514
|
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
232475
232515
|
swap32IfBE = isLE ? (u6) => u6 : byteSwap32;
|
232516
|
+
hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
232517
|
+
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
|
232518
|
+
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
232476
232519
|
});
|
232477
232520
|
|
232478
232521
|
// ../../node_modules/@noble/hashes/esm/sha3.js
|
@@ -235138,14 +235181,7 @@ var init_hmac = __esm(() => {
|
|
235138
235181
|
hmac.create = (hash2, key2) => new HMAC(hash2, key2);
|
235139
235182
|
});
|
235140
235183
|
|
235141
|
-
// ../../node_modules/@noble/curves/esm/
|
235142
|
-
function isBytes2(a7) {
|
235143
|
-
return a7 instanceof Uint8Array || ArrayBuffer.isView(a7) && a7.constructor.name === "Uint8Array";
|
235144
|
-
}
|
235145
|
-
function abytes2(item) {
|
235146
|
-
if (!isBytes2(item))
|
235147
|
-
throw new Error("Uint8Array expected");
|
235148
|
-
}
|
235184
|
+
// ../../node_modules/@noble/curves/esm/utils.js
|
235149
235185
|
function abool(title, value4) {
|
235150
235186
|
if (typeof value4 !== "boolean")
|
235151
235187
|
throw new Error(title + " boolean expected, got " + value4);
|
@@ -235159,51 +235195,11 @@ function hexToNumber2(hex) {
|
|
235159
235195
|
throw new Error("hex string expected, got " + typeof hex);
|
235160
235196
|
return hex === "" ? _0n2 : BigInt("0x" + hex);
|
235161
235197
|
}
|
235162
|
-
function bytesToHex2(bytes) {
|
235163
|
-
abytes2(bytes);
|
235164
|
-
if (hasHexBuiltin)
|
235165
|
-
return bytes.toHex();
|
235166
|
-
let hex = "";
|
235167
|
-
for (let i6 = 0;i6 < bytes.length; i6++) {
|
235168
|
-
hex += hexes2[bytes[i6]];
|
235169
|
-
}
|
235170
|
-
return hex;
|
235171
|
-
}
|
235172
|
-
function asciiToBase16(ch) {
|
235173
|
-
if (ch >= asciis._0 && ch <= asciis._9)
|
235174
|
-
return ch - asciis._0;
|
235175
|
-
if (ch >= asciis.A && ch <= asciis.F)
|
235176
|
-
return ch - (asciis.A - 10);
|
235177
|
-
if (ch >= asciis.a && ch <= asciis.f)
|
235178
|
-
return ch - (asciis.a - 10);
|
235179
|
-
return;
|
235180
|
-
}
|
235181
|
-
function hexToBytes2(hex) {
|
235182
|
-
if (typeof hex !== "string")
|
235183
|
-
throw new Error("hex string expected, got " + typeof hex);
|
235184
|
-
if (hasHexBuiltin)
|
235185
|
-
return Uint8Array.fromHex(hex);
|
235186
|
-
const hl = hex.length;
|
235187
|
-
const al = hl / 2;
|
235188
|
-
if (hl % 2)
|
235189
|
-
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
235190
|
-
const array4 = new Uint8Array(al);
|
235191
|
-
for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
|
235192
|
-
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
235193
|
-
const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
|
235194
|
-
if (n1 === undefined || n22 === undefined) {
|
235195
|
-
const char = hex[hi] + hex[hi + 1];
|
235196
|
-
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
235197
|
-
}
|
235198
|
-
array4[ai] = n1 * 16 + n22;
|
235199
|
-
}
|
235200
|
-
return array4;
|
235201
|
-
}
|
235202
235198
|
function bytesToNumberBE(bytes) {
|
235203
235199
|
return hexToNumber2(bytesToHex2(bytes));
|
235204
235200
|
}
|
235205
235201
|
function bytesToNumberLE(bytes) {
|
235206
|
-
|
235202
|
+
abytes(bytes);
|
235207
235203
|
return hexToNumber2(bytesToHex2(Uint8Array.from(bytes).reverse()));
|
235208
235204
|
}
|
235209
235205
|
function numberToBytesBE(n6, len) {
|
@@ -235220,7 +235216,7 @@ function ensureBytes(title, hex, expectedLength) {
|
|
235220
235216
|
} catch (e10) {
|
235221
235217
|
throw new Error(title + " must be hex string or Uint8Array, cause: " + e10);
|
235222
235218
|
}
|
235223
|
-
} else if (
|
235219
|
+
} else if (isBytes(hex)) {
|
235224
235220
|
res = Uint8Array.from(hex);
|
235225
235221
|
} else {
|
235226
235222
|
throw new Error(title + " must be hex string or Uint8Array");
|
@@ -235230,26 +235226,6 @@ function ensureBytes(title, hex, expectedLength) {
|
|
235230
235226
|
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
235231
235227
|
return res;
|
235232
235228
|
}
|
235233
|
-
function concatBytes3(...arrays) {
|
235234
|
-
let sum = 0;
|
235235
|
-
for (let i6 = 0;i6 < arrays.length; i6++) {
|
235236
|
-
const a7 = arrays[i6];
|
235237
|
-
abytes2(a7);
|
235238
|
-
sum += a7.length;
|
235239
|
-
}
|
235240
|
-
const res = new Uint8Array(sum);
|
235241
|
-
for (let i6 = 0, pad2 = 0;i6 < arrays.length; i6++) {
|
235242
|
-
const a7 = arrays[i6];
|
235243
|
-
res.set(a7, pad2);
|
235244
|
-
pad2 += a7.length;
|
235245
|
-
}
|
235246
|
-
return res;
|
235247
|
-
}
|
235248
|
-
function utf8ToBytes2(str) {
|
235249
|
-
if (typeof str !== "string")
|
235250
|
-
throw new Error("string expected");
|
235251
|
-
return new Uint8Array(new TextEncoder().encode(str));
|
235252
|
-
}
|
235253
235229
|
function inRange(n6, min, max) {
|
235254
235230
|
return isPosBig(n6) && isPosBig(min) && isPosBig(max) && min <= n6 && n6 < max;
|
235255
235231
|
}
|
@@ -235270,6 +235246,8 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235270
235246
|
throw new Error("qByteLen must be a number");
|
235271
235247
|
if (typeof hmacFn !== "function")
|
235272
235248
|
throw new Error("hmacFn must be a function");
|
235249
|
+
const u8n = (len) => new Uint8Array(len);
|
235250
|
+
const u8of = (byte) => Uint8Array.of(byte);
|
235273
235251
|
let v6 = u8n(hashLen);
|
235274
235252
|
let k5 = u8n(hashLen);
|
235275
235253
|
let i6 = 0;
|
@@ -235280,11 +235258,11 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235280
235258
|
};
|
235281
235259
|
const h8 = (...b4) => hmacFn(k5, v6, ...b4);
|
235282
235260
|
const reseed = (seed = u8n(0)) => {
|
235283
|
-
k5 = h8(
|
235261
|
+
k5 = h8(u8of(0), seed);
|
235284
235262
|
v6 = h8();
|
235285
235263
|
if (seed.length === 0)
|
235286
235264
|
return;
|
235287
|
-
k5 = h8(
|
235265
|
+
k5 = h8(u8of(1), seed);
|
235288
235266
|
v6 = h8();
|
235289
235267
|
};
|
235290
235268
|
const gen2 = () => {
|
@@ -235298,7 +235276,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235298
235276
|
out.push(sl);
|
235299
235277
|
len += v6.length;
|
235300
235278
|
}
|
235301
|
-
return
|
235279
|
+
return concatBytes(...out);
|
235302
235280
|
};
|
235303
235281
|
const genUntil = (seed, pred) => {
|
235304
235282
|
reset2();
|
@@ -235311,23 +235289,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235311
235289
|
};
|
235312
235290
|
return genUntil;
|
235313
235291
|
}
|
235314
|
-
function
|
235315
|
-
|
235316
|
-
|
235317
|
-
|
235318
|
-
|
235292
|
+
function isHash(val) {
|
235293
|
+
return typeof val === "function" && Number.isSafeInteger(val.outputLen);
|
235294
|
+
}
|
235295
|
+
function _validateObject(object4, fields, optFields = {}) {
|
235296
|
+
if (!object4 || typeof object4 !== "object")
|
235297
|
+
throw new Error("expected valid options object");
|
235298
|
+
function checkField(fieldName, expectedType, isOpt) {
|
235319
235299
|
const val = object4[fieldName];
|
235320
|
-
if (
|
235300
|
+
if (isOpt && val === undefined)
|
235321
235301
|
return;
|
235322
|
-
|
235323
|
-
|
235324
|
-
|
235325
|
-
}
|
235326
|
-
|
235327
|
-
|
235328
|
-
for (const [fieldName, type4] of Object.entries(optValidators))
|
235329
|
-
checkField(fieldName, type4, true);
|
235330
|
-
return object4;
|
235302
|
+
const current = typeof val;
|
235303
|
+
if (current !== expectedType || val === null)
|
235304
|
+
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
235305
|
+
}
|
235306
|
+
Object.entries(fields).forEach(([k5, v6]) => checkField(k5, v6, false));
|
235307
|
+
Object.entries(optFields).forEach(([k5, v6]) => checkField(k5, v6, true));
|
235331
235308
|
}
|
235332
235309
|
function memoized(fn) {
|
235333
235310
|
const map6 = new WeakMap;
|
@@ -235340,25 +235317,13 @@ function memoized(fn) {
|
|
235340
235317
|
return computed;
|
235341
235318
|
};
|
235342
235319
|
}
|
235343
|
-
var _0n2, _1n2,
|
235320
|
+
var _0n2, _1n2, isPosBig = (n6) => typeof n6 === "bigint" && _0n2 <= n6, bitMask = (n6) => (_1n2 << BigInt(n6)) - _1n2;
|
235344
235321
|
var init_utils3 = __esm(() => {
|
235322
|
+
init_utils2();
|
235323
|
+
init_utils2();
|
235345
235324
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235346
235325
|
_0n2 = /* @__PURE__ */ BigInt(0);
|
235347
235326
|
_1n2 = /* @__PURE__ */ BigInt(1);
|
235348
|
-
hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
235349
|
-
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
|
235350
|
-
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
235351
|
-
validatorFns = {
|
235352
|
-
bigint: (val) => typeof val === "bigint",
|
235353
|
-
function: (val) => typeof val === "function",
|
235354
|
-
boolean: (val) => typeof val === "boolean",
|
235355
|
-
string: (val) => typeof val === "string",
|
235356
|
-
stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
|
235357
|
-
isSafeInteger: (val) => Number.isSafeInteger(val),
|
235358
|
-
array: (val) => Array.isArray(val),
|
235359
|
-
field: (val, object4) => object4.Fp.isValid(val),
|
235360
|
-
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
235361
|
-
};
|
235362
235327
|
});
|
235363
235328
|
|
235364
235329
|
// ../../node_modules/@noble/curves/esm/abstract/modular.js
|
@@ -235472,14 +235437,15 @@ function validateField(field2) {
|
|
235472
235437
|
const initial = {
|
235473
235438
|
ORDER: "bigint",
|
235474
235439
|
MASK: "bigint",
|
235475
|
-
BYTES: "
|
235476
|
-
BITS: "
|
235440
|
+
BYTES: "number",
|
235441
|
+
BITS: "number"
|
235477
235442
|
};
|
235478
235443
|
const opts = FIELD_FIELDS.reduce((map6, val) => {
|
235479
235444
|
map6[val] = "function";
|
235480
235445
|
return map6;
|
235481
235446
|
}, initial);
|
235482
|
-
|
235447
|
+
_validateObject(field2, opts);
|
235448
|
+
return field2;
|
235483
235449
|
}
|
235484
235450
|
function FpPow(Fp, num, power) {
|
235485
235451
|
if (power < _0n3)
|
@@ -235532,10 +235498,28 @@ function nLength(n6, nBitLength) {
|
|
235532
235498
|
const nByteLength = Math.ceil(_nBitLength / 8);
|
235533
235499
|
return { nBitLength: _nBitLength, nByteLength };
|
235534
235500
|
}
|
235535
|
-
function Field(ORDER,
|
235501
|
+
function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
|
235536
235502
|
if (ORDER <= _0n3)
|
235537
235503
|
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
235538
|
-
|
235504
|
+
let _nbitLength = undefined;
|
235505
|
+
let _sqrt = undefined;
|
235506
|
+
if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
|
235507
|
+
if (opts.sqrt || isLE2)
|
235508
|
+
throw new Error("cannot specify opts in two arguments");
|
235509
|
+
const _opts = bitLenOrOpts;
|
235510
|
+
if (_opts.BITS)
|
235511
|
+
_nbitLength = _opts.BITS;
|
235512
|
+
if (_opts.sqrt)
|
235513
|
+
_sqrt = _opts.sqrt;
|
235514
|
+
if (typeof _opts.isLE === "boolean")
|
235515
|
+
isLE2 = _opts.isLE;
|
235516
|
+
} else {
|
235517
|
+
if (typeof bitLenOrOpts === "number")
|
235518
|
+
_nbitLength = bitLenOrOpts;
|
235519
|
+
if (opts.sqrt)
|
235520
|
+
_sqrt = opts.sqrt;
|
235521
|
+
}
|
235522
|
+
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, _nbitLength);
|
235539
235523
|
if (BYTES > 2048)
|
235540
235524
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
235541
235525
|
let sqrtP;
|
@@ -235554,6 +235538,7 @@ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
|
|
235554
235538
|
return _0n3 <= num && num < ORDER;
|
235555
235539
|
},
|
235556
235540
|
is0: (num) => num === _0n3,
|
235541
|
+
isValidNot0: (num) => !f5.is0(num) && f5.isValid(num),
|
235557
235542
|
isOdd: (num) => (num & _1n3) === _1n3,
|
235558
235543
|
neg: (num) => mod(-num, ORDER),
|
235559
235544
|
eql: (lhs, rhs) => lhs === rhs,
|
@@ -235568,7 +235553,7 @@ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
|
|
235568
235553
|
subN: (lhs, rhs) => lhs - rhs,
|
235569
235554
|
mulN: (lhs, rhs) => lhs * rhs,
|
235570
235555
|
inv: (num) => invert(num, ORDER),
|
235571
|
-
sqrt:
|
235556
|
+
sqrt: _sqrt || ((n6) => {
|
235572
235557
|
if (!sqrtP)
|
235573
235558
|
sqrtP = FpSqrt(ORDER);
|
235574
235559
|
return sqrtP(f5, n6);
|
@@ -235606,7 +235591,6 @@ function mapHashToField(key2, fieldOrder, isLE2 = false) {
|
|
235606
235591
|
}
|
235607
235592
|
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _8n, FIELD_FIELDS;
|
235608
235593
|
var init_modular = __esm(() => {
|
235609
|
-
init_utils2();
|
235610
235594
|
init_utils3();
|
235611
235595
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235612
235596
|
_0n3 = BigInt(0);
|
@@ -235638,10 +235622,16 @@ var init_modular = __esm(() => {
|
|
235638
235622
|
});
|
235639
235623
|
|
235640
235624
|
// ../../node_modules/@noble/curves/esm/abstract/curve.js
|
235641
|
-
function
|
235625
|
+
function negateCt(condition, item) {
|
235642
235626
|
const neg = item.negate();
|
235643
235627
|
return condition ? neg : item;
|
235644
235628
|
}
|
235629
|
+
function normalizeZ(c3, property, points) {
|
235630
|
+
const getz = property === "pz" ? (p5) => p5.pz : (p5) => p5.ez;
|
235631
|
+
const toInv = FpInvertBatch(c3.Fp, points.map(getz));
|
235632
|
+
const affined = points.map((p5, i6) => p5.toAffine(toInv[i6]));
|
235633
|
+
return affined.map(c3.fromAffine);
|
235634
|
+
}
|
235645
235635
|
function validateW(W5, bits) {
|
235646
235636
|
if (!Number.isSafeInteger(W5) || W5 <= 0 || W5 > bits)
|
235647
235637
|
throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W5);
|
@@ -235690,9 +235680,13 @@ function validateMSMScalars(scalars, field2) {
|
|
235690
235680
|
function getW(P5) {
|
235691
235681
|
return pointWindowSizes.get(P5) || 1;
|
235692
235682
|
}
|
235683
|
+
function assert0(n6) {
|
235684
|
+
if (n6 !== _0n4)
|
235685
|
+
throw new Error("invalid wNAF");
|
235686
|
+
}
|
235693
235687
|
function wNAF(c3, bits) {
|
235694
235688
|
return {
|
235695
|
-
constTimeNegate,
|
235689
|
+
constTimeNegate: negateCt,
|
235696
235690
|
hasPrecomputes(elm) {
|
235697
235691
|
return getW(elm) !== 1;
|
235698
235692
|
},
|
@@ -235730,11 +235724,12 @@ function wNAF(c3, bits) {
|
|
235730
235724
|
const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n6, window2, wo);
|
235731
235725
|
n6 = nextN;
|
235732
235726
|
if (isZero) {
|
235733
|
-
f5 = f5.add(
|
235727
|
+
f5 = f5.add(negateCt(isNegF, precomputes[offsetF]));
|
235734
235728
|
} else {
|
235735
|
-
p5 = p5.add(
|
235729
|
+
p5 = p5.add(negateCt(isNeg, precomputes[offset]));
|
235736
235730
|
}
|
235737
235731
|
}
|
235732
|
+
assert0(n6);
|
235738
235733
|
return { p: p5, f: f5 };
|
235739
235734
|
},
|
235740
235735
|
wNAFUnsafe(W5, precomputes, n6, acc = c3.ZERO) {
|
@@ -235751,14 +235746,18 @@ function wNAF(c3, bits) {
|
|
235751
235746
|
acc = acc.add(isNeg ? item.negate() : item);
|
235752
235747
|
}
|
235753
235748
|
}
|
235749
|
+
assert0(n6);
|
235754
235750
|
return acc;
|
235755
235751
|
},
|
235756
235752
|
getPrecomputes(W5, P5, transform5) {
|
235757
235753
|
let comp = pointPrecomputes.get(P5);
|
235758
235754
|
if (!comp) {
|
235759
235755
|
comp = this.precomputeWindow(P5, W5);
|
235760
|
-
if (W5 !== 1)
|
235761
|
-
|
235756
|
+
if (W5 !== 1) {
|
235757
|
+
if (typeof transform5 === "function")
|
235758
|
+
comp = transform5(comp);
|
235759
|
+
pointPrecomputes.set(P5, comp);
|
235760
|
+
}
|
235762
235761
|
}
|
235763
235762
|
return comp;
|
235764
235763
|
},
|
@@ -235779,6 +235778,21 @@ function wNAF(c3, bits) {
|
|
235779
235778
|
}
|
235780
235779
|
};
|
235781
235780
|
}
|
235781
|
+
function mulEndoUnsafe(c3, point, k1, k22) {
|
235782
|
+
let acc = point;
|
235783
|
+
let p1 = c3.ZERO;
|
235784
|
+
let p22 = c3.ZERO;
|
235785
|
+
while (k1 > _0n4 || k22 > _0n4) {
|
235786
|
+
if (k1 & _1n4)
|
235787
|
+
p1 = p1.add(acc);
|
235788
|
+
if (k22 & _1n4)
|
235789
|
+
p22 = p22.add(acc);
|
235790
|
+
acc = acc.double();
|
235791
|
+
k1 >>= _1n4;
|
235792
|
+
k22 >>= _1n4;
|
235793
|
+
}
|
235794
|
+
return { p1, p2: p22 };
|
235795
|
+
}
|
235782
235796
|
function pippenger(c3, fieldN, points, scalars) {
|
235783
235797
|
validateMSMPoints(points, c3);
|
235784
235798
|
validateMSMScalars(scalars, fieldN);
|
@@ -235818,27 +235832,38 @@ function pippenger(c3, fieldN, points, scalars) {
|
|
235818
235832
|
}
|
235819
235833
|
return sum;
|
235820
235834
|
}
|
235821
|
-
function
|
235822
|
-
|
235823
|
-
|
235824
|
-
|
235825
|
-
|
235826
|
-
|
235827
|
-
|
235828
|
-
|
235829
|
-
|
235830
|
-
|
235831
|
-
|
235832
|
-
|
235833
|
-
|
235834
|
-
|
235835
|
-
|
235836
|
-
|
235835
|
+
function createField(order, field2) {
|
235836
|
+
if (field2) {
|
235837
|
+
if (field2.ORDER !== order)
|
235838
|
+
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
235839
|
+
validateField(field2);
|
235840
|
+
return field2;
|
235841
|
+
} else {
|
235842
|
+
return Field(order);
|
235843
|
+
}
|
235844
|
+
}
|
235845
|
+
function _createCurveFields(type4, CURVE, curveOpts = {}) {
|
235846
|
+
if (!CURVE || typeof CURVE !== "object")
|
235847
|
+
throw new Error(`expected valid ${type4} CURVE object`);
|
235848
|
+
for (const p5 of ["p", "n", "h"]) {
|
235849
|
+
const val = CURVE[p5];
|
235850
|
+
if (!(typeof val === "bigint" && val > _0n4))
|
235851
|
+
throw new Error(`CURVE.${p5} must be positive bigint`);
|
235852
|
+
}
|
235853
|
+
const Fp = createField(CURVE.p, curveOpts.Fp);
|
235854
|
+
const Fn = createField(CURVE.n, curveOpts.Fn);
|
235855
|
+
const _b = type4 === "weierstrass" ? "b" : "d";
|
235856
|
+
const params = ["Gx", "Gy", "a", _b];
|
235857
|
+
for (const p5 of params) {
|
235858
|
+
if (!Fp.isValid(CURVE[p5]))
|
235859
|
+
throw new Error(`CURVE.${p5} must be valid field element of CURVE.Fp`);
|
235860
|
+
}
|
235861
|
+
return { Fp, Fn };
|
235837
235862
|
}
|
235838
235863
|
var _0n4, _1n4, pointPrecomputes, pointWindowSizes;
|
235839
235864
|
var init_curve = __esm(() => {
|
235840
|
-
init_modular();
|
235841
235865
|
init_utils3();
|
235866
|
+
init_modular();
|
235842
235867
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235843
235868
|
_0n4 = BigInt(0);
|
235844
235869
|
_1n4 = BigInt(1);
|
@@ -235853,54 +235878,116 @@ function validateSigVerOpts(opts) {
|
|
235853
235878
|
if (opts.prehash !== undefined)
|
235854
235879
|
abool("prehash", opts.prehash);
|
235855
235880
|
}
|
235856
|
-
function
|
235857
|
-
|
235858
|
-
|
235859
|
-
|
235860
|
-
|
235861
|
-
}
|
235881
|
+
function _legacyHelperEquat(Fp, a7, b4) {
|
235882
|
+
function weierstrassEquation(x6) {
|
235883
|
+
const x22 = Fp.sqr(x6);
|
235884
|
+
const x32 = Fp.mul(x22, x6);
|
235885
|
+
return Fp.add(Fp.add(x32, Fp.mul(x6, a7)), b4);
|
235886
|
+
}
|
235887
|
+
return weierstrassEquation;
|
235888
|
+
}
|
235889
|
+
function _legacyHelperNormPriv(Fn, allowedPrivateKeyLengths, wrapPrivateKey) {
|
235890
|
+
const { BYTES: expected } = Fn;
|
235891
|
+
function normPrivateKeyToScalar(key2) {
|
235892
|
+
let num;
|
235893
|
+
if (typeof key2 === "bigint") {
|
235894
|
+
num = key2;
|
235895
|
+
} else {
|
235896
|
+
let bytes = ensureBytes("private key", key2);
|
235897
|
+
if (allowedPrivateKeyLengths) {
|
235898
|
+
if (!allowedPrivateKeyLengths.includes(bytes.length * 2))
|
235899
|
+
throw new Error("invalid private key");
|
235900
|
+
const padded = new Uint8Array(expected);
|
235901
|
+
padded.set(bytes, padded.length - bytes.length);
|
235902
|
+
bytes = padded;
|
235903
|
+
}
|
235904
|
+
try {
|
235905
|
+
num = Fn.fromBytes(bytes);
|
235906
|
+
} catch (error44) {
|
235907
|
+
throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key2}`);
|
235908
|
+
}
|
235909
|
+
}
|
235910
|
+
if (wrapPrivateKey)
|
235911
|
+
num = Fn.create(num);
|
235912
|
+
if (!Fn.isValidNot0(num))
|
235913
|
+
throw new Error("invalid private key: out of range [1..N-1]");
|
235914
|
+
return num;
|
235915
|
+
}
|
235916
|
+
return normPrivateKeyToScalar;
|
235917
|
+
}
|
235918
|
+
function weierstrassN(CURVE, curveOpts = {}) {
|
235919
|
+
const { Fp, Fn } = _createCurveFields("weierstrass", CURVE, curveOpts);
|
235920
|
+
const { h: cofactor, n: CURVE_ORDER } = CURVE;
|
235921
|
+
_validateObject(curveOpts, {}, {
|
235862
235922
|
allowInfinityPoint: "boolean",
|
235863
|
-
allowedPrivateKeyLengths: "array",
|
235864
235923
|
clearCofactor: "function",
|
235865
|
-
fromBytes: "function",
|
235866
235924
|
isTorsionFree: "function",
|
235925
|
+
fromBytes: "function",
|
235867
235926
|
toBytes: "function",
|
235927
|
+
endo: "object",
|
235868
235928
|
wrapPrivateKey: "boolean"
|
235869
235929
|
});
|
235870
|
-
const { endo
|
235930
|
+
const { endo } = curveOpts;
|
235871
235931
|
if (endo) {
|
235872
|
-
if (!Fp.
|
235873
|
-
throw new Error("invalid endo: CURVE.a must be 0");
|
235874
|
-
}
|
235875
|
-
if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
|
235932
|
+
if (!Fp.is0(CURVE.a) || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
|
235876
235933
|
throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
|
235877
235934
|
}
|
235878
235935
|
}
|
235879
|
-
|
235880
|
-
|
235881
|
-
|
235882
|
-
|
235883
|
-
|
235884
|
-
|
235885
|
-
|
235886
|
-
|
235887
|
-
|
235888
|
-
|
235889
|
-
|
235890
|
-
|
235891
|
-
|
235892
|
-
|
235936
|
+
function assertCompressionIsSupported() {
|
235937
|
+
if (!Fp.isOdd)
|
235938
|
+
throw new Error("compression is not supported: Field does not have .isOdd()");
|
235939
|
+
}
|
235940
|
+
function pointToBytes(_c, point, isCompressed) {
|
235941
|
+
const { x: x6, y: y4 } = point.toAffine();
|
235942
|
+
const bx = Fp.toBytes(x6);
|
235943
|
+
abool("isCompressed", isCompressed);
|
235944
|
+
if (isCompressed) {
|
235945
|
+
assertCompressionIsSupported();
|
235946
|
+
const hasEvenY = !Fp.isOdd(y4);
|
235947
|
+
return concatBytes(pprefix(hasEvenY), bx);
|
235948
|
+
} else {
|
235949
|
+
return concatBytes(Uint8Array.of(4), bx, Fp.toBytes(y4));
|
235950
|
+
}
|
235951
|
+
}
|
235952
|
+
function pointFromBytes(bytes) {
|
235953
|
+
abytes(bytes);
|
235954
|
+
const L5 = Fp.BYTES;
|
235955
|
+
const LC = L5 + 1;
|
235956
|
+
const LU = 2 * L5 + 1;
|
235957
|
+
const length = bytes.length;
|
235958
|
+
const head = bytes[0];
|
235893
235959
|
const tail = bytes.subarray(1);
|
235894
|
-
|
235895
|
-
|
235896
|
-
|
235897
|
-
|
235898
|
-
|
235899
|
-
|
235900
|
-
|
235901
|
-
|
235902
|
-
|
235960
|
+
if (length === LC && (head === 2 || head === 3)) {
|
235961
|
+
const x6 = Fp.fromBytes(tail);
|
235962
|
+
if (!Fp.isValid(x6))
|
235963
|
+
throw new Error("bad point: is not on curve, wrong x");
|
235964
|
+
const y22 = weierstrassEquation(x6);
|
235965
|
+
let y4;
|
235966
|
+
try {
|
235967
|
+
y4 = Fp.sqrt(y22);
|
235968
|
+
} catch (sqrtError) {
|
235969
|
+
const err = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
235970
|
+
throw new Error("bad point: is not on curve, sqrt error" + err);
|
235971
|
+
}
|
235972
|
+
assertCompressionIsSupported();
|
235973
|
+
const isYOdd = Fp.isOdd(y4);
|
235974
|
+
const isHeadOdd = (head & 1) === 1;
|
235975
|
+
if (isHeadOdd !== isYOdd)
|
235976
|
+
y4 = Fp.neg(y4);
|
235977
|
+
return { x: x6, y: y4 };
|
235978
|
+
} else if (length === LU && head === 4) {
|
235979
|
+
const x6 = Fp.fromBytes(tail.subarray(L5 * 0, L5 * 1));
|
235980
|
+
const y4 = Fp.fromBytes(tail.subarray(L5 * 1, L5 * 2));
|
235981
|
+
if (!isValidXY(x6, y4))
|
235982
|
+
throw new Error("bad point: is not on curve");
|
235983
|
+
return { x: x6, y: y4 };
|
235984
|
+
} else {
|
235985
|
+
throw new Error(`bad point: got length ${length}, expected compressed=${LC} or uncompressed=${LU}`);
|
235986
|
+
}
|
235903
235987
|
}
|
235988
|
+
const toBytes3 = curveOpts.toBytes || pointToBytes;
|
235989
|
+
const fromBytes = curveOpts.fromBytes || pointFromBytes;
|
235990
|
+
const weierstrassEquation = _legacyHelperEquat(Fp, CURVE.a, CURVE.b);
|
235904
235991
|
function isValidXY(x6, y4) {
|
235905
235992
|
const left = Fp.sqr(y4);
|
235906
235993
|
const right = weierstrassEquation(x6);
|
@@ -235912,28 +235999,10 @@ function weierstrassPoints(opts) {
|
|
235912
235999
|
const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
|
235913
236000
|
if (Fp.is0(Fp.add(_4a3, _27b2)))
|
235914
236001
|
throw new Error("bad curve params: a or b");
|
235915
|
-
function
|
235916
|
-
|
235917
|
-
|
235918
|
-
|
235919
|
-
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N6 } = CURVE;
|
235920
|
-
if (lengths && typeof key2 !== "bigint") {
|
235921
|
-
if (isBytes2(key2))
|
235922
|
-
key2 = bytesToHex2(key2);
|
235923
|
-
if (typeof key2 !== "string" || !lengths.includes(key2.length))
|
235924
|
-
throw new Error("invalid private key");
|
235925
|
-
key2 = key2.padStart(nByteLength * 2, "0");
|
235926
|
-
}
|
235927
|
-
let num;
|
235928
|
-
try {
|
235929
|
-
num = typeof key2 === "bigint" ? key2 : bytesToNumberBE(ensureBytes("private key", key2, nByteLength));
|
235930
|
-
} catch (error44) {
|
235931
|
-
throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key2);
|
235932
|
-
}
|
235933
|
-
if (wrapPrivateKey)
|
235934
|
-
num = mod(num, N6);
|
235935
|
-
aInRange("private key", num, _1n5, N6);
|
235936
|
-
return num;
|
236002
|
+
function acoord(title, n6, banZero = false) {
|
236003
|
+
if (!Fp.isValid(n6) || banZero && Fp.is0(n6))
|
236004
|
+
throw new Error(`bad point coordinate ${title}`);
|
236005
|
+
return n6;
|
235937
236006
|
}
|
235938
236007
|
function aprjpoint(other) {
|
235939
236008
|
if (!(other instanceof Point))
|
@@ -235957,31 +236026,31 @@ function weierstrassPoints(opts) {
|
|
235957
236026
|
});
|
235958
236027
|
const assertValidMemo = memoized((p5) => {
|
235959
236028
|
if (p5.is0()) {
|
235960
|
-
if (
|
236029
|
+
if (curveOpts.allowInfinityPoint && !Fp.is0(p5.py))
|
235961
236030
|
return;
|
235962
236031
|
throw new Error("bad point: ZERO");
|
235963
236032
|
}
|
235964
236033
|
const { x: x6, y: y4 } = p5.toAffine();
|
235965
236034
|
if (!Fp.isValid(x6) || !Fp.isValid(y4))
|
235966
|
-
throw new Error("bad point: x or y not
|
236035
|
+
throw new Error("bad point: x or y not field elements");
|
235967
236036
|
if (!isValidXY(x6, y4))
|
235968
236037
|
throw new Error("bad point: equation left != right");
|
235969
236038
|
if (!p5.isTorsionFree())
|
235970
236039
|
throw new Error("bad point: not in prime-order subgroup");
|
235971
236040
|
return true;
|
235972
236041
|
});
|
236042
|
+
function finishEndo(endoBeta, k1p, k2p, k1neg, k2neg) {
|
236043
|
+
k2p = new Point(Fp.mul(k2p.px, endoBeta), k2p.py, k2p.pz);
|
236044
|
+
k1p = negateCt(k1neg, k1p);
|
236045
|
+
k2p = negateCt(k2neg, k2p);
|
236046
|
+
return k1p.add(k2p);
|
236047
|
+
}
|
235973
236048
|
|
235974
236049
|
class Point {
|
235975
236050
|
constructor(px, py, pz) {
|
235976
|
-
|
235977
|
-
|
235978
|
-
|
235979
|
-
throw new Error("y required");
|
235980
|
-
if (pz == null || !Fp.isValid(pz))
|
235981
|
-
throw new Error("z required");
|
235982
|
-
this.px = px;
|
235983
|
-
this.py = py;
|
235984
|
-
this.pz = pz;
|
236051
|
+
this.px = acoord("x", px);
|
236052
|
+
this.py = acoord("y", py, true);
|
236053
|
+
this.pz = acoord("z", pz);
|
235985
236054
|
Object.freeze(this);
|
235986
236055
|
}
|
235987
236056
|
static fromAffine(p5) {
|
@@ -235990,8 +236059,7 @@ function weierstrassPoints(opts) {
|
|
235990
236059
|
throw new Error("invalid affine point");
|
235991
236060
|
if (p5 instanceof Point)
|
235992
236061
|
throw new Error("projective point not allowed");
|
235993
|
-
|
235994
|
-
if (is0(x6) && is0(y4))
|
236062
|
+
if (Fp.is0(x6) && Fp.is0(y4))
|
235995
236063
|
return Point.ZERO;
|
235996
236064
|
return new Point(x6, y4, Fp.ONE);
|
235997
236065
|
}
|
@@ -236002,8 +236070,11 @@ function weierstrassPoints(opts) {
|
|
236002
236070
|
return this.toAffine().y;
|
236003
236071
|
}
|
236004
236072
|
static normalizeZ(points) {
|
236005
|
-
|
236006
|
-
|
236073
|
+
return normalizeZ(Point, "pz", points);
|
236074
|
+
}
|
236075
|
+
static fromBytes(bytes) {
|
236076
|
+
abytes(bytes);
|
236077
|
+
return Point.fromHex(bytes);
|
236007
236078
|
}
|
236008
236079
|
static fromHex(hex) {
|
236009
236080
|
const P5 = Point.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
|
@@ -236011,22 +236082,29 @@ function weierstrassPoints(opts) {
|
|
236011
236082
|
return P5;
|
236012
236083
|
}
|
236013
236084
|
static fromPrivateKey(privateKey) {
|
236085
|
+
const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
|
236014
236086
|
return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
|
236015
236087
|
}
|
236016
236088
|
static msm(points, scalars) {
|
236017
236089
|
return pippenger(Point, Fn, points, scalars);
|
236018
236090
|
}
|
236019
|
-
|
236091
|
+
precompute(windowSize = 8, isLazy = true) {
|
236020
236092
|
wnaf.setWindowSize(this, windowSize);
|
236093
|
+
if (!isLazy)
|
236094
|
+
this.multiply(_3n2);
|
236095
|
+
return this;
|
236096
|
+
}
|
236097
|
+
_setWindowSize(windowSize) {
|
236098
|
+
this.precompute(windowSize);
|
236021
236099
|
}
|
236022
236100
|
assertValidity() {
|
236023
236101
|
assertValidMemo(this);
|
236024
236102
|
}
|
236025
236103
|
hasEvenY() {
|
236026
236104
|
const { y: y4 } = this.toAffine();
|
236027
|
-
if (Fp.isOdd)
|
236028
|
-
|
236029
|
-
|
236105
|
+
if (!Fp.isOdd)
|
236106
|
+
throw new Error("Field doesn't support isOdd");
|
236107
|
+
return !Fp.isOdd(y4);
|
236030
236108
|
}
|
236031
236109
|
equals(other) {
|
236032
236110
|
aprjpoint(other);
|
@@ -236132,188 +236210,121 @@ function weierstrassPoints(opts) {
|
|
236132
236210
|
is0() {
|
236133
236211
|
return this.equals(Point.ZERO);
|
236134
236212
|
}
|
236135
|
-
wNAF(n6) {
|
236136
|
-
return wnaf.wNAFCached(this, n6, Point.normalizeZ);
|
236137
|
-
}
|
236138
|
-
multiplyUnsafe(sc) {
|
236139
|
-
const { endo: endo2, n: N6 } = CURVE;
|
236140
|
-
aInRange("scalar", sc, _0n5, N6);
|
236141
|
-
const I6 = Point.ZERO;
|
236142
|
-
if (sc === _0n5)
|
236143
|
-
return I6;
|
236144
|
-
if (this.is0() || sc === _1n5)
|
236145
|
-
return this;
|
236146
|
-
if (!endo2 || wnaf.hasPrecomputes(this))
|
236147
|
-
return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);
|
236148
|
-
let { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
|
236149
|
-
let k1p = I6;
|
236150
|
-
let k2p = I6;
|
236151
|
-
let d6 = this;
|
236152
|
-
while (k1 > _0n5 || k22 > _0n5) {
|
236153
|
-
if (k1 & _1n5)
|
236154
|
-
k1p = k1p.add(d6);
|
236155
|
-
if (k22 & _1n5)
|
236156
|
-
k2p = k2p.add(d6);
|
236157
|
-
d6 = d6.double();
|
236158
|
-
k1 >>= _1n5;
|
236159
|
-
k22 >>= _1n5;
|
236160
|
-
}
|
236161
|
-
if (k1neg)
|
236162
|
-
k1p = k1p.negate();
|
236163
|
-
if (k2neg)
|
236164
|
-
k2p = k2p.negate();
|
236165
|
-
k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
236166
|
-
return k1p.add(k2p);
|
236167
|
-
}
|
236168
236213
|
multiply(scalar) {
|
236169
|
-
const { endo: endo2
|
236170
|
-
|
236214
|
+
const { endo: endo2 } = curveOpts;
|
236215
|
+
if (!Fn.isValidNot0(scalar))
|
236216
|
+
throw new Error("invalid scalar: out of range");
|
236171
236217
|
let point, fake;
|
236218
|
+
const mul = (n6) => wnaf.wNAFCached(this, n6, Point.normalizeZ);
|
236172
236219
|
if (endo2) {
|
236173
236220
|
const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(scalar);
|
236174
|
-
|
236175
|
-
|
236176
|
-
|
236177
|
-
|
236178
|
-
k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
236179
|
-
point = k1p.add(k2p);
|
236180
|
-
fake = f1p.add(f2p);
|
236221
|
+
const { p: k1p, f: k1f } = mul(k1);
|
236222
|
+
const { p: k2p, f: k2f } = mul(k22);
|
236223
|
+
fake = k1f.add(k2f);
|
236224
|
+
point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
|
236181
236225
|
} else {
|
236182
|
-
const { p: p5, f: f5 } =
|
236226
|
+
const { p: p5, f: f5 } = mul(scalar);
|
236183
236227
|
point = p5;
|
236184
236228
|
fake = f5;
|
236185
236229
|
}
|
236186
236230
|
return Point.normalizeZ([point, fake])[0];
|
236187
236231
|
}
|
236232
|
+
multiplyUnsafe(sc) {
|
236233
|
+
const { endo: endo2 } = curveOpts;
|
236234
|
+
const p5 = this;
|
236235
|
+
if (!Fn.isValid(sc))
|
236236
|
+
throw new Error("invalid scalar: out of range");
|
236237
|
+
if (sc === _0n5 || p5.is0())
|
236238
|
+
return Point.ZERO;
|
236239
|
+
if (sc === _1n5)
|
236240
|
+
return p5;
|
236241
|
+
if (wnaf.hasPrecomputes(this))
|
236242
|
+
return this.multiply(sc);
|
236243
|
+
if (endo2) {
|
236244
|
+
const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
|
236245
|
+
const { p1, p2: p22 } = mulEndoUnsafe(Point, p5, k1, k22);
|
236246
|
+
return finishEndo(endo2.beta, p1, p22, k1neg, k2neg);
|
236247
|
+
} else {
|
236248
|
+
return wnaf.wNAFCachedUnsafe(p5, sc);
|
236249
|
+
}
|
236250
|
+
}
|
236188
236251
|
multiplyAndAddUnsafe(Q4, a7, b4) {
|
236189
|
-
const
|
236190
|
-
const mul = (P5, a8) => a8 === _0n5 || a8 === _1n5 || !P5.equals(G4) ? P5.multiplyUnsafe(a8) : P5.multiply(a8);
|
236191
|
-
const sum = mul(this, a7).add(mul(Q4, b4));
|
236252
|
+
const sum = this.multiplyUnsafe(a7).add(Q4.multiplyUnsafe(b4));
|
236192
236253
|
return sum.is0() ? undefined : sum;
|
236193
236254
|
}
|
236194
|
-
toAffine(
|
236195
|
-
return toAffineMemo(this,
|
236255
|
+
toAffine(invertedZ) {
|
236256
|
+
return toAffineMemo(this, invertedZ);
|
236196
236257
|
}
|
236197
236258
|
isTorsionFree() {
|
236198
|
-
const {
|
236259
|
+
const { isTorsionFree } = curveOpts;
|
236199
236260
|
if (cofactor === _1n5)
|
236200
236261
|
return true;
|
236201
236262
|
if (isTorsionFree)
|
236202
236263
|
return isTorsionFree(Point, this);
|
236203
|
-
|
236264
|
+
return wnaf.wNAFCachedUnsafe(this, CURVE_ORDER).is0();
|
236204
236265
|
}
|
236205
236266
|
clearCofactor() {
|
236206
|
-
const {
|
236267
|
+
const { clearCofactor } = curveOpts;
|
236207
236268
|
if (cofactor === _1n5)
|
236208
236269
|
return this;
|
236209
236270
|
if (clearCofactor)
|
236210
236271
|
return clearCofactor(Point, this);
|
236211
|
-
return this.multiplyUnsafe(
|
236272
|
+
return this.multiplyUnsafe(cofactor);
|
236212
236273
|
}
|
236213
|
-
|
236274
|
+
toBytes(isCompressed = true) {
|
236214
236275
|
abool("isCompressed", isCompressed);
|
236215
236276
|
this.assertValidity();
|
236216
236277
|
return toBytes3(Point, this, isCompressed);
|
236217
236278
|
}
|
236279
|
+
toRawBytes(isCompressed = true) {
|
236280
|
+
return this.toBytes(isCompressed);
|
236281
|
+
}
|
236218
236282
|
toHex(isCompressed = true) {
|
236219
|
-
|
236220
|
-
|
236283
|
+
return bytesToHex2(this.toBytes(isCompressed));
|
236284
|
+
}
|
236285
|
+
toString() {
|
236286
|
+
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
236221
236287
|
}
|
236222
236288
|
}
|
236223
236289
|
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
|
236224
236290
|
Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
|
236225
|
-
|
236226
|
-
|
236227
|
-
|
236228
|
-
|
236229
|
-
|
236230
|
-
normPrivateKeyToScalar,
|
236231
|
-
weierstrassEquation,
|
236232
|
-
isWithinCurveOrder
|
236233
|
-
};
|
236291
|
+
Point.Fp = Fp;
|
236292
|
+
Point.Fn = Fn;
|
236293
|
+
const bits = Fn.BITS;
|
236294
|
+
const wnaf = wNAF(Point, curveOpts.endo ? Math.ceil(bits / 2) : bits);
|
236295
|
+
return Point;
|
236234
236296
|
}
|
236235
|
-
function
|
236236
|
-
|
236237
|
-
|
236238
|
-
|
236297
|
+
function pprefix(hasEvenY) {
|
236298
|
+
return Uint8Array.of(hasEvenY ? 2 : 3);
|
236299
|
+
}
|
236300
|
+
function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
236301
|
+
_validateObject(ecdsaOpts, { hash: "function" }, {
|
236239
236302
|
hmac: "function",
|
236240
|
-
|
236241
|
-
|
236303
|
+
lowS: "boolean",
|
236304
|
+
randomBytes: "function",
|
236242
236305
|
bits2int: "function",
|
236243
|
-
bits2int_modN: "function"
|
236244
|
-
lowS: "boolean"
|
236245
|
-
});
|
236246
|
-
return Object.freeze({ lowS: true, ...opts });
|
236247
|
-
}
|
236248
|
-
function weierstrass(curveDef) {
|
236249
|
-
const CURVE = validateOpts(curveDef);
|
236250
|
-
const { Fp, n: CURVE_ORDER, nByteLength, nBitLength } = CURVE;
|
236251
|
-
const compressedLen = Fp.BYTES + 1;
|
236252
|
-
const uncompressedLen = 2 * Fp.BYTES + 1;
|
236253
|
-
function modN(a7) {
|
236254
|
-
return mod(a7, CURVE_ORDER);
|
236255
|
-
}
|
236256
|
-
function invN(a7) {
|
236257
|
-
return invert(a7, CURVE_ORDER);
|
236258
|
-
}
|
236259
|
-
const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
|
236260
|
-
...CURVE,
|
236261
|
-
toBytes(_c, point, isCompressed) {
|
236262
|
-
const a7 = point.toAffine();
|
236263
|
-
const x6 = Fp.toBytes(a7.x);
|
236264
|
-
const cat = concatBytes3;
|
236265
|
-
abool("isCompressed", isCompressed);
|
236266
|
-
if (isCompressed) {
|
236267
|
-
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x6);
|
236268
|
-
} else {
|
236269
|
-
return cat(Uint8Array.from([4]), x6, Fp.toBytes(a7.y));
|
236270
|
-
}
|
236271
|
-
},
|
236272
|
-
fromBytes(bytes) {
|
236273
|
-
const len = bytes.length;
|
236274
|
-
const head = bytes[0];
|
236275
|
-
const tail = bytes.subarray(1);
|
236276
|
-
if (len === compressedLen && (head === 2 || head === 3)) {
|
236277
|
-
const x6 = bytesToNumberBE(tail);
|
236278
|
-
if (!inRange(x6, _1n5, Fp.ORDER))
|
236279
|
-
throw new Error("Point is not on curve");
|
236280
|
-
const y22 = weierstrassEquation(x6);
|
236281
|
-
let y4;
|
236282
|
-
try {
|
236283
|
-
y4 = Fp.sqrt(y22);
|
236284
|
-
} catch (sqrtError) {
|
236285
|
-
const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
236286
|
-
throw new Error("Point is not on curve" + suffix);
|
236287
|
-
}
|
236288
|
-
const isYOdd = (y4 & _1n5) === _1n5;
|
236289
|
-
const isHeadOdd = (head & 1) === 1;
|
236290
|
-
if (isHeadOdd !== isYOdd)
|
236291
|
-
y4 = Fp.neg(y4);
|
236292
|
-
return { x: x6, y: y4 };
|
236293
|
-
} else if (len === uncompressedLen && head === 4) {
|
236294
|
-
const x6 = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
|
236295
|
-
const y4 = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
|
236296
|
-
return { x: x6, y: y4 };
|
236297
|
-
} else {
|
236298
|
-
const cl = compressedLen;
|
236299
|
-
const ul = uncompressedLen;
|
236300
|
-
throw new Error("invalid Point, expected length of " + cl + ", or uncompressed " + ul + ", got " + len);
|
236301
|
-
}
|
236302
|
-
}
|
236306
|
+
bits2int_modN: "function"
|
236303
236307
|
});
|
236308
|
+
const randomBytes_ = ecdsaOpts.randomBytes || randomBytes;
|
236309
|
+
const hmac_ = ecdsaOpts.hmac || ((key2, ...msgs) => hmac(ecdsaOpts.hash, key2, concatBytes(...msgs)));
|
236310
|
+
const { Fp, Fn } = Point;
|
236311
|
+
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
|
236304
236312
|
function isBiggerThanHalfOrder(number6) {
|
236305
236313
|
const HALF = CURVE_ORDER >> _1n5;
|
236306
236314
|
return number6 > HALF;
|
236307
236315
|
}
|
236308
236316
|
function normalizeS(s7) {
|
236309
|
-
return isBiggerThanHalfOrder(s7) ?
|
236317
|
+
return isBiggerThanHalfOrder(s7) ? Fn.neg(s7) : s7;
|
236318
|
+
}
|
236319
|
+
function aValidRS(title, num) {
|
236320
|
+
if (!Fn.isValidNot0(num))
|
236321
|
+
throw new Error(`invalid signature ${title}: out of range 1..CURVE.n`);
|
236310
236322
|
}
|
236311
|
-
const slcNum = (b4, from, to) => bytesToNumberBE(b4.slice(from, to));
|
236312
236323
|
|
236313
236324
|
class Signature {
|
236314
236325
|
constructor(r6, s7, recovery) {
|
236315
|
-
|
236316
|
-
|
236326
|
+
aValidRS("r", r6);
|
236327
|
+
aValidRS("s", s7);
|
236317
236328
|
this.r = r6;
|
236318
236329
|
this.s = s7;
|
236319
236330
|
if (recovery != null)
|
@@ -236321,9 +236332,9 @@ function weierstrass(curveDef) {
|
|
236321
236332
|
Object.freeze(this);
|
236322
236333
|
}
|
236323
236334
|
static fromCompact(hex) {
|
236324
|
-
const
|
236325
|
-
|
236326
|
-
return new Signature(
|
236335
|
+
const L5 = Fn.BYTES;
|
236336
|
+
const b4 = ensureBytes("compactSignature", hex, L5 * 2);
|
236337
|
+
return new Signature(Fn.fromBytes(b4.subarray(0, L5)), Fn.fromBytes(b4.subarray(L5, L5 * 2)));
|
236327
236338
|
}
|
236328
236339
|
static fromDER(hex) {
|
236329
236340
|
const { r: r6, s: s7 } = DER.toSig(ensureBytes("DER", hex));
|
@@ -236334,20 +236345,24 @@ function weierstrass(curveDef) {
|
|
236334
236345
|
return new Signature(this.r, this.s, recovery);
|
236335
236346
|
}
|
236336
236347
|
recoverPublicKey(msgHash) {
|
236348
|
+
const FIELD_ORDER = Fp.ORDER;
|
236337
236349
|
const { r: r6, s: s7, recovery: rec } = this;
|
236338
|
-
const h8 = bits2int_modN(ensureBytes("msgHash", msgHash));
|
236339
236350
|
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
236340
236351
|
throw new Error("recovery id invalid");
|
236341
|
-
const
|
236342
|
-
if (
|
236352
|
+
const hasCofactor = CURVE_ORDER * _2n3 < FIELD_ORDER;
|
236353
|
+
if (hasCofactor && rec > 1)
|
236354
|
+
throw new Error("recovery id is ambiguous for h>1 curve");
|
236355
|
+
const radj = rec === 2 || rec === 3 ? r6 + CURVE_ORDER : r6;
|
236356
|
+
if (!Fp.isValid(radj))
|
236343
236357
|
throw new Error("recovery id 2 or 3 invalid");
|
236344
|
-
const
|
236345
|
-
const R7 = Point.fromHex(
|
236346
|
-
const ir2 =
|
236347
|
-
const
|
236348
|
-
const
|
236349
|
-
const
|
236350
|
-
|
236358
|
+
const x6 = Fp.toBytes(radj);
|
236359
|
+
const R7 = Point.fromHex(concatBytes(pprefix((rec & 1) === 0), x6));
|
236360
|
+
const ir2 = Fn.inv(radj);
|
236361
|
+
const h8 = bits2int_modN(ensureBytes("msgHash", msgHash));
|
236362
|
+
const u1 = Fn.create(-h8 * ir2);
|
236363
|
+
const u22 = Fn.create(s7 * ir2);
|
236364
|
+
const Q4 = Point.BASE.multiplyUnsafe(u1).add(R7.multiplyUnsafe(u22));
|
236365
|
+
if (Q4.is0())
|
236351
236366
|
throw new Error("point at infinify");
|
236352
236367
|
Q4.assertValidity();
|
236353
236368
|
return Q4;
|
@@ -236356,22 +236371,29 @@ function weierstrass(curveDef) {
|
|
236356
236371
|
return isBiggerThanHalfOrder(this.s);
|
236357
236372
|
}
|
236358
236373
|
normalizeS() {
|
236359
|
-
return this.hasHighS() ? new Signature(this.r,
|
236374
|
+
return this.hasHighS() ? new Signature(this.r, Fn.neg(this.s), this.recovery) : this;
|
236375
|
+
}
|
236376
|
+
toBytes(format2) {
|
236377
|
+
if (format2 === "compact")
|
236378
|
+
return concatBytes(Fn.toBytes(this.r), Fn.toBytes(this.s));
|
236379
|
+
if (format2 === "der")
|
236380
|
+
return hexToBytes2(DER.hexFromSig(this));
|
236381
|
+
throw new Error("invalid format");
|
236360
236382
|
}
|
236361
236383
|
toDERRawBytes() {
|
236362
|
-
return
|
236384
|
+
return this.toBytes("der");
|
236363
236385
|
}
|
236364
236386
|
toDERHex() {
|
236365
|
-
return
|
236387
|
+
return bytesToHex2(this.toBytes("der"));
|
236366
236388
|
}
|
236367
236389
|
toCompactRawBytes() {
|
236368
|
-
return
|
236390
|
+
return this.toBytes("compact");
|
236369
236391
|
}
|
236370
236392
|
toCompactHex() {
|
236371
|
-
|
236372
|
-
return numToSizedHex(this.r, l3) + numToSizedHex(this.s, l3);
|
236393
|
+
return bytesToHex2(this.toBytes("compact"));
|
236373
236394
|
}
|
236374
236395
|
}
|
236396
|
+
const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
|
236375
236397
|
const utils = {
|
236376
236398
|
isValidPrivateKey(privateKey) {
|
236377
236399
|
try {
|
@@ -236383,17 +236405,15 @@ function weierstrass(curveDef) {
|
|
236383
236405
|
},
|
236384
236406
|
normPrivateKeyToScalar,
|
236385
236407
|
randomPrivateKey: () => {
|
236386
|
-
const
|
236387
|
-
return mapHashToField(
|
236408
|
+
const n6 = CURVE_ORDER;
|
236409
|
+
return mapHashToField(randomBytes_(getMinHashLength(n6)), n6);
|
236388
236410
|
},
|
236389
236411
|
precompute(windowSize = 8, point = Point.BASE) {
|
236390
|
-
point.
|
236391
|
-
point.multiply(BigInt(3));
|
236392
|
-
return point;
|
236412
|
+
return point.precompute(windowSize, false);
|
236393
236413
|
}
|
236394
236414
|
};
|
236395
236415
|
function getPublicKey(privateKey, isCompressed = true) {
|
236396
|
-
return Point.fromPrivateKey(privateKey).
|
236416
|
+
return Point.fromPrivateKey(privateKey).toBytes(isCompressed);
|
236397
236417
|
}
|
236398
236418
|
function isProbPub(item) {
|
236399
236419
|
if (typeof item === "bigint")
|
@@ -236401,14 +236421,14 @@ function weierstrass(curveDef) {
|
|
236401
236421
|
if (item instanceof Point)
|
236402
236422
|
return true;
|
236403
236423
|
const arr = ensureBytes("key", item);
|
236404
|
-
const
|
236405
|
-
const
|
236406
|
-
const
|
236407
|
-
const
|
236408
|
-
if (
|
236424
|
+
const length = arr.length;
|
236425
|
+
const L5 = Fp.BYTES;
|
236426
|
+
const LC = L5 + 1;
|
236427
|
+
const LU = 2 * L5 + 1;
|
236428
|
+
if (curveOpts.allowedPrivateKeyLengths || Fn.BYTES === LC) {
|
236409
236429
|
return;
|
236410
236430
|
} else {
|
236411
|
-
return
|
236431
|
+
return length === LC || length === LU;
|
236412
236432
|
}
|
236413
236433
|
}
|
236414
236434
|
function getSharedSecret(privateA, publicB, isCompressed = true) {
|
@@ -236417,27 +236437,27 @@ function weierstrass(curveDef) {
|
|
236417
236437
|
if (isProbPub(publicB) === false)
|
236418
236438
|
throw new Error("second arg must be public key");
|
236419
236439
|
const b4 = Point.fromHex(publicB);
|
236420
|
-
return b4.multiply(normPrivateKeyToScalar(privateA)).
|
236440
|
+
return b4.multiply(normPrivateKeyToScalar(privateA)).toBytes(isCompressed);
|
236421
236441
|
}
|
236422
|
-
const bits2int =
|
236442
|
+
const bits2int = ecdsaOpts.bits2int || function(bytes) {
|
236423
236443
|
if (bytes.length > 8192)
|
236424
236444
|
throw new Error("input is too large");
|
236425
236445
|
const num = bytesToNumberBE(bytes);
|
236426
|
-
const delta = bytes.length * 8 -
|
236446
|
+
const delta = bytes.length * 8 - fnBits;
|
236427
236447
|
return delta > 0 ? num >> BigInt(delta) : num;
|
236428
236448
|
};
|
236429
|
-
const bits2int_modN =
|
236430
|
-
return
|
236449
|
+
const bits2int_modN = ecdsaOpts.bits2int_modN || function(bytes) {
|
236450
|
+
return Fn.create(bits2int(bytes));
|
236431
236451
|
};
|
236432
|
-
const ORDER_MASK = bitMask(
|
236452
|
+
const ORDER_MASK = bitMask(fnBits);
|
236433
236453
|
function int2octets(num) {
|
236434
|
-
aInRange("num < 2^" +
|
236435
|
-
return
|
236454
|
+
aInRange("num < 2^" + fnBits, num, _0n5, ORDER_MASK);
|
236455
|
+
return Fn.toBytes(num);
|
236436
236456
|
}
|
236437
236457
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
236438
236458
|
if (["recovered", "canonical"].some((k5) => (k5 in opts)))
|
236439
236459
|
throw new Error("sign() legacy options not supported");
|
236440
|
-
const { hash: hash2
|
236460
|
+
const { hash: hash2 } = ecdsaOpts;
|
236441
236461
|
let { lowS, prehash, extraEntropy: ent } = opts;
|
236442
236462
|
if (lowS == null)
|
236443
236463
|
lowS = true;
|
@@ -236449,21 +236469,21 @@ function weierstrass(curveDef) {
|
|
236449
236469
|
const d6 = normPrivateKeyToScalar(privateKey);
|
236450
236470
|
const seedArgs = [int2octets(d6), int2octets(h1int)];
|
236451
236471
|
if (ent != null && ent !== false) {
|
236452
|
-
const e10 = ent === true ?
|
236472
|
+
const e10 = ent === true ? randomBytes_(Fp.BYTES) : ent;
|
236453
236473
|
seedArgs.push(ensureBytes("extraEntropy", e10));
|
236454
236474
|
}
|
236455
|
-
const seed =
|
236475
|
+
const seed = concatBytes(...seedArgs);
|
236456
236476
|
const m7 = h1int;
|
236457
236477
|
function k2sig(kBytes) {
|
236458
236478
|
const k5 = bits2int(kBytes);
|
236459
|
-
if (!
|
236479
|
+
if (!Fn.isValidNot0(k5))
|
236460
236480
|
return;
|
236461
|
-
const ik =
|
236481
|
+
const ik = Fn.inv(k5);
|
236462
236482
|
const q6 = Point.BASE.multiply(k5).toAffine();
|
236463
|
-
const r6 =
|
236483
|
+
const r6 = Fn.create(q6.x);
|
236464
236484
|
if (r6 === _0n5)
|
236465
236485
|
return;
|
236466
|
-
const s7 =
|
236486
|
+
const s7 = Fn.create(ik * Fn.create(m7 + r6 * d6));
|
236467
236487
|
if (s7 === _0n5)
|
236468
236488
|
return;
|
236469
236489
|
let recovery = (q6.x === r6 ? 0 : 2) | Number(q6.y & _1n5);
|
@@ -236476,34 +236496,38 @@ function weierstrass(curveDef) {
|
|
236476
236496
|
}
|
236477
236497
|
return { seed, k2sig };
|
236478
236498
|
}
|
236479
|
-
const defaultSigOpts = { lowS:
|
236480
|
-
const defaultVerOpts = { lowS:
|
236499
|
+
const defaultSigOpts = { lowS: ecdsaOpts.lowS, prehash: false };
|
236500
|
+
const defaultVerOpts = { lowS: ecdsaOpts.lowS, prehash: false };
|
236481
236501
|
function sign(msgHash, privKey, opts = defaultSigOpts) {
|
236482
236502
|
const { seed, k2sig } = prepSig(msgHash, privKey, opts);
|
236483
|
-
const
|
236484
|
-
const drbg = createHmacDrbg(C4.hash.outputLen, C4.nByteLength, C4.hmac);
|
236503
|
+
const drbg = createHmacDrbg(ecdsaOpts.hash.outputLen, Fn.BYTES, hmac_);
|
236485
236504
|
return drbg(seed, k2sig);
|
236486
236505
|
}
|
236487
|
-
Point.BASE.
|
236506
|
+
Point.BASE.precompute(8);
|
236488
236507
|
function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
|
236489
236508
|
const sg = signature;
|
236490
236509
|
msgHash = ensureBytes("msgHash", msgHash);
|
236491
236510
|
publicKey = ensureBytes("publicKey", publicKey);
|
236492
|
-
const { lowS, prehash, format: format2 } = opts;
|
236493
236511
|
validateSigVerOpts(opts);
|
236512
|
+
const { lowS, prehash, format: format2 } = opts;
|
236494
236513
|
if ("strict" in opts)
|
236495
236514
|
throw new Error("options.strict was renamed to lowS");
|
236496
|
-
if (format2 !== undefined &&
|
236497
|
-
throw new Error(
|
236498
|
-
const isHex2 = typeof sg === "string" ||
|
236515
|
+
if (format2 !== undefined && !["compact", "der", "js"].includes(format2))
|
236516
|
+
throw new Error('format must be "compact", "der" or "js"');
|
236517
|
+
const isHex2 = typeof sg === "string" || isBytes(sg);
|
236499
236518
|
const isObj = !isHex2 && !format2 && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
|
236500
236519
|
if (!isHex2 && !isObj)
|
236501
236520
|
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
236502
236521
|
let _sig = undefined;
|
236503
236522
|
let P5;
|
236504
236523
|
try {
|
236505
|
-
if (isObj)
|
236506
|
-
|
236524
|
+
if (isObj) {
|
236525
|
+
if (format2 === undefined || format2 === "js") {
|
236526
|
+
_sig = new Signature(sg.r, sg.s);
|
236527
|
+
} else {
|
236528
|
+
throw new Error("invalid format");
|
236529
|
+
}
|
236530
|
+
}
|
236507
236531
|
if (isHex2) {
|
236508
236532
|
try {
|
236509
236533
|
if (format2 !== "compact")
|
@@ -236524,28 +236548,77 @@ function weierstrass(curveDef) {
|
|
236524
236548
|
if (lowS && _sig.hasHighS())
|
236525
236549
|
return false;
|
236526
236550
|
if (prehash)
|
236527
|
-
msgHash =
|
236551
|
+
msgHash = ecdsaOpts.hash(msgHash);
|
236528
236552
|
const { r: r6, s: s7 } = _sig;
|
236529
236553
|
const h8 = bits2int_modN(msgHash);
|
236530
|
-
const is =
|
236531
|
-
const u1 =
|
236532
|
-
const u22 =
|
236533
|
-
const R7 = Point.BASE.
|
236534
|
-
if (
|
236554
|
+
const is = Fn.inv(s7);
|
236555
|
+
const u1 = Fn.create(h8 * is);
|
236556
|
+
const u22 = Fn.create(r6 * is);
|
236557
|
+
const R7 = Point.BASE.multiplyUnsafe(u1).add(P5.multiplyUnsafe(u22));
|
236558
|
+
if (R7.is0())
|
236535
236559
|
return false;
|
236536
|
-
const v6 =
|
236560
|
+
const v6 = Fn.create(R7.x);
|
236537
236561
|
return v6 === r6;
|
236538
236562
|
}
|
236539
|
-
return {
|
236540
|
-
CURVE,
|
236563
|
+
return Object.freeze({
|
236541
236564
|
getPublicKey,
|
236542
236565
|
getSharedSecret,
|
236543
236566
|
sign,
|
236544
236567
|
verify,
|
236545
|
-
|
236546
|
-
|
236547
|
-
|
236548
|
-
};
|
236568
|
+
utils,
|
236569
|
+
Point,
|
236570
|
+
Signature
|
236571
|
+
});
|
236572
|
+
}
|
236573
|
+
function _weierstrass_legacy_opts_to_new(c3) {
|
236574
|
+
const CURVE = {
|
236575
|
+
a: c3.a,
|
236576
|
+
b: c3.b,
|
236577
|
+
p: c3.Fp.ORDER,
|
236578
|
+
n: c3.n,
|
236579
|
+
h: c3.h,
|
236580
|
+
Gx: c3.Gx,
|
236581
|
+
Gy: c3.Gy
|
236582
|
+
};
|
236583
|
+
const Fp = c3.Fp;
|
236584
|
+
const Fn = Field(CURVE.n, c3.nBitLength);
|
236585
|
+
const curveOpts = {
|
236586
|
+
Fp,
|
236587
|
+
Fn,
|
236588
|
+
allowedPrivateKeyLengths: c3.allowedPrivateKeyLengths,
|
236589
|
+
allowInfinityPoint: c3.allowInfinityPoint,
|
236590
|
+
endo: c3.endo,
|
236591
|
+
wrapPrivateKey: c3.wrapPrivateKey,
|
236592
|
+
isTorsionFree: c3.isTorsionFree,
|
236593
|
+
clearCofactor: c3.clearCofactor,
|
236594
|
+
fromBytes: c3.fromBytes,
|
236595
|
+
toBytes: c3.toBytes
|
236596
|
+
};
|
236597
|
+
return { CURVE, curveOpts };
|
236598
|
+
}
|
236599
|
+
function _ecdsa_legacy_opts_to_new(c3) {
|
236600
|
+
const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c3);
|
236601
|
+
const ecdsaOpts = {
|
236602
|
+
hash: c3.hash,
|
236603
|
+
hmac: c3.hmac,
|
236604
|
+
randomBytes: c3.randomBytes,
|
236605
|
+
lowS: c3.lowS,
|
236606
|
+
bits2int: c3.bits2int,
|
236607
|
+
bits2int_modN: c3.bits2int_modN
|
236608
|
+
};
|
236609
|
+
return { CURVE, curveOpts, ecdsaOpts };
|
236610
|
+
}
|
236611
|
+
function _ecdsa_new_output_to_legacy(c3, ecdsa2) {
|
236612
|
+
return Object.assign({}, ecdsa2, {
|
236613
|
+
ProjectivePoint: ecdsa2.Point,
|
236614
|
+
CURVE: c3
|
236615
|
+
});
|
236616
|
+
}
|
236617
|
+
function weierstrass(c3) {
|
236618
|
+
const { CURVE, curveOpts, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c3);
|
236619
|
+
const Point = weierstrassN(CURVE, curveOpts);
|
236620
|
+
const signs = ecdsa(Point, ecdsaOpts, curveOpts);
|
236621
|
+
return _ecdsa_new_output_to_legacy(c3, signs);
|
236549
236622
|
}
|
236550
236623
|
function SWUFpSqrtRatio(Fp, Z4) {
|
236551
236624
|
const q6 = Fp.ORDER;
|
@@ -236611,28 +236684,29 @@ function SWUFpSqrtRatio(Fp, Z4) {
|
|
236611
236684
|
}
|
236612
236685
|
function mapToCurveSimpleSWU(Fp, opts) {
|
236613
236686
|
validateField(Fp);
|
236614
|
-
|
236687
|
+
const { A: A5, B: B4, Z: Z4 } = opts;
|
236688
|
+
if (!Fp.isValid(A5) || !Fp.isValid(B4) || !Fp.isValid(Z4))
|
236615
236689
|
throw new Error("mapToCurveSimpleSWU: invalid opts");
|
236616
|
-
const sqrtRatio = SWUFpSqrtRatio(Fp,
|
236690
|
+
const sqrtRatio = SWUFpSqrtRatio(Fp, Z4);
|
236617
236691
|
if (!Fp.isOdd)
|
236618
|
-
throw new Error("
|
236692
|
+
throw new Error("Field does not have .isOdd()");
|
236619
236693
|
return (u6) => {
|
236620
236694
|
let tv1, tv2, tv3, tv4, tv5, tv6, x6, y4;
|
236621
236695
|
tv1 = Fp.sqr(u6);
|
236622
|
-
tv1 = Fp.mul(tv1,
|
236696
|
+
tv1 = Fp.mul(tv1, Z4);
|
236623
236697
|
tv2 = Fp.sqr(tv1);
|
236624
236698
|
tv2 = Fp.add(tv2, tv1);
|
236625
236699
|
tv3 = Fp.add(tv2, Fp.ONE);
|
236626
|
-
tv3 = Fp.mul(tv3,
|
236627
|
-
tv4 = Fp.cmov(
|
236628
|
-
tv4 = Fp.mul(tv4,
|
236700
|
+
tv3 = Fp.mul(tv3, B4);
|
236701
|
+
tv4 = Fp.cmov(Z4, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO));
|
236702
|
+
tv4 = Fp.mul(tv4, A5);
|
236629
236703
|
tv2 = Fp.sqr(tv3);
|
236630
236704
|
tv6 = Fp.sqr(tv4);
|
236631
|
-
tv5 = Fp.mul(tv6,
|
236705
|
+
tv5 = Fp.mul(tv6, A5);
|
236632
236706
|
tv2 = Fp.add(tv2, tv5);
|
236633
236707
|
tv2 = Fp.mul(tv2, tv3);
|
236634
236708
|
tv6 = Fp.mul(tv6, tv4);
|
236635
|
-
tv5 = Fp.mul(tv6,
|
236709
|
+
tv5 = Fp.mul(tv6, B4);
|
236636
236710
|
tv2 = Fp.add(tv2, tv5);
|
236637
236711
|
x6 = Fp.mul(tv1, tv3);
|
236638
236712
|
const { isValid, value: value4 } = sqrtRatio(tv2, tv6);
|
@@ -236649,9 +236723,10 @@ function mapToCurveSimpleSWU(Fp, opts) {
|
|
236649
236723
|
}
|
236650
236724
|
var DERErr, DER, _0n5, _1n5, _2n3, _3n2, _4n2;
|
236651
236725
|
var init_weierstrass = __esm(() => {
|
236726
|
+
init_hmac();
|
236727
|
+
init_utils3();
|
236652
236728
|
init_curve();
|
236653
236729
|
init_modular();
|
236654
|
-
init_utils3();
|
236655
236730
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
236656
236731
|
DERErr = class DERErr extends Error {
|
236657
236732
|
constructor(m7 = "") {
|
@@ -236759,20 +236834,11 @@ var init_weierstrass = __esm(() => {
|
|
236759
236834
|
});
|
236760
236835
|
|
236761
236836
|
// ../../node_modules/@noble/curves/esm/_shortw_utils.js
|
236762
|
-
function getHash(hash2) {
|
236763
|
-
return {
|
236764
|
-
hash: hash2,
|
236765
|
-
hmac: (key2, ...msgs) => hmac(hash2, key2, concatBytes(...msgs)),
|
236766
|
-
randomBytes
|
236767
|
-
};
|
236768
|
-
}
|
236769
236837
|
function createCurve(curveDef, defHash) {
|
236770
|
-
const create2 = (hash2) => weierstrass({ ...curveDef,
|
236838
|
+
const create2 = (hash2) => weierstrass({ ...curveDef, hash: hash2 });
|
236771
236839
|
return { ...create2(defHash), create: create2 };
|
236772
236840
|
}
|
236773
236841
|
var init__shortw_utils = __esm(() => {
|
236774
|
-
init_hmac();
|
236775
|
-
init_utils2();
|
236776
236842
|
init_weierstrass();
|
236777
236843
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
236778
236844
|
});
|
@@ -236802,52 +236868,55 @@ function anum(item) {
|
|
236802
236868
|
throw new Error("number expected");
|
236803
236869
|
}
|
236804
236870
|
function expand_message_xmd(msg, DST, lenInBytes, H4) {
|
236805
|
-
|
236806
|
-
|
236871
|
+
abytes(msg);
|
236872
|
+
abytes(DST);
|
236807
236873
|
anum(lenInBytes);
|
236808
236874
|
if (DST.length > 255)
|
236809
|
-
DST = H4(
|
236875
|
+
DST = H4(concatBytes(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
|
236810
236876
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H4;
|
236811
236877
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
236812
236878
|
if (lenInBytes > 65535 || ell > 255)
|
236813
236879
|
throw new Error("expand_message_xmd: invalid lenInBytes");
|
236814
|
-
const DST_prime =
|
236880
|
+
const DST_prime = concatBytes(DST, i2osp(DST.length, 1));
|
236815
236881
|
const Z_pad = i2osp(0, r_in_bytes);
|
236816
236882
|
const l_i_b_str = i2osp(lenInBytes, 2);
|
236817
236883
|
const b4 = new Array(ell);
|
236818
|
-
const b_0 = H4(
|
236819
|
-
b4[0] = H4(
|
236884
|
+
const b_0 = H4(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
236885
|
+
b4[0] = H4(concatBytes(b_0, i2osp(1, 1), DST_prime));
|
236820
236886
|
for (let i6 = 1;i6 <= ell; i6++) {
|
236821
236887
|
const args = [strxor(b_0, b4[i6 - 1]), i2osp(i6 + 1, 1), DST_prime];
|
236822
|
-
b4[i6] = H4(
|
236888
|
+
b4[i6] = H4(concatBytes(...args));
|
236823
236889
|
}
|
236824
|
-
const pseudo_random_bytes =
|
236890
|
+
const pseudo_random_bytes = concatBytes(...b4);
|
236825
236891
|
return pseudo_random_bytes.slice(0, lenInBytes);
|
236826
236892
|
}
|
236827
236893
|
function expand_message_xof(msg, DST, lenInBytes, k5, H4) {
|
236828
|
-
|
236829
|
-
|
236894
|
+
abytes(msg);
|
236895
|
+
abytes(DST);
|
236830
236896
|
anum(lenInBytes);
|
236831
236897
|
if (DST.length > 255) {
|
236832
236898
|
const dkLen = Math.ceil(2 * k5 / 8);
|
236833
|
-
DST = H4.create({ dkLen }).update(
|
236899
|
+
DST = H4.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
|
236834
236900
|
}
|
236835
236901
|
if (lenInBytes > 65535 || DST.length > 255)
|
236836
236902
|
throw new Error("expand_message_xof: invalid lenInBytes");
|
236837
236903
|
return H4.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
|
236838
236904
|
}
|
236839
236905
|
function hash_to_field(msg, count, options) {
|
236840
|
-
|
236841
|
-
DST: "stringOrUint8Array",
|
236906
|
+
_validateObject(options, {
|
236842
236907
|
p: "bigint",
|
236843
|
-
m: "
|
236844
|
-
k: "
|
236845
|
-
hash: "
|
236908
|
+
m: "number",
|
236909
|
+
k: "number",
|
236910
|
+
hash: "function"
|
236846
236911
|
});
|
236847
236912
|
const { p: p5, k: k5, m: m7, hash: hash2, expand, DST: _DST } = options;
|
236848
|
-
|
236913
|
+
if (!isBytes(_DST) && typeof _DST !== "string")
|
236914
|
+
throw new Error("DST must be string or uint8array");
|
236915
|
+
if (!isHash(options.hash))
|
236916
|
+
throw new Error("expected valid hash");
|
236917
|
+
abytes(msg);
|
236849
236918
|
anum(count);
|
236850
|
-
const DST = typeof _DST === "string" ?
|
236919
|
+
const DST = typeof _DST === "string" ? utf8ToBytes(_DST) : _DST;
|
236851
236920
|
const log2p = p5.toString(2).length;
|
236852
236921
|
const L5 = Math.ceil((log2p + k5) / 8);
|
236853
236922
|
const len_in_bytes = count * m7 * L5;
|
@@ -236899,13 +236968,17 @@ function createHasher2(Point, mapToCurve, defaults4) {
|
|
236899
236968
|
return {
|
236900
236969
|
defaults: defaults4,
|
236901
236970
|
hashToCurve(msg, options) {
|
236902
|
-
const
|
236971
|
+
const dst = defaults4.DST ? defaults4.DST : {};
|
236972
|
+
const opts = Object.assign({}, defaults4, dst, options);
|
236973
|
+
const u6 = hash_to_field(msg, 2, opts);
|
236903
236974
|
const u0 = map6(u6[0]);
|
236904
236975
|
const u1 = map6(u6[1]);
|
236905
236976
|
return clear(u0.add(u1));
|
236906
236977
|
},
|
236907
236978
|
encodeToCurve(msg, options) {
|
236908
|
-
const
|
236979
|
+
const dst = defaults4.encodeDST ? defaults4.encodeDST : {};
|
236980
|
+
const opts = Object.assign({}, defaults4, dst, options);
|
236981
|
+
const u6 = hash_to_field(msg, 1, opts);
|
236909
236982
|
return clear(map6(u6[0]));
|
236910
236983
|
},
|
236911
236984
|
mapToCurve(scalars) {
|
@@ -236920,8 +236993,8 @@ function createHasher2(Point, mapToCurve, defaults4) {
|
|
236920
236993
|
}
|
236921
236994
|
var os2ip;
|
236922
236995
|
var init_hash_to_curve = __esm(() => {
|
236923
|
-
init_modular();
|
236924
236996
|
init_utils3();
|
236997
|
+
init_modular();
|
236925
236998
|
os2ip = bytesToNumberBE;
|
236926
236999
|
});
|
236927
237000
|
|
@@ -236935,7 +237008,7 @@ __export(exports_secp256k1, {
|
|
236935
237008
|
encodeToCurve: () => encodeToCurve
|
236936
237009
|
});
|
236937
237010
|
function sqrtMod(y4) {
|
236938
|
-
const P5 =
|
237011
|
+
const P5 = secp256k1_CURVE.p;
|
236939
237012
|
const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
|
236940
237013
|
const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
|
236941
237014
|
const b22 = y4 * y4 * y4 % P5;
|
@@ -236960,25 +237033,25 @@ function taggedHash(tag, ...messages) {
|
|
236960
237033
|
let tagP = TAGGED_HASH_PREFIXES[tag];
|
236961
237034
|
if (tagP === undefined) {
|
236962
237035
|
const tagH = sha256(Uint8Array.from(tag, (c3) => c3.charCodeAt(0)));
|
236963
|
-
tagP =
|
237036
|
+
tagP = concatBytes(tagH, tagH);
|
236964
237037
|
TAGGED_HASH_PREFIXES[tag] = tagP;
|
236965
237038
|
}
|
236966
|
-
return sha256(
|
237039
|
+
return sha256(concatBytes(tagP, ...messages));
|
236967
237040
|
}
|
236968
237041
|
function schnorrGetExtPubKey(priv) {
|
236969
237042
|
let d_ = secp256k1.utils.normPrivateKeyToScalar(priv);
|
236970
237043
|
let p5 = Point.fromPrivateKey(d_);
|
236971
|
-
const scalar = p5.
|
237044
|
+
const scalar = hasEven(p5.y) ? d_ : modN(-d_);
|
236972
237045
|
return { scalar, bytes: pointToBytes(p5) };
|
236973
237046
|
}
|
236974
237047
|
function lift_x(x6) {
|
236975
|
-
aInRange("x", x6, _1n6,
|
237048
|
+
aInRange("x", x6, _1n6, secp256k1_CURVE.p);
|
236976
237049
|
const xx = modP(x6 * x6);
|
236977
237050
|
const c3 = modP(xx * x6 + BigInt(7));
|
236978
237051
|
let y4 = sqrtMod(c3);
|
236979
|
-
if (y4
|
237052
|
+
if (!hasEven(y4))
|
236980
237053
|
y4 = modP(-y4);
|
236981
|
-
const p5 =
|
237054
|
+
const p5 = Point.fromAffine({ x: x6, y: y4 });
|
236982
237055
|
p5.assertValidity();
|
236983
237056
|
return p5;
|
236984
237057
|
}
|
@@ -237013,49 +237086,52 @@ function schnorrVerify(signature, message, publicKey) {
|
|
237013
237086
|
try {
|
237014
237087
|
const P5 = lift_x(num(pub));
|
237015
237088
|
const r6 = num(sig.subarray(0, 32));
|
237016
|
-
if (!inRange(r6, _1n6,
|
237089
|
+
if (!inRange(r6, _1n6, secp256k1_CURVE.p))
|
237017
237090
|
return false;
|
237018
237091
|
const s7 = num(sig.subarray(32, 64));
|
237019
|
-
if (!inRange(s7, _1n6,
|
237092
|
+
if (!inRange(s7, _1n6, secp256k1_CURVE.n))
|
237020
237093
|
return false;
|
237021
237094
|
const e10 = challenge(numTo32b(r6), pointToBytes(P5), m7);
|
237022
|
-
const R7 =
|
237023
|
-
|
237095
|
+
const R7 = Point.BASE.multiplyUnsafe(s7).add(P5.multiplyUnsafe(modN(-e10)));
|
237096
|
+
const { x: x6, y: y4 } = R7.toAffine();
|
237097
|
+
if (R7.is0() || !hasEven(y4) || x6 !== r6)
|
237024
237098
|
return false;
|
237025
237099
|
return true;
|
237026
237100
|
} catch (error44) {
|
237027
237101
|
return false;
|
237028
237102
|
}
|
237029
237103
|
}
|
237030
|
-
var
|
237104
|
+
var secp256k1_CURVE, _0n6, _1n6, _2n4, divNearest = (a7, b4) => (a7 + b4 / _2n4) / b4, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes = (point) => point.toBytes(true).slice(1), numTo32b = (n6) => numberToBytesBE(n6, 32), modP = (x6) => mod(x6, secp256k1_CURVE.p), modN = (x6) => mod(x6, secp256k1_CURVE.n), Point, hasEven = (y4) => y4 % _2n4 === _0n6, num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
|
237031
237105
|
var init_secp256k1 = __esm(() => {
|
237032
237106
|
init_sha2();
|
237033
237107
|
init_utils2();
|
237034
237108
|
init__shortw_utils();
|
237035
237109
|
init_hash_to_curve();
|
237036
237110
|
init_modular();
|
237037
|
-
init_utils3();
|
237038
237111
|
init_weierstrass();
|
237112
|
+
init_utils3();
|
237039
237113
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
237040
|
-
|
237041
|
-
|
237114
|
+
secp256k1_CURVE = {
|
237115
|
+
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
|
237116
|
+
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
237117
|
+
h: BigInt(1),
|
237118
|
+
a: BigInt(0),
|
237119
|
+
b: BigInt(7),
|
237120
|
+
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
237121
|
+
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
237122
|
+
};
|
237042
237123
|
_0n6 = BigInt(0);
|
237043
237124
|
_1n6 = BigInt(1);
|
237044
237125
|
_2n4 = BigInt(2);
|
237045
|
-
Fpk1 = Field(
|
237126
|
+
Fpk1 = Field(secp256k1_CURVE.p, undefined, undefined, { sqrt: sqrtMod });
|
237046
237127
|
secp256k1 = createCurve({
|
237047
|
-
|
237048
|
-
b: BigInt(7),
|
237128
|
+
...secp256k1_CURVE,
|
237049
237129
|
Fp: Fpk1,
|
237050
|
-
n: secp256k1N,
|
237051
|
-
Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
|
237052
|
-
Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
|
237053
|
-
h: BigInt(1),
|
237054
237130
|
lowS: true,
|
237055
237131
|
endo: {
|
237056
237132
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
237057
237133
|
splitScalar: (k5) => {
|
237058
|
-
const n6 =
|
237134
|
+
const n6 = secp256k1_CURVE.n;
|
237059
237135
|
const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
|
237060
237136
|
const b1 = -_1n6 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
|
237061
237137
|
const a22 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
|
@@ -237079,7 +237155,7 @@ var init_secp256k1 = __esm(() => {
|
|
237079
237155
|
}
|
237080
237156
|
}, sha256);
|
237081
237157
|
TAGGED_HASH_PREFIXES = {};
|
237082
|
-
Point = /* @__PURE__ */ (() => secp256k1.
|
237158
|
+
Point = /* @__PURE__ */ (() => secp256k1.Point)();
|
237083
237159
|
num = bytesToNumberBE;
|
237084
237160
|
schnorr = /* @__PURE__ */ (() => ({
|
237085
237161
|
getPublicKey: schnorrGetPublicKey,
|
@@ -237125,7 +237201,7 @@ var init_secp256k1 = __esm(() => {
|
|
237125
237201
|
B: BigInt("1771"),
|
237126
237202
|
Z: Fpk1.create(BigInt("-11"))
|
237127
237203
|
}))();
|
237128
|
-
secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.
|
237204
|
+
secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.Point, (scalars) => {
|
237129
237205
|
const { x: x6, y: y4 } = mapSWU(Fpk1.create(scalars[0]));
|
237130
237206
|
return isoMap(x6, y4);
|
237131
237207
|
}, {
|
@@ -238779,7 +238855,7 @@ async function localBatchGatewayRequest(parameters) {
|
|
238779
238855
|
const responses = [];
|
238780
238856
|
await Promise.all(queries.map(async (query, i6) => {
|
238781
238857
|
try {
|
238782
|
-
responses[i6] = await ccipRequest(query);
|
238858
|
+
responses[i6] = query.urls.includes(localBatchGatewayUrl) ? await localBatchGatewayRequest({ data: query.data, ccipRequest }) : await ccipRequest(query);
|
238783
238859
|
failures[i6] = false;
|
238784
238860
|
} catch (err) {
|
238785
238861
|
failures[i6] = true;
|
@@ -258053,9 +258129,9 @@ ${formattedErrors}`);
|
|
258053
258129
|
throw error$37;
|
258054
258130
|
}
|
258055
258131
|
}
|
258056
|
-
var ApplicationAccessTokenSchema = string$1().regex(/^sm_aat_
|
258057
|
-
var PersonalAccessTokenSchema = string$1().regex(/^sm_pat_
|
258058
|
-
var AccessTokenSchema = string$1().regex(/^sm_pat_
|
258132
|
+
var ApplicationAccessTokenSchema = string$1().regex(/^sm_aat_.+$/);
|
258133
|
+
var PersonalAccessTokenSchema = string$1().regex(/^sm_pat_.+$/);
|
258134
|
+
var AccessTokenSchema = string$1().regex(/^(sm_pat_.+|sm_aat_.+)$/);
|
258059
258135
|
function tryParseJson(value, defaultValue = null) {
|
258060
258136
|
try {
|
258061
258137
|
const parsed = JSON.parse(value);
|
@@ -258063,7 +258139,7 @@ function tryParseJson(value, defaultValue = null) {
|
|
258063
258139
|
return defaultValue;
|
258064
258140
|
}
|
258065
258141
|
return parsed;
|
258066
|
-
} catch (
|
258142
|
+
} catch (_err) {
|
258067
258143
|
return defaultValue;
|
258068
258144
|
}
|
258069
258145
|
}
|
@@ -263693,7 +263769,7 @@ async function findMonoRepoPackages(projectDir) {
|
|
263693
263769
|
}));
|
263694
263770
|
const allPaths = packagePaths.flat();
|
263695
263771
|
return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];
|
263696
|
-
} catch (
|
263772
|
+
} catch (_error) {
|
263697
263773
|
return [projectDir];
|
263698
263774
|
}
|
263699
263775
|
}
|
@@ -263764,7 +263840,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
263764
263840
|
var package_default = {
|
263765
263841
|
name: "@settlemint/sdk-cli",
|
263766
263842
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
263767
|
-
version: "2.
|
263843
|
+
version: "2.4.0-main1ce5f55f",
|
263768
263844
|
type: "module",
|
263769
263845
|
private: false,
|
263770
263846
|
license: "FSL-1.1-MIT",
|
@@ -263783,7 +263859,9 @@ var package_default = {
|
|
263783
263859
|
url: "https://github.com/settlemint/sdk/issues",
|
263784
263860
|
email: "support@settlemint.com"
|
263785
263861
|
},
|
263786
|
-
files: [
|
263862
|
+
files: [
|
263863
|
+
"dist"
|
263864
|
+
],
|
263787
263865
|
exports: {
|
263788
263866
|
"./*": {
|
263789
263867
|
types: "./dist/*.d.ts",
|
@@ -263809,13 +263887,14 @@ var package_default = {
|
|
263809
263887
|
devDependencies: {
|
263810
263888
|
"@commander-js/extra-typings": "14.0.0",
|
263811
263889
|
commander: "14.0.0",
|
263812
|
-
"@inquirer/confirm": "5.1.
|
263813
|
-
"@inquirer/input": "4.
|
263814
|
-
"@inquirer/password": "4.0.
|
263815
|
-
"@inquirer/select": "4.2.
|
263816
|
-
"@settlemint/sdk-js": "2.
|
263817
|
-
"@settlemint/sdk-utils": "2.
|
263818
|
-
"@
|
263890
|
+
"@inquirer/confirm": "5.1.13",
|
263891
|
+
"@inquirer/input": "4.2.0",
|
263892
|
+
"@inquirer/password": "4.0.16",
|
263893
|
+
"@inquirer/select": "4.2.4",
|
263894
|
+
"@settlemint/sdk-js": "2.4.0-main1ce5f55f",
|
263895
|
+
"@settlemint/sdk-utils": "2.4.0-main1ce5f55f",
|
263896
|
+
"@settlemint/sdk-viem": "2.4.0-main1ce5f55f",
|
263897
|
+
"@types/node": "24.0.10",
|
263819
263898
|
"@types/semver": "7.7.0",
|
263820
263899
|
"@types/which": "3.0.4",
|
263821
263900
|
"get-tsconfig": "4.10.1",
|
@@ -263823,13 +263902,13 @@ var package_default = {
|
|
263823
263902
|
"is-in-ci": "1.0.0",
|
263824
263903
|
semver: "7.7.2",
|
263825
263904
|
slugify: "1.6.6",
|
263826
|
-
viem: "2.31.
|
263905
|
+
viem: "2.31.6",
|
263827
263906
|
which: "5.0.0",
|
263828
263907
|
yaml: "2.8.0",
|
263829
263908
|
yoctocolors: "2.1.1"
|
263830
263909
|
},
|
263831
263910
|
peerDependencies: {
|
263832
|
-
hardhat: "2.
|
263911
|
+
hardhat: "2.25.0"
|
263833
263912
|
},
|
263834
263913
|
peerDependenciesMeta: {
|
263835
263914
|
hardhat: {
|
@@ -263884,7 +263963,7 @@ async function telemetry(data) {
|
|
263884
263963
|
signal: controller.signal
|
263885
263964
|
});
|
263886
263965
|
clearTimeout(timeout);
|
263887
|
-
} catch (
|
263966
|
+
} catch (_error) {}
|
263888
263967
|
}
|
263889
263968
|
|
263890
263969
|
// ../../node_modules/@commander-js/extra-typings/esm.mjs
|
@@ -276436,9 +276515,9 @@ ${formattedErrors}`);
|
|
276436
276515
|
throw error$372;
|
276437
276516
|
}
|
276438
276517
|
}
|
276439
|
-
var ApplicationAccessTokenSchema2 = string$12().regex(/^sm_aat_
|
276440
|
-
var PersonalAccessTokenSchema2 = string$12().regex(/^sm_pat_
|
276441
|
-
var AccessTokenSchema2 = string$12().regex(/^sm_pat_
|
276518
|
+
var ApplicationAccessTokenSchema2 = string$12().regex(/^sm_aat_.+$/);
|
276519
|
+
var PersonalAccessTokenSchema2 = string$12().regex(/^sm_pat_.+$/);
|
276520
|
+
var AccessTokenSchema2 = string$12().regex(/^(sm_pat_.+|sm_aat_.+)$/);
|
276442
276521
|
function tryParseJson2(value, defaultValue = null) {
|
276443
276522
|
try {
|
276444
276523
|
const parsed = JSON.parse(value);
|
@@ -276446,7 +276525,7 @@ function tryParseJson2(value, defaultValue = null) {
|
|
276446
276525
|
return defaultValue;
|
276447
276526
|
}
|
276448
276527
|
return parsed;
|
276449
|
-
} catch (
|
276528
|
+
} catch (_err) {
|
276450
276529
|
return defaultValue;
|
276451
276530
|
}
|
276452
276531
|
}
|
@@ -287875,8 +287954,9 @@ var workspaceList = (gqlClient) => {
|
|
287875
287954
|
const { workspaces } = await gqlClient.request(getWorkspacesAndApplications);
|
287876
287955
|
const allWorkspaces = workspaces.reduce((acc, workspace) => {
|
287877
287956
|
acc.push(workspace);
|
287878
|
-
if (workspace.childWorkspaces)
|
287957
|
+
if (workspace.childWorkspaces) {
|
287879
287958
|
acc.push(...workspace.childWorkspaces);
|
287959
|
+
}
|
287880
287960
|
return acc;
|
287881
287961
|
}, []);
|
287882
287962
|
return allWorkspaces.sort((a3, b) => a3.name.localeCompare(b.name));
|
@@ -287903,8 +287983,9 @@ var workspaceDelete = (gqlClient) => {
|
|
287903
287983
|
var workspaceAddCredits = (gqlClient) => {
|
287904
287984
|
return async (workspaceId, amount) => {
|
287905
287985
|
const id = validate2(IdSchema2, workspaceId);
|
287906
|
-
if (amount <= 0)
|
287986
|
+
if (amount <= 0) {
|
287907
287987
|
throw new Error("Credit amount must be a positive number");
|
287988
|
+
}
|
287908
287989
|
const { addCredits: result } = await gqlClient.request(addCredits, {
|
287909
287990
|
workspaceId: id,
|
287910
287991
|
amount
|
@@ -288026,8 +288107,9 @@ var applicationAccessTokenCreate = (gqlClient) => {
|
|
288026
288107
|
...otherArgs,
|
288027
288108
|
applicationId: application.id
|
288028
288109
|
});
|
288029
|
-
if (!applicationAccessToken.token)
|
288110
|
+
if (!applicationAccessToken.token) {
|
288030
288111
|
throw new Error("Failed to create application access token");
|
288112
|
+
}
|
288031
288113
|
return applicationAccessToken.token;
|
288032
288114
|
};
|
288033
288115
|
};
|
@@ -288040,7 +288122,7 @@ function setClusterServiceDefaults(args) {
|
|
288040
288122
|
}
|
288041
288123
|
function setNetworkDefaults(args) {
|
288042
288124
|
const clusterServiceArgs = setClusterServiceDefaults(args);
|
288043
|
-
if (args.consensusAlgorithm === "BESU_QBFT")
|
288125
|
+
if (args.consensusAlgorithm === "BESU_QBFT") {
|
288044
288126
|
return {
|
288045
288127
|
...clusterServiceArgs,
|
288046
288128
|
chainId: args.chainId ?? 46040,
|
@@ -288050,6 +288132,7 @@ function setNetworkDefaults(args) {
|
|
288050
288132
|
gasPrice: args.gasPrice ?? 0,
|
288051
288133
|
secondsPerBlock: args.secondsPerBlock ?? 2
|
288052
288134
|
};
|
288135
|
+
}
|
288053
288136
|
return clusterServiceArgs;
|
288054
288137
|
}
|
288055
288138
|
var BlockchainNetworkFragment = graphql(`
|
@@ -288212,6 +288295,20 @@ var restartBlockchainNetwork = graphql(`
|
|
288212
288295
|
}
|
288213
288296
|
}
|
288214
288297
|
`, [BlockchainNetworkFragment]);
|
288298
|
+
var pauseBlockchainNetwork = graphql(`
|
288299
|
+
mutation PauseBlockchainNetwork($uniqueName: String!) {
|
288300
|
+
pauseBlockchainNetworkByUniqueName(uniqueName: $uniqueName) {
|
288301
|
+
...BlockchainNetwork
|
288302
|
+
}
|
288303
|
+
}
|
288304
|
+
`, [BlockchainNetworkFragment]);
|
288305
|
+
var resumeBlockchainNetwork = graphql(`
|
288306
|
+
mutation ResumeBlockchainNetwork($uniqueName: String!) {
|
288307
|
+
resumeBlockchainNetworkByUniqueName(uniqueName: $uniqueName) {
|
288308
|
+
...BlockchainNetwork
|
288309
|
+
}
|
288310
|
+
}
|
288311
|
+
`, [BlockchainNetworkFragment]);
|
288215
288312
|
var blockchainNetworkList = (gqlClient) => {
|
288216
288313
|
return async (applicationUniqueName) => {
|
288217
288314
|
const { blockchainNetworksByUniqueName: { items } } = await gqlClient.request(getBlockchainNetworks, { applicationUniqueName });
|
@@ -288246,6 +288343,14 @@ var blockchainNetworkRestart = (gqlClient) => async (blockchainNetworkUniqueName
|
|
288246
288343
|
const { restartBlockchainNetworkByUniqueName: blockchainNetwork } = await gqlClient.request(restartBlockchainNetwork, { uniqueName: blockchainNetworkUniqueName });
|
288247
288344
|
return blockchainNetwork;
|
288248
288345
|
};
|
288346
|
+
var blockchainNetworkPause = (gqlClient) => async (blockchainNetworkUniqueName) => {
|
288347
|
+
const { pauseBlockchainNetworkByUniqueName: blockchainNetwork } = await gqlClient.request(pauseBlockchainNetwork, { uniqueName: blockchainNetworkUniqueName });
|
288348
|
+
return blockchainNetwork;
|
288349
|
+
};
|
288350
|
+
var blockchainNetworkResume = (gqlClient) => async (blockchainNetworkUniqueName) => {
|
288351
|
+
const { resumeBlockchainNetworkByUniqueName: blockchainNetwork } = await gqlClient.request(resumeBlockchainNetwork, { uniqueName: blockchainNetworkUniqueName });
|
288352
|
+
return blockchainNetwork;
|
288353
|
+
};
|
288249
288354
|
var BlockchainNodeFragment = graphql(`
|
288250
288355
|
fragment BlockchainNode on BlockchainNode {
|
288251
288356
|
__typename
|
@@ -288379,6 +288484,20 @@ var restartBlockchainNode = graphql(`
|
|
288379
288484
|
}
|
288380
288485
|
}
|
288381
288486
|
`, [BlockchainNodeFragment]);
|
288487
|
+
var pauseBlockchainNode = graphql(`
|
288488
|
+
mutation PauseBlockchainNode($uniqueName: String!) {
|
288489
|
+
pauseBlockchainNodeByUniqueName(uniqueName: $uniqueName) {
|
288490
|
+
...BlockchainNode
|
288491
|
+
}
|
288492
|
+
}
|
288493
|
+
`, [BlockchainNodeFragment]);
|
288494
|
+
var resumeBlockchainNode = graphql(`
|
288495
|
+
mutation ResumeBlockchainNode($uniqueName: String!) {
|
288496
|
+
resumeBlockchainNodeByUniqueName(uniqueName: $uniqueName) {
|
288497
|
+
...BlockchainNode
|
288498
|
+
}
|
288499
|
+
}
|
288500
|
+
`, [BlockchainNodeFragment]);
|
288382
288501
|
var blockchainNodeList = (gqlClient) => {
|
288383
288502
|
return async (applicationUniqueName) => {
|
288384
288503
|
const { blockchainNodesByUniqueName: { items } } = await gqlClient.request(getBlockchainNodes, { applicationUniqueName });
|
@@ -288407,6 +288526,14 @@ var blockchainNodeRestart = (gqlClient) => async (blockchainNodeUniqueName) => {
|
|
288407
288526
|
const { restartBlockchainNodeByUniqueName: blockchainNode } = await gqlClient.request(restartBlockchainNode, { uniqueName: blockchainNodeUniqueName });
|
288408
288527
|
return blockchainNode;
|
288409
288528
|
};
|
288529
|
+
var blockchainNodePause = (gqlClient) => async (blockchainNodeUniqueName) => {
|
288530
|
+
const { pauseBlockchainNodeByUniqueName: blockchainNode } = await gqlClient.request(pauseBlockchainNode, { uniqueName: blockchainNodeUniqueName });
|
288531
|
+
return blockchainNode;
|
288532
|
+
};
|
288533
|
+
var blockchainNodeResume = (gqlClient) => async (blockchainNodeUniqueName) => {
|
288534
|
+
const { resumeBlockchainNodeByUniqueName: blockchainNode } = await gqlClient.request(resumeBlockchainNode, { uniqueName: blockchainNodeUniqueName });
|
288535
|
+
return blockchainNode;
|
288536
|
+
};
|
288410
288537
|
var CustomDeploymentFragment = graphql(`
|
288411
288538
|
fragment CustomDeployment on CustomDeployment {
|
288412
288539
|
id
|
@@ -288489,6 +288616,20 @@ var restartCustomDeployment = graphql(`
|
|
288489
288616
|
}
|
288490
288617
|
}
|
288491
288618
|
`, [CustomDeploymentFragment]);
|
288619
|
+
var pauseCustomDeployment = graphql(`
|
288620
|
+
mutation PauseCustomDeployment($uniqueName: String!) {
|
288621
|
+
pauseCustomDeploymentByUniqueName(uniqueName: $uniqueName) {
|
288622
|
+
...CustomDeployment
|
288623
|
+
}
|
288624
|
+
}
|
288625
|
+
`, [CustomDeploymentFragment]);
|
288626
|
+
var resumeCustomDeployment = graphql(`
|
288627
|
+
mutation ResumeCustomDeployment($uniqueName: String!) {
|
288628
|
+
resumeCustomDeploymentByUniqueName(uniqueName: $uniqueName) {
|
288629
|
+
...CustomDeployment
|
288630
|
+
}
|
288631
|
+
}
|
288632
|
+
`, [CustomDeploymentFragment]);
|
288492
288633
|
var customdeploymentList = (gqlClient) => {
|
288493
288634
|
return async (applicationUniqueName) => {
|
288494
288635
|
const { customDeploymentsByUniqueName: { items } } = await gqlClient.request(getCustomDeployments, { applicationUniqueName });
|
@@ -288525,6 +288666,14 @@ var customDeploymentRestart = (gqlClient) => async (customDeploymentUniqueName)
|
|
288525
288666
|
const { restartCustomDeploymentByUniqueName: customDeployment } = await gqlClient.request(restartCustomDeployment, { uniqueName: customDeploymentUniqueName });
|
288526
288667
|
return customDeployment;
|
288527
288668
|
};
|
288669
|
+
var customDeploymentPause = (gqlClient) => async (customDeploymentUniqueName) => {
|
288670
|
+
const { pauseCustomDeploymentByUniqueName: customDeployment } = await gqlClient.request(pauseCustomDeployment, { uniqueName: customDeploymentUniqueName });
|
288671
|
+
return customDeployment;
|
288672
|
+
};
|
288673
|
+
var customDeploymentResume = (gqlClient) => async (customDeploymentUniqueName) => {
|
288674
|
+
const { resumeCustomDeploymentByUniqueName: customDeployment } = await gqlClient.request(resumeCustomDeployment, { uniqueName: customDeploymentUniqueName });
|
288675
|
+
return customDeployment;
|
288676
|
+
};
|
288528
288677
|
var getFoundryEnvConfig = graphql(`
|
288529
288678
|
query GetFoundryEnvConfig($blockchainNodeUniqueName: String!) {
|
288530
288679
|
foundryEnvConfigByUniqueName(blockchainNodeUniqueName: $blockchainNodeUniqueName)
|
@@ -288601,6 +288750,20 @@ var restartLoadBalancer = graphql(`
|
|
288601
288750
|
}
|
288602
288751
|
}
|
288603
288752
|
`, [LoadBalancerFragment]);
|
288753
|
+
var pauseLoadBalancer = graphql(`
|
288754
|
+
mutation PauseLoadBalancer($uniqueName: String!) {
|
288755
|
+
pauseLoadBalancerByUniqueName(uniqueName: $uniqueName) {
|
288756
|
+
...LoadBalancer
|
288757
|
+
}
|
288758
|
+
}
|
288759
|
+
`, [LoadBalancerFragment]);
|
288760
|
+
var resumeLoadBalancer = graphql(`
|
288761
|
+
mutation ResumeLoadBalancer($uniqueName: String!) {
|
288762
|
+
resumeLoadBalancerByUniqueName(uniqueName: $uniqueName) {
|
288763
|
+
...LoadBalancer
|
288764
|
+
}
|
288765
|
+
}
|
288766
|
+
`, [LoadBalancerFragment]);
|
288604
288767
|
var loadBalancerRead = (gqlClient) => {
|
288605
288768
|
return async (loadBalancerUniqueName) => {
|
288606
288769
|
const { loadBalancerByUniqueName: loadBalancer } = await gqlClient.request(getLoadBalancer, { uniqueName: loadBalancerUniqueName });
|
@@ -288634,6 +288797,14 @@ var loadBalancerRestart = (gqlClient) => async (loadBalancerUniqueName) => {
|
|
288634
288797
|
const { restartLoadBalancerByUniqueName: loadBalancer } = await gqlClient.request(restartLoadBalancer, { uniqueName: loadBalancerUniqueName });
|
288635
288798
|
return loadBalancer;
|
288636
288799
|
};
|
288800
|
+
var loadBalancerPause = (gqlClient) => async (loadBalancerUniqueName) => {
|
288801
|
+
const { pauseLoadBalancerByUniqueName: loadBalancer } = await gqlClient.request(pauseLoadBalancer, { uniqueName: loadBalancerUniqueName });
|
288802
|
+
return loadBalancer;
|
288803
|
+
};
|
288804
|
+
var loadBalancerResume = (gqlClient) => async (loadBalancerUniqueName) => {
|
288805
|
+
const { resumeLoadBalancerByUniqueName: loadBalancer } = await gqlClient.request(resumeLoadBalancer, { uniqueName: loadBalancerUniqueName });
|
288806
|
+
return loadBalancer;
|
288807
|
+
};
|
288637
288808
|
var InsightsFragment = graphql(`
|
288638
288809
|
fragment Insights on Insights {
|
288639
288810
|
__typename
|
@@ -288707,6 +288878,20 @@ var restartInsights = graphql(`
|
|
288707
288878
|
}
|
288708
288879
|
}
|
288709
288880
|
`, [InsightsFragment]);
|
288881
|
+
var pauseInsights = graphql(`
|
288882
|
+
mutation PauseInsights($uniqueName: String!) {
|
288883
|
+
pauseInsightsByUniqueName(uniqueName: $uniqueName) {
|
288884
|
+
...Insights
|
288885
|
+
}
|
288886
|
+
}
|
288887
|
+
`, [InsightsFragment]);
|
288888
|
+
var resumeInsights = graphql(`
|
288889
|
+
mutation ResumeInsights($uniqueName: String!) {
|
288890
|
+
resumeInsightsByUniqueName(uniqueName: $uniqueName) {
|
288891
|
+
...Insights
|
288892
|
+
}
|
288893
|
+
}
|
288894
|
+
`, [InsightsFragment]);
|
288710
288895
|
var insightsList = (gqlClient) => {
|
288711
288896
|
return async (applicationUniqueName) => {
|
288712
288897
|
const { insightsListByUniqueName: { items } } = await gqlClient.request(getInsights, { applicationUniqueName });
|
@@ -288740,6 +288925,14 @@ var insightsRestart = (gqlClient) => async (insightsUniqueName) => {
|
|
288740
288925
|
const { restartInsightsByUniqueName: insights } = await gqlClient.request(restartInsights, { uniqueName: insightsUniqueName });
|
288741
288926
|
return insights;
|
288742
288927
|
};
|
288928
|
+
var insightsPause = (gqlClient) => async (insightsUniqueName) => {
|
288929
|
+
const { pauseInsightsByUniqueName: insights } = await gqlClient.request(pauseInsights, { uniqueName: insightsUniqueName });
|
288930
|
+
return insights;
|
288931
|
+
};
|
288932
|
+
var insightsResume = (gqlClient) => async (insightsUniqueName) => {
|
288933
|
+
const { resumeInsightsByUniqueName: insights } = await gqlClient.request(resumeInsights, { uniqueName: insightsUniqueName });
|
288934
|
+
return insights;
|
288935
|
+
};
|
288743
288936
|
var IntegrationFragment = graphql(`
|
288744
288937
|
fragment Integration on Integration {
|
288745
288938
|
__typename
|
@@ -288809,6 +289002,20 @@ var restartIntegrationTool = graphql(`
|
|
288809
289002
|
}
|
288810
289003
|
}
|
288811
289004
|
`, [IntegrationFragment]);
|
289005
|
+
var pauseIntegrationTool = graphql(`
|
289006
|
+
mutation PauseIntegrationTool($uniqueName: String!) {
|
289007
|
+
pauseIntegrationByUniqueName(uniqueName: $uniqueName) {
|
289008
|
+
...Integration
|
289009
|
+
}
|
289010
|
+
}
|
289011
|
+
`, [IntegrationFragment]);
|
289012
|
+
var resumeIntegrationTool = graphql(`
|
289013
|
+
mutation ResumeIntegrationTool($uniqueName: String!) {
|
289014
|
+
resumeIntegrationByUniqueName(uniqueName: $uniqueName) {
|
289015
|
+
...Integration
|
289016
|
+
}
|
289017
|
+
}
|
289018
|
+
`, [IntegrationFragment]);
|
288812
289019
|
var integrationToolList = (gqlClient) => {
|
288813
289020
|
return async (applicationUniqueName) => {
|
288814
289021
|
const { integrationsByUniqueName: { items } } = await gqlClient.request(getIntegrations, { applicationUniqueName });
|
@@ -288836,6 +289043,14 @@ var integrationToolRestart = (gqlClient) => async (integrationUniqueName) => {
|
|
288836
289043
|
const { restartIntegrationByUniqueName: integration } = await gqlClient.request(restartIntegrationTool, { uniqueName: integrationUniqueName });
|
288837
289044
|
return integration;
|
288838
289045
|
};
|
289046
|
+
var integrationToolPause = (gqlClient) => async (integrationUniqueName) => {
|
289047
|
+
const { pauseIntegrationByUniqueName: integration } = await gqlClient.request(pauseIntegrationTool, { uniqueName: integrationUniqueName });
|
289048
|
+
return integration;
|
289049
|
+
};
|
289050
|
+
var integrationToolResume = (gqlClient) => async (integrationUniqueName) => {
|
289051
|
+
const { resumeIntegrationByUniqueName: integration } = await gqlClient.request(resumeIntegrationTool, { uniqueName: integrationUniqueName });
|
289052
|
+
return integration;
|
289053
|
+
};
|
288839
289054
|
var StorageFragment = graphql(`
|
288840
289055
|
fragment Storage on Storage {
|
288841
289056
|
__typename
|
@@ -288905,6 +289120,20 @@ var restartStorage = graphql(`
|
|
288905
289120
|
}
|
288906
289121
|
}
|
288907
289122
|
`, [StorageFragment]);
|
289123
|
+
var pauseStorage = graphql(`
|
289124
|
+
mutation PauseStorage($uniqueName: String!) {
|
289125
|
+
pauseStorageByUniqueName(uniqueName: $uniqueName) {
|
289126
|
+
...Storage
|
289127
|
+
}
|
289128
|
+
}
|
289129
|
+
`, [StorageFragment]);
|
289130
|
+
var resumeStorage = graphql(`
|
289131
|
+
mutation ResumeStorage($uniqueName: String!) {
|
289132
|
+
resumeStorageByUniqueName(uniqueName: $uniqueName) {
|
289133
|
+
...Storage
|
289134
|
+
}
|
289135
|
+
}
|
289136
|
+
`, [StorageFragment]);
|
288908
289137
|
var storageList = (gqlClient) => {
|
288909
289138
|
return async (applicationUniqueName) => {
|
288910
289139
|
const { storagesByUniqueName: { items } } = await gqlClient.request(getStorages, { applicationUniqueName });
|
@@ -288932,6 +289161,14 @@ var storageRestart = (gqlClient) => async (storageUniqueName) => {
|
|
288932
289161
|
const { restartStorageByUniqueName: storage } = await gqlClient.request(restartStorage, { uniqueName: storageUniqueName });
|
288933
289162
|
return storage;
|
288934
289163
|
};
|
289164
|
+
var storagePause = (gqlClient) => async (storageUniqueName) => {
|
289165
|
+
const { pauseStorageByUniqueName: storage } = await gqlClient.request(pauseStorage, { uniqueName: storageUniqueName });
|
289166
|
+
return storage;
|
289167
|
+
};
|
289168
|
+
var storageResume = (gqlClient) => async (storageUniqueName) => {
|
289169
|
+
const { resumeStorageByUniqueName: storage } = await gqlClient.request(resumeStorage, { uniqueName: storageUniqueName });
|
289170
|
+
return storage;
|
289171
|
+
};
|
288935
289172
|
var MiddlewareFragment = graphql(`
|
288936
289173
|
fragment Middleware on Middleware {
|
288937
289174
|
__typename
|
@@ -289032,6 +289269,20 @@ var restartMiddleware = graphql(`
|
|
289032
289269
|
}
|
289033
289270
|
}
|
289034
289271
|
`, [MiddlewareFragment]);
|
289272
|
+
var pauseMiddleware = graphql(`
|
289273
|
+
mutation PauseMiddleware($uniqueName: String!) {
|
289274
|
+
pauseMiddlewareByUniqueName(uniqueName: $uniqueName) {
|
289275
|
+
...Middleware
|
289276
|
+
}
|
289277
|
+
}
|
289278
|
+
`, [MiddlewareFragment]);
|
289279
|
+
var resumeMiddleware = graphql(`
|
289280
|
+
mutation ResumeMiddleware($uniqueName: String!) {
|
289281
|
+
resumeMiddlewareByUniqueName(uniqueName: $uniqueName) {
|
289282
|
+
...Middleware
|
289283
|
+
}
|
289284
|
+
}
|
289285
|
+
`, [MiddlewareFragment]);
|
289035
289286
|
var middlewareList = (gqlClient) => {
|
289036
289287
|
return async (applicationUniqueName) => {
|
289037
289288
|
const { middlewaresByUniqueName: { items } } = await gqlClient.request(getMiddlewares, { applicationUniqueName });
|
@@ -289076,6 +289327,14 @@ var middlewareRestart = (gqlClient) => async (middlewareUniqueName) => {
|
|
289076
289327
|
const { restartMiddlewareByUniqueName: middleware } = await gqlClient.request(restartMiddleware, { uniqueName: middlewareUniqueName });
|
289077
289328
|
return middleware;
|
289078
289329
|
};
|
289330
|
+
var middlewarePause = (gqlClient) => async (middlewareUniqueName) => {
|
289331
|
+
const { pauseMiddlewareByUniqueName: middleware } = await gqlClient.request(pauseMiddleware, { uniqueName: middlewareUniqueName });
|
289332
|
+
return middleware;
|
289333
|
+
};
|
289334
|
+
var middlewareResume = (gqlClient) => async (middlewareUniqueName) => {
|
289335
|
+
const { resumeMiddlewareByUniqueName: middleware } = await gqlClient.request(resumeMiddleware, { uniqueName: middlewareUniqueName });
|
289336
|
+
return middleware;
|
289337
|
+
};
|
289079
289338
|
var getPlatformConfigQuery = graphql(`
|
289080
289339
|
query platformConfig {
|
289081
289340
|
config {
|
@@ -289208,6 +289467,20 @@ var restartPrivateKey = graphql(`
|
|
289208
289467
|
}
|
289209
289468
|
}
|
289210
289469
|
`, [PrivateKeyFragment]);
|
289470
|
+
var pausePrivateKey = graphql(`
|
289471
|
+
mutation PausePrivateKey($uniqueName: String!) {
|
289472
|
+
pausePrivateKeyByUniqueName(uniqueName: $uniqueName) {
|
289473
|
+
...PrivateKey
|
289474
|
+
}
|
289475
|
+
}
|
289476
|
+
`, [PrivateKeyFragment]);
|
289477
|
+
var resumePrivateKey = graphql(`
|
289478
|
+
mutation ResumePrivateKey($uniqueName: String!) {
|
289479
|
+
resumePrivateKeyByUniqueName(uniqueName: $uniqueName) {
|
289480
|
+
...PrivateKey
|
289481
|
+
}
|
289482
|
+
}
|
289483
|
+
`, [PrivateKeyFragment]);
|
289211
289484
|
var privateKeyList = (gqlClient) => {
|
289212
289485
|
return async (applicationUniqueName) => {
|
289213
289486
|
const { privateKeysByUniqueName: { items } } = await gqlClient.request(getPrivateKeys, { applicationUniqueName });
|
@@ -289246,6 +289519,14 @@ var privateKeyRestart = (gqlClient) => async (privateKeyUniqueName) => {
|
|
289246
289519
|
const { restartPrivateKeyByUniqueName: privateKey } = await gqlClient.request(restartPrivateKey, { uniqueName: privateKeyUniqueName });
|
289247
289520
|
return privateKey;
|
289248
289521
|
};
|
289522
|
+
var privateKeyPause = (gqlClient) => async (privateKeyUniqueName) => {
|
289523
|
+
const { pausePrivateKeyByUniqueName: privateKey } = await gqlClient.request(pausePrivateKey, { uniqueName: privateKeyUniqueName });
|
289524
|
+
return privateKey;
|
289525
|
+
};
|
289526
|
+
var privateKeyResume = (gqlClient) => async (privateKeyUniqueName) => {
|
289527
|
+
const { resumePrivateKeyByUniqueName: privateKey } = await gqlClient.request(resumePrivateKey, { uniqueName: privateKeyUniqueName });
|
289528
|
+
return privateKey;
|
289529
|
+
};
|
289249
289530
|
var ClientOptionsSchema = exports_external.object({
|
289250
289531
|
accessToken: AccessTokenSchema2,
|
289251
289532
|
instance: UrlSchema2
|
@@ -289266,26 +289547,30 @@ async function getPincodeVerificationChallenges({ userWalletAddress, accessToken
|
|
289266
289547
|
}
|
289267
289548
|
});
|
289268
289549
|
if (!response.ok) {
|
289269
|
-
if (response.status === 404)
|
289550
|
+
if (response.status === 404) {
|
289270
289551
|
throw new Error(`No user wallet found with address '${userWalletAddress}' for node '${nodeId}'`);
|
289552
|
+
}
|
289271
289553
|
throw new Error("Failed to get verification challenge");
|
289272
289554
|
}
|
289273
289555
|
const verificationChallenges = await response.json();
|
289274
289556
|
return verificationChallenges;
|
289275
289557
|
}
|
289276
289558
|
function getPincodeVerificationChallengeResponse({ verificationChallenge, pincode }) {
|
289277
|
-
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt)
|
289559
|
+
if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) {
|
289278
289560
|
throw new Error("Could not authenticate pin code, invalid challenge format");
|
289561
|
+
}
|
289279
289562
|
const { secret, salt } = verificationChallenge.challenge;
|
289280
289563
|
return generateResponse(pincode, salt, secret);
|
289281
289564
|
}
|
289282
289565
|
function createSettleMintClient(options) {
|
289283
289566
|
ensureServer();
|
289284
|
-
if (options.instance === STANDALONE_INSTANCE2 || options.instance === LOCAL_INSTANCE2)
|
289285
|
-
if (options.anonymous)
|
289567
|
+
if (options.instance === STANDALONE_INSTANCE2 || options.instance === LOCAL_INSTANCE2) {
|
289568
|
+
if (options.anonymous) {
|
289286
289569
|
options.instance = "https://console.settlemint.com";
|
289287
|
-
else
|
289570
|
+
} else {
|
289288
289571
|
throw new Error("Standalone and local instances cannot connect to the SettleMint platform");
|
289572
|
+
}
|
289573
|
+
}
|
289289
289574
|
const validatedOptions = options.anonymous ? validate2(exports_external.object({
|
289290
289575
|
...ClientOptionsSchema.shape,
|
289291
289576
|
accessToken: exports_external.literal("")
|
@@ -289325,57 +289610,75 @@ function createSettleMintClient(options) {
|
|
289325
289610
|
read: blockchainNetworkRead(gqlClient),
|
289326
289611
|
create: blockchainNetworkCreate(gqlClient),
|
289327
289612
|
delete: blockchainNetworkDelete(gqlClient),
|
289328
|
-
restart: blockchainNetworkRestart(gqlClient)
|
289613
|
+
restart: blockchainNetworkRestart(gqlClient),
|
289614
|
+
pause: blockchainNetworkPause(gqlClient),
|
289615
|
+
resume: blockchainNetworkResume(gqlClient)
|
289329
289616
|
},
|
289330
289617
|
blockchainNode: {
|
289331
289618
|
list: blockchainNodeList(gqlClient),
|
289332
289619
|
read: blockchainNodeRead(gqlClient),
|
289333
289620
|
create: blockchainNodeCreate(gqlClient),
|
289334
|
-
restart: blockchainNodeRestart(gqlClient)
|
289621
|
+
restart: blockchainNodeRestart(gqlClient),
|
289622
|
+
pause: blockchainNodePause(gqlClient),
|
289623
|
+
resume: blockchainNodeResume(gqlClient)
|
289335
289624
|
},
|
289336
289625
|
loadBalancer: {
|
289337
289626
|
list: loadBalancerList(gqlClient),
|
289338
289627
|
read: loadBalancerRead(gqlClient),
|
289339
289628
|
create: loadBalancerCreate(gqlClient),
|
289340
|
-
restart: loadBalancerRestart(gqlClient)
|
289629
|
+
restart: loadBalancerRestart(gqlClient),
|
289630
|
+
pause: loadBalancerPause(gqlClient),
|
289631
|
+
resume: loadBalancerResume(gqlClient)
|
289341
289632
|
},
|
289342
289633
|
middleware: {
|
289343
289634
|
list: middlewareList(gqlClient),
|
289344
289635
|
read: middlewareRead(gqlClient),
|
289345
289636
|
graphSubgraphs: graphMiddlewareSubgraphs(gqlClient),
|
289346
289637
|
create: middlewareCreate(gqlClient),
|
289347
|
-
restart: middlewareRestart(gqlClient)
|
289638
|
+
restart: middlewareRestart(gqlClient),
|
289639
|
+
pause: middlewarePause(gqlClient),
|
289640
|
+
resume: middlewareResume(gqlClient)
|
289348
289641
|
},
|
289349
289642
|
integrationTool: {
|
289350
289643
|
list: integrationToolList(gqlClient),
|
289351
289644
|
read: integrationToolRead(gqlClient),
|
289352
289645
|
create: integrationToolCreate(gqlClient),
|
289353
|
-
restart: integrationToolRestart(gqlClient)
|
289646
|
+
restart: integrationToolRestart(gqlClient),
|
289647
|
+
pause: integrationToolPause(gqlClient),
|
289648
|
+
resume: integrationToolResume(gqlClient)
|
289354
289649
|
},
|
289355
289650
|
storage: {
|
289356
289651
|
list: storageList(gqlClient),
|
289357
289652
|
read: storageRead(gqlClient),
|
289358
289653
|
create: storageCreate(gqlClient),
|
289359
|
-
restart: storageRestart(gqlClient)
|
289654
|
+
restart: storageRestart(gqlClient),
|
289655
|
+
pause: storagePause(gqlClient),
|
289656
|
+
resume: storageResume(gqlClient)
|
289360
289657
|
},
|
289361
289658
|
privateKey: {
|
289362
289659
|
list: privateKeyList(gqlClient),
|
289363
289660
|
read: privatekeyRead(gqlClient),
|
289364
289661
|
create: privateKeyCreate(gqlClient),
|
289365
|
-
restart: privateKeyRestart(gqlClient)
|
289662
|
+
restart: privateKeyRestart(gqlClient),
|
289663
|
+
pause: privateKeyPause(gqlClient),
|
289664
|
+
resume: privateKeyResume(gqlClient)
|
289366
289665
|
},
|
289367
289666
|
insights: {
|
289368
289667
|
list: insightsList(gqlClient),
|
289369
289668
|
read: insightsRead(gqlClient),
|
289370
289669
|
create: insightsCreate(gqlClient),
|
289371
|
-
restart: insightsRestart(gqlClient)
|
289670
|
+
restart: insightsRestart(gqlClient),
|
289671
|
+
pause: insightsPause(gqlClient),
|
289672
|
+
resume: insightsResume(gqlClient)
|
289372
289673
|
},
|
289373
289674
|
customDeployment: {
|
289374
289675
|
list: customdeploymentList(gqlClient),
|
289375
289676
|
read: customdeploymentRead(gqlClient),
|
289376
289677
|
create: customdeploymentCreate(gqlClient),
|
289377
289678
|
update: customdeploymentUpdate(gqlClient),
|
289378
|
-
restart: customDeploymentRestart(gqlClient)
|
289679
|
+
restart: customDeploymentRestart(gqlClient),
|
289680
|
+
pause: customDeploymentPause(gqlClient),
|
289681
|
+
resume: customDeploymentResume(gqlClient)
|
289379
289682
|
},
|
289380
289683
|
foundry: { env: getEnv(gqlClient) },
|
289381
289684
|
applicationAccessToken: { create: applicationAccessTokenCreate(gqlClient) },
|
@@ -301270,16 +301573,63 @@ var glob3 = Object.assign(glob_3, {
|
|
301270
301573
|
unescape: unescape4
|
301271
301574
|
});
|
301272
301575
|
glob3.glob = glob3;
|
301576
|
+
function tryParseJson3(value2, defaultValue = null) {
|
301577
|
+
try {
|
301578
|
+
const parsed = JSON.parse(value2);
|
301579
|
+
if (parsed === undefined || parsed === null) {
|
301580
|
+
return defaultValue;
|
301581
|
+
}
|
301582
|
+
return parsed;
|
301583
|
+
} catch (_err) {
|
301584
|
+
return defaultValue;
|
301585
|
+
}
|
301586
|
+
}
|
301587
|
+
async function findMonoRepoRoot2(startDir) {
|
301588
|
+
const lockFilePath = await findUp([
|
301589
|
+
"package-lock.json",
|
301590
|
+
"yarn.lock",
|
301591
|
+
"pnpm-lock.yaml",
|
301592
|
+
"bun.lockb",
|
301593
|
+
"bun.lock"
|
301594
|
+
], { cwd: startDir });
|
301595
|
+
if (lockFilePath) {
|
301596
|
+
const packageJsonPath = join3(dirname3(lockFilePath), "package.json");
|
301597
|
+
const hasWorkSpaces = await packageJsonHasWorkspaces2(packageJsonPath);
|
301598
|
+
return hasWorkSpaces ? dirname3(lockFilePath) : null;
|
301599
|
+
}
|
301600
|
+
let currentDir = startDir;
|
301601
|
+
while (currentDir !== "/") {
|
301602
|
+
const packageJsonPath = join3(currentDir, "package.json");
|
301603
|
+
if (await packageJsonHasWorkspaces2(packageJsonPath)) {
|
301604
|
+
return currentDir;
|
301605
|
+
}
|
301606
|
+
const parentDir = dirname3(currentDir);
|
301607
|
+
if (parentDir === currentDir) {
|
301608
|
+
break;
|
301609
|
+
}
|
301610
|
+
currentDir = parentDir;
|
301611
|
+
}
|
301612
|
+
return null;
|
301613
|
+
}
|
301614
|
+
async function packageJsonHasWorkspaces2(packageJsonPath) {
|
301615
|
+
if (await exists3(packageJsonPath)) {
|
301616
|
+
const packageJson = tryParseJson3(await readFile3(packageJsonPath, "utf-8"));
|
301617
|
+
if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {
|
301618
|
+
return true;
|
301619
|
+
}
|
301620
|
+
}
|
301621
|
+
return false;
|
301622
|
+
}
|
301273
301623
|
|
301274
301624
|
// ../utils/dist/json.js
|
301275
|
-
function
|
301625
|
+
function tryParseJson4(value2, defaultValue = null) {
|
301276
301626
|
try {
|
301277
301627
|
const parsed = JSON.parse(value2);
|
301278
301628
|
if (parsed === undefined || parsed === null) {
|
301279
301629
|
return defaultValue;
|
301280
301630
|
}
|
301281
301631
|
return parsed;
|
301282
|
-
} catch (
|
301632
|
+
} catch (_err) {
|
301283
301633
|
return defaultValue;
|
301284
301634
|
}
|
301285
301635
|
}
|
@@ -301291,7 +301641,7 @@ function extractJsonObject(value2) {
|
|
301291
301641
|
if (!result) {
|
301292
301642
|
return null;
|
301293
301643
|
}
|
301294
|
-
return
|
301644
|
+
return tryParseJson4(result[0]);
|
301295
301645
|
}
|
301296
301646
|
|
301297
301647
|
// src/utils/config.ts
|
@@ -301306,8 +301656,8 @@ async function readConfig() {
|
|
301306
301656
|
await ensureConfigDir();
|
301307
301657
|
try {
|
301308
301658
|
const content = await readFile4(CONFIG_FILE, "utf-8");
|
301309
|
-
return
|
301310
|
-
} catch (
|
301659
|
+
return tryParseJson4(content, { instances: {} });
|
301660
|
+
} catch (_error) {
|
301311
301661
|
return { instances: {} };
|
301312
301662
|
}
|
301313
301663
|
}
|
@@ -301477,7 +301827,7 @@ var getApplicationOrPersonalAccessToken = async ({
|
|
301477
301827
|
}) => {
|
301478
301828
|
const applicationAccessToken = env2.SETTLEMINT_ACCESS_TOKEN;
|
301479
301829
|
const instanceUrl = sanitizeInstanceUrl(instance);
|
301480
|
-
const personalAccessToken = (await getInstanceCredentials(instanceUrl))?.personalAccessToken;
|
301830
|
+
const personalAccessToken = (await getInstanceCredentials(instanceUrl, false))?.personalAccessToken;
|
301481
301831
|
const preferredToken = prefer === "application" ? applicationAccessToken : personalAccessToken;
|
301482
301832
|
const fallbackToken = prefer === "application" ? personalAccessToken : applicationAccessToken;
|
301483
301833
|
const allowFallback = prefer === "application";
|
@@ -302892,7 +303242,7 @@ var inputTheme = {
|
|
302892
303242
|
validationFailureMode: "keep"
|
302893
303243
|
};
|
302894
303244
|
var esm_default2 = createPrompt((config4, done) => {
|
302895
|
-
const { required: required4, validate: validate3 = () => true } = config4;
|
303245
|
+
const { required: required4, validate: validate3 = () => true, prefill = "tab" } = config4;
|
302896
303246
|
const theme = makeTheme(inputTheme, config4.theme);
|
302897
303247
|
const [status, setStatus] = useState("idle");
|
302898
303248
|
const [defaultValue = "", setDefaultValue] = useState(config4.default);
|
@@ -302932,6 +303282,12 @@ var esm_default2 = createPrompt((config4, done) => {
|
|
302932
303282
|
setError(undefined);
|
302933
303283
|
}
|
302934
303284
|
});
|
303285
|
+
useEffect((rl) => {
|
303286
|
+
if (prefill === "editable" && defaultValue) {
|
303287
|
+
rl.write(defaultValue);
|
303288
|
+
setValue(defaultValue);
|
303289
|
+
}
|
303290
|
+
}, []);
|
302935
303291
|
const message = theme.style.message(config4.message, status);
|
302936
303292
|
let formattedValue = value4;
|
302937
303293
|
if (typeof config4.transformer === "function") {
|
@@ -304887,8 +305243,11 @@ function observe(observerId, callbacks, fn) {
|
|
304887
305243
|
if (!listeners2.some((cb) => cb.id === callbackId))
|
304888
305244
|
return;
|
304889
305245
|
const cleanup2 = cleanupCache.get(observerId);
|
304890
|
-
if (listeners2.length === 1 && cleanup2)
|
304891
|
-
cleanup2();
|
305246
|
+
if (listeners2.length === 1 && cleanup2) {
|
305247
|
+
const p5 = cleanup2();
|
305248
|
+
if (p5 instanceof Promise)
|
305249
|
+
p5.catch(() => {});
|
305250
|
+
}
|
304892
305251
|
unsubscribe();
|
304893
305252
|
};
|
304894
305253
|
const listeners = getListeners();
|
@@ -305027,9 +305386,9 @@ function watchContractEvent(client, parameters) {
|
|
305027
305386
|
return poll_;
|
305028
305387
|
if (typeof fromBlock === "bigint")
|
305029
305388
|
return true;
|
305030
|
-
if (client.transport.type === "webSocket")
|
305389
|
+
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
305031
305390
|
return false;
|
305032
|
-
if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
|
305391
|
+
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
305033
305392
|
return false;
|
305034
305393
|
return true;
|
305035
305394
|
})();
|
@@ -305130,7 +305489,7 @@ function watchContractEvent(client, parameters) {
|
|
305130
305489
|
try {
|
305131
305490
|
const transport = (() => {
|
305132
305491
|
if (client.transport.type === "fallback") {
|
305133
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
|
305492
|
+
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
305134
305493
|
if (!transport2)
|
305135
305494
|
return client.transport;
|
305136
305495
|
return transport2.value;
|
@@ -307018,9 +307377,10 @@ async function simulateBlocks(client, parameters) {
|
|
307018
307377
|
const calls = block2.calls.map((call_) => {
|
307019
307378
|
const call2 = call_;
|
307020
307379
|
const account = call2.account ? parseAccount(call2.account) : undefined;
|
307380
|
+
const data = call2.abi ? encodeFunctionData(call2) : call2.data;
|
307021
307381
|
const request2 = {
|
307022
307382
|
...call2,
|
307023
|
-
data: call2.
|
307383
|
+
data: call2.dataSuffix ? concat2([data || "0x", call2.dataSuffix]) : data,
|
307024
307384
|
from: call2.from ?? account?.address
|
307025
307385
|
};
|
307026
307386
|
assertRequest(request2);
|
@@ -307067,7 +307427,7 @@ async function simulateBlocks(client, parameters) {
|
|
307067
307427
|
return;
|
307068
307428
|
return getContractError(error45, {
|
307069
307429
|
abi: abi2 ?? [],
|
307070
|
-
address: to,
|
307430
|
+
address: to ?? "0x",
|
307071
307431
|
args,
|
307072
307432
|
functionName: functionName ?? "<unknown>"
|
307073
307433
|
});
|
@@ -308009,14 +308369,6 @@ async function simulateCalls(client, parameters) {
|
|
308009
308369
|
});
|
308010
308370
|
return accessList.map(({ address, storageKeys }) => storageKeys.length > 0 ? address : null);
|
308011
308371
|
})).then((x6) => x6.flat().filter(Boolean)) : [];
|
308012
|
-
const resultsStateOverrides = stateOverrides?.map((override) => {
|
308013
|
-
if (override.address === account?.address)
|
308014
|
-
return {
|
308015
|
-
...override,
|
308016
|
-
nonce: 0
|
308017
|
-
};
|
308018
|
-
return override;
|
308019
|
-
});
|
308020
308372
|
const blocks = await simulateBlocks(client, {
|
308021
308373
|
blockNumber,
|
308022
308374
|
blockTag,
|
@@ -308046,12 +308398,11 @@ async function simulateCalls(client, parameters) {
|
|
308046
308398
|
}
|
308047
308399
|
] : [],
|
308048
308400
|
{
|
308049
|
-
calls: [...calls, {}].map((call2
|
308401
|
+
calls: [...calls, {}].map((call2) => ({
|
308050
308402
|
...call2,
|
308051
|
-
from: account?.address
|
308052
|
-
nonce: index2
|
308403
|
+
from: account?.address
|
308053
308404
|
})),
|
308054
|
-
stateOverrides
|
308405
|
+
stateOverrides
|
308055
308406
|
},
|
308056
308407
|
...traceAssetChanges ? [
|
308057
308408
|
{
|
@@ -308299,9 +308650,9 @@ function watchBlockNumber(client, { emitOnBegin = false, emitMissed = false, onB
|
|
308299
308650
|
const enablePolling = (() => {
|
308300
308651
|
if (typeof poll_ !== "undefined")
|
308301
308652
|
return poll_;
|
308302
|
-
if (client.transport.type === "webSocket")
|
308653
|
+
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
308303
308654
|
return false;
|
308304
|
-
if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
|
308655
|
+
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
308305
308656
|
return false;
|
308306
308657
|
return true;
|
308307
308658
|
})();
|
@@ -308353,7 +308704,7 @@ function watchBlockNumber(client, { emitOnBegin = false, emitMissed = false, onB
|
|
308353
308704
|
try {
|
308354
308705
|
const transport = (() => {
|
308355
308706
|
if (client.transport.type === "fallback") {
|
308356
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
|
308707
|
+
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
308357
308708
|
if (!transport2)
|
308358
308709
|
return client.transport;
|
308359
308710
|
return transport2.value;
|
@@ -308506,9 +308857,9 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
|
|
308506
308857
|
const enablePolling = (() => {
|
308507
308858
|
if (typeof poll_ !== "undefined")
|
308508
308859
|
return poll_;
|
308509
|
-
if (client.transport.type === "webSocket")
|
308860
|
+
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
308510
308861
|
return false;
|
308511
|
-
if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
|
308862
|
+
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
308512
308863
|
return false;
|
308513
308864
|
return true;
|
308514
308865
|
})();
|
@@ -308577,7 +308928,7 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
|
|
308577
308928
|
}
|
308578
308929
|
const transport = (() => {
|
308579
308930
|
if (client.transport.type === "fallback") {
|
308580
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
|
308931
|
+
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
308581
308932
|
if (!transport2)
|
308582
308933
|
return client.transport;
|
308583
308934
|
return transport2.value;
|
@@ -308590,7 +308941,7 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
|
|
308590
308941
|
if (!active)
|
308591
308942
|
return;
|
308592
308943
|
const block = await getAction(client, getBlock, "getBlock")({
|
308593
|
-
blockNumber: data.
|
308944
|
+
blockNumber: data.result?.number,
|
308594
308945
|
includeTransactions
|
308595
308946
|
}).catch(() => {});
|
308596
308947
|
if (!active)
|
@@ -308624,9 +308975,9 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
308624
308975
|
return poll_;
|
308625
308976
|
if (typeof fromBlock === "bigint")
|
308626
308977
|
return true;
|
308627
|
-
if (client.transport.type === "webSocket")
|
308978
|
+
if (client.transport.type === "webSocket" || client.transport.type === "ipc")
|
308628
308979
|
return false;
|
308629
|
-
if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
|
308980
|
+
if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
|
308630
308981
|
return false;
|
308631
308982
|
return true;
|
308632
308983
|
})();
|
@@ -308713,7 +309064,7 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
308713
309064
|
try {
|
308714
309065
|
const transport = (() => {
|
308715
309066
|
if (client.transport.type === "fallback") {
|
308716
|
-
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
|
309067
|
+
const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
|
308717
309068
|
if (!transport2)
|
308718
309069
|
return client.transport;
|
308719
309070
|
return transport2.value;
|
@@ -308780,7 +309131,7 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
|
|
308780
309131
|
}
|
308781
309132
|
// ../../node_modules/viem/_esm/actions/public/watchPendingTransactions.js
|
308782
309133
|
function watchPendingTransactions(client, { batch = true, onError, onTransactions, poll: poll_, pollingInterval = client.pollingInterval }) {
|
308783
|
-
const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
|
309134
|
+
const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket" && client.transport.type !== "ipc";
|
308784
309135
|
const pollPendingTransactions = () => {
|
308785
309136
|
const observerId = stringify3([
|
308786
309137
|
"watchPendingTransactions",
|
@@ -320438,7 +320789,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
|
|
320438
320789
|
try {
|
320439
320790
|
validate2(exports_external.string(), value4);
|
320440
320791
|
return true;
|
320441
|
-
} catch (
|
320792
|
+
} catch (_error) {
|
320442
320793
|
return "Invalid token name";
|
320443
320794
|
}
|
320444
320795
|
}
|
@@ -320491,7 +320842,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
|
|
320491
320842
|
try {
|
320492
320843
|
validate2(ApplicationAccessTokenSchema2, aat);
|
320493
320844
|
return aat;
|
320494
|
-
} catch (
|
320845
|
+
} catch (_error) {}
|
320495
320846
|
}
|
320496
320847
|
return esm_default5({
|
320497
320848
|
message: "What is the application access token for your application in SettleMint? (format: sm_aat_...)",
|
@@ -320499,7 +320850,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
|
|
320499
320850
|
try {
|
320500
320851
|
validate2(ApplicationAccessTokenSchema2, value4);
|
320501
320852
|
return true;
|
320502
|
-
} catch (
|
320853
|
+
} catch (_error) {
|
320503
320854
|
return "Invalid application access token, it should start with sm_aat_...";
|
320504
320855
|
}
|
320505
320856
|
}
|
@@ -320904,7 +321255,7 @@ async function instancePrompt({
|
|
320904
321255
|
try {
|
320905
321256
|
validate2(UrlSchema2, value4);
|
320906
321257
|
return true;
|
320907
|
-
} catch (
|
321258
|
+
} catch (_error) {
|
320908
321259
|
return "Invalid URL";
|
320909
321260
|
}
|
320910
321261
|
},
|
@@ -320988,7 +321339,7 @@ async function serviceUrlPrompt({
|
|
320988
321339
|
try {
|
320989
321340
|
validate2(UrlSchema2, value4);
|
320990
321341
|
return true;
|
320991
|
-
} catch (
|
321342
|
+
} catch (_error) {
|
320992
321343
|
return "Invalid URL";
|
320993
321344
|
}
|
320994
321345
|
},
|
@@ -321932,7 +322283,7 @@ async function projectNamePrompt(env2, argument) {
|
|
321932
322283
|
try {
|
321933
322284
|
validate2(exports_external.string(), value4);
|
321934
322285
|
return true;
|
321935
|
-
} catch (
|
322286
|
+
} catch (_error) {
|
321936
322287
|
return "Invalid projectname";
|
321937
322288
|
}
|
321938
322289
|
}
|
@@ -325920,7 +326271,7 @@ async function personalAccessTokenPrompt(env2, instance, accept) {
|
|
325920
326271
|
try {
|
325921
326272
|
validate2(PersonalAccessTokenSchema2, value4);
|
325922
326273
|
return true;
|
325923
|
-
} catch (
|
326274
|
+
} catch (_error) {
|
325924
326275
|
return "Invalid personal access token, it should start with sm_pat_...";
|
325925
326276
|
}
|
325926
326277
|
}
|
@@ -326001,7 +326352,7 @@ function loginCommand() {
|
|
326001
326352
|
});
|
326002
326353
|
try {
|
326003
326354
|
await loginSpinner(client);
|
326004
|
-
} catch (
|
326355
|
+
} catch (_error) {
|
326005
326356
|
cancel2(`Invalid personal access token for instance ${selectedInstance}`);
|
326006
326357
|
}
|
326007
326358
|
await storeCredentials(personalAccessToken, selectedInstance);
|
@@ -326151,13 +326502,17 @@ function addClusterServiceArgs(cmd2) {
|
|
326151
326502
|
// src/commands/platform/utils/wait-for-completion.ts
|
326152
326503
|
class TimeoutError2 extends Error {
|
326153
326504
|
}
|
326505
|
+
|
326506
|
+
class DeploymentFailedError extends Error {
|
326507
|
+
}
|
326154
326508
|
async function waitForCompletion({
|
326155
326509
|
settlemint,
|
326156
326510
|
type: type4,
|
326157
326511
|
uniqueName,
|
326158
326512
|
action,
|
326159
326513
|
maxTimeout = 10 * 60 * 1000,
|
326160
|
-
restartIfTimeout = false
|
326514
|
+
restartIfTimeout = false,
|
326515
|
+
restartOnError = false
|
326161
326516
|
}) {
|
326162
326517
|
const serviceType = SETTLEMINT_CLIENT_MAP[type4];
|
326163
326518
|
if (serviceType === "workspace" || serviceType === "application" || serviceType === "foundry" || serviceType === "applicationAccessToken" || serviceType === "platform" || serviceType === "wallet") {
|
@@ -326167,6 +326522,7 @@ async function waitForCompletion({
|
|
326167
326522
|
if (!service || !("read" in service)) {
|
326168
326523
|
throw new Error(`Service ${serviceType} does not support status checking`);
|
326169
326524
|
}
|
326525
|
+
let hasRestarted = false;
|
326170
326526
|
function showSpinner() {
|
326171
326527
|
return spinner({
|
326172
326528
|
startMessage: `Waiting for ${type4} to be ${getActionLabel(action)}`,
|
@@ -326176,33 +326532,20 @@ async function waitForCompletion({
|
|
326176
326532
|
while (true) {
|
326177
326533
|
try {
|
326178
326534
|
const resource = await service.read(uniqueName);
|
326179
|
-
if (resource.status === "COMPLETED") {
|
326180
|
-
if (spinner2) {
|
326181
|
-
spinner2.text = `${capitalizeFirstLetter2(type4)} is ${getActionLabel(action)}`;
|
326182
|
-
} else {
|
326183
|
-
note(`${capitalizeFirstLetter2(type4)} is ${getActionLabel(action)}`);
|
326184
|
-
}
|
326185
|
-
return true;
|
326186
|
-
}
|
326187
326535
|
if (resource.status === "FAILED") {
|
326188
|
-
|
326189
|
-
|
326190
|
-
|
326191
|
-
note(`${capitalizeFirstLetter2(type4)} failed to ${getActionLabel(action)}`);
|
326536
|
+
updateStatus(spinner2, `${capitalizeFirstLetter2(type4)} failed to ${getActionLabel(action)}`);
|
326537
|
+
if (restartOnError) {
|
326538
|
+
throw new DeploymentFailedError;
|
326192
326539
|
}
|
326193
326540
|
return false;
|
326194
326541
|
}
|
326195
|
-
if (
|
326196
|
-
spinner2
|
326197
|
-
|
326198
|
-
note(`${capitalizeFirstLetter2(type4)} is not ready yet (status: ${resource.status})`);
|
326199
|
-
}
|
326200
|
-
} catch (error45) {
|
326201
|
-
if (spinner2) {
|
326202
|
-
spinner2.text = `${capitalizeFirstLetter2(type4)} is not ready yet (status: UNKNOWN)`;
|
326203
|
-
} else {
|
326204
|
-
note(`${capitalizeFirstLetter2(type4)} is not ready yet (status: UNKNOWN)`);
|
326542
|
+
if (isActionComplete(action, resource.status)) {
|
326543
|
+
updateStatus(spinner2, `${capitalizeFirstLetter2(type4)} is ${getActionLabel(action)}`);
|
326544
|
+
return true;
|
326205
326545
|
}
|
326546
|
+
updateStatus(spinner2, `${capitalizeFirstLetter2(type4)} is not ready yet (status: ${resource.status})`);
|
326547
|
+
} catch (_error) {
|
326548
|
+
updateStatus(spinner2, `${capitalizeFirstLetter2(type4)} is not ready yet (status: UNKNOWN)`);
|
326206
326549
|
}
|
326207
326550
|
if (Date.now() - startTime > maxTimeout) {
|
326208
326551
|
throw new TimeoutError2(`Operation timed out after ${maxTimeout / 60000} minutes for ${type4} with unique name ${uniqueName}`);
|
@@ -326215,23 +326558,59 @@ async function waitForCompletion({
|
|
326215
326558
|
try {
|
326216
326559
|
return await showSpinner();
|
326217
326560
|
} catch (error45) {
|
326218
|
-
|
326219
|
-
if (restartIfTimeout && isTimeoutError) {
|
326561
|
+
if (!hasRestarted && shouldRestart(error45, restartIfTimeout)) {
|
326220
326562
|
note(`Restarting ${capitalizeFirstLetter2(type4)}`);
|
326563
|
+
hasRestarted = true;
|
326221
326564
|
await service.restart(uniqueName);
|
326222
326565
|
return showSpinner();
|
326223
326566
|
}
|
326224
326567
|
throw error45;
|
326225
326568
|
}
|
326226
326569
|
}
|
326227
|
-
function
|
326228
|
-
|
326229
|
-
|
326570
|
+
function shouldRestart(error45, restartIfTimeout) {
|
326571
|
+
const isSpinnerError = error45 instanceof SpinnerError;
|
326572
|
+
const isDeploymentFailedError = error45 instanceof DeploymentFailedError || isSpinnerError && error45.originalError instanceof DeploymentFailedError;
|
326573
|
+
if (isDeploymentFailedError) {
|
326574
|
+
return true;
|
326575
|
+
}
|
326576
|
+
const isTimeoutError = error45 instanceof TimeoutError2 || isSpinnerError && error45.originalError instanceof TimeoutError2;
|
326577
|
+
return restartIfTimeout && isTimeoutError;
|
326578
|
+
}
|
326579
|
+
function updateStatus(spinner2, message) {
|
326580
|
+
if (spinner2) {
|
326581
|
+
spinner2.text = message;
|
326582
|
+
} else {
|
326583
|
+
note(message);
|
326584
|
+
}
|
326585
|
+
}
|
326586
|
+
function isActionComplete(action, status) {
|
326587
|
+
switch (action) {
|
326588
|
+
case "pause":
|
326589
|
+
return status === "PAUSED" || status === "AUTO_PAUSED";
|
326590
|
+
case "resume":
|
326591
|
+
case "deploy":
|
326592
|
+
case "destroy":
|
326593
|
+
case "restart":
|
326594
|
+
return status === "COMPLETED";
|
326595
|
+
default:
|
326596
|
+
return false;
|
326230
326597
|
}
|
326231
|
-
|
326232
|
-
|
326598
|
+
}
|
326599
|
+
function getActionLabel(action) {
|
326600
|
+
switch (action) {
|
326601
|
+
case "restart":
|
326602
|
+
return "restarted";
|
326603
|
+
case "destroy":
|
326604
|
+
return "destroyed";
|
326605
|
+
case "pause":
|
326606
|
+
return "paused";
|
326607
|
+
case "resume":
|
326608
|
+
return "resumed";
|
326609
|
+
case "deploy":
|
326610
|
+
return "deployed";
|
326611
|
+
default:
|
326612
|
+
return "deployed";
|
326233
326613
|
}
|
326234
|
-
return "deployed";
|
326235
326614
|
}
|
326236
326615
|
|
326237
326616
|
// src/prompts/provider.prompt.ts
|
@@ -326312,9 +326691,9 @@ function getCreateCommand({
|
|
326312
326691
|
cmd2.alias(alias);
|
326313
326692
|
}
|
326314
326693
|
if (requiresDeployment) {
|
326315
|
-
cmd2.option("-w, --wait", "Wait until deployed").option("
|
326694
|
+
cmd2.option("-w, --wait", "Wait until deployed").option("--restart-if-timeout", "Restart if wait time is exceeded").option("--restart-on-error", "Restart if deployment fails");
|
326316
326695
|
}
|
326317
|
-
execute2(cmd2, async ({ acceptDefaults, prod, default: isDefault, wait: wait2, restartIfTimeout, provider, region }, createFunction) => {
|
326696
|
+
execute2(cmd2, async ({ acceptDefaults, prod, default: isDefault, wait: wait2, restartIfTimeout, restartOnError, provider, region }, createFunction) => {
|
326318
326697
|
intro(`Creating ${type4} in the SettleMint platform`);
|
326319
326698
|
const env2 = await loadEnv(false, !!prod);
|
326320
326699
|
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
@@ -326328,8 +326707,8 @@ function getCreateCommand({
|
|
326328
326707
|
instance
|
326329
326708
|
});
|
326330
326709
|
const platformConfig = await settlemint.platform.config();
|
326331
|
-
let selectedProvider
|
326332
|
-
let selectedRegion
|
326710
|
+
let selectedProvider;
|
326711
|
+
let selectedRegion;
|
326333
326712
|
if (cmd2.options.some((option) => option.long === "--provider")) {
|
326334
326713
|
selectedProvider = await providerPrompt(platformConfig, provider);
|
326335
326714
|
if (!selectedProvider) {
|
@@ -326358,7 +326737,8 @@ function getCreateCommand({
|
|
326358
326737
|
type: waitFor?.resourceType ?? type4,
|
326359
326738
|
uniqueName: waitFor?.uniqueName ?? result.uniqueName,
|
326360
326739
|
action: "deploy",
|
326361
|
-
restartIfTimeout
|
326740
|
+
restartIfTimeout,
|
326741
|
+
restartOnError
|
326362
326742
|
});
|
326363
326743
|
if (!isDeployed) {
|
326364
326744
|
throw new Error(`Failed to deploy ${waitFor?.resourceType ?? type4} ${waitFor?.uniqueName ?? result.uniqueName}`);
|
@@ -327540,7 +327920,7 @@ function privateKeyHsmCreateCommand() {
|
|
327540
327920
|
return baseAction({
|
327541
327921
|
...defaultArgs,
|
327542
327922
|
acceptDefaults
|
327543
|
-
}, async ({ settlemint, env: env2, showSpinner, provider, region }) => {
|
327923
|
+
}, async ({ settlemint, env: env2, showSpinner, provider: _provider, region: _region }) => {
|
327544
327924
|
const applicationUniqueName = application ?? env2.SETTLEMINT_APPLICATION;
|
327545
327925
|
if (!applicationUniqueName) {
|
327546
327926
|
return missingApplication();
|
@@ -327829,25 +328209,256 @@ function deleteCommand() {
|
|
327829
328209
|
return new Command("delete").alias("d").description("Delete a resource in the SettleMint platform").addCommand(applicationDeleteCommand()).addCommand(workspaceDeleteCommand());
|
327830
328210
|
}
|
327831
328211
|
|
328212
|
+
// src/commands/platform/common/pause-command.ts
|
328213
|
+
function getPauseCommand({
|
328214
|
+
name: name3,
|
328215
|
+
type: type4,
|
328216
|
+
alias,
|
328217
|
+
envKey,
|
328218
|
+
pauseFunction,
|
328219
|
+
usePersonalAccessToken = true
|
328220
|
+
}) {
|
328221
|
+
const commandName = sanitizeCommandName(name3);
|
328222
|
+
const typeCommandName = sanitizeCommandName(type4);
|
328223
|
+
const exampleCommandPrefix = `platform pause ${typeCommandName !== commandName ? `${typeCommandName} ` : ""}${commandName}`;
|
328224
|
+
return new Command(commandName).alias(alias).description(`Pause a ${type4} in the SettleMint platform. Provide the ${type4} unique name or use 'default' to pause the default ${type4} from your .env file.`).usage(createExamples([
|
328225
|
+
{
|
328226
|
+
description: `Pauses the specified ${type4} by unique name`,
|
328227
|
+
command: `${exampleCommandPrefix} <unique-name>`
|
328228
|
+
},
|
328229
|
+
{
|
328230
|
+
description: `Pauses the default ${type4} in the production environment`,
|
328231
|
+
command: `${exampleCommandPrefix} default --prod`
|
328232
|
+
}
|
328233
|
+
])).argument("<unique-name>", `The unique name of the ${type4}, use 'default' to pause the default one from your .env file`).option("-a, --accept-defaults", "Accept the default and previously set values").option("--prod", "Connect to your production environment").option("-w, --wait", "Wait until paused").action(async (uniqueName, { acceptDefaults, prod, wait: wait2 }) => {
|
328234
|
+
intro(`Pausing ${type4} in the SettleMint platform`);
|
328235
|
+
const env2 = await loadEnv(false, !!prod);
|
328236
|
+
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
328237
|
+
const accessToken = await getApplicationOrPersonalAccessToken({
|
328238
|
+
env: env2,
|
328239
|
+
instance,
|
328240
|
+
prefer: usePersonalAccessToken ? "personal" : "application"
|
328241
|
+
});
|
328242
|
+
const settlemint = createSettleMintClient({
|
328243
|
+
accessToken,
|
328244
|
+
instance
|
328245
|
+
});
|
328246
|
+
const isDefaultUniqueName = uniqueName === "default";
|
328247
|
+
const serviceUniqueName = isDefaultUniqueName ? typeof env2[envKey] === "string" ? env2[envKey] : null : uniqueName;
|
328248
|
+
if (!serviceUniqueName) {
|
328249
|
+
cancel2(`No default ${type4} found in your .env file. Please provide a valid ${type4} unique name or set a default ${type4} first.`);
|
328250
|
+
}
|
328251
|
+
const result = await spinner({
|
328252
|
+
startMessage: `Pausing ${type4}`,
|
328253
|
+
task: async () => {
|
328254
|
+
return pauseFunction(settlemint, serviceUniqueName);
|
328255
|
+
},
|
328256
|
+
stopMessage: `${capitalizeFirstLetter2(type4)} pause initiated`
|
328257
|
+
});
|
328258
|
+
if (wait2) {
|
328259
|
+
const isPaused = await waitForCompletion({
|
328260
|
+
settlemint,
|
328261
|
+
type: type4,
|
328262
|
+
uniqueName: serviceUniqueName,
|
328263
|
+
action: "pause"
|
328264
|
+
});
|
328265
|
+
if (!isPaused) {
|
328266
|
+
throw new Error(`Failed to pause ${type4} ${serviceUniqueName}`);
|
328267
|
+
}
|
328268
|
+
}
|
328269
|
+
outro(`${capitalizeFirstLetter2(type4)} ${result.name} pause initiated successfully`);
|
328270
|
+
});
|
328271
|
+
}
|
328272
|
+
|
328273
|
+
// src/commands/platform/blockchain-network/pause.ts
|
328274
|
+
function blockchainNetworkPauseCommand() {
|
328275
|
+
return getPauseCommand({
|
328276
|
+
name: "blockchain-network",
|
328277
|
+
type: "blockchain network",
|
328278
|
+
alias: "bnw",
|
328279
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NETWORK",
|
328280
|
+
pauseFunction: async (settlemint, id) => {
|
328281
|
+
return settlemint.blockchainNetwork.pause(id);
|
328282
|
+
}
|
328283
|
+
});
|
328284
|
+
}
|
328285
|
+
|
328286
|
+
// src/commands/platform/blockchain-node/pause.ts
|
328287
|
+
function blockchainNodePauseCommand() {
|
328288
|
+
return getPauseCommand({
|
328289
|
+
name: "blockchain-node",
|
328290
|
+
type: "blockchain node",
|
328291
|
+
alias: "bn",
|
328292
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NODE",
|
328293
|
+
pauseFunction: async (settlemint, id) => {
|
328294
|
+
return settlemint.blockchainNode.pause(id);
|
328295
|
+
}
|
328296
|
+
});
|
328297
|
+
}
|
328298
|
+
|
328299
|
+
// src/commands/platform/custom-deployments/pause.ts
|
328300
|
+
function customDeploymentPauseCommand() {
|
328301
|
+
return getPauseCommand({
|
328302
|
+
name: "custom-deployment",
|
328303
|
+
type: "custom deployment",
|
328304
|
+
alias: "cd",
|
328305
|
+
envKey: "SETTLEMINT_CUSTOM_DEPLOYMENT",
|
328306
|
+
pauseFunction: async (settlemint, id) => {
|
328307
|
+
return settlemint.customDeployment.pause(id);
|
328308
|
+
}
|
328309
|
+
});
|
328310
|
+
}
|
328311
|
+
|
328312
|
+
// src/commands/platform/insights/blockscout/pause.ts
|
328313
|
+
function blockscoutPauseCommand() {
|
328314
|
+
return getPauseCommand({
|
328315
|
+
name: "blockscout",
|
328316
|
+
type: "insights",
|
328317
|
+
alias: "bs",
|
328318
|
+
envKey: "SETTLEMINT_BLOCKSCOUT",
|
328319
|
+
pauseFunction: async (settlemint, id) => {
|
328320
|
+
return settlemint.insights.pause(id);
|
328321
|
+
}
|
328322
|
+
});
|
328323
|
+
}
|
328324
|
+
|
328325
|
+
// src/commands/platform/insights/pause.ts
|
328326
|
+
function insightsPauseCommand() {
|
328327
|
+
return new Command("insights").alias("in").description("Pause an insights service in the SettleMint platform").addCommand(blockscoutPauseCommand());
|
328328
|
+
}
|
328329
|
+
|
328330
|
+
// src/commands/platform/integration-tools/hasura/pause.ts
|
328331
|
+
function hasuraPauseCommand() {
|
328332
|
+
return getPauseCommand({
|
328333
|
+
name: "hasura",
|
328334
|
+
type: "integration tool",
|
328335
|
+
alias: "ha",
|
328336
|
+
envKey: "SETTLEMINT_HASURA",
|
328337
|
+
pauseFunction: async (settlemint, id) => {
|
328338
|
+
return settlemint.integrationTool.pause(id);
|
328339
|
+
}
|
328340
|
+
});
|
328341
|
+
}
|
328342
|
+
|
328343
|
+
// src/commands/platform/integration-tools/pause.ts
|
328344
|
+
function integrationToolPauseCommand() {
|
328345
|
+
return new Command("integration-tool").alias("it").description("Pause an integration tool service in the SettleMint platform").addCommand(hasuraPauseCommand());
|
328346
|
+
}
|
328347
|
+
|
328348
|
+
// src/commands/platform/load-balancer/pause.ts
|
328349
|
+
function loadBalancerPauseCommand() {
|
328350
|
+
return getPauseCommand({
|
328351
|
+
name: "evm",
|
328352
|
+
type: "load balancer",
|
328353
|
+
alias: "lb",
|
328354
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
|
328355
|
+
pauseFunction: async (settlemint, id) => {
|
328356
|
+
return settlemint.loadBalancer.pause(id);
|
328357
|
+
}
|
328358
|
+
});
|
328359
|
+
}
|
328360
|
+
|
328361
|
+
// src/commands/platform/middleware/graph/pause.ts
|
328362
|
+
function graphMiddlewarePauseCommand() {
|
328363
|
+
return getPauseCommand({
|
328364
|
+
name: "graph",
|
328365
|
+
type: "middleware",
|
328366
|
+
alias: "gr",
|
328367
|
+
envKey: "SETTLEMINT_THEGRAPH",
|
328368
|
+
pauseFunction: async (settlemint, id) => {
|
328369
|
+
return settlemint.middleware.pause(id);
|
328370
|
+
}
|
328371
|
+
});
|
328372
|
+
}
|
328373
|
+
|
328374
|
+
// src/commands/platform/middleware/smart-contract-portal/pause.ts
|
328375
|
+
function smartContractPortalMiddlewarePauseCommand() {
|
328376
|
+
return getPauseCommand({
|
328377
|
+
name: "smart-contract-portal",
|
328378
|
+
type: "middleware",
|
328379
|
+
alias: "scp",
|
328380
|
+
envKey: "SETTLEMINT_PORTAL",
|
328381
|
+
pauseFunction: async (settlemint, id) => {
|
328382
|
+
return settlemint.middleware.pause(id);
|
328383
|
+
}
|
328384
|
+
});
|
328385
|
+
}
|
328386
|
+
|
328387
|
+
// src/commands/platform/middleware/pause.ts
|
328388
|
+
function middlewarePauseCommand() {
|
328389
|
+
return new Command("middleware").alias("mw").description("Pause a middleware service in the SettleMint platform").addCommand(graphMiddlewarePauseCommand()).addCommand(smartContractPortalMiddlewarePauseCommand());
|
328390
|
+
}
|
328391
|
+
|
328392
|
+
// src/commands/platform/private-key/pause.ts
|
328393
|
+
function privateKeyPauseCommand() {
|
328394
|
+
return getPauseCommand({
|
328395
|
+
name: "private-key",
|
328396
|
+
type: "private key",
|
328397
|
+
alias: "pk",
|
328398
|
+
envKey: "SETTLEMINT_ACCESSIBLE_PRIVATE_KEY",
|
328399
|
+
pauseFunction: async (settlemint, id) => {
|
328400
|
+
return settlemint.privateKey.pause(id);
|
328401
|
+
}
|
328402
|
+
});
|
328403
|
+
}
|
328404
|
+
|
328405
|
+
// src/commands/platform/storage/ipfs/pause.ts
|
328406
|
+
function ipfsStoragePauseCommand() {
|
328407
|
+
return getPauseCommand({
|
328408
|
+
name: "ipfs",
|
328409
|
+
type: "storage",
|
328410
|
+
alias: "ip",
|
328411
|
+
envKey: "SETTLEMINT_IPFS",
|
328412
|
+
pauseFunction: async (settlemint, id) => {
|
328413
|
+
return settlemint.storage.pause(id);
|
328414
|
+
}
|
328415
|
+
});
|
328416
|
+
}
|
328417
|
+
|
328418
|
+
// src/commands/platform/storage/minio/pause.ts
|
328419
|
+
function minioStoragePauseCommand() {
|
328420
|
+
return getPauseCommand({
|
328421
|
+
name: "minio",
|
328422
|
+
type: "storage",
|
328423
|
+
alias: "m",
|
328424
|
+
envKey: "SETTLEMINT_MINIO",
|
328425
|
+
pauseFunction: async (settlemint, id) => {
|
328426
|
+
return settlemint.storage.pause(id);
|
328427
|
+
}
|
328428
|
+
});
|
328429
|
+
}
|
328430
|
+
|
328431
|
+
// src/commands/platform/storage/pause.ts
|
328432
|
+
function storagePauseCommand() {
|
328433
|
+
return new Command("storage").alias("st").description("Pause a storage service in the SettleMint platform").addCommand(ipfsStoragePauseCommand()).addCommand(minioStoragePauseCommand());
|
328434
|
+
}
|
328435
|
+
|
328436
|
+
// src/commands/platform/pause.ts
|
328437
|
+
function pauseCommand() {
|
328438
|
+
const cmd2 = new Command("pause").description("Pause a resource in the SettleMint platform").addCommand(blockchainNodePauseCommand()).addCommand(blockchainNetworkPauseCommand()).addCommand(customDeploymentPauseCommand()).addCommand(insightsPauseCommand()).addCommand(integrationToolPauseCommand()).addCommand(loadBalancerPauseCommand()).addCommand(middlewarePauseCommand()).addCommand(privateKeyPauseCommand()).addCommand(storagePauseCommand());
|
328439
|
+
return cmd2;
|
328440
|
+
}
|
328441
|
+
|
327832
328442
|
// src/commands/platform/common/restart-command.ts
|
327833
328443
|
function getRestartCommand({
|
327834
328444
|
name: name3,
|
327835
328445
|
type: type4,
|
327836
|
-
subType,
|
327837
328446
|
alias,
|
327838
328447
|
envKey,
|
327839
328448
|
restartFunction,
|
327840
328449
|
usePersonalAccessToken = true
|
327841
328450
|
}) {
|
327842
328451
|
const commandName = sanitizeCommandName(name3);
|
328452
|
+
const typeCommandName = sanitizeCommandName(type4);
|
328453
|
+
const exampleCommandPrefix = `platform restart ${typeCommandName !== commandName ? `${typeCommandName} ` : ""}${commandName}`;
|
327843
328454
|
return new Command(commandName).alias(alias).description(`Restart a ${type4} in the SettleMint platform. Provide the ${type4} unique name or use 'default' to restart the default ${type4} from your .env file.`).usage(createExamples([
|
327844
328455
|
{
|
327845
|
-
description: `Restarts the specified ${type4} by
|
327846
|
-
command:
|
328456
|
+
description: `Restarts the specified ${type4} by unique name`,
|
328457
|
+
command: `${exampleCommandPrefix} <unique-name>`
|
327847
328458
|
},
|
327848
328459
|
{
|
327849
328460
|
description: `Restarts the default ${type4} in the production environment`,
|
327850
|
-
command:
|
328461
|
+
command: `${exampleCommandPrefix} default --prod`
|
327851
328462
|
}
|
327852
328463
|
])).argument("<unique-name>", `The unique name of the ${type4}, use 'default' to restart the default one from your .env file`).option("-a, --accept-defaults", "Accept the default and previously set values").option("--prod", "Connect to your production environment").option("-w, --wait", "Wait until restarted").action(async (uniqueName, { acceptDefaults, prod, wait: wait2 }) => {
|
327853
328464
|
intro(`Restarting ${type4} in the SettleMint platform`);
|
@@ -327934,7 +328545,6 @@ function blockscoutRestartCommand() {
|
|
327934
328545
|
return getRestartCommand({
|
327935
328546
|
name: "blockscout",
|
327936
328547
|
type: "insights",
|
327937
|
-
subType: "blockscout",
|
327938
328548
|
alias: "bs",
|
327939
328549
|
envKey: "SETTLEMINT_BLOCKSCOUT",
|
327940
328550
|
restartFunction: async (settlemint, uniqueName) => {
|
@@ -327953,7 +328563,6 @@ function hasuraRestartCommand() {
|
|
327953
328563
|
return getRestartCommand({
|
327954
328564
|
name: "hasura",
|
327955
328565
|
type: "integration tool",
|
327956
|
-
subType: "hasura",
|
327957
328566
|
alias: "ha",
|
327958
328567
|
envKey: "SETTLEMINT_HASURA",
|
327959
328568
|
restartFunction: async (settlemint, uniqueName) => {
|
@@ -327985,7 +328594,6 @@ function graphRestartCommand() {
|
|
327985
328594
|
return getRestartCommand({
|
327986
328595
|
name: "graph",
|
327987
328596
|
type: "middleware",
|
327988
|
-
subType: "graph",
|
327989
328597
|
alias: "gr",
|
327990
328598
|
envKey: "SETTLEMINT_THEGRAPH",
|
327991
328599
|
restartFunction: async (settlemint, id) => {
|
@@ -327999,7 +328607,6 @@ function smartContractPortalRestartCommand() {
|
|
327999
328607
|
return getRestartCommand({
|
328000
328608
|
name: "smart-contract-portal",
|
328001
328609
|
type: "middleware",
|
328002
|
-
subType: "smart-contract-portal",
|
328003
328610
|
alias: "scp",
|
328004
328611
|
envKey: "SETTLEMINT_PORTAL",
|
328005
328612
|
restartFunction: async (settlemint, uniqueName) => {
|
@@ -328050,6 +328657,236 @@ function restartCommand() {
|
|
328050
328657
|
return cmd2;
|
328051
328658
|
}
|
328052
328659
|
|
328660
|
+
// src/commands/platform/common/resume-command.ts
|
328661
|
+
function getResumeCommand({
|
328662
|
+
name: name3,
|
328663
|
+
type: type4,
|
328664
|
+
alias,
|
328665
|
+
envKey,
|
328666
|
+
resumeFunction,
|
328667
|
+
usePersonalAccessToken = true
|
328668
|
+
}) {
|
328669
|
+
const commandName = sanitizeCommandName(name3);
|
328670
|
+
const typeCommandName = sanitizeCommandName(type4);
|
328671
|
+
const exampleCommandPrefix = `platform resume ${typeCommandName !== commandName ? `${typeCommandName} ` : ""}${commandName}`;
|
328672
|
+
return new Command(commandName).alias(alias).description(`Resume a ${type4} in the SettleMint platform. Provide the ${type4} unique name or use 'default' to resume the default ${type4} from your .env file.`).usage(createExamples([
|
328673
|
+
{
|
328674
|
+
description: `Resumes the specified ${type4} by unique name`,
|
328675
|
+
command: `${exampleCommandPrefix} <unique-name>`
|
328676
|
+
},
|
328677
|
+
{
|
328678
|
+
description: `Resumes the default ${type4} in the production environment`,
|
328679
|
+
command: `${exampleCommandPrefix} default --prod`
|
328680
|
+
}
|
328681
|
+
])).argument("<unique-name>", `The unique name of the ${type4}, use 'default' to resume the default one from your .env file`).option("-a, --accept-defaults", "Accept the default and previously set values").option("--prod", "Connect to your production environment").option("-w, --wait", "Wait until resumed").action(async (uniqueName, { acceptDefaults, prod, wait: wait2 }) => {
|
328682
|
+
intro(`Resuming ${type4} in the SettleMint platform`);
|
328683
|
+
const env2 = await loadEnv(false, !!prod);
|
328684
|
+
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
328685
|
+
const accessToken = await getApplicationOrPersonalAccessToken({
|
328686
|
+
env: env2,
|
328687
|
+
instance,
|
328688
|
+
prefer: usePersonalAccessToken ? "personal" : "application"
|
328689
|
+
});
|
328690
|
+
const settlemint = createSettleMintClient({
|
328691
|
+
accessToken,
|
328692
|
+
instance
|
328693
|
+
});
|
328694
|
+
const isDefaultUniqueName = uniqueName === "default";
|
328695
|
+
const serviceUniqueName = isDefaultUniqueName ? typeof env2[envKey] === "string" ? env2[envKey] : null : uniqueName;
|
328696
|
+
if (!serviceUniqueName) {
|
328697
|
+
cancel2(`No default ${type4} found in your .env file. Please provide a valid ${type4} unique name or set a default ${type4} first.`);
|
328698
|
+
}
|
328699
|
+
const result = await spinner({
|
328700
|
+
startMessage: `Resuming ${type4}`,
|
328701
|
+
task: async () => {
|
328702
|
+
return resumeFunction(settlemint, serviceUniqueName);
|
328703
|
+
},
|
328704
|
+
stopMessage: `${capitalizeFirstLetter2(type4)} resume initiated`
|
328705
|
+
});
|
328706
|
+
if (wait2) {
|
328707
|
+
const isResumed = await waitForCompletion({
|
328708
|
+
settlemint,
|
328709
|
+
type: type4,
|
328710
|
+
uniqueName: serviceUniqueName,
|
328711
|
+
action: "resume"
|
328712
|
+
});
|
328713
|
+
if (!isResumed) {
|
328714
|
+
throw new Error(`Failed to resume ${type4} ${serviceUniqueName}`);
|
328715
|
+
}
|
328716
|
+
}
|
328717
|
+
outro(`${capitalizeFirstLetter2(type4)} ${result.name} resume initiated successfully`);
|
328718
|
+
});
|
328719
|
+
}
|
328720
|
+
|
328721
|
+
// src/commands/platform/blockchain-network/resume.ts
|
328722
|
+
function blockchainNetworkResumeCommand() {
|
328723
|
+
return getResumeCommand({
|
328724
|
+
name: "blockchain-network",
|
328725
|
+
type: "blockchain network",
|
328726
|
+
alias: "bnw",
|
328727
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NETWORK",
|
328728
|
+
resumeFunction: async (settlemint, id) => {
|
328729
|
+
return settlemint.blockchainNetwork.resume(id);
|
328730
|
+
}
|
328731
|
+
});
|
328732
|
+
}
|
328733
|
+
|
328734
|
+
// src/commands/platform/blockchain-node/resume.ts
|
328735
|
+
function blockchainNodeResumeCommand() {
|
328736
|
+
return getResumeCommand({
|
328737
|
+
name: "blockchain-node",
|
328738
|
+
type: "blockchain node",
|
328739
|
+
alias: "bn",
|
328740
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NODE",
|
328741
|
+
resumeFunction: async (settlemint, id) => {
|
328742
|
+
return settlemint.blockchainNode.resume(id);
|
328743
|
+
}
|
328744
|
+
});
|
328745
|
+
}
|
328746
|
+
|
328747
|
+
// src/commands/platform/custom-deployments/resume.ts
|
328748
|
+
function customDeploymentResumeCommand() {
|
328749
|
+
return getResumeCommand({
|
328750
|
+
name: "custom-deployment",
|
328751
|
+
type: "custom deployment",
|
328752
|
+
alias: "cd",
|
328753
|
+
envKey: "SETTLEMINT_CUSTOM_DEPLOYMENT",
|
328754
|
+
resumeFunction: async (settlemint, id) => {
|
328755
|
+
return settlemint.customDeployment.resume(id);
|
328756
|
+
}
|
328757
|
+
});
|
328758
|
+
}
|
328759
|
+
|
328760
|
+
// src/commands/platform/insights/blockscout/resume.ts
|
328761
|
+
function blockscoutResumeCommand() {
|
328762
|
+
return getResumeCommand({
|
328763
|
+
name: "blockscout",
|
328764
|
+
type: "insights",
|
328765
|
+
alias: "bs",
|
328766
|
+
envKey: "SETTLEMINT_BLOCKSCOUT",
|
328767
|
+
resumeFunction: async (settlemint, id) => {
|
328768
|
+
return settlemint.insights.resume(id);
|
328769
|
+
}
|
328770
|
+
});
|
328771
|
+
}
|
328772
|
+
|
328773
|
+
// src/commands/platform/insights/resume.ts
|
328774
|
+
function insightsResumeCommand() {
|
328775
|
+
return new Command("insights").alias("in").description("Resume an insights service in the SettleMint platform").addCommand(blockscoutResumeCommand());
|
328776
|
+
}
|
328777
|
+
|
328778
|
+
// src/commands/platform/integration-tools/hasura/resume.ts
|
328779
|
+
function hasuraResumeCommand() {
|
328780
|
+
return getResumeCommand({
|
328781
|
+
name: "hasura",
|
328782
|
+
type: "integration tool",
|
328783
|
+
alias: "ha",
|
328784
|
+
envKey: "SETTLEMINT_HASURA",
|
328785
|
+
resumeFunction: async (settlemint, id) => {
|
328786
|
+
return settlemint.integrationTool.resume(id);
|
328787
|
+
}
|
328788
|
+
});
|
328789
|
+
}
|
328790
|
+
|
328791
|
+
// src/commands/platform/integration-tools/resume.ts
|
328792
|
+
function integrationToolResumeCommand() {
|
328793
|
+
return new Command("integration-tool").alias("it").description("Resume an integration tool service in the SettleMint platform").addCommand(hasuraResumeCommand());
|
328794
|
+
}
|
328795
|
+
|
328796
|
+
// src/commands/platform/load-balancer/resume.ts
|
328797
|
+
function loadBalancerResumeCommand() {
|
328798
|
+
return getResumeCommand({
|
328799
|
+
name: "load-balancer",
|
328800
|
+
type: "load balancer",
|
328801
|
+
alias: "lb",
|
328802
|
+
envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
|
328803
|
+
resumeFunction: async (settlemint, id) => {
|
328804
|
+
return settlemint.loadBalancer.resume(id);
|
328805
|
+
}
|
328806
|
+
});
|
328807
|
+
}
|
328808
|
+
|
328809
|
+
// src/commands/platform/middleware/graph/resume.ts
|
328810
|
+
function graphMiddlewareResumeCommand() {
|
328811
|
+
return getResumeCommand({
|
328812
|
+
name: "graph",
|
328813
|
+
type: "middleware",
|
328814
|
+
alias: "gr",
|
328815
|
+
envKey: "SETTLEMINT_THEGRAPH",
|
328816
|
+
resumeFunction: async (settlemint, id) => {
|
328817
|
+
return settlemint.middleware.resume(id);
|
328818
|
+
}
|
328819
|
+
});
|
328820
|
+
}
|
328821
|
+
|
328822
|
+
// src/commands/platform/middleware/smart-contract-portal/resume.ts
|
328823
|
+
function smartContractPortalMiddlewareResumeCommand() {
|
328824
|
+
return getResumeCommand({
|
328825
|
+
name: "smart-contract-portal",
|
328826
|
+
type: "middleware",
|
328827
|
+
alias: "scp",
|
328828
|
+
envKey: "SETTLEMINT_PORTAL",
|
328829
|
+
resumeFunction: async (settlemint, id) => {
|
328830
|
+
return settlemint.middleware.resume(id);
|
328831
|
+
}
|
328832
|
+
});
|
328833
|
+
}
|
328834
|
+
|
328835
|
+
// src/commands/platform/middleware/resume.ts
|
328836
|
+
function middlewareResumeCommand() {
|
328837
|
+
return new Command("middleware").alias("mw").description("Resume a middleware service in the SettleMint platform").addCommand(graphMiddlewareResumeCommand()).addCommand(smartContractPortalMiddlewareResumeCommand());
|
328838
|
+
}
|
328839
|
+
|
328840
|
+
// src/commands/platform/private-key/resume.ts
|
328841
|
+
function privateKeyResumeCommand() {
|
328842
|
+
return getResumeCommand({
|
328843
|
+
name: "private-key",
|
328844
|
+
type: "private key",
|
328845
|
+
alias: "pk",
|
328846
|
+
envKey: "SETTLEMINT_ACCESSIBLE_PRIVATE_KEY",
|
328847
|
+
resumeFunction: async (settlemint, id) => {
|
328848
|
+
return settlemint.privateKey.resume(id);
|
328849
|
+
}
|
328850
|
+
});
|
328851
|
+
}
|
328852
|
+
|
328853
|
+
// src/commands/platform/storage/ipfs/resume.ts
|
328854
|
+
function ipfsStorageResumeCommand() {
|
328855
|
+
return getResumeCommand({
|
328856
|
+
name: "ipfs",
|
328857
|
+
type: "storage",
|
328858
|
+
alias: "ip",
|
328859
|
+
envKey: "SETTLEMINT_IPFS",
|
328860
|
+
resumeFunction: async (settlemint, id) => {
|
328861
|
+
return settlemint.storage.resume(id);
|
328862
|
+
}
|
328863
|
+
});
|
328864
|
+
}
|
328865
|
+
|
328866
|
+
// src/commands/platform/storage/minio/resume.ts
|
328867
|
+
function minioStorageResumeCommand() {
|
328868
|
+
return getResumeCommand({
|
328869
|
+
name: "minio",
|
328870
|
+
type: "storage",
|
328871
|
+
alias: "m",
|
328872
|
+
envKey: "SETTLEMINT_MINIO",
|
328873
|
+
resumeFunction: async (settlemint, id) => {
|
328874
|
+
return settlemint.storage.resume(id);
|
328875
|
+
}
|
328876
|
+
});
|
328877
|
+
}
|
328878
|
+
|
328879
|
+
// src/commands/platform/storage/resume.ts
|
328880
|
+
function storageResumeCommand() {
|
328881
|
+
return new Command("storage").alias("st").description("Resume a storage service in the SettleMint platform").addCommand(ipfsStorageResumeCommand()).addCommand(minioStorageResumeCommand());
|
328882
|
+
}
|
328883
|
+
|
328884
|
+
// src/commands/platform/resume.ts
|
328885
|
+
function resumeCommand() {
|
328886
|
+
const cmd2 = new Command("resume").description("Resume a resource in the SettleMint platform").addCommand(blockchainNodeResumeCommand()).addCommand(blockchainNetworkResumeCommand()).addCommand(customDeploymentResumeCommand()).addCommand(insightsResumeCommand()).addCommand(integrationToolResumeCommand()).addCommand(loadBalancerResumeCommand()).addCommand(middlewareResumeCommand()).addCommand(privateKeyResumeCommand()).addCommand(storageResumeCommand());
|
328887
|
+
return cmd2;
|
328888
|
+
}
|
328889
|
+
|
328053
328890
|
// src/commands/platform/custom-deployments/update.ts
|
328054
328891
|
function customDeploymentsUpdateCommand() {
|
328055
328892
|
return new Command("custom-deployment").alias("cd").argument("<tag>", "The tag to update the custom deployment to").option("--unique-name <uniqueName>", "The unique name of the custom deployment to update. If not provided, will use SETTLEMINT_CUSTOM_DEPLOYMENT from env").option("--prod", "Connect to your production environment").option("--wait", "Wait for the custom deployment to be redeployed").description("Update a custom deployment in the SettleMint platform").usage(createExamples([
|
@@ -328440,7 +329277,7 @@ function servicesCommand() {
|
|
328440
329277
|
if (!applicationUniqueName) {
|
328441
329278
|
return nothingSelectedError("application");
|
328442
329279
|
}
|
328443
|
-
let effectiveTypes
|
329280
|
+
let effectiveTypes;
|
328444
329281
|
if (options.type && options.type.length > 0) {
|
328445
329282
|
effectiveTypes = options.type;
|
328446
329283
|
} else if (typeOperands && typeOperands.length > 0) {
|
@@ -328498,7 +329335,7 @@ async function getServicesAndMapResults({
|
|
328498
329335
|
const application = await settlemint.application.read(applicationUniqueName);
|
328499
329336
|
const services = await servicesSpinner(settlemint, applicationUniqueName, types4);
|
328500
329337
|
const results = (types4 ?? SERVICE_TYPES).filter((serviceType) => !types4 || types4.includes(serviceType)).map((serviceType) => {
|
328501
|
-
const [_6, labels] = Object.entries(LABELS_MAP).find(([
|
329338
|
+
const [_6, labels] = Object.entries(LABELS_MAP).find(([_key, value4]) => value4.command === serviceType) ?? [
|
328502
329339
|
null,
|
328503
329340
|
{ plural: serviceType }
|
328504
329341
|
];
|
@@ -328625,7 +329462,7 @@ function listCommand() {
|
|
328625
329462
|
|
328626
329463
|
// src/commands/platform.ts
|
328627
329464
|
function platformCommand() {
|
328628
|
-
return new Command("platform").description("Manage SettleMint platform resources").addCommand(configCommand()).addCommand(createCommand3()).addCommand(deleteCommand()).addCommand(listCommand()).addCommand(restartCommand()).addCommand(updateCommand());
|
329465
|
+
return new Command("platform").description("Manage SettleMint platform resources").addCommand(configCommand()).addCommand(createCommand3()).addCommand(deleteCommand()).addCommand(listCommand()).addCommand(pauseCommand()).addCommand(resumeCommand()).addCommand(restartCommand()).addCommand(updateCommand());
|
328629
329466
|
}
|
328630
329467
|
|
328631
329468
|
// src/commands/smart-contract-set/create.ts
|
@@ -328675,7 +329512,7 @@ var import_which = __toESM(require_lib5(), 1);
|
|
328675
329512
|
async function executeFoundryCommand(command, args) {
|
328676
329513
|
try {
|
328677
329514
|
await import_which.default(command);
|
328678
|
-
} catch (
|
329515
|
+
} catch (_error) {
|
328679
329516
|
cancel2("Foundry is not installed. Instructions to install Foundry can be found here: https://book.getfoundry.sh/getting-started/installation");
|
328680
329517
|
}
|
328681
329518
|
return executeCommand(command, args);
|
@@ -328763,7 +329600,7 @@ function foundryBuildCommand() {
|
|
328763
329600
|
description: "Build the smart contracts with additional Forge options",
|
328764
329601
|
command: "scs foundry build --optimize --force"
|
328765
329602
|
}
|
328766
|
-
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
329603
|
+
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
328767
329604
|
intro("Building smart contracts using Foundry");
|
328768
329605
|
const forgeOptions = mapPassthroughOptions(options, { args: operands });
|
328769
329606
|
await executeFoundryCommand("forge", ["build", ...forgeOptions]);
|
@@ -328786,7 +329623,7 @@ function foundryFormatCommand() {
|
|
328786
329623
|
description: "Format the smart contracts with additional Forge options",
|
328787
329624
|
command: "scs foundry format --check"
|
328788
329625
|
}
|
328789
|
-
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
329626
|
+
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
328790
329627
|
intro("Formatting smart contracts using Foundry");
|
328791
329628
|
const forgeOptions = mapPassthroughOptions(options, { args: operands });
|
328792
329629
|
await executeFoundryCommand("forge", ["fmt", ...forgeOptions]);
|
@@ -328809,7 +329646,7 @@ function foundryNetworkCommand() {
|
|
328809
329646
|
description: "Start a development network using Foundry with a specific port",
|
328810
329647
|
command: "scs foundry network --port 3000"
|
328811
329648
|
}
|
328812
|
-
])).helpOption(false).option("-h, --help", "Get list of possible anvil options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
329649
|
+
])).helpOption(false).option("-h, --help", "Get list of possible anvil options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
328813
329650
|
const anvilOptions = mapPassthroughOptions(options, { args: operands });
|
328814
329651
|
await executeFoundryCommand("anvil", anvilOptions);
|
328815
329652
|
});
|
@@ -328830,7 +329667,7 @@ function foundryTestCommand() {
|
|
328830
329667
|
description: "Run a specific test function",
|
328831
329668
|
command: "scs foundry test --match-test testToken"
|
328832
329669
|
}
|
328833
|
-
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
329670
|
+
])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
328834
329671
|
intro("Running smart contract tests using Foundry");
|
328835
329672
|
const forgeOptions = mapPassthroughOptions(options, { args: operands });
|
328836
329673
|
await executeFoundryCommand("forge", ["test", ...forgeOptions]);
|
@@ -328844,7 +329681,7 @@ var validateIfRequiredPackagesAreInstalled = async (packages, cwd2) => {
|
|
328844
329681
|
try {
|
328845
329682
|
const isInstalled = await isPackageInstalled(pkg, cwd2);
|
328846
329683
|
return { packageName: pkg, isInstalled };
|
328847
|
-
} catch (
|
329684
|
+
} catch (_err) {
|
328848
329685
|
return { packageName: pkg, isInstalled: false };
|
328849
329686
|
}
|
328850
329687
|
}));
|
@@ -328869,7 +329706,7 @@ function hardhatBuildCommand() {
|
|
328869
329706
|
description: "Build the smart contracts using additional options to the Hardhat compile command",
|
328870
329707
|
command: "scs hardhat build --concurrency 2"
|
328871
329708
|
}
|
328872
|
-
])).helpOption(false).option("-h, --help", "Get list of possible hardhat compile options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
329709
|
+
])).helpOption(false).option("-h, --help", "Get list of possible hardhat compile options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
328873
329710
|
intro("Building smart contracts using Hardhat");
|
328874
329711
|
await validateIfRequiredPackagesAreInstalled(["hardhat"]);
|
328875
329712
|
const hardhatOptions = mapPassthroughOptions(options, { args: operands });
|
@@ -328940,7 +329777,7 @@ async function selectTargetNode({
|
|
328940
329777
|
settlemint
|
328941
329778
|
}) {
|
328942
329779
|
const nodeUniqueName = blockchainNodeUniqueName ?? (autoAccept ? env2.SETTLEMINT_BLOCKCHAIN_NODE : undefined);
|
328943
|
-
let node
|
329780
|
+
let node;
|
328944
329781
|
if (!nodeUniqueName) {
|
328945
329782
|
if (!env2.SETTLEMINT_APPLICATION) {
|
328946
329783
|
return missingApplication();
|
@@ -329164,7 +330001,7 @@ function hardhatDeployRemoteCommand() {
|
|
329164
330001
|
} else {
|
329165
330002
|
note("Smart contract deployment was cancelled");
|
329166
330003
|
}
|
329167
|
-
} catch (
|
330004
|
+
} catch (_error) {
|
329168
330005
|
cancel2("The smart contract deployment was unsuccessful. Please check the error details above and try again. You may need to review your contract code or deployment configuration.");
|
329169
330006
|
}
|
329170
330007
|
});
|
@@ -329194,7 +330031,7 @@ function hardhatNetworkCommand() {
|
|
329194
330031
|
description: "Start a development network using Hardhat with a specific port",
|
329195
330032
|
command: "scs hardhat network --port 3000"
|
329196
330033
|
}
|
329197
|
-
])).helpOption(false).option("-h, --help", "Get list of possible hardhat node options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
330034
|
+
])).helpOption(false).option("-h, --help", "Get list of possible hardhat node options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
329198
330035
|
intro("Starting development network using Hardhat");
|
329199
330036
|
await validateIfRequiredPackagesAreInstalled(["hardhat"]);
|
329200
330037
|
const hardhatOptions = mapPassthroughOptions(options, { args: operands });
|
@@ -329303,7 +330140,7 @@ function hardhatTestCommand() {
|
|
329303
330140
|
description: "Run a specific test file",
|
329304
330141
|
command: "scs hardhat test test/token.test.ts"
|
329305
330142
|
}
|
329306
|
-
])).helpOption(false).option("-h, --help", "Get list of possible hardhat test options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options,
|
330143
|
+
])).helpOption(false).option("-h, --help", "Get list of possible hardhat test options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
|
329307
330144
|
intro("Running smart contract tests using Hardhat");
|
329308
330145
|
await validateIfRequiredPackagesAreInstalled(["hardhat"]);
|
329309
330146
|
const hardhatOptions = mapPassthroughOptions(options, { args: operands });
|
@@ -329313,9 +330150,9 @@ function hardhatTestCommand() {
|
|
329313
330150
|
});
|
329314
330151
|
}
|
329315
330152
|
|
329316
|
-
// src/
|
329317
|
-
import {
|
329318
|
-
|
330153
|
+
// src/commands/smart-contract-set/subgraph/add.ts
|
330154
|
+
import { copyFile, mkdir as mkdir7, readFile as readFile10, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
|
330155
|
+
import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute2, join as join11, relative as relative4 } from "node:path";
|
329319
330156
|
|
329320
330157
|
// src/utils/subgraph/subgraph-config.ts
|
329321
330158
|
import { readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
|
@@ -329347,7 +330184,7 @@ var updateSubgraphYamlConfig = async (config5, cwd2 = process.cwd()) => {
|
|
329347
330184
|
var getSubgraphConfig = async (path7 = process.cwd()) => {
|
329348
330185
|
try {
|
329349
330186
|
const configContents = await readFile9(join10(path7, CONFIG_FILE_PATH));
|
329350
|
-
const currentConfig =
|
330187
|
+
const currentConfig = tryParseJson4(configContents.toString());
|
329351
330188
|
return currentConfig;
|
329352
330189
|
} catch (err) {
|
329353
330190
|
const error45 = err;
|
@@ -329356,7 +330193,102 @@ var getSubgraphConfig = async (path7 = process.cwd()) => {
|
|
329356
330193
|
}
|
329357
330194
|
};
|
329358
330195
|
|
330196
|
+
// src/commands/smart-contract-set/subgraph/add.ts
|
330197
|
+
var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
330198
|
+
function subgraphAddCommand() {
|
330199
|
+
return new Command("add").description("Add a contract to the subgraph").usage(createExamples([
|
330200
|
+
{
|
330201
|
+
description: "Add a contract to the subgraph",
|
330202
|
+
command: "scs subgraph add --abi=./abis/bond.json --contract-name=bond"
|
330203
|
+
}
|
330204
|
+
])).requiredOption("--abi <abi>", "Path to the contract ABI.").requiredOption("--contract-name <contract-name>", "Name of the contract.").option("--address <contract-address>", `Address of the contract (defaults to ${DEFAULT_ADDRESS}).`).option("--start-block <start-block>", "Start block of the contract (defaults to 0).").option("--network <network>", "Network name (defaults to settlemint).").action(async ({ abi: abi2, contractName, address, startBlock, network }) => {
|
330205
|
+
intro(`Adding subgraph config for contract ${contractName}`);
|
330206
|
+
const abiPath = isAbsolute2(abi2) ? abi2 : join11(process.cwd(), abi2);
|
330207
|
+
if (!await exists3(abiPath)) {
|
330208
|
+
throw new Error("ABI file not found");
|
330209
|
+
}
|
330210
|
+
await validateIfRequiredPackagesAreInstalled(["@graphprotocol/graph-cli"]);
|
330211
|
+
if (await isGenerated()) {
|
330212
|
+
throw new Error("This command does not support automatically generated subgraph configs");
|
330213
|
+
}
|
330214
|
+
const { command, args } = await getPackageManagerExecutable();
|
330215
|
+
const subgraphYamlFile = await getSubgraphYamlFile();
|
330216
|
+
const abiName = basename5(abiPath);
|
330217
|
+
const subgraphYamlDir = dirname8(subgraphYamlFile);
|
330218
|
+
await mkdir7(join11(subgraphYamlDir, "abis"), { recursive: true });
|
330219
|
+
const localAbiPath = join11(subgraphYamlDir, "abis", abiName);
|
330220
|
+
await copyFile(abiPath, localAbiPath);
|
330221
|
+
try {
|
330222
|
+
const root = await projectRoot3();
|
330223
|
+
await fixPackageJson(root);
|
330224
|
+
const monoRepoRoot = await findMonoRepoRoot2(root);
|
330225
|
+
if (monoRepoRoot) {
|
330226
|
+
await fixPackageJson(monoRepoRoot, false);
|
330227
|
+
}
|
330228
|
+
await executeCommand(command, [
|
330229
|
+
...args,
|
330230
|
+
"graph",
|
330231
|
+
"add",
|
330232
|
+
"--abi",
|
330233
|
+
abi2,
|
330234
|
+
"--contract-name",
|
330235
|
+
contractName,
|
330236
|
+
"--start-block",
|
330237
|
+
startBlock ?? "0",
|
330238
|
+
address ?? DEFAULT_ADDRESS,
|
330239
|
+
subgraphYamlFile
|
330240
|
+
]);
|
330241
|
+
const subgraphYamlConfig = await getSubgraphYamlConfig();
|
330242
|
+
if (subgraphYamlConfig) {
|
330243
|
+
const updatedDataSources = subgraphYamlConfig?.dataSources.map((dataSource) => {
|
330244
|
+
if (dataSource.name === contractName) {
|
330245
|
+
dataSource.network = network ?? "settlemint";
|
330246
|
+
dataSource.mapping.abis = [
|
330247
|
+
{
|
330248
|
+
name: contractName,
|
330249
|
+
file: relative4(subgraphYamlDir, abiPath)
|
330250
|
+
}
|
330251
|
+
];
|
330252
|
+
}
|
330253
|
+
return dataSource;
|
330254
|
+
});
|
330255
|
+
await updateSubgraphYamlConfig({
|
330256
|
+
...subgraphYamlConfig,
|
330257
|
+
dataSources: updatedDataSources
|
330258
|
+
});
|
330259
|
+
}
|
330260
|
+
} finally {
|
330261
|
+
await unlink2(localAbiPath);
|
330262
|
+
}
|
330263
|
+
outro(`Subgraph config for contract ${contractName} added successfully`);
|
330264
|
+
});
|
330265
|
+
}
|
330266
|
+
async function fixPackageJson(packageJsonDir, requiresCodegenScript = true) {
|
330267
|
+
const packageJsonPath = join11(packageJsonDir, "package.json");
|
330268
|
+
if (!await exists3(packageJsonPath)) {
|
330269
|
+
return;
|
330270
|
+
}
|
330271
|
+
let hasPackageJsonChanged = false;
|
330272
|
+
const subgraphPackageJson = await readFile10(packageJsonPath);
|
330273
|
+
const subgraphPackageJsonData = JSON.parse(subgraphPackageJson.toString());
|
330274
|
+
if (subgraphPackageJsonData.packageManager?.includes("bun")) {
|
330275
|
+
note("Removing package manager from package.json (bun is not an official package manager)");
|
330276
|
+
delete subgraphPackageJsonData.packageManager;
|
330277
|
+
hasPackageJsonChanged = true;
|
330278
|
+
}
|
330279
|
+
if (requiresCodegenScript && !subgraphPackageJsonData.scripts?.codegen) {
|
330280
|
+
note("Adding codegen script to package.json");
|
330281
|
+
subgraphPackageJsonData.scripts.codegen = "settlemint scs subgraph codegen";
|
330282
|
+
hasPackageJsonChanged = true;
|
330283
|
+
}
|
330284
|
+
if (hasPackageJsonChanged) {
|
330285
|
+
await writeFile9(packageJsonPath, JSON.stringify(subgraphPackageJsonData, null, 2));
|
330286
|
+
}
|
330287
|
+
}
|
330288
|
+
|
329359
330289
|
// src/utils/subgraph/setup.ts
|
330290
|
+
import { rm as rm4 } from "node:fs/promises";
|
330291
|
+
var import_semver = __toESM(require_semver2(), 1);
|
329360
330292
|
var SETTLEMINT_NETWORK = "settlemint";
|
329361
330293
|
async function subgraphSetup({ network }) {
|
329362
330294
|
const generated = await isGenerated();
|
@@ -329466,12 +330398,12 @@ async function getNodeName({
|
|
329466
330398
|
|
329467
330399
|
// src/commands/smart-contract-set/subgraph/build.ts
|
329468
330400
|
function subgraphBuildCommand() {
|
329469
|
-
return new Command("build").description("Build the subgraph").usage(createExamples([
|
330401
|
+
return new Command("build").description("Build the subgraph").option("--ipfs <ipfs-url>", "The IPFS URL to use for the subgraph deployment").usage(createExamples([
|
329470
330402
|
{
|
329471
330403
|
description: "Build the subgraph",
|
329472
330404
|
command: "scs subgraph build"
|
329473
330405
|
}
|
329474
|
-
])).action(async () => {
|
330406
|
+
])).action(async ({ ipfs }) => {
|
329475
330407
|
intro("Building subgraph");
|
329476
330408
|
await validateIfRequiredPackagesAreInstalled(["@graphprotocol/graph-cli"]);
|
329477
330409
|
await subgraphSetup({
|
@@ -329480,7 +330412,7 @@ function subgraphBuildCommand() {
|
|
329480
330412
|
const { command, args } = await getPackageManagerExecutable();
|
329481
330413
|
const subgraphYamlFile = await getSubgraphYamlFile();
|
329482
330414
|
await executeCommand(command, [...args, "graph", "codegen", subgraphYamlFile]);
|
329483
|
-
await executeCommand(command, [...args, "graph", "build", subgraphYamlFile]);
|
330415
|
+
await executeCommand(command, [...args, "graph", "build", ...ipfs ? ["--ipfs", ipfs] : [], subgraphYamlFile]);
|
329484
330416
|
outro("Subgraph built successfully");
|
329485
330417
|
});
|
329486
330418
|
}
|
@@ -329746,6 +330678,7 @@ function smartContractSetCommand() {
|
|
329746
330678
|
hardhat.addCommand(hardhatScriptCommand());
|
329747
330679
|
hardhat.addCommand(hardhatTestCommand());
|
329748
330680
|
const subgraph = new Command("subgraph").alias("sg").enablePositionalOptions().description("Commands for managing TheGraph subgraphs for smart contract indexing");
|
330681
|
+
subgraph.addCommand(subgraphAddCommand());
|
329749
330682
|
subgraph.addCommand(subgraphBuildCommand());
|
329750
330683
|
subgraph.addCommand(subgraphCodegenCommand());
|
329751
330684
|
subgraph.addCommand(subgraphDeployCommand());
|
@@ -329875,4 +330808,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
329875
330808
|
// src/cli.ts
|
329876
330809
|
sdkCliCommand();
|
329877
330810
|
|
329878
|
-
//# debugId=
|
330811
|
+
//# debugId=EE1620A62BBFBB8B64756E2164756E21
|