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
10 changes: 8 additions & 2 deletions crates/trp/src/compiler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pallas::ledger::primitives::conway::CostModels;
use std::collections::HashMap;

use dolos_core::{Domain, Genesis};
use dolos_core::{ChainPoint, Domain, Genesis, StateStore};

use crate::{Config, Error};

Expand Down Expand Up @@ -50,18 +50,24 @@

Ok(out)
}

pub fn load_compiler<D: Domain>(
domain: &D,
config: &Config,
) -> Result<tx3_cardano::Compiler, Error> {
let pparams = build_pparams::<D>(domain)?;

let cursor = domain.state().read_cursor()?.ok_or(Error::TipNotResolved)?;
let slot = cursor.slot();
let hash = cursor.hash().map(|h| h.to_vec()).unwrap_or_default();

let tip = tx3_cardano::ChainPoint { slot, hash };

Check failure on line 63 in crates/trp/src/compiler.rs

View workflow job for this annotation

GitHub Actions / Check Build

cannot find struct, variant or union type `ChainPoint` in crate `tx3_cardano`

let compiler = tx3_cardano::Compiler::new(

Check failure on line 65 in crates/trp/src/compiler.rs

View workflow job for this annotation

GitHub Actions / Check Build

this function takes 2 arguments but 3 arguments were supplied
pparams,
tx3_cardano::Config {
extra_fees: config.extra_fees,
},
tip,
);

Ok(compiler)
Expand Down
5 changes: 5 additions & 0 deletions crates/trp/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum Error {

#[error("tx script returned failure")]
TxScriptFailure(Vec<String>),

#[error("failed to resolve tip slot/hash")]
TipNotResolved,
}

trait IntoErrorData {
Expand Down Expand Up @@ -128,6 +131,7 @@ impl Error {
pub const CODE_MISSING_TX_ARG: i32 = -32001;
pub const CODE_INPUT_NOT_RESOLVED: i32 = -32002;
pub const CODE_TX_SCRIPT_FAILURE: i32 = -32003;
pub const CODE_TIP_NOT_RESOLVED: i32 = -32004;

pub fn code(&self) -> i32 {
match self {
Expand All @@ -149,6 +153,7 @@ impl Error {
Error::MissingTxArg { .. } => Self::CODE_MISSING_TX_ARG,
Error::InputNotResolved(_, _, _) => Self::CODE_INPUT_NOT_RESOLVED,
Error::TxScriptFailure(_) => Self::CODE_TX_SCRIPT_FAILURE,
Error::TipNotResolved => Self::CODE_TIP_NOT_RESOLVED,
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/trp/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mod tests {
const SUBJECT_PROTOCOL: &str = r#"
party Sender;
party Receiver;

tx swap(quantity: Int) {
input source {
from: Sender,
Expand Down
Loading