Skip to main content

amaru_kernel/
lib.rs

1// Copyright 2024 PRAGMA
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// TODO: Temporary re-exports until Pallas migrations
16//
17// Re-exports still needed in a few places; but that shall become redundant as soon as we have
18// properly reworked addresses.
19pub use pallas_addresses::{
20    ByronAddress, Error as AddressError, ShelleyAddress, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress,
21    StakePayload,
22    byron::{AddrAttrProperty, AddrType, AddressPayload},
23};
24// TODO: Temporary re-exports until Pallas migrations
25//
26// See above.
27pub use pallas_primitives::conway::{Constr, KeepRaw, MaybeIndefArray};
28// TODO: Temporary re-exports until Pallas migrations
29//
30// See above.
31pub use pallas_traverse::{ComputeHash, OriginalHash};
32
33pub mod cardano;
34pub use cardano::{
35    account::Account,
36    address::{Address, is_locked_by_script},
37    anchor::Anchor,
38    asset_name::AssetName,
39    auxiliary_data::AuxiliaryData,
40    ballot::Ballot,
41    ballot_id::BallotId,
42    bigint::BigInt,
43    block::Block,
44    block_header::BlockHeader,
45    block_height::BlockHeight,
46    bootstrap_witness::BootstrapWitness,
47    bytes::Bytes,
48    certificate::Certificate,
49    certificate_pointer::CertificatePointer,
50    constitution::Constitution,
51    constitutional_committee::ConstitutionalCommitteeStatus,
52    cost_model::CostModel,
53    cost_models::CostModels,
54    drep::DRep,
55    drep_registration::DRepRegistration,
56    drep_state::DRepState,
57    drep_voting_thresholds::DRepVotingThresholds,
58    epoch::Epoch,
59    era_bound::EraBound,
60    era_history::{
61        EraHistory, EraHistoryError, EraHistoryFileError, MAINNET_ERA_HISTORY, PREPROD_ERA_HISTORY,
62        PREVIEW_ERA_HISTORY, TESTNET_ERA_HISTORY, load_era_history_from_file,
63    },
64    era_name::{EraName, EraNameError},
65    era_params::EraParams,
66    era_summary::EraSummary,
67    ex_units::{ExUnits, sum_ex_units},
68    ex_units_prices::ExUnitPrices,
69    governance_action::GovernanceAction,
70    hash::{Hash, Hasher, HeaderHash, NULL_HASH28, NULL_HASH32, ORIGIN_HASH, PoolId, TransactionId, size},
71    header::Header,
72    header_body::HeaderBody,
73    int::Int,
74    language::Language,
75    lovelace::Lovelace,
76    memoized::{
77        MemoizedDatum, MemoizedNativeScript, MemoizedPlutusData, MemoizedScript, MemoizedTransactionOutput,
78        decode_script, deserialize_script, encode_script, from_minted_script, script_original_bytes,
79        serialize_memoized_script, serialize_script,
80    },
81    metadatum::Metadatum,
82    native_script::NativeScript,
83    network::Network,
84    network_id::NetworkId,
85    network_magic::NetworkMagic,
86    network_name::NetworkName,
87    non_zero_int::NonZeroInt,
88    nonce::{Nonce, parse_nonce},
89    ordered_redeemer::OrderedRedeemer,
90    peer::Peer,
91    plutus_data::PlutusData,
92    plutus_script::PlutusScript,
93    point::Point,
94    pool_metadata::PoolMetadata,
95    pool_params::PoolParams,
96    pool_voting_thresholds::PoolVotingThresholds,
97    positive_coin::PositiveCoin,
98    proposal::Proposal,
99    proposal_id::{ComparableProposalId, ProposalId},
100    proposal_pointer::ProposalPointer,
101    proposal_state::ProposalState,
102    protocol_parameters::{
103        ConsensusParameters, GlobalParameters, MAINNET_GLOBAL_PARAMETERS, PREPROD_GLOBAL_PARAMETERS,
104        PREPROD_INITIAL_PROTOCOL_PARAMETERS, PREVIEW_GLOBAL_PARAMETERS, PREVIEW_INITIAL_PROTOCOL_PARAMETERS,
105        ProtocolParameters, TESTNET_GLOBAL_PARAMETERS,
106    },
107    protocol_parameters_update::{ProtocolParamUpdate, display_protocol_parameters_update},
108    protocol_version::{PROTOCOL_VERSION_9, PROTOCOL_VERSION_10, ProtocolVersion},
109    rational_number::RationalNumber,
110    raw_block::RawBlock,
111    redeemer::Redeemer,
112    redeemer_key::RedeemerKey,
113    redeemers::Redeemers,
114    relay::Relay,
115    required_script::RequiredScript,
116    reward::Reward,
117    reward_account::{RewardAccount, expect_stake_credential, new_stake_address, reward_account_to_stake_credential},
118    reward_kind::RewardKind,
119    script_kind::ScriptKind,
120    script_purpose::{ScriptPurpose, script_purpose_to_string},
121    slot::{Slot, SlotArithmeticError},
122    stake_credential::{BorrowedStakeCredential, StakeCredential, stake_credential_from_reward_account},
123    stake_credential_kind::StakeCredentialKind,
124    tip::Tip,
125    transaction::Transaction,
126    transaction_body::TransactionBody,
127    transaction_input::{TransactionInput, transaction_input_to_string},
128    transaction_pointer::TransactionPointer,
129    value::Value,
130    vkey_witness::{InvalidEd25519Signature, VKeyWitness, verify_ed25519_signature},
131    vote::Vote,
132    voter::Voter,
133    voter_kind::VoterKind,
134    voting_procedure::VotingProcedure,
135    witness_set::WitnessSet,
136};
137#[cfg(any(test, feature = "test-utils"))]
138pub use cardano::{
139    address::any_shelley_address,
140    anchor::any_anchor,
141    ballot::any_ballot,
142    ballot_id::{any_ballot_id, any_voter},
143    block_header::{
144        any_fake_header, any_header, any_header_hash, any_header_with_parent, any_header_with_some_parent,
145        any_headers_chain, any_headers_chain_with_root, make_header,
146    },
147    block_height::any_block_height,
148    certificate_pointer::any_certificate_pointer,
149    constitution::any_constitution,
150    constitutional_committee::any_constitutional_committee_status,
151    drep::any_drep,
152    epoch::any_epoch,
153    era_bound::{any_era_bound, any_era_bound_for_epoch, any_era_bound_time},
154    era_name::any_era_name,
155    era_params::any_era_params,
156    hash::{any_hash28, any_hash32},
157    network::any_network,
158    network_magic::any_network_magic,
159    network_name::any_network_name,
160    point::{any_point, any_specific_point},
161    pool_params::any_pool_params,
162    proposal::any_proposal,
163    proposal_id::{any_comparable_proposal_id, any_proposal_id},
164    proposal_pointer::any_proposal_pointer,
165    protocol_parameters::{
166        any_cost_model, any_cost_models, any_drep_voting_thresholds, any_ex_unit_prices, any_ex_units,
167        any_ex_units_prices, any_gov_action, any_guardrails_script, any_pool_voting_thresholds, any_protocol_parameter,
168        any_protocol_params_update, any_protocol_version, any_withdrawal,
169    },
170    rational_number::any_rational_number,
171    reward_account::any_reward_account,
172    stake_credential::any_stake_credential,
173    tip::any_tip,
174    transaction_pointer::any_transaction_pointer,
175    vote::{VOTE_ABSTAIN, VOTE_NO, VOTE_YES, any_vote, any_vote_ref},
176};
177
178pub mod cbor {
179    pub use amaru_minicbor_extra::{
180        TAG_MAP_259, TAG_SET_258, allow_tag, check_tagged_array_length, decode_break, expect_tag, from_cbor,
181        from_cbor_no_leftovers, from_cbor_no_leftovers_with, heterogeneous_array, heterogeneous_map, lazy,
182        missing_field, tee, to_cbor, unexpected_field,
183    };
184    pub use minicbor::{
185        CborLen, Decode, Decoder, Encode, Encoder, bytes,
186        data::{self, IanaTag, Tag, Type},
187        decode, decode_with, display, encode, encode_with, len, len_with, to_vec, to_vec_with,
188    };
189    pub use pallas_codec::utils::AnyCbor as Any;
190}
191pub use cbor::{from_cbor, from_cbor_no_leftovers, from_cbor_no_leftovers_with, to_cbor};
192
193mod data_structures;
194#[cfg(any(test, feature = "test-utils"))]
195pub use data_structures::nullable::any_nullable;
196#[doc(hidden)]
197pub use data_structures::{
198    ignore_eq::IgnoreEq,
199    key_value_pairs::{IntoKeyValuePairsError, KeyValuePairs},
200    legacy::Legacy,
201    non_empty_bytes::{EmptyBytesError, NonEmptyBytes},
202    non_empty_key_value_pairs::{IntoNonEmptyKeyValuePairsError, NonEmptyKeyValuePairs},
203    non_empty_set::{IntoNonEmptySetError, NonEmptySet},
204    non_empty_vec::{IntoNonEmptyVecError, NonEmptyVec},
205    nullable::Nullable,
206    set::Set,
207    strict_maybe::StrictMaybe,
208};
209pub use serde_json as json;
210
211pub mod macros;
212
213mod traits;
214#[doc(hidden)]
215pub use traits::{
216    AsHash, AsIndex, AsShelley, HasExUnits, HasLovelace, HasNetwork, HasOwnership, HasRedeemers, HasScriptHash,
217    IsHeader, as_hash, as_index, as_shelley, has_ex_units, has_lovelace, has_network, has_ownership, has_redeemers,
218    has_script_hash, is_header,
219};
220
221pub mod utils;