@secondlayer/cli 23.1.0 → 23.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ secondlayer --version
12
12
 
13
13
  ## Auth
14
14
 
15
- Default API is `http://127.0.0.1:3800`. Override with `SECONDLAYER_API_URL`.
15
+ Default API is `http://127.0.0.1:3800`, or the hosted API when only `SECONDLAYER_API_KEY` is set. Override with `SECONDLAYER_API_URL`.
16
16
 
17
17
  Writes against a published bind use `INSTANCE_TOKEN` from `secondlayer init`.
18
18
  Loopback reads need no token. Your hosted account (credits, archive fetches)
@@ -191,7 +191,7 @@ or poll the subgraph API: see
191
191
  |---|---|
192
192
  | `INSTANCE_TOKEN` | From `secondlayer init` for writes. Loopback reads need no token |
193
193
  | `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`) |
194
- | `SECONDLAYER_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
194
+ | `SECONDLAYER_API_URL` | API URL. Default `http://127.0.0.1:3800`, or hosted with only `SECONDLAYER_API_KEY` set |
195
195
  | `STACKS_NETWORK` | Default network (also via `--network <mainnet\|testnet\|devnet>`) |
196
196
  | `DATABASE_URL` | Postgres that `bootstrap`, `verify`, `repair`, and `backup` connect to. Point it at the compose Postgres (`postgres://secondlayer:<POSTGRES_PASSWORD>@127.0.0.1:5432/secondlayer`); unset, the shared dev URL `postgres://postgres:postgres@localhost:5432/secondlayer_dev` is used |
197
197
  | `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
package/dist/cli.js CHANGED
@@ -2129,9 +2129,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2129
2129
  });
2130
2130
 
2131
2131
  // src/lib/api-url.ts
2132
- import { isHostedApiUrl } from "@secondlayer/sdk";
2132
+ import { isHostedApiUrl, resolveBaseUrl } from "@secondlayer/sdk";
2133
2133
  function resolveApiUrl() {
2134
- return (process.env.SECONDLAYER_API_URL ?? LOCAL_API_URL).replace(/\/+$/, "");
2134
+ return resolveBaseUrl();
2135
2135
  }
2136
2136
  function resolveArchiveOpsUrl() {
2137
2137
  return (process.env.SL_CREDITS_API_URL ?? ARCHIVE_OPS_API_URL).replace(/\/+$/, "");
@@ -2142,8 +2142,9 @@ function isMerchantUrl(url = resolveApiUrl()) {
2142
2142
  function assertInstanceUrl(url = resolveApiUrl()) {
2143
2143
  if (!isMerchantUrl(url))
2144
2144
  return;
2145
+ const fix = process.env.SECONDLAYER_API_URL ? "unset SECONDLAYER_API_URL" : "set INSTANCE_TOKEN";
2145
2146
  throw new Error(`this command runs on your instance, not api.secondlayer.tools.
2146
- unset SECONDLAYER_API_URL, or pass --api-url http://127.0.0.1:3800`);
2147
+ ${fix}, or pass --api-url http://127.0.0.1:3800`);
2147
2148
  }
2148
2149
  var LOCAL_API_URL = "http://127.0.0.1:3800", ARCHIVE_OPS_API_URL = "https://api.secondlayer.tools";
2149
2150
  var init_api_url = () => {};
