Skip to content

Commit

Permalink
fix msg format in EVENTS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
llllllluc committed Jan 22, 2023
1 parent c386f32 commit 38d466a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,34 +166,34 @@ sdk.NewEvent(
sdk.NewEvent(
"instantiate",
sdk.NewAttribute("code_id", fmt.Sprintf("%d", msg.CodeID)),
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
)

// Execute Contract
sdk.NewEvent(
"execute",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
)

// Migrate Contract
sdk.NewEvent(
"migrate",
// Note: this is the new code id that is being migrated to
sdk.NewAttribute("code_id", fmt.Sprintf("%d", msg.CodeID)),
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
)

// Set new admin
sdk.NewEvent(
"update_admin",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("admin", msg.NewAdmin),
)

// Clear admin
sdk.NewEvent(
"clear_admin",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
)

// Pin Code
Expand All @@ -211,7 +211,7 @@ sdk.NewEvent(
// Emitted when processing a submessage reply
sdk.NewEvent(
"reply",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
// If the submessage was successful, and reply is processing the success case
sdk.NewAttribute("mode", "handle_success"),
// If the submessage returned an error that was "caught" by the reply block
Expand All @@ -221,12 +221,12 @@ sdk.NewEvent(
// Emitted when handling sudo
sdk.NewEvent(
"sudo",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
)
```

Note that every event that affects a contract (not store code, pin or unpin) will return the contract_addr as
`_contract_addr`. The events that are related to a particular wasm code (store code, instantiate, pin, unpin, and migrate)
Note that every event that affects a contract (not store code, pin or unpin) will return the contract_address as
`_contract_address`. The events that are related to a particular wasm code (store code, instantiate, pin, unpin, and migrate)
will emit that as `code_id`. All attributes prefixed with `_` are reserved and may not be emitted by a smart contract,
so we use the underscore prefix consistently with attributes that may be injected into custom events.

Expand All @@ -247,14 +247,14 @@ an eg. `transfer` event from the bank module. The output here may look like:
```go
sdk.NewEvent(
"wasm-promote"
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("batch_id", "6"),
sdk.NewAttribute("address", "cosmos1234567"),
sdk.NewAttribute("address", "cosmos1765432"),
),
sdk.NewEvent(
"wasm-promote"
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("batch_id", "7"),
sdk.NewAttribute("address", "cosmos19875632"),
)
Expand All @@ -267,7 +267,7 @@ more than flattening them all into one event like:
```go
sdk.NewEvent(
"wasm"
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("action", "promote"),
sdk.NewAttribute("batch_id", "6"),
sdk.NewAttribute("address", "cosmos1234567"),
Expand Down Expand Up @@ -338,36 +338,36 @@ sdk.NewEvent(
// top-level exection call
sdk.NewEvent(
"execute",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
),
sdk.NewEvent(
"wasm",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("custom", "from contract"),
),

// instantiating contract (first dipatched message)
sdk.NewEvent(
"instantiate",
sdk.NewAttribute("code_id", fmt.Sprintf("%d", msg.CodeID)),
sdk.NewAttribute("_contract_addr", newContract.String()),
sdk.NewAttribute("_contract_address", newContract.String()),
)
// didn't emit any attributes, but one event
sdk.NewEvent(
"wasm-custom",
sdk.NewAttribute("_contract_addr", newContract.String()),
sdk.NewAttribute("_contract_address", newContract.String()),
sdk.NewAttribute("foobar", "baz"),
),

// handling the reply (this doesn't emit a message event as it never goes through the message server)
sdk.NewEvent(
"reply",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("mode", "handle_success"),
),
sdk.NewEvent(
"wasm",
sdk.NewAttribute("_contract_addr", contractAddr.String()),
sdk.NewAttribute("_contract_address", contractAddr.String()),
sdk.NewAttribute("custom", "from contract"),
),

Expand All @@ -389,11 +389,11 @@ field, and the following in the `events` field:
sdk.NewEvent(
"instantiate",
sdk.NewAttribute("code_id", fmt.Sprintf("%d", msg.CodeID)),
sdk.NewAttribute("_contract_addr", newContract.String()),
sdk.NewAttribute("_contract_address", newContract.String()),
)
sdk.NewEvent(
"wasm-custom",
sdk.NewAttribute("_contract_addr", newContract.String()),
sdk.NewAttribute("_contract_address", newContract.String()),
sdk.NewAttribute("foobar", "baz"),
),
```
Expand Down

0 comments on commit 38d466a

Please sign in to comment.