Skip to content

Commit 25ece42

Browse files
authored
Merge pull request #82 from oursky/feat/nft-on-xnft-rc1
StarFerry upgrade.
2 parents c7775d1 + 8c14b3f commit 25ece42

File tree

269 files changed

+71078
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+71078
-231
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
test:
1111
name: Run test
1212
runs-on: ubuntu-latest
13-
timeout-minutes: 10
13+
timeout-minutes: 15
1414
steps:
1515
- uses: actions/checkout@v3
1616
- uses: actions/setup-go@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ build
1212
dist
1313
release
1414
deploy/liked.service
15+
16+
x/likenft/testutil/generated_*

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ go.sum: go.mod
4141
install: go.sum $(BUILDDIR)/
4242
go install -mod=readonly $(BUILD_FLAGS) ./...
4343

44-
test:
44+
codegen:
45+
go install github.com/golang/mock/mockgen@v1.6.0
46+
go generate ./...
47+
48+
test: codegen
4549
go test -v ./...
4650

4751
clean:

app/app.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ import (
9797
"github.com/likecoin/likecoin-chain/v3/backport/cosmos-sdk/v0.46.0-rc1/x/nft"
9898
nftkeeper "github.com/likecoin/likecoin-chain/v3/backport/cosmos-sdk/v0.46.0-rc1/x/nft/keeper"
9999
nftmodule "github.com/likecoin/likecoin-chain/v3/backport/cosmos-sdk/v0.46.0-rc1/x/nft/module"
100+
101+
"github.com/likecoin/likecoin-chain/v3/x/likenft"
102+
likenftkeeper "github.com/likecoin/likecoin-chain/v3/x/likenft/keeper"
103+
likenfttypes "github.com/likecoin/likecoin-chain/v3/x/likenft/types"
100104
)
101105

102106
var (
@@ -138,6 +142,7 @@ var (
138142

139143
// LikeCoin
140144
iscn.AppModuleBasic{},
145+
likenft.AppModuleBasic{},
141146
)
142147

143148
// module account permissions
@@ -150,6 +155,7 @@ var (
150155
govtypes.ModuleName: {authtypes.Burner},
151156
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
152157
nft.ModuleName: nil,
158+
likenfttypes.ModuleName: nil,
153159
}
154160
)
155161

@@ -188,6 +194,7 @@ type LikeApp struct {
188194
FeeGrantKeeper feegrantkeeper.Keeper
189195
IscnKeeper iscnkeeper.Keeper
190196
NftKeeper nftkeeper.Keeper
197+
LikeNftKeeper likenftkeeper.Keeper
191198

192199
// make scoped keepers public for test purposes
193200
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
@@ -234,9 +241,10 @@ func NewLikeApp(
234241
authzkeeper.StoreKey,
235242
iscntypes.StoreKey,
236243
nftkeeper.StoreKey,
244+
likenfttypes.StoreKey,
237245
)
238246
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
239-
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
247+
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, likenfttypes.MemStoreKey)
240248

