@settlemint/sdk-cli 2.3.14-main94feffb3 → 2.3.14-maina78e17fa
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 +164 -19
- package/dist/cli.js.map +6 -5
- package/package.json +7 -5
package/dist/cli.js
CHANGED
@@ -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,
|
@@ -263764,7 +263764,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
263764
263764
|
var package_default = {
|
263765
263765
|
name: "@settlemint/sdk-cli",
|
263766
263766
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
263767
|
-
version: "2.3.14-
|
263767
|
+
version: "2.3.14-maina78e17fa",
|
263768
263768
|
type: "module",
|
263769
263769
|
private: false,
|
263770
263770
|
license: "FSL-1.1-MIT",
|
@@ -263783,7 +263783,9 @@ var package_default = {
|
|
263783
263783
|
url: "https://github.com/settlemint/sdk/issues",
|
263784
263784
|
email: "support@settlemint.com"
|
263785
263785
|
},
|
263786
|
-
files: [
|
263786
|
+
files: [
|
263787
|
+
"dist"
|
263788
|
+
],
|
263787
263789
|
exports: {
|
263788
263790
|
"./*": {
|
263789
263791
|
types: "./dist/*.d.ts",
|
@@ -263813,9 +263815,9 @@ var package_default = {
|
|
263813
263815
|
"@inquirer/input": "4.1.12",
|
263814
263816
|
"@inquirer/password": "4.0.15",
|
263815
263817
|
"@inquirer/select": "4.2.3",
|
263816
|
-
"@settlemint/sdk-js": "2.3.14-
|
263817
|
-
"@settlemint/sdk-utils": "2.3.14-
|
263818
|
-
"@settlemint/sdk-viem": "2.3.14-
|
263818
|
+
"@settlemint/sdk-js": "2.3.14-maina78e17fa",
|
263819
|
+
"@settlemint/sdk-utils": "2.3.14-maina78e17fa",
|
263820
|
+
"@settlemint/sdk-viem": "2.3.14-maina78e17fa",
|
263819
263821
|
"@types/node": "24.0.1",
|
263820
263822
|
"@types/semver": "7.7.0",
|
263821
263823
|
"@types/which": "3.0.4",
|
@@ -295793,6 +295795,17 @@ async function exists3(path$1) {
|
|
295793
295795
|
return false;
|
295794
295796
|
}
|
295795
295797
|
}
|
295798
|
+
function tryParseJson3(value2, defaultValue = null) {
|
295799
|
+
try {
|
295800
|
+
const parsed = JSON.parse(value2);
|
295801
|
+
if (parsed === undefined || parsed === null) {
|
295802
|
+
return defaultValue;
|
295803
|
+
}
|
295804
|
+
return parsed;
|
295805
|
+
} catch (err) {
|
295806
|
+
return defaultValue;
|
295807
|
+
}
|
295808
|
+
}
|
295796
295809
|
var require_balanced_match4 = __commonJS4({ "../../node_modules/balanced-match/index.js"(exports, module) {
|
295797
295810
|
module.exports = balanced$1;
|
295798
295811
|
function balanced$1(a3, b, str) {
|
@@ -301271,9 +301284,45 @@ var glob3 = Object.assign(glob_3, {
|
|
301271
301284
|
unescape: unescape4
|
301272
301285
|
});
|
301273
301286
|
glob3.glob = glob3;
|
301287
|
+
async function findMonoRepoRoot2(startDir) {
|
301288
|
+
const lockFilePath = await findUp([
|
301289
|
+
"package-lock.json",
|
301290
|
+
"yarn.lock",
|
301291
|
+
"pnpm-lock.yaml",
|
301292
|
+
"bun.lockb",
|
301293
|
+
"bun.lock"
|
301294
|
+
], { cwd: startDir });
|
301295
|
+
if (lockFilePath) {
|
301296
|
+
const packageJsonPath = join3(dirname3(lockFilePath), "package.json");
|
301297
|
+
const hasWorkSpaces = await packageJsonHasWorkspaces2(packageJsonPath);
|
301298
|
+
return hasWorkSpaces ? dirname3(lockFilePath) : null;
|
301299
|
+
}
|
301300
|
+
let currentDir = startDir;
|
301301
|
+
while (currentDir !== "/") {
|
301302
|
+
const packageJsonPath = join3(currentDir, "package.json");
|
301303
|
+
if (await packageJsonHasWorkspaces2(packageJsonPath)) {
|
301304
|
+
return currentDir;
|
301305
|
+
}
|
301306
|
+
const parentDir = dirname3(currentDir);
|
301307
|
+
if (parentDir === currentDir) {
|
301308
|
+
break;
|
301309
|
+
}
|
301310
|
+
currentDir = parentDir;
|
301311
|
+
}
|
301312
|
+
return null;
|
301313
|
+
}
|
301314
|
+
async function packageJsonHasWorkspaces2(packageJsonPath) {
|
301315
|
+
if (await exists3(packageJsonPath)) {
|
301316
|
+
const packageJson = tryParseJson3(await readFile3(packageJsonPath, "utf-8"));
|
301317
|
+
if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {
|
301318
|
+
return true;
|
301319
|
+
}
|
301320
|
+
}
|
301321
|
+
return false;
|
301322
|
+
}
|
301274
301323
|
|
301275
301324
|
// ../utils/dist/json.js
|
301276
|
-
function
|
301325
|
+
function tryParseJson4(value2, defaultValue = null) {
|
301277
301326
|
try {
|
301278
301327
|
const parsed = JSON.parse(value2);
|
301279
301328
|
if (parsed === undefined || parsed === null) {
|
@@ -301292,7 +301341,7 @@ function extractJsonObject(value2) {
|
|
301292
301341
|
if (!result) {
|
301293
301342
|
return null;
|
301294
301343
|
}
|
301295
|
-
return
|
301344
|
+
return tryParseJson4(result[0]);
|
301296
301345
|
}
|
301297
301346
|
|
301298
301347
|
// src/utils/config.ts
|
@@ -301307,7 +301356,7 @@ async function readConfig() {
|
|
301307
301356
|
await ensureConfigDir();
|
301308
301357
|
try {
|
301309
301358
|
const content = await readFile4(CONFIG_FILE, "utf-8");
|
301310
|
-
return
|
301359
|
+
return tryParseJson4(content, { instances: {} });
|
301311
301360
|
} catch (error41) {
|
301312
301361
|
return { instances: {} };
|
301313
301362
|
}
|
@@ -329314,9 +329363,9 @@ function hardhatTestCommand() {
|
|
329314
329363
|
});
|
329315
329364
|
}
|
329316
329365
|
|
329317
|
-
// src/
|
329318
|
-
import {
|
329319
|
-
|
329366
|
+
// src/commands/smart-contract-set/subgraph/add.ts
|
329367
|
+
import { copyFile, mkdir as mkdir7, readFile as readFile10, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
|
329368
|
+
import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute2, join as join11, relative as relative4 } from "node:path";
|
329320
329369
|
|
329321
329370
|
// src/utils/subgraph/subgraph-config.ts
|
329322
329371
|
import { readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
|
@@ -329348,7 +329397,7 @@ var updateSubgraphYamlConfig = async (config5, cwd2 = process.cwd()) => {
|
|
329348
329397
|
var getSubgraphConfig = async (path7 = process.cwd()) => {
|
329349
329398
|
try {
|
329350
329399
|
const configContents = await readFile9(join10(path7, CONFIG_FILE_PATH));
|
329351
|
-
const currentConfig =
|
329400
|
+
const currentConfig = tryParseJson4(configContents.toString());
|
329352
329401
|
return currentConfig;
|
329353
329402
|
} catch (err) {
|
329354
329403
|
const error45 = err;
|
@@ -329357,7 +329406,102 @@ var getSubgraphConfig = async (path7 = process.cwd()) => {
|
|
329357
329406
|
}
|
329358
329407
|
};
|
329359
329408
|
|
329409
|
+
// src/commands/smart-contract-set/subgraph/add.ts
|
329410
|
+
var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
329411
|
+
function subgraphAddCommand() {
|
329412
|
+
return new Command("add").description("Add a contract to the subgraph").usage(createExamples([
|
329413
|
+
{
|
329414
|
+
description: "Add a contract to the subgraph",
|
329415
|
+
command: "scs subgraph add --abi=./abis/bond.json --contract-name=bond"
|
329416
|
+
}
|
329417
|
+
])).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 }) => {
|
329418
|
+
intro(`Adding subgraph config for contract ${contractName}`);
|
329419
|
+
const abiPath = isAbsolute2(abi2) ? abi2 : join11(process.cwd(), abi2);
|
329420
|
+
if (!await exists3(abiPath)) {
|
329421
|
+
throw new Error("ABI file not found");
|
329422
|
+
}
|
329423
|
+
await validateIfRequiredPackagesAreInstalled(["@graphprotocol/graph-cli"]);
|
329424
|
+
if (await isGenerated()) {
|
329425
|
+
throw new Error("This command does not support automatically generated subgraph configs");
|
329426
|
+
}
|
329427
|
+
const { command, args } = await getPackageManagerExecutable();
|
329428
|
+
const subgraphYamlFile = await getSubgraphYamlFile();
|
329429
|
+
const abiName = basename5(abiPath);
|
329430
|
+
const subgraphYamlDir = dirname8(subgraphYamlFile);
|
329431
|
+
await mkdir7(join11(subgraphYamlDir, "abis"), { recursive: true });
|
329432
|
+
const localAbiPath = join11(subgraphYamlDir, "abis", abiName);
|
329433
|
+
await copyFile(abiPath, localAbiPath);
|
329434
|
+
try {
|
329435
|
+
const root = await projectRoot3();
|
329436
|
+
await fixPackageJson(root);
|
329437
|
+
const monoRepoRoot = await findMonoRepoRoot2(root);
|
329438
|
+
if (monoRepoRoot) {
|
329439
|
+
await fixPackageJson(monoRepoRoot, false);
|
329440
|
+
}
|
329441
|
+
await executeCommand(command, [
|
329442
|
+
...args,
|
329443
|
+
"graph",
|
329444
|
+
"add",
|
329445
|
+
"--abi",
|
329446
|
+
abi2,
|
329447
|
+
"--contract-name",
|
329448
|
+
contractName,
|
329449
|
+
"--start-block",
|
329450
|
+
startBlock ?? "0",
|
329451
|
+
address ?? DEFAULT_ADDRESS,
|
329452
|
+
subgraphYamlFile
|
329453
|
+
]);
|
329454
|
+
const subgraphYamlConfig = await getSubgraphYamlConfig();
|
329455
|
+
if (subgraphYamlConfig) {
|
329456
|
+
const updatedDataSources = subgraphYamlConfig?.dataSources.map((dataSource) => {
|
329457
|
+
if (dataSource.name === contractName) {
|
329458
|
+
dataSource.network = network ?? "settlemint";
|
329459
|
+
dataSource.mapping.abis = [
|
329460
|
+
{
|
329461
|
+
name: contractName,
|
329462
|
+
file: relative4(subgraphYamlDir, abiPath)
|
329463
|
+
}
|
329464
|
+
];
|
329465
|
+
}
|
329466
|
+
return dataSource;
|
329467
|
+
});
|
329468
|
+
await updateSubgraphYamlConfig({
|
329469
|
+
...subgraphYamlConfig,
|
329470
|
+
dataSources: updatedDataSources
|
329471
|
+
});
|
329472
|
+
}
|
329473
|
+
} finally {
|
329474
|
+
await unlink2(localAbiPath);
|
329475
|
+
}
|
329476
|
+
outro(`Subgraph config for contract ${contractName} added successfully`);
|
329477
|
+
});
|
329478
|
+
}
|
329479
|
+
async function fixPackageJson(packageJsonDir, requiresCodegenScript = true) {
|
329480
|
+
const packageJsonPath = join11(packageJsonDir, "package.json");
|
329481
|
+
if (!await exists3(packageJsonPath)) {
|
329482
|
+
return;
|
329483
|
+
}
|
329484
|
+
let hasPackageJsonChanged = false;
|
329485
|
+
const subgraphPackageJson = await readFile10(packageJsonPath);
|
329486
|
+
const subgraphPackageJsonData = JSON.parse(subgraphPackageJson.toString());
|
329487
|
+
if (subgraphPackageJsonData.packageManager?.includes("bun")) {
|
329488
|
+
note("Removing package manager from package.json (bun is not an official package manager)");
|
329489
|
+
delete subgraphPackageJsonData.packageManager;
|
329490
|
+
hasPackageJsonChanged = true;
|
329491
|
+
}
|
329492
|
+
if (requiresCodegenScript && !subgraphPackageJsonData.scripts?.codegen) {
|
329493
|
+
note("Adding codegen script to package.json");
|
329494
|
+
subgraphPackageJsonData.scripts.codegen = "settlemint scs subgraph codegen";
|
329495
|
+
hasPackageJsonChanged = true;
|
329496
|
+
}
|
329497
|
+
if (hasPackageJsonChanged) {
|
329498
|
+
await writeFile9(packageJsonPath, JSON.stringify(subgraphPackageJsonData, null, 2));
|
329499
|
+
}
|
329500
|
+
}
|
329501
|
+
|
329360
329502
|
// src/utils/subgraph/setup.ts
|
329503
|
+
import { rm as rm4 } from "node:fs/promises";
|
329504
|
+
var import_semver = __toESM(require_semver2(), 1);
|
329361
329505
|
var SETTLEMINT_NETWORK = "settlemint";
|
329362
329506
|
async function subgraphSetup({ network }) {
|
329363
329507
|
const generated = await isGenerated();
|
@@ -329747,6 +329891,7 @@ function smartContractSetCommand() {
|
|
329747
329891
|
hardhat.addCommand(hardhatScriptCommand());
|
329748
329892
|
hardhat.addCommand(hardhatTestCommand());
|
329749
329893
|
const subgraph = new Command("subgraph").alias("sg").enablePositionalOptions().description("Commands for managing TheGraph subgraphs for smart contract indexing");
|
329894
|
+
subgraph.addCommand(subgraphAddCommand());
|
329750
329895
|
subgraph.addCommand(subgraphBuildCommand());
|
329751
329896
|
subgraph.addCommand(subgraphCodegenCommand());
|
329752
329897
|
subgraph.addCommand(subgraphDeployCommand());
|
@@ -329876,4 +330021,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
329876
330021
|
// src/cli.ts
|
329877
330022
|
sdkCliCommand();
|
329878
330023
|
|
329879
|
-
//# debugId=
|
330024
|
+
//# debugId=252464843DFF08D264756E2164756E21
|