diff --git a/app/app.go b/app/app.go index dfdae3834..b9cfe233a 100644 --- a/app/app.go +++ b/app/app.go @@ -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" ) @@ -211,6 +215,7 @@ var ( pricefeed.AppModuleBasic{}, ununifidist.AppModuleBasic{}, incentive.AppModuleBasic{}, + nftmarket.AppModuleBasic{}, // wasm.AppModuleBasic{}, ) @@ -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 @@ -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) @@ -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") @@ -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), ) @@ -671,6 +689,7 @@ func NewApp( cdptypes.ModuleName, incentivetypes.ModuleName, pricefeedtypes.ModuleName, + nftmarkettypes.ModuleName, // ibchost.ModuleName, // ibctransfertypes.ModuleName, @@ -702,6 +721,7 @@ func NewApp( cdptypes.ModuleName, incentivetypes.ModuleName, pricefeedtypes.ModuleName, + nftmarkettypes.ModuleName, // ibchost.ModuleName, // ibctransfertypes.ModuleName, @@ -741,6 +761,7 @@ func NewApp( cdptypes.ModuleName, incentivetypes.ModuleName, ununifidisttypes.ModuleName, + nftmarkettypes.ModuleName, // ibchost.ModuleName, // ibctransfertypes.ModuleName, diff --git a/x/nftmarket/client/cli/tx.go b/x/nftmarket/client/cli/tx.go index 8ce8098b9..293f2f6f3 100644 --- a/x/nftmarket/client/cli/tx.go +++ b/x/nftmarket/client/cli/tx.go @@ -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 @@ -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 } diff --git a/x/nftmarket/handler.go b/x/nftmarket/handler.go index 0b00a164b..66ecfc65c 100644 --- a/x/nftmarket/handler.go +++ b/x/nftmarket/handler.go @@ -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) diff --git a/x/nftmarket/types/keys.go b/x/nftmarket/types/keys.go index b6484f793..a3e20aebc 100644 --- a/x/nftmarket/types/keys.go +++ b/x/nftmarket/types/keys.go @@ -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 diff --git a/x/nftmarket/types/msgs.go b/x/nftmarket/types/msgs.go index 82c6911e5..4d68f6014 100644 --- a/x/nftmarket/types/msgs.go +++ b/x/nftmarket/types/msgs.go @@ -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, } }