Skip to content

Commit

Permalink
cli: implement resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 25, 2023
1 parent 3961b4d commit d47871f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
17 changes: 9 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ strict_types = { workspace = true }
bp-core = { workspace = true }
bp-std = { workspace = true }
bp-wallet = { workspace = true, features = ["fs"] }
bp-esplora = { workspace = true, optional = true }
bp-esplora = { workspace = true, features = ["rgb"], optional = true }
descriptors = { workspace = true }
rgb-std = { workspace = true }
rgb-psbt = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Exec for RgbArgs {
);
}
UniversalBindle::Contract(bindle) => {
let mut resolver = self.resolver();
let mut resolver = self.resolver()?;
let id = bindle.id();
let contract = bindle
.unbindle()
Expand Down Expand Up @@ -714,7 +714,7 @@ impl Exec for RgbArgs {
eprintln!("Dump is successfully generated and saved to '{root_dir}'");
}
Command::Validate { file } => {
let mut resolver = self.resolver();
let mut resolver = self.resolver()?;
let bindle = Bindle::<Transfer>::load_file(file)?;
let status = match bindle
.unbindle()
Expand All @@ -728,7 +728,7 @@ impl Exec for RgbArgs {
}
Command::Accept { force, file } => {
let mut runtime = self.rgb_runtime(&config)?;
let mut resolver = self.resolver();
let mut resolver = self.resolver()?;
let bindle = Bindle::<Transfer>::load_file(file)?;
let transfer = bindle
.unbindle()
Expand Down
15 changes: 2 additions & 13 deletions cli/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,7 @@ impl ResolveTx for PanickingResolver {
}

impl RgbArgs {
pub fn resolver(&self) -> impl ResolveTx + ResolveHeight {
#[derive(Default)]
struct DumbResolver();
impl ResolveHeight for DumbResolver {
type Error = Infallible;
fn resolve_anchor(&mut self, _: &XAnchor) -> Result<WitnessAnchor, Self::Error> {
todo!()
}
}
impl ResolveTx for DumbResolver {
fn resolve_bp_tx(&self, _: Layer1, _: Txid) -> Result<Tx, TxResolverError> { todo!() }
}
DumbResolver::default()
pub fn resolver(&self) -> Result<impl ResolveTx + ResolveHeight, esplora::Error> {
esplora::Builder::new(&self.resolver.esplora).build_blocking()
}
}
3 changes: 3 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ pub enum RuntimeError {
#[from(bpwallet::LoadError)]
Bp(bpwallet::RuntimeError),

#[from]
Esplora(esplora::Error),

#[from]
Yaml(serde_yaml::Error),

Expand Down

0 comments on commit d47871f

Please sign in to comment.