@@ -51,27 +51,29 @@ lazy_static! {
51
51
#[ repr( u64 ) ]
52
52
pub enum Method {
53
53
Constructor = METHOD_CONSTRUCTOR ,
54
- // Non-standard.
55
- Mint = 2 ,
56
- Destroy = 3 ,
57
- // Static method numbers for token standard methods, for private use.
58
- Name = 10 ,
59
- Symbol = 11 ,
60
- TotalSupply = 12 ,
61
- BalanceOf = 13 ,
62
- Transfer = 14 ,
63
- TransferFrom = 15 ,
64
- IncreaseAllowance = 16 ,
65
- DecreaseAllowance = 17 ,
66
- RevokeAllowance = 18 ,
67
- Burn = 19 ,
68
- BurnFrom = 20 ,
69
- Allowance = 21 ,
54
+ // Deprecated in v10
55
+ // Mint = 2,
56
+ // Destroy = 3,
57
+ // Name = 10,
58
+ // Symbol = 11,
59
+ // TotalSupply = 12,
60
+ // BalanceOf = 13,
61
+ // Transfer = 14,
62
+ // TransferFrom = 15,
63
+ // IncreaseAllowance = 16,
64
+ // DecreaseAllowance = 17,
65
+ // RevokeAllowance = 18,
66
+ // Burn = 19,
67
+ // BurnFrom = 20,
68
+ // Allowance = 21,
70
69
// Method numbers derived from FRC-0042 standards
70
+ MintExported = frc42_dispatch:: method_hash!( "Mint" ) ,
71
+ DestroyExported = frc42_dispatch:: method_hash!( "Destroy" ) ,
71
72
NameExported = frc42_dispatch:: method_hash!( "Name" ) ,
72
73
SymbolExported = frc42_dispatch:: method_hash!( "Symbol" ) ,
74
+ GranularityExported = frc42_dispatch:: method_hash!( "GranularityExported" ) ,
73
75
TotalSupplyExported = frc42_dispatch:: method_hash!( "TotalSupply" ) ,
74
- BalanceOfExported = frc42_dispatch:: method_hash!( "BalanceOf " ) ,
76
+ BalanceExported = frc42_dispatch:: method_hash!( "Balance " ) ,
75
77
TransferExported = frc42_dispatch:: method_hash!( "Transfer" ) ,
76
78
TransferFromExported = frc42_dispatch:: method_hash!( "TransferFrom" ) ,
77
79
IncreaseAllowanceExported = frc42_dispatch:: method_hash!( "IncreaseAllowance" ) ,
@@ -108,6 +110,11 @@ impl Actor {
108
110
Ok ( "DCAP" . to_string ( ) )
109
111
}
110
112
113
+ pub fn granularity ( rt : & mut impl Runtime ) -> Result < GranularityReturn , ActorError > {
114
+ rt. validate_immediate_caller_accept_any ( ) ?;
115
+ Ok ( GranularityReturn { granularity : DATACAP_GRANULARITY } )
116
+ }
117
+
111
118
pub fn total_supply ( rt : & mut impl Runtime , _: ( ) ) -> Result < TokenAmount , ActorError > {
112
119
rt. validate_immediate_caller_accept_any ( ) ?;
113
120
let mut st: State = rt. state ( ) ?;
@@ -116,7 +123,7 @@ impl Actor {
116
123
Ok ( token. total_supply ( ) )
117
124
}
118
125
119
- pub fn balance_of ( rt : & mut impl Runtime , address : Address ) -> Result < TokenAmount , ActorError > {
126
+ pub fn balance ( rt : & mut impl Runtime , address : Address ) -> Result < TokenAmount , ActorError > {
120
127
// NOTE: mutability and method caller here are awkward for a read-only call
121
128
rt. validate_immediate_caller_accept_any ( ) ?;
122
129
let mut st: State = rt. state ( ) ?;
@@ -477,59 +484,63 @@ impl ActorCode for Actor {
477
484
Self :: constructor ( rt, cbor:: deserialize_params ( params) ?) ?;
478
485
Ok ( RawBytes :: default ( ) )
479
486
}
480
- Some ( Method :: Mint ) => {
487
+ Some ( Method :: MintExported ) => {
481
488
let ret = Self :: mint ( rt, cbor:: deserialize_params ( params) ?) ?;
482
489
serialize ( & ret, "mint result" )
483
490
}
484
- Some ( Method :: Destroy ) => {
491
+ Some ( Method :: DestroyExported ) => {
485
492
let ret = Self :: destroy ( rt, cbor:: deserialize_params ( params) ?) ?;
486
493
serialize ( & ret, "destroy result" )
487
494
}
488
- Some ( Method :: Name ) | Some ( Method :: NameExported ) => {
495
+ Some ( Method :: NameExported ) => {
489
496
let ret = Self :: name ( rt) ?;
490
497
serialize ( & ret, "name result" )
491
498
}
492
- Some ( Method :: Symbol ) | Some ( Method :: SymbolExported ) => {
499
+ Some ( Method :: SymbolExported ) => {
493
500
let ret = Self :: symbol ( rt) ?;
494
501
serialize ( & ret, "symbol result" )
495
502
}
496
- Some ( Method :: TotalSupply ) | Some ( Method :: TotalSupplyExported ) => {
503
+ Some ( Method :: GranularityExported ) => {
504
+ let ret = Self :: granularity ( rt) ?;
505
+ serialize ( & ret, "granularity result" )
506
+ }
507
+ Some ( Method :: TotalSupplyExported ) => {
497
508
let ret = Self :: total_supply ( rt, cbor:: deserialize_params ( params) ?) ?;
498
509
serialize ( & ret, "total_supply result" )
499
510
}
500
- Some ( Method :: BalanceOf ) | Some ( Method :: BalanceOfExported ) => {
501
- let ret = Self :: balance_of ( rt, cbor:: deserialize_params ( params) ?) ?;
511
+ Some ( Method :: BalanceExported ) => {
512
+ let ret = Self :: balance ( rt, cbor:: deserialize_params ( params) ?) ?;
502
513
serialize ( & ret, "balance_of result" )
503
514
}
504
- Some ( Method :: Transfer ) | Some ( Method :: TransferExported ) => {
515
+ Some ( Method :: TransferExported ) => {
505
516
let ret = Self :: transfer ( rt, cbor:: deserialize_params ( params) ?) ?;
506
517
serialize ( & ret, "transfer result" )
507
518
}
508
- Some ( Method :: TransferFrom ) | Some ( Method :: TransferFromExported ) => {
519
+ Some ( Method :: TransferFromExported ) => {
509
520
let ret = Self :: transfer_from ( rt, cbor:: deserialize_params ( params) ?) ?;
510
521
serialize ( & ret, "transfer_from result" )
511
522
}
512
- Some ( Method :: IncreaseAllowance ) | Some ( Method :: IncreaseAllowanceExported ) => {
523
+ Some ( Method :: IncreaseAllowanceExported ) => {
513
524
let ret = Self :: increase_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
514
525
serialize ( & ret, "increase_allowance result" )
515
526
}
516
- Some ( Method :: DecreaseAllowance ) | Some ( Method :: DecreaseAllowanceExported ) => {
527
+ Some ( Method :: DecreaseAllowanceExported ) => {
517
528
let ret = Self :: decrease_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
518
529
serialize ( & ret, "decrease_allowance result" )
519
530
}
520
- Some ( Method :: RevokeAllowance ) | Some ( Method :: RevokeAllowanceExported ) => {
531
+ Some ( Method :: RevokeAllowanceExported ) => {
521
532
Self :: revoke_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
522
533
Ok ( RawBytes :: default ( ) )
523
534
}
524
- Some ( Method :: Burn ) | Some ( Method :: BurnExported ) => {
535
+ Some ( Method :: BurnExported ) => {
525
536
let ret = Self :: burn ( rt, cbor:: deserialize_params ( params) ?) ?;
526
537
serialize ( & ret, "burn result" )
527
538
}
528
- Some ( Method :: BurnFrom ) | Some ( Method :: BurnFromExported ) => {
539
+ Some ( Method :: BurnFromExported ) => {
529
540
let ret = Self :: burn_from ( rt, cbor:: deserialize_params ( params) ?) ?;
530
541
serialize ( & ret, "burn_from result" )
531
542
}
532
- Some ( Method :: Allowance ) | Some ( Method :: AllowanceExported ) => {
543
+ Some ( Method :: AllowanceExported ) => {
533
544
let ret = Self :: allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
534
545
serialize ( & ret, "allowance result" )
535
546
}
0 commit comments