Skip to content

Commit de92622

Browse files
committed
add amendment-diff cmd
1 parent f15dd37 commit de92622

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

proposal.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func proposalCmd() *ffcli.Command {
3131
Name: "proposal",
3232
ShortHelp: "Prints JSON format compatible with the `tx gov submit-proposal` command",
3333
Subcommands: []*ffcli.Command{
34-
proposalTextCmd(), proposalAmendmentCmd(), proposalUpgradeCmd(),
34+
proposalTextCmd(), proposalAmendmentCmd(), proposalAmendmentDiffCmd(), proposalUpgradeCmd(),
3535
},
3636
Exec: func(ctx context.Context, args []string) error {
3737
return flag.ErrHelp
@@ -111,6 +111,45 @@ func proposalAmendmentCmd() *ffcli.Command {
111111
}
112112
}
113113

114+
func proposalAmendmentDiffCmd() *ffcli.Command {
115+
fs := flag.NewFlagSet("amendment-diff", flag.ContinueOnError)
116+
deposit := fs.String("deposit", "512000000uatone", "Proposal deposit")
117+
return &ffcli.Command{
118+
Name: "amendment-diff",
119+
ShortUsage: "govbox proposal amendment-diff <path/to/amendment.diff>",
120+
ShortHelp: "Prints a constitution amendment proposal for the `tx gov submit-proposal` command",
121+
LongHelp: "The argument must be a patch/diff file",
122+
FlagSet: fs,
123+
Exec: func(ctx context.Context, args []string) error {
124+
if err := fs.Parse(args); err != nil {
125+
return err
126+
}
127+
if fs.NArg() != 1 {
128+
return flag.ErrHelp
129+
}
130+
bz, err := os.ReadFile(fs.Arg(0))
131+
if err != nil {
132+
return err
133+
}
134+
135+
data := map[string]any{
136+
"title": "Constitution Amendment",
137+
"summary": "# Constitution Amendment\n\nThis is a proposal to amend the constitution of Atom One.\n\nThe amendment is as follows:\n\n```diff\n" + string(bz) + "\n```",
138+
"messages": []map[string]any{
139+
{
140+
"@type": "/atomone.gov.v1.MsgProposeConstitutionAmendment",
141+
"authority": "atone10d07y265gmmuvt4z0w9aw880jnsr700j5z0zqt",
142+
"amendment": string(bz),
143+
},
144+
},
145+
"deposit": *deposit,
146+
"metadata": "ipfs://CID",
147+
}
148+
return printPropopal(data)
149+
},
150+
}
151+
}
152+
114153
func proposalUpgradeCmd() *ffcli.Command {
115154
fs := flag.NewFlagSet("upgrade", flag.ContinueOnError)
116155
deposit := fs.String("deposit", "512000000uatone", "Proposal deposit")

0 commit comments

Comments
 (0)