Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Package timelock is a simplified port of OpenZeppelin's TimelockController.

Readme View source

Timelock

⚠️ Experimental — generated with no human supervision by the daily MCP pipeline (Solidity→Gno port). Not audited. See r/moul/x/daily.


A simplified gno.land port of OpenZeppelin's TimelockController. Actions are scheduled with a block delay and can only be executed once the chain reaches the operation's ready height; before that they can be cancelled. It ports the core delay-enforcement idea idiomatically — block height (runtime.ChainHeight()) replaces block.number, panic replaces require, chain.Emit replaces events, and an avl.Tree replaces the Solidity mapping (role-based access control is omitted for simplicity).

Operations are terminal once executed or cancelled, and Render lists every operation with its live state (Pending / Ready / Executed / Cancelled) and the number of blocks remaining until it becomes ready.

Example calls

# Schedule an action to run 20 blocks from now; returns the operation id.
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/timelock/v0 \
  -func Schedule -args "upgrade contract" -args 20 ...

# Once ChainHeight() >= readyHeight, execute it.
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/timelock/v0 \
  -func Execute -args 1 ...

# Or cancel it beforehand.
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/timelock/v0 \
  -func Cancel -args 1 ...

View the queue by rendering the realm (gno.land/r/moul/x/daily/timelock/v0).


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/daily/timelock/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package timelock is a simplified port of OpenZeppelin's TimelockController.

Operations are scheduled with a delay (measured in blocks). A scheduled operation becomes executable only once the chain height reaches the operation's ready height. Until then it can be cancelled by anyone (this simplified port omits role-based access control). Once executed or cancelled, an operation is terminal.

Solidity mapping:

  • block.number -> runtime.ChainHeight()
  • msg.sender -> unsafe.PreviousRealm().Address()
  • require(...) -> panic(...)
  • events -> chain.Emit(...)
  • mapping(id => op) -> avl.Tree keyed by zero-padded id

Constants 1

Functions 6

func BlocksRemaining

Action
1func BlocksRemaining(op *Operation, height int64) int64
source

BlocksRemaining returns how many blocks remain before op is ready (0 if already ready or past).

func Cancel

crossing Action
1func Cancel(cur realm, id int)
source

Cancel drops a pending or ready operation before it executes. It panics if the operation is unknown or already terminal.

func Execute

crossing Action
1func Execute(cur realm, id int)
source

Execute runs a ready operation. It panics if the operation is unknown, already terminal, or not yet ready.

func Render

1func Render(path string) string
source

Render implements the standard realm markdown view.

func Schedule

crossing Action
1func Schedule(cur realm, action string, delayBlocks int) int
source

Schedule registers a new operation to run after delayBlocks blocks and returns its id. delayBlocks must be >= 0.

func StateOf

Action
1func StateOf(op *Operation, height int64) string
source

StateOf returns the display state of op at the given chain height.

Types 1

type Operation

struct
1type Operation struct {
2	ID          int
3	Action      string
4	Proposer    address
5	Scheduled   int64 // chain height at scheduling
6	ReadyHeight int64 // executable once ChainHeight() >= ReadyHeight
7	Done        bool  // executed
8	Cancelled   bool
9}
source

Operation is a single scheduled action.

Imports 6

Source Files 3