@secondlayer/cli 23.3.0 → 23.4.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/dist/cli.js +44 -83
- package/dist/cli.js.map +6 -6
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -29357,6 +29357,12 @@ function inspectSourceGitState(absPath) {
|
|
|
29357
29357
|
}
|
|
29358
29358
|
return { kind: "clean" };
|
|
29359
29359
|
}
|
|
29360
|
+
function uncommittedSourceWarning(state, file) {
|
|
29361
|
+
if (state.kind !== "untracked" && state.kind !== "modified")
|
|
29362
|
+
return;
|
|
29363
|
+
const reason = state.kind === "untracked" ? "not tracked by git" : "modified with uncommitted changes";
|
|
29364
|
+
return `${file} is ${reason}, so this deploy's only copy is the database row. Commit it to keep a copy.`;
|
|
29365
|
+
}
|
|
29360
29366
|
var init_git_status = () => {};
|
|
29361
29367
|
|
|
29362
29368
|
// src/lib/merge-print-subgraph.ts
|
|
@@ -29990,7 +29996,6 @@ import {
|
|
|
29990
29996
|
} from "node:fs";
|
|
29991
29997
|
import { basename, dirname as dirname5, extname, join as join7, relative, resolve as resolve5 } from "node:path";
|
|
29992
29998
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
29993
|
-
import { confirm as confirm2 } from "@inquirer/prompts";
|
|
29994
29999
|
import {
|
|
29995
30000
|
generatePrintPayloadTypes,
|
|
29996
30001
|
generatePrintSchemaSubgraph as generatePrintSchemaSubgraph2,
|
|
@@ -30004,31 +30009,11 @@ import {
|
|
|
30004
30009
|
deriveVerification as deriveVerification2,
|
|
30005
30010
|
isDeterminismViolation
|
|
30006
30011
|
} from "@secondlayer/subgraphs/verification";
|
|
30007
|
-
async function
|
|
30008
|
-
|
|
30009
|
-
|
|
30010
|
-
|
|
30011
|
-
|
|
30012
|
-
const code = err?.code;
|
|
30013
|
-
const missingSdk = (code === "ERR_MODULE_NOT_FOUND" || msg.includes("ERR_MODULE_NOT_FOUND")) && msg.includes("@secondlayer/subgraphs");
|
|
30014
|
-
if (!missingSdk)
|
|
30015
|
-
throw err;
|
|
30016
|
-
warn("Missing dependency: @secondlayer/subgraphs");
|
|
30017
|
-
const install = await confirm2({
|
|
30018
|
-
message: "Install with `bun add @secondlayer/subgraphs`?",
|
|
30019
|
-
default: true
|
|
30020
|
-
});
|
|
30021
|
-
if (!install)
|
|
30022
|
-
throw err;
|
|
30023
|
-
await new Promise((res, rej) => {
|
|
30024
|
-
const child = spawn2("bun", ["add", "@secondlayer/subgraphs"], {
|
|
30025
|
-
stdio: "inherit"
|
|
30026
|
-
});
|
|
30027
|
-
child.on("error", rej);
|
|
30028
|
-
child.on("exit", (c) => c === 0 ? res() : rej(new Error(`bun add exit ${c}`)));
|
|
30029
|
-
});
|
|
30030
|
-
return await import(absPath);
|
|
30031
|
-
}
|
|
30012
|
+
async function loadSubgraphDefinition(source, fileName) {
|
|
30013
|
+
const { bundleSubgraphCode } = await import("@secondlayer/bundler");
|
|
30014
|
+
const bundled = await bundleSubgraphCode(source, { fileName });
|
|
30015
|
+
const url = `data:text/javascript;base64,${Buffer.from(bundled.handlerCode, "utf8").toString("base64")}`;
|
|
30016
|
+
return { mod: await import(url), bundled };
|
|
30032
30017
|
}
|
|
30033
30018
|
async function typecheckHandler(absPath) {
|
|
30034
30019
|
await new Promise((res, rej) => {
|
|
@@ -30542,8 +30527,7 @@ Try --trait sip-010 or \`subgraphs scaffold ${opts.fromContract}\` for ABI calls
|
|
|
30542
30527
|
if (opts.fromContract) {
|
|
30543
30528
|
info(`Schema inferred from ${opts.fromContract} print events (${opts.tablePerTopic ? "table per topic" : "single wide table"})`);
|
|
30544
30529
|
}
|
|
30545
|
-
info(`Next:
|
|
30546
|
-
note(" deploy refuses an unstaged file unless you pass --allow-uncommitted: a staged copy is the one git can recover.");
|
|
30530
|
+
info(`Next: secondlayer subgraphs deploy subgraphs/${name}.ts`);
|
|
30547
30531
|
});
|
|
30548
30532
|
subgraphs.command("add <file>").description("Merge another contract's observed print sources into an existing subgraph file").requiredOption("--from-contract <contractId>", "Contract whose print schema to merge (requires network)").option("--table-per-topic", "One table per print topic instead of a single wide table for the added contract").addHelpText("after", `
|
|
30549
30533
|
Adds sources/schema/handlers for a second (or Nth) contract into an existing
|
|
@@ -30650,10 +30634,10 @@ Stopped watching.`);
|
|
|
30650
30634
|
});
|
|
30651
30635
|
await new Promise(() => {});
|
|
30652
30636
|
});
|
|
30653
|
-
subgraphs.command("deploy <file>").alias("update").description("Deploy a subgraph definition file (alias: update — deploy is create-or-update)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--tip-first", "Go live at chain tip immediately; history backfills in the background (handlers may only insert, upsert and delete; update, increment and row reads are refused)").option("--dry-run", "Validate and preview deploy without writing changes").option("-y, --yes", "Skip the reindex confirmation prompt").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").option("--allow-uncommitted", "
|
|
30654
|
-
|
|
30655
|
-
|
|
30656
|
-
--allow-uncommitted to
|
|
30637
|
+
subgraphs.command("deploy <file>").alias("update").description("Deploy a subgraph definition file (alias: update — deploy is create-or-update)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--tip-first", "Go live at chain tip immediately; history backfills in the background (handlers may only insert, upsert and delete; update, increment and row reads are refused)").option("--dry-run", "Validate and preview deploy without writing changes").option("-y, --yes", "Skip the reindex confirmation prompt").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").option("--allow-uncommitted", "Don't warn when the source file isn't committed in git").addHelpText("after", `
|
|
30638
|
+
If the source file isn't committed in git, deploy warns that the deployed
|
|
30639
|
+
definition's only copy is the row in the database. It never blocks; pass
|
|
30640
|
+
--allow-uncommitted to silence the warning.
|
|
30657
30641
|
|
|
30658
30642
|
Hosted: set SECONDLAYER_API_KEY and SECONDLAYER_API_URL=https://api.secondlayer.tools.
|
|
30659
30643
|
Hostable sources are event filters and contract_call/contract_deploy; anything else
|
|
@@ -30662,28 +30646,10 @@ deploy does not backfill from genesis.`).action(async (file, options) => {
|
|
|
30662
30646
|
try {
|
|
30663
30647
|
const absPath = resolve5(file);
|
|
30664
30648
|
if (!options.dryRun) {
|
|
30665
|
-
if (options.allowUncommitted) {
|
|
30666
|
-
|
|
30667
|
-
|
|
30668
|
-
|
|
30669
|
-
if (gitState.kind === "untracked" || gitState.kind === "modified") {
|
|
30670
|
-
const reason = gitState.kind === "untracked" ? "not tracked by git" : "modified with uncommitted changes";
|
|
30671
|
-
const message = `${file} is ${reason}. Deploy it and the only copy of this definition is a row in the database.`;
|
|
30672
|
-
if (process.stdin.isTTY) {
|
|
30673
|
-
warn(message);
|
|
30674
|
-
const confirmed = await confirm2({
|
|
30675
|
-
message: "Deploy anyway?",
|
|
30676
|
-
default: false
|
|
30677
|
-
});
|
|
30678
|
-
if (!confirmed) {
|
|
30679
|
-
info("Nothing was deployed.");
|
|
30680
|
-
process.exit(0);
|
|
30681
|
-
}
|
|
30682
|
-
} else {
|
|
30683
|
-
error(`${message} Stage it with \`git add ${file}\`, or pass --allow-uncommitted.`);
|
|
30684
|
-
process.exit(1);
|
|
30685
|
-
}
|
|
30686
|
-
}
|
|
30649
|
+
if (!options.allowUncommitted) {
|
|
30650
|
+
const advice = uncommittedSourceWarning(inspectSourceGitState(absPath), file);
|
|
30651
|
+
if (advice)
|
|
30652
|
+
warn(advice);
|
|
30687
30653
|
}
|
|
30688
30654
|
}
|
|
30689
30655
|
const config = await loadConfig2();
|
|
@@ -30697,18 +30663,28 @@ deploy does not backfill from genesis.`).action(async (file, options) => {
|
|
|
30697
30663
|
await typecheckHandler(absPath);
|
|
30698
30664
|
}
|
|
30699
30665
|
info(`Loading subgraph from ${absPath}`);
|
|
30700
|
-
const mod = await loadSubgraphWithDepCheck(absPath);
|
|
30701
|
-
const def = mod.default ?? mod;
|
|
30702
|
-
const effectiveDef = {
|
|
30703
|
-
...startBlock === undefined ? def : { ...def, startBlock },
|
|
30704
|
-
...options.tipFirst ? { backfillMode: "concurrent" } : {}
|
|
30705
|
-
};
|
|
30706
30666
|
const { validateSubgraphDefinition } = await import("@secondlayer/subgraphs/validate");
|
|
30707
30667
|
const { readFile } = await import("node:fs/promises");
|
|
30708
30668
|
const derived = config.network !== "local" ? await withDerivedAbis(await readFile(absPath, "utf8")) : undefined;
|
|
30709
30669
|
for (const name of Object.keys(derived?.abis ?? {})) {
|
|
30710
30670
|
info(`Using the deployed contract's abi for source "${name}"`);
|
|
30711
30671
|
}
|
|
30672
|
+
const source = derived?.source ?? await readFile(absPath, "utf8");
|
|
30673
|
+
const { mod, bundled } = await loadSubgraphDefinition(source, relative(process.cwd(), absPath));
|
|
30674
|
+
const def = mod.default ?? mod;
|
|
30675
|
+
const authored = {
|
|
30676
|
+
...def,
|
|
30677
|
+
sources: Object.fromEntries(Object.entries(def.sources ?? {}).map(([k, v]) => {
|
|
30678
|
+
if (!derived?.abis[k])
|
|
30679
|
+
return [k, v];
|
|
30680
|
+
const { abi: _abi, ...rest } = v;
|
|
30681
|
+
return [k, rest];
|
|
30682
|
+
}))
|
|
30683
|
+
};
|
|
30684
|
+
const effectiveDef = {
|
|
30685
|
+
...startBlock === undefined ? authored : { ...authored, startBlock },
|
|
30686
|
+
...options.tipFirst ? { backfillMode: "concurrent" } : {}
|
|
30687
|
+
};
|
|
30712
30688
|
const validated = validateSubgraphDefinition(derived && Object.keys(derived.abis).length > 0 ? {
|
|
30713
30689
|
...effectiveDef,
|
|
30714
30690
|
sources: Object.fromEntries(Object.entries(effectiveDef.sources).map(([k, v]) => [
|
|
@@ -30721,11 +30697,6 @@ deploy does not backfill from genesis.`).action(async (file, options) => {
|
|
|
30721
30697
|
}
|
|
30722
30698
|
if (config.network !== "local") {
|
|
30723
30699
|
info(`${dryRun ? "Bundling for remote deploy dry run" : "Bundling for remote deploy"} (${config.network})...`);
|
|
30724
|
-
const source = derived?.source ?? await readFile(absPath, "utf8");
|
|
30725
|
-
const { bundleSubgraphCode } = await import("@secondlayer/bundler");
|
|
30726
|
-
const bundled = await bundleSubgraphCode(source, {
|
|
30727
|
-
fileName: relative(process.cwd(), absPath)
|
|
30728
|
-
});
|
|
30729
30700
|
const handlerCode = bundled.handlerCode;
|
|
30730
30701
|
const localVerification = checkDeterminism(effectiveDef, bundled.findings);
|
|
30731
30702
|
if (dryRun) {
|
|
@@ -30840,16 +30811,7 @@ deploy does not backfill from genesis.`).action(async (file, options) => {
|
|
|
30840
30811
|
await printDeployFooter();
|
|
30841
30812
|
}
|
|
30842
30813
|
} else {
|
|
30843
|
-
|
|
30844
|
-
try {
|
|
30845
|
-
const { bundleSubgraphCode } = await import("@secondlayer/bundler");
|
|
30846
|
-
findings = (await bundleSubgraphCode(await readFile(absPath, "utf8"), {
|
|
30847
|
-
fileName: relative(process.cwd(), absPath)
|
|
30848
|
-
})).findings;
|
|
30849
|
-
} catch {
|
|
30850
|
-
findings = undefined;
|
|
30851
|
-
}
|
|
30852
|
-
const verification = findings ? checkDeterminism(effectiveDef, findings) : undefined;
|
|
30814
|
+
const verification = checkDeterminism(effectiveDef, bundled.findings);
|
|
30853
30815
|
if (dryRun) {
|
|
30854
30816
|
printSubgraphDeployPreview(createSubgraphDeployPreview(validated), {
|
|
30855
30817
|
network: config.network,
|
|
@@ -31892,7 +31854,7 @@ var {
|
|
|
31892
31854
|
// package.json
|
|
31893
31855
|
var package_default = {
|
|
31894
31856
|
name: "@secondlayer/cli",
|
|
31895
|
-
version: "23.
|
|
31857
|
+
version: "23.4.0",
|
|
31896
31858
|
description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
|
|
31897
31859
|
repository: {
|
|
31898
31860
|
type: "git",
|
|
@@ -31943,7 +31905,7 @@ var package_default = {
|
|
|
31943
31905
|
"@secondlayer/scaffold": "^1.6.3",
|
|
31944
31906
|
"@secondlayer/sdk": "^16.2.0",
|
|
31945
31907
|
"@secondlayer/shared": "^15.0.1",
|
|
31946
|
-
"@secondlayer/stacks": "^6.
|
|
31908
|
+
"@secondlayer/stacks": "^6.6.0",
|
|
31947
31909
|
"@secondlayer/subgraphs": "^8.0.1",
|
|
31948
31910
|
"@secondlayer/verify": "^0.6.1",
|
|
31949
31911
|
esbuild: "^0.28.2",
|
|
@@ -35867,7 +35829,7 @@ is what makes minting possible without Bitcoin.`).action(async (opts) => {
|
|
|
35867
35829
|
const txid = await client.callContract({
|
|
35868
35830
|
contract,
|
|
35869
35831
|
functionName: "complete-deposit-wrapper",
|
|
35870
|
-
|
|
35832
|
+
args: [
|
|
35871
35833
|
Cl.bufferFromHex(depositTxid),
|
|
35872
35834
|
Cl.uint(0),
|
|
35873
35835
|
Cl.uint(amount),
|
|
@@ -36868,7 +36830,7 @@ init_api_url();
|
|
|
36868
36830
|
init_http();
|
|
36869
36831
|
import { hostname } from "node:os";
|
|
36870
36832
|
import { createInterface } from "node:readline";
|
|
36871
|
-
import { confirm as
|
|
36833
|
+
import { confirm as confirm2, input } from "@inquirer/prompts";
|
|
36872
36834
|
|
|
36873
36835
|
// src/lib/open-browser.ts
|
|
36874
36836
|
import { spawn as spawn3 } from "node:child_process";
|
|
@@ -36951,7 +36913,7 @@ async function shouldContinueLogin(target, options, deps = defaultLoginCheckDeps
|
|
|
36951
36913
|
return false;
|
|
36952
36914
|
}
|
|
36953
36915
|
try {
|
|
36954
|
-
const proceed = await
|
|
36916
|
+
const proceed = await confirm2({
|
|
36955
36917
|
message: "Log in as a different user?",
|
|
36956
36918
|
default: false
|
|
36957
36919
|
});
|
|
@@ -37698,8 +37660,7 @@ program.hook("preAction", (thisCommand) => {
|
|
|
37698
37660
|
program.addHelpText("after", `
|
|
37699
37661
|
Quickstart:
|
|
37700
37662
|
$ secondlayer subgraphs create my-watcher --from-contract SP....my-contract
|
|
37701
|
-
$
|
|
37702
|
-
$ secondlayer subgraphs deploy subgraphs/my-watcher.ts # or --allow-uncommitted
|
|
37663
|
+
$ secondlayer subgraphs deploy subgraphs/my-watcher.ts
|
|
37703
37664
|
|
|
37704
37665
|
Self-host, from docker/oss in a checkout:
|
|
37705
37666
|
$ secondlayer init --network mainnet
|
|
@@ -37737,5 +37698,5 @@ registerCreditsCommand(program);
|
|
|
37737
37698
|
registerArchiveCommand(program);
|
|
37738
37699
|
program.parse();
|
|
37739
37700
|
|
|
37740
|
-
//# debugId=
|
|
37701
|
+
//# debugId=C1922C0758B86D1064756E2164756E21
|
|
37741
37702
|
//# sourceMappingURL=cli.js.map
|