Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated functions #654

Merged
merged 9 commits into from
Jan 29, 2024
Merged
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
315 changes: 39 additions & 276 deletions rust/pkg/cardano_serialization_lib.js.flow

Large diffs are not rendered by default.

30 changes: 7 additions & 23 deletions rust/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ impl NetworkInfo {
protocol_magic: 1,
}
}
/// !!! DEPRECATED !!!
/// This network does not exist anymore. Use `.testnet_preview()` or `.testnet_preprod()`
#[deprecated(
since = "11.2.0",
note = "Use `.testnet_preview` or `.testnet_preprod`"
)]
pub fn testnet() -> NetworkInfo {
NetworkInfo {
network_id: 0b0000,
protocol_magic: 1097911063,
}
}
pub fn mainnet() -> NetworkInfo {
NetworkInfo {
network_id: 0b0001,
Expand Down Expand Up @@ -285,9 +273,6 @@ impl ByronAddress {
magic if magic == NetworkInfo::mainnet().protocol_magic() => {
Ok(NetworkInfo::mainnet().network_id())
}
magic if magic == NetworkInfo::testnet().protocol_magic() => {
Ok(NetworkInfo::testnet().network_id())
}
magic if magic == NetworkInfo::testnet_preprod().protocol_magic() => {
Ok(NetworkInfo::testnet_preprod().network_id())
}
Expand Down Expand Up @@ -597,7 +582,6 @@ impl Address {
_ => "addr",
};
let prefix_tail = match self.network_id()? {
id if id == NetworkInfo::testnet().network_id() => "_test",
id if id == NetworkInfo::testnet_preprod().network_id() => "_test",
id if id == NetworkInfo::testnet_preview().network_id() => "_test",
_ => "",
Expand Down Expand Up @@ -645,9 +629,9 @@ impl Deserialize for Address {
#[wasm_bindgen]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct BaseAddress {
network: u8,
payment: Credential,
stake: Credential,
pub(crate) network: u8,
pub(crate) payment: Credential,
pub(crate) stake: Credential,
}

#[wasm_bindgen]
Expand Down Expand Up @@ -683,8 +667,8 @@ impl BaseAddress {
#[wasm_bindgen]
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct EnterpriseAddress {
network: u8,
payment: Credential,
pub(crate) network: u8,
pub(crate) payment: Credential,
}

#[wasm_bindgen]
Expand Down Expand Up @@ -715,8 +699,8 @@ impl EnterpriseAddress {
#[wasm_bindgen]
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RewardAddress {
network: u8,
payment: Credential,
pub(crate) network: u8,
pub(crate) payment: Credential,
}

#[wasm_bindgen]
Expand Down
15 changes: 0 additions & 15 deletions rust/src/builders/output_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,6 @@ impl TransactionOutputAmountBuilder {
cfg
}

/// !!! DEPRECATED !!!
/// Since babbage era cardano nodes use coins per byte. Use '.with_asset_and_min_required_coin_by_utxo_cost' instead.
#[deprecated(
since = "11.0.0",
note = "Since babbage era cardano nodes use coins per byte. Use '.with_asset_and_min_required_coin_by_utxo_cost' instead."
)]
pub fn with_asset_and_min_required_coin(
&self,
multiasset: &MultiAsset,
coins_per_utxo_word: &Coin,
) -> Result<TransactionOutputAmountBuilder, JsError> {
let data_cost = DataCost::new_coins_per_word(coins_per_utxo_word);
self.with_asset_and_min_required_coin_by_utxo_cost(multiasset, &data_cost)
}

pub fn with_asset_and_min_required_coin_by_utxo_cost(
&self,
multiasset: &MultiAsset,
Expand Down
19 changes: 1 addition & 18 deletions rust/src/builders/script_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,7 @@ impl PlutusScriptSource {
pub fn new(script: &PlutusScript) -> Self {
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(),
None,
))
}

pub fn new_ref_input_with_lang_ver(
pub fn new_ref_input(
script_hash: &ScriptHash,
input: &TransactionInput,
lang_ver: &Language,
Expand Down
84 changes: 12 additions & 72 deletions rust/src/builders/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,6 @@ impl TransactionBuilderConfigBuilder {
cfg
}

/// !!! DEPRECATED !!!
/// Since babbage era cardano nodes use coins per byte. Use '.coins_per_utxo_byte' instead.
#[deprecated(
since = "11.0.0",
note = "Since babbage era cardano nodes use coins per byte. Use '.coins_per_utxo_byte' instead."
)]
pub fn coins_per_utxo_word(&self, coins_per_utxo_word: &Coin) -> Self {
let mut cfg = self.clone();
cfg.data_cost = Some(DataCost::new_coins_per_word(coins_per_utxo_word));
cfg
}

pub fn coins_per_utxo_byte(&self, coins_per_utxo_byte: &Coin) -> Self {
let mut cfg = self.clone();
cfg.data_cost = Some(DataCost::new_coins_per_byte(coins_per_utxo_byte));
Expand Down Expand Up @@ -414,7 +402,7 @@ impl TransactionBuilder {
&input.input,
&input.output.amount,
)?;
self.add_input(&input.output.address, &input.input, &input.output.amount);
self.add_regular_input(&input.output.address, &input.input, &input.output.amount);
input_total = input_total.checked_add(&input.output.amount)?;
output_total = output_total.checked_add(&Value::new(&input_fee))?;
}
Expand Down Expand Up @@ -494,7 +482,7 @@ impl TransactionBuilder {
&input.input,
&input.output.amount,
)?;
self.add_input(&input.output.address, &input.input, &input.output.amount);
self.add_regular_input(&input.output.address, &input.input, &input.output.amount);
input_total = input_total.checked_add(&input.output.amount)?;
output_total = output_total.checked_add(&Value::new(&input_fee))?;
}
Expand Down Expand Up @@ -532,7 +520,7 @@ impl TransactionBuilder {
// differing from CIP2, we include the needed fees in the targets instead of just output values
let input_fee =
self.fee_for_input(&input.output.address, &input.input, &input.output.amount)?;
self.add_input(&input.output.address, &input.input, &input.output.amount);
self.add_regular_input(&input.output.address, &input.input, &input.output.amount);
*input_total = input_total.checked_add(&input.output.amount)?;
*output_total = output_total.checked_add(&Value::new(&input_fee))?;
available_indices.swap_remove(available_indices.iter().position(|j| i == j).unwrap());
Expand Down Expand Up @@ -650,7 +638,7 @@ impl TransactionBuilder {
&input.input,
&input.output.amount,
)?;
self.add_input(&input.output.address, &input.input, &input.output.amount);
self.add_regular_input(&input.output.address, &input.input, &input.output.amount);
*input_total = input_total.checked_add(&input.output.amount)?;
*output_total = output_total.checked_add(&Value::new(&input_fee))?;
}
Expand Down Expand Up @@ -763,23 +751,6 @@ impl TransactionBuilder {
self.inputs.add_key_input(hash, input, amount);
}

/// This method adds the input to the builder BUT leaves a missing spot for the witness native script
///
/// After adding the input with this method, use `.add_required_native_input_scripts`
/// and `.add_required_plutus_input_scripts` to add the witness scripts
///
/// Or instead use `.add_native_script_input` and `.add_plutus_script_input`
/// to add inputs right along with the script, instead of the script hash
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
pub fn add_script_input(
&mut self,
hash: &ScriptHash,
input: &TransactionInput,
amount: &Value,
) {
self.inputs.add_script_input(hash, input, amount);
}

/// This method will add the input to the builder and also register the required native script witness
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
pub fn add_native_script_input(
Expand Down Expand Up @@ -812,41 +783,15 @@ impl TransactionBuilder {
self.inputs.add_bootstrap_input(hash, input, amount);
}

/// Note that for script inputs this method will use underlying generic `.add_script_input`
/// which leaves a required empty spot for the script witness (or witnesses in case of Plutus).
/// You can use `.add_native_script_input` or `.add_plutus_script_input` directly to register the input along with the witness.
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
pub fn add_input(&mut self, address: &Address, input: &TransactionInput, amount: &Value) {
self.inputs.add_input(address, input, amount);
/// This function is replace for previous one add_input.
/// The functions adds a non script input, if it is a script input it returns an error.
/// To add script input you need to use add_native_script_input or add_plutus_script_input.
/// Also we recommend to use TxInputsBuilder and .set_inputs, because all add_*_input functions might be removed from transaction builder.
#[deprecated(since = "12.0.0", note = "Use `.set_inputs`")]
pub fn add_regular_input(&mut self, address: &Address, input: &TransactionInput, amount: &Value) -> Result<(), JsError>{
self.inputs.add_regular_input(address, input, amount)
}

/// Returns the number of still missing input scripts (either native or plutus)
/// Use `.add_required_native_input_scripts` or `.add_required_plutus_input_scripts` to add the missing scripts
#[deprecated(
since = "10.2.0",
note = "Use `.count_missing_input_scripts` from `TxInputsBuilder`"
)]
pub fn count_missing_input_scripts(&self) -> usize {
self.inputs.count_missing_input_scripts()
}

/// Try adding the specified scripts as witnesses for ALREADY ADDED script inputs
/// Any scripts that don't match any of the previously added inputs will be ignored
/// Returns the number of remaining required missing witness scripts
/// Use `.count_missing_input_scripts` to find the number of still missing scripts
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
pub fn add_required_native_input_scripts(&mut self, scripts: &NativeScripts) -> usize {
self.inputs.add_required_native_input_scripts(scripts)
}

/// Try adding the specified scripts as witnesses for ALREADY ADDED script inputs
/// Any scripts that don't match any of the previously added inputs will be ignored
/// Returns the number of remaining required missing witness scripts
/// Use `.count_missing_input_scripts` to find the number of still missing scripts
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
pub fn add_required_plutus_input_scripts(&mut self, scripts: &PlutusWitnesses) -> usize {
self.inputs.add_required_plutus_input_scripts(scripts)
}

/// Returns a copy of the current script input witness scripts in the builder
#[deprecated(since = "10.2.0", note = "Use `.set_inputs`")]
Expand Down Expand Up @@ -877,7 +822,7 @@ impl TransactionBuilder {

let fee_before = min_fee(&self_copy)?;

self_copy.add_input(&address, &input, &amount);
self_copy.add_regular_input(&address, &input, &amount);
let fee_after = min_fee(&self_copy)?;
fee_after.checked_sub(&fee_before)
}
Expand Down Expand Up @@ -2164,11 +2109,6 @@ impl TransactionBuilder {
/// NOTE: is_valid set to true
/// NOTE: Will fail in case there are any script inputs added with no corresponding witness
pub fn build_tx(&self) -> Result<Transaction, JsError> {
if self.count_missing_input_scripts() > 0 {
return Err(JsError::from_str(
"There are some script inputs added that don't have the corresponding script provided as a witness!",
));
}
if self.has_plutus_inputs() {
if self.script_data_hash.is_none() {
return Err(JsError::from_str(
Expand Down
Loading
Loading