Skip to content

Commit

Permalink
Merge branch 'master' into evgenii/ordered_datum_map
Browse files Browse the repository at this point in the history
  • Loading branch information
lisicky authored Feb 6, 2023
2 parents 5e2dd0d + 38bbca6 commit b337499
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardano-serialization-lib",
"version": "11.2.1",
"version": "11.3.0",
"description": "(De)serialization functions for the Cardano blockchain along with related utility functions",
"scripts": {
"rust:build-nodejs": "(rimraf ./rust/pkg && cd rust; wasm-pack build --target=nodejs; cd ..; npm run js:ts-json-gen; cd rust; wasm-pack pack) && npm run js:flowgen",
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cardano-serialization-lib"
version = "11.2.1"
version = "11.3.0"
edition = "2018"
authors = ["EMURGO"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion rust/json-gen/Cargo.lock

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

19 changes: 19 additions & 0 deletions rust/pkg/cardano_serialization_lib.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -3954,6 +3954,11 @@ declare export class MintBuilder {
*/
get_plutus_witnesses(): PlutusWitnesses;

/**
* @returns {TransactionInputs}
*/
get_ref_inputs(): TransactionInputs;

/**
* @returns {Redeemers}
*/
Expand Down Expand Up @@ -5007,6 +5012,10 @@ declare export class PlutusScriptSource {
static new(script: PlutusScript): PlutusScriptSource;

/**
* !!! DEPRECATED !!!
* This constructor has missed information about plutus script language vesrion. That can affect
* the script data hash calculation.
* Use `.new_ref_input_with_lang_ver` instead
* @param {ScriptHash} script_hash
* @param {TransactionInput} input
* @returns {PlutusScriptSource}
Expand Down Expand Up @@ -5131,6 +5140,16 @@ declare export class PlutusWitness {
redeemer: Redeemer
): PlutusWitness;

/**
* @param {PlutusScriptSource} script
* @param {Redeemer} redeemer
* @returns {PlutusWitness}
*/
static new_with_ref_without_datum(
script: PlutusScriptSource,
redeemer: Redeemer
): PlutusWitness;

/**
* @returns {PlutusScript | void}
*/
Expand Down
185 changes: 184 additions & 1 deletion rust/src/tx_builder.rs

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions rust/src/tx_builder/mint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ impl MintBuilder {
match script_mint {
ScriptMint::Plutus(plutus_mints) => {
for (redeemer, _) in &plutus_mints.redeemer_mints {
if let PlutusScriptSourceEnum::Script(script) = &plutus_mints.script {
plutus_witnesses.push(PlutusWitness::new_without_datum(script, redeemer));
}
plutus_witnesses.push(
PlutusWitness::new_with_ref_without_datum(
&PlutusScriptSource(plutus_mints.script.clone()),
redeemer)
);
}
},
_ => {},
Expand All @@ -159,6 +161,21 @@ impl MintBuilder {
PlutusWitnesses(plutus_witnesses)
}

pub fn get_ref_inputs(&self) -> TransactionInputs {
let mut reference_inputs = Vec::new();
for script_mint in self.mints.values() {
match script_mint {
ScriptMint::Plutus(plutus_mints) => {
if let PlutusScriptSourceEnum::RefInput(ref_input, _, _) = &plutus_mints.script {
reference_inputs.push(ref_input.clone());
}
},
_ => {},
}
}
TransactionInputs(reference_inputs)
}

pub fn get_redeeemers(&self) -> Result<Redeemers, JsError> {
let mut redeeemers = Vec::new();
let mut index = BigNum::zero();
Expand Down
16 changes: 16 additions & 0 deletions rust/src/tx_builder/tx_inputs_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ impl PlutusScriptSource {
Self(PlutusScriptSourceEnum::Script(script.clone()))
}

/// !!! DEPRECATED !!!
/// This constructor has missed information about plutus script language vesrion. That can affect
/// the script data hash calculation.
/// Use `.new_ref_input_with_lang_ver` instead
#[deprecated(
since = "11.3.0",
note = "This constructor has missed information about plutus script language vesrion. That can affect the script data hash calculation. Use `.new_ref_input_with_lang_ver` instead."
)]
pub fn new_ref_input(script_hash: &ScriptHash, input: &TransactionInput) -> Self {
Self(PlutusScriptSourceEnum::RefInput(input.clone(),
script_hash.clone(),
Expand Down Expand Up @@ -157,6 +165,14 @@ impl PlutusWitness {
}
}

pub fn new_with_ref_without_datum(script: &PlutusScriptSource, redeemer: &Redeemer) -> Self {
Self {
script: script.0.clone(),
datum: None,
redeemer: redeemer.clone(),
}
}

pub fn script(&self) -> Option<PlutusScript> {
match &self.script {
PlutusScriptSourceEnum::Script(script) => Some(script.clone()),
Expand Down
2 changes: 1 addition & 1 deletion rust/src/tx_builder_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct TxBuilderConstants();
#[wasm_bindgen]
impl TxBuilderConstants {
pub fn plutus_default_cost_models() -> Costmdls {
TxBuilderConstants::plutus_alonzo_cost_models()
TxBuilderConstants::plutus_vasil_cost_models()
}

pub fn plutus_alonzo_cost_models() -> Costmdls {
Expand Down

0 comments on commit b337499

Please sign in to comment.