chore(interop): update u5c spec to v0.8.0 (#493)
This commit is contained in:
parent
c7f2240e0e
commit
3dbd582207
4 changed files with 1318 additions and 468 deletions
|
|
@ -176,7 +176,7 @@ impl Server {
|
|||
/// # Arguments
|
||||
///
|
||||
/// * `blocks` - Ordered list of block bodies corresponding to the client's
|
||||
/// requested range.
|
||||
/// requested range.
|
||||
pub async fn send_block_range(&mut self, blocks: Vec<Body>) -> Result<(), ServerError> {
|
||||
if blocks.is_empty() {
|
||||
self.send_no_blocks().await
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pallas-primitives = { version = "=0.29.0", path = "../pallas-primitives" }
|
|||
pallas-codec = { version = "=0.29.0", path = "../pallas-codec" }
|
||||
pallas-crypto = { version = "=0.29.0", path = "../pallas-crypto" }
|
||||
|
||||
utxorpc-spec = { version = "0.7.0" }
|
||||
utxorpc-spec = { version = "0.8.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4.3"
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl<C: LedgerContext> Mapper<C> {
|
|||
pub fn map_redeemer(&self, x: &trv::MultiEraRedeemer) -> u5c::Redeemer {
|
||||
u5c::Redeemer {
|
||||
purpose: self.map_purpose(&x.tag()).into(),
|
||||
datum: self.map_plutus_datum(x.data()).into(),
|
||||
payload: self.map_plutus_datum(x.data()).into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +112,24 @@ impl<C: LedgerContext> Mapper<C> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn map_tx_datum(&self, x: &trv::MultiEraOutput) -> u5c::Datum {
|
||||
u5c::Datum {
|
||||
hash: match x.datum() {
|
||||
Some(babbage::PseudoDatumOption::Data(x)) => x.original_hash().to_vec().into(),
|
||||
Some(babbage::PseudoDatumOption::Hash(x)) => x.to_vec().into(),
|
||||
_ => vec![].into(),
|
||||
},
|
||||
payload: match x.datum() {
|
||||
Some(babbage::PseudoDatumOption::Data(x)) => self.map_plutus_datum(&x.0).into(),
|
||||
_ => None,
|
||||
},
|
||||
original_cbor: match x.datum() {
|
||||
Some(babbage::PseudoDatumOption::Data(x)) => x.raw_cbor().to_vec().into(),
|
||||
_ => vec![].into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_tx_output(&self, x: &trv::MultiEraOutput) -> u5c::TxOutput {
|
||||
u5c::TxOutput {
|
||||
address: x.address().map(|a| a.to_vec()).unwrap_or_default().into(),
|
||||
|
|
@ -124,15 +142,7 @@ impl<C: LedgerContext> Mapper<C> {
|
|||
.iter()
|
||||
.map(|x| self.map_policy_assets(x))
|
||||
.collect(),
|
||||
datum: match x.datum() {
|
||||
Some(babbage::PseudoDatumOption::Data(x)) => self.map_plutus_datum(&x.0).into(),
|
||||
_ => None,
|
||||
},
|
||||
datum_hash: match x.datum() {
|
||||
Some(babbage::PseudoDatumOption::Data(x)) => x.original_hash().to_vec().into(),
|
||||
Some(babbage::PseudoDatumOption::Hash(x)) => x.to_vec().into(),
|
||||
_ => vec![].into(),
|
||||
},
|
||||
datum: self.map_tx_datum(x).into(),
|
||||
script: match x.script_ref() {
|
||||
Some(conway::PseudoScript::NativeScript(x)) => u5c::Script {
|
||||
script: u5c::script::Script::Native(Self::map_native_script(&x)).into(), /* */
|
||||
|
|
@ -669,6 +679,15 @@ mod tests {
|
|||
let cbor = hex::decode(block_str).unwrap();
|
||||
let block = pallas_traverse::MultiEraBlock::decode(&cbor).unwrap();
|
||||
let current = serde_json::json!(mapper.map_block(&block));
|
||||
|
||||
// un-comment the following to generate a new snapshot
|
||||
|
||||
// std::fs::write(
|
||||
// "new_snapshot.json",
|
||||
// serde_json::to_string_pretty(¤t).unwrap(),
|
||||
// )
|
||||
// .unwrap();
|
||||
|
||||
let expected: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
||||
|
||||
assert_eq!(expected, current)
|
||||
|
|
|
|||
1743
test_data/u5c1.json
1743
test_data/u5c1.json
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue