Skip to content

Commit 6767cac

Browse files
authored
fix(rust/rbac-registration): Make rbac-registration WASM compatible (#479)
* fix: deps Signed-off-by: bkioshn <[email protected]> * fix: import Signed-off-by: bkioshn <[email protected]> * fix: bump minor version Signed-off-by: bkioshn <[email protected]> * fix: bump cat-type and cardano-bc-type Signed-off-by: bkioshn <[email protected]> --------- Signed-off-by: bkioshn <[email protected]>
1 parent 0e16500 commit 6767cac

File tree

12 files changed

+48
-51
lines changed

12 files changed

+48
-51
lines changed

rust/rbac-registration/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rbac-registration"
33
description = "Role Based Access Control Registration"
44
keywords = ["cardano", "catalyst", "rbac registration"]
5-
version = "0.0.7"
5+
version = "0.0.8"
66
authors = [
77
"Arissara Chotivichit <[email protected]>"
88
]
@@ -33,7 +33,6 @@ oid-registry = "0.7.1"
3333
thiserror = "2.0.11"
3434

3535
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "c509-certificate-v0.0.3" }
36-
pallas = { version = "0.33.0" }
3736
cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" }
38-
cardano-blockchain-types = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types-v0.0.5" }
39-
catalyst-types = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types-v0.0.5" }
37+
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.6" }
38+
catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.6" }

