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