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 information into EventXXXChanged #621

Merged
merged 4 commits into from
Aug 6, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/collection) [\#604](https://github.com/line/lbm-sdk/pull/604) add EventOwnerChanged and EventRootChanged
* (x/collection) [\#608](https://github.com/line/lbm-sdk/pull/608) remove new APIs on x/collection
* (x/token) [\#609](https://github.com/line/lbm-sdk/pull/609) remove new APIs on x/token
* (x/collection) [\#621](https://github.com/line/lbm-sdk/pull/621) add additional information into EventXXXChanged

### Bug Fixes
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58279,6 +58279,10 @@ definitions:
timestamp:
type: string
format: date-time
voting_weight:
type: string
format: int64
title: '*** Ostracon Extended Fields ***'
description: >-
DuplicateVoteEvidence contains evidence of a validator
signed two conflicting votes.
Expand Down Expand Up @@ -58459,6 +58463,10 @@ definitions:
proposer_priority:
type: string
format: int64
voting_weight:
type: string
format: int64
title: '*** Ostracon Extended Fields ***'
proposer:
type: object
properties:
Expand All @@ -58483,6 +58491,10 @@ definitions:
proposer_priority:
type: string
format: int64
voting_weight:
type: string
format: int64
title: '*** Ostracon Extended Fields ***'
total_voting_power:
type: string
format: int64
Expand Down Expand Up @@ -58515,6 +58527,10 @@ definitions:
proposer_priority:
type: string
format: int64
voting_weight:
type: string
format: int64
title: '*** Ostracon Extended Fields ***'
total_voting_power:
type: string
format: int64
Expand Down
4 changes: 4 additions & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14120,6 +14120,8 @@ Since: 0.46.0 (finschia)
| ----- | ---- | ----- | ----------- |
| `contract_id` | [string](#string) | | contract id associated with the contract. |
| `token_id` | [string](#string) | | token id associated with the token. |
| `from` | [string](#string) | | address of the previous owner before the change. |
| `to` | [string](#string) | | address of the new owner. |



Expand Down Expand Up @@ -14157,6 +14159,8 @@ Since: 0.46.0 (finschia)
| ----- | ---- | ----- | ----------- |
| `contract_id` | [string](#string) | | contract id associated with the contract. |
| `token_id` | [string](#string) | | token id associated with the token. |
| `from` | [string](#string) | | token id of the previous root before the change. |
| `to` | [string](#string) | | token id of the new root. |



Expand Down
8 changes: 8 additions & 0 deletions proto/lbm/collection/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ message EventOwnerChanged {
string contract_id = 1;
// token id associated with the token.
string token_id = 2;
// address of the previous owner before the change.
string from = 3;
// address of the new owner.
string to = 4;
}

// EventRootChanged is emitted when the root of token is changed by operation applied to its ancestor.
Expand All @@ -318,4 +322,8 @@ message EventRootChanged {
string contract_id = 1;
// token id associated with the token.
string token_id = 2;
// token id of the previous root before the change.
string from = 3;
// token id of the new root.
string to = 4;
}
424 changes: 316 additions & 108 deletions x/collection/event.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions x/collection/keeper/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (k Keeper) Attach(ctx sdk.Context, contractID string, owner sdk.AccAddress,
event := collection.EventRootChanged{
ContractId: contractID,
TokenId: descendantID,
From: subject,
To: root,
}
ctx.EventManager().EmitEvent(collection.NewEventOperationRootChanged(event))
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {
Expand Down Expand Up @@ -131,10 +133,13 @@ func (k Keeper) Detach(ctx sdk.Context, contractID string, owner sdk.AccAddress,
k.deleteChild(ctx, contractID, *parent, subject)

// legacy
root := k.GetRoot(ctx, contractID, *parent)
k.iterateDescendants(ctx, contractID, subject, func(descendantID string, _ int) (stop bool) {
event := collection.EventRootChanged{
ContractId: contractID,
TokenId: descendantID,
From: root,
To: subject,
}
ctx.EventManager().EmitEvent(collection.NewEventOperationRootChanged(event))
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/collection/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func (k Keeper) SendCoins(ctx sdk.Context, contractID string, from, to sdk.AccAd
event := collection.EventOwnerChanged{
ContractId: contractID,
TokenId: descendantID,
From: from.String(),
To: to.String(),
}
ctx.EventManager().EmitEvent(collection.NewEventOperationTransferNFT(event))
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {
Expand Down