rust/rbac-registration/src/cardano/cip509/cip509.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ use std::{
99

1010
use anyhow::{anyhow, Context};
1111
use cardano_blockchain_types::{
12-
MetadatumLabel, MultiEraBlock, StakeAddress, TransactionId, TxnIndex,
12+
hashes::{Blake2b256Hash, TransactionId, BLAKE_2B256_SIZE},
13+
pallas_addresses::{Address, ShelleyAddress},
14+
pallas_primitives::{conway, Nullable},
15+
pallas_traverse::MultiEraTx,
16+
MetadatumLabel, MultiEraBlock, StakeAddress, TxnIndex,
1317
};
1418
use catalyst_types::{
1519
catalyst_id::{role_index::RoleId, CatalystId},
1620
cbor_utils::{report_duplicated_key, report_missing_keys},
17-
hashes::{Blake2b256Hash, BLAKE_2B256_SIZE},
1821
problem_report::ProblemReport,
1922
uuid::UuidV4,
2023
};
@@ -23,14 +26,6 @@ use minicbor::{
2326
decode::{self},
2427
Decode, Decoder,
2528
};
26-
use pallas::{
27-
codec::utils::Nullable,
28-
ledger::{
29-
addresses::{Address, ShelleyAddress},
30-
primitives::conway,
31-
traverse::MultiEraTx,
32-
},
33-
};
3429
use strum_macros::FromRepr;
3530
use tracing::warn;
3631
use uuid::Uuid;
@@ -459,7 +454,7 @@ impl Decode<'_, DecodeContext<'_, '_>> for Cip509 {
459454

460455
/// Records the payment history for the given set of addresses.
461456
fn payment_history(
462-
txn: &conway::MintedTx,
457+
txn: &conway::Tx,
463458
track_payment_addresses: &[ShelleyAddress],
464459
origin: &PointTxnIdx,
465460
report: &ProblemReport,
@@ -474,7 +469,7 @@ fn payment_history(
474469
.collect();
475470

476471
for (index, output) in txn.transaction_body.outputs.iter().enumerate() {
477-
let conway::PseudoTransactionOutput::PostAlonzo(output) = output else {
472+
let conway::TransactionOutput::PostAlonzo(output) = output else {
478473
continue;
479474
};
480475

rust/rbac-registration/src/cardano/cip509/decode_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use std::collections::HashMap;
44

5+
use cardano_blockchain_types::{pallas_addresses::ShelleyAddress, pallas_primitives::conway};
56
use catalyst_types::problem_report::ProblemReport;
6-
use pallas::ledger::{addresses::ShelleyAddress, primitives::conway};
77

88
use crate::cardano::cip509::{Payment, PointTxnIdx};
99

@@ -12,7 +12,7 @@ pub struct DecodeContext<'r, 't> {
1212
/// A slot and a transaction index.
1313
pub origin: PointTxnIdx,
1414
/// A transaction.
15-
pub txn: &'t conway::MintedTx<'t>,
15+
pub txn: &'t conway::Tx<'t>,
1616
/// A payment history.
1717
pub payment_history: HashMap<ShelleyAddress, Vec<Payment>>,
1818
/// A problem report.

rust/rbac-registration/src/cardano/cip509/types/payment_history.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use std::collections::HashMap;
44

5-
use pallas::{
6-
crypto::hash::Hash,
7-
ledger::{addresses::ShelleyAddress, primitives::conway::Value},
5+
use cardano_blockchain_types::{
6+
pallas_addresses::ShelleyAddress,
7+
pallas_primitives::{conway::Value, Hash},
88
};
99

1010
use super::point_tx_idx::PointTxnIdx;

rust/rbac-registration/src/cardano/cip509/types/role_data.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
33
use std::{borrow::Cow, collections::HashMap};
44

5-
use cardano_blockchain_types::TxnWitness;
6-
use catalyst_types::{catalyst_id::role_index::RoleId, problem_report::ProblemReport};
7-
use pallas::ledger::{
8-
addresses::{Address, ShelleyAddress},
9-
primitives::conway,
10-
traverse::MultiEraTx,
5+
use cardano_blockchain_types::{
6+
pallas_addresses::{Address, ShelleyAddress},
7+
pallas_primitives::conway,
8+
pallas_traverse::MultiEraTx,
9+
TxnWitness,
1110
};
11+
use catalyst_types::{catalyst_id::role_index::RoleId, problem_report::ProblemReport};
1212

1313
use crate::cardano::cip509::{
1414
rbac::role_data::CborRoleData, utils::cip19::extract_key_hash, KeyLocalRef,
@@ -32,7 +32,7 @@ impl RoleData {
3232
#[must_use]
3333
pub fn new(
3434
data: CborRoleData,
35-
txn: &conway::MintedTx,
35+
txn: &conway::Tx,
3636
report: &ProblemReport,
3737
) -> Self {
3838
let payment_key = if data.number == Some(RoleId::Role0) && data.payment_key.is_none() {
@@ -101,7 +101,7 @@ impl RoleData {
101101
/// Converts the payment key from the form encoded in CBOR role data to `ShelleyAddress`.
102102
fn convert_payment_key(
103103
index: Option<u16>,
104-
txn: &conway::MintedTx,
104+
txn: &conway::Tx,
105105
context: &str,
106106
report: &ProblemReport,
107107
) -> Option<ShelleyAddress> {
@@ -118,8 +118,8 @@ fn convert_payment_key(
118118
};
119119

120120
let address = match outputs.get(index) {
121-
Some(conway::PseudoTransactionOutput::PostAlonzo(o)) => &o.address,
122-
Some(conway::PseudoTransactionOutput::Legacy(o)) => &o.address,
121+
Some(conway::TransactionOutput::PostAlonzo(o)) => &o.address,
122+
Some(conway::TransactionOutput::Legacy(o)) => &o.address,
123123
None => {
124124
report.other(
125125
&format!(

rust/rbac-registration/src/cardano/cip509/types/role_data_record.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use std::collections::HashMap;
44

5+
use cardano_blockchain_types::pallas_addresses::ShelleyAddress;
56
use catalyst_types::catalyst_id::key_rotation::KeyRotation;
6-
use pallas::ledger::addresses::ShelleyAddress;
77

88
use super::{CertOrPk, PointData, PointTxnIdx};
99

rust/rbac-registration/src/cardano/cip509/types/tx_input_hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Transaction input hash type
22
33
use anyhow::Context;
4-
use catalyst_types::hashes::Blake2b128Hash;
4+
use cardano_blockchain_types::hashes::Blake2b128Hash;
55

66
/// A 16-byte hash of the transaction inputs field.
77
///

rust/rbac-registration/src/cardano/cip509/utils/cip134_uri_set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use c509_certificate::{
1010
general_names::general_name::{GeneralNameTypeRegistry, GeneralNameValue},
1111
C509ExtensionType,
1212
};
13-
use cardano_blockchain_types::{Cip0134Uri, StakeAddress};
13+
use cardano_blockchain_types::{pallas_addresses::Address, Cip0134Uri, StakeAddress};
1414
use catalyst_types::problem_report::ProblemReport;
1515
use der_parser::der::parse_der_sequence;
16-
use pallas::ledger::addresses::Address;
1716
use tracing::debug;
1817
use x509_cert::der::oid::db::rfc5912::ID_CE_SUBJECT_ALT_NAME;
1918

@@ -304,7 +303,8 @@ fn convert_stake_addresses(uris: &[Cip0134Uri]) -> Vec<StakeAddress> {
304303

305304
#[cfg(test)]
306305
mod tests {
307-
use pallas::ledger::addresses::{Address, Network};
306+
307+
use cardano_blockchain_types::pallas_addresses::{Address, Network};
308308

309309
use crate::{cardano::cip509::Cip509, utils::test};
310310

rust/rbac-registration/src/cardano/cip509/validation.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
use std::borrow::Cow;
88

99
use c509_certificate::c509::C509;
10-
use cardano_blockchain_types::{Network, TxnWitness, VKeyHash};
11-
use catalyst_types::{
12-
catalyst_id::{role_index::RoleId, CatalystId},
10+
use cardano_blockchain_types::{
1311
hashes::{Blake2b128Hash, Blake2b256Hash},
14-
problem_report::ProblemReport,
15-
};
16-
use ed25519_dalek::{Signature, VerifyingKey};
17-
use pallas::{
18-
codec::{
12+
pallas_addresses::Address,
13+
pallas_codec::{
1914
minicbor::{Encode, Encoder},
2015
utils::Bytes,
2116
},
22-
ledger::{addresses::Address, primitives::conway, traverse::MultiEraTx},
17+
pallas_primitives::conway,
18+
pallas_traverse::MultiEraTx,
19+
Network, TxnWitness, VKeyHash,
2320
};
21+
use catalyst_types::{
22+
catalyst_id::{role_index::RoleId, CatalystId},
23+
problem_report::ProblemReport,
24+
};
25+
use ed25519_dalek::{Signature, VerifyingKey};
2426
use x509_cert::{der::Encode as X509Encode, Certificate as X509};
2527

2628
use crate::cardano::cip509::{
@@ -44,7 +46,7 @@ pub(crate) const URI: u8 = 134;
4446
/// Checks that hashing transactions inputs produces the value equal to the given one.
4547
pub fn validate_txn_inputs_hash(
4648
hash: &TxInputHash,
47-
transaction: &conway::MintedTx,
49+
transaction: &conway::Tx,
4850
report: &ProblemReport,
4951
) {
5052
let context = "Cip509 transaction input hash validation";
@@ -118,7 +120,7 @@ pub fn validate_aux(
118120
/// Checks that all public keys extracted from x509 and c509 certificates are present in
119121
/// the witness set of the transaction.
120122
pub fn validate_stake_public_key(
121-
transaction: &conway::MintedTx,
123+
transaction: &conway::Tx,
122124
uris: Option<&Cip0134UriSet>,
123125
report: &ProblemReport,
124126
) {

rust/rbac-registration/src/cardano/cip509/x509_chunks.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ fn decompress(
122122
mod tests {
123123
use std::collections::HashMap;
124124

125-
use cardano_blockchain_types::Point;
125+
use cardano_blockchain_types::{pallas_traverse::MultiEraTx, Point};
126126
use catalyst_types::problem_report::ProblemReport;
127-
use pallas::ledger::traverse::MultiEraTx;
128127

129128
use super::*;
130129
use crate::{cardano::cip509::PointTxnIdx, utils::test};

0 commit comments

Comments
 (0)