Skip to content

Commit

Permalink
rename mint/burn to grant/revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Ivanov committed Jul 2, 2024
1 parent 6224b42 commit dee36d8
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 154 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ var (
erc20client.RegisterCoinProposalHandler,
erc20client.RegisterERC20ProposalHandler,
erc20client.ToggleTokenConversionProposalHandler,
shariahoracleclient.MintCACProposalHandler,
shariahoracleclient.BurnCACProposalHandler,
shariahoracleclient.GrantCACProposalHandler,
shariahoracleclient.RevokeCACProposalHandler,
shariahoracleclient.UpdateCACContractProposalHandler,
},
),
Expand Down
6 changes: 3 additions & 3 deletions proto/haqq/shariahoracle/v1/cac.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package haqq.shariahoracle.v1;
import "gogoproto/gogo.proto";
option go_package = "github.com/haqq-network/haqq/x/shariahoracle/types";

// RegisterMintCACProposal
message MintCACProposal {
// RegisterGrantCACProposal
message GrantCACProposal {
option (gogoproto.equal) = false;
// title of the proposal
string title = 1;
Expand All @@ -15,7 +15,7 @@ message MintCACProposal {
repeated string grantees = 3;
}

message BurnCACProposal {
message RevokeCACProposal {
option (gogoproto.equal) = false;
// title of the proposal
string title = 1;
Expand Down
12 changes: 6 additions & 6 deletions x/shariahoracle/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/spf13/cobra"
)

// NewMintCACProposalCmd returns a command handler for submitting a mint community approval certificates proposal
func NewMintCACProposalCmd() *cobra.Command {
// NewGrantCACProposalCmd returns a command handler for submitting a mint community approval certificates proposal
func NewGrantCACProposalCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "mint-cac GRANTEES...",
Short: "Submit a new mint community approval certificates proposal",
Expand Down Expand Up @@ -45,7 +45,7 @@ func NewMintCACProposalCmd() *cobra.Command {

grantees := args

content := types.NewMintCACProposal(title, description, grantees...)
content := types.NewGrantCACProposal(title, description, grantees...)

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
Expand All @@ -71,8 +71,8 @@ func NewMintCACProposalCmd() *cobra.Command {
return cmd
}

// NewBurnCACProposalCmd returns a command handler for submitting a burn community approval certificates proposal
func NewBurnCACProposalCmd() *cobra.Command {
// NewRevokeCACProposalCmd returns a command handler for submitting a burn community approval certificates proposal
func NewRevokeCACProposalCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "burn-cac GRANTEES...",
Short: "Submit a new burn community approval certificates proposal",
Expand Down Expand Up @@ -106,7 +106,7 @@ func NewBurnCACProposalCmd() *cobra.Command {

grantees := args

content := types.NewBurnCACProposal(title, description, grantees...)
content := types.NewRevokeCACProposal(title, description, grantees...)

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/shariahoracle/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

var (
MintCACProposalHandler = govclient.NewProposalHandler(cli.NewMintCACProposalCmd)
BurnCACProposalHandler = govclient.NewProposalHandler(cli.NewBurnCACProposalCmd)
GrantCACProposalHandler = govclient.NewProposalHandler(cli.NewGrantCACProposalCmd)
RevokeCACProposalHandler = govclient.NewProposalHandler(cli.NewRevokeCACProposalCmd)
UpdateCACContractProposalHandler = govclient.NewProposalHandler(cli.NewUpdateCACContractProposalCmd)
)
8 changes: 4 additions & 4 deletions x/shariahoracle/keeper/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/haqq-network/haqq/x/shariahoracle/types"
)

// MintCAC mints CAC
func (k Keeper) MintCAC(ctx sdk.Context, to string) error {
// GrantCAC mints CAC
func (k Keeper) GrantCAC(ctx sdk.Context, to string) error {
// mint CAC
contract := common.HexToAddress(k.GetCACContractAddress(ctx))

Expand All @@ -27,8 +27,8 @@ func (k Keeper) MintCAC(ctx sdk.Context, to string) error {
return nil
}

// BurnCAC burns CAC
func (k Keeper) BurnCAC(ctx sdk.Context, from string) error {
// RevokeCAC burns CAC
func (k Keeper) RevokeCAC(ctx sdk.Context, from string) error {
// burn CAC
contract := common.HexToAddress(k.GetCACContractAddress(ctx))

Expand Down
12 changes: 6 additions & 6 deletions x/shariahoracle/keeper/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/mock"
)

func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy locks here because it is a test
func (suite *KeeperTestSuite) TestGrantCAC() { //nolint:govet // we can copy locks here because it is a test

testCases := []struct {
name string
Expand Down Expand Up @@ -45,7 +45,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock
suite.Require().NoError(err)
params := types.NewParams(cacAddr.String())
suite.app.ShariahOracleKeeper.SetParams(suite.ctx, params) //nolint:errcheck
err = suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String())
err = suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String())
suite.Require().NoError(err)
},
false,
Expand Down Expand Up @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock

tc.malleate()

err := suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String())
err := suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String())
suite.Commit()

if tc.expPass {
Expand All @@ -89,7 +89,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock
}
}

func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy locks here because it is a test
func (suite *KeeperTestSuite) TestRevokeCAC() { //nolint:govet // we can copy locks here because it is a test

testCases := []struct {
name string
Expand All @@ -108,7 +108,7 @@ func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy lock
suite.Require().NoError(err)
params := types.NewParams(cacAddr.String())
suite.app.ShariahOracleKeeper.SetParams(suite.ctx, params) //nolint:errcheck
err = suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String())
err = suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String())
suite.Require().NoError(err)
},
true,
Expand Down Expand Up @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy lock

tc.malleate()

err := suite.app.ShariahOracleKeeper.BurnCAC(suite.ctx, types.ModuleAddress.String())
err := suite.app.ShariahOracleKeeper.RevokeCAC(suite.ctx, types.ModuleAddress.String())
suite.Commit()

if tc.expPass {
Expand Down
28 changes: 14 additions & 14 deletions x/shariahoracle/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
func NewShariahOracleProposalHandler(k *keeper.Keeper) govv1beta1.Handler {
return func(ctx sdk.Context, content govv1beta1.Content) error {
switch c := content.(type) {
case *types.MintCACProposal:
return handleMintCACProposal(ctx, k, c)
case *types.BurnCACProposal:
return handleBurnCACProposal(ctx, k, c)
case *types.GrantCACProposal:
return handleGrantCACProposal(ctx, k, c)
case *types.RevokeCACProposal:
return handleRevokeCACProposal(ctx, k, c)
case *types.UpdateCACContractProposal:
return handleUpdateCACContractProposal(ctx, k, c)
default:
Expand All @@ -25,11 +25,11 @@ func NewShariahOracleProposalHandler(k *keeper.Keeper) govv1beta1.Handler {
}
}

// handleMintCACProposal
func handleMintCACProposal(
// handleGrantCACProposal
func handleGrantCACProposal(
ctx sdk.Context,
k *keeper.Keeper,
p *types.MintCACProposal,
p *types.GrantCACProposal,
) error {
for _, grantee := range p.Grantees {
cacMinted, err := k.DoesAddressHaveCAC(ctx, grantee)
Expand All @@ -38,10 +38,10 @@ func handleMintCACProposal(
}

Check warning on line 38 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L33-L38

Added lines #L33 - L38 were not covered by tests

if cacMinted {
return errorsmod.Wrapf(types.ErrCACAlreadyMinted, "CAC already minted for address %s", grantee)
return errorsmod.Wrapf(types.ErrCACAlreadyGranted, "CAC already minted for address %s", grantee)
}

Check warning on line 42 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L40-L42

Added lines #L40 - L42 were not covered by tests

err = k.MintCAC(ctx, grantee)
err = k.GrantCAC(ctx, grantee)
if err != nil {
return err
}

Check warning on line 47 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L44-L47

Added lines #L44 - L47 were not covered by tests
Expand All @@ -50,11 +50,11 @@ func handleMintCACProposal(
return nil

Check warning on line 50 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L50

Added line #L50 was not covered by tests
}

// handleBurnCACProposal
func handleBurnCACProposal(
// handleRevokeCACProposal
func handleRevokeCACProposal(
ctx sdk.Context,
k *keeper.Keeper,
p *types.BurnCACProposal,
p *types.RevokeCACProposal,
) error {
for _, grantee := range p.Grantees {
cacMinted, err := k.DoesAddressHaveCAC(ctx, grantee)
Expand All @@ -63,10 +63,10 @@ func handleBurnCACProposal(
}

Check warning on line 63 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L58-L63

Added lines #L58 - L63 were not covered by tests

if !cacMinted {
return errorsmod.Wrapf(types.ErrCACNotMinted, "CAC not minted for address %s", grantee)
return errorsmod.Wrapf(types.ErrCACNotGranted, "CAC not minted for address %s", grantee)
}

Check warning on line 67 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L65-L67

Added lines #L65 - L67 were not covered by tests

err = k.BurnCAC(ctx, grantee)
err = k.RevokeCAC(ctx, grantee)
if err != nil {
return err
}

Check warning on line 72 in x/shariahoracle/proposal_handler.go

View check run for this annotation

Codecov / codecov/patch

x/shariahoracle/proposal_handler.go#L69-L72

Added lines #L69 - L72 were not covered by tests
Expand Down
Loading

0 comments on commit dee36d8

Please sign in to comment.