-
Notifications
You must be signed in to change notification settings - Fork 0
/
helloDebot.code
2441 lines (2362 loc) · 33.5 KB
/
helloDebot.code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.version sol 0.45.0
.macro constructor
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7_with_init_storage$
}
;; constructor protection
GETGLOB 6
THROWIF 51
PUSHINT 1
SETGLOB 6
;; end constructor protection
ENDS
ACCEPT
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.macro setIcon
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDREF
ENDS
;; param: icon
CALLREF {
CALL $setIcon_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl setIcon_internal
.type setIcon_internal, @function
CALL $setIcon_internal_macro$
.macro setIcon_internal_macro
;; param: icon
; function setIcon
GETGLOB 5
DUP
ISNULL
PUSHCONT {
DROP
PUSHINT 0
}
IF
;; ==
GETGLOB 2
EQUAL
THROWIFNOT 100
ACCEPT
; expValue
; end expValue
;; push identifier icon
; colValue
; end colValue
; end function setIcon
SETGLOB 14
.macro setDeviceCode
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
;; decode TvmCell
LDREF
ENDS
;; param: code
CALLREF {
CALL $setDeviceCode_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl setDeviceCode_internal
.type setDeviceCode_internal, @function
CALL $setDeviceCode_internal_macro$
.macro setDeviceCode_internal_macro
;; param: code
; function setDeviceCode
GETGLOB 5
DUP
ISNULL
PUSHCONT {
DROP
PUSHINT 0
}
IF
;; ==
GETGLOB 2
EQUAL
THROWIFNOT 100
ACCEPT
; expValue
; end expValue
;; push identifier code
; colValue
; end colValue
; end function setDeviceCode
SETGLOB 16
.macro start
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
ENDS
CALLREF {
CALL $start_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl start_internal
.type start_internal, @function
CALL $start_internal_macro$
.macro start_internal_macro
; function start
PUSHINT 0
PUSHREF {
.blob x4465626f7420737461727421
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 335034575
PUSHREF {
.blob x696e707574206964
}
PUSHINT 0
PUSHINT 1
PUSHINT 100
CALLREF {
CALL $AmountInput_no_obj_get_macro$
}
; end function start
.macro addDeviceSetDeviceId
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDUQ 128
PUSHCONT {
;; load next cell
LDREF
ENDS
CTOS
LDU 128
}
IFNOT
ENDS
;; param: value
CALLREF {
CALL $addDeviceSetDeviceId_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl addDeviceSetDeviceId_internal
.type addDeviceSetDeviceId_internal, @function
CALL $addDeviceSetDeviceId_internal_macro$
.macro addDeviceSetDeviceId_internal_macro
;; param: value
; function addDeviceSetDeviceId
; expValue
; end expValue
;; push identifier value
DUP
; colValue
SETGLOB 24
; end colValue
NEWDICT
PUSHINT 0
NEWC
STU 256
PUSHINT 0
ROT
PUSHINT 64
DICTUSETB
;; push identifier m_deviceId
GETGLOB 24
NEWC
STU 256
PUSHINT 1
ROT
PUSHINT 64
DICTUSETB
NEWC
STDICT
ENDC
;; push identifier m_iotDeviceCode
GETGLOB 16
NEWC
STSLICECONST x2_
STOPTREF
STOPTREF
STZERO
ENDC
HASHCU
NEWC
STSLICECONST x801_
STU 256
ENDC
CTOS
; expValue
; end expValue
; colValue
SETGLOB 23
; end colValue
TRUE
CALLREF {
CALL $isDeviceMoneySend_internal_macro$
}
; end function addDeviceSetDeviceId
DROP
.macro isDeviceMoneySend
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDI 1
ENDS
;; param: value
CALLREF {
CALL $isDeviceMoneySend_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl isDeviceMoneySend_internal
.type isDeviceMoneySend_internal, @function
CALL $isDeviceMoneySend_internal_macro$
.macro isDeviceMoneySend_internal_macro
;; param: value
; function isDeviceMoneySend
;; if
;; push identifier value
DUP
PUSHCONT {
PUSHINT 1717762330
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $Sdk_no_obj_getAccountType_macro$
}
}
PUSHCONT {
PUSHINT 94113135
PUSHREF {
.blob x5465726d696e6174656421
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
}
IFELSE
;; end if
; end function isDeviceMoneySend
DROP
.macro addDeviceCheckContract
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDI 8
ENDS
;; param: acc_type
CALLREF {
CALL $addDeviceCheckContract_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl addDeviceCheckContract_internal
.type addDeviceCheckContract_internal, @function
CALL $addDeviceCheckContract_internal_macro$
.macro addDeviceCheckContract_internal_macro
;; param: acc_type
; function addDeviceCheckContract
;; if
;; push identifier acc_type
DUP
EQINT -1
PUSHCONT {
PUSHINT 0
PUSHREF {
.blob x53656e6420302e3120746f6e206f72206d6f726520746f2074686520616464726573733a
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 0
NEWC
NULL
TUPLE 2
NEWC
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $convertAddressToHexString_macro$
}
CALLREF {
CALL $assembleList_macro$
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 690182183
PUSHREF {
.blob x44696420796f752073656e6420746865206d6f6e65793f
}
CALLREF {
CALL $ConfirmInput_no_obj_get_macro$
}
}
PUSHCONT {
;; if
;; push identifier acc_type
DUP
EQINT 0
PUSHCONT {
PUSHINT 1701548687
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $Sdk_no_obj_getBalance_macro$
}
}
PUSHCONT {
;; if
;; push identifier acc_type
DUP
EQINT 1
PUSHCONT {
PUSHINT 0
NEWC
NULL
TUPLE 2
NEWC
PUSHSLICE x636f6e747261637420657869737420
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $convertAddressToHexString_macro$
}
CALLREF {
CALL $assembleList_macro$
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 0
PUSHREF {
.blob x66696e697368
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
}
PUSHCONT {
;; if
;; push identifier acc_type
DUP
EQINT 2
PUSHCONT {
PUSHINT 94113135
NEWC
NULL
TUPLE 2
NEWC
PUSHSLICE x5465726d696e6174656421204163636f756e7420
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $convertAddressToHexString_macro$
}
PUSHSLICE x2069732066726f7a656e2e
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
CALLREF {
CALL $assembleList_macro$
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
}
IF
;; end if
}
IFELSE
;; end if
}
IFELSE
;; end if
}
IFELSE
;; end if
; end function addDeviceCheckContract
DROP
.macro checkIotDeviceBalance
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDUQ 128
PUSHCONT {
;; load next cell
LDREF
ENDS
CTOS
LDU 128
}
IFNOT
ENDS
;; param: nanotokens
CALLREF {
CALL $checkIotDeviceBalance_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl checkIotDeviceBalance_internal
.type checkIotDeviceBalance_internal, @function
CALL $checkIotDeviceBalance_internal_macro$
.macro checkIotDeviceBalance_internal_macro
;; param: nanotokens
; function checkIotDeviceBalance
;; if
;; push identifier nanotokens
DUP
;; <
PUSHINT 100000000
LESS
PUSHCONT {
PUSHINT 0
NEWC
NULL
TUPLE 2
NEWC
PUSHSLICE x4164647265737320
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier m_deviceAddr
GETGLOB 23
CALLREF {
CALL $convertAddressToHexString_macro$
}
PUSHSLICE x2062616c616e636520697320
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier nanotokens
PUSH S3
PUSHINT 9
CALLREF {
CALL $convertFixedPointToString_macro$
}
PUSHSLICE x20746f6e73
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
CALLREF {
CALL $assembleList_macro$
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT -1
CALLREF {
CALL $addDeviceCheckContract_internal_macro$
}
}
PUSHCONT {
PUSHINT 1822630878
PUSHREF {
.blob x4465706c6f79696e672e2e
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
}
IFELSE
;; end if
; end function checkIotDeviceBalance
DROP
.macro DeployIotDevice
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
ENDS
CALLREF {
CALL $DeployIotDevice_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl DeployIotDevice_internal
.type DeployIotDevice_internal, @function
CALL $DeployIotDevice_internal_macro$
.macro DeployIotDevice_internal_macro
; function DeployIotDevice
NEWDICT
PUSHINT 0
NEWC
STU 256
PUSHINT 0
ROT
PUSHINT 64
DICTUSETB
;; push identifier m_deviceId
GETGLOB 24
NEWC
STU 256
PUSHINT 1
ROT
PUSHINT 64
DICTUSETB
NEWC
STDICT
ENDC
;; push identifier m_iotDeviceCode
GETGLOB 16
NEWC
STSLICECONST x2_
STOPTREF
STOPTREF
STZERO
ENDC
;; decl: image
;; push identifier image
DUP
HASHCU
NEWC
STSLICECONST x801_
STU 256
ENDC
CTOS
;; decl: addr
NULL
;; decl: none
;; push identifier addr
PUSH S1
PUSHSLICE x926283ed7483886e3fe0174_
NEWC
STSLICE
STSLICE
PUSHSLICE x0e_
STSLICER
;; push identifier image
PUSH S3
STREFR
STSLICECONST 1
NEWC
STSLICECONST 1
PUSHINT 512
STZEROES
;; push identifier none
PUSH2 S2, S2
ISNULL
PUSHCONT {
DROP
STSLICECONST 0
}
PUSHCONT {
SWAP
STSLICECONST 1
STU 256
}
IFELSE
PUSHSLICE x00000000000000000000000068b55f3f
STSLICER
STBREFR
ENDC
;; decl: deployMsg
;; push identifier deployMsg
DUP
PUSHINT 1
SENDRAWMSG
BLKDROP 4
; end function DeployIotDevice
.macro onSuccessDeviceDeployed
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
ENDS
CALLREF {
CALL $onSuccessDeviceDeployed_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl onSuccessDeviceDeployed_internal
.type onSuccessDeviceDeployed_internal, @function
CALL $onSuccessDeviceDeployed_internal_macro$
.macro onSuccessDeviceDeployed_internal_macro
; function onSuccessDeviceDeployed
PUSHINT 0
PUSHREF {
.blob x6f6e537563636573734465766963654465706c6f796564
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 0
PUSHREF {
.blob x66696e697368
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
; end function onSuccessDeviceDeployed
.macro onDeployDeviceFailed
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
LDU 32
LDU 32
ENDS
;; param: sdkError
;; param: exitCode
CALLREF {
CALL $onDeployDeviceFailed_internal_macro$
}
CALLREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl onDeployDeviceFailed_internal
.type onDeployDeviceFailed_internal, @function
CALL $onDeployDeviceFailed_internal_macro$
.macro onDeployDeviceFailed_internal_macro
;; param: sdkError
;; param: exitCode
; function onDeployDeviceFailed
PUSHINT 0
NEWC
NULL
TUPLE 2
NEWC
PUSHSLICE x4465706c6f79206661696c65642e2053646b206572726f72203d20
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier sdkError
PUSH S4
PUSHINT 0
FALSE
FALSE
CALLREF {
CALL $convertIntToDecStr_macro$
}
CALLREF {
CALL $appendToList_macro$
}
PUSHSLICE x2c204572726f7220636f6465203d20
CALLREF {
CALL $storeStringInBuilders_macro$
}
CALLREF {
CALL $appendToList_macro$
}
;; push identifier exitCode
PUSH S3
PUSHINT 0
FALSE
FALSE
CALLREF {
CALL $convertIntToDecStr_macro$
}
CALLREF {
CALL $appendToList_macro$
}
CALLREF {
CALL $assembleList_macro$
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
PUSHINT 1822630878
PUSHREF {
.blob x52657472696e67
}
CALLREF {
CALL $Terminal_no_obj_print_macro$
}
; end function onDeployDeviceFailed
DROP2
.macro getDebotInfo
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
ENDS
CALLREF {
CALL $getDebotInfo_internal_macro$
}
;; emitting 10 value(s)
PUSH S10
PUSHCONT {
PUSH S12
CTOS
LDU 2
LDMSGADDR
DROP
NIP
NEWC
STSLICECONST xc
STSLICE
PUSHINT 1
STUR 98
REVERSE 10, 1
BLKSWAP 10, 1
NEWC
STSLICECONST x00000deb
STREF
STREF
STREF
BLKSWAP 7, 1
NEWC
STREF
STREF
STSLICE
STREF
BLKSWAP 3, 1
NEWC
STREF
STREF
STREF
STBREFR
STBREFR
STBREFR
ENDC
PUSHINT 0
SENDRAWMSG
}
PUSHCONT {
BLKDROP 10
}
IFELSE
IFREF {
CALL $c7_to_c4$
}
TRUE
SETGLOB 7
.globl getDebotInfo_internal
.type getDebotInfo_internal, @function
CALL $getDebotInfo_internal_macro$
.macro getDebotInfo_internal_macro
;; ret param: name
PUSHREF {
}
;; ret param: version
PUSHREF {
}
;; ret param: publisher
PUSHREF {
}
;; ret param: caption
PUSHREF {
}
;; ret param: author
PUSHREF {
}
;; ret param: support
PUSHSLICE x8000000000000000000000000000000000000000000000000000000000000000001_
;; ret param: hello
PUSHREF {
}
;; ret param: language
PUSHREF {
}
;; ret param: dabi
PUSHREF {
}
;; ret param: icon
PUSHREF {
}
; function getDebotInfo
; expValue
; end expValue
PUSHREF {
.blob x5465737420696e6974207374617465
}
; colValue
POP S10
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x302e302e33
}
; colValue
POP S9
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x
}
; colValue
POP S8
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x5465737420696e6974207374617465
}
; colValue
POP S7
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x
}
; colValue
POP S6
; end colValue
;; address.makeAddrStd()
PUSHSLICE x8000000000000000000000000000000000000000000000000000000000000000001_
; expValue
; end expValue
; colValue
POP S5
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x48656c6c6f2c206920616d2061204465426f742e
}
; colValue
POP S4
; end colValue
; expValue
; end expValue
PUSHREF {
.blob x656e
}
; colValue
POP S3
; end colValue
;; push identifier m_debotAbi
GETGLOB 11
DUP
ISNULL
THROWIF 63
; expValue
; end expValue
; colValue
POP S2
; end colValue
; expValue
; end expValue
;; push identifier m_icon
; colValue
DROP
GETGLOB 14
; end colValue
; end function getDebotInfo
.macro getRequiredInterfaces
DROP
GETGLOB 8
ISNULL
IFREF {
CALL $c4_to_c7$
}
ENDS
CALLREF {
CALL $getRequiredInterfaces_internal_macro$
}
;; emitting 1 value(s)
PUSH S1
PUSHCONT {
PUSH S3
CTOS
LDU 2
LDMSGADDR
DROP
NIP
NEWC
STSLICECONST xc
STSLICE
PUSHSLICE x00000000000000000000000036190b42a_
STSLICER
SWAP
UNPAIR
XCHG s2
STU 32
STDICT
ENDC
PUSHINT 0