Skip to content

Commit

Permalink
Deprecate marker proposal transaction (#1798)
Browse files Browse the repository at this point in the history
* Update command to do nothing, and update long help text to redirect user.

* Update changelog.

* Update tests to say that each previous command fails.

* Add linting fix.

---------

Co-authored-by: Daniel Wedul <[email protected]>
  • Loading branch information
Taztingo and SpicyLemon authored Jan 10, 2024
1 parent 0964f0f commit 0c19cc8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* Remove deleted marker send deny entries [#1666](https://github.com/provenance-io/provenance/issues/1666).
* Deprecate marker proposal transaction [#1797](https://github.com/provenance-io/provenance/issues/1797).

### Dependencies

Expand Down
12 changes: 6 additions & 6 deletions x/marker/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,45 +1240,45 @@ func (s *IntegrationTestSuite) TestMarkerTxGovProposals() {
"IncreaseSupply",
fmt.Sprintf(`{"title":"test mint marker","description":"description","manager":"%s",
"amount":{"denom":"propcoin","amount":"10"}}`, s.testnet.Validators[0].Address.String()),
false, &sdk.TxResponse{}, 0,
true, &sdk.TxResponse{}, 0,
},
{
"burn marker proposal",
"DecreaseSupply",
fmt.Sprintf(`{"title":"test burn marker","description":"description","manager":"%s",
"amount":{"denom":"propcoin","amount":"10"}}`, s.testnet.Validators[0].Address.String()),
false, &sdk.TxResponse{}, 0,
true, &sdk.TxResponse{}, 0,
},
{
"change status marker proposal",
"ChangeStatus",
`{"title":"test change marker status","description":"description","denom":"propcoin",
"new_status":"MARKER_STATUS_CANCELLED"}`,
false, &sdk.TxResponse{}, 0,
true, &sdk.TxResponse{}, 0,
},
{
"add admin marker proposal",
"SetAdministrator",
fmt.Sprintf(`{"title":"test add admin to marker","description":"description",
"denom":"propcoin","access":[{"address":"%s", "permissions": [1,2,3,4,5,6]}]}`,
s.testnet.Validators[0].Address.String()),
false, &sdk.TxResponse{}, 0,
true, &sdk.TxResponse{}, 0,
},
{
"remove admin marker proposal",
"RemoveAdministrator",
fmt.Sprintf(`{"title":"test remove marker admin","description":"description",
"denom":"propcoin","removed_address":["%s"]}`,
s.testnet.Validators[0].Address.String()),
false, &sdk.TxResponse{}, 0,
true, &sdk.TxResponse{}, 0,
},
{
"withdraw escrow marker proposal",
"WithdrawEscrow",
fmt.Sprintf(`{"title":"test withdraw marker","description":"description","target_address":"%s",
"denom":"%s", "amount":[{"denom":"%s","amount":"1"}]}`, s.testnet.Validators[0].Address.String(),
s.cfg.BondDenom, s.cfg.BondDenom),
false, &sdk.TxResponse{}, 0x5,
true, &sdk.TxResponse{}, 0x5,
// The gov module now has its own set of errors.
// This /should/ fail due to insufficient funds, and it does, but then the gov module erroneously wraps it again.
// Insufficient funds is 0x5 in the main SDK's set of errors.
Expand Down
108 changes: 3 additions & 105 deletions x/marker/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cli

import (
"encoding/json"
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"
Expand All @@ -25,7 +23,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
channelutils "github.com/cosmos/ibc-go/v6/modules/core/04-channel/client/utils"

Expand Down Expand Up @@ -99,111 +96,12 @@ func GetCmdMarkerProposal() *cobra.Command {
Use: "proposal [type] [proposal-file] [deposit]",
Args: cobra.ExactArgs(3),
Short: "Submit a marker proposal along with an initial deposit",
Long: strings.TrimSpace(`Submit a marker proposal along with an initial deposit.
Proposal title, description, deposit, and marker proposal params must be set in a provided JSON file.
Where proposal.json contains:
{
"title": "Test Proposal",
"description": "My awesome proposal",
"denom": "denomstring"
// additional properties based on type here
}
Valid Proposal Types (and associated parameters):
- AddMarker
"amount": 100,
"manager": "pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk",
"status": "active", // [proposed, finalized, active]
"marker_type": "COIN", // COIN, RESTRICTED
"access_list": [ {"address":"pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk", "permissions": [1,2,3]} ],
"supply_fixed": true,
"allow_governance_control": true,
- IncreaseSupply
"amount": {"denom":"coin", "amount":"10"}
- DecreaseSupply
"amount": {"denom":"coin", "amount":"10"}
- SetAdministrator
"access": [{"address":"pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk", "permissions": [1,2,3]}]
- RemoveAdministrator
"removed_address": ["pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk"]
- ChangeStatus
"new_status": "MARKER_STATUS_ACTIVE" // [finalized, active, cancelled, destroyed]
- WithdrawEscrow
"amount": "100coin"
"target_address": "pb1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk"
- SetDenomMetadata
"metadata": {
"description": "description text",
"base": "basedenom",
"display": "displaydenom",
"name": "Denom Name",
"symbol": "DSYMB",
"denom_units": [
{"denom":"basedenom","exponent":0,"aliases":[]},
{"denom":"otherdenomunit","exponent":9,"aliases":[]}
]
}
Long: strings.TrimSpace(`This command has been deprecated, and is no longer functional.
Please use 'gov proposal submit-proposal instead.
`,
),
Example: fmt.Sprintf(`$ %s tx marker proposal AddMarker "path/to/proposal.json" 1000%s --from mykey`, version.AppName, sdk.DefaultBondDenom),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

contents, err := os.ReadFile(args[1])
if err != nil {
return err
}

var proposal govtypesv1beta1.Content

switch args[0] {
case types.ProposalTypeIncreaseSupply:
proposal = &types.SupplyIncreaseProposal{}
case types.ProposalTypeDecreaseSupply:
proposal = &types.SupplyDecreaseProposal{}
case types.ProposalTypeSetAdministrator:
proposal = &types.SetAdministratorProposal{}
case types.ProposalTypeRemoveAdministrator:
proposal = &types.RemoveAdministratorProposal{}
case types.ProposalTypeChangeStatus:
proposal = &types.ChangeStatusProposal{}
case types.ProposalTypeWithdrawEscrow:
proposal = &types.WithdrawEscrowProposal{}
case types.ProposalTypeSetDenomMetadata:
proposal = &types.SetDenomMetadataProposal{}
default:
return fmt.Errorf("unknown proposal type %s", args[0])
}
err = json.Unmarshal(contents, proposal)
if err != nil {
return err
}

deposit, err := sdk.ParseCoinsNormalized(args[2])
if err != nil {
return err
}

callerAddr := clientCtx.GetFromAddress()
msg, err := govtypesv1beta1.NewMsgSubmitProposal(proposal, deposit, callerAddr)
if err != nil {
return fmt.Errorf("invalid governance proposal. Error: %w", err)
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
return fmt.Errorf("this command has been deprecated, and is no longer functional. Please use 'gov proposal submit-proposal' instead")
},
}
flags.AddTxFlagsToCmd(cmd)
Expand Down

0 comments on commit 0c19cc8

Please sign in to comment.