@@ -20,7 +20,8 @@ use num_traits::{FromPrimitive, Zero};
2020use fil_actors_runtime:: cbor:: serialize;
2121use fil_actors_runtime:: runtime:: { ActorCode , Runtime } ;
2222use fil_actors_runtime:: {
23- actor_error, cbor, ActorContext , ActorError , AsActorError , SYSTEM_ACTOR_ADDR ,
23+ actor_error, cbor, restrict_internal_api, ActorContext , ActorError , AsActorError ,
24+ SYSTEM_ACTOR_ADDR ,
2425} ;
2526
2627pub use self :: state:: State ;
@@ -42,9 +43,10 @@ lazy_static! {
4243 * BigInt :: from( 1_000_000_000_000_000_000_000_i128 )
4344 ) ;
4445}
45- /// Static method numbers for builtin-actor private dispatch.
46- /// The methods are also expected to be exposed via FRC-XXXX standard calling convention,
47- /// with numbers determined by name.
46+
47+ /// Datacap actor methods available
48+ /// Some methods are available under 2 method nums -- a static number for "private" builtin actor usage,
49+ /// and via FRC-XXXX calling convention, with number determined by method name.
4850#[ derive( FromPrimitive ) ]
4951#[ repr( u64 ) ]
5052pub enum Method {
@@ -65,6 +67,19 @@ pub enum Method {
6567 Burn = 19 ,
6668 BurnFrom = 20 ,
6769 Allowance = 21 ,
70+ // Method numbers derived from FRC-XXXX standards
71+ NameExported = frc42_dispatch:: method_hash!( "Name" ) ,
72+ SymbolExported = frc42_dispatch:: method_hash!( "Symbol" ) ,
73+ TotalSupplyExported = frc42_dispatch:: method_hash!( "TotalSupply" ) ,
74+ BalanceOfExported = frc42_dispatch:: method_hash!( "BalanceOf" ) ,
75+ TransferExported = frc42_dispatch:: method_hash!( "Transfer" ) ,
76+ TransferFromExported = frc42_dispatch:: method_hash!( "TransferFrom" ) ,
77+ IncreaseAllowanceExported = frc42_dispatch:: method_hash!( "IncreaseAllowance" ) ,
78+ DecreaseAllowanceExported = frc42_dispatch:: method_hash!( "DecreaseAllowance" ) ,
79+ RevokeAllowanceExported = frc42_dispatch:: method_hash!( "RevokeAllowance" ) ,
80+ BurnExported = frc42_dispatch:: method_hash!( "Burn" ) ,
81+ BurnFromExported = frc42_dispatch:: method_hash!( "BurnFrom" ) ,
82+ AllowanceExported = frc42_dispatch:: method_hash!( "Allowance" ) ,
6883}
6984
7085pub struct Actor ;
@@ -452,6 +467,7 @@ impl ActorCode for Actor {
452467 where
453468 RT : Runtime ,
454469 {
470+ restrict_internal_api ( rt, method) ?;
455471 // I'm trying to find a fixed template for these blocks so we can macro it.
456472 // Current blockers:
457473 // - the serialize method maps () to CBOR null (we want no bytes instead)
@@ -469,51 +485,51 @@ impl ActorCode for Actor {
469485 let ret = Self :: destroy ( rt, cbor:: deserialize_params ( params) ?) ?;
470486 serialize ( & ret, "destroy result" )
471487 }
472- Some ( Method :: Name ) => {
488+ Some ( Method :: Name ) | Some ( Method :: NameExported ) => {
473489 let ret = Self :: name ( rt) ?;
474490 serialize ( & ret, "name result" )
475491 }
476- Some ( Method :: Symbol ) => {
492+ Some ( Method :: Symbol ) | Some ( Method :: SymbolExported ) => {
477493 let ret = Self :: symbol ( rt) ?;
478494 serialize ( & ret, "symbol result" )
479495 }
480- Some ( Method :: TotalSupply ) => {
496+ Some ( Method :: TotalSupply ) | Some ( Method :: TotalSupplyExported ) => {
481497 let ret = Self :: total_supply ( rt, cbor:: deserialize_params ( params) ?) ?;
482498 serialize ( & ret, "total_supply result" )
483499 }
484- Some ( Method :: BalanceOf ) => {
500+ Some ( Method :: BalanceOf ) | Some ( Method :: BalanceOfExported ) => {
485501 let ret = Self :: balance_of ( rt, cbor:: deserialize_params ( params) ?) ?;
486502 serialize ( & ret, "balance_of result" )
487503 }
488- Some ( Method :: Transfer ) => {
504+ Some ( Method :: Transfer ) | Some ( Method :: TransferExported ) => {
489505 let ret = Self :: transfer ( rt, cbor:: deserialize_params ( params) ?) ?;
490506 serialize ( & ret, "transfer result" )
491507 }
492- Some ( Method :: TransferFrom ) => {
508+ Some ( Method :: TransferFrom ) | Some ( Method :: TransferFromExported ) => {
493509 let ret = Self :: transfer_from ( rt, cbor:: deserialize_params ( params) ?) ?;
494510 serialize ( & ret, "transfer_from result" )
495511 }
496- Some ( Method :: IncreaseAllowance ) => {
512+ Some ( Method :: IncreaseAllowance ) | Some ( Method :: IncreaseAllowanceExported ) => {
497513 let ret = Self :: increase_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
498514 serialize ( & ret, "increase_allowance result" )
499515 }
500- Some ( Method :: DecreaseAllowance ) => {
516+ Some ( Method :: DecreaseAllowance ) | Some ( Method :: DecreaseAllowanceExported ) => {
501517 let ret = Self :: decrease_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
502518 serialize ( & ret, "decrease_allowance result" )
503519 }
504- Some ( Method :: RevokeAllowance ) => {
520+ Some ( Method :: RevokeAllowance ) | Some ( Method :: RevokeAllowanceExported ) => {
505521 Self :: revoke_allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
506522 Ok ( RawBytes :: default ( ) )
507523 }
508- Some ( Method :: Burn ) => {
524+ Some ( Method :: Burn ) | Some ( Method :: BurnExported ) => {
509525 let ret = Self :: burn ( rt, cbor:: deserialize_params ( params) ?) ?;
510526 serialize ( & ret, "burn result" )
511527 }
512- Some ( Method :: BurnFrom ) => {
528+ Some ( Method :: BurnFrom ) | Some ( Method :: BurnFromExported ) => {
513529 let ret = Self :: burn_from ( rt, cbor:: deserialize_params ( params) ?) ?;
514530 serialize ( & ret, "burn_from result" )
515531 }
516- Some ( Method :: Allowance ) => {
532+ Some ( Method :: Allowance ) | Some ( Method :: AllowanceExported ) => {
517533 let ret = Self :: allowance ( rt, cbor:: deserialize_params ( params) ?) ?;
518534 serialize ( & ret, "allowance result" )
519535 }
0 commit comments