Skip to content

Commit

Permalink
fix(legacy jor sig check): chain crypto sig check
Browse files Browse the repository at this point in the history
  • Loading branch information
cong-or committed May 5, 2024
1 parent 1efcf62 commit a9e2586
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 60 deletions.
55 changes: 23 additions & 32 deletions catalyst-gateway/bin/src/cardano/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub type StakeCredentialHash = String;
pub type StakeCredentialKey = String;

/// Hash size
#[allow(dead_code)]
pub(crate) const BLAKE_2B_256_HASH_SIZE: usize = 256 / 8;

/// Helper function to generate the `blake2b_256` hash of a byte slice
Expand Down Expand Up @@ -58,11 +57,9 @@ pub struct PolicyAsset {
pub fn parse_policy_assets(assets: &[MultiEraPolicyAssets<'_>]) -> Vec<PolicyAsset> {
assets
.iter()
.map(|asset| {
PolicyAsset {
policy_hash: asset.policy().to_string(),
assets: parse_child_assets(&asset.assets()),
}
.map(|asset| PolicyAsset {
policy_hash: asset.policy().to_string(),
assets: parse_child_assets(&asset.assets()),
})
.collect()
}
Expand All @@ -71,25 +68,21 @@ pub fn parse_policy_assets(assets: &[MultiEraPolicyAssets<'_>]) -> Vec<PolicyAss
pub fn parse_child_assets(assets: &[MultiEraAsset]) -> Vec<Asset> {
assets
.iter()
.filter_map(|asset| {
match asset {
MultiEraAsset::AlonzoCompatibleOutput(id, name, amount) => {
Some(Asset {
policy_id: id.to_string(),
name: name.to_string(),
amount: *amount,
})
},
MultiEraAsset::AlonzoCompatibleMint(id, name, amount) => {
let amount = u64::try_from(*amount).ok()?;
Some(Asset {
policy_id: id.to_string(),
name: name.to_string(),
amount,
})
},
_ => Some(Asset::default()),
}
.filter_map(|asset| match asset {
MultiEraAsset::AlonzoCompatibleOutput(id, name, amount) => Some(Asset {
policy_id: id.to_string(),
name: name.to_string(),
amount: *amount,
}),
MultiEraAsset::AlonzoCompatibleMint(id, name, amount) => {
let amount = u64::try_from(*amount).ok()?;
Some(Asset {
policy_id: id.to_string(),
name: name.to_string(),
amount,
})
},
_ => Some(Asset::default()),
})
.collect()
}
Expand All @@ -113,13 +106,11 @@ pub fn extract_stake_credentials_from_certs(
pallas::ledger::primitives::alonzo::Certificate::StakeDelegation(
stake_credential,
_,
) => {
match stake_credential {
StakeCredential::AddrKeyhash(stake_credential) => {
stake_credentials.push(hex::encode(stake_credential.as_slice()));
},
StakeCredential::Scripthash(_) => (),
}
) => match stake_credential {
StakeCredential::AddrKeyhash(stake_credential) => {
stake_credentials.push(hex::encode(stake_credential.as_slice()));
},
StakeCredential::Scripthash(_) => (),
},
_ => continue,
}
Expand Down
28 changes: 0 additions & 28 deletions catalyst-gateway/tests/api_tests/snapshot_tool-56364174.json
Original file line number Diff line number Diff line change
Expand Up @@ -2433,20 +2433,6 @@
"tx_id": 300334,
"nonce": 18212876
},
{
"delegations": [
[
"0x627510960279286b23505748ec667364475e638d9e38a8c3517953368bbadd68",
1
]
],
"rewards_address": "0x00ad6a01b9390630e4be401c05860bcc50bf62dc0b9d2a64ffc4615de41a42d217652f0036c3ec8af5f3b12cb8727497ec8382518c2d8d4fca",
"stake_public_key": "0x2e1cb95cd34235bf86273b203be5eca2054bf2bab0f9093a151521dcaa198413",
"voting_power": 4470233,
"voting_purpose": 0,
"tx_id": 835522,
"nonce": 28120865
},
{
"delegations": [
[
Expand Down Expand Up @@ -3748,20 +3734,6 @@
"tx_id": 949132,
"nonce": 31500349
},
{
"delegations": [
[
"0xdc06cc9b46c983af66e4c5c52463086b174780c8ab09b9aa9f4e3441c0cc9da6",
1
]
],
"rewards_address": "0x0002f1c39e73708869c5d068efce51c7a8a779620639e919adbffdf7ba7e872b69a8844a5c619738e87338d34135ea3bebb973f7181a6ff40d",
"stake_public_key": "0xed05e31db7866366a12c7414fbc3b6708740e9bdad00f6c190068db14a24ba4b",
"voting_power": 999823499,
"voting_purpose": 0,
"tx_id": 144983,
"nonce": 13450365
},
{
"delegations": [
[
Expand Down

0 comments on commit a9e2586

Please sign in to comment.