Kind Realm (renderable)
Name v1
Namespace gnoswap / halt
Exported functions 32
Module gno.land/r/gnoswap/halt/v1
gno 0.9 config.gno gno
⧉
1 package halt 2 3 // HaltConfig stores halt state for each operation type. 4 type HaltConfig map [OpType] bool 5 6 // IsHalted returns true if the specified operation is halted, false otherwise. 7 // Returns false if operation type is not found in configuration. AssertIsNotHaltedCommunityPool ()
AssertIsNotHaltedEmission ()
AssertIsNotHaltedGovernance ()
AssertIsNotHaltedGovStaker ()
AssertIsNotHaltedLaunchpad ()
AssertIsNotHaltedOperation (op string)
AssertIsNotHaltedPool ()
AssertIsNotHaltedPosition ()
AssertIsNotHaltedProtocolFee ()
AssertIsNotHaltedRouter ()
AssertIsNotHaltedStaker ()
AssertIsNotHaltedWithdraw ()
AssertIsNotHaltedXGns ()
GetHaltConfig () map[gno.land/r/gnoswap/halt/v1.OpType]bool
GetHaltConfigJson () string
IsHalted (opTypes ...gno.land/r/gnoswap/halt/v1.OpType) (bool, interface {Error func() string})
IsHaltedCommunityPool () bool
IsHaltedEmission () bool
IsHaltedGovernance () bool
IsHaltedGovStaker () bool
IsHaltedLaunchpad () bool
IsHaltedPool () bool
IsHaltedPosition () bool
IsHaltedProtocolFee () bool
IsHaltedRouter () bool
IsHaltedStaker () bool
IsHaltedWithdraw () bool
IsHaltedXGns () bool
OpTypes () []gno.land/r/gnoswap/halt/v1.OpType
Render (path string) string
SetHaltLevel (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, level string)
SetOperationStatus (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, op string, halted bool)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.
8 //
9 // Parameters:
10 // - op: operation type whose halt flag is queried.
11 //
12 // Returns:
13 // - halted: configured halt flag; false when op is absent from the configuration.
14 func (c HaltConfig) IsHalted(op OpType) bool {
15 halted, exists := c[op]
16 if !exists {
17 return false
18 }
19
20 return halted
21 }
22
23 // Clone creates a deep copy of the halt configuration and returns it.
24 //
25 // Returns:
26 // - clone: independent map containing the same operation halt flags as the receiver.
27 func (c HaltConfig) Clone() HaltConfig {
28 clone := make(HaltConfig)
29
30 for op, option := range c {
31 clone[op] = option
32 }
33
34 return clone
35 }
36
37 // get retrieves halt state for the specified operation type.
38 //
39 // Errors:
40 // - errOpTypeNotFound: the specified operation type does not exist in the config
41 func (c HaltConfig) get(op OpType) ( bool , error ) {
42 enabled, exists := c[op]
43 if !exists {
44 return false , makeErrorWithDetails(errOpTypeNotFound, op.String())
45 }
46
47 return enabled, nil
48 }
49
50 // set updates halt state for the specified operation type.
51 // Returns error if operation type is invalid.
52 func (c HaltConfig) set(op OpType, enabled bool ) error {
53 if !op.IsValid() {
54 return makeErrorWithDetails(errInvalidOpType, op.String())
55 }
56
57 c[op] = enabled
58
59 return nil
60 }
61
62 // newNoneConfig creates configuration with all operations enabled (no halts).
63 func newNoneConfig() HaltConfig {
64 return HaltConfig{
65 OpTypePool: false ,
66 OpTypePosition: false ,
67 OpTypeProtocolFee: false ,
68 OpTypeRouter: false ,
69 OpTypeStaker: false ,
70 OpTypeLaunchpad: false ,
71 OpTypeGovernance: false ,
72 OpTypeGovStaker: false ,
73 OpTypeXGns: false ,
74 OpTypeCommunityPool: false ,
75 OpTypeEmission: false ,
76 OpTypeWithdraw: false ,
77 }
78 }
79
80 // newSafeModeConfig creates configuration for safe mode with only withdrawals halted.
81 func newSafeModeConfig() HaltConfig {
82 return HaltConfig{
83 OpTypePool: false ,
84 OpTypePosition: false ,
85 OpTypeProtocolFee: false ,
86 OpTypeRouter: false ,
87 OpTypeStaker: false ,
88 OpTypeLaunchpad: false ,
89 OpTypeGovernance: false ,
90 OpTypeGovStaker: false ,
91 OpTypeXGns: false ,
92 OpTypeCommunityPool: false ,
93 OpTypeEmission: false ,
94 OpTypeWithdraw: true ,
95 }
96 }
97
98 // newEmergencyConfig creates configuration for emergency mode with most operations halted.
99 // Only governance and withdraw operations remain enabled for emergency recovery.
100 func newEmergencyConfig() HaltConfig {
101 return HaltConfig{
102 OpTypePool: true ,
103 OpTypePosition: true ,
104 OpTypeProtocolFee: true ,
105 OpTypeRouter: true ,
106 OpTypeStaker: true ,
107 OpTypeLaunchpad: true ,
108 OpTypeGovernance: false ,
109 OpTypeGovStaker: true ,
110 OpTypeXGns: true ,
111 OpTypeCommunityPool: true ,
112 OpTypeEmission: true ,
113 OpTypeWithdraw: false ,
114 }
115 }
116
117 // newCompleteConfig creates configuration with all operations halted for complete lockdown.
118 func newCompleteConfig() HaltConfig {
119 return HaltConfig{
120 OpTypePool: true ,
121 OpTypePosition: true ,
122 OpTypeProtocolFee: true ,
123 OpTypeRouter: true ,
124 OpTypeStaker: true ,
125 OpTypeLaunchpad: true ,
126 OpTypeGovernance: true ,
127 OpTypeGovStaker: true ,
128 OpTypeXGns: true ,
129 OpTypeCommunityPool: true ,
130 OpTypeEmission: true ,
131 OpTypeWithdraw: true ,
132 }
133 }
134