Skip to content

Commit

Permalink
cli: improve contract state reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jun 8, 2024
1 parent 8e4f799 commit b2a4fbc
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 85 deletions.
59 changes: 30 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bp-electrum = "0.11.0-beta.6"
bp-esplora = "0.11.0-beta.6"
descriptors = "0.11.0-beta.6"
psbt = { version = "0.11.0-beta.6", features = ["client-side-validation"] }
bp-wallet = { version = "0.11.0-beta.6" }
bp-wallet = { version = "0.11.0-beta.6.1" }
rgb-std = { version = "0.11.0-beta.6", features = ["fs"] }
rgb-psbt = { version = "0.11.0-beta.6", path = "psbt" }
rgb-interfaces = "0.11.0-beta.6"
Expand Down Expand Up @@ -74,6 +74,7 @@ descriptors = { workspace = true }
bp-wallet = { workspace = true }
rgb-std = { workspace = true }
rgb-psbt = { workspace = true }
rgb-interfaces = { workspace = true }
indexmap = { workspace = true }
chrono = { workspace = true }
serde_crate = { workspace = true, optional = true }
Expand Down
14 changes: 12 additions & 2 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Default for RgbArgs {
}

impl RgbArgs {
fn load_stock(&self, stock_path: &Path) -> Result<Stock, WalletError> {
pub(crate) fn load_stock(&self, stock_path: &Path) -> Result<Stock, WalletError> {
if self.verbose > 1 {
eprint!("Loading stock ... ");
}
Expand Down Expand Up @@ -112,6 +112,15 @@ impl RgbArgs {
) -> Result<StoredWallet<Wallet<XpubDerivable, RgbDescr>>, WalletError> {
let stock_path = self.general.base_dir();
let stock = self.load_stock(&stock_path)?;
self.rgb_wallet_from_stock(config, stock)
}

pub fn rgb_wallet_from_stock(
&self,
config: &Config,
stock: Stock,
) -> Result<StoredWallet<Wallet<XpubDerivable, RgbDescr>>, WalletError> {
let stock_path = self.general.base_dir();
let wallet = self.inner.bp_runtime::<RgbDescr>(config)?;
let wallet_path = wallet.path().clone();
let wallet = StoredWallet::attach(stock_path, wallet_path, stock, wallet.detach());
Expand All @@ -123,7 +132,8 @@ impl RgbArgs {
let resolver = match (&self.resolver.esplora, &self.resolver.electrum) {
(None, Some(url)) => AnyResolver::electrum_blocking(url, None),
(Some(url), None) => AnyResolver::esplora_blocking(url, None),
_ => unreachable!("clap is broken"),
_ => Err(s!(" - error: no transaction resolver is specified; use either --esplora \
or --electrum argument")),
}
.map_err(WalletError::Resolver)?;
resolver.check(self.general.network)?;
Expand Down
Loading

0 comments on commit b2a4fbc

Please sign in to comment.