@@ -639,10 +639,16 @@ const char *tvm_emulator_run_get_method(void *tvm_emulator, int method_id, const
639
639
return strdup (jb.string_builder ().as_cslice ().c_str ());
640
640
}
641
641
642
- const char *tvm_emulator_emulate_run_method (uint32_t len, const char *params_boc, int64_t gas_limit) {
642
+ struct TvmEulatorEmulateRunMethodResponse
643
+ {
644
+ const char *response;
645
+ const char *log;
646
+ };
647
+
648
+ TvmEulatorEmulateRunMethodResponse emulate_run_method (uint32_t len, const char *params_boc, int64_t gas_limit) {
643
649
auto params_cell = vm::std_boc_deserialize (td::Slice (params_boc, len));
644
650
if (params_cell.is_error ()) {
645
- return nullptr ;
651
+ return { nullptr , nullptr } ;
646
652
}
647
653
auto params_cs = vm::load_cell_slice (params_cell.move_as_ok ());
648
654
auto code = params_cs.fetch_ref ();
@@ -657,12 +663,12 @@ const char *tvm_emulator_emulate_run_method(uint32_t len, const char *params_boc
657
663
658
664
td::Ref<vm::Stack> stack;
659
665
if (!vm::Stack::deserialize_to (stack_cs, stack)) {
660
- return nullptr ;
666
+ return { nullptr , nullptr } ;
661
667
}
662
668
663
669
td::Ref<vm::Stack> c7;
664
670
if (!vm::Stack::deserialize_to (c7_cs, c7)) {
665
- return nullptr ;
671
+ return { nullptr , nullptr } ;
666
672
}
667
673
668
674
auto emulator = new emulator::TvmEmulator (code, data);
@@ -692,7 +698,7 @@ const char *tvm_emulator_emulate_run_method(uint32_t len, const char *params_boc
692
698
td::Status unpack_res = config_ptr->unpack ();
693
699
if (unpack_res.is_error ()) {
694
700
LOG (ERROR) << " Can't unpack config params" ;
695
- return nullptr ;
701
+ return { nullptr , nullptr } ;
696
702
}
697
703
emulator->set_config (config_ptr);
698
704
}
@@ -708,7 +714,7 @@ const char *tvm_emulator_emulate_run_method(uint32_t len, const char *params_boc
708
714
709
715
vm::CellBuilder stack_cb;
710
716
if (!result.stack ->serialize (stack_cb)) {
711
- return nullptr ;
717
+ return { nullptr , nullptr } ;
712
718
}
713
719
714
720
vm::CellBuilder cb;
@@ -718,7 +724,7 @@ const char *tvm_emulator_emulate_run_method(uint32_t len, const char *params_boc
718
724
719
725
auto ser = vm::std_boc_serialize (cb.finalize ());
720
726
if (!ser.is_ok ()) {
721
- return nullptr ;
727
+ return { nullptr , nullptr } ;
722
728
}
723
729
auto sok = ser.move_as_ok ();
724
730
@@ -727,7 +733,26 @@ const char *tvm_emulator_emulate_run_method(uint32_t len, const char *params_boc
727
733
memcpy (rn, &sz, 4 );
728
734
memcpy (rn+4 , sok.data (), sz);
729
735
730
- return rn;
736
+ auto log_sz = uint32_t (result.vm_log .size ());
737
+ char * log_buffer = (char *)malloc (log_sz + 4 );
738
+ memcpy (log_buffer, &log_sz, 4 );
739
+ memcpy (log_buffer+4 , result.vm_log .data (), log_sz);
740
+
741
+ return { rn, log_buffer };
742
+ }
743
+
744
+ const char *tvm_emulator_emulate_run_method (uint32_t len, const char *params_boc, int64_t gas_limit) {
745
+ auto result = emulate_run_method (len, params_boc, gas_limit);
746
+ return result.response ;
747
+ }
748
+
749
+ const char *tvm_emulator_emulate_run_method_detailed (uint32_t len, const char *params_boc, int64_t gas_limit) {
750
+ auto result = emulate_run_method (len, params_boc, gas_limit);
751
+ TvmEulatorEmulateRunMethodResponse* response_ptr =
752
+ (TvmEulatorEmulateRunMethodResponse*)malloc (sizeof (TvmEulatorEmulateRunMethodResponse));
753
+ response_ptr->response = result.response ;
754
+ response_ptr->log = result.log ;
755
+ return reinterpret_cast <const char *>(response_ptr);
731
756
}
732
757
733
758
const char *tvm_emulator_send_external_message (void *tvm_emulator, const char *message_body_boc) {
0 commit comments