8
8
"errors"
9
9
"fmt"
10
10
"github.com/tonkeeper/tongo/abi"
11
+ "go.uber.org/zap"
11
12
"net/http"
12
13
"strings"
13
14
"time"
@@ -353,7 +354,13 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas
353
354
return nil , toError (http .StatusBadRequest , err )
354
355
}
355
356
hash , err := c .HashString ()
357
+ if err != nil {
358
+ return nil , toError (http .StatusBadRequest , err )
359
+ }
356
360
trace , _ , err := h .storage .GetTraceWithState (ctx , hash )
361
+ if err != nil {
362
+ h .logger .Warn ("get trace from storage: " , zap .Error (err ))
363
+ }
357
364
if trace == nil {
358
365
configBase64 , err := h .storage .TrimmedConfigBase64 ()
359
366
if err != nil {
@@ -379,7 +386,7 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas
379
386
if err != nil {
380
387
return nil , toError (http .StatusInternalServerError , err )
381
388
}
382
- err = h .storage .SaveTraceWithState (hash , trace , []abi.MethodInvocation {}, 24 * time .Hour )
389
+ err = h .storage .SaveTraceWithState (ctx , hash , trace , []abi.MethodInvocation {}, 24 * time .Hour )
383
390
if err != nil {
384
391
fmt .Println ("trace not saved: " , err )
385
392
}
@@ -407,8 +414,14 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat
407
414
}
408
415
trace , prs := h .mempoolEmulate .traces .Get (hash )
409
416
if ! prs {
410
- hs , _ := c .HashString ()
417
+ hs , err := c .HashString ()
418
+ if err != nil {
419
+ return nil , toError (http .StatusBadRequest , err )
420
+ }
411
421
trace , _ , err = h .storage .GetTraceWithState (ctx , hs )
422
+ if err != nil {
423
+ h .logger .Warn ("get trace from storage: " , zap .Error (err ))
424
+ }
412
425
if trace == nil {
413
426
var m tlb.Message
414
427
if err := tlb .Unmarshal (c , & m ); err != nil {
@@ -438,7 +451,7 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat
438
451
if err != nil {
439
452
return nil , toError (http .StatusInternalServerError , err )
440
453
}
441
- err = h .storage .SaveTraceWithState (hs , trace , []abi.MethodInvocation {}, 24 * time .Hour )
454
+ err = h .storage .SaveTraceWithState (ctx , hs , trace , []abi.MethodInvocation {}, 24 * time .Hour )
442
455
if err != nil {
443
456
fmt .Println ("trace not saved: " , err )
444
457
}
@@ -468,7 +481,13 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat
468
481
trace , prs := h .mempoolEmulate .traces .Get (hash )
469
482
if ! prs {
470
483
hs , err := c .HashString ()
484
+ if err != nil {
485
+ return nil , toError (http .StatusBadRequest , err )
486
+ }
471
487
trace , _ , err = h .storage .GetTraceWithState (ctx , hs )
488
+ if err != nil {
489
+ h .logger .Warn ("get trace from storage: " , zap .Error (err ))
490
+ }
472
491
if trace == nil {
473
492
var m tlb.Message
474
493
err = tlb .Unmarshal (c , & m )
@@ -499,7 +518,7 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat
499
518
if err != nil {
500
519
return nil , toError (http .StatusInternalServerError , err )
501
520
}
502
- err = h .storage .SaveTraceWithState (hs , trace , []abi.MethodInvocation {}, 24 * time .Hour )
521
+ err = h .storage .SaveTraceWithState (ctx , hs , trace , []abi.MethodInvocation {}, 24 * time .Hour )
503
522
if err != nil {
504
523
fmt .Println ("trace not saved: " , err )
505
524
}
@@ -591,7 +610,13 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula
591
610
}
592
611
593
612
hash , err := msgCell .HashString ()
613
+ if err != nil {
614
+ return nil , toError (http .StatusBadRequest , err )
615
+ }
594
616
trace , _ , err := h .storage .GetTraceWithState (ctx , hash )
617
+ if err != nil {
618
+ h .logger .Warn ("get trace from storage: " , zap .Error (err ))
619
+ }
595
620
if trace == nil {
596
621
configBase64 , err := h .storage .TrimmedConfigBase64 ()
597
622
if err != nil {
@@ -633,7 +658,7 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula
633
658
if err != nil {
634
659
return nil , toError (http .StatusInternalServerError , err )
635
660
}
636
- err = h .storage .SaveTraceWithState (hash , trace , []abi.MethodInvocation {}, 24 * time .Hour )
661
+ err = h .storage .SaveTraceWithState (ctx , hash , trace , []abi.MethodInvocation {}, 24 * time .Hour )
637
662
if err != nil {
638
663
fmt .Println ("trace not saved: " , err )
639
664
}
0 commit comments