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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

render_example_test.gno

2.96 Kb · 60 lines
 1package dev
 2
 3// ExampleRender pins the device index. It carries no chain value, so it does
 4// not move with the block height the way the devices themselves do.
 5func ExampleRender() {
 6	print(Render(""))
 7	// Output:
 8	// # /dev
 9	//
10	// The chain as a Plan 9 device tree. Each file is a function: reading it runs code, so `/dev/height` is never stale.
11	//
12	// Posted to [`r/moul/x/plan9/ns`](/r/nym-moultest123/x/plan9/ns/v1)'s `/srv` at deploy time, so no realm has to import this one to use it:
13	//
14	// ```
15	// bind /srv/dev /dev
16	// ```
17	//
18	// | device | contents |
19	// |---|---|
20	// | [`caller`](/r/nym-moultest123/x/plan9/dev/v1:cat/caller) | pkgpath of the realm that crossed into this read |
21	// | [`domain`](/r/nym-moultest123/x/plan9/dev/v1:cat/domain) | the chain domain |
22	// | [`drivers`](/r/nym-moultest123/x/plan9/dev/v1:cat/drivers) | this table |
23	// | [`height`](/r/nym-moultest123/x/plan9/dev/v1:cat/height) | current block height |
24	// | [`null`](/r/nym-moultest123/x/plan9/dev/v1:cat/null) | always empty; the bit bucket |
25	// | [`random`](/r/nym-moultest123/x/plan9/dev/v1:cat/random) | sha256 of chain id and height, hex; block-deterministic, NOT unpredictable |
26	// | [`session`](/r/nym-moultest123/x/plan9/dev/v1:cat/session) | the calling key's session scope, one AllowPath per line |
27	// | [`sysname`](/r/nym-moultest123/x/plan9/dev/v1:cat/sysname) | the chain id |
28	// | [`time`](/r/nym-moultest123/x/plan9/dev/v1:cat/time) | block time, RFC3339 |
29	// | [`user`](/r/nym-moultest123/x/plan9/dev/v1:cat/user) | the origin caller's address |
30	// | [`zero`](/r/nym-moultest123/x/plan9/dev/v1:cat/zero) | endless NUL bytes; reads exactly what you ask for |
31	//
32	// Design and analysis: [moul/gno-contracts#136](https://github.com/moul/gno-contracts/issues/136).
33	//
34	// _Not affiliated with Plan 9. Plan 9 from Bell Labs is the work of the Computing Science Research Center at Bell Labs; the name and the marks are theirs, and the copyright is held by the [Plan 9 Foundation](https://p9f.org). This realm borrows the vocabulary and none of the code: it is an homage, asking what that ecosystem's spirit looks like on a chain._
35}
36
37// ExampleRender_cat pins one device read. /dev/drivers is the one device whose
38// contents are fixed, which makes it the only one an example can assert; the
39// chain-derived ones are checked against chain/runtime in dev_test.gno.
40func ExampleRender_cat() {
41	print(Render("cat/drivers"))
42	// Output:
43	// # /dev/drivers
44	//
45	// ```
46	// caller	pkgpath of the realm that crossed into this read
47	// domain	the chain domain
48	// drivers	this table
49	// height	current block height
50	// null	always empty; the bit bucket
51	// random	sha256 of chain id and height, hex; block-deterministic, NOT unpredictable
52	// session	the calling key's session scope, one AllowPath per line
53	// sysname	the chain id
54	// time	block time, RFC3339
55	// user	the origin caller's address
56	// zero	endless NUL bytes; reads exactly what you ask for
57	// ```
58	//
59	// [all devices](/r/nym-moultest123/x/plan9/dev/v1)
60}