@@ -39,14 +39,20 @@ pub fn check_restrict_assets(
39
39
) -> Result < TypeSignature , CheckError > {
40
40
check_arguments_at_least ( 3 , args) ?;
41
41
42
- let asset_owner = & args[ 0 ] ;
43
- let allowance_list = args[ 1 ]
42
+ let asset_owner = args
43
+ . first ( )
44
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?;
45
+ let allowance_list = args
46
+ . get ( 1 )
47
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?
44
48
. match_list ( )
45
49
. ok_or ( CheckErrors :: ExpectedListOfAllowances (
46
50
"restrict-assets?" . into ( ) ,
47
51
2 ,
48
52
) ) ?;
49
- let body_exprs = & args[ 2 ..] ;
53
+ let body_exprs = args
54
+ . get ( 2 ..)
55
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?;
50
56
51
57
if allowance_list. len ( ) > MAX_ALLOWANCES {
52
58
return Err ( CheckErrors :: TooManyAllowances ( MAX_ALLOWANCES , allowance_list. len ( ) ) . into ( ) ) ;
@@ -90,13 +96,17 @@ pub fn check_as_contract(
90
96
) -> Result < TypeSignature , CheckError > {
91
97
check_arguments_at_least ( 2 , args) ?;
92
98
93
- let allowance_list = args[ 0 ]
99
+ let allowance_list = args
100
+ . first ( )
101
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?
94
102
. match_list ( )
95
103
. ok_or ( CheckErrors :: ExpectedListOfAllowances (
96
104
"as-contract?" . into ( ) ,
97
105
1 ,
98
106
) ) ?;
99
- let body_exprs = & args[ 1 ..] ;
107
+ let body_exprs = args
108
+ . get ( 1 ..)
109
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?;
100
110
101
111
if allowance_list. len ( ) > MAX_ALLOWANCES {
102
112
return Err ( CheckErrors :: TooManyAllowances ( MAX_ALLOWANCES , allowance_list. len ( ) ) . into ( ) ) ;
@@ -185,7 +195,12 @@ fn check_allowance_with_stx(
185
195
) -> Result < bool , CheckError > {
186
196
check_argument_count ( 1 , args) ?;
187
197
188
- checker. type_check_expects ( & args[ 0 ] , context, & TypeSignature :: UIntType ) ?;
198
+ checker. type_check_expects (
199
+ args. first ( )
200
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
201
+ context,
202
+ & TypeSignature :: UIntType ,
203
+ ) ?;
189
204
190
205
Ok ( false )
191
206
}
@@ -199,9 +214,24 @@ fn check_allowance_with_ft(
199
214
) -> Result < bool , CheckError > {
200
215
check_argument_count ( 3 , args) ?;
201
216
202
- checker. type_check_expects ( & args[ 0 ] , context, & TypeSignature :: PrincipalType ) ?;
203
- checker. type_check_expects ( & args[ 1 ] , context, & ASCII_128 ) ?;
204
- checker. type_check_expects ( & args[ 2 ] , context, & TypeSignature :: UIntType ) ?;
217
+ checker. type_check_expects (
218
+ args. first ( )
219
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
220
+ context,
221
+ & TypeSignature :: PrincipalType ,
222
+ ) ?;
223
+ checker. type_check_expects (
224
+ args. get ( 1 )
225
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
226
+ context,
227
+ & ASCII_128 ,
228
+ ) ?;
229
+ checker. type_check_expects (
230
+ args. get ( 2 )
231
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
232
+ context,
233
+ & TypeSignature :: UIntType ,
234
+ ) ?;
205
235
206
236
Ok ( false )
207
237
}
@@ -215,11 +245,25 @@ fn check_allowance_with_nft(
215
245
) -> Result < bool , CheckError > {
216
246
check_argument_count ( 3 , args) ?;
217
247
218
- checker. type_check_expects ( & args[ 0 ] , context, & TypeSignature :: PrincipalType ) ?;
219
- checker. type_check_expects ( & args[ 1 ] , context, & ASCII_128 ) ?;
248
+ checker. type_check_expects (
249
+ args. first ( )
250
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
251
+ context,
252
+ & TypeSignature :: PrincipalType ,
253
+ ) ?;
254
+ checker. type_check_expects (
255
+ args. get ( 1 )
256
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
257
+ context,
258
+ & ASCII_128 ,
259
+ ) ?;
220
260
221
261
// Asset identifiers must be a Clarity list with any type of elements
222
- let id_list_ty = checker. type_check ( & args[ 2 ] , context) ?;
262
+ let id_list_ty = checker. type_check (
263
+ args. get ( 2 )
264
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
265
+ context,
266
+ ) ?;
223
267
let TypeSignature :: SequenceType ( SequenceSubtype :: ListType ( list_data) ) = id_list_ty else {
224
268
return Err ( CheckErrors :: WithNftExpectedListOfIdentifiers . into ( ) ) ;
225
269
} ;
@@ -243,7 +287,12 @@ fn check_allowance_with_stacking(
243
287
) -> Result < bool , CheckError > {
244
288
check_argument_count ( 1 , args) ?;
245
289
246
- checker. type_check_expects ( & args[ 0 ] , context, & TypeSignature :: UIntType ) ?;
290
+ checker. type_check_expects (
291
+ args. first ( )
292
+ . ok_or ( CheckErrors :: CheckerImplementationFailure ) ?,
293
+ context,
294
+ & TypeSignature :: UIntType ,
295
+ ) ?;
247
296
248
297
Ok ( false )
249
298
}
0 commit comments