@spectratools/assembly-cli 0.3.1 → 0.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.
Files changed (2) hide show
  1. package/dist/cli.js +89 -16
  2. package/package.json +1 -7
package/dist/cli.js CHANGED
@@ -4392,6 +4392,18 @@ council.command("seat", {
4392
4392
  examples: [{ args: { id: 0 }, description: "Inspect seat #0" }],
4393
4393
  async run(c) {
4394
4394
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4395
+ const seatCount = await client.readContract({
4396
+ abi: councilSeatsAbi,
4397
+ address: ABSTRACT_MAINNET_ADDRESSES.councilSeats,
4398
+ functionName: "seatCount"
4399
+ });
4400
+ if (c.args.id >= Number(seatCount)) {
4401
+ return c.error({
4402
+ code: "OUT_OF_RANGE",
4403
+ message: `Seat id ${c.args.id} does not exist (seatCount: ${seatCount})`,
4404
+ retryable: false
4405
+ });
4406
+ }
4395
4407
  const seatTuple = await client.readContract({
4396
4408
  abi: councilSeatsAbi,
4397
4409
  address: ABSTRACT_MAINNET_ADDRESSES.councilSeats,
@@ -4895,6 +4907,18 @@ forum.command("thread", {
4895
4907
  examples: [{ args: { id: 1 }, description: "Fetch thread #1 and its comments" }],
4896
4908
  async run(c) {
4897
4909
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4910
+ const threadCount = await client.readContract({
4911
+ abi: forumAbi,
4912
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
4913
+ functionName: "threadCount"
4914
+ });
4915
+ if (c.args.id > Number(threadCount)) {
4916
+ return c.error({
4917
+ code: "OUT_OF_RANGE",
4918
+ message: `Thread id ${c.args.id} does not exist (threadCount: ${threadCount})`,
4919
+ retryable: false
4920
+ });
4921
+ }
4898
4922
  const [threadTuple, commentCount] = await Promise.all([
4899
4923
  client.readContract({
4900
4924
  abi: forumAbi,
@@ -4967,6 +4991,18 @@ forum.command("comment", {
4967
4991
  examples: [{ args: { id: 1 }, description: "Fetch comment #1" }],
4968
4992
  async run(c) {
4969
4993
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
4994
+ const commentCount = await client.readContract({
4995
+ abi: forumAbi,
4996
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
4997
+ functionName: "commentCount"
4998
+ });
4999
+ if (c.args.id > Number(commentCount)) {
5000
+ return c.error({
5001
+ code: "OUT_OF_RANGE",
5002
+ message: `Comment id ${c.args.id} does not exist (commentCount: ${commentCount})`,
5003
+ retryable: false
5004
+ });
5005
+ }
4970
5006
  const commentTuple = await client.readContract({
4971
5007
  abi: forumAbi,
4972
5008
  address: ABSTRACT_MAINNET_ADDRESSES.forum,
@@ -5012,6 +5048,18 @@ forum.command("petition", {
5012
5048
  examples: [{ args: { id: 1 }, description: "Fetch petition #1" }],
5013
5049
  async run(c) {
5014
5050
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5051
+ const petitionCount = await client.readContract({
5052
+ abi: forumAbi,
5053
+ address: ABSTRACT_MAINNET_ADDRESSES.forum,
5054
+ functionName: "petitionCount"
5055
+ });
5056
+ if (c.args.id > Number(petitionCount)) {
5057
+ return c.error({
5058
+ code: "OUT_OF_RANGE",
5059
+ message: `Petition id ${c.args.id} does not exist (petitionCount: ${petitionCount})`,
5060
+ retryable: false
5061
+ });
5062
+ }
5015
5063
  const petition = decodePetition(
5016
5064
  await client.readContract({
5017
5065
  abi: forumAbi,
@@ -5261,6 +5309,18 @@ governance.command("proposal", {
5261
5309
  examples: [{ args: { id: 1 }, description: "Fetch proposal #1" }],
5262
5310
  async run(c) {
5263
5311
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5312
+ const proposalCount = await client.readContract({
5313
+ abi: governanceAbi,
5314
+ address: ABSTRACT_MAINNET_ADDRESSES.governance,
5315
+ functionName: "proposalCount"
5316
+ });
5317
+ if (c.args.id > Number(proposalCount)) {
5318
+ return c.error({
5319
+ code: "OUT_OF_RANGE",
5320
+ message: `Proposal id ${c.args.id} does not exist (proposalCount: ${proposalCount})`,
5321
+ retryable: false
5322
+ });
5323
+ }
5264
5324
  const proposal = decodeProposal(
5265
5325
  await client.readContract({
5266
5326
  abi: governanceAbi,
@@ -5484,17 +5544,20 @@ var members = Cli4.create("members", {
5484
5544
  members.command("list", {
5485
5545
  description: "List members from an indexer snapshot (or Registered event fallback) plus on-chain active state.",
5486
5546
  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
- ),
5547
+ output: z4.object({
5548
+ members: z4.array(
5549
+ z4.object({
5550
+ address: z4.string(),
5551
+ active: z4.boolean(),
5552
+ registered: z4.boolean(),
5553
+ activeUntil: z4.number(),
5554
+ activeUntilRelative: z4.string(),
5555
+ lastHeartbeatAt: z4.number(),
5556
+ lastHeartbeatRelative: z4.string()
5557
+ })
5558
+ ),
5559
+ count: z4.number()
5560
+ }),
5498
5561
  examples: [
5499
5562
  { description: "List members using default indexer snapshot" },
5500
5563
  { description: "Override ASSEMBLY_INDEXER_URL to use a custom snapshot source" }
@@ -5563,11 +5626,9 @@ members.command("list", {
5563
5626
  lastHeartbeatRelative: relTime(info.lastHeartbeatAt)
5564
5627
  };
5565
5628
  });
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
- }
5629
+ return c.ok({
5630
+ members: rows,
5631
+ count: rows.length
5571
5632
  });
5572
5633
  }
5573
5634
  });
@@ -5788,6 +5849,18 @@ treasury.command("executed", {
5788
5849
  examples: [{ args: { proposalId: 1 }, description: "Check execution status for proposal #1" }],
5789
5850
  async run(c) {
5790
5851
  const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
5852
+ const proposalCount = await client.readContract({
5853
+ abi: governanceAbi,
5854
+ address: ABSTRACT_MAINNET_ADDRESSES.governance,
5855
+ functionName: "proposalCount"
5856
+ });
5857
+ if (c.args.proposalId > Number(proposalCount)) {
5858
+ return c.error({
5859
+ code: "OUT_OF_RANGE",
5860
+ message: `Proposal id ${c.args.proposalId} does not exist (proposalCount: ${proposalCount})`,
5861
+ retryable: false
5862
+ });
5863
+ }
5791
5864
  const executed = await client.readContract({
5792
5865
  abi: treasuryAbi,
5793
5866
  address: ABSTRACT_MAINNET_ADDRESSES.treasury,
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.0",
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",