Skip to content

Commit

Permalink
Add events for setContractAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed Jan 26, 2023
1 parent 0084796 commit 33bf579
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
14 changes: 14 additions & 0 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,20 @@ func (k Keeper) setContractAdmin(ctx sdk.Context, contractAddress, caller, newAd
}
contractInfo.Admin = newAdmin.String()
k.storeContractInfo(ctx, contractAddress, contractInfo)

if newAdmin != nil {
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeUpdateContractAdmin,
sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()),
sdk.NewAttribute(types.AttributeKeyAdmin, newAdmin.String()),
))
} else {
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.EventTypeClearContractAdmin,
sdk.NewAttribute(types.AttributeKeyContractAddr, contractAddress.String()),
))
}

return nil
}

Expand Down
21 changes: 12 additions & 9 deletions x/wasm/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ const (
// CustomContractEventPrefix contracts can create custom events. To not mix them with other system events they got the `wasm-` prefix.
CustomContractEventPrefix = "wasm-"

EventTypeStoreCode = "store_code"
EventTypeInstantiate = "instantiate"
EventTypeExecute = "execute"
EventTypeMigrate = "migrate"
EventTypePinCode = "pin_code"
EventTypeUnpinCode = "unpin_code"
EventTypeSudo = "sudo"
EventTypeReply = "reply"
EventTypeGovContractResult = "gov_contract_result"
EventTypeStoreCode = "store_code"
EventTypeInstantiate = "instantiate"
EventTypeExecute = "execute"
EventTypeMigrate = "migrate"
EventTypePinCode = "pin_code"
EventTypeUnpinCode = "unpin_code"
EventTypeSudo = "sudo"
EventTypeReply = "reply"
EventTypeGovContractResult = "gov_contract_result"
EventTypeUpdateContractAdmin = "update_contract_admin"
EventTypeClearContractAdmin = "clear_contract_admin"
)

// event attributes returned from contract execution
Expand All @@ -26,4 +28,5 @@ const (
AttributeKeyChecksum = "code_checksum"
AttributeKeyResultDataHex = "result"
AttributeKeyRequiredCapability = "required_capability"
AttributeKeyAdmin = "admin"
)

0 comments on commit 33bf579

Please sign in to comment.