@@ -8,8 +8,9 @@ use std::os::raw::{c_char, c_uint};
88
99use crate :: error:: { FFIError , FFIErrorCode } ;
1010use crate :: transaction_checking:: FFIManagedWallet ;
11- use crate :: types:: { FFIAccountType , FFINetworks , FFIWallet } ;
11+ use crate :: types:: { FFIAccountType , FFIWallet } ;
1212use crate :: utils:: rust_string_to_c;
13+ use crate :: FFINetwork ;
1314use key_wallet:: account:: ManagedAccountCollection ;
1415use key_wallet:: managed_account:: address_pool:: {
1516 AddressInfo , AddressPool , KeySource , PublicKeyType ,
@@ -246,7 +247,7 @@ pub struct FFIAddressPoolInfo {
246247#[ no_mangle]
247248pub unsafe extern "C" fn managed_wallet_get_address_pool_info (
248249 managed_wallet : * const FFIManagedWallet ,
249- network : FFINetworks ,
250+ network : FFINetwork ,
250251 account_type : FFIAccountType ,
251252 account_index : c_uint ,
252253 pool_type : FFIAddressPoolType ,
@@ -259,17 +260,7 @@ pub unsafe extern "C" fn managed_wallet_get_address_pool_info(
259260 }
260261
261262 let managed_wallet = & * ( * managed_wallet) . inner ;
262- let network_rust: key_wallet:: Network = match network. try_into ( ) {
263- Ok ( n) => n,
264- Err ( _) => {
265- FFIError :: set_error (
266- error,
267- FFIErrorCode :: InvalidInput ,
268- "Must specify exactly one network" . to_string ( ) ,
269- ) ;
270- return false ;
271- }
272- } ;
263+ let network_rust: key_wallet:: Network = network. into ( ) ;
273264
274265 let account_type_rust = account_type. to_account_type ( account_index) ;
275266
@@ -376,7 +367,7 @@ pub unsafe extern "C" fn managed_wallet_get_address_pool_info(
376367#[ no_mangle]
377368pub unsafe extern "C" fn managed_wallet_set_gap_limit (
378369 managed_wallet : * mut FFIManagedWallet ,
379- network : FFINetworks ,
370+ network : FFINetwork ,
380371 account_type : FFIAccountType ,
381372 account_index : c_uint ,
382373 pool_type : FFIAddressPoolType ,
@@ -389,17 +380,7 @@ pub unsafe extern "C" fn managed_wallet_set_gap_limit(
389380 }
390381
391382 let managed_wallet = & mut * ( * managed_wallet) . inner ;
392- let network_rust: key_wallet:: Network = match network. try_into ( ) {
393- Ok ( n) => n,
394- Err ( _) => {
395- FFIError :: set_error (
396- error,
397- FFIErrorCode :: InvalidInput ,
398- "Must specify exactly one network" . to_string ( ) ,
399- ) ;
400- return false ;
401- }
402- } ;
383+ let network_rust: key_wallet:: Network = network. into ( ) ;
403384
404385 let account_type_rust = account_type. to_account_type ( account_index) ;
405386
@@ -496,7 +477,7 @@ pub unsafe extern "C" fn managed_wallet_set_gap_limit(
496477pub unsafe extern "C" fn managed_wallet_generate_addresses_to_index (
497478 managed_wallet : * mut FFIManagedWallet ,
498479 wallet : * const FFIWallet ,
499- network : FFINetworks ,
480+ network : FFINetwork ,
500481 account_type : FFIAccountType ,
501482 account_index : c_uint ,
502483 pool_type : FFIAddressPoolType ,
@@ -510,17 +491,7 @@ pub unsafe extern "C" fn managed_wallet_generate_addresses_to_index(
510491
511492 let managed_wallet = & mut * ( * managed_wallet) . inner ;
512493 let wallet = & * wallet;
513- let network_rust: key_wallet:: Network = match network. try_into ( ) {
514- Ok ( n) => n,
515- Err ( _) => {
516- FFIError :: set_error (
517- error,
518- FFIErrorCode :: InvalidInput ,
519- "Must specify exactly one network" . to_string ( ) ,
520- ) ;
521- return false ;
522- }
523- } ;
494+ let network_rust: key_wallet:: Network = network. into ( ) ;
524495
525496 let account_type_rust = account_type. to_account_type ( account_index) ;
526497
@@ -671,7 +642,7 @@ pub unsafe extern "C" fn managed_wallet_generate_addresses_to_index(
671642#[ no_mangle]
672643pub unsafe extern "C" fn managed_wallet_mark_address_used (
673644 managed_wallet : * mut FFIManagedWallet ,
674- network : FFINetworks ,
645+ network : FFINetwork ,
675646 address : * const c_char ,
676647 error : * mut FFIError ,
677648) -> bool {
@@ -681,17 +652,7 @@ pub unsafe extern "C" fn managed_wallet_mark_address_used(
681652 }
682653
683654 let managed_wallet = & mut * ( * managed_wallet) . inner ;
684- let network_rust: key_wallet:: Network = match network. try_into ( ) {
685- Ok ( n) => n,
686- Err ( _) => {
687- FFIError :: set_error (
688- error,
689- FFIErrorCode :: InvalidInput ,
690- "Must specify exactly one network" . to_string ( ) ,
691- ) ;
692- return false ;
693- }
694- } ;
655+ let network_rust: key_wallet:: Network = network. into ( ) ;
695656
696657 // Parse the address string
697658 let address_str = match std:: ffi:: CStr :: from_ptr ( address) . to_str ( ) {
@@ -1001,7 +962,7 @@ pub unsafe extern "C" fn address_info_array_free(infos: *mut *mut FFIAddressInfo
1001962#[ cfg( test) ]
1002963mod tests {
1003964 use super :: * ;
1004- use crate :: FFINetwork ;
965+ use crate :: { FFINetwork , FFINetworks } ;
1005966
1006967 #[ test]
1007968 fn test_address_pool_type_values ( ) {
0 commit comments