@secondlayer/cli 9.3.1 → 9.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 +51 -38
- package/dist/cli.js.map +6 -6
- package/package.json +6 -16
package/dist/cli.js
CHANGED
|
@@ -29095,27 +29095,41 @@ export default defineSubgraph({
|
|
|
29095
29095
|
}
|
|
29096
29096
|
function poxStacking(name) {
|
|
29097
29097
|
return `import { defineSubgraph } from "@secondlayer/subgraphs";
|
|
29098
|
+
import { POX5_ABI } from "@secondlayer/stacks/pox5";
|
|
29098
29099
|
|
|
29099
29100
|
/**
|
|
29100
|
-
* Track
|
|
29101
|
-
* extension, increase, aggregation, signer-key authorizations.
|
|
29101
|
+
* Track PoX-5 \`stake\` calls with their arguments already decoded.
|
|
29102
29102
|
*
|
|
29103
|
-
*
|
|
29104
|
-
*
|
|
29103
|
+
* pox-5 replaced pox-4 when Epoch 4.0 activated (Bitcoin block 960,230,
|
|
29104
|
+
* 2026-07-30). SIP-045 reshaped the API: stacking became bonds + staking, so
|
|
29105
|
+
* the entry point is \`stake\`, not \`stack-stx\`.
|
|
29106
|
+
*
|
|
29107
|
+
* The source pairs \`abi\` with \`functionName\`, which is what makes
|
|
29108
|
+
* \`event.input\` a typed, named argument set instead of positional
|
|
29109
|
+
* \`args[0] as bigint\`. Add one source per function you want to track.
|
|
29105
29110
|
*
|
|
29106
29111
|
* Query examples once deployed:
|
|
29107
|
-
* GET /v1/subgraphs/${name}/calls?
|
|
29112
|
+
* GET /v1/subgraphs/${name}/calls?caller=SP1...
|
|
29108
29113
|
* GET /v1/subgraphs/${name}/calls?caller=SP1...
|
|
29109
29114
|
*/
|
|
29110
29115
|
export default defineSubgraph({
|
|
29111
29116
|
name: "${name}",
|
|
29112
29117
|
version: "1.0.0",
|
|
29113
|
-
description: "PoX-
|
|
29118
|
+
description: "PoX-5 stake calls with decoded arguments",
|
|
29114
29119
|
|
|
29115
29120
|
sources: {
|
|
29116
29121
|
pox: {
|
|
29117
29122
|
type: "contract_call",
|
|
29118
|
-
|
|
29123
|
+
// pox-5 is the live PoX contract since Epoch 4.0 activated at Bitcoin
|
|
29124
|
+
// block 960,230 (2026-07-30). Stacking history before that is pox-4 —
|
|
29125
|
+
// point a second source at \`.pox-4\` if you need it.
|
|
29126
|
+
contractId: "SP000000000000000000002Q6VF78.pox-5",
|
|
29127
|
+
// \`abi\` + \`functionName\` together are what type \`event.input\`: the
|
|
29128
|
+
// arguments cannot be typed without knowing which function was called.
|
|
29129
|
+
// POX5_ABI ships \`as const\` in @secondlayer/stacks, so there is no
|
|
29130
|
+
// hand-copied ABI to drift. Add a source per function you care about.
|
|
29131
|
+
functionName: "stake",
|
|
29132
|
+
abi: POX5_ABI,
|
|
29119
29133
|
},
|
|
29120
29134
|
},
|
|
29121
29135
|
|
|
@@ -29124,6 +29138,8 @@ export default defineSubgraph({
|
|
|
29124
29138
|
columns: {
|
|
29125
29139
|
function_name: { type: "text", indexed: true, search: true },
|
|
29126
29140
|
caller: { type: "principal", indexed: true, search: true },
|
|
29141
|
+
amount_ustx: { type: "uint" },
|
|
29142
|
+
num_cycles: { type: "uint" },
|
|
29127
29143
|
result_ok: { type: "boolean" },
|
|
29128
29144
|
},
|
|
29129
29145
|
},
|
|
@@ -29131,12 +29147,14 @@ export default defineSubgraph({
|
|
|
29131
29147
|
|
|
29132
29148
|
handlers: {
|
|
29133
29149
|
pox: (event, ctx) => {
|
|
29134
|
-
//
|
|
29135
|
-
//
|
|
29150
|
+
// \`event.input\` is the decoded, named, typed argument set — no
|
|
29151
|
+
// \`args[0] as bigint\`. Hover \`amountUstx\` and it is a bigint.
|
|
29136
29152
|
const resultHex = event.resultHex ?? "";
|
|
29137
29153
|
ctx.insert("calls", {
|
|
29138
29154
|
function_name: event.functionName || ctx.tx.functionName || "",
|
|
29139
29155
|
caller: ctx.tx.sender,
|
|
29156
|
+
amount_ustx: event.input.amountUstx,
|
|
29157
|
+
num_cycles: event.input.numCycles,
|
|
29140
29158
|
result_ok: resultHex.startsWith("0x07"), // 0x07 = response-ok type tag
|
|
29141
29159
|
});
|
|
29142
29160
|
},
|
|
@@ -29249,21 +29267,27 @@ function deriveBaseUrl(apiUrl) {
|
|
|
29249
29267
|
// src/commands/subgraph-test.ts
|
|
29250
29268
|
var exports_subgraph_test = {};
|
|
29251
29269
|
__export(exports_subgraph_test, {
|
|
29252
|
-
runSubgraphTest: () => runSubgraphTest
|
|
29270
|
+
runSubgraphTest: () => runSubgraphTest,
|
|
29271
|
+
loadCassette: () => loadCassette,
|
|
29272
|
+
filterHashOf: () => filterHashOf,
|
|
29273
|
+
DECODER_VERSION: () => DECODER_VERSION
|
|
29253
29274
|
});
|
|
29254
29275
|
import { createHash } from "node:crypto";
|
|
29255
29276
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
29256
29277
|
import { dirname as dirname3, resolve as resolve2 } from "node:path";
|
|
29257
29278
|
import { Index } from "@secondlayer/sdk";
|
|
29279
|
+
import {
|
|
29280
|
+
DECODED_EVENT_TYPES
|
|
29281
|
+
} from "@secondlayer/stacks/filters";
|
|
29258
29282
|
function filterHashOf(sources) {
|
|
29259
29283
|
const stable = JSON.stringify(Object.fromEntries(Object.entries(sources).sort(([a4], [b2]) => a4.localeCompare(b2))), (_k, v2) => typeof v2 === "bigint" ? `${v2}n` : v2);
|
|
29260
29284
|
return createHash("sha256").update(stable).digest("hex").slice(0, 16);
|
|
29261
29285
|
}
|
|
29262
|
-
function cassettePath(name) {
|
|
29263
|
-
return resolve2(
|
|
29286
|
+
function cassettePath(name, dir = CASSETTE_DIR) {
|
|
29287
|
+
return resolve2(dir, `${name}.json`);
|
|
29264
29288
|
}
|
|
29265
|
-
function loadCassette(name, filterHash) {
|
|
29266
|
-
const path11 = cassettePath(name);
|
|
29289
|
+
function loadCassette(name, filterHash, dir = CASSETTE_DIR) {
|
|
29290
|
+
const path11 = cassettePath(name, dir);
|
|
29267
29291
|
if (!existsSync2(path11))
|
|
29268
29292
|
return null;
|
|
29269
29293
|
let parsed;
|
|
@@ -29281,12 +29305,11 @@ function loadCassette(name, filterHash) {
|
|
|
29281
29305
|
return parsed;
|
|
29282
29306
|
}
|
|
29283
29307
|
function eventTypeFor(filter) {
|
|
29284
|
-
if (filter.type === "print_event")
|
|
29285
|
-
return "print";
|
|
29286
29308
|
if (filter.type === "contract_call" || filter.type === "contract_deploy") {
|
|
29287
29309
|
return null;
|
|
29288
29310
|
}
|
|
29289
|
-
|
|
29311
|
+
const candidate = filter.type === "print_event" ? "print" : filter.type;
|
|
29312
|
+
return DECODED_EVENT_TYPES.includes(candidate) ? candidate : null;
|
|
29290
29313
|
}
|
|
29291
29314
|
async function runSubgraphTest(file, options3) {
|
|
29292
29315
|
const absPath = resolve2(file);
|
|
@@ -30871,10 +30894,10 @@ function registerIndexCommand(program2) {
|
|
|
30871
30894
|
fail("list nft transfers", err);
|
|
30872
30895
|
}
|
|
30873
30896
|
});
|
|
30874
|
-
rangeFlags(index.command("events")).description("List decoded events by type (stx_*, ft/nft mint/burn, print, …)").
|
|
30897
|
+
rangeFlags(index.command("events")).description("List decoded events by type (stx_*, ft/nft mint/burn, print, …)").option("--event-type <type>", "Decoded event type").option("--types <type>", "alias for --event-type, ONE value (the Streams spelling)").option("--sender <principal>", "Filter by sender").option("--recipient <principal>", "Filter by recipient").option("--asset-identifier <id>", "Filter by asset identifier").action(async (o3) => {
|
|
30875
30898
|
try {
|
|
30876
30899
|
emit(await client().events.list({
|
|
30877
|
-
eventType: o3.eventType,
|
|
30900
|
+
eventType: o3.eventType ?? o3.types,
|
|
30878
30901
|
...rangeParams(o3),
|
|
30879
30902
|
sender: o3.sender,
|
|
30880
30903
|
recipient: o3.recipient,
|
|
@@ -34739,7 +34762,7 @@ var {
|
|
|
34739
34762
|
// package.json
|
|
34740
34763
|
var package_default = {
|
|
34741
34764
|
name: "@secondlayer/cli",
|
|
34742
|
-
version: "9.
|
|
34765
|
+
version: "9.4.0",
|
|
34743
34766
|
repository: {
|
|
34744
34767
|
type: "git",
|
|
34745
34768
|
url: "git+https://github.com/ryanwaits/secondlayer.git",
|
|
@@ -34764,11 +34787,7 @@ var package_default = {
|
|
|
34764
34787
|
import: "./dist/plugins/index.js"
|
|
34765
34788
|
}
|
|
34766
34789
|
},
|
|
34767
|
-
files: [
|
|
34768
|
-
"dist",
|
|
34769
|
-
"templates",
|
|
34770
|
-
"README.md"
|
|
34771
|
-
],
|
|
34790
|
+
files: ["dist", "templates", "README.md"],
|
|
34772
34791
|
scripts: {
|
|
34773
34792
|
build: "bunup",
|
|
34774
34793
|
dev: "bunup --watch",
|
|
@@ -34776,22 +34795,16 @@ var package_default = {
|
|
|
34776
34795
|
typecheck: "tsc --noEmit",
|
|
34777
34796
|
prepublishOnly: "bun run build"
|
|
34778
34797
|
},
|
|
34779
|
-
keywords: [
|
|
34780
|
-
"stacks",
|
|
34781
|
-
"clarity",
|
|
34782
|
-
"blockchain",
|
|
34783
|
-
"smart-contracts",
|
|
34784
|
-
"cli"
|
|
34785
|
-
],
|
|
34798
|
+
keywords: ["stacks", "clarity", "blockchain", "smart-contracts", "cli"],
|
|
34786
34799
|
author: "",
|
|
34787
34800
|
license: "MIT",
|
|
34788
34801
|
dependencies: {
|
|
34789
34802
|
"@inquirer/prompts": "^8.2.0",
|
|
34790
34803
|
"@secondlayer/bundler": "^0.4.0",
|
|
34791
34804
|
"@secondlayer/scaffold": "^1.5.1",
|
|
34792
|
-
"@secondlayer/sdk": "^6.
|
|
34793
|
-
"@secondlayer/shared": "^7.
|
|
34794
|
-
"@secondlayer/stacks": "^3.
|
|
34805
|
+
"@secondlayer/sdk": "^6.47.0",
|
|
34806
|
+
"@secondlayer/shared": "^7.4.0",
|
|
34807
|
+
"@secondlayer/stacks": "^3.2.0",
|
|
34795
34808
|
"@secondlayer/subgraphs": "^3.23.1",
|
|
34796
34809
|
"@biomejs/js-api": "^0.7.0",
|
|
34797
34810
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
@@ -36970,7 +36983,7 @@ function registerStreamsCommand(program2) {
|
|
|
36970
36983
|
process.exit(1);
|
|
36971
36984
|
}
|
|
36972
36985
|
});
|
|
36973
|
-
const events = streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").addHelpText("after", `
|
|
36986
|
+
const events = streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--event-type <type>", "alias for a single-value --types (the Index spelling)").option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").addHelpText("after", `
|
|
36974
36987
|
Examples:
|
|
36975
36988
|
$ sl streams events --types stx_transfer,print --limit 50
|
|
36976
36989
|
$ sl streams events --not-types print --contract-id SP00....token,SP01....token
|
|
@@ -36978,7 +36991,7 @@ Examples:
|
|
|
36978
36991
|
$ sl streams events --cursor 150000:3`).action(async (options3) => {
|
|
36979
36992
|
try {
|
|
36980
36993
|
const envelope = await client2().events.list({
|
|
36981
|
-
types: parseTypes(options3.types),
|
|
36994
|
+
types: parseTypes(options3.types ?? options3.eventType),
|
|
36982
36995
|
notTypes: parseTypes(options3.notTypes, "--not-types"),
|
|
36983
36996
|
contractId: parseList(options3.contractId),
|
|
36984
36997
|
sender: parseList(options3.sender),
|
|
@@ -38619,5 +38632,5 @@ registerAccountCommand(program);
|
|
|
38619
38632
|
registerKeysCommand(program);
|
|
38620
38633
|
program.parse();
|
|
38621
38634
|
|
|
38622
|
-
//# debugId=
|
|
38635
|
+
//# debugId=7399D6CA5840E86964756E2164756E21
|
|
38623
38636
|
//# sourceMappingURL=cli.js.map
|