@talismn/on-chain-id 0.0.0-pr1672-20241023050142 → 0.0.0-pr1672-20241023070444

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