241249
app := &LikeApp{
242250
BaseApp: bApp,
@@ -265,6 +273,7 @@ func NewLikeApp(
265273
ibcTransferSubspace := app.ParamsKeeper.Subspace(ibctransfertypes.ModuleName)
266274
ibcHostSubspace := app.ParamsKeeper.Subspace(ibchost.ModuleName)
267275
iscnSubspace := app.ParamsKeeper.Subspace(iscntypes.ModuleName)
276+
likeNftSubspace := app.ParamsKeeper.Subspace(likenfttypes.ModuleName)
268277

269278
bApp.SetParamStore(
270279
app.ParamsKeeper.Subspace(baseapp.Paramspace).
@@ -316,6 +325,7 @@ func NewLikeApp(
316325
app.IscnKeeper = iscnkeeper.NewKeeper(appCodec, keys[iscntypes.StoreKey], app.AccountKeeper, app.BankKeeper, iscnSubspace)
317326

318327
app.NftKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper)
328+
app.LikeNftKeeper = *likenftkeeper.NewKeeper(app.appCodec, keys[likenfttypes.StoreKey], app.memKeys[likenfttypes.MemStoreKey], likeNftSubspace, app.AccountKeeper, app.BankKeeper, app.IscnKeeper, app.NftKeeper)
319329

320330
// register the staking hooks
321331
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
@@ -394,6 +404,7 @@ func NewLikeApp(
394404
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
395405
iscn.NewAppModule(app.IscnKeeper),
396406
nftmodule.NewAppModule(appCodec, app.NftKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
407+
likenft.NewAppModule(appCodec, app.LikeNftKeeper, app.AccountKeeper, app.BankKeeper),
397408
)
398409

399410
// During begin block slashing happens after distr.BeginBlocker so that
@@ -422,6 +433,7 @@ func NewLikeApp(
422433
paramstypes.ModuleName,
423434
iscntypes.ModuleName,
424435
nft.ModuleName,
436+
likenfttypes.ModuleName,
425437
)
426438

427439
app.mm.SetOrderEndBlockers(
@@ -444,6 +456,7 @@ func NewLikeApp(
444456
upgradetypes.ModuleName,
445457
iscntypes.ModuleName,
446458
nft.ModuleName,
459+
likenfttypes.ModuleName,
447460
)
448461

449462
// NOTE: The genutils module must occur after staking so that pools are
@@ -471,6 +484,7 @@ func NewLikeApp(
471484
upgradetypes.ModuleName,
472485
iscntypes.ModuleName,
473486
nft.ModuleName,
487+
likenfttypes.ModuleName,
474488
)
475489

476490
app.mm.RegisterInvariants(&app.CrisisKeeper)
@@ -557,7 +571,7 @@ func (app *LikeApp) registerUpgradeHandlers() {
557571

558572
if upgradeInfo.Name == "v3.0.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
559573
storeUpgrades := storetypes.StoreUpgrades{
560-
Added: []string{nft.StoreKey},
574+
Added: []string{nft.StoreKey, likenfttypes.StoreKey},
561575
}
562576

563577
// configure store loader that checks if version == upgradeHeight and applies store upgrades

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/cosmos/cosmos-sdk v0.45.6
77
github.com/cosmos/ibc-go/v2 v2.3.0
88
github.com/gogo/protobuf v1.3.3
9+
github.com/golang/mock v1.6.0
910
github.com/golang/protobuf v1.5.2
1011
github.com/gorilla/mux v1.8.0
1112
github.com/grpc-ecosystem/grpc-gateway v1.16.0
@@ -19,6 +20,7 @@ require (
1920
github.com/tendermint/tm-db v0.6.6
2021
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
2122
google.golang.org/grpc v1.45.0
23+
google.golang.org/protobuf v1.27.1
2224
)
2325

2426
require (
@@ -121,7 +123,6 @@ require (
121123
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
122124
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
123125
golang.org/x/text v0.3.7 // indirect
124-
google.golang.org/protobuf v1.27.1 // indirect
125126
gopkg.in/ini.v1 v1.66.2 // indirect
126127
gopkg.in/yaml.v2 v2.4.0 // indirect
127128
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect

proto/buf.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ deps:
88
- remote: buf.build
99
owner: cosmos
1010
repository: cosmos-sdk
11-
commit: 5463f864d90d42678e5622499c08548a
11+
commit: 5a0f723faed2400d8f1ed75519f1b063
1212
- remote: buf.build
1313
owner: cosmos
1414
repository: gogo-proto

proto/buf.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ lint:
1010
- UNARY_RPC
1111
- COMMENT_FIELD
1212
- SERVICE_SUFFIX
13-
- PACKAGE_VERSION_SUFFIX
1413
- RPC_REQUEST_STANDARD_NAME
1514
- COMMENT_RPC
1615
- COMMENT_MESSAGE
@@ -19,7 +18,7 @@ lint:
1918
- ENUM_VALUE_PREFIX
2019
- ENUM_ZERO_VALUE_SUFFIX
2120
ignore:
22-
- iscn
21+
- likechain/iscn
2322
breaking:
2423
use:
2524
- FILE

proto/iscn/genesis.proto renamed to proto/likechain/iscn/genesis.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ syntax = "proto3";
33
package likechain.iscn;
44

55
import "gogoproto/gogo.proto";
6-
import "iscn/params.proto";
6+
import "likechain/iscn/params.proto";
77

88
option go_package = "github.com/likecoin/likecoin-chain/v3/x/iscn/types";
99

File renamed without changes.
File renamed without changes.

proto/iscn/query.proto renamed to proto/likechain/iscn/query.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package likechain.iscn;
44

55
import "gogoproto/gogo.proto";
66
import "google/api/annotations.proto";
7-
import "iscn/params.proto";
7+
import "likechain/iscn/params.proto";
88

99
option go_package = "github.com/likecoin/likecoin-chain/v3/x/iscn/types";
1010

proto/iscn/store.proto renamed to proto/likechain/iscn/store.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ syntax = "proto3";
33
package likechain.iscn;
44

55
import "gogoproto/gogo.proto";
6-
import "iscn/iscnid.proto";
6+
import "likechain/iscn/iscnid.proto";
77

88
option go_package = "github.com/likecoin/likecoin-chain/v3/x/iscn/types";
99

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
import "gogoproto/gogo.proto";
6+
import "likechain/likenft/v1/nft_input.proto";
7+
8+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
9+
10+
message BlindBoxContent {
11+
string class_id = 1;
12+
string id = 2;
13+
NFTInput input = 3 [(gogoproto.nullable) = false];
14+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
import "gogoproto/gogo.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
9+
10+
message ClassData {
11+
bytes metadata = 1 [
12+
(gogoproto.nullable) = false,
13+
(gogoproto.customtype) = "JsonInput"
14+
];
15+
ClassParent parent = 2 [(gogoproto.nullable) = false];
16+
ClassConfig config = 3 [(gogoproto.nullable) = false];
17+
BlindBoxState blind_box_state = 4 [(gogoproto.nullable) = false];
18+
}
19+
20+
enum ClassParentType {
21+
UNKNOWN = 0;
22+
ISCN = 1;
23+
ACCOUNT = 2;
24+
}
25+
26+
message ClassParent {
27+
ClassParentType type = 1;
28+
string iscn_id_prefix = 2 [(gogoproto.nullable) = true];
29+
uint64 iscn_version_at_mint = 3 [(gogoproto.nullable) = true];
30+
string account = 4 [(gogoproto.nullable) = true];
31+
}
32+
33+
message MintPeriod {
34+
google.protobuf.Timestamp start_time = 1 [
35+
(gogoproto.stdtime) = true,
36+
(gogoproto.nullable) = false
37+
];
38+
repeated string allowed_addresses = 2;
39+
uint64 mint_price = 3;
40+
}
41+
42+
message ClassConfig {
43+
bool burnable = 1;
44+
uint64 max_supply = 2;
45+
BlindBoxConfig blind_box_config = 3 [(gogoproto.nullable) = true];
46+
}
47+
48+
message BlindBoxConfig {
49+
repeated MintPeriod mint_periods = 1 [(gogoproto.nullable) = false];
50+
google.protobuf.Timestamp reveal_time = 2 [
51+
(gogoproto.stdtime) = true,
52+
(gogoproto.nullable) = false
53+
];
54+
}
55+
56+
message BlindBoxState {
57+
uint64 content_count = 1;
58+
bool to_be_revealed = 2;
59+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
import "gogoproto/gogo.proto";
6+
import "likechain/likenft/v1/class_data.proto";
7+
8+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
9+
10+
message ClassInput {
11+
string name = 1;
12+
string symbol = 2;
13+
string description = 3;
14+
string uri = 4;
15+
string uri_hash = 5;
16+
bytes metadata = 6 [
17+
(gogoproto.nullable) = false,
18+
(gogoproto.customtype) = "JsonInput"
19+
];
20+
ClassConfig config = 7 [(gogoproto.nullable) = false];
21+
}
22+
23+
message ClassParentInput {
24+
ClassParentType type = 1;
25+
string iscn_id_prefix = 2 [(gogoproto.nullable) = true];
26+
// for account, infers to use message sender's address
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
import "gogoproto/gogo.proto";
6+
import "google/protobuf/timestamp.proto";
7+
8+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
9+
10+
message ClassRevealQueueEntry {
11+
google.protobuf.Timestamp reveal_time = 1 [
12+
(gogoproto.stdtime) = true,
13+
(gogoproto.nullable) = false
14+
];
15+
string class_id = 2;
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
import "gogoproto/gogo.proto";
6+
7+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
8+
9+
message ClassesByAccount {
10+
string account = 1;
11+
repeated string class_ids = 2;
12+
}
13+
14+
message ClassesByAccountStoreRecord {
15+
bytes acc_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
16+
repeated string class_ids = 2;
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
syntax = "proto3";
2+
3+
package likechain.likenft.v1;
4+
5+
option go_package = "github.com/likecoin/likecoin-chain/v3/x/likenft/types";
6+
7+
message ClassesByISCN {
8+
string iscn_id_prefix = 1;
9+
repeated string class_ids = 2;
10+
}

0 commit comments

Comments
 (0)