@@ -282,11 +282,11 @@ impl AssetMap {
282
282
asset : & AssetIdentifier ,
283
283
amount : u128 ,
284
284
) -> Result < u128 > {
285
- let current_amount = match self . token_map . get ( principal ) {
286
- Some ( principal_map ) => * principal_map . get ( asset ) . unwrap_or ( & 0 ) ,
287
- None => 0 ,
288
- } ;
289
-
285
+ let current_amount = self
286
+ . token_map
287
+ . get ( principal )
288
+ . map ( |x| x . get ( asset ) . unwrap_or ( & 0 ) )
289
+ . unwrap_or ( & 0 ) ;
290
290
current_amount
291
291
. checked_add ( amount)
292
292
. ok_or ( RuntimeErrorType :: ArithmeticOverflow . into ( ) )
@@ -443,24 +443,17 @@ impl AssetMap {
443
443
principal : & PrincipalData ,
444
444
asset_identifier : & AssetIdentifier ,
445
445
) -> Option < u128 > {
446
- match self . token_map . get ( principal) {
447
- Some ( assets) => assets. get ( asset_identifier) . copied ( ) ,
448
- None => None ,
449
- }
446
+ let assets = self . token_map . get ( principal) ?;
447
+ assets. get ( asset_identifier) . copied ( )
450
448
}
451
449
452
450
pub fn get_nonfungible_tokens (
453
451
& self ,
454
452
principal : & PrincipalData ,
455
453
asset_identifier : & AssetIdentifier ,
456
454
) -> Option < & Vec < Value > > {
457
- match self . asset_map . get ( principal) {
458
- Some ( assets) => match assets. get ( asset_identifier) {
459
- Some ( values) => Some ( values) ,
460
- None => None ,
461
- } ,
462
- None => None ,
463
- }
455
+ let assets = self . asset_map . get ( principal) ?;
456
+ assets. get ( asset_identifier)
464
457
}
465
458
}
466
459
0 commit comments