@spectratools/assembly-cli 0.10.1 → 0.11.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 +117 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5776,6 +5776,123 @@ forum.command("post-comment", {
|
|
|
5776
5776
|
}
|
|
5777
5777
|
}
|
|
5778
5778
|
});
|
|
5779
|
+
forum.command("create-petition", {
|
|
5780
|
+
description: "Create a new petition for community-initiated proposals.",
|
|
5781
|
+
hint: "Requires PRIVATE_KEY environment variable for signing.",
|
|
5782
|
+
options: writeOptions.extend({
|
|
5783
|
+
title: z3.string().min(1).describe("Petition title"),
|
|
5784
|
+
description: z3.string().min(1).describe("Petition description"),
|
|
5785
|
+
kind: z3.coerce.number().int().nonnegative().max(255).describe("Proposal kind enum value"),
|
|
5786
|
+
category: z3.string().default("governance").describe("Forum category label for the petition")
|
|
5787
|
+
}),
|
|
5788
|
+
env: writeEnv,
|
|
5789
|
+
output: z3.object({
|
|
5790
|
+
proposer: z3.string(),
|
|
5791
|
+
category: z3.string(),
|
|
5792
|
+
kind: z3.number(),
|
|
5793
|
+
title: z3.string(),
|
|
5794
|
+
description: z3.string(),
|
|
5795
|
+
expectedPetitionId: z3.number(),
|
|
5796
|
+
expectedThreadId: z3.number(),
|
|
5797
|
+
tx: txResultOutput2
|
|
5798
|
+
}),
|
|
5799
|
+
examples: [
|
|
5800
|
+
{
|
|
5801
|
+
options: {
|
|
5802
|
+
title: "Expand treasury diversification",
|
|
5803
|
+
description: "Propose allocating 5% of treasury to stablecoin reserves.",
|
|
5804
|
+
kind: 1,
|
|
5805
|
+
category: "treasury"
|
|
5806
|
+
},
|
|
5807
|
+
description: "Create a petition as an active Assembly member"
|
|
5808
|
+
}
|
|
5809
|
+
],
|
|
5810
|
+
async run(c) {
|
|
5811
|
+
const client = createAssemblyPublicClient(c.env.ABSTRACT_RPC_URL);
|
|
5812
|
+
const account = resolveAccount(c.env);
|
|
5813
|
+
const [activeMember, petitionCountBefore, threadCountBefore] = await Promise.all([
|
|
5814
|
+
client.readContract({
|
|
5815
|
+
abi: registryAbi,
|
|
5816
|
+
address: ABSTRACT_MAINNET_ADDRESSES.registry,
|
|
5817
|
+
functionName: "isActive",
|
|
5818
|
+
args: [account.address]
|
|
5819
|
+
}),
|
|
5820
|
+
client.readContract({
|
|
5821
|
+
abi: forumAbi,
|
|
5822
|
+
address: ABSTRACT_MAINNET_ADDRESSES.forum,
|
|
5823
|
+
functionName: "petitionCount"
|
|
5824
|
+
}),
|
|
5825
|
+
client.readContract({
|
|
5826
|
+
abi: forumAbi,
|
|
5827
|
+
address: ABSTRACT_MAINNET_ADDRESSES.forum,
|
|
5828
|
+
functionName: "threadCount"
|
|
5829
|
+
})
|
|
5830
|
+
]);
|
|
5831
|
+
if (!activeMember) {
|
|
5832
|
+
return c.error({
|
|
5833
|
+
code: "NOT_ACTIVE_MEMBER",
|
|
5834
|
+
message: `Address ${toChecksum(account.address)} is not an active Assembly member.`,
|
|
5835
|
+
retryable: false
|
|
5836
|
+
});
|
|
5837
|
+
}
|
|
5838
|
+
const expectedPetitionId = Number(petitionCountBefore) + 1;
|
|
5839
|
+
const expectedThreadId = Number(threadCountBefore) + 1;
|
|
5840
|
+
const proposalInput = {
|
|
5841
|
+
kind: c.options.kind,
|
|
5842
|
+
title: c.options.title,
|
|
5843
|
+
description: c.options.description,
|
|
5844
|
+
intentSteps: [],
|
|
5845
|
+
intentConstraints: {
|
|
5846
|
+
deadline: 0,
|
|
5847
|
+
maxAllowedRiskTier: 0
|
|
5848
|
+
},
|
|
5849
|
+
configUpdates: []
|
|
5850
|
+
};
|
|
5851
|
+
try {
|
|
5852
|
+
const txResult = await assemblyWriteTx({
|
|
5853
|
+
env: c.env,
|
|
5854
|
+
options: c.options,
|
|
5855
|
+
address: ABSTRACT_MAINNET_ADDRESSES.forum,
|
|
5856
|
+
abi: forumAbi,
|
|
5857
|
+
functionName: "createPetition",
|
|
5858
|
+
args: [c.options.category, proposalInput]
|
|
5859
|
+
});
|
|
5860
|
+
return c.ok(
|
|
5861
|
+
{
|
|
5862
|
+
proposer: toChecksum(account.address),
|
|
5863
|
+
category: c.options.category,
|
|
5864
|
+
kind: c.options.kind,
|
|
5865
|
+
title: c.options.title,
|
|
5866
|
+
description: c.options.description,
|
|
5867
|
+
expectedPetitionId,
|
|
5868
|
+
expectedThreadId,
|
|
5869
|
+
tx: txResult
|
|
5870
|
+
},
|
|
5871
|
+
c.format === "json" || c.format === "jsonl" ? void 0 : {
|
|
5872
|
+
cta: {
|
|
5873
|
+
description: "Next steps:",
|
|
5874
|
+
commands: [
|
|
5875
|
+
{ command: "forum petition", args: { id: String(expectedPetitionId) } },
|
|
5876
|
+
{
|
|
5877
|
+
command: "forum sign-petition",
|
|
5878
|
+
args: { petitionId: String(expectedPetitionId) }
|
|
5879
|
+
}
|
|
5880
|
+
]
|
|
5881
|
+
}
|
|
5882
|
+
}
|
|
5883
|
+
);
|
|
5884
|
+
} catch (error) {
|
|
5885
|
+
if (error instanceof TxError) {
|
|
5886
|
+
return c.error({
|
|
5887
|
+
code: error.code,
|
|
5888
|
+
message: error.message,
|
|
5889
|
+
retryable: error.code === "NONCE_CONFLICT"
|
|
5890
|
+
});
|
|
5891
|
+
}
|
|
5892
|
+
throw error;
|
|
5893
|
+
}
|
|
5894
|
+
}
|
|
5895
|
+
});
|
|
5779
5896
|
forum.command("sign-petition", {
|
|
5780
5897
|
description: "Sign an existing petition as an active member.",
|
|
5781
5898
|
hint: "Requires PRIVATE_KEY environment variable for signing.",
|
package/package.json
CHANGED