Skip to content

Commit

Permalink
com
Browse files Browse the repository at this point in the history
  • Loading branch information
eauxxs committed May 19, 2024
1 parent e9e9b6a commit 3ee5f97
Show file tree
Hide file tree
Showing 15 changed files with 799 additions and 689 deletions.
548 changes: 269 additions & 279 deletions Cargo.lock

Large diffs are not rendered by default.

84 changes: 50 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ exclude = ["migration"]
members = [".", "migration"]

[dependencies]
base64 = { version = "0.22.0", default-features = false, features = [
"std",
] }
base64 = { version = "0.22.0", default-features = false, features = ["std"] }
bdk = { version = "0.29", default-features = false, features = [
"key-value-db",
"keys-bip39",
Expand All @@ -34,9 +32,7 @@ electrum-client = { version = "0.19.0", optional = true, default-features = fals
"proxy",
"use-rustls",
] }
futures = { version = "0.3", default-features = false, features = [
"executor",
] }
futures = { version = "0.3", default-features = false, features = ["executor"] }
hex = { version = "0.4.3", default-features = false }
rand = { version = "0.8.5", default-features = false }
reqwest = { version = "0.12", default-features = false, features = [
Expand All @@ -56,9 +52,7 @@ sea-orm = { version = "=0.12.15", default-features = false, features = [
"sqlx-sqlite",
] }
sea-query = { version = "=0.30.7", default-features = false }
serde = { version = "^1.0", default-features = false, features = [
"derive",
] }
serde = { version = "^1.0", default-features = false, features = ["derive"] }
serde_json = { version = "^1.0", default-features = false, features = [
"preserve_order",
] }
Expand All @@ -71,34 +65,37 @@ time = { version = "0.3.34", default-features = false }
tree_magic = { version = "0.2.3", default-features = false }
typenum = { version = "1.17.0", default-features = false }
walkdir = { version = "2.5.0", default-features = false }
zip = { version = "0.6.6", default-features = false, features = [
"zstd",
] }
zip = { version = "0.6.6", default-features = false, features = ["zstd"] }

# RGB-related deps
amplify = { version = "=4.6.0", default-features = false }
bp-core = { version = "=0.11.0-beta.5", default-features = false }
bp-electrum = { version = "=0.11.0-beta.5", optional = true, default-features = false, features = [
amplify = { version = "4.6.0", default-features = false }
bp-core = { version = "0.11.0-beta.5", default-features = false }
bp-electrum = { version = "0.11.0-beta.5", optional = true, default-features = false, features = [
"proxy",
"use-rustls",
] }
bp-seals = { version = "=0.11.0-beta.5", default-features = false }
bp-std = { version = "=0.11.0-beta.5", default-features = false }
commit_verify = { version = "=0.11.0-beta.5", default-features = false }
rgb-core = { version = "=0.11.0-beta.5", default-features = false, features = [
bp-seals = { version = "0.11.0-beta.5", default-features = false }
bp-std = { version = "0.11.0-beta.5", default-features = false }
commit_verify = { version = "0.11.0-beta.5", default-features = false }
rgb-core = { version = "0.11.0-beta.5", default-features = false, features = [
"stl",
] }
rgb-invoice = { version = "=0.11.0-beta.5", default-features = false }
rgb-persist-fs = { version = "=0.11.1", default-features = false }
rgb-psbt = { version = "=0.11.0-beta.5", default-features = false }
rgb-runtime = { version = "=0.11.0-beta.5", default-features = false, features = [
"serde",
rgb-invoice = { version = "0.11.0-beta.5", default-features = false }
rgb-psbt = { git = "https://github.com/eauxxs/rgb", branch = "dev" }
# rgb-persist-fs = { version = "0.11.1", default-features = false }
# rgb-runtime = { version = "0.11.0-beta.5", default-features = false, features = [
# "serde",
# ] }
rgb-runtime = { git = "https://github.com/eauxxs/rgb", branch = "dev", features = [
"all",
] }
rgb-schemata = { version = "=0.11.0-beta.5", default-features = false }
rgb-std = { version = "=0.11.0-beta.5", default-features = false }
strict_encoding = { version = "=2.7.0-beta.1", default-features = false }
strict_encoding_derive = { version = "=2.7.0-beta.1", default-features = false } # temporary dependency pin
strict_types = { version = "=2.7.0-beta.2", default-features = false }
# rgb-schemata = { version = "0.11.0-beta.5", default-features = false }
rgb-schemata = { git = "https://github.com/RGB-WG/rgb-schemata", branch = "master" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "master" }
rgb-std = { version = "0.11.0-beta.5", default-features = false }
strict_encoding = { version = "2.7.0-beta.1", default-features = false }
strict_encoding_derive = { version = "2.7.0-beta.1", default-features = false } # temporary dependency pin
strict_types = { version = "2.7.0-beta.2", default-features = false }

[dev-dependencies]
copy_dir = { version = "0.1.3", default-features = false }
Expand All @@ -115,9 +112,28 @@ electrum = [
"bdk/electrum",
"bp-electrum",
"electrum-client",
"rgb-runtime/electrum",
]
esplora = [
"bdk/use-esplora-blocking",
"rgb-runtime/esplora_blocking",
# "rgb-runtime/electrum_blocking ",
]
esplora = ["bdk/use-esplora-blocking"]

[patch.crates-io]
strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "develop" }
strict_types = { git = "https://github.com/strict-types/strict-types", branch = "develop" }
commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" }
single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" }
bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "master" }
bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "master" }
bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "master" }
bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "master" }
bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
bp-derive = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "develop" }
psbt = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "develop" }
aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "develop" }
rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "develop" }
rgb-std = { git = "https://github.com/eauxxs/rgb-std", branch = "dev" }
rgb-invoice = { git = "https://github.com/eauxxs/rgb-std", branch = "dev" }
rgb-schemata = { git = "https://github.com/RGB-WG/rgb-schemata", branch = "master" }
rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "master" }
67 changes: 41 additions & 26 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
//! This module defines the [`Error`] enum, containing all error variants returned by functions in
//! the library.

