@@ -40,37 +40,42 @@ impl SubnetPrecompile {
40
40
}
41
41
42
42
fn register_network ( handle : & mut impl PrecompileHandle , data : & [ u8 ] ) -> PrecompileResult {
43
- let call = if data. len ( ) == 32 {
44
- let mut hotkey = [ 0u8 ; 32 ] ;
45
- hotkey. copy_from_slice ( get_slice ( data, 0 , 32 ) ?) ;
46
-
47
- RuntimeCall :: SubtensorModule (
48
- pallet_subtensor:: Call :: < Runtime > :: register_network_with_identity {
49
- hotkey : hotkey. into ( ) ,
50
- identity : None ,
51
- } ,
52
- )
53
- } else if data. len ( ) > 32 {
54
- let ( pubkey, subnet_name, github_repo, subnet_contact) =
55
- Self :: parse_register_network_parameters ( data) ?;
56
-
57
- let identity: pallet_subtensor:: SubnetIdentityOf = pallet_subtensor:: SubnetIdentityOf {
58
- subnet_name,
59
- github_repo,
60
- subnet_contact,
61
- } ;
62
-
63
- // Create the register_network callcle
64
- RuntimeCall :: SubtensorModule (
65
- pallet_subtensor:: Call :: < Runtime > :: register_network_with_identity {
66
- hotkey : pubkey. into ( ) ,
67
- identity : Some ( identity) ,
68
- } ,
69
- )
70
- } else {
71
- return Err ( PrecompileFailure :: Error {
72
- exit_status : ExitError :: InvalidRange ,
73
- } ) ;
43
+ let call = match data. len ( ) {
44
+ 32 => {
45
+ let mut hotkey = [ 0u8 ; 32 ] ;
46
+ hotkey. copy_from_slice ( get_slice ( data, 0 , 32 ) ?) ;
47
+
48
+ RuntimeCall :: SubtensorModule (
49
+ pallet_subtensor:: Call :: < Runtime > :: register_network_with_identity {
50
+ hotkey : hotkey. into ( ) ,
51
+ identity : None ,
52
+ } ,
53
+ )
54
+ }
55
+ 32 .. => {
56
+ let ( pubkey, subnet_name, github_repo, subnet_contact) =
57
+ Self :: parse_register_network_parameters ( data) ?;
58
+
59
+ let identity: pallet_subtensor:: SubnetIdentityOf =
60
+ pallet_subtensor:: SubnetIdentityOf {
61
+ subnet_name,
62
+ github_repo,
63
+ subnet_contact,
64
+ } ;
65
+
66
+ // Create the register_network callcle
67
+ RuntimeCall :: SubtensorModule (
68
+ pallet_subtensor:: Call :: < Runtime > :: register_network_with_identity {
69
+ hotkey : pubkey. into ( ) ,
70
+ identity : Some ( identity) ,
71
+ } ,
72
+ )
73
+ }
74
+ _ => {
75
+ return Err ( PrecompileFailure :: Error {
76
+ exit_status : ExitError :: InvalidRange ,
77
+ } ) ;
78
+ }
74
79
} ;
75
80
76
81
// Dispatch the register_network call
0 commit comments