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

fix: fix the order of events #599

Merged
merged 5 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/auth) [\#563](https://github.com/line/lbm-sdk/pull/563) fix unmarshal bug of `BaseAccountJSON`
* (client) [\#565](https://github.com/line/lbm-sdk/pull/565) fix the data race problem in `TestQueryABCIHeight`
* (x/token) [\#589](https://github.com/line/lbm-sdk/pull/589) fix naming collision in x/token enums
* (x/token) [\#599](https://github.com/line/lbm-sdk/pull/599) fix the order of events

### Breaking Changes
* (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path
Expand Down
52 changes: 42 additions & 10 deletions x/token/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewEventIssueToken(e EventIssue, grantee, to sdk.AccAddress, amount sdk.Int
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
zemyblue marked this conversation as resolved.
Show resolved Hide resolved
}
return new
}
Expand All @@ -68,7 +68,7 @@ func NewEventMintToken(e EventMinted) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -84,7 +84,7 @@ func NewEventBurnToken(e EventBurned) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -101,7 +101,7 @@ func NewEventBurnTokenFrom(e EventBurned) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func NewEventTransfer(e EventSent) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -152,7 +152,7 @@ func NewEventTransferFrom(e EventSent) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -164,14 +164,46 @@ func NewEventGrantPermToken(e EventGrant) sdk.Event {
AttributeKeyTo: e.Grantee,
AttributeKeyPerm: LegacyPermission(e.Permission).String(),
}
if e.Granter != e.Grantee {
if len(e.Granter) != 0 {
attributes[AttributeKeyFrom] = e.Granter
}

new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}

func NewEventGrantPermTokenHead(e EventGrant) sdk.Event {
eventType := EventTypeGrantPermToken.String()
attributes := map[AttributeKey]string{
AttributeKeyContractID: e.ContractId,
AttributeKeyTo: e.Grantee,
}
if len(e.Granter) != 0 {
attributes[AttributeKeyFrom] = e.Granter
}

new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new = new.AppendAttributes(attribute)
}
return new
}

func NewEventGrantPermTokenBody(e EventGrant) sdk.Event {
eventType := EventTypeGrantPermToken.String()
attributes := map[AttributeKey]string{
AttributeKeyPerm: LegacyPermission(e.Permission).String(),
}

new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -187,7 +219,7 @@ func NewEventRevokePermToken(e EventAbandon) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Expand All @@ -203,7 +235,7 @@ func NewEventApproveToken(e EventAuthorizedOperator) sdk.Event {
new := sdk.NewEvent(eventType)
for key, value := range attributes {
attribute := sdk.NewAttribute(key.String(), value)
new.AppendAttributes(attribute)
new = new.AppendAttributes(attribute)
}
return new
}
Loading