Skip to content
Playground(another site)

bynk.event.emit_outside_owner

Error Events.emit[E] named an event E not declared in the emitting context — only an event's declaring context may emit it.

Only the context that declares an event may emit it. A consumer can see the event through consumes, to subscribe to it with from Events(…), but being able to name a type does not make it yours to forge: other contexts then could not trust that an event came from its owner. Emit an event of your own, or call a service of the owning context and let it emit.

Example

orders.bynk
context orders
exports transparent { Paid }
event Paid = { id: String }
// mailer.bynk
context mailer
consumes orders
consumes bynk { Events }
event Sent = { id: String }
Events.emit[Paid](Paid { id: "x" }) // ✗ `Paid` belongs to `orders`
Events.emit[Sent](Sent { id: "x" }) // ✓ `Sent` is declared here

In the Book

See also

  • Every code in its category, Events, on the diagnostic index.
  • bynk explain bynk.event.emit_outside_owner shows the same from the installed toolchain, without a network.