use std::fmt::Display;

use rgb::persistence::{IndexProvider, MemStash, StashProvider, StateProvider, StockError};
use rgbinvoice::TransportParseError;

use super::*;

/// The error variants returned by functions.
Expand Down Expand Up @@ -449,10 +454,10 @@ pub enum InternalError {
RgbLoad(#[from] rgbstd::containers::LoadError),

#[error("RGB runtime error: {0}")]
RgbRuntime(#[from] rgb_rt::RuntimeError),
RgbRuntime(#[from] StockError),

#[error("RGB stash error: {0}")]
RgbStash(#[from] rgbstd::persistence::StashError<std::convert::Infallible>),
RgbStash(#[from] rgbstd::persistence::StashError<MemStash>),

#[error("Seal parse error: {0}")]
SealParse(#[from] bp::seals::txout::explicit::ParseError),
Expand Down Expand Up @@ -532,30 +537,30 @@ impl From<bdk::blockchain::esplora::EsploraError> for Error {
}
}

impl From<rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>>
for InternalError
{
fn from(
e: rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>,
) -> Self {
InternalError::RgbConsigner(e.to_string())
}
}

impl From<rgbstd::persistence::InventoryDataError<std::convert::Infallible>> for InternalError {
fn from(e: rgbstd::persistence::InventoryDataError<std::convert::Infallible>) -> Self {
InternalError::RgbInventoryData(e.to_string())
}
}

impl From<rgbstd::persistence::InventoryError<std::convert::Infallible>> for InternalError {
fn from(e: rgbstd::persistence::InventoryError<std::convert::Infallible>) -> Self {
InternalError::RgbInventory(e.to_string())
}
}

impl From<invoice::TransportParseError> for Error {
fn from(e: invoice::TransportParseError) -> Self {
// impl From<rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>>
// for InternalError
// {
// fn from(
// e: rgbstd::persistence::ConsignerError<std::convert::Infallible, std::convert::Infallible>,
// ) -> Self {
// InternalError::RgbConsigner(e.to_string())
// }
// }

// impl From<rgbstd::persistence::InventoryDataError<std::convert::Infallible>> for InternalError {
// fn from(e: rgbstd::persistence::InventoryDataError<std::convert::Infallible>) -> Self {
// InternalError::RgbInventoryData(e.to_string())
// }
// }

// impl From<rgbstd::persistence::InventoryError<std::convert::Infallible>> for InternalError {
// fn from(e: rgbstd::persistence::InventoryError<std::convert::Infallible>) -> Self {
// InternalError::RgbInventory(e.to_string())
// }
// }

impl From<TransportParseError> for Error {
fn from(e: TransportParseError) -> Self {
Error::InvalidTransportEndpoint {
details: e.to_string(),
}
Expand Down Expand Up @@ -593,3 +598,13 @@ impl From<rgbstd::interface::BuilderError> for Error {
}
}
}

impl<S: StashProvider, H: StateProvider, P: IndexProvider, E: Display + std::error::Error>
From<StockError<S, H, P, E>> for Error
{
fn from(value: StockError<S, H, P, E>) -> Self {
Error::Internal {
details: value.to_string(),
}
}
}
51 changes: 20 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub mod utils;
pub mod wallet;

pub use bdk::{BlockTime, SignOptions};
pub use rgbstd::{containers::Contract, contract::ContractId};
pub use rgbstd::containers::Contract;

pub use crate::{
database::enums::{AssetSchema, TransferStatus, TransportType},
Expand Down Expand Up @@ -164,57 +164,46 @@ use commit_verify::Conceal;
#[cfg(feature = "electrum")]
use electrum_client::{Client as ElectrumClient, ConfigBuilder, ElectrumApi, Param};
use futures::executor::block_on;
use psrgbt::{PropKey, ProprietaryKeyRgb};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use invoice::{Amount, Precision};
use invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, RgbTransport, XChainNet};
use psbt::{PropKey, ProprietaryKeyRgb};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use psbt::{Psbt as RgbPsbt, RgbPsbt as RgbPsbtTrait};
use psrgbt::{Psbt as RgbPsbt, RgbPsbt as RgbPsbtTrait};
use rand::{distributions::Alphanumeric, Rng};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use reqwest::{
blocking::{multipart, Client as RestClient},
header::CONTENT_TYPE,
};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use rgb::invoice::{Amount, Precision};
use rgb::invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, RgbTransport, XChainNet};
#[cfg(feature = "electrum")]
use rgb::AnyResolver as ElectrumResolver;

Check warning on line 180 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_features

unused import: `rgb::AnyResolver as ElectrumResolver`

Check failure on line 180 in src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `rgb::AnyResolver as ElectrumResolver`

Check failure on line 180 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_and_coverage

unused import: `rgb::AnyResolver as ElectrumResolver`
#[cfg(any(feature = "electrum", feature = "esplora"))]
use rgb::AnyResolver;
use rgb::{
validation::Status, Genesis, Layer1, OpId, Opout, SchemaId, SubSchema, Transition, XChain,
XOutpoint, XOutputSeal,
validation::Status, Genesis, Layer1, OpId, Opout, SchemaId, Transition, XChain, XOutpoint,

Check warning on line 184 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_features

unused imports: `Genesis`, `SchemaId`, `XOutpoint`, `validation::Status`

Check failure on line 184 in src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

unused imports: `Genesis`, `SchemaId`, `XOutpoint`, `validation::Status`

Check failure on line 184 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_and_coverage

unused imports: `Genesis`, `SchemaId`, `XOutpoint`, `validation::Status`
XOutputSeal,
};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use rgb::{validation::Validity, Assign, BlindingFactor, WitnessId};
use rgb::{validation::Validity, Assign, BlindingFactor};
use rgb_lib_migration::{Migrator, MigratorTrait};
#[cfg(feature = "electrum")]
use rgb_rt::electrum::Resolver as ElectrumResolver;
#[cfg(feature = "esplora")]
use rgb_rt::esplora_blocking::Resolver as EsploraResolver;

Check failure on line 191 in src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

failed to resolve: use of undeclared crate or module `rgb_rt`

Check failure on line 191 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_and_coverage

failed to resolve: use of undeclared crate or module `rgb_rt`
#[cfg(any(feature = "electrum", feature = "esplora"))]
use rgb_rt::AnyResolver;
use rgb_schemata::{cfa_rgb25, cfa_schema, uda_rgb21, uda_schema, NonInflatableAsset};
use rgbfs::StockFs;
use rgbstd::{
accessors::MergeReveal,
containers::{BuilderSeal, FileContent},
interface::ContractBuilder,
stl::{AssetSpec, ContractTerms, Details, Name, RicardianContract, Ticker},
};
use rgbstd::{
containers::{CloseMethodSet, Fascia, Transfer as RgbTransfer},

Check warning on line 199 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_features

unused imports: `Fascia`, `IfaceId`, `IfaceImpl`, `Iface`, `TransitionBuilder`, `resolvers::ResolveHeight`

Check failure on line 199 in src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

unused imports: `Fascia`, `IfaceId`, `IfaceImpl`, `Iface`, `TransitionBuilder`

Check failure on line 199 in src/lib.rs

View workflow job for this annotation

GitHub Actions / test_and_coverage

unused imports: `Fascia`, `IfaceId`, `IfaceImpl`, `Iface`, `TransitionBuilder`, `resolvers::ResolveHeight`
contract::GraphSeal,
interface::{
ContractIface, Iface, IfaceClass, IfaceId, IfaceImpl, IssuerClass, Rgb20, Rgb21, Rgb25,
TransitionBuilder,
},
interface::{ContractIface, Iface, IfaceClass, IfaceId, IfaceImpl, TransitionBuilder},
invoice::{ChainNet, InvoiceState},
persistence::{Inventory, PersistedState, Stash, Stock},
persistence::{PersistedState, Stock},
resolvers::ResolveHeight,

Check failure on line 203 in src/lib.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `resolvers::ResolveHeight`
stl::{Attachment, MediaType},
Operation, Txid as RgbTxid,
};
#[cfg(any(feature = "electrum", feature = "esplora"))]
use rgbstd::{
containers::{BuilderSeal, FileContent},
contract::GenesisSeal,
interface::{
rgb21::{Allocation, OwnedFraction, TokenData, TokenIndex},
ContractBuilder,
},
stl::{AssetSpec, AssetTerms, Details, Name, RicardianContract, Ticker},
};
use scrypt::{
password_hash::{PasswordHasher, Salt, SaltString},
Params, Scrypt,
Expand Down
Loading

0 comments on commit 3ee5f97

Please sign in to comment.