@spectratools/assembly-cli 0.3.1 → 0.4.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +101 -17
  2. package/package.json +1 -7
package/dist/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { realpathSync } from "fs";
4
5
  import { fileURLToPath } from "url";
5
6
  import { Cli as Cli6, z as z6 } from "incur";
6
7
 
@@ -4392,6 +4393,18 @@ council.command("seat", {
4392
4393
  examples: [{ args: { id: 0 }, description: "Inspect seat #0" }],
4393
4394
  async run(c) {
4394
4395
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4396
+ const seatCount = await client.readContract({
4397
+ abi: councilSeatsAbi,
4398
+ address: ABSTRACT_MAINNET_ADDRESSES.councilSeats,
4399
+ functionName: "seatCount"
4400
+ });
4401
+ if (c.args.id >= Number(seatCount)) {
4402
+ return c.error({
4403
+ code: "OUT_OF_RANGE",
4404
+ message: `Seat id ${c.args.id} does not exist (seatCount: ${seatCount})`,
4405
+ retryable: false
4406
+ });
4407
+ }
4395
4408
  const seatTuple = await client.readContract({
4396
4409
  abi: councilSeatsAbi,
4397
4410
  address: ABSTRACT_MAINNET_ADDRESSES.councilSeats,
@@ -4895,6 +4908,18 @@ forum.command("thread", {
4895
4908
  examples: [{ args: { id: 1 }, description: "Fetch thread #1 and its comments" }],
4896
4909
  async run(c) {
4897
4910
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4911
+ const threadCount = await client.readContract({
4912
+ abi: forumAbi,
4913
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
4914
+ functionName: "threadCount"
4915
+ });
4916
+ if (c.args.id > Number(threadCount)) {
4917
+ return c.error({
4918
+ code: "OUT_OF_RANGE",
4919
+ message: `Thread id ${c.args.id} does not exist (threadCount: ${threadCount})`,
4920
+ retryable: false
4921
+ });
4922
+ }
4898
4923
  const [threadTuple, commentCount] = await Promise.all([
4899
4924
  client.readContract({
4900
4925
  abi: forumAbi,
@@ -4967,6 +4992,18 @@ forum.command("comment", {
4967
4992
  examples: [{ args: { id: 1 }, description: "Fetch comment #1" }],
4968
4993
  async run(c) {
4969
4994
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4995
+ const commentCount = await client.readContract({
4996
+ abi: forumAbi,
4997
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
4998
+ functionName: "commentCount"
4999
+ });
5000
+ if (c.args.id > Number(commentCount)) {
5001
+ return c.error({
5002
+ code: "OUT_OF_RANGE",
5003
+ message: `Comment id ${c.args.id} does not exist (commentCount: ${commentCount})`,
5004
+ retryable: false
5005
+ });
5006
+ }
4970
5007
  const commentTuple = await client.readContract({
4971
5008
  abi: forumAbi,
4972
5009
  address: ABSTRACT_MAINNET_ADDRESSES.forum,
@@ -5012,6 +5049,18 @@ forum.command("petition", {
5012
5049
  examples: [{ args: { id: 1 }, description: "Fetch petition #1" }],
5013
5050
  async run(c) {
5014
5051
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5052
+ const petitionCount = await client.readContract({
5053
+ abi: forumAbi,
5054
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
5055
+ functionName: "petitionCount"
5056
+ });
5057
+ if (c.args.id > Number(petitionCount)) {
5058
+ return c.error({
5059
+ code: "OUT_OF_RANGE",
5060
+ message: `Petition id ${c.args.id} does not exist (petitionCount: ${petitionCount})`,
5061
+ retryable: false
5062
+ });
5063
+ }
5015
5064
  const petition = decodePetition(
5016
5065
  await client.readContract({
5017
5066
  abi: forumAbi,
@@ -5261,6 +5310,18 @@ governance.command("proposal", {
5261
5310
  examples: [{ args: { id: 1 }, description: "Fetch proposal #1" }],
5262
5311
  async run(c) {
5263
5312
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5313
+ const proposalCount = await client.readContract({
5314
+ abi: governanceAbi,
5315
+ address: ABSTRACT_MAINNET_ADDRESSES.governance,
5316
+ functionName: "proposalCount"
5317
+ });
5318
+ if (c.args.id > Number(proposalCount)) {
5319
+ return c.error({
5320
+ code: "OUT_OF_RANGE",
5321
+ message: `Proposal id ${c.args.id} does not exist (proposalCount: ${proposalCount})`,
5322
+ retryable: false
5323
+ });
5324
+ }
5264
5325
  const proposal = decodeProposal(
5265
5326
  await client.readContract({
5266
5327
  abi: governanceAbi,
@@ -5484,17 +5545,20 @@ var members = Cli4.create("members", {
5484
5545
  members.command("list", {
5485
5546
  description: "List members from an indexer snapshot (or Registered event fallback) plus on-chain active state.",
5486
5547
  env: env4,
5487
- output: z4.array(
5488
- z4.object({
5489
- address: z4.string(),
5490
- active: z4.boolean(),
5491
- registered: z4.boolean(),
5492
- activeUntil: z4.number(),
5493
- activeUntilRelative: z4.string(),
5494
- lastHeartbeatAt: z4.number(),
5495
- lastHeartbeatRelative: z4.string()
5496
- })
5497
- ),
5548
+ output: z4.object({
5549
+ members: z4.array(
5550
+ z4.object({
5551
+ address: z4.string(),
5552
+ active: z4.boolean(),
5553
+ registered: z4.boolean(),
5554
+ activeUntil: z4.number(),
5555
+ activeUntilRelative: z4.string(),
5556
+ lastHeartbeatAt: z4.number(),
5557
+ lastHeartbeatRelative: z4.string()
5558
+ })
5559
+ ),
5560
+ count: z4.number()
5561
+ }),
5498
5562
  examples: [
5499
5563
  { description: "List members using default indexer snapshot" },
5500
5564
  { description: "Override ASSEMBLY_INDEXER_URL to use a custom snapshot source" }
@@ -5563,11 +5627,9 @@ members.command("list", {
5563
5627
  lastHeartbeatRelative: relTime(info.lastHeartbeatAt)
5564
5628
  };
5565
5629
  });
5566
- return c.ok(rows, {
5567
- cta: {
5568
- description: fallbackReason ? `Indexer unavailable (${indexerIssue(fallbackReason)}); using on-chain Registered event fallback. Inspect one member:` : "Inspect one member:",
5569
- commands: [{ command: "members info", args: { address: "<addr>" } }]
5570
- }
5630
+ return c.ok({
5631
+ members: rows,
5632
+ count: rows.length
5571
5633
  });
5572
5634
  }
5573
5635
  });
@@ -5788,6 +5850,18 @@ treasury.command("executed", {
5788
5850
  examples: [{ args: { proposalId: 1 }, description: "Check execution status for proposal #1" }],
5789
5851
  async run(c) {
5790
5852
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5853
+ const proposalCount = await client.readContract({
5854
+ abi: governanceAbi,
5855
+ address: ABSTRACT_MAINNET_ADDRESSES.governance,
5856
+ functionName: "proposalCount"
5857
+ });
5858
+ if (c.args.proposalId > Number(proposalCount)) {
5859
+ return c.error({
5860
+ code: "OUT_OF_RANGE",
5861
+ message: `Proposal id ${c.args.proposalId} does not exist (proposalCount: ${proposalCount})`,
5862
+ retryable: false
5863
+ });
5864
+ }
5791
5865
  const executed = await client.readContract({
5792
5866
  abi: treasuryAbi,
5793
5867
  address: ABSTRACT_MAINNET_ADDRESSES.treasury,
@@ -6061,7 +6135,17 @@ cli.command("health", {
6061
6135
  }
6062
6136
  });
6063
6137
  applyFriendlyErrorHandling(cli);
6064
- var isMain = process.argv[1] === fileURLToPath(import.meta.url);
6138
+ var isMain = (() => {
6139
+ const entrypoint = process.argv[1];
6140
+ if (!entrypoint) {
6141
+ return false;
6142
+ }
6143
+ try {
6144
+ return realpathSync(entrypoint) === realpathSync(fileURLToPath(import.meta.url));
6145
+ } catch {
6146
+ return false;
6147
+ }
6148
+ })();
6065
6149
  if (isMain) {
6066
6150
  cli.serve();
6067
6151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectratools/assembly-cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "CLI for Assembly governance on Abstract (members, council, forum, proposals, and treasury).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,12 +28,6 @@
28
28
  "bin": {
29
29
  "assembly-cli": "./dist/cli.js"
30
30
  },
31
- "exports": {
32
- ".": {
33
- "types": "./dist/index.d.ts",
34
- "default": "./dist/index.js"
35
- }
36
- },
37
31
  "dependencies": {
38
32
  "incur": "^0.2.2",
39
33
  "ox": "^0.14.0",