From c059c1ff1c87059eb082f6738613eefe93a062d3 Mon Sep 17 00:00:00 2001 From: Kayos Date: Tue, 5 May 2026 13:42:33 -0700 Subject: [PATCH] =?UTF-8?q?fix(dao):=20build=20errors=20in=20plutus=5Fdata?= =?UTF-8?q?=20=E2=80=94=20or-pattern=20parens,=20Int=E2=86=92i128,=20Bound?= =?UTF-8?q?edBytes=20AsRef=20ambiguity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/aldabra-dao/src/agora/plutus_data.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/aldabra-dao/src/agora/plutus_data.rs b/crates/aldabra-dao/src/agora/plutus_data.rs index 78a2d49..c08d394 100644 --- a/crates/aldabra-dao/src/agora/plutus_data.rs +++ b/crates/aldabra-dao/src/agora/plutus_data.rs @@ -69,7 +69,8 @@ pub fn as_constr(pd: &PlutusData) -> DaoResult<(u64, &Vec)> { c.tag ))); }; - let MaybeIndefArray::Def(ref fields) | MaybeIndefArray::Indef(ref fields) = c.fields; + let (MaybeIndefArray::Def(ref fields) | MaybeIndefArray::Indef(ref fields)) = + c.fields; Ok((idx, fields)) } other => Err(DaoError::Datum(format!( @@ -82,8 +83,10 @@ pub fn as_constr(pd: &PlutusData) -> DaoResult<(u64, &Vec)> { pub fn as_int(pd: &PlutusData) -> DaoResult { match pd { PlutusData::BigInt(BigInt::Int(i)) => { - // pallas's BigInt::Int wraps a `minicbor::data::Int` which lossily exposes i64 only. - Ok(i128::from(i64::from(*i))) + // pallas's BigInt::Int wraps a `minicbor::data::Int`. Convert via + // i128 (Int → i128 is total since CBOR spec encodes [-2^64, 2^64-1] + // — minicbor's Int can't exceed i128's range). + Ok(i128::from(*i)) } PlutusData::BigInt(BigInt::BigUInt(b)) => { let bs = b.as_slice(); @@ -114,7 +117,12 @@ pub fn as_int(pd: &PlutusData) -> DaoResult { /// Decode a PlutusData::BoundedBytes into a Vec. pub fn as_bytes(pd: &PlutusData) -> DaoResult> { match pd { - PlutusData::BoundedBytes(b) => Ok(b.as_ref().clone()), + PlutusData::BoundedBytes(b) => { + // `BoundedBytes` impls `AsRef>` AND `AsRef<[u8]>`, so we + // pin the slice variant explicitly to disambiguate. + let bs: &[u8] = b.as_ref(); + Ok(bs.to_vec()) + } other => Err(DaoError::Datum(format!( "expected BoundedBytes, got {other:?}" ))),