11use std:: str:: FromStr ;
22
33use miden_client:: Client ;
4- use miden_client:: account:: AccountIdAddress ;
5- use miden_client:: address:: { Address , AddressInterface , NetworkId } ;
6- use miden_client:: note:: NoteExecutionMode ;
4+ use miden_client:: address:: { Address , AddressInterface , NetworkId , RoutingParameters } ;
5+ use miden_client:: note:: { NoteExecutionMode , NoteTag } ;
76
87use crate :: errors:: CliError ;
98use crate :: utils:: parse_account_id;
@@ -12,7 +11,6 @@ use crate::{Parser, Subcommand, create_dynamic_table, load_config_file};
1211#[ derive( Debug , Clone ) ]
1312pub enum CliAddressInterface {
1413 BasicWallet ,
15- Unspecified ,
1614}
1715
1816impl FromStr for CliAddressInterface {
@@ -21,7 +19,6 @@ impl FromStr for CliAddressInterface {
2119 fn from_str ( value : & str ) -> Result < Self , Self :: Err > {
2220 match value {
2321 "BasicWallet" => Ok ( CliAddressInterface :: BasicWallet ) ,
24- "Unspecified" => Ok ( CliAddressInterface :: Unspecified ) ,
2522 other => Err ( format ! (
2623 "Invalid interface: {other}. Valid values are: BasicWallet, Unspecified" ,
2724 ) ) ,
@@ -33,7 +30,6 @@ impl From<CliAddressInterface> for AddressInterface {
3330 fn from ( value : CliAddressInterface ) -> Self {
3431 match value {
3532 CliAddressInterface :: BasicWallet => AddressInterface :: BasicWallet ,
36- CliAddressInterface :: Unspecified => AddressInterface :: Unspecified ,
3733 }
3834 }
3935}
@@ -99,8 +95,11 @@ fn print_account_addresses(account_id: &String, addresses: &Vec<Address>, networ
9995 println ! ( "Addresses for AccountId {account_id}:" ) ;
10096 let mut table = create_dynamic_table ( & [ "Address" , "Interface" ] ) ;
10197 for address in addresses {
102- let address_bech32 = address. to_bech32 ( network_id. clone ( ) ) ;
103- let interface = address. interface ( ) . to_string ( ) ;
98+ let address_bech32 = address. encode ( network_id. clone ( ) ) ;
99+ let interface = match address. interface ( ) {
100+ Some ( interface) => interface. to_string ( ) ,
101+ None => "Unspecified" . to_string ( ) ,
102+ } ;
104103 table. add_row ( vec ! [ address_bech32, interface] ) ;
105104 }
106105
@@ -152,18 +151,22 @@ async fn add_address<AUTH>(
152151) -> Result < ( ) , CliError > {
153152 let account_id = parse_account_id ( & client, & account_id) . await ?;
154153 let interface = interface. into ( ) ;
155- let account_id_address = match tag_len {
156- Some ( tag_len) => AccountIdAddress :: new ( account_id , interface)
157- . with_tag_len ( tag_len)
154+ let routing_params = match tag_len {
155+ Some ( tag_len) => RoutingParameters :: new ( interface)
156+ . with_note_tag_len ( tag_len)
158157 . map_err ( |e| CliError :: Address ( e, String :: new ( ) ) ) ?,
159- None => AccountIdAddress :: new ( account_id , interface) ,
158+ None => RoutingParameters :: new ( interface) ,
160159 } ;
160+ let address = Address :: new ( account_id)
161+ . with_routing_parameters ( routing_params)
162+ . map_err ( |err| CliError :: Address ( err, "Failed to set routing params" . to_string ( ) ) ) ?;
161163
162- let execution_mode = match account_id_address. to_note_tag ( ) . execution_mode ( ) {
164+ let note_tag = NoteTag :: from_account_id ( account_id) ;
165+ let execution_mode = match note_tag. execution_mode ( ) {
163166 NoteExecutionMode :: Local => "Local" ,
164167 NoteExecutionMode :: Network => "Network" ,
165168 } ;
166- client. add_address ( account_id_address . into ( ) , account_id) . await ?;
169+ client. add_address ( address , account_id) . await ?;
167170
168171 println ! ( "Address added: Account Id {account_id} - Execution mode: {execution_mode}" ) ;
169172 Ok ( ( ) )
@@ -175,7 +178,7 @@ async fn remove_address<AUTH>(
175178 address : String ,
176179) -> Result < ( ) , CliError > {
177180 let account_id = parse_account_id ( & client, & account_id) . await ?;
178- let ( _, address) = Address :: from_bech32 ( & address) . map_err ( |e| CliError :: Address ( e, address) ) ?;
181+ let ( _, address) = Address :: decode ( & address) . map_err ( |e| CliError :: Address ( e, address) ) ?;
179182 let execution_mode = match address. to_note_tag ( ) . execution_mode ( ) {
180183 NoteExecutionMode :: Local => "Local" ,
181184 NoteExecutionMode :: Network => "Network" ,
0 commit comments