@@ -117,24 +117,31 @@ pub struct AccountData {
117117 pub signer_type : SignerType ,
118118}
119119
120- impl From < AccountData > for accounts:: AccountRecord {
121- fn from ( account : AccountData ) -> Self {
120+ impl TryFrom < AccountData > for accounts:: AccountRecord {
121+ type Error = accounts:: AccountsError ;
122+
123+ fn try_from ( account : AccountData ) -> Result < Self , Self :: Error > {
122124 let signer = match account. signer_type {
123125 SignerType :: Local { private_key } => {
124126 SignerSpec :: PrivateKey ( PrivateKeySpec :: new ( private_key) )
125127 }
126128 SignerType :: Ledger { ledger_path } => SignerSpec :: Ledger ( LedgerSpec :: new ( ledger_path) ) ,
127129 } ;
128- Self {
130+ Ok ( Self {
129131 public_key : account. public_key ,
130- address : account. address ,
132+ address : account
133+ . address
134+ . ok_or ( accounts:: AccountsError :: MissingField {
135+ field : "address" ,
136+ operation : "connected account use" ,
137+ } ) ?,
131138 salt : account. salt ,
132139 deployed : account. deployed ,
133140 class_hash : account. class_hash ,
134141 legacy : account. legacy ,
135142 account_type : account. account_type ,
136143 signer,
137- }
144+ } )
138145 }
139146}
140147
@@ -382,7 +389,7 @@ pub async fn get_account_from_repository<'a>(
382389 let chain_id = get_chain_id ( provider) . await ?;
383390 let ( account_data, signer) = if let Some ( keystore) = keystore {
384391 let account_data: accounts:: AccountRecord =
385- get_account_data_from_keystore ( account, keystore) ?. into ( ) ;
392+ get_account_data_from_keystore ( account, keystore) ?. try_into ( ) ? ;
386393 let private_key = account_data
387394 . signer
388395 . private_key ( )
@@ -442,9 +449,7 @@ pub(crate) async fn build_account(
442449 provider : & JsonRpcClient < HttpTransport > ,
443450 signer : RuntimeSigner ,
444451) -> Result < RuntimeAccount < ' _ > > {
445- let address = account_data
446- . address
447- . context ( "Failed to get account address" ) ?;
452+ let address = account_data. address ;
448453
449454 verify_account_address ( address, chain_id, provider) . await ?;
450455
@@ -595,7 +600,7 @@ pub fn get_account_data_from_repository(
595600 } ;
596601 Ok ( AccountData {
597602 public_key : account. public_key ,
598- address : account. address ,
603+ address : Some ( account. address ) ,
599604 salt : account. salt ,
600605 deployed : account. deployed ,
601606 class_hash : account. class_hash ,
0 commit comments