Skip to content

Commit b9242f3

Browse files
authored
feat: add additional information into EventXXXChanged (#621)
* Add additional fields to events * Update CHANGELOG.md * Use more specific word in the comment
1 parent 9ba6ea3 commit b9242f3

File tree

8 files changed

+353
-109
lines changed

8 files changed

+353
-109
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
6060
* (x/collection) [\#604](https://github.com/line/lbm-sdk/pull/604) add EventOwnerChanged and EventRootChanged
6161
* (x/collection) [\#608](https://github.com/line/lbm-sdk/pull/608) remove new APIs on x/collection
6262
* (x/token) [\#609](https://github.com/line/lbm-sdk/pull/609) remove new APIs on x/token
63+
* (x/collection) [\#621](https://github.com/line/lbm-sdk/pull/621) add additional information into EventXXXChanged
6364

6465
### Bug Fixes
6566
* (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path

client/docs/statik/statik.go

+1-1
Large diffs are not rendered by default.

client/docs/swagger-ui/swagger.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -58279,6 +58279,10 @@ definitions:
5827958279
timestamp:
5828058280
type: string
5828158281
format: date-time
58282+
voting_weight:
58283+
type: string
58284+
format: int64
58285+
title: '*** Ostracon Extended Fields ***'
5828258286
description: >-
5828358287
DuplicateVoteEvidence contains evidence of a validator
5828458288
signed two conflicting votes.
@@ -58459,6 +58463,10 @@ definitions:
5845958463
proposer_priority:
5846058464
type: string
5846158465
format: int64
58466+
voting_weight:
58467+
type: string
58468+
format: int64
58469+
title: '*** Ostracon Extended Fields ***'
5846258470
proposer:
5846358471
type: object
5846458472
properties:
@@ -58483,6 +58491,10 @@ definitions:
5848358491
proposer_priority:
5848458492
type: string
5848558493
format: int64
58494+
voting_weight:
58495+
type: string
58496+
format: int64
58497+
title: '*** Ostracon Extended Fields ***'
5848658498
total_voting_power:
5848758499
type: string
5848858500
format: int64
@@ -58515,6 +58527,10 @@ definitions:
5851558527
proposer_priority:
5851658528
type: string
5851758529
format: int64
58530+
voting_weight:
58531+
type: string
58532+
format: int64
58533+
title: '*** Ostracon Extended Fields ***'
5851858534
total_voting_power:
5851958535
type: string
5852058536
format: int64

docs/core/proto-docs.md

+4
Original file line numberDiff line numberDiff line change
@@ -14120,6 +14120,8 @@ Since: 0.46.0 (finschia)
1412014120
| ----- | ---- | ----- | ----------- |
1412114121
| `contract_id` | [string](#string) | | contract id associated with the contract. |
1412214122
| `token_id` | [string](#string) | | token id associated with the token. |
14123+
| `from` | [string](#string) | | address of the previous owner before the change. |
14124+
| `to` | [string](#string) | | address of the new owner. |
1412314125

1412414126

1412514127

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

1416114165

1416214166

proto/lbm/collection/v1/event.proto

+8
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ message EventOwnerChanged {
308308
string contract_id = 1;
309309
// token id associated with the token.
310310
string token_id = 2;
311+
// address of the previous owner before the change.
312+
string from = 3;
313+
// address of the new owner.
314+
string to = 4;
311315
}
312316

313317
// EventRootChanged is emitted when the root of token is changed by operation applied to its ancestor.
@@ -318,4 +322,8 @@ message EventRootChanged {
318322
string contract_id = 1;
319323
// token id associated with the token.
320324
string token_id = 2;
325+
// token id of the previous root before the change.
326+
string from = 3;
327+
// token id of the new root.
328+
string to = 4;
321329
}

x/collection/event.pb.go

+316-108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/collection/keeper/nft.go

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ func (k Keeper) Attach(ctx sdk.Context, contractID string, owner sdk.AccAddress,
9898
event := collection.EventRootChanged{
9999
ContractId: contractID,
100100
TokenId: descendantID,
101+
From: subject,
102+
To: root,
101103
}
102104
ctx.EventManager().EmitEvent(collection.NewEventOperationRootChanged(event))
103105
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {
@@ -131,10 +133,13 @@ func (k Keeper) Detach(ctx sdk.Context, contractID string, owner sdk.AccAddress,
131133
k.deleteChild(ctx, contractID, *parent, subject)
132134

133135
// legacy
136+
root := k.GetRoot(ctx, contractID, *parent)
134137
k.iterateDescendants(ctx, contractID, subject, func(descendantID string, _ int) (stop bool) {
135138
event := collection.EventRootChanged{
136139
ContractId: contractID,
137140
TokenId: descendantID,
141+
From: root,
142+
To: subject,
138143
}
139144
ctx.EventManager().EmitEvent(collection.NewEventOperationRootChanged(event))
140145
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {

x/collection/keeper/send.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func (k Keeper) SendCoins(ctx sdk.Context, contractID string, from, to sdk.AccAd
2121
event := collection.EventOwnerChanged{
2222
ContractId: contractID,
2323
TokenId: descendantID,
24+
From: from.String(),
25+
To: to.String(),
2426
}
2527
ctx.EventManager().EmitEvent(collection.NewEventOperationTransferNFT(event))
2628
if err := ctx.EventManager().EmitTypedEvent(&event); err != nil {

0 commit comments

Comments
 (0)