Skip to content

Commit 58f831b

Browse files
committed
Merge branch 'feat/output-preimage-saving' of github.com:HerodotusDev/hdp-cairo into feat/output-preimage-saving
2 parents c79b74a + f652075 commit 58f831b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crates/dry_hint_processor/src/output.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ use cairo_vm::{
88
},
99
hint_processor_utils::felt_to_usize,
1010
},
11-
types::exec_scope::ExecutionScopes,
11+
types::{
12+
exec_scope::ExecutionScopes,
13+
relocatable::MaybeRelocatable,
14+
},
1215
vm::{errors::hint_errors::HintError, vm_core::VirtualMachine},
1316
Felt252,
1417
};
@@ -55,9 +58,15 @@ impl CustomHintProcessor {
5558
.get_continuous_range(retdata_ptr, len)?
5659
.into_iter()
5760
.map(|value| {
58-
value
59-
.get_int()
60-
.ok_or_else(|| HintError::CustomHint("retdata contains relocatable value, expected felt".to_string().into_boxed_str()))
61+
match value {
62+
MaybeRelocatable::Int(felt) => Ok(felt),
63+
MaybeRelocatable::RelocatableValue(relocatable) => {
64+
let segment_index = Felt252::from(relocatable.segment_index);
65+
let offset = Felt252::from(relocatable.offset);
66+
let two_to_64 = Felt252::from(2u64).pow(64u128);
67+
Ok(segment_index * two_to_64 + offset)
68+
}
69+
}
6170
})
6271
.collect::<Result<Vec<Felt252>, HintError>>()?;
6372

0 commit comments

Comments
 (0)