refactor: Re-organize and clean-up pallas-primitives (#523)
* Re-organize and clean-up pallas-primitives
Namely:
- Move _common_ (i.e. era-independent) types and structures up to the
`lib` module; to be shared across all eras. If any of those deviate
in a subsequent era, it is easy to bring them down and define new
types from the point of divergence onward. This simplifies the scope
of each era-specific module and make them slightly easier to
navigate.
Note that, each era module still re-export all of the common types
that's relevant to that particular era. So technically, this
reorganization doesn't really change anything for callers/users of
the library.
- Rename `Scripthash` to `ScriptHash`. Before this commit, both
actually existed as `ScriptHash` was introduced with the Conway era.
Yet, they refer to the same thing, so the duplication is simply
confusing.
- Rename `One` / `Two` constructors for `NetworkId` to `Testnet` and
`Mainnet` respectively. Also defined idiomatic `From` & `TryFrom`
implementation for conversion to and from `u8`. This is a lot let
confusing!
- Generalize `PlutusScript` with a constant generic, to avoid
repetition for each plutus script generated for specific version.
Note that a distinction is still _necessary_ if we want to provie
out-of-the-box serialisers for Plutus scripts, which are serialised
with a tag prefix depending on the language. All else apart, they
are strictly similar types.
- Rename `CostMdls` to `CostModels`. Because, common.
- Rename `plutus_script` to `plutus_v1_script` in the Alonzo's witness
set, for consistency with other eras.
* Fix ordering of ScriptHash variants.
This is an odd one. See the note.
* Bump minicbor to v0.25.1
* Add aliases with deprecation warnings to various fields and types.
* revert renaming plutus_script to plutus_v1_script in Alonzo witness
See https://github.com/txpipe/pallas/pull/523#discussion_r1807329742
This commit is contained in:
parent
7d79407163
commit
6b667c78a3
26 changed files with 972 additions and 1071 deletions
|
|
@ -480,7 +480,7 @@ mod alonzo_tests {
|
|||
),
|
||||
(
|
||||
// (tx hash, tx output index):
|
||||
// (d2f9764fa93ae5bcabbb65c7a2f97d1e31188064ae3d2ba1462114453928dd99, 0)
|
||||
// (d2f9764fa93ae5bcabbb65c7a2f97d1e31188064ae3d2ba1462114453928dd99, 0)
|
||||
String::from("01c81ffcbc08ff49965d74f90c391541ff1cc2b043ffe41c81d840be8729f2ae5ed49a1734823ba37fd09923f5f7d494ae0efa23dd98ce02da"),
|
||||
Value::Coin(20292207),
|
||||
None,
|
||||
|
|
@ -1152,9 +1152,7 @@ mod alonzo_tests {
|
|||
let cbor_bytes: Vec<u8> = cbor_to_bytes(include_str!("../../test_data/alonzo1.tx"));
|
||||
let mut mtx: MintedTx = minted_tx_from_cbor(&cbor_bytes);
|
||||
let mut tx_body: TransactionBody = (*mtx.transaction_body).clone();
|
||||
// Note that NetworkId::One maps to 0 through
|
||||
// crate::utils::get_network_id_value, which is not correct in mainnet.
|
||||
tx_body.network_id = Some(NetworkId::One);
|
||||
tx_body.network_id = Some(NetworkId::Testnet);
|
||||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue