@talismn/on-chain-id 0.1.28 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,9 +2,7 @@
2
2
 
3
3
  var crypto = require('@talismn/crypto');
4
4
  var anylogger = require('anylogger');
5
- var apiContract = require('@polkadot/api-contract');
6
- var util = require('@polkadot/util');
7
- var util$1 = require('@talismn/util');
5
+ var util = require('@talismn/util');
8
6
 
9
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
8
 
@@ -15,1386 +13,15 @@ var packageJson = {
15
13
 
16
14
  var log = anylogger__default.default(packageJson.name);
17
15
 
18
- var aznsRouterAbiJson = {
19
- source: {
20
- hash: "0x63308c1311af44bb47082327c301fce559ca28f6bb010a61b9884d9246746abf",
21
- language: "ink! 4.2.1",
22
- compiler: "rustc 1.68.0-nightly",
23
- build_info: {
24
- build_mode: "Release",
25
- cargo_contract_version: "3.0.1",
26
- rust_toolchain: "nightly-aarch64-apple-darwin",
27
- wasm_opt_settings: {
28
- keep_debug_symbols: false,
29
- optimization_passes: "Z"
30
- }
31
- }
32
- },
33
- contract: {
34
- name: "azns_router",
35
- version: "1.0.0",
36
- authors: [
37
- "AZERO.ID <hello@azero.id>"
38
- ]
39
- },
40
- spec: {
41
- constructors: [
42
- {
43
- args: [
44
- {
45
- label: "admin",
46
- type: {
47
- displayName: [
48
- "AccountId"
49
- ],
50
- type: 0
51
- }
52
- }
53
- ],
54
- "default": false,
55
- docs: [
56
- ],
57
- label: "new",
58
- payable: false,
59
- returnType: {
60
- displayName: [
61
- "ink_primitives",
62
- "ConstructorResult"
63
- ],
64
- type: 6
65
- },
66
- selector: "0x9bae9d5e"
67
- }
68
- ],
69
- docs: [
70
- ],
71
- environment: {
72
- accountId: {
73
- displayName: [
74
- "AccountId"
75
- ],
76
- type: 0
77
- },
78
- balance: {
79
- displayName: [
80
- "Balance"
81
- ],
82
- type: 25
83
- },
84
- blockNumber: {
85
- displayName: [
86
- "BlockNumber"
87
- ],
88
- type: 28
89
- },
90
- chainExtension: {
91
- displayName: [
92
- "ChainExtension"
93
- ],
94
- type: 29
95
- },
96
- hash: {
97
- displayName: [
98
- "Hash"
99
- ],
100
- type: 26
101
- },
102
- maxEventTopics: 4,
103
- timestamp: {
104
- displayName: [
105
- "Timestamp"
106
- ],
107
- type: 27
108
- }
109
- },
110
- events: [
111
- ],
112
- lang_error: {
113
- displayName: [
114
- "ink",
115
- "LangError"
116
- ],
117
- type: 8
118
- },
119
- messages: [
120
- {
121
- args: [
122
- {
123
- label: "tld",
124
- type: {
125
- displayName: [
126
- "Vec"
127
- ],
128
- type: 4
129
- }
130
- },
131
- {
132
- label: "registry_addr",
133
- type: {
134
- displayName: [
135
- "AccountId"
136
- ],
137
- type: 0
138
- }
139
- }
140
- ],
141
- "default": false,
142
- docs: [
143
- ],
144
- label: "add_registry",
145
- mutates: true,
146
- payable: false,
147
- returnType: {
148
- displayName: [
149
- "ink",
150
- "MessageResult"
151
- ],
152
- type: 9
153
- },
154
- selector: "0xc997efe3"
155
- },
156
- {
157
- args: [
158
- {
159
- label: "tld",
160
- type: {
161
- displayName: [
162
- "Vec"
163
- ],
164
- type: 4
165
- }
166
- },
167
- {
168
- label: "registry_addr",
169
- type: {
170
- displayName: [
171
- "AccountId"
172
- ],
173
- type: 0
174
- }
175
- }
176
- ],
177
- "default": false,
178
- docs: [
179
- ],
180
- label: "update_registry",
181
- mutates: true,
182
- payable: false,
183
- returnType: {
184
- displayName: [
185
- "ink",
186
- "MessageResult"
187
- ],
188
- type: 9
189
- },
190
- selector: "0x562de86b"
191
- },
192
- {
193
- args: [
194
- {
195
- label: "registry_addr",
196
- type: {
197
- displayName: [
198
- "AccountId"
199
- ],
200
- type: 0
201
- }
202
- }
203
- ],
204
- "default": false,
205
- docs: [
206
- ],
207
- label: "remove_registry_address",
208
- mutates: true,
209
- payable: false,
210
- returnType: {
211
- displayName: [
212
- "ink",
213
- "MessageResult"
214
- ],
215
- type: 9
216
- },
217
- selector: "0xcc78aead"
218
- },
219
- {
220
- args: [
221
- ],
222
- "default": false,
223
- docs: [
224
- ],
225
- label: "get_all_registries",
226
- mutates: false,
227
- payable: false,
228
- returnType: {
229
- displayName: [
230
- "ink",
231
- "MessageResult"
232
- ],
233
- type: 12
234
- },
235
- selector: "0xe6da7bf0"
236
- },
237
- {
238
- args: [
239
- ],
240
- "default": false,
241
- docs: [
242
- ],
243
- label: "get_all_tlds",
244
- mutates: false,
245
- payable: false,
246
- returnType: {
247
- displayName: [
248
- "ink",
249
- "MessageResult"
250
- ],
251
- type: 15
252
- },
253
- selector: "0xf1a7af41"
254
- },
255
- {
256
- args: [
257
- {
258
- label: "registry_addr",
259
- type: {
260
- displayName: [
261
- "AccountId"
262
- ],
263
- type: 0
264
- }
265
- }
266
- ],
267
- "default": false,
268
- docs: [
269
- ],
270
- label: "get_associated_tlds",
271
- mutates: false,
272
- payable: false,
273
- returnType: {
274
- displayName: [
275
- "ink",
276
- "MessageResult"
277
- ],
278
- type: 15
279
- },
280
- selector: "0xcb18f821"
281
- },
282
- {
283
- args: [
284
- {
285
- label: "tld",
286
- type: {
287
- displayName: [
288
- "String"
289
- ],
290
- type: 5
291
- }
292
- }
293
- ],
294
- "default": false,
295
- docs: [
296
- ],
297
- label: "get_registry",
298
- mutates: false,
299
- payable: false,
300
- returnType: {
301
- displayName: [
302
- "ink",
303
- "MessageResult"
304
- ],
305
- type: 16
306
- },
307
- selector: "0x15a5d20a"
308
- },
309
- {
310
- args: [
311
- {
312
- label: "domain",
313
- type: {
314
- displayName: [
315
- "String"
316
- ],
317
- type: 5
318
- }
319
- }
320
- ],
321
- "default": false,
322
- docs: [
323
- ],
324
- label: "get_address",
325
- mutates: false,
326
- payable: false,
327
- returnType: {
328
- displayName: [
329
- "ink",
330
- "MessageResult"
331
- ],
332
- type: 18
333
- },
334
- selector: "0xd259f7ba"
335
- },
336
- {
337
- args: [
338
- {
339
- label: "account",
340
- type: {
341
- displayName: [
342
- "AccountId"
343
- ],
344
- type: 0
345
- }
346
- },
347
- {
348
- label: "tld",
349
- type: {
350
- displayName: [
351
- "Option"
352
- ],
353
- type: 20
354
- }
355
- }
356
- ],
357
- "default": false,
358
- docs: [
359
- " @returns list of (registry-address, primary-domain) for given account"
360
- ],
361
- label: "get_primary_domains",
362
- mutates: false,
363
- payable: false,
364
- returnType: {
365
- displayName: [
366
- "ink",
367
- "MessageResult"
368
- ],
369
- type: 21
370
- },
371
- selector: "0xdf3a358e"
372
- },
373
- {
374
- args: [
375
- ],
376
- "default": false,
377
- docs: [
378
- ],
379
- label: "get_admin",
380
- mutates: false,
381
- payable: false,
382
- returnType: {
383
- displayName: [
384
- "ink",
385
- "MessageResult"
386
- ],
387
- type: 24
388
- },
389
- selector: "0x57b8a8a7"
390
- },
391
- {
392
- args: [
393
- ],
394
- "default": false,
395
- docs: [
396
- ],
397
- label: "get_pending_admin",
398
- mutates: false,
399
- payable: false,
400
- returnType: {
401
- displayName: [
402
- "ink",
403
- "MessageResult"
404
- ],
405
- type: 16
406
- },
407
- selector: "0xbcd31d76"
408
- },
409
- {
410
- args: [
411
- {
412
- label: "account",
413
- type: {
414
- displayName: [
415
- "Option"
416
- ],
417
- type: 17
418
- }
419
- }
420
- ],
421
- "default": false,
422
- docs: [
423
- ],
424
- label: "transfer_ownership",
425
- mutates: true,
426
- payable: false,
427
- returnType: {
428
- displayName: [
429
- "ink",
430
- "MessageResult"
431
- ],
432
- type: 9
433
- },
434
- selector: "0x107e33ea"
435
- },
436
- {
437
- args: [
438
- ],
439
- "default": false,
440
- docs: [
441
- ],
442
- label: "accept_ownership",
443
- mutates: true,
444
- payable: false,
445
- returnType: {
446
- displayName: [
447
- "ink",
448
- "MessageResult"
449
- ],
450
- type: 9
451
- },
452
- selector: "0xb55be9f0"
453
- },
454
- {
455
- args: [
456
- {
457
- label: "code_hash",
458
- type: {
459
- displayName: [
460
- ],
461
- type: 1
462
- }
463
- }
464
- ],
465
- "default": false,
466
- docs: [
467
- ],
468
- label: "upgrade_contract",
469
- mutates: true,
470
- payable: false,
471
- returnType: {
472
- displayName: [
473
- "ink",
474
- "MessageResult"
475
- ],
476
- type: 6
477
- },
478
- selector: "0x1345543d"
479
- }
480
- ]
481
- },
482
- storage: {
483
- root: {
484
- layout: {
485
- struct: {
486
- fields: [
487
- {
488
- layout: {
489
- leaf: {
490
- key: "0x00000000",
491
- ty: 0
492
- }
493
- },
494
- name: "admin"
495
- },
496
- {
497
- layout: {
498
- "enum": {
499
- dispatchKey: "0x00000000",
500
- name: "Option",
501
- variants: {
502
- "0": {
503
- fields: [
504
- ],
505
- name: "None"
506
- },
507
- "1": {
508
- fields: [
509
- {
510
- layout: {
511
- leaf: {
512
- key: "0x00000000",
513
- ty: 0
514
- }
515
- },
516
- name: "0"
517
- }
518
- ],
519
- name: "Some"
520
- }
521
- }
522
- }
523
- },
524
- name: "pending_admin"
525
- },
526
- {
527
- layout: {
528
- leaf: {
529
- key: "0x00000000",
530
- ty: 3
531
- }
532
- },
533
- name: "registry"
534
- },
535
- {
536
- layout: {
537
- root: {
538
- layout: {
539
- leaf: {
540
- key: "0x00000064",
541
- ty: 0
542
- }
543
- },
544
- root_key: "0x00000064"
545
- }
546
- },
547
- name: "routes"
548
- },
549
- {
550
- layout: {
551
- root: {
552
- layout: {
553
- leaf: {
554
- key: "0x00000065",
555
- ty: 4
556
- }
557
- },
558
- root_key: "0x00000065"
559
- }
560
- },
561
- name: "associated_tlds"
562
- }
563
- ],
564
- name: "Router"
565
- }
566
- },
567
- root_key: "0x00000000"
568
- }
569
- },
570
- types: [
571
- {
572
- id: 0,
573
- type: {
574
- def: {
575
- composite: {
576
- fields: [
577
- {
578
- type: 1,
579
- typeName: "[u8; 32]"
580
- }
581
- ]
582
- }
583
- },
584
- path: [
585
- "ink_primitives",
586
- "types",
587
- "AccountId"
588
- ]
589
- }
590
- },
591
- {
592
- id: 1,
593
- type: {
594
- def: {
595
- array: {
596
- len: 32,
597
- type: 2
598
- }
599
- }
600
- }
601
- },
602
- {
603
- id: 2,
604
- type: {
605
- def: {
606
- primitive: "u8"
607
- }
608
- }
609
- },
610
- {
611
- id: 3,
612
- type: {
613
- def: {
614
- sequence: {
615
- type: 0
616
- }
617
- }
618
- }
619
- },
620
- {
621
- id: 4,
622
- type: {
623
- def: {
624
- sequence: {
625
- type: 5
626
- }
627
- }
628
- }
629
- },
630
- {
631
- id: 5,
632
- type: {
633
- def: {
634
- primitive: "str"
635
- }
636
- }
637
- },
638
- {
639
- id: 6,
640
- type: {
641
- def: {
642
- variant: {
643
- variants: [
644
- {
645
- fields: [
646
- {
647
- type: 7
648
- }
649
- ],
650
- index: 0,
651
- name: "Ok"
652
- },
653
- {
654
- fields: [
655
- {
656
- type: 8
657
- }
658
- ],
659
- index: 1,
660
- name: "Err"
661
- }
662
- ]
663
- }
664
- },
665
- params: [
666
- {
667
- name: "T",
668
- type: 7
669
- },
670
- {
671
- name: "E",
672
- type: 8
673
- }
674
- ],
675
- path: [
676
- "Result"
677
- ]
678
- }
679
- },
680
- {
681
- id: 7,
682
- type: {
683
- def: {
684
- tuple: [
685
- ]
686
- }
687
- }
688
- },
689
- {
690
- id: 8,
691
- type: {
692
- def: {
693
- variant: {
694
- variants: [
695
- {
696
- index: 1,
697
- name: "CouldNotReadInput"
698
- }
699
- ]
700
- }
701
- },
702
- path: [
703
- "ink_primitives",
704
- "LangError"
705
- ]
706
- }
707
- },
708
- {
709
- id: 9,
710
- type: {
711
- def: {
712
- variant: {
713
- variants: [
714
- {
715
- fields: [
716
- {
717
- type: 10
718
- }
719
- ],
720
- index: 0,
721
- name: "Ok"
722
- },
723
- {
724
- fields: [
725
- {
726
- type: 8
727
- }
728
- ],
729
- index: 1,
730
- name: "Err"
731
- }
732
- ]
733
- }
734
- },
735
- params: [
736
- {
737
- name: "T",
738
- type: 10
739
- },
740
- {
741
- name: "E",
742
- type: 8
743
- }
744
- ],
745
- path: [
746
- "Result"
747
- ]
748
- }
749
- },
750
- {
751
- id: 10,
752
- type: {
753
- def: {
754
- variant: {
755
- variants: [
756
- {
757
- fields: [
758
- {
759
- type: 7
760
- }
761
- ],
762
- index: 0,
763
- name: "Ok"
764
- },
765
- {
766
- fields: [
767
- {
768
- type: 11
769
- }
770
- ],
771
- index: 1,
772
- name: "Err"
773
- }
774
- ]
775
- }
776
- },
777
- params: [
778
- {
779
- name: "T",
780
- type: 7
781
- },
782
- {
783
- name: "E",
784
- type: 11
785
- }
786
- ],
787
- path: [
788
- "Result"
789
- ]
790
- }
791
- },
792
- {
793
- id: 11,
794
- type: {
795
- def: {
796
- variant: {
797
- variants: [
798
- {
799
- index: 0,
800
- name: "NotAdmin"
801
- },
802
- {
803
- index: 1,
804
- name: "InvalidRegistryAddress"
805
- },
806
- {
807
- fields: [
808
- {
809
- type: 5,
810
- typeName: "String"
811
- }
812
- ],
813
- index: 2,
814
- name: "TldAlreadyInUse"
815
- },
816
- {
817
- fields: [
818
- {
819
- type: 5,
820
- typeName: "String"
821
- }
822
- ],
823
- index: 3,
824
- name: "TldNotFound"
825
- },
826
- {
827
- index: 4,
828
- name: "CouldNotResolveDomain"
829
- },
830
- {
831
- index: 5,
832
- name: "InvalidDomainName"
833
- },
834
- {
835
- index: 6,
836
- name: "EmptyList"
837
- }
838
- ]
839
- }
840
- },
841
- path: [
842
- "azns_router",
843
- "azns_router",
844
- "Error"
845
- ]
846
- }
847
- },
848
- {
849
- id: 12,
850
- type: {
851
- def: {
852
- variant: {
853
- variants: [
854
- {
855
- fields: [
856
- {
857
- type: 13
858
- }
859
- ],
860
- index: 0,
861
- name: "Ok"
862
- },
863
- {
864
- fields: [
865
- {
866
- type: 8
867
- }
868
- ],
869
- index: 1,
870
- name: "Err"
871
- }
872
- ]
873
- }
874
- },
875
- params: [
876
- {
877
- name: "T",
878
- type: 13
879
- },
880
- {
881
- name: "E",
882
- type: 8
883
- }
884
- ],
885
- path: [
886
- "Result"
887
- ]
888
- }
889
- },
890
- {
891
- id: 13,
892
- type: {
893
- def: {
894
- sequence: {
895
- type: 14
896
- }
897
- }
898
- }
899
- },
900
- {
901
- id: 14,
902
- type: {
903
- def: {
904
- tuple: [
905
- 0,
906
- 4
907
- ]
908
- }
909
- }
910
- },
911
- {
912
- id: 15,
913
- type: {
914
- def: {
915
- variant: {
916
- variants: [
917
- {
918
- fields: [
919
- {
920
- type: 4
921
- }
922
- ],
923
- index: 0,
924
- name: "Ok"
925
- },
926
- {
927
- fields: [
928
- {
929
- type: 8
930
- }
931
- ],
932
- index: 1,
933
- name: "Err"
934
- }
935
- ]
936
- }
937
- },
938
- params: [
939
- {
940
- name: "T",
941
- type: 4
942
- },
943
- {
944
- name: "E",
945
- type: 8
946
- }
947
- ],
948
- path: [
949
- "Result"
950
- ]
951
- }
952
- },
953
- {
954
- id: 16,
955
- type: {
956
- def: {
957
- variant: {
958
- variants: [
959
- {
960
- fields: [
961
- {
962
- type: 17
963
- }
964
- ],
965
- index: 0,
966
- name: "Ok"
967
- },
968
- {
969
- fields: [
970
- {
971
- type: 8
972
- }
973
- ],
974
- index: 1,
975
- name: "Err"
976
- }
977
- ]
978
- }
979
- },
980
- params: [
981
- {
982
- name: "T",
983
- type: 17
984
- },
985
- {
986
- name: "E",
987
- type: 8
988
- }
989
- ],
990
- path: [
991
- "Result"
992
- ]
993
- }
994
- },
995
- {
996
- id: 17,
997
- type: {
998
- def: {
999
- variant: {
1000
- variants: [
1001
- {
1002
- index: 0,
1003
- name: "None"
1004
- },
1005
- {
1006
- fields: [
1007
- {
1008
- type: 0
1009
- }
1010
- ],
1011
- index: 1,
1012
- name: "Some"
1013
- }
1014
- ]
1015
- }
1016
- },
1017
- params: [
1018
- {
1019
- name: "T",
1020
- type: 0
1021
- }
1022
- ],
1023
- path: [
1024
- "Option"
1025
- ]
1026
- }
1027
- },
1028
- {
1029
- id: 18,
1030
- type: {
1031
- def: {
1032
- variant: {
1033
- variants: [
1034
- {
1035
- fields: [
1036
- {
1037
- type: 19
1038
- }
1039
- ],
1040
- index: 0,
1041
- name: "Ok"
1042
- },
1043
- {
1044
- fields: [
1045
- {
1046
- type: 8
1047
- }
1048
- ],
1049
- index: 1,
1050
- name: "Err"
1051
- }
1052
- ]
1053
- }
1054
- },
1055
- params: [
1056
- {
1057
- name: "T",
1058
- type: 19
1059
- },
1060
- {
1061
- name: "E",
1062
- type: 8
1063
- }
1064
- ],
1065
- path: [
1066
- "Result"
1067
- ]
1068
- }
1069
- },
1070
- {
1071
- id: 19,
1072
- type: {
1073
- def: {
1074
- variant: {
1075
- variants: [
1076
- {
1077
- fields: [
1078
- {
1079
- type: 0
1080
- }
1081
- ],
1082
- index: 0,
1083
- name: "Ok"
1084
- },
1085
- {
1086
- fields: [
1087
- {
1088
- type: 11
1089
- }
1090
- ],
1091
- index: 1,
1092
- name: "Err"
1093
- }
1094
- ]
1095
- }
1096
- },
1097
- params: [
1098
- {
1099
- name: "T",
1100
- type: 0
1101
- },
1102
- {
1103
- name: "E",
1104
- type: 11
1105
- }
1106
- ],
1107
- path: [
1108
- "Result"
1109
- ]
1110
- }
1111
- },
1112
- {
1113
- id: 20,
1114
- type: {
1115
- def: {
1116
- variant: {
1117
- variants: [
1118
- {
1119
- index: 0,
1120
- name: "None"
1121
- },
1122
- {
1123
- fields: [
1124
- {
1125
- type: 5
1126
- }
1127
- ],
1128
- index: 1,
1129
- name: "Some"
1130
- }
1131
- ]
1132
- }
1133
- },
1134
- params: [
1135
- {
1136
- name: "T",
1137
- type: 5
1138
- }
1139
- ],
1140
- path: [
1141
- "Option"
1142
- ]
1143
- }
1144
- },
1145
- {
1146
- id: 21,
1147
- type: {
1148
- def: {
1149
- variant: {
1150
- variants: [
1151
- {
1152
- fields: [
1153
- {
1154
- type: 22
1155
- }
1156
- ],
1157
- index: 0,
1158
- name: "Ok"
1159
- },
1160
- {
1161
- fields: [
1162
- {
1163
- type: 8
1164
- }
1165
- ],
1166
- index: 1,
1167
- name: "Err"
1168
- }
1169
- ]
1170
- }
1171
- },
1172
- params: [
1173
- {
1174
- name: "T",
1175
- type: 22
1176
- },
1177
- {
1178
- name: "E",
1179
- type: 8
1180
- }
1181
- ],
1182
- path: [
1183
- "Result"
1184
- ]
1185
- }
1186
- },
1187
- {
1188
- id: 22,
1189
- type: {
1190
- def: {
1191
- sequence: {
1192
- type: 23
1193
- }
1194
- }
1195
- }
1196
- },
1197
- {
1198
- id: 23,
1199
- type: {
1200
- def: {
1201
- tuple: [
1202
- 0,
1203
- 5
1204
- ]
1205
- }
1206
- }
1207
- },
1208
- {
1209
- id: 24,
1210
- type: {
1211
- def: {
1212
- variant: {
1213
- variants: [
1214
- {
1215
- fields: [
1216
- {
1217
- type: 0
1218
- }
1219
- ],
1220
- index: 0,
1221
- name: "Ok"
1222
- },
1223
- {
1224
- fields: [
1225
- {
1226
- type: 8
1227
- }
1228
- ],
1229
- index: 1,
1230
- name: "Err"
1231
- }
1232
- ]
1233
- }
1234
- },
1235
- params: [
1236
- {
1237
- name: "T",
1238
- type: 0
1239
- },
1240
- {
1241
- name: "E",
1242
- type: 8
1243
- }
1244
- ],
1245
- path: [
1246
- "Result"
1247
- ]
1248
- }
1249
- },
1250
- {
1251
- id: 25,
1252
- type: {
1253
- def: {
1254
- primitive: "u128"
1255
- }
1256
- }
1257
- },
1258
- {
1259
- id: 26,
1260
- type: {
1261
- def: {
1262
- composite: {
1263
- fields: [
1264
- {
1265
- type: 1,
1266
- typeName: "[u8; 32]"
1267
- }
1268
- ]
1269
- }
1270
- },
1271
- path: [
1272
- "ink_primitives",
1273
- "types",
1274
- "Hash"
1275
- ]
1276
- }
1277
- },
1278
- {
1279
- id: 27,
1280
- type: {
1281
- def: {
1282
- primitive: "u64"
1283
- }
1284
- }
1285
- },
1286
- {
1287
- id: 28,
1288
- type: {
1289
- def: {
1290
- primitive: "u32"
1291
- }
1292
- }
1293
- },
1294
- {
1295
- id: 29,
1296
- type: {
1297
- def: {
1298
- variant: {
1299
- }
1300
- },
1301
- path: [
1302
- "ink_env",
1303
- "types",
1304
- "NoChainExtension"
1305
- ]
1306
- }
1307
- }
1308
- ],
1309
- version: "4"
1310
- };
1311
-
1312
- const ROUTER_ABI = new apiContract.Abi(aznsRouterAbiJson);
1313
- const ROUTER_ADDRESS = {
1314
- "alephzero": "5FfRtDtpS3Vcr7BTChjPiQNrcAKu3VLv4E1NGF6ng6j3ZopJ",
1315
- "alephzero-testnet": "5HXjj3xhtRMqRYCRaXTDcVPz3Mez2XBruyujw6UEkvn8PCiA"
1316
- };
1317
- const readContract = async (provider, registry, from, contractAddress, data) => {
1318
- const rawResult = await provider.send("state_call", ["ContractsApi_call", util.u8aToHex(util.u8aConcatStrict([
1319
- // origin
1320
- registry.createType("AccountId", from).toU8a(),
1321
- // dest
1322
- registry.createType("AccountId", contractAddress).toU8a(),
1323
- // value
1324
- registry.createType("Balance", 0).toU8a(),
1325
- // gasLimit
1326
- registry.createType("Option<WeightV2>").toU8a(),
1327
- // storageDepositLimit
1328
- registry.createType("Option<Balance>").toU8a(),
1329
- // inputData
1330
- data]))]);
1331
- return registry.createType("ContractExecResult", rawResult);
1332
- };
1333
- const resolveDomainToAddress = async (domain, {
1334
- provider,
1335
- registry,
1336
- chainId
1337
- }) => {
1338
- try {
1339
- const routerAddress = ROUTER_ADDRESS[chainId];
1340
- if (!routerAddress) throw new Error(`No azns router address found for chainId: ${chainId}`);
1341
- const message = ROUTER_ABI.findMessage("get_address");
1342
- if (!message) throw new Error(`No get_address message found in aznsRouter abi`);
1343
- const {
1344
- result
1345
- } = await readContract(provider, registry, routerAddress, routerAddress, message.toU8a([domain]));
1346
- if (!result.isOk) throw result.asErr;
1347
- const resultType = message.returnType.lookupName ?? message.returnType.type;
1348
- const returnValue = registry.createTypeUnsafe(resultType, [result.asOk.data.toU8a(true)], {
1349
- isPedantic: true
1350
- });
1351
- if (!returnValue.isOk) throw returnValue.asErr;
1352
- if (!returnValue.asOk.isOk) throw returnValue.asOk.asErr;
1353
- return returnValue.asOk.asOk.toString();
1354
- } catch (cause) {
1355
- throw new Error(`Failed to resolve azns domain ${domain} on ${chainId}`, {
1356
- cause
1357
- });
1358
- }
1359
- };
1360
- const resolveAddressToDomain = async (address, {
1361
- provider,
1362
- registry,
1363
- chainId
1364
- }) => {
1365
- try {
1366
- const routerAddress = ROUTER_ADDRESS[chainId];
1367
- if (!routerAddress) throw new Error(`No azns router address found for chainId: ${chainId}`);
1368
- const message = ROUTER_ABI.findMessage("get_primary_domains");
1369
- if (!message) throw new Error(`No get_address get_primary_domains found in aznsRouter abi`);
1370
- const {
1371
- result
1372
- } = await readContract(provider, registry, routerAddress, routerAddress, message.toU8a([address, undefined]));
1373
- if (!result.isOk) throw result.asErr;
1374
- const resultType = message.returnType.lookupName ?? message.returnType.type;
1375
- const returnValue = registry.createTypeUnsafe(resultType, [result.asOk.data.toU8a(true)], {
1376
- isPedantic: true
1377
- });
1378
- if (!returnValue.isOk) throw returnValue.asErr;
1379
- return returnValue.asOk[0]?.[1]?.toString() ?? null;
1380
- } catch (cause) {
1381
- throw new Error(`Failed to lookup azns domain for ${address} on ${chainId}`, {
1382
- cause
1383
- });
1384
- }
1385
- };
1386
-
1387
16
  /**
1388
17
  * Looks up the on-chain identifiers for some addresses.
1389
- * Supports ENS and AZNS.
18
+ * Supports ENS.
1390
19
  */
1391
20
  const lookupAddresses = async (config, addresses) => {
1392
21
  const onChainIds = new Map(addresses.map(address => [address, null]));
1393
- const [aznsDomains, ensDomains] = await Promise.all([lookupAznsAddresses(config, addresses), lookupEnsAddresses(config, addresses)]);
1394
- aznsDomains.forEach((domain, address) => {
1395
- if (!domain) return;
1396
- onChainIds.set(address, domain);
1397
- });
22
+ const [ensDomains] = await Promise.all([lookupEnsAddresses(config, addresses)
23
+ // add more providers here
24
+ ]);
1398
25
  ensDomains.forEach((domain, address) => {
1399
26
  if (!domain) return;
1400
27
  onChainIds.set(address, domain);
@@ -1404,25 +31,10 @@ const lookupAddresses = async (config, addresses) => {
1404
31
 
1405
32
  /**
1406
33
  * Looks up the on-chain AZNS domains for some addresses.
34
+ * @deprecated
1407
35
  */
1408
36
  const lookupAznsAddresses = async (config, addresses) => {
1409
- const onChainIds = new Map(addresses.map(address => [address, null]));
1410
- if (!config.chainConnectors.substrate) {
1411
- log.warn(`Could not find Substrate chainConnector in OnChainId::lookupAznsAddresses`);
1412
- return onChainIds;
1413
- }
1414
- const provider = config.chainConnectors.substrate.asProvider(config.chainIdAlephZero);
1415
- const results = await Promise.allSettled(addresses.map(async address => {
1416
- if (!crypto.isSs58Address(address)) return;
1417
- const domain = await resolveAddressToDomain(address, {
1418
- chainId: config.aznsSupportedChainIdAlephZero,
1419
- registry: config.registryAlephZero,
1420
- provider
1421
- });
1422
- if (domain) onChainIds.set(address, domain);
1423
- }));
1424
- results.forEach(result => result.status === "rejected" && log.warn(result.reason));
1425
- return onChainIds;
37
+ return new Promise(resolve => resolve(new Map(addresses.map(address => [address, null]))));
1426
38
  };
1427
39
 
1428
40
  /**
@@ -1452,21 +64,14 @@ const lookupEnsAddresses = async (config, addresses) => {
1452
64
  return onChainIds;
1453
65
  };
1454
66
 
1455
- /** dot separated string with `azero` or `tzero` suffix e.g. `fontbois.tzero` or `talisman.tzero` */
1456
- const isPotentialAzns = name => typeof name === "string" && /^.+\.(([ta]zero)|(a0))$/.test(name);
1457
-
1458
- /** dot separated string e.g. `ens.eth` or `hello.lol`, but not ending with `.azero` nor `.tzero` */
1459
- const isPotentialEns = name => typeof name === "string" && /^.+\..+$/.test(name) && !isPotentialAzns(name);
67
+ /** dot separated string e.g. `ens.eth` or `hello.lol` */
68
+ const isPotentialEns = name => typeof name === "string" && /^.+\..+$/.test(name);
1460
69
 
1461
70
  const resolveNames = async (config, names) => {
1462
71
  const resolvedNames = new Map(names.map(name => [name, null]));
1463
- const [aznsNames, ensNames] = await Promise.all([resolveAznsNames(config, names), resolveEnsNames(config, names)]);
1464
- aznsNames.forEach((lookup, name) => {
1465
- if (!lookup) return;
1466
- const [address, lookupType] = lookup;
1467
- if (!address) return;
1468
- resolvedNames.set(name, [address, lookupType]);
1469
- });
72
+ const [ensNames] = await Promise.all([resolveEnsNames(config, names)
73
+ // add more providers here
74
+ ]);
1470
75
  ensNames.forEach((lookup, name) => {
1471
76
  if (!lookup) return;
1472
77
  const [address, lookupType] = lookup;
@@ -1478,26 +83,10 @@ const resolveNames = async (config, names) => {
1478
83
 
1479
84
  /**
1480
85
  * Looks up the addresses for some azns (azero.id) domains.
86
+ * @deprecated
1481
87
  */
1482
- const resolveAznsNames = async (config, names) => {
1483
- const resolvedNames = new Map(names.map(name => [name, null]));
1484
- if (names.every(name => !isPotentialAzns(name))) return resolvedNames;
1485
- if (!config.chainConnectors.substrate) {
1486
- log.warn(`Could not find Substrate chainConnector in OnChainId::resolveAznsNames`);
1487
- return resolvedNames;
1488
- }
1489
- const provider = config.chainConnectors.substrate.asProvider(config.chainIdAlephZero);
1490
- const results = await Promise.allSettled(names.map(async name => {
1491
- if (!isPotentialAzns(name)) return;
1492
- const address = await resolveDomainToAddress(name, {
1493
- chainId: config.aznsSupportedChainIdAlephZero,
1494
- registry: config.registryAlephZero,
1495
- provider
1496
- });
1497
- if (address) resolvedNames.set(name, [address, "azns"]);
1498
- }));
1499
- results.forEach(result => result.status === "rejected" && log.warn(result.reason));
1500
- return resolvedNames;
88
+ const resolveAznsNames = (config, names) => {
89
+ return new Promise(resolve => resolve(new Map(names.map(name => [name, null]))));
1501
90
  };
1502
91
 
1503
92
  /**
@@ -1518,7 +107,7 @@ const resolveEnsNames = async (config, names) => {
1518
107
  // this hangs forever in some cases (ex: try agyle.e first, then agyle.et => hangs) - couldn't explain it
1519
108
  client.getEnsAddress({
1520
109
  name
1521
- }), util$1.throwAfter(10_000, "Timeout")]);
110
+ }), util.throwAfter(10_000, "Timeout")]);
1522
111
  address !== null && resolvedNames.set(name, [address, "ens"]);
1523
112
  } catch (cause) {
1524
113
  throw new Error(`Failed to resolve address for ens domain '${name}'`, {
@@ -1530,22 +119,26 @@ const resolveEnsNames = async (config, names) => {
1530
119
  return resolvedNames;
1531
120
  };
1532
121
 
122
+ /** @deprecated */
123
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
124
+ const isPotentialAzns = name => false;
125
+
1533
126
  class OnChainId {
1534
127
  #config;
1535
128
  constructor(config) {
1536
129
  this.#config = {
1537
130
  ...config,
1538
- chainIdAlephZero: config.chainIdAlephZero ?? "aleph-zero",
1539
- aznsSupportedChainIdAlephZero: config.aznsSupportedChainIdAlephZero ?? "alephzero",
1540
131
  networkIdEthereum: config.networkIdEthereum ?? "1"
1541
132
  };
1542
133
  }
1543
134
  resolveNames = (...args) => resolveNames(this.#config, ...args);
1544
135
  resolveEnsNames = (...args) => resolveEnsNames(this.#config, ...args);
136
+ /** @deprecated */
1545
137
  resolveAznsNames = (...args) => resolveAznsNames(this.#config, ...args);
1546
138
  lookupAddresses = (...args) => lookupAddresses(this.#config, ...args);
1547
- lookupAznsAddresses = (...args) => lookupAznsAddresses(this.#config, ...args);
139
+ /** @deprecated */
1548
140
  lookupEnsAddresses = (...args) => lookupEnsAddresses(this.#config, ...args);
141
+ lookupAznsAddresses = (...args) => lookupAznsAddresses(this.#config, ...args);
1549
142
  }
1550
143
 
1551
144
  exports.OnChainId = OnChainId;