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

feat: enable NFT factory & rename #635

Merged
merged 13 commits into from
Jul 18, 2023
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
76 changes: 38 additions & 38 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ import (
yieldaggregatorkeeper "github.com/UnUniFi/chain/x/yieldaggregator/keeper"
yieldaggregatortypes "github.com/UnUniFi/chain/x/yieldaggregator/types"

nftmarket "github.com/UnUniFi/chain/x/nftbackedloan"
nftmarketkeeper "github.com/UnUniFi/chain/x/nftbackedloan/keeper"
nftmarkettypes "github.com/UnUniFi/chain/x/nftbackedloan/types"
nftbackedloan "github.com/UnUniFi/chain/x/nftbackedloan"
nftbackedloankeeper "github.com/UnUniFi/chain/x/nftbackedloan/keeper"
nftbackedloantypes "github.com/UnUniFi/chain/x/nftbackedloan/types"

// "github.com/UnUniFi/chain/x/nftfactory"
// nftmintkeeper "github.com/UnUniFi/chain/x/nftfactory/keeper"
// nftminttypes "github.com/UnUniFi/chain/x/nftfactory/types"
"github.com/UnUniFi/chain/x/derivatives"
derivativeskeeper "github.com/UnUniFi/chain/x/derivatives/keeper"
derivativestypes "github.com/UnUniFi/chain/x/derivatives/types"
nftfactory "github.com/UnUniFi/chain/x/nftfactory"
nftfactorykeeper "github.com/UnUniFi/chain/x/nftfactory/keeper"
nftfactorytypes "github.com/UnUniFi/chain/x/nftfactory/types"
"github.com/UnUniFi/chain/x/pricefeed"
pricefeedkeeper "github.com/UnUniFi/chain/x/pricefeed/keeper"
pricefeedtypes "github.com/UnUniFi/chain/x/pricefeed/types"
Expand Down Expand Up @@ -247,8 +247,8 @@ var (
ibcfee.AppModuleBasic{},

// original modules
nftmarket.AppModuleBasic{},
// nftmint.AppModuleBasic{},
nftbackedloan.AppModuleBasic{},
nftfactory.AppModuleBasic{},

yieldaggregator.AppModuleBasic{},
stakeibc.AppModuleBasic{},
Expand Down Expand Up @@ -278,9 +278,9 @@ var (
wasm.ModuleName: {authtypes.Burner},

// original modules
nftmarkettypes.ModuleName: nil,
// nftmarkettypes.NftTradingFee: nil,
// nftminttypes.ModuleName: nil,
nftbackedloantypes.ModuleName: nil,
// nftbackedloantypes.NftTradingFee: nil,
nftfactorytypes.ModuleName: nil,

yieldaggregatortypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakeibctypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -365,8 +365,8 @@ type App struct {
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

NftmarketKeeper nftmarketkeeper.Keeper
// NftmintKeeper nftmintkeeper.Keeper
NftbackedloanKeeper nftbackedloankeeper.Keeper
NftfactoryKeeper nftfactorykeeper.Keeper

YieldaggregatorKeeper yieldaggregatorkeeper.Keeper
StakeibcKeeper stakeibckeeper.Keeper
Expand Down Expand Up @@ -434,8 +434,8 @@ func NewApp(
icacontrollertypes.StoreKey,

// original modules
nftmarkettypes.StoreKey,
// nftminttypes.StoreKey,
nftbackedloantypes.StoreKey,
nftfactorytypes.StoreKey,

yieldaggregatortypes.StoreKey,
stakeibctypes.StoreKey,
Expand Down Expand Up @@ -708,21 +708,21 @@ func NewApp(
wasmOpts...,
)

// app.NftmintKeeper = nftmintkeeper.NewKeeper(
// appCodec,
// keys[nftminttypes.StoreKey],
// keys[nftminttypes.MemStoreKey],
// app.GetSubspace(nftminttypes.ModuleName),
// app.AccountKeeper,
// app.NFTKeeper,
// )
app.NftfactoryKeeper = nftfactorykeeper.NewKeeper(
appCodec,
keys[nftfactorytypes.StoreKey],
keys[nftfactorytypes.MemStoreKey],
app.GetSubspace(nftfactorytypes.ModuleName),
app.AccountKeeper,
app.NFTKeeper,
)

nftmarketKeeper := nftmarketkeeper.NewKeeper(
nftbackedloanKeeper := nftbackedloankeeper.NewKeeper(
appCodec,
encodingConfig.TxConfig,
keys[nftmarkettypes.StoreKey],
keys[nftmarkettypes.MemStoreKey],
app.GetSubspace(nftmarkettypes.ModuleName),
keys[nftbackedloantypes.StoreKey],
keys[nftbackedloantypes.MemStoreKey],
app.GetSubspace(nftbackedloantypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.NFTKeeper,
Expand Down Expand Up @@ -842,7 +842,7 @@ func NewApp(
)

// create Keeper objects which have Hooks
app.NftmarketKeeper = *nftmarketKeeper.SetHooks(nftmarkettypes.NewMultiNftbackedloanHooks(app.EcosystemincentiveKeeper.Hooks()))
app.NftbackedloanKeeper = *nftbackedloanKeeper.SetHooks(nftbackedloantypes.NewMultiNftbackedloanHooks(app.EcosystemincentiveKeeper.Hooks()))

// Register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
Expand Down Expand Up @@ -948,8 +948,8 @@ func NewApp(
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),

// original modules
// nftmint.NewAppModule(appCodec, app.NftmintKeeper, app.NFTKeeper),
nftmarket.NewAppModule(appCodec, app.NftmarketKeeper, app.AccountKeeper, app.BankKeeper),
nftfactory.NewAppModule(appCodec, app.NftfactoryKeeper, app.NFTKeeper),
nftbackedloan.NewAppModule(appCodec, app.NftbackedloanKeeper, app.AccountKeeper, app.BankKeeper),

yieldaggregator.NewAppModule(appCodec, app.YieldaggregatorKeeper, app.AccountKeeper, app.BankKeeper),
stakeibc.NewAppModule(appCodec, app.StakeibcKeeper, app.AccountKeeper, app.BankKeeper),
Expand Down Expand Up @@ -991,8 +991,8 @@ func NewApp(
ecosystemincentivetypes.ModuleName,
pricefeedtypes.ModuleName,

// nftminttypes.ModuleName,
nftmarkettypes.ModuleName,
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,

stakeibctypes.ModuleName,
epochstypes.ModuleName,
Expand Down Expand Up @@ -1035,8 +1035,8 @@ func NewApp(
ecosystemincentivetypes.ModuleName,
pricefeedtypes.ModuleName,

// nftminttypes.ModuleName,
nftmarkettypes.ModuleName,
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,
stakeibctypes.ModuleName,
epochstypes.ModuleName,
interchainquerytypes.ModuleName,
Expand Down Expand Up @@ -1084,8 +1084,8 @@ func NewApp(

// original modules
pricefeedtypes.ModuleName,
// nftminttypes.ModuleName,
nftmarkettypes.ModuleName,
nftfactorytypes.ModuleName,
nftbackedloantypes.ModuleName,
ecosystemincentivetypes.ModuleName,

stakeibctypes.ModuleName,
Expand Down Expand Up @@ -1428,8 +1428,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(wasm.ModuleName)

// original modules
paramsKeeper.Subspace(nftmarkettypes.ModuleName)
// paramsKeeper.Subspace(nftminttypes.ModuleName)
paramsKeeper.Subspace(nftbackedloantypes.ModuleName)
paramsKeeper.Subspace(nftfactorytypes.ModuleName)

paramsKeeper.Subspace(stakeibctypes.ModuleName)
paramsKeeper.Subspace(epochstypes.ModuleName)
Expand Down
54 changes: 52 additions & 2 deletions docs/client/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5572,7 +5572,35 @@ paths:

signatures required by gogoproto.
borrowing_limit:
type: string
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
total_deposit:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.


NOTE: The amount field is an Int which implements the custom
method

signatures required by gogoproto.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -10860,7 +10888,29 @@ definitions:

signatures required by gogoproto.
borrowing_limit:
type: string
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
total_deposit:
type: object
properties:
denom:
type: string
amount:
type: string
description: |-
Coin defines a token with a denomination and an amount.

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
ununifi.nftbackedloan.QueryLoansResponse:
type: object
properties:
Expand Down
62 changes: 32 additions & 30 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2868,23 +2868,23 @@ Query defines the gRPC querier service.

### NftListing

| Field | Type | Label | Description |
| ------------------------ | ------------------------------------------------------- | ----- | ----------- |
| `nft_id` | [NftIdentifier](#ununifi.nftmarket.NftIdentifier) | | |
| `owner` | [string](#string) | | |
| `listing_type` | [ListingType](#ununifi.nftmarket.ListingType) | | |
| `state` | [ListingState](#ununifi.nftmarket.ListingState) | | |
| `bid_token` | [string](#string) | | |
| `minimum_deposit_rate` | [string](#string) | | |
| `automatic_refinancing` | [bool](#bool) | | |
| `started_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `full_payment_end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `successful_bid_end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `auto_relisted_count` | [uint64](#uint64) | | |
| `collected_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `collected_amount_negative` | [bool] | | |
| `minimum_bidding_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | |
| Field | Type | Label | Description |
| --------------------------- | ------------------------------------------------------- | ----- | ----------- |
| `nft_id` | [NftIdentifier](#ununifi.nftmarket.NftIdentifier) | | |
| `owner` | [string](#string) | | |
| `listing_type` | [ListingType](#ununifi.nftmarket.ListingType) | | |
| `state` | [ListingState](#ununifi.nftmarket.ListingState) | | |
| `bid_token` | [string](#string) | | |
| `minimum_deposit_rate` | [string](#string) | | |
| `automatic_refinancing` | [bool](#bool) | | |
| `started_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `full_payment_end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `successful_bid_end_at` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `auto_relisted_count` | [uint64](#uint64) | | |
| `collected_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `collected_amount_negative` | [bool] | | |
| `minimum_bidding_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | |

<a name="ununifi.nftmarket.Params"></a>

Expand Down Expand Up @@ -2942,14 +2942,14 @@ Query defines the gRPC querier service.

### ListingState

| Name | Number | Description |
| ---------------- | ------ | ----------- |
| UNKNOWN | 0 | |
| LISTING | 1 | |
| BIDDING | 2 | |
| SALE_DECISION | 3 | |
| LIQUIDATION | 4 | |
| SUCCESSFUL_BID | 5 | |
| Name | Number | Description |
| -------------- | ------ | ----------- |
| UNKNOWN | 0 | |
| LISTING | 1 | |
| BIDDING | 2 | |
| SALE_DECISION | 3 | |
| LIQUIDATION | 4 | |
| SUCCESSFUL_BID | 5 | |

<a name="ununifi.nftmarket.ListingType"></a>

Expand Down Expand Up @@ -3120,10 +3120,11 @@ GenesisState defines the nftmarket module's genesis state.

### QueryLoanResponse

| Field | Type | Label | Description |
| ----------------- | ------------------------------- | ----- | ----------- |
| `loan` | [Loan](#ununifi.nftmarket.Loan) | | |
| `borrowing_limit` | [string](#string) | | |
| Field | Type | Label | Description |
| ----------------- | ----------------------------------------------------- | ----- | ----------- |
| `loan` | [Loan](#ununifi.nftmarket.Loan) | | |
| `borrowing_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `total_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |

<a name="ununifi.nftmarket.QueryLoansRequest"></a>

Expand Down Expand Up @@ -3812,7 +3813,8 @@ GenesisState defines the nftmarket module's genesis state.
| Field | Type | Label | Description |
| ----------------- | --------------------------------- | ----- | ----------- |
| `loan` | [Loan](#ununifi.nftmarketv1.Loan) | | |
| `borrowing_limit` | [string](#string) | | |
| `borrowing_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |
| `total_deposit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | |

<a name="ununifi.nftmarketv1.QueryLoansRequest"></a>

Expand Down
7 changes: 2 additions & 5 deletions proto/ununifi/nftbackedloan/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@ message QueryLoanRequest {

message QueryLoanResponse {
Loan loan = 1 [(gogoproto.nullable) = false];
string borrowing_limit = 2 [
(gogoproto.moretags) = "yaml:\"borrowing_limit\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
cosmos.base.v1beta1.Coin borrowing_limit = 2 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin total_deposit = 3 [(gogoproto.nullable) = false];
}

message QueryNftBidsRequest {
Expand Down
8 changes: 4 additions & 4 deletions scripts/commands/nftmint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ SCRIPT_DIR=$(cd $(dirname $0); pwd)
# create class and get the class id
# ununifid tx nftmint create-class Test[ClassName] ipfs://testcid/[BaseTokenUri] 1000[TokenSupplyCap] 0[MintingPermission] --from debug --chain-id test"
# onlyOwner can create nft
$BINARY tx nftmint create-class Test ipfs://testcid/ 100000 0 --from $USER1 $conf
$BINARY tx nftfactory create-class Test-onlyOwner ipfs://testcid/ 100000 0 --from $USER1 $conf
# everyone can create nft
$BINARY tx nftmint create-class Test ipfs://testcid/ 100000 1 --from $USER1 $conf
$BINARY tx nftfactory create-class Test-everyone ipfs://testcid/ 100000 1 --from $USER1 $conf
CLASS_ID_ONLYOWNER=$(ununifid q nftmint class-ids-by-owner $USER_ADDRESS_1 --output json |jq .owning_class_id_list.class_id[0] |sed -e 's/\"//g')
CLASS_ID_EVERYONE=$(ununifid q nftmint class-ids-by-owner $USER_ADDRESS_1 --output json |jq .owning_class_id_list.class_id[1] |sed -e 's/\"//g')
## NOTE: $CLASS_ID returns "class_id" that returns error against below messages.
## Just try redefine CLASS_ID with simple text or just replace once you get the class_id.
## If you know the solution for this, please let me know or just commit and push.
# mint nft
$BINARY tx nftmint mint-nft $CLASS_ID_ONLYOWNER a00 $USER_ADDRESS_1 --from $USER1 --chain-id test -y
$BINARY tx nftmint mint-nft $CLASS_ID_EVERYONE a00 $USER_ADDRESS_1 --from $USER1 --chain-id test -y
$BINARY tx nftfactory mint-nft $CLASS_ID_ONLYOWNER a00 $USER_ADDRESS_1 --from $USER1 --chain-id test -y
$BINARY tx nftfactory mint-nft $CLASS_ID_EVERYONE a00 $USER_ADDRESS_1 --from $USER1 --chain-id test -y

# # burn nft
# $BINARY tx nftmint burn-nft $CLASS_ID a00 --from debug --chain-id test -y
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jq '.app_state.pricefeed.posted_prices = [
# ununifid start --home=$NODE_HOME

# for nftmint
jq '.app_state.nftmint.class_attributes_list = [
jq '.app_state.nftfactory.class_attributes_list = [
{
"base_token_uri": "ipfs://testcid/",
"class_id": "ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3",
Expand Down
2 changes: 1 addition & 1 deletion x/nftbackedloan/abci.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nftmarket
package nftbackedloan

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
2 changes: 1 addition & 1 deletion x/nftbackedloan/genesis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nftmarket
package nftbackedloan

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
Loading