Skip to content

Commit c07ecc6

Browse files
committed
fix(cardano-blockchain-types): rename ctx
Signed-off-by: bkioshn <[email protected]>
1 parent 908b14b commit c07ecc6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

rust/cardano-blockchain-types/src/metadata/cip36/key_registration.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ enum Cip36KeyRegistrationKeys {
7676
}
7777

7878
impl Decode<'_, ProblemReport> for Cip36KeyRegistration {
79-
fn decode(d: &mut Decoder, ctx: &mut ProblemReport) -> Result<Self, decode::Error> {
79+
fn decode(d: &mut Decoder, err_report: &mut ProblemReport) -> Result<Self, decode::Error> {
8080
let map_len = decode_map_len(d, "CIP36 Key Registration")?;
8181

8282
let mut cip36_key_registration = Cip36KeyRegistration::default();
@@ -85,24 +85,24 @@ impl Decode<'_, ProblemReport> for Cip36KeyRegistration {
8585
let mut found_keys: Vec<Cip36KeyRegistrationKeys> = Vec::new();
8686

8787
for index in 0..map_len {
88-
let key: u16 = decode_helper(d, "key in CIP36 Key Registration", ctx)?;
88+
let key: u16 = decode_helper(d, "key in CIP36 Key Registration", err_report)?;
8989

9090
if let Some(key) = Cip36KeyRegistrationKeys::from_repr(key) {
91-
if check_is_key_exist(&found_keys, &key, index, ctx) {
91+
if check_is_key_exist(&found_keys, &key, index, err_report) {
9292
continue;
9393
}
9494
match key {
9595
Cip36KeyRegistrationKeys::VotingKey => {
96-
let (is_cip36, voting_keys) = decode_voting_key(d, ctx)?;
96+
let (is_cip36, voting_keys) = decode_voting_key(d, err_report)?;
9797
cip36_key_registration.is_cip36 = is_cip36;
9898
cip36_key_registration.voting_pks = voting_keys;
9999
},
100100
Cip36KeyRegistrationKeys::StakePk => {
101-
let stake_pk = decode_stake_pk(d, ctx)?;
101+
let stake_pk = decode_stake_pk(d, err_report)?;
102102
cip36_key_registration.stake_pk = stake_pk;
103103
},
104104
Cip36KeyRegistrationKeys::PaymentAddr => {
105-
let shelley_addr = decode_payment_addr(d, ctx)?;
105+
let shelley_addr = decode_payment_addr(d, err_report)?;
106106
cip36_key_registration.is_payable = shelley_addr
107107
.as_ref()
108108
.map(|addr| !addr.payment().is_script())
@@ -130,7 +130,7 @@ impl Decode<'_, ProblemReport> for Cip36KeyRegistration {
130130

131131
for key in &required_keys {
132132
if !found_keys.contains(key) {
133-
ctx.missing_field(
133+
err_report.missing_field(
134134
&format!("{key:?}"),
135135
"Missing required key in CIP36 Key Registration",
136136
);

rust/cardano-blockchain-types/src/metadata/cip36/registration_witness.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) struct Cip36RegistrationWitness {
2222
}
2323

2424
impl Decode<'_, ProblemReport> for Cip36RegistrationWitness {
25-
fn decode(d: &mut Decoder, ctx: &mut ProblemReport) -> Result<Self, decode::Error> {
25+
fn decode(d: &mut Decoder, err_report: &mut ProblemReport) -> Result<Self, decode::Error> {
2626
let map_len = decode_map_len(d, "CIP36 Registration Witness")?;
2727

2828
// Expected only 1 key in the map.
@@ -32,11 +32,11 @@ impl Decode<'_, ProblemReport> for Cip36RegistrationWitness {
3232
)));
3333
}
3434

35-
let key: u16 = decode_helper(d, "key in CIP36 Registration Witness", ctx)?;
35+
let key: u16 = decode_helper(d, "key in CIP36 Registration Witness", err_report)?;
3636

3737
// The key needs to be 1.
3838
if key != 1 {
39-
ctx.invalid_value(
39+
err_report.invalid_value(
4040
"map key",
4141
format!("{key}").as_str(),
4242
"expected key 1",
@@ -47,7 +47,7 @@ impl Decode<'_, ProblemReport> for Cip36RegistrationWitness {
4747
let sig_bytes = decode_bytes(d, "CIP36 Registration Witness signature")?;
4848
let signature = ed25519_dalek::Signature::from_slice(&sig_bytes)
4949
.map_err(|_| {
50-
ctx.conversion_error(
50+
err_report.conversion_error(
5151
"Signature",
5252
format!("{sig_bytes:?}").as_str(),
5353
"Cannot convert bytes to Ed25519 signature",

0 commit comments

Comments
 (0)