@@ -76,7 +76,7 @@ pub fn deploy_token_to_source_chain(
76
76
origin_chain,
77
77
chain,
78
78
deploy_token. token_id ,
79
- Some ( deploy_token. decimals ) ,
79
+ deploy_token. decimals ,
80
80
) ?;
81
81
}
82
82
None => {
@@ -90,7 +90,7 @@ pub fn deploy_token_to_source_chain(
90
90
storage,
91
91
chain. clone ( ) ,
92
92
deploy_token. token_id ,
93
- & TokenInstance :: new_on_origin ( Some ( deploy_token. decimals ) ) ,
93
+ & TokenInstance :: new_on_origin ( deploy_token. decimals ) ,
94
94
)
95
95
} )
96
96
. change_context ( Error :: State ) ?;
@@ -119,7 +119,7 @@ pub fn deploy_token_to_destination_chain(
119
119
storage,
120
120
chain. clone ( ) ,
121
121
deploy_token. token_id ,
122
- & TokenInstance :: new ( & deploy_token. deployment_type ( ) , Some ( deploy_token. decimals ) ) ,
122
+ & TokenInstance :: new ( & deploy_token. deployment_type ( ) , deploy_token. decimals ) ,
123
123
)
124
124
. change_context ( Error :: State )
125
125
. map ( |_| ( ) )
@@ -146,7 +146,7 @@ fn ensure_matching_original_deployment(
146
146
origin_chain : ChainNameRaw ,
147
147
chain : & ChainNameRaw ,
148
148
token_id : TokenId ,
149
- decimals : Option < u8 > ,
149
+ decimals : u8 ,
150
150
) -> Result < ( ) , Error > {
151
151
ensure ! (
152
152
origin_chain == * chain,
@@ -236,20 +236,12 @@ fn destination_amount(
236
236
let destination_token = try_load_token_instance ( storage, destination_chain. clone ( ) , token_id) ?;
237
237
238
238
let ( source_decimals, destination_decimals) =
239
- match ( source_token. decimals , destination_token. decimals ) {
240
- ( Some ( source_decimals) , Some ( destination_decimals) )
241
- if source_decimals == destination_decimals =>
242
- {
243
- return Ok ( source_amount)
244
- }
245
- ( Some ( source_decimals) , Some ( destination_decimals) ) => {
246
- ( source_decimals, destination_decimals)
247
- }
248
- ( None , None ) => return Ok ( source_amount) ,
249
- _ => unreachable ! (
250
- "decimals should be set in both the source and destination, or set in neither"
251
- ) , // This should never happen
252
- } ;
239
+ ( source_token. decimals , destination_token. decimals ) ;
240
+
241
+ if source_decimals == destination_decimals {
242
+ return Ok ( source_amount) ;
243
+ }
244
+
253
245
let destination_max_uint = state:: load_chain_config ( storage, destination_chain)
254
246
. change_context ( Error :: State ) ?
255
247
. max_uint ;
@@ -339,14 +331,14 @@ mod test {
339
331
& mut storage,
340
332
source_chain. clone ( ) ,
341
333
transfer. token_id ,
342
- & TokenInstance :: new_on_origin ( Some ( 18 ) ) ,
334
+ & TokenInstance :: new_on_origin ( 18 ) ,
343
335
)
344
336
. unwrap ( ) ;
345
337
state:: save_token_instance (
346
338
& mut storage,
347
339
destination_chain. clone ( ) ,
348
340
transfer. token_id ,
349
- & TokenInstance :: new ( & TokenDeploymentType :: Trustless , Some ( 12 ) ) ,
341
+ & TokenInstance :: new ( & TokenDeploymentType :: Trustless , 12 ) ,
350
342
)
351
343
. unwrap ( ) ;
352
344
state:: save_chain_config (
@@ -390,14 +382,14 @@ mod test {
390
382
& mut storage,
391
383
source_chain. clone ( ) ,
392
384
transfer. token_id ,
393
- & TokenInstance :: new_on_origin ( Some ( 12 ) ) ,
385
+ & TokenInstance :: new_on_origin ( 12 ) ,
394
386
)
395
387
. unwrap ( ) ;
396
388
state:: save_token_instance (
397
389
& mut storage,
398
390
destination_chain. clone ( ) ,
399
391
transfer. token_id ,
400
- & TokenInstance :: new ( & TokenDeploymentType :: Trustless , Some ( 18 ) ) ,
392
+ & TokenInstance :: new ( & TokenDeploymentType :: Trustless , 18 ) ,
401
393
)
402
394
. unwrap ( ) ;
403
395
state:: save_chain_config (
@@ -441,14 +433,14 @@ mod test {
441
433
& mut storage,
442
434
source_chain. clone ( ) ,
443
435
transfer. token_id ,
444
- & TokenInstance :: new_on_origin ( Some ( 12 ) ) ,
436
+ & TokenInstance :: new_on_origin ( 12 ) ,
445
437
)
446
438
. unwrap ( ) ;
447
439
state:: save_token_instance (
448
440
& mut storage,
449
441
destination_chain. clone ( ) ,
450
442
transfer. token_id ,
451
- & TokenInstance :: new ( & TokenDeploymentType :: Trustless , Some ( 12 ) ) ,
443
+ & TokenInstance :: new ( & TokenDeploymentType :: Trustless , 12 ) ,
452
444
)
453
445
. unwrap ( ) ;
454
446
state:: save_chain_config (
@@ -492,14 +484,14 @@ mod test {
492
484
& mut storage,
493
485
source_chain. clone ( ) ,
494
486
transfer. token_id ,
495
- & TokenInstance :: new_on_origin ( Some ( 18 ) ) ,
487
+ & TokenInstance :: new_on_origin ( 18 ) ,
496
488
)
497
489
. unwrap ( ) ;
498
490
state:: save_token_instance (
499
491
& mut storage,
500
492
destination_chain. clone ( ) ,
501
493
transfer. token_id ,
502
- & TokenInstance :: new ( & TokenDeploymentType :: Trustless , Some ( 12 ) ) ,
494
+ & TokenInstance :: new ( & TokenDeploymentType :: Trustless , 12 ) ,
503
495
)
504
496
. unwrap ( ) ;
505
497
state:: save_chain_config (
@@ -543,14 +535,14 @@ mod test {
543
535
& mut storage,
544
536
source_chain. clone ( ) ,
545
537
transfer. token_id ,
546
- & TokenInstance :: new_on_origin ( Some ( 18 ) ) ,
538
+ & TokenInstance :: new_on_origin ( 18 ) ,
547
539
)
548
540
. unwrap ( ) ;
549
541
state:: save_token_instance (
550
542
& mut storage,
551
543
destination_chain. clone ( ) ,
552
544
transfer. token_id ,
553
- & TokenInstance :: new ( & TokenDeploymentType :: Trustless , Some ( 12 ) ) ,
545
+ & TokenInstance :: new ( & TokenDeploymentType :: Trustless , 12 ) ,
554
546
)
555
547
. unwrap ( ) ;
556
548
state:: save_chain_config (
0 commit comments