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: add additional fields into x/collection events #638

Merged
merged 3 commits into from
Aug 16, 2022
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
5 changes: 5 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13918,6 +13918,7 @@ Since: 0.46.0 (finschia)

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `creator` | [string](#string) | | address which created the contract. |
| `contract_id` | [string](#string) | | contract id associated with the contract. |
| `name` | [string](#string) | | name of the contract. |
| `meta` | [string](#string) | | metadata of the contract. |
Expand All @@ -13939,6 +13940,7 @@ Since: 0.46.0 (finschia)
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `contract_id` | [string](#string) | | contract id associated with the contract. |
| `operator` | [string](#string) | | address which triggered the create. |
| `class_id` | [string](#string) | | class id associated with the token class. |
| `name` | [string](#string) | | name of the token class. |
| `meta` | [string](#string) | | metadata of the token class. |
Expand All @@ -13961,6 +13963,7 @@ Since: 0.46.0 (finschia)
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `contract_id` | [string](#string) | | contract id associated with the contract. |
| `operator` | [string](#string) | | address which triggered the create. |
| `class_id` | [string](#string) | | class id associated with the token class. |
| `name` | [string](#string) | | name of the token class. |
| `meta` | [string](#string) | | metadata of the token class. |
Expand All @@ -13984,6 +13987,7 @@ Since: 0.46.0 (finschia)
| `operator` | [string](#string) | | address which triggered the detach. |
| `holder` | [string](#string) | | address which holds the token. |
| `subject` | [string](#string) | | token being detached. |
| `previous_parent` | [string](#string) | | parent token before the detach. |



Expand Down Expand Up @@ -14105,6 +14109,7 @@ Since: 0.46.0 (finschia)
| `operator` | [string](#string) | | address which triggered the modify. |
| `class_id` | [string](#string) | | class id associated with the token class. |
| `changes` | [Attribute](#lbm.collection.v1.Attribute) | repeated | changes of the attributes applied. |
| `type_name` | [string](#string) | | type name of the token class. |



Expand Down
34 changes: 22 additions & 12 deletions proto/lbm/collection/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ message EventRevokedOperator {
//
// Since: 0.46.0 (finschia)
message EventCreatedContract {
// address which created the contract.
string creator = 1;
// contract id associated with the contract.
string contract_id = 1;
string contract_id = 2;
// name of the contract.
string name = 2;
string name = 3;
// metadata of the contract.
string meta = 3;
string meta = 4;
// uri for the contract image stored off chain.
string base_img_uri = 4;
string base_img_uri = 5;
}

// EventCreatedFTClass is emitted when a new fungible token class is created.
Expand All @@ -134,16 +136,18 @@ message EventCreatedContract {
message EventCreatedFTClass {
// contract id associated with the contract.
string contract_id = 1;
// address which triggered the create.
string operator = 2;
// class id associated with the token class.
string class_id = 2;
string class_id = 3;
// name of the token class.
string name = 3;
string name = 4;
// metadata of the token class.
string meta = 4;
string meta = 5;
// decimals of the token class.
int32 decimals = 5;
int32 decimals = 6;
// mintable represents whether the token class is allowed to mint or burn its tokens.
bool mintable = 6;
bool mintable = 7;
}

// EventCreatedNFTClass is emitted when a new non-fungible token class is created.
Expand All @@ -152,12 +156,14 @@ message EventCreatedFTClass {
message EventCreatedNFTClass {
// contract id associated with the contract.
string contract_id = 1;
// address which triggered the create.
string operator = 2;
// class id associated with the token class.
string class_id = 2;
string class_id = 3;
// name of the token class.
string name = 3;
string name = 4;
// metadata of the token class.
string meta = 4;
string meta = 5;
}

// EventGrant is emitted when a granter grants its permission to a grantee.
Expand Down Expand Up @@ -254,6 +260,8 @@ message EventModifiedTokenClass {
string class_id = 3;
// changes of the attributes applied.
repeated Attribute changes = 4 [(gogoproto.nullable) = false];
// type name of the token class.
string type_name = 5;
}

// EventModifiedNFT is emitted when the information of a non-fungible token is modified.
Expand Down Expand Up @@ -298,6 +306,8 @@ message EventDetached {
string holder = 3;
// token being detached.
string subject = 4;
// parent token before the detach.
string previous_parent = 5;
}

// EventOwnerChanged is emitted when the owner of token is changed by operation applied to its ancestor.
Expand Down
8 changes: 4 additions & 4 deletions x/collection/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func AttributeKeyFromString(name string) AttributeKey {
}

// Deprecated: use EventCreatedContract.
func NewEventCreateCollection(event EventCreatedContract, creator sdk.AccAddress) sdk.Event {
func NewEventCreateCollection(event EventCreatedContract) sdk.Event {
eventType := EventTypeCreateCollection.String()
attributes := map[AttributeKey]string{
AttributeKeyContractID: event.ContractId,
AttributeKeyName: event.Name,
AttributeKeyMeta: event.Meta,
AttributeKeyBaseImgURI: event.BaseImgUri,

AttributeKeyOwner: creator.String(),
AttributeKeyOwner: event.Creator,
}

res := sdk.NewEvent(eventType)
Expand All @@ -54,7 +54,7 @@ func NewEventCreateCollection(event EventCreatedContract, creator sdk.AccAddress
}

// Deprecated: use EventCreatedFTClass.
func NewEventIssueFT(event EventCreatedFTClass, operator, to sdk.AccAddress, amount sdk.Int) sdk.Event {
func NewEventIssueFT(event EventCreatedFTClass, to sdk.AccAddress, amount sdk.Int) sdk.Event {
eventType := EventTypeIssueFT.String()
attributes := map[AttributeKey]string{
AttributeKeyContractID: event.ContractId,
Expand All @@ -64,7 +64,7 @@ func NewEventIssueFT(event EventCreatedFTClass, operator, to sdk.AccAddress, amo
AttributeKeyDecimals: fmt.Sprintf("%d", event.Decimals),
AttributeKeyMintable: fmt.Sprintf("%t", event.Mintable),

AttributeKeyOwner: operator.String(),
AttributeKeyOwner: event.Operator,
AttributeKeyTo: to.String(),
AttributeKeyAmount: amount.String(),
}
Expand Down
Loading