Skip to content

Commit

Permalink
fix: remove unnecesary panics
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Apr 30, 2022
1 parent a3a2e57 commit ec4838b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion faucet/src/faucet/simple_faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const DEFAULT_GAS_BUDGET: u64 = 1000;

impl SimpleFaucet {
pub async fn new(mut wallet: WalletContext) -> Result<Self, FaucetError> {
let active_address = wallet.active_address().unwrap();
let active_address = wallet
.active_address()
.map_err(|err| FaucetError::Wallet(err.to_string()))?;
info!("SimpleFaucet::new with active address: {active_address}");

let mut coins = wallet
Expand Down
10 changes: 7 additions & 3 deletions faucet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ async fn main() -> Result<(), anyhow::Error> {
info!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
.await?;
Ok(())
}

Expand Down Expand Up @@ -138,7 +137,12 @@ async fn create_wallet_context() -> Result<WalletContext, anyhow::Error> {
let wallet_conf = sui_config_dir()?.join(SUI_WALLET_CONFIG);
info!("Initialize wallet from config path: {:?}", wallet_conf);
let mut context = WalletContext::new(&wallet_conf)?;
let address = context.config.accounts.first().cloned().unwrap();
let address = context
.config
.accounts
.first()
.cloned()
.ok_or_else(|| anyhow::anyhow!("Empty wallet context!"))?;

// Sync client to retrieve objects from the network.
WalletCommands::SyncClientState {
Expand Down
3 changes: 1 addition & 2 deletions sui/src/bin/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ async fn main() -> Result<(), anyhow::Error> {
&consensus_parameters,
Some(net),
)
.await
.unwrap()
.await?
.spawn_with_bind_address(&listen_address)
.await
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion sui/src/bin/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn main() -> Result<(), anyhow::Error> {

let mut app: Command = ClientOpt::command();
app = app.no_binary_name(false);
let options: ClientOpt = ClientOpt::from_arg_matches(&app.get_matches()).unwrap();
let options: ClientOpt = ClientOpt::from_arg_matches(&app.get_matches())?;
let wallet_conf_path = options
.config
.clone()
Expand Down

0 comments on commit ec4838b

Please sign in to comment.