Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions balius-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ pub use balius_macros as macros;
/// Macro to mark the main function for the worker
pub use balius_macros::main;

/// Transaction builder artifacts
pub mod txbuilder;

/// Internal functions to be used by the generated code
pub mod _internal;

Expand Down
61 changes: 14 additions & 47 deletions balius-sdk/src/qol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::marker::PhantomData;

use pallas_primitives::Fragment;
use thiserror::Error;
use utxorpc_spec::utxorpc::v1alpha::cardano::PParams;

use crate::_internal::Handler;
use crate::wit;
Expand All @@ -9,22 +11,30 @@ use crate::wit;
pub enum Error {
#[error("internal error: {0}")]
Internal(String),

#[error("bad config")]
BadConfig,

#[error("bad params")]
BadParams,

#[error("bad utxo")]
BadUtxo,

#[error("event mismatch, expected {0}")]
EventMismatch(String),

#[error("kv error: {0}")]
KV(wit::balius::app::kv::KvError),
KV(#[from] wit::balius::app::kv::KvError),

#[error("ledger error: {0}")]
Ledger(wit::balius::app::ledger::LedgerError),
Ledger(#[from] wit::balius::app::ledger::LedgerError),

#[error("sign error: {0}")]
Sign(wit::balius::app::sign::SignError),
Sign(#[from] wit::balius::app::sign::SignError),

#[error("http error: {0}")]
Http(wit::balius::app::http::ErrorCode),
Http(#[from] wit::balius::app::http::ErrorCode),
}

impl From<Error> for wit::HandleError {
Expand Down Expand Up @@ -76,36 +86,6 @@ impl From<serde_json::Error> for Error {
}
}

impl From<wit::balius::app::kv::KvError> for Error {
fn from(error: wit::balius::app::kv::KvError) -> Self {
Error::KV(error)
}
}

impl From<wit::balius::app::ledger::LedgerError> for Error {
fn from(error: wit::balius::app::ledger::LedgerError) -> Self {
Error::Ledger(error)
}
}

impl From<wit::balius::app::sign::SignError> for Error {
fn from(error: wit::balius::app::sign::SignError) -> Self {
Error::Sign(error)
}
}

impl From<wit::balius::app::http::ErrorCode> for Error {
fn from(error: wit::balius::app::http::ErrorCode) -> Self {
Error::Http(error)
}
}

impl From<crate::txbuilder::BuildError> for Error {
fn from(error: crate::txbuilder::BuildError) -> Self {
Error::Internal(error.to_string())
}
}

pub type WorkerResult<T> = std::result::Result<T, Error>;

pub struct FnHandler<F, C, E, R>
Expand Down Expand Up @@ -281,19 +261,6 @@ impl<D> TryFrom<wit::Event> for Utxo<D> {
}
}

pub struct NewTx(pub Box<dyn crate::txbuilder::TxExpr>);

impl TryInto<wit::Response> for NewTx {
type Error = Error;

fn try_into(self) -> Result<wit::Response, Self::Error> {
let ledger = crate::txbuilder::ExtLedgerFacade;
let tx = crate::txbuilder::build(self.0, ledger)?;
let cbor = pallas_codec::minicbor::to_vec(&tx).unwrap();
Ok(wit::Response::PartialTx(cbor))
}
}

impl crate::_internal::Worker {
pub fn new() -> Self {
Self::default()
Expand Down
Loading
Loading