2121
2222extern crate blockstack_lib;
2323
24+ use std:: convert:: TryFrom ;
25+ use std:: io:: prelude:: * ;
26+ use std:: io:: Read ;
27+ use std:: { env, fs, io} ;
28+
29+ use blockstack_lib:: address:: b58;
2430use blockstack_lib:: address:: AddressHashMode ;
31+ use blockstack_lib:: burnchains:: bitcoin:: address:: {
32+ ADDRESS_VERSION_MAINNET_SINGLESIG , ADDRESS_VERSION_TESTNET_SINGLESIG ,
33+ } ;
2534use blockstack_lib:: burnchains:: Address ;
2635use blockstack_lib:: chainstate:: stacks:: {
27- StacksAddress , StacksBlock , StacksMicroblock , StacksPrivateKey , StacksPublicKey ,
28- StacksTransaction , StacksTransactionSigner , TokenTransferMemo , TransactionAnchorMode ,
29- TransactionAuth , TransactionContractCall , TransactionPayload , TransactionSmartContract ,
36+ StacksBlock , StacksMicroblock , StacksPrivateKey , StacksPublicKey , StacksTransaction ,
37+ StacksTransactionSigner , TokenTransferMemo , TransactionAnchorMode , TransactionAuth ,
38+ TransactionContractCall , TransactionPayload , TransactionSmartContract ,
3039 TransactionSpendingCondition , TransactionVersion , C32_ADDRESS_VERSION_MAINNET_SINGLESIG ,
3140 C32_ADDRESS_VERSION_TESTNET_SINGLESIG ,
3241} ;
42+ use blockstack_lib:: codec:: { Error as CodecError , StacksMessageCodec } ;
3343use blockstack_lib:: core:: { CHAIN_ID_MAINNET , CHAIN_ID_TESTNET } ;
34- use blockstack_lib:: net:: { Error as NetError , StacksMessageCodec } ;
44+ use blockstack_lib:: net:: Error as NetError ;
45+ use blockstack_lib:: types:: chainstate:: StacksAddress ;
3546use blockstack_lib:: util:: {
3647 hash:: hex_bytes, hash:: to_hex, log, retry:: LogReader , strings:: StacksString ,
3748} ;
@@ -41,15 +52,6 @@ use blockstack_lib::vm::{
4152 types:: PrincipalData ,
4253 ClarityName , ContractName , Value ,
4354} ;
44- use std:: convert:: TryFrom ;
45- use std:: io:: prelude:: * ;
46- use std:: io:: Read ;
47- use std:: { env, fs, io} ;
48-
49- use blockstack_lib:: address:: b58;
50- use blockstack_lib:: burnchains:: bitcoin:: address:: {
51- ADDRESS_VERSION_MAINNET_SINGLESIG , ADDRESS_VERSION_TESTNET_SINGLESIG ,
52- } ;
5355
5456const USAGE : & str = "blockstack-cli (options) [method] [args...]
5557
@@ -215,6 +217,12 @@ impl From<NetError> for CliError {
215217 }
216218}
217219
220+ impl From < CodecError > for CliError {
221+ fn from ( value : CodecError ) -> Self {
222+ CliError :: Message ( format ! ( "Stacks CodecError: {}" , value) )
223+ }
224+ }
225+
218226impl From < std:: num:: ParseIntError > for CliError {
219227 fn from ( value : std:: num:: ParseIntError ) -> Self {
220228 CliError :: Message ( format ! ( "Failed to parse integer: {}" , value) )
@@ -779,6 +787,7 @@ fn main_handler(mut argv: Vec<String>) -> Result<String, CliError> {
779787#[ cfg( test) ]
780788mod test {
781789 use super :: * ;
790+
782791 #[ test]
783792 fn generate_should_work ( ) {
784793 assert ! ( main_handler( vec![ "generate-sk" . into( ) , "--testnet" . into( ) ] ) . is_ok( ) ) ;
0 commit comments