github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/fvm/environment/parse_restricted_checker.go (about) 1 // AUTO-GENERATED BY generate-wrappers fvm/environment/parse_restricted_checker.go. DO NOT MODIFY. 2 3 package environment 4 5 import ( 6 "github.com/onflow/flow-go/fvm/errors" 7 "github.com/onflow/flow-go/fvm/storage/state" 8 "github.com/onflow/flow-go/module/trace" 9 ) 10 11 func parseRestricted( 12 txnState state.NestedTransactionPreparer, 13 spanName trace.SpanName, 14 ) error { 15 if txnState.IsParseRestricted() { 16 return errors.NewParseRestrictedModeInvalidAccessFailure(spanName) 17 } 18 19 return nil 20 } 21 22 // Utility functions used for checking unexpected operation access while 23 // cadence is parsing programs. 24 // 25 // The generic functions are of the form 26 // parseRestrict<x>Arg<y>Ret(txnState, spanName, callback, arg1, ..., argX) 27 // where the callback expects <x> number of arguments, and <y> number of 28 // return values (not counting error). If the callback expects no argument, 29 // <x>Arg is omitted, and similarly for return value. 30 31 func parseRestrict1Arg[ 32 Arg0T any, 33 ]( 34 txnState state.NestedTransactionPreparer, 35 spanName trace.SpanName, 36 callback func(Arg0T) error, 37 arg0 Arg0T, 38 ) error { 39 err := parseRestricted(txnState, spanName) 40 if err != nil { 41 return err 42 } 43 44 return callback(arg0) 45 } 46 47 func parseRestrict2Arg[ 48 Arg0T any, 49 Arg1T any, 50 ]( 51 txnState state.NestedTransactionPreparer, 52 spanName trace.SpanName, 53 callback func(Arg0T, Arg1T) error, 54 arg0 Arg0T, 55 arg1 Arg1T, 56 ) error { 57 err := parseRestricted(txnState, spanName) 58 if err != nil { 59 return err 60 } 61 62 return callback(arg0, arg1) 63 } 64 65 func parseRestrict3Arg[ 66 Arg0T any, 67 Arg1T any, 68 Arg2T any, 69 ]( 70 txnState state.NestedTransactionPreparer, 71 spanName trace.SpanName, 72 callback func(Arg0T, Arg1T, Arg2T) error, 73 arg0 Arg0T, 74 arg1 Arg1T, 75 arg2 Arg2T, 76 ) error { 77 err := parseRestricted(txnState, spanName) 78 if err != nil { 79 return err 80 } 81 82 return callback(arg0, arg1, arg2) 83 } 84 85 func parseRestrict1Ret[ 86 Ret0T any, 87 ]( 88 txnState state.NestedTransactionPreparer, 89 spanName trace.SpanName, 90 callback func() (Ret0T, error), 91 ) ( 92 Ret0T, 93 error, 94 ) { 95 err := parseRestricted(txnState, spanName) 96 if err != nil { 97 var value0 Ret0T 98 return value0, err 99 } 100 101 return callback() 102 } 103 104 func parseRestrict1Arg1Ret[ 105 Arg0T any, 106 Ret0T any, 107 ]( 108 txnState state.NestedTransactionPreparer, 109 spanName trace.SpanName, 110 callback func(Arg0T) (Ret0T, error), 111 arg0 Arg0T, 112 ) ( 113 Ret0T, 114 error, 115 ) { 116 err := parseRestricted(txnState, spanName) 117 if err != nil { 118 var value0 Ret0T 119 return value0, err 120 } 121 122 return callback(arg0) 123 } 124 125 func parseRestrict2Arg1Ret[ 126 Arg0T any, 127 Arg1T any, 128 Ret0T any, 129 ]( 130 txnState state.NestedTransactionPreparer, 131 spanName trace.SpanName, 132 callback func(Arg0T, Arg1T) (Ret0T, error), 133 arg0 Arg0T, 134 arg1 Arg1T, 135 ) ( 136 Ret0T, 137 error, 138 ) { 139 err := parseRestricted(txnState, spanName) 140 if err != nil { 141 var value0 Ret0T 142 return value0, err 143 } 144 145 return callback(arg0, arg1) 146 } 147 148 func parseRestrict3Arg1Ret[ 149 Arg0T any, 150 Arg1T any, 151 Arg2T any, 152 Ret0T any, 153 ]( 154 txnState state.NestedTransactionPreparer, 155 spanName trace.SpanName, 156 callback func(Arg0T, Arg1T, Arg2T) (Ret0T, error), 157 arg0 Arg0T, 158 arg1 Arg1T, 159 arg2 Arg2T, 160 ) ( 161 Ret0T, 162 error, 163 ) { 164 err := parseRestricted(txnState, spanName) 165 if err != nil { 166 var value0 Ret0T 167 return value0, err 168 } 169 170 return callback(arg0, arg1, arg2) 171 } 172 173 func parseRestrict4Arg1Ret[ 174 Arg0T any, 175 Arg1T any, 176 Arg2T any, 177 Arg3T any, 178 Ret0T any, 179 ]( 180 txnState state.NestedTransactionPreparer, 181 spanName trace.SpanName, 182 callback func(Arg0T, Arg1T, Arg2T, Arg3T) (Ret0T, error), 183 arg0 Arg0T, 184 arg1 Arg1T, 185 arg2 Arg2T, 186 arg3 Arg3T, 187 ) ( 188 Ret0T, 189 error, 190 ) { 191 err := parseRestricted(txnState, spanName) 192 if err != nil { 193 var value0 Ret0T 194 return value0, err 195 } 196 197 return callback(arg0, arg1, arg2, arg3) 198 } 199 200 func parseRestrict6Arg1Ret[ 201 Arg0T any, 202 Arg1T any, 203 Arg2T any, 204 Arg3T any, 205 Arg4T any, 206 Arg5T any, 207 Ret0T any, 208 ]( 209 txnState state.NestedTransactionPreparer, 210 spanName trace.SpanName, 211 callback func(Arg0T, Arg1T, Arg2T, Arg3T, Arg4T, Arg5T) (Ret0T, error), 212 arg0 Arg0T, 213 arg1 Arg1T, 214 arg2 Arg2T, 215 arg3 Arg3T, 216 arg4 Arg4T, 217 arg5 Arg5T, 218 ) ( 219 Ret0T, 220 error, 221 ) { 222 err := parseRestricted(txnState, spanName) 223 if err != nil { 224 var value0 Ret0T 225 return value0, err 226 } 227 228 return callback(arg0, arg1, arg2, arg3, arg4, arg5) 229 } 230 231 func parseRestrict1Arg2Ret[ 232 Arg0T any, 233 Ret0T any, 234 Ret1T any, 235 ]( 236 txnState state.NestedTransactionPreparer, 237 spanName trace.SpanName, 238 callback func(Arg0T) (Ret0T, Ret1T, error), 239 arg0 Arg0T, 240 ) ( 241 Ret0T, 242 Ret1T, 243 error, 244 ) { 245 err := parseRestricted(txnState, spanName) 246 if err != nil { 247 var value0 Ret0T 248 var value1 Ret1T 249 return value0, value1, err 250 } 251 252 return callback(arg0) 253 }