Skip to content

Commit

Permalink
Revert "Merge pull request #270 from provenance-io/llama/add-fee-deno…
Browse files Browse the repository at this point in the history
…m-change-proposal"

This reverts commit 7462a84, reversing
changes made to 23ba5dc.
  • Loading branch information
SpicyLemon committed Nov 15, 2022
1 parent 7462a84 commit 648ae0c
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 738 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

* Add functionality to update denom metadata via gov proposal [#270](https://github.com/provenance-io/cosmos-sdk/pull/270)
* nothing

---
Expand Down
17 changes: 0 additions & 17 deletions proto/cosmos/bank/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ service Msg {

// MultiSend defines a method for sending coins from some accounts to other accounts.
rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse);

// UpdateDenomMetadata defines a method for updating the denom metadata. Only usable in x/gov proposal.
rpc UpdateDenomMetadata(MsgUpdateDenomMetadata) returns (MsgUpdateDenomMetadataResponse);
}

// MsgSend represents a message to send coins from one account to another.
Expand Down Expand Up @@ -50,17 +47,3 @@ message MsgMultiSend {
// MsgMultiSendResponse defines the Msg/MultiSend response type.
message MsgMultiSendResponse {}

message MsgUpdateDenomMetadata {
option (cosmos.msg.v1.signer) = "from_address";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string title = 2;
string description = 3;
Metadata metadata = 4;
}

// MsgUpdateDenomMetadataResponse defines the Msg/UpdateDenomMetadata response type.
message MsgUpdateDenomMetadataResponse {}
2 changes: 0 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ func NewSimApp(
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
)

// set the governance module account as the authority
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(),
)
Expand Down
9 changes: 0 additions & 9 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper
import (
"fmt"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/internal/conv"
Expand Down Expand Up @@ -48,8 +47,6 @@ type Keeper interface {
DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error

GetAuthority() string

types.QueryServer
}

Expand All @@ -62,7 +59,6 @@ type BaseKeeper struct {
storeKey storetypes.StoreKey
paramSpace paramtypes.Subspace
mintCoinsRestrictionFn MintingRestrictionFn
authority string
}

type MintingRestrictionFn func(ctx sdk.Context, coins sdk.Coins) error
Expand Down Expand Up @@ -117,7 +113,6 @@ func NewBaseKeeper(
storeKey: storeKey,
paramSpace: paramSpace,
mintCoinsRestrictionFn: func(ctx sdk.Context, coins sdk.Coins) error { return nil },
authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), // hardcoded till all transitive dependencies can be updated to pass in the constructor instead
}
}

Expand Down Expand Up @@ -555,7 +550,3 @@ func (k BaseViewKeeper) IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bo
}
}
}

func (k BaseKeeper) GetAuthority() string {
return k.authority
}
16 changes: 2 additions & 14 deletions x/bank/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@ package keeper

import (
"context"

"github.com/armon/go-metrics"
"cosmossdk.io/errors"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/bank/types"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
)

type msgServer struct {
Keeper
}

// UpdateDenomMetadata updates the denom metadata if the message is signed by gov module account
func (k msgServer) UpdateDenomMetadata(goCtx context.Context, msg *types.MsgUpdateDenomMetadata) (*types.MsgUpdateDenomMetadataResponse, error) {
if k.GetAuthority() != msg.FromAddress {
return nil, errors.Wrapf(gov.ErrInvalidSigner, "expected %s got %s", k.GetAuthority(), msg.FromAddress)
}

ctx := sdk.UnwrapSDKContext(goCtx)
k.Keeper.SetDenomMetaData(ctx, *msg.Metadata)
return &types.MsgUpdateDenomMetadataResponse{}, nil
}

// NewMsgServerImpl returns an implementation of the bank MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
Expand Down Expand Up @@ -113,4 +102,3 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t

return &types.MsgMultiSendResponse{}, nil
}

2 changes: 1 addition & 1 deletion x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (k BaseSendKeeper) subUnlockedCoins(ctx sdk.Context, addr sdk.AccAddress, a

_, hasNeg := sdk.Coins{spendable}.SafeSub(coin)
if hasNeg {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "%s is smaller than %s", spendable, balance)
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "%s is smaller than %s", spendable, coin)
}

