Skip to content

Commit f380ceb

Browse files
CRC: make construct_print_transaction_event take a ref
Signed-off-by: Jacinta Ferrant <236437600+jacinta-stacks@users.noreply.github.com>
1 parent 170e403 commit f380ceb

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

clarity/src/vm/contexts.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,13 +1514,12 @@ impl<'a, 'b, 'hooks> ExecutionState<'a, 'b, 'hooks> {
15141514
}
15151515

15161516
pub fn construct_print_transaction_event(
1517-
contract_id: &QualifiedContractIdentifier,
1518-
value: &Value,
1517+
contract_id: QualifiedContractIdentifier,
1518+
value: Value,
15191519
) -> StacksTransactionEvent {
15201520
let print_event = SmartContractEventData {
1521-
key: (contract_id.clone(), "print".to_string()),
1522-
// TODO: why isn't this charged for?
1523-
value: value.clone(),
1521+
key: (contract_id, "print".to_string()),
1522+
value,
15241523
};
15251524

15261525
StacksTransactionEvent::SmartContractEvent(print_event)
@@ -1529,10 +1528,10 @@ impl<'a, 'b, 'hooks> ExecutionState<'a, 'b, 'hooks> {
15291528
pub fn register_print_event(
15301529
&mut self,
15311530
invoke_ctx: &InvocationContext,
1532-
value: &Value,
1531+
value: Value,
15331532
) -> Result<(), VmExecutionError> {
15341533
let event = Self::construct_print_transaction_event(
1535-
&invoke_ctx.contract_context.contract_identifier,
1534+
invoke_ctx.contract_context.contract_identifier.clone(),
15361535
value,
15371536
);
15381537

clarity/src/vm/functions/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,9 @@ fn special_print(
663663
debug!("{}", input.as_ref());
664664
}
665665

666-
exec_state.register_print_event(invoke_ctx, input.as_ref())?;
667-
input.clone_with_cost(exec_state)
666+
let value = input.clone_with_cost(exec_state)?;
667+
exec_state.register_print_event(invoke_ctx, value.clone())?;
668+
Ok(value)
668669
}
669670

670671
fn special_if(

pox-locking/src/pox_2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,10 @@ pub fn handle_contract_call(
514514
if let Some(event_info) = event_info_opt {
515515
let event_response =
516516
Value::okay(event_info).expect("FATAL: failed to construct (ok event-info)");
517-
let tx_event =
518-
ExecutionState::construct_print_transaction_event(contract_id, &event_response);
517+
let tx_event = ExecutionState::construct_print_transaction_event(
518+
contract_id.clone(),
519+
event_response,
520+
);
519521
Some(tx_event)
520522
} else {
521523
None

pox-locking/src/pox_3.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ pub fn handle_contract_call(
404404
if let Some(event_info) = event_info_opt {
405405
let event_response =
406406
Value::okay(event_info).expect("FATAL: failed to construct (ok event-info)");
407-
let tx_event =
408-
ExecutionState::construct_print_transaction_event(contract_id, &event_response);
407+
let tx_event = ExecutionState::construct_print_transaction_event(
408+
contract_id.clone(),
409+
event_response,
410+
);
409411
Some(tx_event)
410412
} else {
411413
None

pox-locking/src/pox_4.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,10 @@ pub fn handle_contract_call(
370370
if let Some(event_info) = event_info_opt {
371371
let event_response =
372372
Value::okay(event_info).expect("FATAL: failed to construct (ok event-info)");
373-
let tx_event =
374-
ExecutionState::construct_print_transaction_event(contract_id, &event_response);
373+
let tx_event = ExecutionState::construct_print_transaction_event(
374+
contract_id.clone(),
375+
event_response,
376+
);
375377
Some(tx_event)
376378
} else {
377379
None

stackslib/src/chainstate/stacks/boot/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl StacksChainState {
622622

623623
// Add synthetic print event for `handle-unlock`, since it alters stacking state
624624
let tx_event =
625-
ExecutionState::construct_print_transaction_event(&pox_contract, &event_info);
625+
ExecutionState::construct_print_transaction_event(pox_contract.clone(), event_info);
626626
events.push(tx_event);
627627
total_events.extend(events.into_iter());
628628
}

0 commit comments

Comments
 (0)