Skip to content

Commit

Permalink
Merge pull request #663 from UnUniFi/nftfactory
Browse files Browse the repository at this point in the history
nftfactory Repair (mainly Class ID)
  • Loading branch information
kimurayu45z authored Aug 14, 2023
2 parents 80591a2 + 0dbd12e commit d5c513b
Show file tree
Hide file tree
Showing 62 changed files with 3,252 additions and 6,754 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v `go list ./... | grep -v -E 'deprecated/|x/ecosystemincentive/|x/nftfactory/'`
run: go test -v `go list ./... | grep -v -E 'x/ecosystemincentive/'`
7 changes: 6 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ func NewAppKeeper(
appKeepers.BankKeeper,
)

appKeepers.UnUniFiNFTKeeper = ununifinftkeeper.NewKeeper(appKeepers.NFTKeeper, appCodec)
appKeepers.UnUniFiNFTKeeper = ununifinftkeeper.NewKeeper(
appKeepers.NFTKeeper,
appCodec,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -451,6 +455,7 @@ func NewAppKeeper(
appKeepers.keys[nftfactorytypes.MemStoreKey],
appKeepers.GetSubspace(nftfactorytypes.ModuleName),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.UnUniFiNFTKeeper,
)

Expand Down
4 changes: 4 additions & 0 deletions proto/ununifi/nft/nft.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import "google/protobuf/any.proto";

option go_package = "github.com/UnUniFi/chain/x/nft/types";

message ClassData {
string send_prehook_contract = 1;
}

message NftData {
bool send_disabled = 1;
}
42 changes: 16 additions & 26 deletions proto/ununifi/nftfactory/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,30 @@ import "ununifi/nftfactory/nftfactory.proto";
option go_package = "github.com/UnUniFi/chain/x/nftfactory/types";

message EventCreateClass {
string owner = 1;
string class_id = 2;
string base_token_uri = 3;
string token_supply_cap = 4;
MintingPermission minting_permission = 5;
}

message EventSendClassOwnership {
string sender = 1;
string receiver = 2;
string class_id = 3;
}

message EventUpdateBaseTokenUri {
string owner = 1;
string class_id = 2;
string base_token_uri = 3;
string class_id = 2;
}

message EventUpdateTokenSupplyCap {
string owner = 1;
string class_id = 2;
string token_supply_cap = 3;
message EventUpdateClass {
string sender = 1;
string class_id = 2;
}

message EventMintNFT {
string class_id = 1;
string nft_id = 2;
string owner = 3;
string minter = 4;
string sender = 1;
string class_id = 2;
string token_id = 3;
string recipient = 4;
}

message EventBurnNFT {
string burner = 1;
string sender = 1;
string class_id = 2;
string nft_id = 3;
string token_id = 3;
}

message EventChangeAdmin {
string admin = 1;
string class_id = 3;
string new_admin = 2;
}
16 changes: 13 additions & 3 deletions proto/ununifi/nftfactory/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ option go_package = "github.com/UnUniFi/chain/x/nftfactory/types";

// GenesisState defines the nftfactory module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.moretags) = "yaml:\"params\"", (gogoproto.nullable) = false];
repeated ClassAttributes class_attributes_list = 2
[(gogoproto.moretags) = "yaml:\"class_attributes_list\"", (gogoproto.nullable) = false];
Params params = 1 [(gogoproto.moretags) = "yaml:\"params\"", (gogoproto.nullable) = false];
repeated GenesisClass classes = 2
[(gogoproto.moretags) = "yaml:\"class_ownerships\"", (gogoproto.nullable) = false];
}

message GenesisClass {
option (gogoproto.equal) = true;

string class_id = 1 [ (gogoproto.moretags) = "yaml:\"class_id\"" ];
ClassAuthorityMetadata authority_metadata = 2 [
(gogoproto.moretags) = "yaml:\"authority_metadata\"",
(gogoproto.nullable) = false
];
}
46 changes: 17 additions & 29 deletions proto/ununifi/nftfactory/nftfactory.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,28 @@ syntax = "proto3";
package ununifi.nftfactory;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/UnUniFi/chain/x/nftfactory/types";

enum MintingPermission {
OnlyOwner = 0;
Anyone = 1;
// WhiteList = 2;
}

message ClassAttributes {
string class_id = 1;
string owner = 2;
string base_token_uri = 3;
MintingPermission minting_permission = 4;
uint64 token_supply_cap = 5;
}
// ClassAuthorityMetadata specifies metadata for addresses that have specific
// capabilities over a nft factory class. Right now there is only one Admin
// permission, but is planned to be extended to the future.
message ClassAuthorityMetadata {
option (gogoproto.equal) = true;

message OwningClassIdList {
string owner = 1;
repeated string class_id = 2;
}

message ClassNameIdList {
string class_name = 1;
repeated string class_id = 2;
// Can be empty for no admin, or a valid address
string Admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ];
}

message Params {
uint64 MaxNFTSupplyCap = 1;
uint64 MinClassNameLen = 2;
uint64 MaxClassNameLen = 3;
uint64 MinUriLen = 4;
uint64 MaxUriLen = 5;
uint64 MaxSymbolLen = 6;
uint64 MaxDescriptionLen = 7;
// ClassCreationFee is the fee required to create a new denom using the nftfactory module
repeated cosmos.base.v1beta1.Coin class_creation_fee = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
(gogoproto.nullable) = false
];

// FeeCollectorAddress is the address where fees collected from denom creation are sent to
string fee_collector_address = 2;
}
61 changes: 26 additions & 35 deletions proto/ununifi/nftfactory/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,41 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ununifi/nftfactory/params";
}
rpc ClassAttributes(QueryClassAttributesRequest) returns (QueryClassAttributesResponse) {
option (google.api.http).get = "/ununifi/nftfactory/class_owner/{class_id}";
rpc ClassAuthorityMetadata(QueryClassAuthorityMetadataRequest)
returns (QueryClassAuthorityMetadataResponse) {
option (google.api.http).get =
"/ununifi/nftfactory/class/factory/{creator}/{subclass}/authority-metadata";
}
rpc NFTMinter(QueryNFTMinterRequest) returns (QueryNFTMinterResponse) {
option (google.api.http).get = "/ununifi/nftfactory/nft_minter/{class_id}/{nft_id}";
}
rpc ClassIdsByName(QueryClassIdsByNameRequest) returns (QueryClassIdsByNameResponse) {
option (google.api.http).get = "/ununifi/nftfactory/class_ids_by_name/{class_name}";
}
rpc ClassIdsByOwner(QueryClassIdsByOwnerRequest) returns (QueryClassIdsByOwnerResponse) {
option (google.api.http).get = "/ununifi/nftfactory/class_ids_by_owner/{owner}";
rpc ClassesFromCreator(QueryClassesFromCreatorRequest)
returns (QueryClassesFromCreatorResponse) {
option (google.api.http).get =
"/ununifi/nftfactory/classes-from-creator/{creator}";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

message QueryClassAttributesRequest {
string class_id = 1;
}
message QueryClassAttributesResponse {
ClassAttributes class_attributes = 1;
}

message QueryNFTMinterRequest {
string class_id = 1;
string nft_id = 2;
}
message QueryNFTMinterResponse {
string minter = 1;
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

message QueryClassIdsByNameRequest {
string class_name = 1;
message QueryClassAuthorityMetadataRequest {
string creator = 1 [ (gogoproto.moretags) = "yaml:\"creator\"" ];
string subclass = 2 [ (gogoproto.moretags) = "yaml:\"subclass\"" ];
}
message QueryClassIdsByNameResponse {
ClassNameIdList class_name_id_list = 1;
message QueryClassAuthorityMetadataResponse {
ClassAuthorityMetadata authority_metadata = 1 [
(gogoproto.moretags) = "yaml:\"authority_metadata\"",
(gogoproto.nullable) = false
];
}

message QueryClassIdsByOwnerRequest {
string owner = 1;
}
message QueryClassIdsByOwnerResponse {
OwningClassIdList owning_class_id_list = 1;
message QueryClassesFromCreatorRequest {
string creator = 1 [ (gogoproto.moretags) = "yaml:\"creator\"" ];
}
message QueryClassesFromCreatorResponse {
repeated string classes = 1 [ (gogoproto.moretags) = "yaml:\"classes\"" ];
}
68 changes: 36 additions & 32 deletions proto/ununifi/nftfactory/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,61 @@ option go_package = "github.com/UnUniFi/chain/x/nftfactory/types";

service Msg {
rpc CreateClass(MsgCreateClass) returns (MsgCreateClassResponse);
rpc SendClassOwnership(MsgSendClassOwnership) returns (MsgSendClassOwnershipResponse);
rpc UpdateBaseTokenUri(MsgUpdateBaseTokenUri) returns (MsgUpdateBaseTokenUriResponse);
rpc UpdateTokenSupplyCap(MsgUpdateTokenSupplyCap) returns (MsgUpdateTokenSupplyCapResponse);
rpc UpdateClass(MsgUpdateClass) returns (MsgUpdateClassResponse);
rpc MintNFT(MsgMintNFT) returns (MsgMintNFTResponse);
rpc BurnNFT(MsgBurnNFT) returns (MsgBurnNFTResponse);
rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse);
}

message MsgCreateClass {
string sender = 1;
string name = 2;
string base_token_uri = 3;
uint64 token_supply_cap = 4;
MintingPermission minting_permission = 5;
string symbol = 7;
string description = 8;
string class_uri = 9;
string sender = 1;
string subclass = 2;
string name = 3;
string symbol = 4;
string description = 5;
string uri = 6;
string uri_hash = 7;
}
message MsgCreateClassResponse {}

message MsgSendClassOwnership {
string sender = 1;
string class_id = 2;
string recipient = 3;
}
message MsgSendClassOwnershipResponse {}
message MsgCreateClassResponse {}

message MsgUpdateBaseTokenUri {
string sender = 1;
string class_id = 2;
string base_token_uri = 3;
message MsgUpdateClass {
string sender = 1;
string class_id = 2;
string name = 3;
string symbol = 4;
string description = 5;
string uri = 6;
string uri_hash = 7;
}
message MsgUpdateBaseTokenUriResponse {}

message MsgUpdateTokenSupplyCap {
string sender = 1;
string class_id = 2;
uint64 token_supply_cap = 3;
}
message MsgUpdateTokenSupplyCapResponse {}
message MsgUpdateClassResponse {}

message MsgMintNFT {
string sender = 1;
string class_id = 2;
string nft_id = 3;
string recipient = 4;
string token_id = 3;
string uri = 4;
string uri_hash = 5;
string recipient = 6;
}

message MsgMintNFTResponse {}

message MsgBurnNFT {
string sender = 1;
string class_id = 2;
string nft_id = 3;
string token_id = 3;
}

message MsgBurnNFTResponse {}

// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign
// adminship of a class to a new account
message MsgChangeAdmin {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string class_id = 2 [ (gogoproto.moretags) = "yaml:\"class_id\"" ];
string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ];
}

message MsgChangeAdminResponse {}
Loading

0 comments on commit d5c513b

Please sign in to comment.