1+ use stellar_xdr:: curr:: MuxedAccount ;
2+
13use crate :: {
24 commands:: {
35 global,
46 tx:: xdr:: { tx_envelope_from_input, Error as XdrParsingError } ,
57 } ,
6- config,
8+ config:: { self , locator , network } ,
79 xdr:: { self , SequenceNumber , TransactionEnvelope , WriteXdr } ,
810} ;
911
1012#[ derive( clap:: Parser , Debug , Clone ) ]
1113pub struct Cmd {
1214 #[ command( flatten) ]
13- pub config : config:: Args ,
15+ pub network : network:: Args ,
16+ #[ command( flatten) ]
17+ pub locator : locator:: Args ,
1418}
1519
1620#[ derive( thiserror:: Error , Debug ) ]
@@ -44,7 +48,8 @@ impl Cmd {
4448 ) -> Result < ( ) , Error > {
4549 match tx_env {
4650 TransactionEnvelope :: Tx ( transaction_v1_envelope) => {
47- let current_seq_num = self . current_seq_num ( ) . await ?;
51+ let tx_source_acct = & transaction_v1_envelope. tx . source_account ;
52+ let current_seq_num = self . current_seq_num ( tx_source_acct) . await ?;
4853 let next_seq_num = current_seq_num + 1 ;
4954 transaction_v1_envelope. tx . seq_num = SequenceNumber ( next_seq_num) ;
5055 }
@@ -55,20 +60,14 @@ impl Cmd {
5560 Ok ( ( ) )
5661 }
5762
58- async fn current_seq_num ( & self ) -> Result < i64 , Error > {
59- let network = & self . config . get_network ( ) ?;
63+ async fn current_seq_num ( & self , tx_source_acct : & MuxedAccount ) -> Result < i64 , Error > {
64+ let network = & self . network . get ( & self . locator ) ?;
6065 let client = network. rpc_client ( ) ?;
6166 client
6267 . verify_network_passphrase ( Some ( & network. network_passphrase ) )
6368 . await ?;
6469
65- let muxed_account = self . config . source_account ( ) . await ?;
66-
67- let bytes = match muxed_account {
68- soroban_sdk:: xdr:: MuxedAccount :: Ed25519 ( uint256) => uint256. 0 ,
69- soroban_sdk:: xdr:: MuxedAccount :: MuxedEd25519 ( muxed_account) => muxed_account. ed25519 . 0 ,
70- } ;
71- let address = stellar_strkey:: ed25519:: PublicKey ( bytes) . to_string ( ) ;
70+ let address = tx_source_acct. to_string ( ) ;
7271
7372 let account = client. get_account ( & address) . await ?;
7473 Ok ( * account. seq_num . as_ref ( ) )
0 commit comments