@talismn/on-chain-id 0.0.0-pr1673-20241022081611 → 0.0.0-pr1674-20241023064453

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