v0 source pure
v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...
View source
v0 - Unaudited This is an initial version of this package that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
ownable
Package ownable provides an ownership pattern for Gno realms, allowing contracts to restrict access to privileged operations to a designated owner.
v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.
Package ownable provides an ownership pattern for Gno realms, allowing contracts to restrict access to privileged operations to a designated owner.
1
1
1
func NewWithAddress
NewWithAddress creates an Ownable with the given address as owner. This is the only constructor — the previous New/NewWithOrigin/ NewWithAddressByPrevious sugar baked runtime walks and an auth-mode flag into the struct; the realm using this package now picks the owner address explicitly (e.g. cur.Previous().Address() after verifying cur.Previous().IsUserCall() in init).
1
type Ownable
structOwnable 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. Ownable is safe to export as a top-level object.
Authority-mutating methods (TransferOwnership, DropOwnership) take (_ int, rlm realm). The caller threads its own cur; the method asserts rlm.IsCurrent() and identifies the principal as rlm.Previous().Address() — which must equal the current owner.
Read methods (OwnedBy, AssertOwnedBy) keep the bare-address shape; callers extract the address themselves (e.g. cur.Previous().Address()).
Methods on Ownable
func AssertOwnedBy
method on OwnableAssertOwnedBy panics with ErrUnauthorized if addr is not the owner.
func DropOwnership
method on OwnableDropOwnership removes the owner, disabling any owner-related actions. rlm must be the caller's own captured cur; rlm.Previous().Address() must equal the current owner.
func OwnedBy
method on OwnableOwnedBy reports whether addr is the current owner.
func Owner
method on OwnableOwner returns the owner address.
func TransferOwnership
method on OwnableTransferOwnership transfers ownership of the Ownable to newOwner. rlm must be the caller's own captured cur (asserted via rlm.IsCurrent()). The principal is rlm.Previous().Address() — the realm that crossed into the caller — which must equal the current owner.
IsCurrent + rlm.Previous() makes the principal unforgeable: an attacker calling TransferOwnership on a foreign Ownable cannot supply an arbitrary caller address; rlm comes from a runtime-validated crossing frame.
2
- chain stdlib
- errors stdlib