@@ -139,11 +139,7 @@ where
139139 id_to_hex_string( * new_tx. tx_id. as_hash( ) )
140140 )
141141 } else {
142- let hex = new_tx. tx . to_string ( ) ;
143- let mut summary = new_tx. tx . take ( ) . transaction ( ) . text_summary ( chain_config) ;
144- format_fees ( & mut summary, & new_tx. fees ) ;
145-
146- format ! ( "{summary}\n The transaction was created and is ready to be submitted:\n {hex}" , )
142+ format_tx_to_be_broadcasted ( new_tx. tx , & new_tx. fees , chain_config)
147143 } ;
148144
149145 ConsoleCommand :: Print ( status_text)
@@ -1157,11 +1153,17 @@ where
11571153 )
11581154 . await ?;
11591155
1160- Ok ( ConsoleCommand :: Print ( format ! (
1161- "A new token has been issued with ID: {} in tx: {}" ,
1162- new_token. token_id,
1163- id_to_hex_string( * new_token. tx_id. as_hash( ) )
1164- ) ) )
1156+ let result = if new_token. broadcasted {
1157+ format ! (
1158+ "A new token has been issued with ID: {} in tx: {}" ,
1159+ new_token. token_id,
1160+ id_to_hex_string( * new_token. tx_id. as_hash( ) )
1161+ )
1162+ } else {
1163+ format_tx_to_be_broadcasted ( new_token. tx , & new_token. fees , chain_config)
1164+ } ;
1165+
1166+ Ok ( ConsoleCommand :: Print ( result) )
11651167 }
11661168
11671169 WalletCommand :: IssueNewNft {
@@ -1191,11 +1193,17 @@ where
11911193 . issue_new_nft ( selected_account, destination_address, metadata, self . config )
11921194 . await ?;
11931195
1194- Ok ( ConsoleCommand :: Print ( format ! (
1195- "A new NFT has been issued with ID: {} in tx: {}" ,
1196- new_token. token_id,
1197- id_to_hex_string( * new_token. tx_id. as_hash( ) )
1198- ) ) )
1196+ let result = if new_token. broadcasted {
1197+ format ! (
1198+ "A new NFT has been issued with ID: {} in tx: {}" ,
1199+ new_token. token_id,
1200+ id_to_hex_string( * new_token. tx_id. as_hash( ) )
1201+ )
1202+ } else {
1203+ format_tx_to_be_broadcasted ( new_token. tx , & new_token. fees , chain_config)
1204+ } ;
1205+
1206+ Ok ( ConsoleCommand :: Print ( result) )
11991207 }
12001208
12011209 WalletCommand :: MintTokens {
@@ -1670,30 +1678,43 @@ where
16701678
16711679 WalletCommand :: CreateDelegation { owner, pool_id } => {
16721680 let ( wallet, selected_account) = wallet_and_selected_acc ( & mut self . wallet ) . await ?;
1673- let delegation_id = wallet
1674- . create_delegation ( selected_account, owner, pool_id, self . config )
1675- . await ?
1676- . delegation_id ;
1681+ let new_delegation =
1682+ wallet. create_delegation ( selected_account, owner, pool_id, self . config ) . await ?;
16771683
1678- Ok ( ConsoleCommand :: Print ( format ! (
1679- "Success, the creation of delegation transaction was broadcast to the network. Delegation id: {}" ,
1680- delegation_id
1681- ) ) )
1684+ let result = if new_delegation. broadcasted {
1685+ format ! (
1686+ "Success, the creation of delegation transaction was broadcast to the network. Delegation id: {} in tx: {}" ,
1687+ new_delegation. delegation_id,
1688+ id_to_hex_string( * new_delegation. tx_id. as_hash( ) )
1689+ )
1690+ } else {
1691+ format_tx_to_be_broadcasted (
1692+ new_delegation. tx ,
1693+ & new_delegation. fees ,
1694+ chain_config,
1695+ )
1696+ } ;
1697+
1698+ Ok ( ConsoleCommand :: Print ( result) )
16821699 }
16831700
16841701 WalletCommand :: DelegateStaking {
16851702 amount,
16861703 delegation_id,
16871704 } => {
16881705 let ( wallet, selected_account) = wallet_and_selected_acc ( & mut self . wallet ) . await ?;
1689- wallet
1706+ let new_tx = wallet
16901707 . delegate_staking ( selected_account, amount, delegation_id, self . config )
16911708 . await ?;
16921709
1693- Ok ( ConsoleCommand :: Print (
1710+ let result = if new_tx . broadcasted {
16941711 "Success, the delegation staking transaction was broadcast to the network"
1695- . to_owned ( ) ,
1696- ) )
1712+ . to_owned ( )
1713+ } else {
1714+ format_tx_to_be_broadcasted ( new_tx. tx , & new_tx. fees , chain_config)
1715+ } ;
1716+
1717+ Ok ( ConsoleCommand :: Print ( result) )
16971718 }
16981719
16991720 WalletCommand :: WithdrawFromDelegation {
@@ -1702,7 +1723,7 @@ where
17021723 delegation_id,
17031724 } => {
17041725 let ( wallet, selected_account) = wallet_and_selected_acc ( & mut self . wallet ) . await ?;
1705- wallet
1726+ let new_tx = wallet
17061727 . withdraw_from_delegation (
17071728 selected_account,
17081729 address,
@@ -1711,9 +1732,8 @@ where
17111732 self . config ,
17121733 )
17131734 . await ?;
1714- Ok ( ConsoleCommand :: Print (
1715- "Success. The transaction was broadcast to the network" . to_owned ( ) ,
1716- ) )
1735+
1736+ Ok ( Self :: new_tx_command ( new_tx, chain_config) )
17171737 }
17181738
17191739 WalletCommand :: CreateStakePool {
@@ -1953,6 +1973,18 @@ where
19531973 }
19541974}
19551975
1976+ fn format_tx_to_be_broadcasted (
1977+ tx : HexEncoded < SignedTransaction > ,
1978+ fees : & Balances ,
1979+ chain_config : & ChainConfig ,
1980+ ) -> String {
1981+ let hex = tx. to_string ( ) ;
1982+ let mut summary = tx. take ( ) . transaction ( ) . text_summary ( chain_config) ;
1983+ format_fees ( & mut summary, fees) ;
1984+
1985+ format ! ( "{summary}\n The transaction was created and is ready to be submitted:\n {hex}" )
1986+ }
1987+
19561988fn format_signature_status ( ( idx, status) : ( usize , & RpcSignatureStatus ) ) -> String {
19571989 let status = match status {
19581990 RpcSignatureStatus :: FullySigned => "FullySigned" . to_owned ( ) ,
0 commit comments