Skip to content

Commit

Permalink
pass test
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Feb 9, 2024
1 parent adae437 commit 6afce4e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ var (
tokenfactorytypes.EnableBurnFrom,
tokenfactorytypes.EnableForceTransfer,
tokenfactorytypes.EnableSetMetadata,
tokenfactorytypes.EnableAuthoritiesSudoMint,
}
)

Expand Down
12 changes: 6 additions & 6 deletions x/tokenfactory/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ func (suite *KeeperTestSuite) TestGenesis() {
genesisState := types.GenesisState{
FactoryDenoms: []types.GenesisDenom{
{
Denom: "factory/tokenfactory1t7egva48prqmzl59x5ngv4zx0dtrwewcvz09h0/bitcoin",
Denom: "factory/cosmos1t7egva48prqmzl59x5ngv4zx0dtrwewcdqdjr8/bitcoin",
AuthorityMetadata: types.DenomAuthorityMetadata{
Admin: "tokenfactory1t7egva48prqmzl59x5ngv4zx0dtrwewcvz09h0",
Admin: "cosmos1t7egva48prqmzl59x5ngv4zx0dtrwewcdqdjr8",
},
},
{
Denom: "factory/tokenfactory1t7egva48prqmzl59x5ngv4zx0dtrwewcvz09h0/diff-admin",
Denom: "factory/cosmos1t7egva48prqmzl59x5ngv4zx0dtrwewcdqdjr8/diff-admin",
AuthorityMetadata: types.DenomAuthorityMetadata{
Admin: "tokenfactory15czt5nhlnvayqq37xun9s9yus0d6y26d8uh5qf",
Admin: "cosmos15czt5nhlnvayqq37xun9s9yus0d6y26dx74r5p",
},
},
{
Denom: "factory/tokenfactory1t7egva48prqmzl59x5ngv4zx0dtrwewcvz09h0/litecoin",
Denom: "factory/cosmos1t7egva48prqmzl59x5ngv4zx0dtrwewcdqdjr8/litecoin",
AuthorityMetadata: types.DenomAuthorityMetadata{
Admin: "tokenfactory1t7egva48prqmzl59x5ngv4zx0dtrwewcvz09h0",
Admin: "cosmos1t7egva48prqmzl59x5ngv4zx0dtrwewcdqdjr8",
},
},
},
Expand Down
30 changes: 13 additions & 17 deletions x/tokenfactory/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,19 @@ func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.
var err error
ctx := sdk.UnwrapSDKContext(goCtx)

sudoEnabled := types.IsCapabilityEnabled(server.Keeper.enabledCapabilities, types.EnableAuthoritiesSudoMint)

if !sudoEnabled {
// Standard User Verification
_, denomExists := server.bankKeeper.GetDenomMetaData(ctx, msg.Amount.Denom)
if !denomExists {
return nil, types.ErrDenomDoesNotExist.Wrapf("denom: %s. sudoEnabled: %v", msg.Amount.Denom, sudoEnabled)
}

authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom())
if err != nil {
return nil, err
}

if msg.Sender != authorityMetadata.GetAdmin() {
return nil, types.ErrUnauthorized
}
// Standard User Verification
_, denomExists := server.bankKeeper.GetDenomMetaData(ctx, msg.Amount.Denom)
if !denomExists {
return nil, types.ErrDenomDoesNotExist.Wrapf("denom: %s", msg.Amount.Denom)
}

authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom())
if err != nil {
return nil, err
}

if msg.Sender != authorityMetadata.GetAdmin() {
return nil, types.ErrUnauthorized
}

if msg.MintToAddress == "" {
Expand Down
2 changes: 0 additions & 2 deletions x/tokenfactory/types/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const (
EnableSetMetadata = "enable_metadata"
EnableForceTransfer = "enable_force_transfer"
EnableBurnFrom = "enable_burn_from"
// Allows Authorities of the module to mint any token they wish (including base tokens)
EnableAuthoritiesSudoMint = "enable_admin_sudo_mint"
)

func IsCapabilityEnabled(enabledCapabilities []string, capability string) bool {
Expand Down

0 comments on commit 6afce4e

Please sign in to comment.