1
1
# Interrealm Specification
2
2
3
- Gno extends Go's type system with a interrealm rules. These rules can be
3
+ Gno extends Go's type system with interrealm rules. These rules can be
4
4
checked during the static type-checking phase (but at the moment they are
5
5
partially dependent on runtime checks).
6
6
@@ -24,7 +24,7 @@ A function declared in a realm package when called:
24
24
25
25
The ` crossing() ` statement must be the first statement of a function's body.
26
26
It is illegal to use anywhere else, and cannot be used in p packages. Functions
27
- that begin with the ` crossing() ` statement are called "crossing" functions".
27
+ that begin with the ` crossing() ` statement are called "crossing functions".
28
28
29
29
A crossing function declared in a realm different than the last explicitly
30
30
crossed realm * must* be called like ` cross(fn)(...) ` . That is, functions of
@@ -54,7 +54,7 @@ else's pen it is still your signature; signature:pen :: current:borrowed.
54
54
A crossing method declared in a realm cannot modify the receiver if the object
55
55
resides in a different realm. However not all methods are required to be
56
56
crossing methods, and crossing methods may still read the state of the
57
- receiver (and in general anything reacheable is readible ).
57
+ receiver (and in general anything reachable is readable ).
58
58
59
59
New unreal objects reachable from the borrowed realm (or current realm if there
60
60
was no method call that borrowed) become persisted in the borrowed realm (or
@@ -68,7 +68,7 @@ MsgCall can only call (realm) crossing functions.
68
68
MsgRun will run a file's ` main() ` function in the user's realm and may call
69
69
both crossing functions and non-crossing functions.
70
70
71
- A realm package's initialization (including init() calls) execute with current
71
+ A realm package's initialization (including ` init() ` calls) execute with current
72
72
realm of itself, and it ` std.PreviousRealm() ` will panic unless the call stack
73
73
includes a crossing function called like ` cross(fn)(...) ` .
74
74
@@ -100,7 +100,7 @@ implicit and generally not obvious without more language features.
100
100
101
101
Code declared in p packages (or declared in "immutable" realm packages) can
102
102
help different realms enforce contracts trustlessly, even those that involve
103
- the caller's current realm. Otherwise two mutable (upgreadeable ) realms cannot
103
+ the caller's current realm. Otherwise two mutable (upgradeable ) realms cannot
104
104
export trust unto the chain because functions declared in those two realms can
105
105
be upgraded.
106
106
@@ -109,19 +109,19 @@ future Gno versions.
109
109
110
110
### Usage
111
111
112
- P package code cannot containing crossing functions, nor use crossing(). P
112
+ P package code cannot contain crossing functions, nor use ` crossing() ` . P
113
113
package code also cannot import R realm packages. But code can call named
114
114
crossing functions e.g. those passed in as parameters.
115
115
116
- You must declare a public realm function to be crossing() if it is intended to
116
+ You must declare a public realm function to be ` crossing() ` if it is intended to
117
117
be called by end users, because users cannot MsgCall non-crossing functions
118
118
(for safety/consistency) or p package functions (there's no point).
119
119
120
120
Utility functions that are a common sequence of non-crossing logic can be
121
121
offered in realm packages as non-crossing functions. These can also import and
122
122
use other realm utility non-crossing functions; whereas p packages cannot
123
123
import realm packages at all. And convenience/utility functions that are being
124
- staged before publishing as permanent p code should also reside in upgreadeable
124
+ staged before publishing as permanent p code should also reside in upgradeable
125
125
realms.
126
126
127
127
Generally you want your methods to be non-crossing. Because they should work
@@ -141,7 +141,7 @@ overrides for testing are defined in `testing/stdlibs/std/std.gno/go`. All
141
141
stdlibs functions are available unless overridden by the latter.
142
142
143
143
` std.CurrentRealm() ` shifts to ` std.PreviousRealm() ` if and only if a function
144
- is called like cross(fn)(...).
144
+ is called like ` cross(fn)(...) ` .
145
145
146
146
#### MsgCall
147
147
@@ -212,7 +212,7 @@ func main() {
212
212
}
213
213
```
214
214
215
- Notice in gnovm/pkg/gnolang/misc.go, the following:
215
+ Notice in ` gnovm/pkg/gnolang/misc.go ` , the following:
216
216
217
217
``` go
218
218
// For keeping record of package & realm coins.
@@ -241,7 +241,7 @@ func DerivePkgBech32Addr(pkgPath string) crypto.Bech32Address {
241
241
```
242
242
243
243
These function names are distinct from what is available in Gno
244
- from stdlibs/std/crypto.gno:
244
+ from ` stdlibs/std/crypto.gno ` :
245
245
246
246
``` go
247
247
// Returns a crypto hash derived pkgPath, unless pkgPath is a MsgRun run path,
@@ -255,14 +255,14 @@ func DerivePkgAddr(pkgPath string) Address {
255
255
1 . ` std.DerivePkgAddr("gno.land/r/name123/realm") ` - bech32 from hash(path)
256
256
2 . ` std.DerivePkgAddr("gno.land/r/g1user/run") ` - bech32 substring "g1user"
257
257
258
- Therefore in the MsgRun file's init() function the previous realm and current
258
+ Therefore in the MsgRun file's ` init() ` function the previous realm and current
259
259
realm have different pkgpaths (the origin caller always has empty pkgpath) but
260
260
the address is the same.
261
261
262
262
#### MsgAddPackage
263
263
264
264
During MsgAddPackage ` std.PreviousRealm() ` refers to the package deployer both
265
- in gloval var decls as well as inside ` init() ` functions. After that the
265
+ in global var decls as well as inside ` init() ` functions. After that the
266
266
package deployer is no longer provided, so packages need to remember the
267
267
deployer in the initialization if needed.
268
268
@@ -320,9 +320,9 @@ The `gnovm/tests/stdlibs/testing/context_testing.gno` file provides functions
320
320
for overriding frame details from Gno test code.
321
321
322
322
` testing.SetRealm(std.NewUserRealm("g1user")) ` is identical to
323
- `testing.SetOriginCaller("g1user"). Both will override the Gno frame to make it
323
+ ` testing.SetOriginCaller("g1user") ` . Both will override the Gno frame to make it
324
324
appear as if the current frame is the end user signing with a hardware signer.
325
- Both will also set ExecContext.OriginCaller to that user. One of these will
325
+ Both will also set ` ExecContext.OriginCaller ` to that user. One of these will
326
326
become deprecated.
327
327
328
328
#### Gno test cases with ` _test.gno ` like ` TestFoo(t *testing.T) `
@@ -421,9 +421,9 @@ func main() {
421
421
422
422
#### Future Work
423
423
424
- std.SetOriginCaller() should maybe be deprecated in favor of
425
- std.SetRealm(std.NewUserRealm(user)) renamed to
426
- std.SetRealm(std.NewOriginRealm(user)).
424
+ ` std.SetOriginCaller() ` should maybe be deprecated in favor of
425
+ ` std.SetRealm(std.NewUserRealm(user)) ` renamed to
426
+ ` std.SetRealm(std.NewOriginRealm(user)) ` .
427
427
428
- std.SetRealm(std.NewCodeRealm(path)) renamed to
429
- std.SetRealm(std.NewPackageRealm(path)).
428
+ ` std.SetRealm(std.NewCodeRealm(path)) ` renamed to
429
+ ` std.SetRealm(std.NewPackageRealm(path)) ` .
0 commit comments