@settlemint/sdk-cli 2.3.14-pr84e01ac3 → 2.3.14-pr9ea16ef8

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 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: () => tryParseJson4,
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 tryParseJson4(text) {
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) || tryParseJson4(host.readFile(packageJsonPath));
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) || tryParseJson4(host.readFile(packageJsonPath));
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 = tryParseJson4(stringContent);
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: () => tryParseJson4,
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.0";
231626
+ var version5 = "2.31.1";
231627
231627
 
231628
231628
  // ../../node_modules/viem/_esm/errors/base.js
231629
231629
  function walk(err, fn) {
@@ -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-pr84e01ac3",
263767
+ version: "2.3.14-pr9ea16ef8",
263768
263768
  type: "module",
263769
263769
  private: false,
263770
263770
  license: "FSL-1.1-MIT",
@@ -263813,9 +263813,10 @@ var package_default = {
263813
263813
  "@inquirer/input": "4.1.12",
263814
263814
  "@inquirer/password": "4.0.15",
263815
263815
  "@inquirer/select": "4.2.3",
263816
- "@settlemint/sdk-js": "2.3.14-pr84e01ac3",
263817
- "@settlemint/sdk-utils": "2.3.14-pr84e01ac3",
263818
- "@types/node": "24.0.0",
263816
+ "@settlemint/sdk-js": "2.3.14-pr9ea16ef8",
263817
+ "@settlemint/sdk-utils": "2.3.14-pr9ea16ef8",
263818
+ "@settlemint/sdk-viem": "2.3.14-pr9ea16ef8",
263819
+ "@types/node": "24.0.1",
263819
263820
  "@types/semver": "7.7.0",
263820
263821
  "@types/which": "3.0.4",
263821
263822
  "get-tsconfig": "4.10.1",
@@ -263823,13 +263824,13 @@ var package_default = {
263823
263824
  "is-in-ci": "1.0.0",
263824
263825
  semver: "7.7.2",
263825
263826
  slugify: "1.6.6",
263826
- viem: "2.31.0",
263827
+ viem: "2.31.1",
263827
263828
  which: "5.0.0",
263828
263829
  yaml: "2.8.0",
263829
263830
  yoctocolors: "2.1.1"
263830
263831
  },
263831
263832
  peerDependencies: {
263832
- hardhat: "2.24.2"
263833
+ hardhat: "2.24.3"
263833
263834
  },
263834
263835
  peerDependenciesMeta: {
263835
263836
  hardhat: {
@@ -295792,6 +295793,17 @@ async function exists3(path$1) {
295792
295793
  return false;
295793
295794
  }
295794
295795
  }
295796
+ function tryParseJson3(value2, defaultValue = null) {
295797
+ try {
295798
+ const parsed = JSON.parse(value2);
295799
+ if (parsed === undefined || parsed === null) {
295800
+ return defaultValue;
295801
+ }
295802
+ return parsed;
295803
+ } catch (err) {
295804
+ return defaultValue;
295805
+ }
295806
+ }
295795
295807
  var require_balanced_match4 = __commonJS4({ "../../node_modules/balanced-match/index.js"(exports, module) {
295796
295808
  module.exports = balanced$1;
295797
295809
  function balanced$1(a3, b, str) {
@@ -301270,9 +301282,45 @@ var glob3 = Object.assign(glob_3, {
301270
301282
  unescape: unescape4
301271
301283
  });
301272
301284
  glob3.glob = glob3;
301285
+ async function findMonoRepoRoot2(startDir) {
301286
+ const lockFilePath = await findUp([
301287
+ "package-lock.json",
301288
+ "yarn.lock",
301289
+ "pnpm-lock.yaml",
301290
+ "bun.lockb",
301291
+ "bun.lock"
301292
+ ], { cwd: startDir });
301293
+ if (lockFilePath) {
301294
+ const packageJsonPath = join3(dirname3(lockFilePath), "package.json");
301295
+ const hasWorkSpaces = await packageJsonHasWorkspaces2(packageJsonPath);
301296
+ return hasWorkSpaces ? dirname3(lockFilePath) : null;
301297
+ }
301298
+ let currentDir = startDir;
301299
+ while (currentDir !== "/") {
301300
+ const packageJsonPath = join3(currentDir, "package.json");
301301
+ if (await packageJsonHasWorkspaces2(packageJsonPath)) {
301302
+ return currentDir;
301303
+ }
301304
+ const parentDir = dirname3(currentDir);
301305
+ if (parentDir === currentDir) {
301306
+ break;
301307
+ }
301308
+ currentDir = parentDir;
301309
+ }
301310
+ return null;
301311
+ }
301312
+ async function packageJsonHasWorkspaces2(packageJsonPath) {
301313
+ if (await exists3(packageJsonPath)) {
301314
+ const packageJson = tryParseJson3(await readFile3(packageJsonPath, "utf-8"));
301315
+ if (packageJson?.workspaces && Array.isArray(packageJson?.workspaces) && packageJson?.workspaces.length > 0) {
301316
+ return true;
301317
+ }
301318
+ }
301319
+ return false;
301320
+ }
301273
301321
 
301274
301322
  // ../utils/dist/json.js
301275
- function tryParseJson3(value2, defaultValue = null) {
301323
+ function tryParseJson4(value2, defaultValue = null) {
301276
301324
  try {
301277
301325
  const parsed = JSON.parse(value2);
301278
301326
  if (parsed === undefined || parsed === null) {
@@ -301291,7 +301339,7 @@ function extractJsonObject(value2) {
301291
301339
  if (!result) {
301292
301340
  return null;
301293
301341
  }
301294
- return tryParseJson3(result[0]);
301342
+ return tryParseJson4(result[0]);
301295
301343
  }
301296
301344
 
301297
301345
  // src/utils/config.ts
@@ -301306,7 +301354,7 @@ async function readConfig() {
301306
301354
  await ensureConfigDir();
301307
301355
  try {
301308
301356
  const content = await readFile4(CONFIG_FILE, "utf-8");
301309
- return tryParseJson3(content, { instances: {} });
301357
+ return tryParseJson4(content, { instances: {} });
301310
301358
  } catch (error41) {
301311
301359
  return { instances: {} };
301312
301360
  }
@@ -329313,9 +329361,9 @@ function hardhatTestCommand() {
329313
329361
  });
329314
329362
  }
329315
329363
 
329316
- // src/utils/subgraph/setup.ts
329317
- import { rm as rm4 } from "node:fs/promises";
329318
- var import_semver = __toESM(require_semver2(), 1);
329364
+ // src/commands/smart-contract-set/subgraph/add.ts
329365
+ import { copyFile, mkdir as mkdir7, readFile as readFile10, unlink as unlink2, writeFile as writeFile9 } from "node:fs/promises";
329366
+ import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute2, join as join11, relative as relative4 } from "node:path";
329319
329367
 
329320
329368
  // src/utils/subgraph/subgraph-config.ts
329321
329369
  import { readFile as readFile9, writeFile as writeFile8 } from "node:fs/promises";
@@ -329347,7 +329395,7 @@ var updateSubgraphYamlConfig = async (config5, cwd2 = process.cwd()) => {
329347
329395
  var getSubgraphConfig = async (path7 = process.cwd()) => {
329348
329396
  try {
329349
329397
  const configContents = await readFile9(join10(path7, CONFIG_FILE_PATH));
329350
- const currentConfig = tryParseJson3(configContents.toString());
329398
+ const currentConfig = tryParseJson4(configContents.toString());
329351
329399
  return currentConfig;
329352
329400
  } catch (err) {
329353
329401
  const error45 = err;
@@ -329356,7 +329404,102 @@ var getSubgraphConfig = async (path7 = process.cwd()) => {
329356
329404
  }
329357
329405
  };
329358
329406
 
329407
+ // src/commands/smart-contract-set/subgraph/add.ts
329408
+ var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
329409
+ function subgraphAddCommand() {
329410
+ return new Command("add").description("Add a contract to the subgraph").usage(createExamples([
329411
+ {
329412
+ description: "Add a contract to the subgraph",
329413
+ command: "scs subgraph add --abi=./abis/bond.json --contract-name=bond"
329414
+ }
329415
+ ])).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 }) => {
329416
+ intro(`Adding subgraph config for contract ${contractName}`);
329417
+ const abiPath = isAbsolute2(abi2) ? abi2 : join11(process.cwd(), abi2);
329418
+ if (!await exists3(abiPath)) {
329419
+ throw new Error("ABI file not found");
329420
+ }
329421
+ await validateIfRequiredPackagesAreInstalled(["@graphprotocol/graph-cli"]);
329422
+ if (await isGenerated()) {
329423
+ throw new Error("This command does not support automatically generated subgraph configs");
329424
+ }
329425
+ const { command, args } = await getPackageManagerExecutable();
329426
+ const subgraphYamlFile = await getSubgraphYamlFile();
329427
+ const abiName = basename5(abiPath);
329428
+ const subgraphYamlDir = dirname8(subgraphYamlFile);
329429
+ await mkdir7(join11(subgraphYamlDir, "abis"), { recursive: true });
329430
+ const localAbiPath = join11(subgraphYamlDir, "abis", abiName);
329431
+ await copyFile(abiPath, localAbiPath);
329432
+ try {
329433
+ const root = await projectRoot3();
329434
+ await fixPackageJson(root);
329435
+ const monoRepoRoot = await findMonoRepoRoot2(root);
329436
+ if (monoRepoRoot) {
329437
+ await fixPackageJson(monoRepoRoot, false);
329438
+ }
329439
+ await executeCommand(command, [
329440
+ ...args,
329441
+ "graph",
329442
+ "add",
329443
+ "--abi",
329444
+ abi2,
329445
+ "--contract-name",
329446
+ contractName,
329447
+ "--start-block",
329448
+ startBlock ?? "0",
329449
+ address ?? DEFAULT_ADDRESS,
329450
+ subgraphYamlFile
329451
+ ]);
329452
+ const subgraphYamlConfig = await getSubgraphYamlConfig();
329453
+ if (subgraphYamlConfig) {
329454
+ const updatedDataSources = subgraphYamlConfig?.dataSources.map((dataSource) => {
329455
+ if (dataSource.name === contractName) {
329456
+ dataSource.network = network ?? "settlemint";
329457
+ dataSource.mapping.abis = [
329458
+ {
329459
+ name: contractName,
329460
+ file: relative4(subgraphYamlDir, abiPath)
329461
+ }
329462
+ ];
329463
+ }
329464
+ return dataSource;
329465
+ });
329466
+ await updateSubgraphYamlConfig({
329467
+ ...subgraphYamlConfig,
329468
+ dataSources: updatedDataSources
329469
+ });
329470
+ }
329471
+ } finally {
329472
+ await unlink2(localAbiPath);
329473
+ }
329474
+ outro(`Subgraph config for contract ${contractName} added successfully`);
329475
+ });
329476
+ }
329477
+ async function fixPackageJson(packageJsonDir, requiresCodegenScript = true) {
329478
+ const packageJsonPath = join11(packageJsonDir, "package.json");
329479
+ if (!await exists3(packageJsonPath)) {
329480
+ return;
329481
+ }
329482
+ let hasPackageJsonChanged = false;
329483
+ const subgraphPackageJson = await readFile10(packageJsonPath);
329484
+ const subgraphPackageJsonData = JSON.parse(subgraphPackageJson.toString());
329485
+ if (subgraphPackageJsonData.packageManager?.includes("bun")) {
329486
+ note("Removing package manager from package.json (bun is not an official package manager)");
329487
+ delete subgraphPackageJsonData.packageManager;
329488
+ hasPackageJsonChanged = true;
329489
+ }
329490
+ if (requiresCodegenScript && !subgraphPackageJsonData.scripts?.codegen) {
329491
+ note("Adding codegen script to package.json");
329492
+ subgraphPackageJsonData.scripts.codegen = "settlemint scs subgraph codegen";
329493
+ hasPackageJsonChanged = true;
329494
+ }
329495
+ if (hasPackageJsonChanged) {
329496
+ await writeFile9(packageJsonPath, JSON.stringify(subgraphPackageJsonData, null, 2));
329497
+ }
329498
+ }
329499
+
329359
329500
  // src/utils/subgraph/setup.ts
329501
+ import { rm as rm4 } from "node:fs/promises";
329502
+ var import_semver = __toESM(require_semver2(), 1);
329360
329503
  var SETTLEMINT_NETWORK = "settlemint";
329361
329504
  async function subgraphSetup({ network }) {
329362
329505
  const generated = await isGenerated();
@@ -329746,6 +329889,7 @@ function smartContractSetCommand() {
329746
329889
  hardhat.addCommand(hardhatScriptCommand());
329747
329890
  hardhat.addCommand(hardhatTestCommand());
329748
329891
  const subgraph = new Command("subgraph").alias("sg").enablePositionalOptions().description("Commands for managing TheGraph subgraphs for smart contract indexing");
329892
+ subgraph.addCommand(subgraphAddCommand());
329749
329893
  subgraph.addCommand(subgraphBuildCommand());
329750
329894
  subgraph.addCommand(subgraphCodegenCommand());
329751
329895
  subgraph.addCommand(subgraphDeployCommand());
@@ -329875,4 +330019,4 @@ async function sdkCliCommand(argv = process.argv) {
329875
330019
  // src/cli.ts
329876
330020
  sdkCliCommand();
329877
330021
 
329878
- //# debugId=130851916A87CB0E64756E2164756E21
330022
+ //# debugId=F9C985A5F49A150064756E2164756E21