Skip to content

Commit

Permalink
Merge pull request #194 from UnUniFi/fix_runnning_error
Browse files Browse the repository at this point in the history
Fix runnning error
  • Loading branch information
mkXultra authored Jun 10, 2022
2 parents fb43ea9 + f00be2e commit a1221f8
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 7 deletions.
21 changes: 21 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ import (
"github.com/UnUniFi/chain/x/ununifidist"
ununifidistkeeper "github.com/UnUniFi/chain/x/ununifidist/keeper"
ununifidisttypes "github.com/UnUniFi/chain/x/ununifidist/types"

"github.com/UnUniFi/chain/x/nftmarket"
nftmarketkeeper "github.com/UnUniFi/chain/x/nftmarket/keeper"
nftmarkettypes "github.com/UnUniFi/chain/x/nftmarket/types"
// "github.com/CosmWasm/wasmd/x/wasm"
// wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
)
Expand Down Expand Up @@ -211,6 +215,7 @@ var (
pricefeed.AppModuleBasic{},
ununifidist.AppModuleBasic{},
incentive.AppModuleBasic{},
nftmarket.AppModuleBasic{},
// wasm.AppModuleBasic{},
)

Expand Down Expand Up @@ -304,6 +309,7 @@ type App struct {
incentiveKeeper incentivekeeper.Keeper
ununifidistKeeper ununifidistkeeper.Keeper
pricefeedKeeper pricefeedkeeper.Keeper
nftmarketKeeper nftmarketkeeper.Keeper

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -355,6 +361,7 @@ func NewApp(
ununifidisttypes.StoreKey, pricefeedtypes.StoreKey,
// wasm.StoreKey,
nftkeeper.StoreKey,
nftmarkettypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -550,6 +557,16 @@ func NewApp(
app.BankKeeper,
)

app.nftmarketKeeper = nftmarketkeeper.NewKeeper(
appCodec,
keys[nftmarkettypes.StoreKey],
keys[nftmarkettypes.MemStoreKey],
app.GetSubspace(nftmarkettypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.NFTKeeper,
)

app.cdpKeeper = *cdpKeeper.SetHooks(cdptypes.NewMultiCdpHooks(app.incentiveKeeper.Hooks()))

// wasmDir := filepath.Join(homePath, "wasm")
Expand Down Expand Up @@ -639,6 +656,7 @@ func NewApp(
incentive.NewAppModule(appCodec, app.incentiveKeeper, app.AccountKeeper, app.BankKeeper, app.cdpKeeper),
ununifidist.NewAppModule(appCodec, app.ununifidistKeeper, app.AccountKeeper, app.BankKeeper),
pricefeed.NewAppModule(appCodec, app.pricefeedKeeper, app.AccountKeeper),
nftmarket.NewAppModule(appCodec, app.nftmarketKeeper, app.AccountKeeper, app.BankKeeper),
// wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper),
)

Expand Down Expand Up @@ -671,6 +689,7 @@ func NewApp(
cdptypes.ModuleName,
incentivetypes.ModuleName,
pricefeedtypes.ModuleName,
nftmarkettypes.ModuleName,

// ibchost.ModuleName,
// ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -702,6 +721,7 @@ func NewApp(
cdptypes.ModuleName,
incentivetypes.ModuleName,
pricefeedtypes.ModuleName,
nftmarkettypes.ModuleName,

// ibchost.ModuleName,
// ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -741,6 +761,7 @@ func NewApp(
cdptypes.ModuleName,
incentivetypes.ModuleName,
ununifidisttypes.ModuleName,
nftmarkettypes.ModuleName,

// ibchost.ModuleName,
// ibctransfertypes.ModuleName,
Expand Down
44 changes: 43 additions & 1 deletion x/nftmarket/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package cli

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/UnUniFi/chain/x/nftmarket/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
)

// GetTxCmd returns the transaction commands for this module
Expand All @@ -19,7 +23,45 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand()
cmd.AddCommand(CmdCreateListing())

return cmd
}

// todo: Implementation fields
// BidToken, MinBid, BidHook, ListingType
func CmdCreateListing() *cobra.Command {
cmd := &cobra.Command{
Use: "listing [class-id] [nft-id]",
Short: "Creates a new listing",
Long: strings.TrimSpace(
fmt.Sprintf(`Create a new listing, depositing nft.
Example:
$ %s tx %s listing 1 1 --from myKeyName --chain-id ununifi-x
`, version.AppName, types.ModuleName)),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

classId := args[0]
nftId := args[1]
nftIde := types.NftIdentifier{
ClassId: classId,
NftId: nftId,
}

msg := types.NewMsgListNft(clientCtx.GetFromAddress(), nftIde)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
3 changes: 0 additions & 3 deletions x/nftmarket/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
case *types.MsgCancelNftListing:
res, err := msgServer.CancelNftListing(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgNftBuyBack:
res, err := msgServer.NftBuyBack(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgExpandListingPeriod:
res, err := msgServer.ExpandListingPeriod(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
Expand Down
2 changes: 1 addition & 1 deletion x/nftmarket/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
ModuleName = "nftmarket"

// StoreKey defines the primary module store key
StoreKey = ModuleName
StoreKey = "ununifinftmarket"

// RouterKey is the message route for nftmarket
RouterKey = ModuleName
Expand Down
10 changes: 8 additions & 2 deletions x/nftmarket/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ import (
// ensure Msg interface compliance at compile time
var _ sdk.Msg = &MsgListNft{}

func NewMsgListNft(sender sdk.AccAddress) MsgListNft {
// todo: Implementation fields
// BidToken, MinBid, BidHook, ListingType
func NewMsgListNft(sender sdk.AccAddress, nftId NftIdentifier) MsgListNft {
return MsgListNft{
Sender: sender.Bytes(),
Sender: sender.Bytes(),
NftId: nftId,
BidToken: "uguu",
MinBid: sdk.NewInt(1),
BidHook: 1,
}
}

Expand Down

0 comments on commit a1221f8

Please sign in to comment.