Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating tokenmint bugs #171

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion x/tokenmint/keeper/mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ func (k *Keeper) MintNewTokensForApp(ctx sdk.Context, appMappingId uint64, asset
if err := k.MintCoin(ctx, types.ModuleName, sdk.NewCoin(assetData.Denom, amount)); err != nil {
return err
}
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, sdk.AccAddress(address), sdk.NewCoin(assetData.Denom, amount)); err != nil {
userAddress, err := sdk.AccAddressFromBech32(address)

if err != nil {
return err
}
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, userAddress, sdk.NewCoin(assetData.Denom, amount)); err != nil {
return err
}
k.UpdateAssetDataInTokenMintByApp(ctx, appMappingId, assetId, true, amount)
Expand Down
17 changes: 15 additions & 2 deletions x/tokenmint/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"fmt"
"time"

"github.com/comdex-official/comdex/x/tokenmint/types"
Expand Down Expand Up @@ -92,7 +93,12 @@ func (k *msgServer) MsgMintNewTokens(c context.Context, msg *types.MsgMintNewTok
if err := k.MintCoin(ctx, types.ModuleName, sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
return nil, err
}
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, sdk.AccAddress(assetDataInApp.Recipient), sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
userAddress, err := sdk.AccAddressFromBech32(assetDataInApp.Recipient)

if err != nil {
return nil, err
}
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, userAddress, sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
return nil, err
}

Expand All @@ -112,13 +118,20 @@ func (k *msgServer) MsgMintNewTokens(c context.Context, msg *types.MsgMintNewTok
if found {
return nil, types.ErrorGensisMintingForTokenalreadyDone
}
userAddress, err := sdk.AccAddressFromBech32(assetDataInApp.Recipient)

if err != nil {
return nil, err
}

if err := k.MintCoin(ctx, types.ModuleName, sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
return nil, err
}
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, sdk.AccAddress(assetDataInApp.Recipient), sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
fmt.Println(types.ModuleName, "module name ")
if err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, userAddress, sdk.NewCoin(assetData.Denom, *assetDataInApp.GenesisSupply)); err != nil {
return nil, err
}
// fmt.Println(sdk.AccAddress(assetDataInApp.Recipient), "reciepient address ")

var newTokenMintappData types.MintedTokens
newTokenMintappData.AssetId = msg.AssetId
Expand Down