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: implement x/collection #574

Merged
merged 89 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
a1bd2c1
feat: define x/collection proto
0Tech May 24, 2022
e8ef9d1
feat: update proto
0Tech May 30, 2022
a5be418
feat: add event_spent and event_received
0Tech May 30, 2022
91b84af
feat: add x/collection to simapp
0Tech May 30, 2022
4772e08
feat: implement send
0Tech May 30, 2022
934669a
feat: add getters to classes
0Tech May 31, 2022
ef0e5a6
feat: implement create
0Tech May 30, 2022
9a2001c
feat: add new msgs and deprecate the old ones
0Tech Jun 2, 2022
9857ace
fix: fix the type of the event fields
0Tech Jun 2, 2022
e830346
feat: add new queries and deprecate the old ones
0Tech Jun 3, 2022
9cad6cf
feat: implement msgs
0Tech Jun 3, 2022
d37c105
fix: use coins
0Tech Jun 9, 2022
06fc5fc
feat: implement authorization logic
0Tech Jun 9, 2022
e9ef079
feat: implement grant
0Tech Jun 9, 2022
cc357e9
feat: implement nft
0Tech Jun 13, 2022
9278448
feat: implement genesis
0Tech Jun 13, 2022
cd81839
docs: update documents on proto
0Tech Jun 15, 2022
8260807
docs: update version information in the comments
0Tech Jun 15, 2022
c6ec4a0
docs: update ERC777 related comments
0Tech Jun 15, 2022
7f360c4
test: add tests on genesis
0Tech Jun 15, 2022
1a88643
feat: update protos
0Tech Jun 23, 2022
4d86120
fix: fix export genesis
0Tech Jun 24, 2022
6f85fc2
feat: return the id of the created entity
0Tech Jun 24, 2022
b94f926
feat: add next ids to genesis state
0Tech Jun 24, 2022
a34cc8f
feat: add queries
0Tech Jun 24, 2022
97e62f8
fix: split EventMinted
0Tech Jun 27, 2022
4d90df4
feat: update field names and comments in tx proto
0Tech Jun 27, 2022
fc7bd52
feat: update comments in query proto
0Tech Jun 27, 2022
8a5990d
fix: fix event types and update proto
0Tech Jun 27, 2022
c259200
feat: add query client
0Tech Jun 28, 2022
483dd61
feat: add nft to genesis
0Tech Jun 28, 2022
c18f2a4
fix: fix parents iterator
0Tech Jun 28, 2022
ab2ecc3
lint: suppress unused for a while
0Tech Jun 28, 2022
d6f404f
feat: enable servers
0Tech Jun 28, 2022
f64ba90
refactor: remove ValidateNFTID() of keeper
0Tech Jun 28, 2022
dccfaab
Merge branch 'main' into collection
0Tech Jun 28, 2022
f3e89cf
docs: update CHANGELOG.md
0Tech Jun 28, 2022
255155d
feat: implement mint and burn
0Tech Jun 28, 2022
533e50a
test: increase coverage of msgs.go
0Tech Jun 29, 2022
6f9a354
test: increase coverage of msg_server.go
0Tech Jun 29, 2022
ff0a868
test: add tests on grpc_query.go
0Tech Jun 30, 2022
7d52147
Merge branch 'main' into collection
0Tech Jun 30, 2022
b78d41a
feat: implement attach and detach
0Tech Jun 30, 2022
bb2ec23
refactor: remove validateRoot
0Tech Jul 4, 2022
44f57ea
feat: implement modify
0Tech Jul 4, 2022
d849db8
test: burn tokens
0Tech Jul 4, 2022
6f5bb2e
lint: lint
0Tech Jul 5, 2022
86a3a26
feat: add Msg/CreateFTClass and Msg/CreateNFTClass
0Tech Jul 5, 2022
bd33bd0
fix: remove an interface TokenClass from proto
0Tech Jul 6, 2022
0b26c64
feat: add Query/TokenClassTypeURL
0Tech Jul 6, 2022
e1702b4
feat: add tx cli
0Tech Jul 6, 2022
5c506bf
docs: update deprecated comments
0Tech Jul 7, 2022
8cca778
test: add tests for collection types
0Tech Jul 7, 2022
f48646b
lint: add a exclude rule for the deprecated collection proto
0Tech Jul 7, 2022
2d68f6c
feat: add mintable logic
0Tech Jul 7, 2022
da4d7ea
feat: limit the number of descendants (NFT)
0Tech Jul 8, 2022
a0d1b4b
test: remove redundant test cases
0Tech Jul 8, 2022
56b01ec
fix: fix naming collision in enums
0Tech Jul 8, 2022
65ae5d7
feat: add legacy events
0Tech Jul 11, 2022
1183d6a
feat: emit operation events (daphne compat.)
0Tech Jul 12, 2022
e315585
chore: remove the commented logic
0Tech Jul 12, 2022
b8a3ac7
docs: add error conditions to tx proto
0Tech Jul 12, 2022
902917b
Merge branch 'main' into collection
0Tech Jul 12, 2022
4512e1b
feat: add depth and width limit on attach
0Tech Jul 13, 2022
cda1a89
feat: add params for the limits
0Tech Jul 13, 2022
1147933
test: check attribute_key_to
0Tech Jul 13, 2022
681d752
fix: emit legacy event against the original request
0Tech Jul 14, 2022
8a9c401
chore: put the logics after get_client_context except setting from
0Tech Jul 14, 2022
a701abc
fix: revisit creation logics
0Tech Jul 14, 2022
a01c026
feat: add tx cli to the module
0Tech Jul 15, 2022
ad3c142
chore: clean up legacy logic
0Tech Jul 15, 2022
6289832
chore: remove commented routerkey
0Tech Jul 15, 2022
65ef698
feat: update genesis validation
0Tech Jul 15, 2022
c25c571
docs: add hints to the deprecation message
0Tech Jul 15, 2022
abac9d7
Merge branch 'main' into collection
0Tech Jul 15, 2022
352e22c
chore: fix typo
0Tech Jul 15, 2022
52855d0
fix: completely remove the rejected spec
0Tech Jul 15, 2022
b9e2c45
refactor: remove duplicate logic
0Tech Jul 15, 2022
9ed5843
chore: completely remove Query/NFTs
0Tech Jul 15, 2022
0cb7c8b
fix: correct event emissions
0Tech Jul 15, 2022
35644f4
chore: literal to nil
0Tech Jul 15, 2022
ec33cbe
fix: use returned error
0Tech Jul 15, 2022
d5bd89b
lint: use literal to avoid false negative
0Tech Jul 15, 2022
ffabd85
chore: remove unimplemented logics
0Tech Jul 18, 2022
363d651
chore: remove unused id logic and deprecate old ones
0Tech Jul 18, 2022
5216dc9
feat: add a validation on params
0Tech Jul 18, 2022
b4549db
feat: add telemetry on account creation
0Tech Jul 18, 2022
0d6c2b6
Merge branch 'main' into collection
0Tech Jul 18, 2022
cbe6f87
style: use variable name other than 'new'
0Tech Jul 18, 2022
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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ issues:
- text: "SA1019: codec.LegacyAmino is deprecated"
linters:
- staticcheck
- text: "SA1019: collection."
linters:
- staticcheck
max-issues-per-linter: 10000
max-same-issues: 10000

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/foundation) [\#518](https://github.com/line/lbm-sdk/pull/518) add foundation treasury feature to x/foundation
* (x/foundation) [\#528](https://github.com/line/lbm-sdk/pull/528) add a feature of whitelist for /lbm.foundation.v1.MsgWithdrawFromTreasury
* (proto) [\#584](https://github.com/line/lbm-sdk/pull/564) remove `prove` field in the `GetTxsEventRequest` of `tx` proto
* (x/collection) [\#574](https://github.com/line/lbm-sdk/pull/574) implement x/collection

### Improvements

Expand Down
3,801 changes: 3,801 additions & 0 deletions docs/core/proto-docs.md

Large diffs are not rendered by default.

213 changes: 213 additions & 0 deletions proto/lbm/collection/v1/collection.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
syntax = "proto3";
package lbm.collection.v1;

option go_package = "github.com/line/lbm-sdk/x/collection";
option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

// Params defines the parameters for the collection module.
message Params {
uint32 depth_limit = 1;
uint32 width_limit = 2;
}

// Contract defines the information of the contract for the collection.
message Contract {
// contract_id defines the unique identifier of the contract.
string contract_id = 1;
// name defines the human-readable name of the contract.
string name = 2;
// meta is a brief description of the contract.
string meta = 3;
// base img uri is an uri for the contract image stored off chain.
string base_img_uri = 4;
}

// FTClass defines the class of fungible token.
//
// Since: 0.46.0 (finschia)
message FTClass {
option (gogoproto.goproto_getters) = true;
option (cosmos_proto.implements_interface) = "TokenClass";

// id defines the unique identifier of the token class.
// Note: size of the class id is 8 in length.
// Note: token id of the fungible token would be `id` + `00000000`.
string id = 1;
// name defines the human-readable name of the token class.
string name = 2;
// meta is a brief description of the token class.
string meta = 3;
// decimals is the number of decimals which one must divide the amount by to get its user representation.
int32 decimals = 4;
// mintable represents whether the token class is allowed to mint or burn its tokens.
bool mintable = 5;
}

// NFTClass defines the class of non-fungible token.
//
// Since: 0.46.0 (finschia)
message NFTClass {
option (gogoproto.goproto_getters) = true;
option (cosmos_proto.implements_interface) = "TokenClass";

// id defines the unique identifier of the token class.
// Note: size of the class id is 8 in length.
string id = 1;
// name defines the human-readable name of the token class.
string name = 2;
// meta is a brief description of the token class.
string meta = 3;
}

// NFT defines the information of non-fungible token.
//
// Since: 0.46.0 (finschia)
message NFT {
// id defines the unique identifier of the token.
string id = 1;
// name defines the human-readable name of the token.
string name = 2;
// meta is a brief description of the token.
string meta = 3;
}

// Deprecated: use NFT
//
// OwnerNFT defines the information of non-fungible token.
message OwnerNFT {
option (cosmos_proto.implements_interface) = "Token";

// contract id associated with the contract.
string contract_id = 1;
// id defines the unique identifier of the token.
string token_id = 2;
// name defines the human-readable name of the token.
string name = 3;
// meta is a brief description of the token.
string meta = 4;

// owner of the token.
string owner = 5;
}

// Deprecated: use FTClass
//
// FT defines the information of fungible token.
message FT {
option (cosmos_proto.implements_interface) = "Token";

// contract id associated with the contract.
string contract_id = 1;
// token id defines the unique identifier of the fungible token.
string token_id = 2;
// name defines the human-readable name of the fungible token.
string name = 3;
// meta is a brief description of the fungible token.
string meta = 4;
// decimals is the number of decimals which one must divide the amount by to get its user representation.
int32 decimals = 5;
// mintable represents whether the fungible token is allowed to be minted or burnt.
bool mintable = 6;
}

// Deprecated: use TokenClass
//
// TokenType defines the information of token type.
message TokenType {
// contract id associated with the contract.
string contract_id = 1;
// token type defines the unique identifier of the token type.
string token_type = 2;
// name defines the human-readable name of the token type.
string name = 3;
// meta is a brief description of the token type.
string meta = 4;
}

// Coin defines a token with a token id and an amount.
message Coin {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = true;

// token id associated with the token.
string token_id = 1;
// amount of the token.
string amount = 2 [(gogoproto.customtype) = "github.com/line/lbm-sdk/types.Int", (gogoproto.nullable) = false];
}

// Grant defines permission given to a grantee.
//
// Since: 0.46.0 (finschia)
message Grant {
// address of the grantee.
string grantee = 1;
// permission on the contract.
Permission permission = 2;
}

// Permission enumerates the valid permissions on a contract.
enum Permission {
option (gogoproto.goproto_enum_prefix) = false;

// unspecified defines the default permission which is invalid.
PERMISSION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "PermissionUnspecified"];

// PERMISSION_ISSUE defines a permission to create a token class.
PERMISSION_ISSUE = 1 [(gogoproto.enumvalue_customname) = "PermissionIssue"];
// PERMISSION_MODIFY defines a permission to modify a contract.
PERMISSION_MODIFY = 2 [(gogoproto.enumvalue_customname) = "PermissionModify"];
// PERMISSION_MINT defines a permission to mint tokens of a contract.
PERMISSION_MINT = 3 [(gogoproto.enumvalue_customname) = "PermissionMint"];
// PERMISSION_BURN defines a permission to burn tokens of a contract.
PERMISSION_BURN = 4 [(gogoproto.enumvalue_customname) = "PermissionBurn"];
}

// Deprecated: use Permission
//
// LegacyPermission enumerates the valid permissions on a contract.
enum LegacyPermission {
option (gogoproto.goproto_enum_stringer) = false;
option (gogoproto.goproto_enum_prefix) = false;

// unspecified defines the default permission which is invalid.
LEGACY_PERMISSION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "LegacyPermissionUnspecified"];

// issue defines a permission to create a token class.
LEGACY_PERMISSION_ISSUE = 1 [(gogoproto.enumvalue_customname) = "LegacyPermissionIssue"];
// modify defines a permission to modify a contract.
LEGACY_PERMISSION_MODIFY = 2 [(gogoproto.enumvalue_customname) = "LegacyPermissionModify"];
// mint defines a permission to mint tokens of a contract.
LEGACY_PERMISSION_MINT = 3 [(gogoproto.enumvalue_customname) = "LegacyPermissionMint"];
// burn defines a permission to burn tokens of a contract.
LEGACY_PERMISSION_BURN = 4 [(gogoproto.enumvalue_customname) = "LegacyPermissionBurn"];
}

// Authorization defines an authorization given to the operator on tokens of the holder.
//
// Since: 0.46.0 (finschia)
message Authorization {
// address of the holder which authorizes the manipulation of its tokens.
string holder = 1;
// address of the operator which the authorization is granted to.
string operator = 2;
}

// Attribute defines a key and value of the attribute.
//
// Since: 0.46.0 (finschia)
message Attribute {
string key = 1;
string value = 2;
}

// Deprecated: use Attribute
//
// Change defines a field-value pair.
message Change {
string field = 1;
string value = 2;
}
Loading