Skip to content

Commit

Permalink
check denom for initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
mj850 committed Nov 18, 2024
1 parent 5562fce commit 64ff084
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x/confidentialtransfers/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ func (m msgServer) InitializeAccount(goCtx context.Context, req *types.MsgInitia
return nil, sdkerrors.Wrap(sdkerrors.ErrNotFound, "account already exists")
}

// Check if denom already exists.
_, denomExists := m.Keeper.BankKeeper().GetDenomMetaData(ctx, instruction.Denom)
if !denomExists {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "denom does not exist")
}

// Validate the public key
validated := zkproofs.VerifyPubKeyValidity(*instruction.Pubkey, *instruction.Proofs.PubkeyValidityProof)
if !validated {
Expand Down
2 changes: 2 additions & 0 deletions x/confidentialtransfers/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

// AccountKeeper defines the contract required for account APIs.
Expand All @@ -17,6 +18,7 @@ type AccountKeeper interface {
// BankKeeper defines the contract needed to be fulfilled for banking and supply
// dependencies.
type BankKeeper interface {
GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool)
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

0 comments on commit 64ff084

Please sign in to comment.