@@ -9,7 +9,6 @@ use fvm_shared::bigint::bigint_ser::BigIntDe;
9
9
use fvm_shared:: bigint:: BigInt ;
10
10
use fvm_shared:: bigint:: Zero ;
11
11
use fvm_shared:: econ:: TokenAmount ;
12
- use fvm_shared:: ActorID ;
13
12
14
13
use self :: errors:: ActorError ;
15
14
use self :: state:: TokenState ;
83
82
/// Injected blockstore
84
83
bs : BS ,
85
84
/// Access to the runtime
86
- fvm : FVM ,
87
- }
88
-
89
- /// Resolve an address to an ActorID
90
- fn resolve_address ( address : & Address ) -> Result < ActorID > {
91
- match fvm_sdk:: actor:: resolve_address ( address) {
92
- Some ( addr) => Ok ( addr) ,
93
- None => Err ( ActorError :: AddrNotFound ( * address) ) ,
94
- }
85
+ _fvm : FVM ,
95
86
}
96
87
97
88
impl < BS , FVM > StandardToken < BS , FVM >
@@ -114,7 +105,7 @@ where
114
105
init_state. save ( & self . bs ) ;
115
106
116
107
let mint_params = params. mint_params ;
117
- self . mint ( mint_params) ;
108
+ self . mint ( mint_params) ? ;
118
109
Ok ( ( ) )
119
110
}
120
111
@@ -157,21 +148,16 @@ where
157
148
let balance = balances
158
149
. delete ( & holder) ?
159
150
. map ( |de| de. 1 . 0 )
160
- . unwrap_or ( TokenAmount :: zero ( ) ) ;
151
+ . unwrap_or_else ( TokenAmount :: zero) ;
161
152
let new_balance = balance
162
153
. checked_add ( & params. value )
163
- . ok_or ( ActorError :: Arithmetic ( String :: from (
164
- "Minting into caused overflow" ,
165
- ) ) ) ?;
154
+ . ok_or_else ( || ActorError :: Arithmetic ( String :: from ( "Minting into caused overflow" ) ) ) ?;
166
155
balances. set ( holder, BigIntDe ( new_balance) ) ?;
167
156
168
157
// set the global supply of the contract
169
- let new_supply = state
170
- . supply
171
- . checked_add ( & params. value )
172
- . ok_or ( ActorError :: Arithmetic ( String :: from (
173
- "Minting caused total supply to overflow" ,
174
- ) ) ) ?;
158
+ let new_supply = state. supply . checked_add ( & params. value ) . ok_or_else ( || {
159
+ ActorError :: Arithmetic ( String :: from ( "Minting caused total supply to overflow" ) )
160
+ } ) ?;
175
161
state. supply = new_supply;
176
162
177
163
// commit the state if supply and balance increased
@@ -230,7 +216,7 @@ where
230
216
} ,
231
217
// No allowance recorded previously
232
218
None => {
233
- caller_allowances_map. set ( spender, BigIntDe ( params. value . clone ( ) ) ) ;
219
+ caller_allowances_map. set ( spender, BigIntDe ( params. value . clone ( ) ) ) ? ;
234
220
params. value
235
221
}
236
222
} ;
@@ -263,7 +249,7 @@ where
263
249
. checked_sub ( & params. value )
264
250
. unwrap ( ) // Unwrap should be safe as allowance always > 0
265
251
. max ( BigInt :: zero ( ) ) ;
266
- caller_allowances_map. set ( spender, BigIntDe ( new_allowance. clone ( ) ) ) ;
252
+ caller_allowances_map. set ( spender, BigIntDe ( new_allowance. clone ( ) ) ) ? ;
267
253
new_allowance
268
254
}
269
255
None => {
@@ -298,7 +284,7 @@ where
298
284
} ;
299
285
300
286
let new_allowance = TokenAmount :: zero ( ) ;
301
- caller_allowances_map. set ( spender, BigIntDe ( new_allowance. clone ( ) ) ) ;
287
+ caller_allowances_map. set ( spender, BigIntDe ( new_allowance. clone ( ) ) ) ? ;
302
288
state. save ( & self . bs ) ;
303
289
304
290
Ok ( AllowanceReturn {
@@ -336,11 +322,11 @@ where
336
322
} )
337
323
}
338
324
339
- fn burn ( & self , params : BurnParams ) -> Result < BurnReturn > {
325
+ fn burn ( & self , _params : BurnParams ) -> Result < BurnReturn > {
340
326
todo ! ( )
341
327
}
342
328
343
- fn transfer_from ( & self , params : TransferParams ) -> Result < TransferReturn > {
329
+ fn transfer_from ( & self , _params : TransferParams ) -> Result < TransferReturn > {
344
330
todo ! ( )
345
331
}
346
332
}
0 commit comments