newBalance := balance.Sub(coin)
Expand Down
2 changes: 0 additions & 2 deletions x/bank/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import (
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgSend{}, "cosmos-sdk/MsgSend")
legacy.RegisterAminoMsg(cdc, &MsgMultiSend{}, "cosmos-sdk/MsgMultiSend")
legacy.RegisterAminoMsg(cdc, &MsgUpdateDenomMetadata{}, "cosmos-sdk/MsgUpdateDenomMetadata")
cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization", nil)
}

func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgSend{},
&MsgMultiSend{},
&MsgUpdateDenomMetadata{},
)
registry.RegisterImplementations(
(*authz.Authorization)(nil),
Expand Down
47 changes: 2 additions & 45 deletions x/bank/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (

// bank message types
const (
TypeMsgSend = "send"
TypeMsgMultiSend = "multisend"
TypeMsgUpdateDenomMetadata = "updatedenommetada"
TypeMsgSend = "send"
TypeMsgMultiSend = "multisend"
)

var _ sdk.Msg = &MsgSend{}
Expand Down Expand Up @@ -185,45 +184,3 @@ func ValidateInputsOutputs(inputs []Input, outputs []Output) error {

return nil
}

var _ sdk.Msg = &MsgUpdateDenomMetadata{}

// NewMsgUpdateDenomMetadata - construct a message to update denom metadata
func NewMsgUpdateDenomMetadata(fromAddr, title string, description string, metadata *Metadata) *MsgUpdateDenomMetadata {
return &MsgUpdateDenomMetadata{
FromAddress: fromAddr,
Title: title,
Description: description,
Metadata: metadata,
}
}

// Route Implements Msg
func (msg MsgUpdateDenomMetadata) Route() string {
return RouterKey
}

// Type Implements Msg
func (msg MsgUpdateDenomMetadata) Type() string {
return TypeMsgUpdateDenomMetadata
}

// ValidateBasic Implements Msg.
func (msg MsgUpdateDenomMetadata) ValidateBasic() error {
err := msg.Metadata.Validate()
if err != nil {
return err
}
return nil
}

// GetSignBytes Implements Msg.
func (msg MsgUpdateDenomMetadata) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

// GetSigners Implements Msg.
func (msg MsgUpdateDenomMetadata) GetSigners() []sdk.AccAddress {
fromAddress, _ := sdk.AccAddressFromBech32(msg.FromAddress)
return []sdk.AccAddress{fromAddress}
}
32 changes: 0 additions & 32 deletions x/bank/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,35 +275,3 @@ func TestMsgSendGetSigners(t *testing.T) {
require.Equal(t, 1, len(res))
require.True(t, from.Equals(res[0]))
}

func TestUpdateDenomMetadataGetSignBytes(t *testing.T) {
//from := sdk.AccAddress("input")
//coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
msg := MsgUpdateDenomMetadata{
Title: "title",
Description: "description",
Metadata: &Metadata {
Name: "Cosmos Hub Atom",
Symbol: "ATOM",
Description: "The native staking token of the Cosmos Hub.",
DenomUnits: []*DenomUnit{
{"uatom", uint32(0), []string{"microatom"}},
},
},
}
res := msg.GetSignBytes()

expected := `{"type":"cosmos-sdk/MsgUpdateDenomMetadata","value":{"description":"description","metadata":{"denom_units":[{"aliases":["microatom"],"denom":"uatom"}],"description":"The native staking token of the Cosmos Hub.","name":"Cosmos Hub Atom","symbol":"ATOM"},"title":"title"}}`
require.Equal(t, expected, string(res))
}

func TestUpdateDenomMetadataGetSigners(t *testing.T) {
from := sdk.AccAddress("input111111111111111")
title := "Proposal Title"
description := "Proposal description"
metadata := Metadata{}
msg := NewMsgUpdateDenomMetadata(from.String(), title, description, &metadata)
res := msg.GetSigners()
require.Equal(t, 1, len(res))
require.True(t, from.Equals(res[0]))
}
Loading

0 comments on commit 648ae0c

Please sign in to comment.