@@ -2539,9 +2540,11 @@ var init_output = __esm(() => {
2539
2540
 
2540
2541
  // src/lib/api-client.ts
2541
2542
  import { ApiError, SecondLayer } from "@secondlayer/sdk";
2542
- function nextStepHint(status, detail) {
2543
+ function nextStepHint(status, detail, code) {
2543
2544
  if (status === undefined)
2544
2545
  return;
2546
+ if (code === "STACK_ASLEEP")
2547
+ return "Any write starts it, such as creating or updating a webhook.";
2545
2548
  if (status === 402)
2546
2549
  return detail === "spend_cap_reached" ? `You reached your monthly spend cap. Raise it: ${CREDITS_URL}` : `Add credits to create webhooks and deploy subgraphs: ${CREDITS_URL}`;
2547
2550
  if (status === 403)
@@ -2581,7 +2584,7 @@ function handleApiError(err, action) {
2581
2584
  }
2582
2585
  const detail = err instanceof Error ? err.message : String(err);
2583
2586
  printError(`Failed to ${action}: ${detail}`, {
2584
- hint: nextStepHint(status, detail)
2587
+ hint: nextStepHint(status, detail, code)
2585
2588
  });
2586
2589
  process.exit(1);
2587
2590
  }
@@ -29542,7 +29545,7 @@ export default defineSubgraph({
29542
29545
  import { createHash as createHash4 } from "node:crypto";
29543
29546
  import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
29544
29547
  import { dirname as dirname4, resolve as resolve3 } from "node:path";
29545
- import { Index, resolveApiKey as resolveApiKey3, resolveBaseUrl } from "@secondlayer/sdk";
29548
+ import { Index, resolveApiKey as resolveApiKey3, resolveBaseUrl as resolveBaseUrl2 } from "@secondlayer/sdk";
29546
29549
  import {
29547
29550
  DECODED_EVENT_TYPES,
29548
29551
  VM_EVENT_TYPES
@@ -29591,7 +29594,7 @@ function eventTypeFor(filter) {
29591
29594
  return null;
29592
29595
  }
29593
29596
  function indexApiUrl() {
29594
- return resolveBaseUrl();
29597
+ return resolveBaseUrl2();
29595
29598
  }
29596
29599
  function indexReadFailure(err, ctx) {
29597
29600
  const e = err;
@@ -29808,7 +29811,7 @@ import { existsSync as existsSync3 } from "node:fs";
29808
29811
  import { resolve as resolve4 } from "node:path";
29809
29812
  import {
29810
29813
  Index as Index2,
29811
- resolveBaseUrl as resolveBaseUrl2
29814
+ resolveBaseUrl as resolveBaseUrl3
29812
29815
  } from "@secondlayer/sdk";
29813
29816
  import {
29814
29817
  DECODED_EVENT_TYPES as DECODED_EVENT_TYPES2
@@ -29903,7 +29906,7 @@ async function runSubgraphPreview(file, options) {
29903
29906
  source: name,
29904
29907
  fromHeight,
29905
29908
  toHeight,
29906
- apiUrl: resolveBaseUrl2(),
29909
+ apiUrl: resolveBaseUrl3(),
29907
29910
  file
29908
29911
  });
29909
29912
  printError(failure.message, { hint: failure.hint });
@@ -29934,7 +29937,7 @@ async function runSubgraphPreview(file, options) {
29934
29937
  source: name,
29935
29938
  fromHeight,
29936
29939
  toHeight,
29937
- apiUrl: resolveBaseUrl2(),
29940
+ apiUrl: resolveBaseUrl3(),
29938
29941
  file
29939
29942
  });
29940
29943
  printError(failure.message, { hint: failure.hint });
@@ -31888,7 +31891,7 @@ var {
31888
31891
  // package.json
31889
31892
  var package_default = {
31890
31893
  name: "@secondlayer/cli",
31891
- version: "23.1.0",
31894
+ version: "23.2.0",
31892
31895
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
31893
31896
  repository: {
31894
31897
  type: "git",
@@ -31937,7 +31940,7 @@ var package_default = {
31937
31940
  "@inquirer/prompts": "^8.2.0",
31938
31941
  "@secondlayer/bundler": "^0.7.3",
31939
31942
  "@secondlayer/scaffold": "^1.6.3",
31940
- "@secondlayer/sdk": "^16.0.0",
31943
+ "@secondlayer/sdk": "^16.2.0",
31941
31944
  "@secondlayer/shared": "^15.0.0",
31942
31945
  "@secondlayer/stacks": "^6.5.3",
31943
31946
  "@secondlayer/subgraphs": "^8.0.1",
@@ -35960,7 +35963,7 @@ function dockerCompose(composePath, args) {
35960
35963
  });
35961
35964
  return res.status ?? 1;
35962
35965
  }
35963
- var API_URL = resolveApiUrl();
35966
+ var API_URL = (process.env.SECONDLAYER_API_URL || LOCAL_API_URL).replace(/\/+$/, "");
35964
35967
  var INDEXER_URL = process.env.INDEXER_URL ?? "http://localhost:3700";
35965
35968
  var SERVICES = [
35966
35969
  "indexer",
@@ -37777,5 +37780,5 @@ registerCreditsCommand(program);
37777
37780
  registerArchiveCommand(program);
37778
37781
  program.parse();
37779
37782
 
37780
- //# debugId=0DC9F45DD895F4A264756E2164756E21
37783
+ //# debugId=E3E81976D75D13F864756E2164756E21
37781
37784
  //# sourceMappingURL=cli.js.map