-
Notifications
You must be signed in to change notification settings - Fork 36
/
tx.go
453 lines (390 loc) · 13.6 KB
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
package cli
import (
"strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/provenance-io/provenance/x/exchange"
)
// CmdTx creates the tx command (and sub-commands) for the exchange module.
func CmdTx() *cobra.Command {
cmd := &cobra.Command{
Use: exchange.ModuleName,
Aliases: []string{"ex"},
Short: "Transaction commands for the exchange module",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
CmdTxCreateAsk(),
CmdTxCreateBid(),
CmdTxCommitFunds(),
CmdTxCancelOrder(),
CmdTxFillBids(),
CmdTxFillAsks(),
CmdTxMarketSettle(),
CmdTxMarketCommitmentSettle(),
CmdTxMarketReleaseCommitments(),
CmdTxMarketSetOrderExternalID(),
CmdTxMarketWithdraw(),
CmdTxMarketUpdateDetails(),
CmdTxMarketUpdateAcceptingOrders(),
CmdTxMarketUpdateUserSettle(),
CmdTxMarketUpdateAcceptingCommitments(),
CmdTxMarketUpdateIntermediaryDenom(),
CmdTxMarketManagePermissions(),
CmdTxMarketManageReqAttrs(),
CmdTxCreatePayment(),
CmdTxAcceptPayment(),
CmdTxRejectPayment(),
CmdTxRejectPayments(),
CmdTxCancelPayments(),
CmdTxChangePaymentTarget(),
CmdTxGovCreateMarket(),
CmdTxGovManageFees(),
CmdTxGovCloseMarket(),
CmdTxGovUpdateParams(),
)
return cmd
}
// CmdTxCreateAsk creates the create-ask sub-command for the exchange tx command.
func CmdTxCreateAsk() *cobra.Command {
cmd := &cobra.Command{
Use: "create-ask",
Aliases: []string{"ask", "create-ask-order", "ask-order"},
Short: "Create an ask order",
RunE: genericTxRunE(MakeMsgCreateAsk),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCreateAsk(cmd)
return cmd
}
// CmdTxCreateBid creates the create-bid sub-command for the exchange tx command.
func CmdTxCreateBid() *cobra.Command {
cmd := &cobra.Command{
Use: "create-bid",
Aliases: []string{"bid", "create-bid-order", "bid-order"},
Short: "Create a bid order",
RunE: genericTxRunE(MakeMsgCreateBid),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCreateBid(cmd)
return cmd
}
// CmdTxCommitFunds creates the commit-funds sub-command for the exchange tx command.
func CmdTxCommitFunds() *cobra.Command {
cmd := &cobra.Command{
Use: "commit",
Aliases: []string{"commit-funds"},
Short: "Commit funds to a market",
RunE: genericTxRunE(MakeMsgCommitFunds),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCommitFunds(cmd)
return cmd
}
// CmdTxCancelOrder creates the cancel-order sub-command for the exchange tx command.
func CmdTxCancelOrder() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-order",
Aliases: []string{"cancel"},
Short: "Cancel an order",
RunE: genericTxRunE(MakeMsgCancelOrder),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCancelOrder(cmd)
return cmd
}
// CmdTxFillBids creates the fill-bids sub-command for the exchange tx command.
func CmdTxFillBids() *cobra.Command {
cmd := &cobra.Command{
Use: "fill-bids",
Short: "Fill one or more bid orders",
RunE: genericTxRunE(MakeMsgFillBids),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxFillBids(cmd)
return cmd
}
// CmdTxFillAsks creates the fill-asks sub-command for the exchange tx command.
func CmdTxFillAsks() *cobra.Command {
cmd := &cobra.Command{
Use: "fill-asks",
Short: "Fill one or more ask orders",
RunE: genericTxRunE(MakeMsgFillAsks),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxFillAsks(cmd)
return cmd
}
// CmdTxMarketSettle creates the market-settle sub-command for the exchange tx command.
func CmdTxMarketSettle() *cobra.Command {
cmd := &cobra.Command{
Use: "market-settle",
Aliases: []string{"settle"},
Short: "Settle some orders",
RunE: genericTxRunE(MakeMsgMarketSettle),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketSettle(cmd)
return cmd
}
// CmdTxMarketCommitmentSettle creates the market-commitment-settle sub-command for the exchange tx command.
func CmdTxMarketCommitmentSettle() *cobra.Command {
cmd := &cobra.Command{
Use: "market-commitment-settle",
Aliases: []string{"commitment-settle", "market-settle-commitments", "settle-commitments"},
Short: "Move some committed funds",
RunE: genericTxRunE(MakeMsgMarketCommitmentSettle),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketCommitmentSettle(cmd)
return cmd
}
// CmdTxMarketReleaseCommitments creates the market-release-commitments sub-command for the exchange tx command.
func CmdTxMarketReleaseCommitments() *cobra.Command {
cmd := &cobra.Command{
Use: "market-release-commitments",
Aliases: []string{"release-commitments"},
Short: "Release funds that have been committed to a market",
RunE: genericTxRunE(MakeMsgMarketReleaseCommitments),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketReleaseCommitments(cmd)
return cmd
}
// CmdTxMarketSetOrderExternalID creates the market-set-external-id sub-command for the exchange tx command.
func CmdTxMarketSetOrderExternalID() *cobra.Command {
cmd := &cobra.Command{
Use: "market-set-external-id",
Aliases: []string{"market-set-order-external-id", "set-external-id", "external-id"},
Short: "Set an order's external id",
RunE: genericTxRunE(MakeMsgMarketSetOrderExternalID),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketSetOrderExternalID(cmd)
return cmd
}
// CmdTxMarketWithdraw creates the market-withdraw sub-command for the exchange tx command.
func CmdTxMarketWithdraw() *cobra.Command {
cmd := &cobra.Command{
Use: "market-withdraw",
Aliases: []string{"withdraw"},
Short: "Withdraw funds from a market account",
RunE: genericTxRunE(MakeMsgMarketWithdraw),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketWithdraw(cmd)
return cmd
}
// CmdTxMarketUpdateDetails creates the market-details sub-command for the exchange tx command.
func CmdTxMarketUpdateDetails() *cobra.Command {
cmd := &cobra.Command{
Use: "market-details",
Aliases: []string{"market-update-details", "update-market-details", "update-details"},
Short: "Update a market's details",
RunE: genericTxRunE(MakeMsgMarketUpdateDetails),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketUpdateDetails(cmd)
return cmd
}
// CmdTxMarketUpdateAcceptingOrders creates the market-accepting-orders sub-command for the exchange tx command.
func CmdTxMarketUpdateAcceptingOrders() *cobra.Command {
cmd := &cobra.Command{
Use: "market-accepting-orders",
Aliases: []string{"market-update-accepting-orders", "update-market-accepting-orders", "update-accepting-orders"},
Short: "Change whether a market is accepting orders",
RunE: genericTxRunE(MakeMsgMarketUpdateAcceptingOrders),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketUpdateAcceptingOrders(cmd)
return cmd
}
// CmdTxMarketUpdateUserSettle creates the market-user-settle sub-command for the exchange tx command.
func CmdTxMarketUpdateUserSettle() *cobra.Command {
cmd := &cobra.Command{
Use: "market-user-settle",
Aliases: []string{"market-update-user-settle", "update-market-user-settle", "update-user-settle"},
Short: "Change whether a market allows settlements initiated by users",
RunE: genericTxRunE(MakeMsgMarketUpdateUserSettle),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketUpdateUserSettle(cmd)
return cmd
}
// CmdTxMarketUpdateAcceptingCommitments creates the market-accepting-commitments sub-command for the exchange tx command.
func CmdTxMarketUpdateAcceptingCommitments() *cobra.Command {
cmd := &cobra.Command{
Use: "market-accepting-commitments",
Aliases: []string{"market-update-accepting-commitments", "update-market-accepting-commitments", "update-accepting-commitments"},
Short: "Change whether a market is accepting commitments",
RunE: genericTxRunE(MakeMsgMarketUpdateAcceptingCommitments),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketUpdateAcceptingCommitments(cmd)
return cmd
}
// CmdTxMarketUpdateIntermediaryDenom creates the market-intermediary-denom sub-command for the exchange tx command.
func CmdTxMarketUpdateIntermediaryDenom() *cobra.Command {
cmd := &cobra.Command{
Use: "market-intermediary-denom",
Aliases: []string{"market-update-intermediary-denom", "update-market-intermediary-denom", "update-intermediary-denom"},
Short: "Change a market's intermediary denom",
RunE: genericTxRunE(MakeMsgMarketUpdateIntermediaryDenom),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketUpdateIntermediaryDenom(cmd)
return cmd
}
// CmdTxMarketManagePermissions creates the market-permissions sub-command for the exchange tx command.
func CmdTxMarketManagePermissions() *cobra.Command {
cmd := &cobra.Command{
Use: "market-permissions",
Aliases: []string{"market-manage-permissions", "manage-market-permissions", "manage-permissions", "permissions"},
Short: "Update the account permissions for a market",
RunE: genericTxRunE(MakeMsgMarketManagePermissions),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketManagePermissions(cmd)
return cmd
}
// CmdTxMarketManageReqAttrs creates the market-req-attrs sub-command for the exchange tx command.
func CmdTxMarketManageReqAttrs() *cobra.Command {
cmd := &cobra.Command{
Use: "market-req-attrs",
Aliases: []string{"market-manage-req-attrs", "manage-market-req-attrs", "manage-req-attrs", "req-attrs"},
Short: "Manage the attributes required to create orders in a market",
RunE: genericTxRunE(MakeMsgMarketManageReqAttrs),
}
newAliases := make([]string, 0, len(cmd.Aliases))
for _, alias := range cmd.Aliases {
if strings.Contains(alias, "req-attrs") {
newAliases = append(newAliases, strings.Replace(alias, "req-attrs", "required-attributes", 1))
}
}
cmd.Aliases = append(cmd.Aliases, newAliases...)
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxMarketManageReqAttrs(cmd)
return cmd
}
// CmdTxCreatePayment creates the create-payment sub-command for the exchange tx command.
func CmdTxCreatePayment() *cobra.Command {
cmd := &cobra.Command{
Use: "create-payment",
Short: "Create a payment",
RunE: genericTxRunE(MakeMsgCreatePayment),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCreatePayment(cmd)
return cmd
}
// CmdTxAcceptPayment creates the accept-payment sub-command for the exchange tx command.
func CmdTxAcceptPayment() *cobra.Command {
cmd := &cobra.Command{
Use: "accept-payment",
Short: "Accept a payment",
RunE: genericTxRunE(MakeMsgAcceptPayment),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxAcceptPayment(cmd)
return cmd
}
// CmdTxRejectPayment creates the reject-payment sub-command for the exchange tx command.
func CmdTxRejectPayment() *cobra.Command {
cmd := &cobra.Command{
Use: "reject-payment",
Short: "Reject a payment",
RunE: genericTxRunE(MakeMsgRejectPayment),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxRejectPayment(cmd)
return cmd
}
// CmdTxRejectPayments creates the reject-payments sub-command for the exchange tx command.
func CmdTxRejectPayments() *cobra.Command {
cmd := &cobra.Command{
Use: "reject-payments",
Short: "Reject multiple payments",
RunE: genericTxRunE(MakeMsgRejectPayments),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxRejectPayments(cmd)
return cmd
}
// CmdTxCancelPayments creates the cancel-payments sub-command for the exchange tx command.
func CmdTxCancelPayments() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-payments",
Short: "Cancel multiple payments",
RunE: genericTxRunE(MakeMsgCancelPayments),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxCancelPayments(cmd)
return cmd
}
// CmdTxChangePaymentTarget creates the change-payment-target sub-command for the exchange tx command.
func CmdTxChangePaymentTarget() *cobra.Command {
cmd := &cobra.Command{
Use: "change-payment-target",
Short: "Change a payment's target",
RunE: genericTxRunE(MakeMsgChangePaymentTarget),
}
flags.AddTxFlagsToCmd(cmd)
SetupCmdTxChangePaymentTarget(cmd)
return cmd
}
// CmdTxGovCreateMarket creates the gov-create-market sub-command for the exchange tx command.
func CmdTxGovCreateMarket() *cobra.Command {
cmd := &cobra.Command{
Use: "gov-create-market",
Aliases: []string{"create-market"},
Short: "Submit a governance proposal to create a market",
RunE: govTxRunE(MakeMsgGovCreateMarket),
}
flags.AddTxFlagsToCmd(cmd)
govcli.AddGovPropFlagsToCmd(cmd)
SetupCmdTxGovCreateMarket(cmd)
return cmd
}
// CmdTxGovManageFees creates the gov-manage-fees sub-command for the exchange tx command.
func CmdTxGovManageFees() *cobra.Command {
cmd := &cobra.Command{
Use: "gov-manage-fees",
Aliases: []string{"manage-fees", "gov-update-fees", "update-fees"},
Short: "Submit a governance proposal to change a market's fees",
RunE: govTxRunE(MakeMsgGovManageFees),
}
flags.AddTxFlagsToCmd(cmd)
govcli.AddGovPropFlagsToCmd(cmd)
SetupCmdTxGovManageFees(cmd)
return cmd
}
// CmdTxGovCloseMarket creates the gov-close-market sub-command for the exchange tx command.
func CmdTxGovCloseMarket() *cobra.Command {
cmd := &cobra.Command{
Use: "gov-close-market",
Aliases: []string{"close-market"},
Short: "Submit a governance proposal to close a market",
RunE: govTxRunE(MakeMsgGovCloseMarket),
}
flags.AddTxFlagsToCmd(cmd)
govcli.AddGovPropFlagsToCmd(cmd)
SetupCmdTxGovCloseMarket(cmd)
return cmd
}
// CmdTxGovUpdateParams creates the gov-update-params sub-command for the exchange tx command.
func CmdTxGovUpdateParams() *cobra.Command {
cmd := &cobra.Command{
Use: "gov-update-params",
Aliases: []string{"gov-params", "update-params", "params"},
Short: "Submit a governance proposal to update the exchange module params",
RunE: govTxRunE(MakeMsgGovUpdateParams),
}
flags.AddTxFlagsToCmd(cmd)
govcli.AddGovPropFlagsToCmd(cmd)
SetupCmdTxGovUpdateParams(cmd)
return cmd
}