@settlemint/sdk-cli 2.3.2-pr31e5a661 → 2.3.2-pr37d1321f
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/dist/cli.js +593 -268
- package/dist/cli.js.map +38 -36
- package/package.json +3 -3
package/dist/cli.js
CHANGED
@@ -54139,8 +54139,8 @@ ${lanes.join(`
|
|
54139
54139
|
function sysLog(s) {
|
54140
54140
|
return curSysLog(s);
|
54141
54141
|
}
|
54142
|
-
function setSysLog(
|
54143
|
-
curSysLog =
|
54142
|
+
function setSysLog(logger3) {
|
54143
|
+
curSysLog = logger3;
|
54144
54144
|
}
|
54145
54145
|
function createDirectoryWatcherSupportingRecursive({
|
54146
54146
|
watchDirectory,
|
@@ -204833,10 +204833,10 @@ ${options.prefix}` : `
|
|
204833
204833
|
return [];
|
204834
204834
|
}
|
204835
204835
|
var ThrottledOperations = class _ThrottledOperations {
|
204836
|
-
constructor(host,
|
204836
|
+
constructor(host, logger3) {
|
204837
204837
|
this.host = host;
|
204838
204838
|
this.pendingTimeouts = /* @__PURE__ */ new Map;
|
204839
|
-
this.logger =
|
204839
|
+
this.logger = logger3.hasLevel(3) ? logger3 : undefined;
|
204840
204840
|
}
|
204841
204841
|
schedule(operationId, delay, cb) {
|
204842
204842
|
const pendingTimeout = this.pendingTimeouts.get(operationId);
|
@@ -204864,10 +204864,10 @@ ${options.prefix}` : `
|
|
204864
204864
|
}
|
204865
204865
|
};
|
204866
204866
|
var GcTimer = class _GcTimer {
|
204867
|
-
constructor(host, delay,
|
204867
|
+
constructor(host, delay, logger3) {
|
204868
204868
|
this.host = host;
|
204869
204869
|
this.delay = delay;
|
204870
|
-
this.logger =
|
204870
|
+
this.logger = logger3;
|
204871
204871
|
}
|
204872
204872
|
scheduleCollect() {
|
204873
204873
|
if (!this.host.gc || this.timerId !== undefined) {
|
@@ -210796,11 +210796,11 @@ Dynamic files must always be opened with service's current directory or service
|
|
210796
210796
|
return edits.every((edit) => textSpanEnd(edit.span) < pos);
|
210797
210797
|
}
|
210798
210798
|
var CommandNames = CommandTypes;
|
210799
|
-
function formatMessage2(msg,
|
210800
|
-
const verboseLogging =
|
210799
|
+
function formatMessage2(msg, logger3, byteLength, newLine) {
|
210800
|
+
const verboseLogging = logger3.hasLevel(3);
|
210801
210801
|
const json2 = JSON.stringify(msg);
|
210802
210802
|
if (verboseLogging) {
|
210803
|
-
|
210803
|
+
logger3.info(`${msg.type}:${stringifyIndented(msg)}`);
|
210804
210804
|
}
|
210805
210805
|
const len = byteLength(json2, "utf8");
|
210806
210806
|
return `Content-Length: ${1 + len}\r
|
@@ -210927,10 +210927,10 @@ ${json2}${newLine}`;
|
|
210927
210927
|
const info = infos && firstOrUndefined(infos);
|
210928
210928
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
210929
210929
|
}
|
210930
|
-
function getReferencesWorker(projects, defaultProject, initialLocation, useCaseSensitiveFileNames2,
|
210930
|
+
function getReferencesWorker(projects, defaultProject, initialLocation, useCaseSensitiveFileNames2, logger3) {
|
210931
210931
|
var _a, _b;
|
210932
210932
|
const perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation, getDefinitionLocation(defaultProject, initialLocation, false), mapDefinitionInProject, (project, position) => {
|
210933
|
-
|
210933
|
+
logger3.info(`Finding references to ${position.fileName} position ${position.pos} in project ${project.getProjectName()}`);
|
210934
210934
|
return project.getLanguageService().findReferences(position.fileName, position.pos);
|
210935
210935
|
}, (referencedSymbol, cb) => {
|
210936
210936
|
cb(documentSpanLocation(referencedSymbol.definition));
|
@@ -214310,9 +214310,9 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
214310
214310
|
}
|
214311
214311
|
};
|
214312
214312
|
var _TypingsInstallerAdapter = class _TypingsInstallerAdapter2 {
|
214313
|
-
constructor(telemetryEnabled,
|
214313
|
+
constructor(telemetryEnabled, logger3, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
|
214314
214314
|
this.telemetryEnabled = telemetryEnabled;
|
214315
|
-
this.logger =
|
214315
|
+
this.logger = logger3;
|
214316
214316
|
this.host = host;
|
214317
214317
|
this.globalTypingsCacheLocation = globalTypingsCacheLocation;
|
214318
214318
|
this.event = event;
|
@@ -262458,7 +262458,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
262458
262458
|
var package_default = {
|
262459
262459
|
name: "@settlemint/sdk-cli",
|
262460
262460
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
262461
|
-
version: "2.3.2-
|
262461
|
+
version: "2.3.2-pr37d1321f",
|
262462
262462
|
type: "module",
|
262463
262463
|
private: false,
|
262464
262464
|
license: "FSL-1.1-MIT",
|
@@ -262507,8 +262507,8 @@ var package_default = {
|
|
262507
262507
|
"@inquirer/input": "4.1.10",
|
262508
262508
|
"@inquirer/password": "4.0.13",
|
262509
262509
|
"@inquirer/select": "4.2.1",
|
262510
|
-
"@settlemint/sdk-js": "2.3.2-
|
262511
|
-
"@settlemint/sdk-utils": "2.3.2-
|
262510
|
+
"@settlemint/sdk-js": "2.3.2-pr37d1321f",
|
262511
|
+
"@settlemint/sdk-utils": "2.3.2-pr37d1321f",
|
262512
262512
|
"@types/node": "22.15.21",
|
262513
262513
|
"@types/semver": "7.7.0",
|
262514
262514
|
"@types/which": "3.0.4",
|
@@ -263841,24 +263841,84 @@ function table(title, data) {
|
|
263841
263841
|
}
|
263842
263842
|
|
263843
263843
|
// ../utils/dist/http.mjs
|
263844
|
+
var maskTokens3 = (output) => {
|
263845
|
+
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
263846
|
+
};
|
263847
|
+
function createLogger(options = {}) {
|
263848
|
+
const { level = "warn", prefix = "" } = options;
|
263849
|
+
const logLevels = {
|
263850
|
+
debug: 0,
|
263851
|
+
info: 1,
|
263852
|
+
warn: 2,
|
263853
|
+
error: 3,
|
263854
|
+
none: 4
|
263855
|
+
};
|
263856
|
+
const currentLevelValue = logLevels[level];
|
263857
|
+
const formatArgs = (args) => {
|
263858
|
+
if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {
|
263859
|
+
return "";
|
263860
|
+
}
|
263861
|
+
const formatted = args.map((arg) => {
|
263862
|
+
if (arg instanceof Error) {
|
263863
|
+
return `
|
263864
|
+
${arg.stack || arg.message}`;
|
263865
|
+
}
|
263866
|
+
if (typeof arg === "object" && arg !== null) {
|
263867
|
+
return `
|
263868
|
+
${JSON.stringify(arg, null, 2)}`;
|
263869
|
+
}
|
263870
|
+
return ` ${String(arg)}`;
|
263871
|
+
}).join("");
|
263872
|
+
return `, args:${formatted}`;
|
263873
|
+
};
|
263874
|
+
const shouldLog = (level2) => {
|
263875
|
+
return logLevels[level2] >= currentLevelValue;
|
263876
|
+
};
|
263877
|
+
return {
|
263878
|
+
debug: (message, ...args) => {
|
263879
|
+
if (shouldLog("debug")) {
|
263880
|
+
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens3(message)}${maskTokens3(formatArgs(args))}\x1B[0m`);
|
263881
|
+
}
|
263882
|
+
},
|
263883
|
+
info: (message, ...args) => {
|
263884
|
+
if (shouldLog("info")) {
|
263885
|
+
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens3(message)}${maskTokens3(formatArgs(args))}\x1B[0m`);
|
263886
|
+
}
|
263887
|
+
},
|
263888
|
+
warn: (message, ...args) => {
|
263889
|
+
if (shouldLog("warn")) {
|
263890
|
+
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens3(message)}${maskTokens3(formatArgs(args))}\x1B[0m`);
|
263891
|
+
}
|
263892
|
+
},
|
263893
|
+
error: (message, ...args) => {
|
263894
|
+
if (shouldLog("error")) {
|
263895
|
+
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens3(message)}${maskTokens3(formatArgs(args))}\x1B[0m`);
|
263896
|
+
}
|
263897
|
+
}
|
263898
|
+
};
|
263899
|
+
}
|
263900
|
+
var logger = createLogger();
|
263844
263901
|
async function retryWhenFailed(fn, maxRetries = 5, initialSleepTime = 1000, stopOnError) {
|
263845
|
-
let
|
263846
|
-
|
263902
|
+
let retries = 0;
|
263903
|
+
const maxAttempts = maxRetries + 1;
|
263904
|
+
while (retries < maxAttempts) {
|
263847
263905
|
try {
|
263848
263906
|
return await fn();
|
263849
263907
|
} catch (e) {
|
263908
|
+
const error35 = e;
|
263850
263909
|
if (typeof stopOnError === "function") {
|
263851
|
-
const error35 = e;
|
263852
263910
|
if (stopOnError(error35)) {
|
263853
263911
|
throw error35;
|
263854
263912
|
}
|
263855
263913
|
}
|
263856
|
-
|
263857
|
-
if (attempt >= maxRetries) {
|
263914
|
+
if (retries >= maxRetries) {
|
263858
263915
|
throw e;
|
263859
263916
|
}
|
263860
|
-
const
|
263861
|
-
const
|
263917
|
+
const baseDelay = 2 ** retries * initialSleepTime;
|
263918
|
+
const jitterAmount = initialSleepTime * (Math.random() / 10);
|
263919
|
+
const delay = baseDelay + jitterAmount;
|
263920
|
+
retries += 1;
|
263921
|
+
logger.warn(`An error occurred ${error35.message}, retrying in ${delay.toFixed(0)}ms (retry ${retries} of ${maxRetries})...`);
|
263862
263922
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
263863
263923
|
}
|
263864
263924
|
}
|
@@ -266154,7 +266214,11 @@ function getPincodeVerificationChallengeResponse({
|
|
266154
266214
|
function createSettleMintClient(options) {
|
266155
266215
|
ensureServer();
|
266156
266216
|
if (options.instance === STANDALONE_INSTANCE2) {
|
266157
|
-
|
266217
|
+
if (options.anonymous) {
|
266218
|
+
options.instance = "https://console.settlemint.com";
|
266219
|
+
} else {
|
266220
|
+
throw new Error("Standalone instances cannot connect to the SettleMint platform");
|
266221
|
+
}
|
266158
266222
|
}
|
266159
266223
|
const validatedOptions = options.anonymous ? validate2(exports_external.object({
|
266160
266224
|
...ClientOptionsSchema.shape,
|
@@ -267049,14 +267113,14 @@ async function getPackageManagerExecutable(targetDir) {
|
|
267049
267113
|
function shouldPrint2() {
|
267050
267114
|
return process.env.SETTLEMINT_DISABLE_TERMINAL !== "true";
|
267051
267115
|
}
|
267052
|
-
var
|
267116
|
+
var maskTokens4 = (output) => {
|
267053
267117
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
267054
267118
|
};
|
267055
267119
|
var note2 = (message, level = "info") => {
|
267056
267120
|
if (!shouldPrint2()) {
|
267057
267121
|
return;
|
267058
267122
|
}
|
267059
|
-
const maskedMessage =
|
267123
|
+
const maskedMessage = maskTokens4(message);
|
267060
267124
|
console.log("");
|
267061
267125
|
if (level === "warn") {
|
267062
267126
|
console.warn(yellowBright(maskedMessage));
|
@@ -267117,24 +267181,84 @@ function extractJsonObject(value2) {
|
|
267117
267181
|
}
|
267118
267182
|
return tryParseJson3(result[0]);
|
267119
267183
|
}
|
267184
|
+
var maskTokens5 = (output) => {
|
267185
|
+
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
267186
|
+
};
|
267187
|
+
function createLogger2(options = {}) {
|
267188
|
+
const { level = "warn", prefix = "" } = options;
|
267189
|
+
const logLevels = {
|
267190
|
+
debug: 0,
|
267191
|
+
info: 1,
|
267192
|
+
warn: 2,
|
267193
|
+
error: 3,
|
267194
|
+
none: 4
|
267195
|
+
};
|
267196
|
+
const currentLevelValue = logLevels[level];
|
267197
|
+
const formatArgs = (args) => {
|
267198
|
+
if (args.length === 0 || args.every((arg) => arg === undefined || arg === null)) {
|
267199
|
+
return "";
|
267200
|
+
}
|
267201
|
+
const formatted = args.map((arg) => {
|
267202
|
+
if (arg instanceof Error) {
|
267203
|
+
return `
|
267204
|
+
${arg.stack || arg.message}`;
|
267205
|
+
}
|
267206
|
+
if (typeof arg === "object" && arg !== null) {
|
267207
|
+
return `
|
267208
|
+
${JSON.stringify(arg, null, 2)}`;
|
267209
|
+
}
|
267210
|
+
return ` ${String(arg)}`;
|
267211
|
+
}).join("");
|
267212
|
+
return `, args:${formatted}`;
|
267213
|
+
};
|
267214
|
+
const shouldLog = (level2) => {
|
267215
|
+
return logLevels[level2] >= currentLevelValue;
|
267216
|
+
};
|
267217
|
+
return {
|
267218
|
+
debug: (message, ...args) => {
|
267219
|
+
if (shouldLog("debug")) {
|
267220
|
+
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens5(message)}${maskTokens5(formatArgs(args))}\x1B[0m`);
|
267221
|
+
}
|
267222
|
+
},
|
267223
|
+
info: (message, ...args) => {
|
267224
|
+
if (shouldLog("info")) {
|
267225
|
+
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens5(message)}${maskTokens5(formatArgs(args))}\x1B[0m`);
|
267226
|
+
}
|
267227
|
+
},
|
267228
|
+
warn: (message, ...args) => {
|
267229
|
+
if (shouldLog("warn")) {
|
267230
|
+
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens5(message)}${maskTokens5(formatArgs(args))}\x1B[0m`);
|
267231
|
+
}
|
267232
|
+
},
|
267233
|
+
error: (message, ...args) => {
|
267234
|
+
if (shouldLog("error")) {
|
267235
|
+
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens5(message)}${maskTokens5(formatArgs(args))}\x1B[0m`);
|
267236
|
+
}
|
267237
|
+
}
|
267238
|
+
};
|
267239
|
+
}
|
267240
|
+
var logger2 = createLogger2();
|
267120
267241
|
async function retryWhenFailed2(fn, maxRetries = 5, initialSleepTime = 1000, stopOnError) {
|
267121
|
-
let
|
267122
|
-
|
267242
|
+
let retries = 0;
|
267243
|
+
const maxAttempts = maxRetries + 1;
|
267244
|
+
while (retries < maxAttempts) {
|
267123
267245
|
try {
|
267124
267246
|
return await fn();
|
267125
267247
|
} catch (e3) {
|
267248
|
+
const error36 = e3;
|
267126
267249
|
if (typeof stopOnError === "function") {
|
267127
|
-
const error36 = e3;
|
267128
267250
|
if (stopOnError(error36)) {
|
267129
267251
|
throw error36;
|
267130
267252
|
}
|
267131
267253
|
}
|
267132
|
-
|
267133
|
-
if (attempt >= maxRetries) {
|
267254
|
+
if (retries >= maxRetries) {
|
267134
267255
|
throw e3;
|
267135
267256
|
}
|
267136
|
-
const
|
267137
|
-
const
|
267257
|
+
const baseDelay = 2 ** retries * initialSleepTime;
|
267258
|
+
const jitterAmount = initialSleepTime * (Math.random() / 10);
|
267259
|
+
const delay = baseDelay + jitterAmount;
|
267260
|
+
retries += 1;
|
267261
|
+
logger2.warn(`An error occurred ${error36.message}, retrying in ${delay.toFixed(0)}ms (retry ${retries} of ${maxRetries})...`);
|
267138
267262
|
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
267139
267263
|
}
|
267140
267264
|
}
|
@@ -267152,6 +267276,11 @@ function camelCaseToWords2(s) {
|
|
267152
267276
|
function replaceUnderscoresAndHyphensWithSpaces(s) {
|
267153
267277
|
return s.replace(/[-_]/g, " ");
|
267154
267278
|
}
|
267279
|
+
function extractBaseUrlBeforeSegment(baseUrl, pathSegment) {
|
267280
|
+
const url2 = new URL(baseUrl);
|
267281
|
+
const segmentIndex = url2.pathname.indexOf(pathSegment);
|
267282
|
+
return url2.origin + (segmentIndex >= 0 ? url2.pathname.substring(0, segmentIndex) : url2.pathname);
|
267283
|
+
}
|
267155
267284
|
|
267156
267285
|
// ../utils/dist/filesystem.mjs
|
267157
267286
|
import { dirname as dirname5 } from "path";
|
@@ -267378,29 +267507,24 @@ init_index_chunk();
|
|
267378
267507
|
var PACKAGE_NAME = "@settlemint/sdk-hasura";
|
267379
267508
|
async function codegenHasura(env2) {
|
267380
267509
|
const gqlEndpoint = env2.SETTLEMINT_HASURA_ENDPOINT;
|
267381
|
-
const
|
267510
|
+
const instance = env2.SETTLEMINT_INSTANCE;
|
267511
|
+
const accessToken = instance === STANDALONE_INSTANCE2 ? undefined : await getApplicationOrPersonalAccessToken({
|
267382
267512
|
env: env2,
|
267383
267513
|
instance: env2.SETTLEMINT_INSTANCE,
|
267384
267514
|
prefer: "application"
|
267385
267515
|
});
|
267386
267516
|
const adminSecret = env2.SETTLEMINT_HASURA_ADMIN_SECRET;
|
267387
|
-
|
267388
|
-
if (!gqlEndpoint || !accessToken || !adminSecret) {
|
267389
|
-
note("[Codegen] Missing required Hasura environment variables", "warn");
|
267390
|
-
return;
|
267391
|
-
}
|
267392
|
-
if (gqlEndpoint && accessToken && adminSecret) {
|
267517
|
+
if (gqlEndpoint && adminSecret) {
|
267393
267518
|
await generateSchema({
|
267394
267519
|
input: gqlEndpoint,
|
267395
267520
|
output: "hasura-schema.graphql",
|
267396
267521
|
tsconfig: undefined,
|
267397
267522
|
headers: {
|
267398
267523
|
"x-hasura-admin-secret": adminSecret,
|
267399
|
-
"x-auth-token": accessToken
|
267524
|
+
...accessToken ? { "x-auth-token": accessToken } : {}
|
267400
267525
|
}
|
267401
267526
|
});
|
267402
|
-
|
267403
|
-
const hasuraTemplate = `import { createHasuraClient } from "${PACKAGE_NAME}";
|
267527
|
+
const hasuraTemplate = `import { createHasuraClient } from "${PACKAGE_NAME}";
|
267404
267528
|
import type { introspection } from "@schemas/hasura-env";
|
267405
267529
|
import { createLogger, requestLogger, type LogLevel } from '@settlemint/sdk-utils/logging';
|
267406
267530
|
|
@@ -267423,22 +267547,27 @@ export const { client: hasuraClient, graphql: hasuraGraphql } = createHasuraClie
|
|
267423
267547
|
};
|
267424
267548
|
}>({
|
267425
267549
|
instance: process.env.SETTLEMINT_HASURA_ENDPOINT!,
|
267426
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
267550
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
267427
267551
|
adminSecret: process.env.SETTLEMINT_HASURA_ADMIN_SECRET!,
|
267428
267552
|
}, {
|
267429
267553
|
fetch: requestLogger(logger, "hasura", fetch) as typeof fetch,
|
267430
267554
|
});`;
|
267431
|
-
|
267432
|
-
|
267555
|
+
await writeTemplate(hasuraTemplate, "/lib/settlemint", "hasura.ts");
|
267556
|
+
} else {
|
267557
|
+
note("[Codegen] Missing required Hasura environment variables", "warn");
|
267558
|
+
}
|
267559
|
+
const databaseUrl = env2.SETTLEMINT_HASURA_DATABASE_URL;
|
267560
|
+
if (databaseUrl) {
|
267561
|
+
const drizzleTemplate = `import { createPostgresPool } from "${PACKAGE_NAME}/postgres";
|
267433
267562
|
|
267434
|
-
export const postgresPool = createPostgresPool(process.env.SETTLEMINT_HASURA_DATABASE_URL ??
|
267563
|
+
export const postgresPool = createPostgresPool(process.env.SETTLEMINT_HASURA_DATABASE_URL ?? "");
|
267435
267564
|
`;
|
267436
|
-
|
267437
|
-
|
267438
|
-
|
267439
|
-
|
267440
|
-
|
267441
|
-
|
267565
|
+
await writeTemplate(drizzleTemplate, "/lib/settlemint", "postgres.ts");
|
267566
|
+
const projectDir = await projectRoot3();
|
267567
|
+
if (!await isPackageInstalled(PACKAGE_NAME, projectDir)) {
|
267568
|
+
await installDependencies(PACKAGE_NAME, projectDir);
|
267569
|
+
}
|
267570
|
+
} else {
|
267442
267571
|
note("[Codegen] Missing database environment variables", "warn");
|
267443
267572
|
}
|
267444
267573
|
}
|
@@ -267450,21 +267579,19 @@ async function codegenPortal(env2) {
|
|
267450
267579
|
if (!gqlEndpoint) {
|
267451
267580
|
return;
|
267452
267581
|
}
|
267453
|
-
const
|
267582
|
+
const instance = env2.SETTLEMINT_INSTANCE;
|
267583
|
+
const accessToken = instance === STANDALONE_INSTANCE2 ? undefined : await getApplicationOrPersonalAccessToken({
|
267454
267584
|
env: env2,
|
267455
267585
|
instance: env2.SETTLEMINT_INSTANCE,
|
267456
267586
|
prefer: "application"
|
267457
267587
|
});
|
267458
|
-
if (!accessToken) {
|
267459
|
-
return;
|
267460
|
-
}
|
267461
267588
|
await generateSchema({
|
267462
267589
|
input: gqlEndpoint,
|
267463
267590
|
output: "portal-schema.graphql",
|
267464
267591
|
tsconfig: undefined,
|
267465
|
-
headers: {
|
267466
|
-
"x-auth-token": accessToken
|
267467
|
-
}
|
267592
|
+
headers: accessToken ? {
|
267593
|
+
"x-auth-token": accessToken
|
267594
|
+
} : {}
|
267468
267595
|
});
|
267469
267596
|
const template = `import { createPortalClient, getWebsocketClient } from "${PACKAGE_NAME2}";
|
267470
267597
|
import type { introspection } from "@schemas/portal-env";
|
@@ -267481,14 +267608,14 @@ export const { client: portalClient, graphql: portalGraphql } = createPortalClie
|
|
267481
267608
|
};
|
267482
267609
|
}>({
|
267483
267610
|
instance: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
267484
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
267611
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
267485
267612
|
}, {
|
267486
267613
|
fetch: requestLogger(logger, "portal", fetch) as typeof fetch,
|
267487
267614
|
});
|
267488
267615
|
|
267489
267616
|
export const getPortalWebsocketClient = getWebsocketClient({
|
267490
267617
|
portalGraphqlEndpoint: process.env.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT!,
|
267491
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
267618
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
267492
267619
|
});
|
267493
267620
|
`;
|
267494
267621
|
await writeTemplate(template, "/lib/settlemint", "portal.ts");
|
@@ -267515,14 +267642,12 @@ async function codegenTheGraph(env2, subgraphNames) {
|
|
267515
267642
|
if (!Array.isArray(gqlEndpoints) || gqlEndpoints.length === 0) {
|
267516
267643
|
return;
|
267517
267644
|
}
|
267518
|
-
const
|
267645
|
+
const instance = env2.SETTLEMINT_INSTANCE;
|
267646
|
+
const accessToken = instance === STANDALONE_INSTANCE2 ? undefined : await getApplicationOrPersonalAccessToken({
|
267519
267647
|
env: env2,
|
267520
267648
|
instance: env2.SETTLEMINT_INSTANCE,
|
267521
267649
|
prefer: "application"
|
267522
267650
|
});
|
267523
|
-
if (!accessToken) {
|
267524
|
-
return;
|
267525
|
-
}
|
267526
267651
|
const template = [
|
267527
267652
|
`import { createTheGraphClient } from "${PACKAGE_NAME3}";`,
|
267528
267653
|
"import { createLogger, requestLogger, type LogLevel } from '@settlemint/sdk-utils/logging';"
|
@@ -267549,9 +267674,9 @@ async function codegenTheGraph(env2, subgraphNames) {
|
|
267549
267674
|
input: gqlEndpoint,
|
267550
267675
|
output: `the-graph-schema-${name3}.graphql`,
|
267551
267676
|
tsconfig: undefined,
|
267552
|
-
headers: {
|
267677
|
+
headers: accessToken ? {
|
267553
267678
|
"x-auth-token": accessToken
|
267554
|
-
}
|
267679
|
+
} : {}
|
267555
267680
|
});
|
267556
267681
|
const nameSuffix = capitalizeFirstLetter2(name3);
|
267557
267682
|
const graphqlClientVariable = getVariableName(`theGraphClient${nameSuffix}`);
|
@@ -267571,7 +267696,7 @@ export const { client: ${graphqlClientVariable}, graphql: ${graphqlVariable} } =
|
|
267571
267696
|
};
|
267572
267697
|
}>({
|
267573
267698
|
instances: JSON.parse(process.env.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS || '[]'),
|
267574
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
267699
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
267575
267700
|
subgraphName: "${name3}",
|
267576
267701
|
cache: "force-cache",
|
267577
267702
|
}, {
|
@@ -267618,11 +267743,12 @@ async function testGqlEndpoint({
|
|
267618
267743
|
try {
|
267619
267744
|
await graphqlFetchWithRetry(gqlEndpoint, {
|
267620
267745
|
method: "POST",
|
267621
|
-
headers: {
|
267622
|
-
"
|
267623
|
-
...isHasura ? { "x-hasura-admin-secret": hasuraAdminSecret ?? "" } : {}
|
267624
|
-
|
267625
|
-
|
267746
|
+
headers: appendHeaders({
|
267747
|
+
"Content-Type": "application/json",
|
267748
|
+
...isHasura ? { "x-hasura-admin-secret": hasuraAdminSecret ?? "" } : {}
|
267749
|
+
}, {
|
267750
|
+
"x-auth-token": accessToken
|
267751
|
+
}),
|
267626
267752
|
body: JSON.stringify({
|
267627
267753
|
query: `
|
267628
267754
|
query {
|
@@ -268546,19 +268672,22 @@ async function codegenTsconfig(env2, thegraphSubgraphNames) {
|
|
268546
268672
|
blockscout: false
|
268547
268673
|
};
|
268548
268674
|
}
|
268549
|
-
|
268550
|
-
|
268551
|
-
|
268552
|
-
|
268553
|
-
|
268554
|
-
|
268555
|
-
|
268556
|
-
|
268557
|
-
hasura
|
268558
|
-
|
268559
|
-
|
268560
|
-
|
268561
|
-
|
268675
|
+
let accessToken;
|
268676
|
+
if (env2.SETTLEMINT_INSTANCE !== STANDALONE_INSTANCE2) {
|
268677
|
+
accessToken = await getApplicationOrPersonalAccessToken({
|
268678
|
+
env: env2,
|
268679
|
+
instance: env2.SETTLEMINT_INSTANCE,
|
268680
|
+
prefer: "application"
|
268681
|
+
});
|
268682
|
+
if (!accessToken) {
|
268683
|
+
note("No access token found, skipping codegen for hasura, portal, thegraph and blockscout", "warn");
|
268684
|
+
return {
|
268685
|
+
hasura: false,
|
268686
|
+
portal: false,
|
268687
|
+
thegraph: false,
|
268688
|
+
blockscout: false
|
268689
|
+
};
|
268690
|
+
}
|
268562
268691
|
}
|
268563
268692
|
const theGraphEndpoints = (env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS ?? []).filter((gqlEndpoint) => {
|
268564
268693
|
const name3 = getSubgraphName(gqlEndpoint);
|
@@ -268995,22 +269124,21 @@ async function codegenBlockscout(env2) {
|
|
268995
269124
|
if (!endpoint) {
|
268996
269125
|
return;
|
268997
269126
|
}
|
268998
|
-
const
|
269127
|
+
const instance = env2.SETTLEMINT_INSTANCE;
|
269128
|
+
const accessToken = instance === STANDALONE_INSTANCE2 ? undefined : await getApplicationOrPersonalAccessToken({
|
268999
269129
|
env: env2,
|
269000
269130
|
instance: env2.SETTLEMINT_INSTANCE,
|
269001
269131
|
prefer: "application"
|
269002
269132
|
});
|
269003
|
-
if (!accessToken) {
|
269004
|
-
return;
|
269005
|
-
}
|
269006
269133
|
const introspectionJsonPath = resolve5(process.cwd(), "__blockscout-introspection__.json");
|
269007
269134
|
try {
|
269008
269135
|
const data = await graphqlFetchWithRetry(endpoint, {
|
269009
269136
|
method: "POST",
|
269010
|
-
headers: {
|
269011
|
-
"x-auth-token": accessToken,
|
269137
|
+
headers: appendHeaders({
|
269012
269138
|
"Content-Type": "application/json"
|
269013
|
-
},
|
269139
|
+
}, {
|
269140
|
+
"x-auth-token": accessToken
|
269141
|
+
}),
|
269014
269142
|
body: JSON.stringify({
|
269015
269143
|
query: `
|
269016
269144
|
query IntrospectionQuery {
|
@@ -269157,7 +269285,7 @@ export const { client: blockscoutClient, graphql: blockscoutGraphql } = createBl
|
|
269157
269285
|
};
|
269158
269286
|
}>({
|
269159
269287
|
instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT!,
|
269160
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
269288
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
269161
269289
|
}, {
|
269162
269290
|
fetch: requestLogger(logger, "blockscout", fetch) as typeof fetch,
|
269163
269291
|
});
|
@@ -269184,7 +269312,7 @@ async function codegenIpfs(env2) {
|
|
269184
269312
|
|
269185
269313
|
export const { client } = createServerIpfsClient({
|
269186
269314
|
instance: process.env.SETTLEMINT_IPFS_API_ENDPOINT!,
|
269187
|
-
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
|
269315
|
+
accessToken: process.env.SETTLEMINT_ACCESS_TOKEN ?? "",
|
269188
269316
|
});`;
|
269189
269317
|
await writeTemplate(clientTemplate, "/lib/settlemint", "ipfs.ts");
|
269190
269318
|
const projectDir = await projectRoot3();
|
@@ -274793,7 +274921,7 @@ async function codegenViem(env2) {
|
|
274793
274921
|
}
|
274794
274922
|
const chainId = env2.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID ?? await ae4({
|
274795
274923
|
accessToken: env2.SETTLEMINT_ACCESS_TOKEN,
|
274796
|
-
rpcUrl:
|
274924
|
+
rpcUrl: loadBalancerRpcEndpoint ?? blockchainNodeRpcEndpoint
|
274797
274925
|
});
|
274798
274926
|
if (!chainId) {
|
274799
274927
|
note("[Codegen] No chain ID found, skipping Viem resources generation", "warn");
|
@@ -274817,7 +274945,7 @@ async function codegenViem(env2) {
|
|
274817
274945
|
* The public client. Use this if you need to read from the blockchain.
|
274818
274946
|
*/
|
274819
274947
|
export const publicClient = getPublicClient({
|
274820
|
-
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN,
|
274948
|
+
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN ?? "",
|
274821
274949
|
chainId: ${env2.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID ? "process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!" : `"${chainId}"`},
|
274822
274950
|
chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,
|
274823
274951
|
rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT!,
|
@@ -274829,7 +274957,7 @@ export const publicClient = getPublicClient({
|
|
274829
274957
|
* The wallet client. Use this if you need to write to the blockchain.
|
274830
274958
|
*/
|
274831
274959
|
export const walletClient = getWalletClient({
|
274832
|
-
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN,
|
274960
|
+
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN ?? "",
|
274833
274961
|
chainId: ${env2.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID ? "process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!" : `"${chainId}"`},
|
274834
274962
|
chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,
|
274835
274963
|
rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT!,
|
@@ -274840,7 +274968,7 @@ export const walletClient = getWalletClient({
|
|
274840
274968
|
* HD wallets require a challenge response to be sent with the request.
|
274841
274969
|
*/
|
274842
274970
|
export const hdWalletClient = getWalletClient({
|
274843
|
-
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN,
|
274971
|
+
accessToken: process.env.SETTLEMINT_BLOCKCHAIN_ACCESS_TOKEN ?? "",
|
274844
274972
|
chainId: ${env2.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID ? "process.env.SETTLEMINT_BLOCKCHAIN_NETWORK_CHAIN_ID!" : `"${chainId}"`},
|
274845
274973
|
chainName: process.env.SETTLEMINT_BLOCKCHAIN_NETWORK!,
|
274846
274974
|
rpcUrl: process.env.SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT!,
|
@@ -275487,7 +275615,12 @@ async function theGraphPrompt({
|
|
275487
275615
|
}
|
275488
275616
|
|
275489
275617
|
// src/prompts/instance.prompt.ts
|
275490
|
-
async function instancePrompt(
|
275618
|
+
async function instancePrompt({
|
275619
|
+
env: env2,
|
275620
|
+
accept,
|
275621
|
+
freeTextInput = false,
|
275622
|
+
isCi = is_in_ci_default
|
275623
|
+
}) {
|
275491
275624
|
const autoAccept = !!accept || isCi;
|
275492
275625
|
const defaultInstance = env2.SETTLEMINT_INSTANCE;
|
275493
275626
|
const defaultPossible = autoAccept && defaultInstance;
|
@@ -275517,10 +275650,7 @@ async function instancePrompt(env2, accept, freeTextInput = false, isCi = is_in_
|
|
275517
275650
|
return sanitizeInstanceUrl(instance);
|
275518
275651
|
}
|
275519
275652
|
if (knownInstances.length === 0) {
|
275520
|
-
|
275521
|
-
}
|
275522
|
-
if (knownInstances.length === 1) {
|
275523
|
-
return sanitizeInstanceUrl(knownInstances[0]);
|
275653
|
+
note("No instances found. Run `settlemint login` to configure an instance.", "warn");
|
275524
275654
|
}
|
275525
275655
|
return esm_default3({
|
275526
275656
|
message: "What instance do you want to connect to?",
|
@@ -275530,16 +275660,17 @@ async function instancePrompt(env2, accept, freeTextInput = false, isCi = is_in_
|
|
275530
275660
|
value: sanitizeInstanceUrl(instance)
|
275531
275661
|
})),
|
275532
275662
|
{
|
275533
|
-
name: "Standalone (
|
275663
|
+
name: "Standalone (services run independently of SettleMint platform)",
|
275534
275664
|
value: STANDALONE_INSTANCE2
|
275535
275665
|
}
|
275536
275666
|
],
|
275537
|
-
default: sanitizeInstanceUrl(defaultPromptInstance)
|
275667
|
+
default: sanitizeInstanceUrl(knownInstances.length > 0 ? defaultPromptInstance : STANDALONE_INSTANCE2)
|
275538
275668
|
});
|
275539
275669
|
}
|
275540
275670
|
|
275541
275671
|
// src/prompts/standalone/service-secret.prompt.ts
|
275542
275672
|
async function serviceSecretPrompt({
|
275673
|
+
name: name3,
|
275543
275674
|
defaultSecret,
|
275544
275675
|
message = "Enter service secret:",
|
275545
275676
|
accept = false,
|
@@ -275554,7 +275685,7 @@ async function serviceSecretPrompt({
|
|
275554
275685
|
}
|
275555
275686
|
if (defaultSecret) {
|
275556
275687
|
const keep = await esm_default4({
|
275557
|
-
message:
|
275688
|
+
message: `Do you want to use the existing ${name3} secret?`,
|
275558
275689
|
default: true
|
275559
275690
|
});
|
275560
275691
|
if (keep) {
|
@@ -275564,7 +275695,7 @@ async function serviceSecretPrompt({
|
|
275564
275695
|
const serviceSecret = await esm_default5({
|
275565
275696
|
message
|
275566
275697
|
});
|
275567
|
-
return serviceSecret
|
275698
|
+
return serviceSecret || undefined;
|
275568
275699
|
}
|
275569
275700
|
|
275570
275701
|
// src/prompts/standalone/service-url.prompt.ts
|
@@ -275596,7 +275727,7 @@ async function serviceUrlPrompt({
|
|
275596
275727
|
},
|
275597
275728
|
transformer: (value4) => value4.trim()
|
275598
275729
|
});
|
275599
|
-
return
|
275730
|
+
return serviceUrl || undefined;
|
275600
275731
|
}
|
275601
275732
|
|
275602
275733
|
// src/prompts/workspace.prompt.ts
|
@@ -275861,11 +275992,51 @@ function getHdPrivateKeyEnv(service) {
|
|
275861
275992
|
};
|
275862
275993
|
}
|
275863
275994
|
|
275995
|
+
// src/utils/subgraph/thegraph-url.ts
|
275996
|
+
function getUpdatedSubgraphEndpoints({
|
275997
|
+
existingEndpoints,
|
275998
|
+
newSubgraphName,
|
275999
|
+
middlewareAdminUrl,
|
276000
|
+
removedSubgraphName
|
276001
|
+
}) {
|
276002
|
+
const existingEndpointsWithoutRemoved = existingEndpoints.filter((endpoint) => {
|
276003
|
+
return getSubgraphName(endpoint) !== removedSubgraphName;
|
276004
|
+
});
|
276005
|
+
if (newSubgraphName) {
|
276006
|
+
if (!middlewareAdminUrl) {
|
276007
|
+
throw new Error("Middleware admin URL is required to add a new subgraph");
|
276008
|
+
}
|
276009
|
+
const baseUrl = extractBaseUrlBeforeSegment(middlewareAdminUrl, "/admin");
|
276010
|
+
if (baseUrl) {
|
276011
|
+
const endpoint = `${getTheGraphSubgraphUrl(baseUrl, newSubgraphName)}`;
|
276012
|
+
if (!existingEndpointsWithoutRemoved.includes(endpoint)) {
|
276013
|
+
existingEndpointsWithoutRemoved.push(endpoint);
|
276014
|
+
}
|
276015
|
+
}
|
276016
|
+
}
|
276017
|
+
return existingEndpointsWithoutRemoved;
|
276018
|
+
}
|
276019
|
+
function getTheGraphUrl(subgraphUrls) {
|
276020
|
+
if (Array.isArray(subgraphUrls) && subgraphUrls.length > 0) {
|
276021
|
+
return extractBaseUrlBeforeSegment(subgraphUrls[0], "/subgraphs");
|
276022
|
+
}
|
276023
|
+
return;
|
276024
|
+
}
|
276025
|
+
function getTheGraphSubgraphNames(subgraphUrls) {
|
276026
|
+
if (Array.isArray(subgraphUrls) && subgraphUrls.length > 0) {
|
276027
|
+
return subgraphUrls.map((url2) => getSubgraphName(url2));
|
276028
|
+
}
|
276029
|
+
return [];
|
276030
|
+
}
|
276031
|
+
function getTheGraphSubgraphUrl(theGraphUrl, subgraphName) {
|
276032
|
+
return `${theGraphUrl}/subgraphs/name/${subgraphName}`;
|
276033
|
+
}
|
276034
|
+
|
275864
276035
|
// ../utils/dist/logging.mjs
|
275865
|
-
var
|
276036
|
+
var maskTokens6 = (output) => {
|
275866
276037
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
275867
276038
|
};
|
275868
|
-
function
|
276039
|
+
function createLogger3(options = {}) {
|
275869
276040
|
const { level = "warn", prefix = "" } = options;
|
275870
276041
|
const logLevels = {
|
275871
276042
|
debug: 0,
|
@@ -275898,27 +276069,49 @@ ${JSON.stringify(arg, null, 2)}`;
|
|
275898
276069
|
return {
|
275899
276070
|
debug: (message, ...args) => {
|
275900
276071
|
if (shouldLog("debug")) {
|
275901
|
-
console.debug(`\x1B[32m${prefix}[DEBUG] ${
|
276072
|
+
console.debug(`\x1B[32m${prefix}[DEBUG] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
275902
276073
|
}
|
275903
276074
|
},
|
275904
276075
|
info: (message, ...args) => {
|
275905
276076
|
if (shouldLog("info")) {
|
275906
|
-
console.info(`\x1B[34m${prefix}[INFO] ${
|
276077
|
+
console.info(`\x1B[34m${prefix}[INFO] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
275907
276078
|
}
|
275908
276079
|
},
|
275909
276080
|
warn: (message, ...args) => {
|
275910
276081
|
if (shouldLog("warn")) {
|
275911
|
-
console.warn(`\x1B[33m${prefix}[WARN] ${
|
276082
|
+
console.warn(`\x1B[33m${prefix}[WARN] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
275912
276083
|
}
|
275913
276084
|
},
|
275914
276085
|
error: (message, ...args) => {
|
275915
276086
|
if (shouldLog("error")) {
|
275916
|
-
console.error(`\x1B[31m${prefix}[ERROR] ${
|
276087
|
+
console.error(`\x1B[31m${prefix}[ERROR] ${maskTokens6(message)}${maskTokens6(formatArgs(args))}\x1B[0m`);
|
275917
276088
|
}
|
275918
276089
|
}
|
275919
276090
|
};
|
275920
276091
|
}
|
275921
|
-
var
|
276092
|
+
var logger3 = createLogger3();
|
276093
|
+
|
276094
|
+
// src/prompts/standalone/service-value.prompt.ts
|
276095
|
+
async function serviceValuePrompt({
|
276096
|
+
defaultValue,
|
276097
|
+
example,
|
276098
|
+
message = "Enter service value:",
|
276099
|
+
accept = false,
|
276100
|
+
isCi = is_in_ci_default
|
276101
|
+
}) {
|
276102
|
+
const autoAccept = !!accept || isCi;
|
276103
|
+
if (autoAccept && defaultValue) {
|
276104
|
+
return defaultValue;
|
276105
|
+
}
|
276106
|
+
if (isCi) {
|
276107
|
+
return defaultValue;
|
276108
|
+
}
|
276109
|
+
const serviceSecret = await esm_default2({
|
276110
|
+
message: example ? `${message} (eg ${example})` : message,
|
276111
|
+
default: defaultValue
|
276112
|
+
});
|
276113
|
+
return serviceSecret || undefined;
|
276114
|
+
}
|
275922
276115
|
|
275923
276116
|
// src/commands/connect.ts
|
275924
276117
|
function connectCommand() {
|
@@ -275942,7 +276135,10 @@ function connectCommand() {
|
|
275942
276135
|
])).action(async ({ acceptDefaults, prod, instance }) => {
|
275943
276136
|
intro("Connecting your dApp");
|
275944
276137
|
const env2 = await loadEnv(false, !!prod);
|
275945
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(
|
276138
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
276139
|
+
env: env2,
|
276140
|
+
accept: true
|
276141
|
+
});
|
275946
276142
|
if (selectedInstance === STANDALONE_INSTANCE2) {
|
275947
276143
|
await connectToStandalone(env2, acceptDefaults, prod);
|
275948
276144
|
} else {
|
@@ -276144,7 +276340,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276144
276340
|
message: "What is the JSON RPC endpoint for the blockchain node you want to use for sending transactions?",
|
276145
276341
|
example: "https://blockchain-node.mydomain.com",
|
276146
276342
|
defaultValue: env2.SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT,
|
276147
|
-
|
276343
|
+
type: "url"
|
276148
276344
|
},
|
276149
276345
|
{
|
276150
276346
|
id: "loadBalancerJsonRpcEndpoint",
|
@@ -276152,7 +276348,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276152
276348
|
message: "What is the JSON RPC endpoint for the load balancer or blockchain node you want to use for read operations?",
|
276153
276349
|
example: "https://load-balancer.mydomain.com",
|
276154
276350
|
defaultValue: env2.SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER_JSON_RPC_ENDPOINT,
|
276155
|
-
|
276351
|
+
type: "url"
|
276156
276352
|
},
|
276157
276353
|
{
|
276158
276354
|
id: "hasuraEndpoint",
|
@@ -276160,7 +276356,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276160
276356
|
message: "What is the GraphQL endpoint for the Hasura instance you want to connect to?",
|
276161
276357
|
example: "https://hasura.mydomain.com/v1/graphql",
|
276162
276358
|
defaultValue: env2.SETTLEMINT_HASURA_ENDPOINT,
|
276163
|
-
|
276359
|
+
type: "url"
|
276164
276360
|
},
|
276165
276361
|
{
|
276166
276362
|
id: "hasuraAdminSecret",
|
@@ -276168,7 +276364,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276168
276364
|
message: "What is the admin secret for the Hasura instance you want to connect to?",
|
276169
276365
|
example: "",
|
276170
276366
|
defaultValue: env2.SETTLEMINT_HASURA_ADMIN_SECRET,
|
276171
|
-
|
276367
|
+
type: "secret"
|
276172
276368
|
},
|
276173
276369
|
{
|
276174
276370
|
id: "hasuraDatabaseUrl",
|
@@ -276176,15 +276372,23 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276176
276372
|
message: "What is the database URL for the Hasura instance you want to connect to?",
|
276177
276373
|
example: "postgresql://username:password@host:port/database",
|
276178
276374
|
defaultValue: env2.SETTLEMINT_HASURA_DATABASE_URL,
|
276179
|
-
|
276375
|
+
type: "url"
|
276180
276376
|
},
|
276181
276377
|
{
|
276182
276378
|
id: "theGraphEndpoint",
|
276183
|
-
label: "The Graph
|
276184
|
-
message: "What is the
|
276185
|
-
example: "https://thegraph.mydomain.com
|
276186
|
-
defaultValue:
|
276187
|
-
|
276379
|
+
label: "The Graph Endpoint",
|
276380
|
+
message: "What is the endpoint for the The Graph instance you want to connect to?",
|
276381
|
+
example: "https://thegraph.mydomain.com",
|
276382
|
+
defaultValue: getTheGraphUrl(env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS),
|
276383
|
+
type: "url"
|
276384
|
+
},
|
276385
|
+
{
|
276386
|
+
id: "theGraphSubgraphNames",
|
276387
|
+
label: "The Graph subgraph names",
|
276388
|
+
message: "What are the names of the subgraphs you want to connect to (separated by commas)?",
|
276389
|
+
example: "subgraph-1,subgraph-2",
|
276390
|
+
defaultValue: getTheGraphSubgraphNames(env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS).join(","),
|
276391
|
+
type: "value"
|
276188
276392
|
},
|
276189
276393
|
{
|
276190
276394
|
id: "portalGraphqlEndpoint",
|
@@ -276192,7 +276396,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276192
276396
|
message: "What is the GraphQL endpoint for the Smart Contract Portal instance you want to connect to?",
|
276193
276397
|
example: "https://portal.mydomain.com/graphql",
|
276194
276398
|
defaultValue: env2.SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT,
|
276195
|
-
|
276399
|
+
type: "url"
|
276196
276400
|
},
|
276197
276401
|
{
|
276198
276402
|
id: "minioEndpoint",
|
@@ -276200,7 +276404,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276200
276404
|
message: "What is the endpoint for the MinIO instance you want to connect to?",
|
276201
276405
|
example: "s3://minio.mydomain.com",
|
276202
276406
|
defaultValue: env2.SETTLEMINT_MINIO_ENDPOINT,
|
276203
|
-
|
276407
|
+
type: "url"
|
276204
276408
|
},
|
276205
276409
|
{
|
276206
276410
|
id: "minioAccessKey",
|
@@ -276208,7 +276412,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276208
276412
|
message: "What is the access key for the MinIO instance you want to connect to?",
|
276209
276413
|
example: "",
|
276210
276414
|
defaultValue: env2.SETTLEMINT_MINIO_ACCESS_KEY,
|
276211
|
-
|
276415
|
+
type: "secret"
|
276212
276416
|
},
|
276213
276417
|
{
|
276214
276418
|
id: "minioSecretKey",
|
@@ -276216,7 +276420,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276216
276420
|
message: "What is the secret key for the MinIO instance you want to connect to?",
|
276217
276421
|
example: "",
|
276218
276422
|
defaultValue: env2.SETTLEMINT_MINIO_SECRET_KEY,
|
276219
|
-
|
276423
|
+
type: "secret"
|
276220
276424
|
},
|
276221
276425
|
{
|
276222
276426
|
id: "ipfsApiEndpoint",
|
@@ -276224,7 +276428,7 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276224
276428
|
message: "What is the endpoint for the IPFS instance you want to connect to?",
|
276225
276429
|
example: "https://ipfs.mydomain.com/api/v0",
|
276226
276430
|
defaultValue: env2.SETTLEMINT_IPFS_API_ENDPOINT,
|
276227
|
-
|
276431
|
+
type: "url"
|
276228
276432
|
},
|
276229
276433
|
{
|
276230
276434
|
id: "blockscoutGraphqlEndpoint",
|
@@ -276232,42 +276436,44 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276232
276436
|
message: "What is the GraphQL endpoint for the Blockscout instance you want to connect to?",
|
276233
276437
|
example: "https://blockscout.mydomain.com/api/v1/graphql",
|
276234
276438
|
defaultValue: env2.SETTLEMINT_BLOCKSCOUT_GRAPHQL_ENDPOINT,
|
276235
|
-
|
276439
|
+
type: "url"
|
276236
276440
|
}
|
276237
276441
|
];
|
276238
276442
|
const selectedServices = {};
|
276239
276443
|
for (const prompt of standalonePrompts) {
|
276240
|
-
const { id, message, example, defaultValue,
|
276241
|
-
const result =
|
276444
|
+
const { id, label, message, example, defaultValue, type: type4 } = prompt;
|
276445
|
+
const result = type4 === "secret" ? await serviceSecretPrompt({
|
276446
|
+
name: label,
|
276242
276447
|
message,
|
276243
276448
|
defaultSecret: defaultValue,
|
276244
276449
|
accept: acceptDefaults
|
276245
|
-
}) : await serviceUrlPrompt({
|
276450
|
+
}) : type4 === "url" ? await serviceUrlPrompt({
|
276246
276451
|
message,
|
276247
276452
|
example,
|
276248
276453
|
defaultUrl: defaultValue,
|
276249
276454
|
accept: acceptDefaults
|
276455
|
+
}) : await serviceValuePrompt({
|
276456
|
+
message,
|
276457
|
+
example,
|
276458
|
+
defaultValue,
|
276459
|
+
accept: acceptDefaults
|
276250
276460
|
});
|
276251
276461
|
selectedServices[id] = {
|
276252
276462
|
label: prompt.label,
|
276253
276463
|
result,
|
276254
|
-
isSecret
|
276464
|
+
isSecret: type4 === "secret"
|
276255
276465
|
};
|
276256
276466
|
}
|
276257
276467
|
if (acceptDefaults) {
|
276258
|
-
table("
|
276259
|
-
if (item.isSecret) {
|
276260
|
-
return {
|
276261
|
-
...item,
|
276262
|
-
result: "********"
|
276263
|
-
};
|
276264
|
-
}
|
276468
|
+
table("Configuration", Object.values(selectedServices).filter((item) => !item.isSecret).map((item) => {
|
276265
276469
|
return {
|
276266
|
-
|
276267
|
-
|
276470
|
+
name: item.label,
|
276471
|
+
value: item.result ? maskTokens6(item.result) : undefined
|
276268
276472
|
};
|
276269
276473
|
}).filter(Boolean));
|
276270
276474
|
}
|
276475
|
+
const theGraphUrl = selectedServices.theGraphEndpoint?.result;
|
276476
|
+
const theGraphSubgraphNames = selectedServices.theGraphSubgraphNames?.result;
|
276271
276477
|
await writeEnvSpinner(!!prod, {
|
276272
276478
|
SETTLEMINT_INSTANCE: STANDALONE_INSTANCE2,
|
276273
276479
|
SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT: selectedServices.blockchainNodeJsonRpcEndpoint?.result,
|
@@ -276275,8 +276481,8 @@ async function connectToStandalone(env2, acceptDefaults, prod) {
|
|
276275
276481
|
SETTLEMINT_HASURA_ENDPOINT: selectedServices.hasuraEndpoint?.result,
|
276276
276482
|
SETTLEMINT_HASURA_ADMIN_SECRET: selectedServices.hasuraAdminSecret?.result,
|
276277
276483
|
SETTLEMINT_HASURA_DATABASE_URL: selectedServices.hasuraDatabaseUrl?.result,
|
276278
|
-
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS:
|
276279
|
-
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH:
|
276484
|
+
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: theGraphUrl && theGraphSubgraphNames ? theGraphSubgraphNames.split(",").map((name3) => getTheGraphSubgraphUrl(theGraphUrl, name3)) : [],
|
276485
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: theGraphSubgraphNames ? theGraphSubgraphNames.split(",")[0] : undefined,
|
276280
276486
|
SETTLEMINT_PORTAL_GRAPHQL_ENDPOINT: selectedServices.portalGraphqlEndpoint?.result,
|
276281
276487
|
SETTLEMINT_MINIO_ENDPOINT: selectedServices.minioEndpoint?.result,
|
276282
276488
|
SETTLEMINT_MINIO_ACCESS_KEY: selectedServices.minioAccessKey?.result,
|
@@ -280077,7 +280283,10 @@ function createCommand2() {
|
|
280077
280283
|
if (version5 && !template) {
|
280078
280284
|
cancel2("The --version option requires the --template option to be set");
|
280079
280285
|
}
|
280080
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(
|
280286
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
280287
|
+
env: env2,
|
280288
|
+
accept: true
|
280289
|
+
});
|
280081
280290
|
const settlemint = createSettleMintClient({
|
280082
280291
|
instance: selectedInstance,
|
280083
280292
|
accessToken: "",
|
@@ -280182,38 +280391,49 @@ function hasuraTrackCommand() {
|
|
280182
280391
|
])).option("-a, --accept-defaults", "Accept the default and previously set values").option("-d, --database <database>", "Database name", "default").action(async ({ acceptDefaults, database }) => {
|
280183
280392
|
intro("Tracking all tables in Hasura");
|
280184
280393
|
const env2 = await loadEnv(false, false);
|
280185
|
-
const
|
280186
|
-
if (!applicationUniqueName) {
|
280187
|
-
return missingApplication();
|
280188
|
-
}
|
280189
|
-
const selectedInstance = await instancePrompt(env2, true);
|
280190
|
-
const accessToken = await getApplicationOrPersonalAccessToken({
|
280394
|
+
const selectedInstance = await instancePrompt({
|
280191
280395
|
env: env2,
|
280192
|
-
|
280193
|
-
prefer: "application"
|
280194
|
-
});
|
280195
|
-
const settlemint = createSettleMintClient({
|
280196
|
-
accessToken,
|
280197
|
-
instance: selectedInstance
|
280198
|
-
});
|
280199
|
-
const integrationTools = await serviceSpinner("integration tool", () => settlemint.integrationTool.list(applicationUniqueName));
|
280200
|
-
const hasura = await hasuraPrompt({
|
280201
|
-
env: env2,
|
280202
|
-
integrations: integrationTools,
|
280203
|
-
accept: acceptDefaults,
|
280204
|
-
isRequired: true
|
280396
|
+
accept: acceptDefaults
|
280205
280397
|
});
|
280206
|
-
|
280207
|
-
|
280398
|
+
let hasuraGraphqlEndpoint;
|
280399
|
+
let hasuraAdminSecret;
|
280400
|
+
let accessToken;
|
280401
|
+
if (selectedInstance === STANDALONE_INSTANCE2) {
|
280402
|
+
hasuraGraphqlEndpoint = env2.SETTLEMINT_HASURA_ENDPOINT;
|
280403
|
+
hasuraAdminSecret = env2.SETTLEMINT_HASURA_ADMIN_SECRET;
|
280404
|
+
} else {
|
280405
|
+
const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
|
280406
|
+
if (!applicationUniqueName) {
|
280407
|
+
return missingApplication();
|
280408
|
+
}
|
280409
|
+
accessToken = await getApplicationOrPersonalAccessToken({
|
280410
|
+
env: env2,
|
280411
|
+
instance: selectedInstance,
|
280412
|
+
prefer: "application"
|
280413
|
+
});
|
280414
|
+
const settlemint = createSettleMintClient({
|
280415
|
+
accessToken,
|
280416
|
+
instance: selectedInstance
|
280417
|
+
});
|
280418
|
+
const integrationTools = await serviceSpinner("integration tool", () => settlemint.integrationTool.list(applicationUniqueName));
|
280419
|
+
const hasura = await hasuraPrompt({
|
280420
|
+
env: env2,
|
280421
|
+
integrations: integrationTools,
|
280422
|
+
accept: acceptDefaults,
|
280423
|
+
isRequired: true
|
280424
|
+
});
|
280425
|
+
if (!hasura) {
|
280426
|
+
return nothingSelectedError("Hasura instance");
|
280427
|
+
}
|
280428
|
+
const hasuraEnv = getHasuraEnv(hasura);
|
280429
|
+
hasuraGraphqlEndpoint = hasuraEnv.SETTLEMINT_HASURA_ENDPOINT;
|
280430
|
+
hasuraAdminSecret = hasuraEnv.SETTLEMINT_HASURA_ADMIN_SECRET;
|
280208
280431
|
}
|
280209
|
-
const hasuraEnv = getHasuraEnv(hasura);
|
280210
|
-
const hasuraGraphqlEndpoint = hasuraEnv.SETTLEMINT_HASURA_ENDPOINT;
|
280211
|
-
const hasuraAdminSecret = hasuraEnv.SETTLEMINT_HASURA_ADMIN_SECRET;
|
280212
280432
|
if (!hasuraGraphqlEndpoint || !hasuraAdminSecret) {
|
280213
280433
|
return note("Could not retrieve Hasura endpoint or admin secret. Please check your configuration.");
|
280214
280434
|
}
|
280215
|
-
const baseUrl =
|
280216
|
-
const queryEndpoint = new URL(
|
280435
|
+
const baseUrl = extractBaseUrlBeforeSegment(hasuraGraphqlEndpoint, "/v1/graphql");
|
280436
|
+
const queryEndpoint = new URL(`${baseUrl}/v1/metadata`).toString();
|
280217
280437
|
const messages = [];
|
280218
280438
|
const { result } = await spinner({
|
280219
280439
|
startMessage: `Tracking all tables in Hasura from database "${database}"`,
|
@@ -280222,11 +280442,12 @@ function hasuraTrackCommand() {
|
|
280222
280442
|
const executeHasuraQuery = async (query) => {
|
280223
280443
|
const response = await fetch(queryEndpoint, {
|
280224
280444
|
method: "POST",
|
280225
|
-
headers: {
|
280445
|
+
headers: appendHeaders({
|
280226
280446
|
"Content-Type": "application/json",
|
280227
|
-
"X-Hasura-Admin-Secret": hasuraAdminSecret
|
280447
|
+
"X-Hasura-Admin-Secret": hasuraAdminSecret
|
280448
|
+
}, {
|
280228
280449
|
"x-auth-token": accessToken
|
280229
|
-
},
|
280450
|
+
}),
|
280230
280451
|
body: JSON.stringify(query)
|
280231
280452
|
});
|
280232
280453
|
if (!response.ok) {
|
@@ -280345,7 +280566,11 @@ function loginCommand() {
|
|
280345
280566
|
intro("Login to your SettleMint account");
|
280346
280567
|
const autoAccept = !!acceptDefaults || !!tokenStdin;
|
280347
280568
|
const env2 = await loadEnv(false, false);
|
280348
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(
|
280569
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
280570
|
+
env: env2,
|
280571
|
+
accept: autoAccept,
|
280572
|
+
freeTextInput: true
|
280573
|
+
});
|
280349
280574
|
let personalAccessToken = "";
|
280350
280575
|
if (tokenStdin) {
|
280351
280576
|
if (cmd2.args.length > 0) {
|
@@ -280462,11 +280687,17 @@ function pincodeVerificationResponseCommand() {
|
|
280462
280687
|
])).action(async ({ instance, blockchainNode, walletAddress }) => {
|
280463
280688
|
intro("Generating pincode verification response for wallet address");
|
280464
280689
|
const env2 = await loadEnv(false, false);
|
280690
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
280691
|
+
env: env2,
|
280692
|
+
accept: true
|
280693
|
+
});
|
280694
|
+
if (selectedInstance === STANDALONE_INSTANCE2) {
|
280695
|
+
return cancel2("This command does not support standalone instances");
|
280696
|
+
}
|
280465
280697
|
const applicationUniqueName = env2.SETTLEMINT_APPLICATION;
|
280466
280698
|
if (!applicationUniqueName) {
|
280467
280699
|
return missingApplication();
|
280468
280700
|
}
|
280469
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(env2, true);
|
280470
280701
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
280471
280702
|
if (!personalAccessToken) {
|
280472
280703
|
return missingPersonalAccessTokenError();
|
@@ -280685,7 +280916,7 @@ function getCreateCommand({
|
|
280685
280916
|
execute2(cmd2, async ({ acceptDefaults, prod, default: isDefault, wait: wait2, restartIfTimeout, provider, region }, createFunction) => {
|
280686
280917
|
intro(`Creating ${type4} in the SettleMint platform`);
|
280687
280918
|
const env2 = await loadEnv(false, !!prod);
|
280688
|
-
const instance = await instancePrompt(env2, acceptDefaults);
|
280919
|
+
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
280689
280920
|
const accessToken = await getApplicationOrPersonalAccessToken({
|
280690
280921
|
env: env2,
|
280691
280922
|
instance,
|
@@ -282110,7 +282341,7 @@ function getDeleteCommand({
|
|
282110
282341
|
await deleteConfirmationPrompt(`this ${type4}`);
|
282111
282342
|
}
|
282112
282343
|
const env2 = await loadEnv(false, !!prod);
|
282113
|
-
const instance = await instancePrompt(env2, acceptDefaults);
|
282344
|
+
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
282114
282345
|
const accessToken = await getApplicationOrPersonalAccessToken({
|
282115
282346
|
env: env2,
|
282116
282347
|
instance,
|
@@ -282204,7 +282435,7 @@ function getRestartCommand({
|
|
282204
282435
|
])).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 }) => {
|
282205
282436
|
intro(`Restarting ${type4} in the SettleMint platform`);
|
282206
282437
|
const env2 = await loadEnv(false, !!prod);
|
282207
|
-
const instance = await instancePrompt(env2, acceptDefaults);
|
282438
|
+
const instance = await instancePrompt({ env: env2, accept: acceptDefaults });
|
282208
282439
|
const accessToken = await getApplicationOrPersonalAccessToken({
|
282209
282440
|
env: env2,
|
282210
282441
|
instance,
|
@@ -282420,7 +282651,10 @@ function customDeploymentsUpdateCommand() {
|
|
282420
282651
|
if (!customDeploymentUniqueName) {
|
282421
282652
|
cancel2("No custom deployment unique name specified. Please provide it either via the --unique-name flag or by setting the SETTLEMINT_CUSTOM_DEPLOYMENT environment variable");
|
282422
282653
|
}
|
282423
|
-
const instance = await instancePrompt(
|
282654
|
+
const instance = await instancePrompt({
|
282655
|
+
env: env2,
|
282656
|
+
accept: true
|
282657
|
+
});
|
282424
282658
|
const accessToken = await getApplicationOrPersonalAccessToken({
|
282425
282659
|
env: env2,
|
282426
282660
|
instance,
|
@@ -282528,7 +282762,10 @@ function configCommand() {
|
|
282528
282762
|
])).action(async ({ prod, instance, output }) => {
|
282529
282763
|
intro("Getting platform configuration");
|
282530
282764
|
const env2 = await loadEnv(false, !!prod);
|
282531
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(
|
282765
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
282766
|
+
env: env2,
|
282767
|
+
accept: true
|
282768
|
+
});
|
282532
282769
|
const settlemint = createSettleMintClient({
|
282533
282770
|
accessToken: "",
|
282534
282771
|
instance: selectedInstance,
|
@@ -282647,7 +282884,10 @@ function applicationsListCommand() {
|
|
282647
282884
|
])).option("-w, --workspace <workspace>", "The workspace unique name to list applications for (defaults to workspace from env)").addOption(new Option("-o, --output <output>", "The output format").choices(["wide", "json", "yaml"])).action(async ({ workspace, output }) => {
|
282648
282885
|
intro("Listing applications");
|
282649
282886
|
const env2 = await loadEnv(false, false);
|
282650
|
-
const selectedInstance = await instancePrompt(
|
282887
|
+
const selectedInstance = await instancePrompt({
|
282888
|
+
env: env2,
|
282889
|
+
accept: true
|
282890
|
+
});
|
282651
282891
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
282652
282892
|
if (!personalAccessToken) {
|
282653
282893
|
return missingPersonalAccessTokenError();
|
@@ -282765,7 +283005,10 @@ function servicesCommand() {
|
|
282765
283005
|
])).option("--app, --application <application>", "The application unique name to list the services in (defaults to application from env)").addOption(new Option("-t, --type <type...>", "The type(s) of service to list").choices(SERVICE_TYPES)).addOption(new Option("-o, --output <output>", "The output format").choices(["wide", "json", "yaml"])).arguments("[typeOperands...]").action(async (typeOperands, options) => {
|
282766
283006
|
intro("Listing application services");
|
282767
283007
|
const env2 = await loadEnv(false, false);
|
282768
|
-
const selectedInstance = await instancePrompt(
|
283008
|
+
const selectedInstance = await instancePrompt({
|
283009
|
+
env: env2,
|
283010
|
+
accept: true
|
283011
|
+
});
|
282769
283012
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
282770
283013
|
if (!personalAccessToken) {
|
282771
283014
|
return missingPersonalAccessTokenError();
|
@@ -282918,7 +283161,10 @@ function workspacesListCommand() {
|
|
282918
283161
|
intro("Listing workspaces");
|
282919
283162
|
}
|
282920
283163
|
const env2 = await loadEnv(false, false);
|
282921
|
-
const selectedInstance = await instancePrompt(
|
283164
|
+
const selectedInstance = await instancePrompt({
|
283165
|
+
env: env2,
|
283166
|
+
accept: true
|
283167
|
+
});
|
282922
283168
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
282923
283169
|
if (!personalAccessToken) {
|
282924
283170
|
return missingPersonalAccessTokenError();
|
@@ -283029,7 +283275,10 @@ function createCommand4() {
|
|
283029
283275
|
intro("Creating a new smart contract set");
|
283030
283276
|
const env2 = await loadEnv(false, false);
|
283031
283277
|
const name3 = await projectNamePrompt(env2, projectName);
|
283032
|
-
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(
|
283278
|
+
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt({
|
283279
|
+
env: env2,
|
283280
|
+
accept: true
|
283281
|
+
});
|
283033
283282
|
const settlemint = createSettleMintClient({
|
283034
283283
|
instance: selectedInstance,
|
283035
283284
|
accessToken: "",
|
@@ -283443,7 +283692,10 @@ function hardhatDeployRemoteCommand() {
|
|
283443
283692
|
const env2 = await loadEnv(false, !!prod);
|
283444
283693
|
let node;
|
283445
283694
|
let envHardhatConfig = {};
|
283446
|
-
const instance = await instancePrompt(
|
283695
|
+
const instance = await instancePrompt({
|
283696
|
+
env: env2,
|
283697
|
+
accept: true
|
283698
|
+
});
|
283447
283699
|
if (instance === STANDALONE_INSTANCE2) {
|
283448
283700
|
envHardhatConfig.BTP_RPC_URL = env2.SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT ?? "";
|
283449
283701
|
} else {
|
@@ -283456,8 +283708,8 @@ function hardhatDeployRemoteCommand() {
|
|
283456
283708
|
accessToken,
|
283457
283709
|
instance
|
283458
283710
|
});
|
283459
|
-
|
283460
|
-
envHardhatConfig = await settlemint.foundry.env(
|
283711
|
+
node = await selectTargetNode({ env: env2, blockchainNodeUniqueName, autoAccept, settlemint });
|
283712
|
+
envHardhatConfig = await settlemint.foundry.env(node.uniqueName);
|
283461
283713
|
}
|
283462
283714
|
const hardhatConfig = await getHardhatConfigData(envHardhatConfig);
|
283463
283715
|
if (verify && !hardhatConfig?.etherscan?.apiKey) {
|
@@ -283580,20 +283832,28 @@ function hardhatScriptRemoteCommand() {
|
|
283580
283832
|
await validateIfRequiredPackagesAreInstalled(["hardhat"]);
|
283581
283833
|
const autoAccept = !!acceptDefaults || is_in_ci_default;
|
283582
283834
|
const env2 = await loadEnv(false, !!prod);
|
283583
|
-
|
283584
|
-
const
|
283835
|
+
let envHardhatConfig = {};
|
283836
|
+
const instance = await instancePrompt({
|
283585
283837
|
env: env2,
|
283586
|
-
|
283587
|
-
prefer: "application"
|
283838
|
+
accept: true
|
283588
283839
|
});
|
283589
|
-
|
283590
|
-
|
283591
|
-
|
283592
|
-
|
283593
|
-
|
283594
|
-
|
283840
|
+
if (instance === STANDALONE_INSTANCE2) {
|
283841
|
+
envHardhatConfig.BTP_RPC_URL = env2.SETTLEMINT_BLOCKCHAIN_NODE_JSON_RPC_ENDPOINT ?? "";
|
283842
|
+
} else {
|
283843
|
+
const accessToken = await getApplicationOrPersonalAccessToken({
|
283844
|
+
env: env2,
|
283845
|
+
instance,
|
283846
|
+
prefer: "application"
|
283847
|
+
});
|
283848
|
+
const settlemint = createSettleMintClient({
|
283849
|
+
accessToken,
|
283850
|
+
instance
|
283851
|
+
});
|
283852
|
+
const node = await selectTargetNode({ env: env2, blockchainNodeUniqueName, autoAccept, settlemint });
|
283853
|
+
envHardhatConfig = await settlemint.foundry.env(node.uniqueName);
|
283854
|
+
}
|
283595
283855
|
const { command, args } = await getPackageManagerExecutable();
|
283596
|
-
await executeCommand(command, [...args, "hardhat", "run", script, "--network", "btp", ...compile ? ["--no-compile"] : []], { env:
|
283856
|
+
await executeCommand(command, [...args, "hardhat", "run", script, "--network", "btp", ...compile ? ["--no-compile"] : []], { env: envHardhatConfig });
|
283597
283857
|
outro("Script execution completed successfully");
|
283598
283858
|
});
|
283599
283859
|
return cmd2;
|
@@ -283763,8 +284023,11 @@ async function getTheGraphNetwork({
|
|
283763
284023
|
theGraphMiddleware,
|
283764
284024
|
env: env2,
|
283765
284025
|
instance,
|
283766
|
-
accessToken
|
284026
|
+
accessToken = ""
|
283767
284027
|
}) {
|
284028
|
+
if (instance === STANDALONE_INSTANCE2) {
|
284029
|
+
return SETTLEMINT_NETWORK;
|
284030
|
+
}
|
283768
284031
|
const isFixedNetwork = (theGraphMiddleware?.entityVersion ?? 4) >= 4;
|
283769
284032
|
return isFixedNetwork ? SETTLEMINT_NETWORK : sanitizeName(await getNodeName({ env: env2, instance, accessToken }), 30);
|
283770
284033
|
}
|
@@ -283836,30 +284099,37 @@ function subgraphDeployCommand() {
|
|
283836
284099
|
description: "Deploy the subgraph with a specific name",
|
283837
284100
|
command: "scs subgraph deploy my-subgraph"
|
283838
284101
|
}
|
283839
|
-
])).option("-a, --accept-defaults", "Accept the default and previously set values").option("--prod", "Connect to your production environment").argument("[subgraph-name]", "The name of the subgraph to deploy (defaults to value in .env if not provided)").action(async (subgraphName, { prod, acceptDefaults }) => {
|
284102
|
+
])).option("--ipfs <ipfs-url>", "The IPFS URL to use for the subgraph deployment (defaults to https://ipfs.console.settlemint.com)").option("-a, --accept-defaults", "Accept the default and previously set values").option("--prod", "Connect to your production environment").argument("[subgraph-name]", "The name of the subgraph to deploy (defaults to value in .env if not provided)").action(async (subgraphName, { prod, acceptDefaults, ipfs }) => {
|
283840
284103
|
intro("Deploying subgraph");
|
283841
284104
|
await validateIfRequiredPackagesAreInstalled(["@graphprotocol/graph-cli"]);
|
283842
284105
|
const autoAccept = !!acceptDefaults || is_in_ci_default;
|
283843
284106
|
const env2 = await loadEnv(false, !!prod);
|
283844
|
-
const instance = await instancePrompt(
|
283845
|
-
const accessToken = await getApplicationOrPersonalAccessToken({
|
284107
|
+
const instance = await instancePrompt({
|
283846
284108
|
env: env2,
|
283847
|
-
|
283848
|
-
prefer: "application"
|
284109
|
+
accept: true
|
283849
284110
|
});
|
283850
|
-
|
283851
|
-
|
283852
|
-
|
283853
|
-
|
283854
|
-
|
283855
|
-
|
284111
|
+
let theGraphMiddleware;
|
284112
|
+
let accessToken;
|
284113
|
+
if (instance !== STANDALONE_INSTANCE2) {
|
284114
|
+
accessToken = await getApplicationOrPersonalAccessToken({
|
284115
|
+
env: env2,
|
284116
|
+
instance,
|
284117
|
+
prefer: "application"
|
284118
|
+
});
|
284119
|
+
theGraphMiddleware = await getTheGraphMiddleware({ env: env2, instance, accessToken, autoAccept });
|
284120
|
+
if (!theGraphMiddleware) {
|
284121
|
+
return nothingSelectedError("graph middleware");
|
284122
|
+
}
|
284123
|
+
if (theGraphMiddleware.status !== "COMPLETED") {
|
284124
|
+
serviceNotRunningError("graph middleware", theGraphMiddleware.status);
|
284125
|
+
}
|
284126
|
+
await updateSpecVersion(theGraphMiddleware.specVersion);
|
283856
284127
|
}
|
283857
284128
|
const network = await getTheGraphNetwork({ theGraphMiddleware, env: env2, instance, accessToken });
|
283858
284129
|
await subgraphSetup({
|
283859
284130
|
network
|
283860
284131
|
});
|
283861
284132
|
const subgraphYamlFile = await getSubgraphYamlFile();
|
283862
|
-
await updateSpecVersion(theGraphMiddleware.specVersion);
|
283863
284133
|
const { command, args } = await getPackageManagerExecutable();
|
283864
284134
|
await executeCommand(command, [...args, "graph", "codegen", subgraphYamlFile]);
|
283865
284135
|
const generated = await isGenerated();
|
@@ -283888,7 +284158,21 @@ function subgraphDeployCommand() {
|
|
283888
284158
|
if (!graphName) {
|
283889
284159
|
cancel2("No subgraph name provided. Please provide a subgraph name to continue.");
|
283890
284160
|
}
|
283891
|
-
|
284161
|
+
let middlewareAdminUrl;
|
284162
|
+
if (accessToken && theGraphMiddleware) {
|
284163
|
+
middlewareAdminUrl = new URL(`/${encodeURIComponent(accessToken)}/admin`, theGraphMiddleware.serviceUrl).toString();
|
284164
|
+
} else {
|
284165
|
+
const serviceUrl = await serviceUrlPrompt({
|
284166
|
+
defaultUrl: `${getTheGraphUrl(env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS)}/admin`,
|
284167
|
+
accept: autoAccept,
|
284168
|
+
message: "What is the admin endpoint for the The Graph instance you want to connect to?",
|
284169
|
+
example: "https://thegraph.mydomain.com/admin"
|
284170
|
+
});
|
284171
|
+
if (!serviceUrl) {
|
284172
|
+
cancel2("No The Graph admin URL provided. Please provide a The Graph admin URL to continue.");
|
284173
|
+
}
|
284174
|
+
middlewareAdminUrl = serviceUrl.includes("/admin") ? serviceUrl : new URL(`${serviceUrl}/admin`).toString();
|
284175
|
+
}
|
283892
284176
|
await executeCommand(command, [...args, "graph", "create", "--node", middlewareAdminUrl, graphName]);
|
283893
284177
|
await executeCommand(command, [
|
283894
284178
|
...args,
|
@@ -283899,22 +284183,34 @@ function subgraphDeployCommand() {
|
|
283899
284183
|
"--node",
|
283900
284184
|
middlewareAdminUrl,
|
283901
284185
|
"--ipfs",
|
283902
|
-
"https://ipfs.console.settlemint.com",
|
284186
|
+
ipfs ?? "https://ipfs.console.settlemint.com",
|
283903
284187
|
graphName,
|
283904
284188
|
subgraphYamlFile
|
283905
284189
|
]);
|
283906
|
-
|
283907
|
-
|
283908
|
-
|
283909
|
-
|
283910
|
-
|
283911
|
-
|
283912
|
-
|
283913
|
-
|
283914
|
-
|
283915
|
-
|
283916
|
-
|
283917
|
-
|
284190
|
+
if (accessToken && theGraphMiddleware) {
|
284191
|
+
const settlemintClient = createSettleMintClient({
|
284192
|
+
accessToken,
|
284193
|
+
instance
|
284194
|
+
});
|
284195
|
+
const middleware = await settlemintClient.middleware.read(theGraphMiddleware.uniqueName);
|
284196
|
+
const graphEnv = await getGraphEnv(settlemintClient, middleware, graphName);
|
284197
|
+
await writeEnvSpinner(!!prod, {
|
284198
|
+
...env2,
|
284199
|
+
SETTLEMINT_THEGRAPH: theGraphMiddleware.uniqueName,
|
284200
|
+
...graphEnv,
|
284201
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH ?? graphName
|
284202
|
+
});
|
284203
|
+
} else {
|
284204
|
+
await writeEnvSpinner(!!prod, {
|
284205
|
+
...env2,
|
284206
|
+
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: getUpdatedSubgraphEndpoints({
|
284207
|
+
existingEndpoints: env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS ?? [],
|
284208
|
+
middlewareAdminUrl,
|
284209
|
+
newSubgraphName: graphName
|
284210
|
+
}),
|
284211
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH ?? graphName
|
284212
|
+
});
|
284213
|
+
}
|
283918
284214
|
outro(`Subgraph ${graphName} deployed successfully`);
|
283919
284215
|
});
|
283920
284216
|
}
|
@@ -283925,7 +284221,6 @@ async function updateSpecVersion(specVersion) {
|
|
283925
284221
|
}
|
283926
284222
|
|
283927
284223
|
// src/commands/smart-contract-set/subgraph/remove.ts
|
283928
|
-
import { dirname as dirname10 } from "node:path";
|
283929
284224
|
function subgraphRemoveCommand() {
|
283930
284225
|
return new Command("remove").description("Remove a subgraph").usage(createExamples([
|
283931
284226
|
{
|
@@ -283946,46 +284241,76 @@ function subgraphRemoveCommand() {
|
|
283946
284241
|
if (!force) {
|
283947
284242
|
await deleteConfirmationPrompt(`the subgraph ${graphName}`);
|
283948
284243
|
}
|
283949
|
-
const instance = await instancePrompt(
|
283950
|
-
const accessToken = await getApplicationOrPersonalAccessToken({
|
284244
|
+
const instance = await instancePrompt({
|
283951
284245
|
env: env2,
|
283952
|
-
|
283953
|
-
prefer: "application"
|
284246
|
+
accept: true
|
283954
284247
|
});
|
283955
|
-
|
283956
|
-
|
283957
|
-
|
283958
|
-
|
283959
|
-
|
283960
|
-
|
284248
|
+
let theGraphMiddleware;
|
284249
|
+
let accessToken;
|
284250
|
+
if (instance !== STANDALONE_INSTANCE2) {
|
284251
|
+
accessToken = await getApplicationOrPersonalAccessToken({
|
284252
|
+
env: env2,
|
284253
|
+
instance,
|
284254
|
+
prefer: "application"
|
284255
|
+
});
|
284256
|
+
theGraphMiddleware = await getTheGraphMiddleware({ env: env2, instance, accessToken, autoAccept });
|
284257
|
+
if (!theGraphMiddleware) {
|
284258
|
+
return nothingSelectedError("graph middleware");
|
284259
|
+
}
|
284260
|
+
if (theGraphMiddleware.status !== "COMPLETED") {
|
284261
|
+
serviceNotRunningError("graph middleware", theGraphMiddleware.status);
|
284262
|
+
}
|
283961
284263
|
}
|
283962
|
-
const subgraphYamlFile = await getSubgraphYamlFile();
|
283963
|
-
const cwd2 = dirname10(subgraphYamlFile);
|
283964
284264
|
const { command, args } = await getPackageManagerExecutable();
|
283965
|
-
|
284265
|
+
let middlewareAdminUrl;
|
284266
|
+
if (accessToken && theGraphMiddleware) {
|
284267
|
+
middlewareAdminUrl = new URL(`/${encodeURIComponent(accessToken)}/admin`, theGraphMiddleware.serviceUrl).toString();
|
284268
|
+
} else {
|
284269
|
+
const serviceUrl = await serviceUrlPrompt({
|
284270
|
+
defaultUrl: `${getTheGraphUrl(env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS)}/admin`,
|
284271
|
+
accept: autoAccept,
|
284272
|
+
message: "What is the admin endpoint for the The Graph instance you want to connect to?",
|
284273
|
+
example: "https://thegraph.mydomain.com/admin"
|
284274
|
+
});
|
284275
|
+
if (!serviceUrl) {
|
284276
|
+
cancel2("No The Graph admin URL provided. Please provide a The Graph admin URL to continue.");
|
284277
|
+
}
|
284278
|
+
middlewareAdminUrl = serviceUrl.includes("/admin") ? serviceUrl : new URL(`${serviceUrl}/admin`).toString();
|
284279
|
+
}
|
283966
284280
|
await executeCommand(command, [...args, "graph", "remove", "--node", middlewareAdminUrl, graphName]);
|
283967
|
-
|
283968
|
-
|
283969
|
-
|
283970
|
-
|
283971
|
-
|
283972
|
-
|
283973
|
-
|
283974
|
-
|
283975
|
-
|
283976
|
-
|
283977
|
-
|
283978
|
-
|
283979
|
-
|
283980
|
-
|
283981
|
-
|
283982
|
-
|
283983
|
-
|
283984
|
-
|
283985
|
-
|
283986
|
-
|
283987
|
-
|
283988
|
-
|
284281
|
+
if (accessToken && theGraphMiddleware) {
|
284282
|
+
const settlemintClient = createSettleMintClient({
|
284283
|
+
accessToken,
|
284284
|
+
instance
|
284285
|
+
});
|
284286
|
+
const graphEndpoints = await spinner({
|
284287
|
+
startMessage: "Waiting for subgraph to be removed",
|
284288
|
+
task: () => retryWhenFailed2(async () => {
|
284289
|
+
const middleware = await settlemintClient.middleware.read(theGraphMiddleware.uniqueName);
|
284290
|
+
const endpoints = await getGraphEnv(settlemintClient, middleware);
|
284291
|
+
if (endpoints.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS?.some((endpoint) => endpoint.endsWith(graphName))) {
|
284292
|
+
throw new Error(`Subgraph '${graphName}' not removed from middleware '${theGraphMiddleware.uniqueName}'`);
|
284293
|
+
}
|
284294
|
+
return endpoints;
|
284295
|
+
}, 5, 5000),
|
284296
|
+
stopMessage: "Waiting finished"
|
284297
|
+
});
|
284298
|
+
await writeEnvSpinner(!!prod, {
|
284299
|
+
...env2,
|
284300
|
+
SETTLEMINT_THEGRAPH: theGraphMiddleware.uniqueName,
|
284301
|
+
...graphEndpoints,
|
284302
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH === graphName ? undefined : env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH
|
284303
|
+
});
|
284304
|
+
} else {
|
284305
|
+
await writeEnvSpinner(!!prod, {
|
284306
|
+
...env2,
|
284307
|
+
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: getUpdatedSubgraphEndpoints({
|
284308
|
+
existingEndpoints: env2.SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS ?? [],
|
284309
|
+
removedSubgraphName: graphName
|
284310
|
+
}),
|
284311
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH === graphName ? undefined : env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH
|
284312
|
+
});
|
284313
|
+
}
|
283989
284314
|
outro(`Subgraph ${graphName} removed successfully`);
|
283990
284315
|
});
|
283991
284316
|
}
|
@@ -284133,4 +284458,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
284133
284458
|
// src/cli.ts
|
284134
284459
|
sdkCliCommand();
|
284135
284460
|
|
284136
|
-
//# debugId=
|
284461
|
+
//# debugId=575F21B9E3C4FA2A64756E2164756E21
|