diff --git a/examples/gno.land/p/demo/ownable/ownable.gno b/examples/gno.land/p/demo/ownable/ownable.gno index 22c0c33acc6..75ebcde0a28 100644 --- a/examples/gno.land/p/demo/ownable/ownable.gno +++ b/examples/gno.land/p/demo/ownable/ownable.gno @@ -4,6 +4,8 @@ import ( "std" ) +const OwnershipTransferEvent = "OwnershipTransfer" + // Ownable is meant to be used as a top-level object to make your contract ownable OR // being embedded in a Gno object to manage per-object ownership. type Ownable struct { @@ -31,7 +33,13 @@ func (o *Ownable) TransferOwnership(newOwner std.Address) error { return ErrInvalidAddress } + prevOwner := o.owner o.owner = newOwner + std.Emit( + OwnershipTransferEvent, + "from", string(prevOwner), + "to", string(newOwner), + ) return nil } @@ -44,7 +52,15 @@ func (o *Ownable) DropOwnership() error { return err } + prevOwner := o.owner o.owner = "" + + std.Emit( + OwnershipTransferEvent, + "from", string(prevOwner), + "to", "", + ) + return nil }