@beclab/olaresid 0.1.13 → 0.2.1

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.
Files changed (182) hide show
  1. package/CLI-TREE.md +107 -0
  2. package/CLI.md +122 -1340
  3. package/README.md +30 -12
  4. package/SDK-TREE.md +151 -0
  5. package/TAG.md +95 -41
  6. package/config.json +6 -4
  7. package/dist/abi/TerminusDIDQueryABI.d.ts +397 -0
  8. package/dist/abi/TerminusDIDQueryABI.d.ts.map +1 -0
  9. package/dist/abi/TerminusDIDQueryABI.js +519 -0
  10. package/dist/abi/TerminusDIDQueryABI.js.map +1 -0
  11. package/dist/business/index.d.ts.map +1 -1
  12. package/dist/business/index.js +9 -23
  13. package/dist/business/index.js.map +1 -1
  14. package/dist/business/tag-context.d.ts +1 -0
  15. package/dist/business/tag-context.d.ts.map +1 -1
  16. package/dist/business/tag-context.js +13 -7
  17. package/dist/business/tag-context.js.map +1 -1
  18. package/dist/cli.js +177 -76
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config/index.d.ts +16 -4
  21. package/dist/config/index.d.ts.map +1 -1
  22. package/dist/config/index.js +28 -14
  23. package/dist/config/index.js.map +1 -1
  24. package/dist/domain/core.d.ts +65 -0
  25. package/dist/domain/core.d.ts.map +1 -0
  26. package/dist/domain/core.js +317 -0
  27. package/dist/domain/core.js.map +1 -0
  28. package/dist/domain/index.d.ts +104 -57
  29. package/dist/domain/index.d.ts.map +1 -1
  30. package/dist/domain/index.js +188 -428
  31. package/dist/domain/index.js.map +1 -1
  32. package/dist/domain/types.d.ts +56 -0
  33. package/dist/domain/types.d.ts.map +1 -0
  34. package/dist/domain/types.js +3 -0
  35. package/dist/domain/types.js.map +1 -0
  36. package/dist/index.d.ts +81 -23
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +158 -143
  39. package/dist/index.js.map +1 -1
  40. package/dist/utils/crypto-utils.d.ts +110 -0
  41. package/dist/utils/crypto-utils.d.ts.map +1 -1
  42. package/dist/utils/crypto-utils.js +127 -8
  43. package/dist/utils/crypto-utils.js.map +1 -1
  44. package/dist/utils/error-parser.d.ts.map +1 -1
  45. package/dist/utils/error-parser.js +2 -1
  46. package/dist/utils/error-parser.js.map +1 -1
  47. package/dist/utils/event-parser.d.ts +161 -0
  48. package/dist/utils/event-parser.d.ts.map +1 -0
  49. package/dist/utils/event-parser.js +140 -0
  50. package/dist/utils/event-parser.js.map +1 -0
  51. package/dist/utils/tag-type-builder.d.ts +43 -0
  52. package/dist/utils/tag-type-builder.d.ts.map +1 -1
  53. package/dist/utils/tag-type-builder.js +122 -0
  54. package/dist/utils/tag-type-builder.js.map +1 -1
  55. package/dist/utils/tag-type-parser.d.ts +70 -0
  56. package/dist/utils/tag-type-parser.d.ts.map +1 -0
  57. package/dist/utils/tag-type-parser.js +190 -0
  58. package/dist/utils/tag-type-parser.js.map +1 -0
  59. package/examples/create-with-rpc-demo.ts +142 -0
  60. package/examples/fetch-all-flat-demo.ts +159 -0
  61. package/examples/fetch-by-indices-demo.ts +235 -0
  62. package/examples/fetch-domain-demo.ts +137 -0
  63. package/examples/fetch-domains-demo.ts +221 -0
  64. package/examples/frontend-demo/index.html +2 -2
  65. package/examples/frontend-demo/package-lock.json +4 -1
  66. package/examples/index.ts +3 -5
  67. package/jest.config.js +25 -0
  68. package/package.json +6 -2
  69. package/src/abi/TerminusDIDQueryABI.ts +516 -0
  70. package/src/business/index.ts +9 -33
  71. package/src/business/tag-context.ts +35 -7
  72. package/src/cli.ts +253 -90
  73. package/src/config/index.ts +34 -19
  74. package/src/domain/core.ts +382 -0
  75. package/src/domain/index.ts +271 -641
  76. package/src/domain/types.ts +59 -0
  77. package/src/index.ts +230 -207
  78. package/src/utils/crypto-utils.ts +205 -2
  79. package/src/utils/error-parser.ts +2 -1
  80. package/src/utils/event-parser.ts +353 -0
  81. package/src/utils/tag-type-builder.ts +138 -0
  82. package/src/utils/tag-type-parser.ts +246 -0
  83. package/tests/unit/crypto-utils.test.ts +338 -0
  84. package/tests/unit/ed25519-jwk.test.ts +201 -0
  85. package/tests/unit/event-parser.test.ts +690 -0
  86. package/tests/unit/generate-mnemonic.test.ts +268 -0
  87. package/tests/unit/olares-id-format.test.ts +321 -0
  88. package/tests/unit/tag-type-parser.test.ts +802 -0
  89. package/tests/unit/tag-types.test.ts +821 -0
  90. package/tests/unit/version.test.ts +14 -0
  91. package/tsconfig.json +3 -2
  92. package/dist/abi/ABITypeABI.d.ts +0 -88
  93. package/dist/abi/ABITypeABI.d.ts.map +0 -1
  94. package/dist/abi/ABITypeABI.js +0 -382
  95. package/dist/abi/ABITypeABI.js.map +0 -1
  96. package/dist/abi/RegistryABI.d.ts +0 -77
  97. package/dist/abi/RegistryABI.d.ts.map +0 -1
  98. package/dist/abi/RegistryABI.js +0 -462
  99. package/dist/abi/RegistryABI.js.map +0 -1
  100. package/dist/tag/address.d.ts +0 -11
  101. package/dist/tag/address.d.ts.map +0 -1
  102. package/dist/tag/address.js +0 -44
  103. package/dist/tag/address.js.map +0 -1
  104. package/dist/tag/array.d.ts +0 -14
  105. package/dist/tag/array.d.ts.map +0 -1
  106. package/dist/tag/array.js +0 -72
  107. package/dist/tag/array.js.map +0 -1
  108. package/dist/tag/bool.d.ts +0 -11
  109. package/dist/tag/bool.d.ts.map +0 -1
  110. package/dist/tag/bool.js +0 -43
  111. package/dist/tag/bool.js.map +0 -1
  112. package/dist/tag/bytes.d.ts +0 -11
  113. package/dist/tag/bytes.d.ts.map +0 -1
  114. package/dist/tag/bytes.js +0 -37
  115. package/dist/tag/bytes.js.map +0 -1
  116. package/dist/tag/flarray.d.ts +0 -15
  117. package/dist/tag/flarray.d.ts.map +0 -1
  118. package/dist/tag/flarray.js +0 -81
  119. package/dist/tag/flarray.js.map +0 -1
  120. package/dist/tag/flbytes.d.ts +0 -11
  121. package/dist/tag/flbytes.d.ts.map +0 -1
  122. package/dist/tag/flbytes.js +0 -47
  123. package/dist/tag/flbytes.js.map +0 -1
  124. package/dist/tag/index.d.ts +0 -32
  125. package/dist/tag/index.d.ts.map +0 -1
  126. package/dist/tag/index.js +0 -121
  127. package/dist/tag/index.js.map +0 -1
  128. package/dist/tag/int.d.ts +0 -12
  129. package/dist/tag/int.d.ts.map +0 -1
  130. package/dist/tag/int.js +0 -49
  131. package/dist/tag/int.js.map +0 -1
  132. package/dist/tag/string.d.ts +0 -11
  133. package/dist/tag/string.d.ts.map +0 -1
  134. package/dist/tag/string.js +0 -37
  135. package/dist/tag/string.js.map +0 -1
  136. package/dist/tag/tag.d.ts +0 -67
  137. package/dist/tag/tag.d.ts.map +0 -1
  138. package/dist/tag/tag.js +0 -157
  139. package/dist/tag/tag.js.map +0 -1
  140. package/dist/tag/tuple.d.ts +0 -17
  141. package/dist/tag/tuple.d.ts.map +0 -1
  142. package/dist/tag/tuple.js +0 -162
  143. package/dist/tag/tuple.js.map +0 -1
  144. package/dist/tag/uint.d.ts +0 -12
  145. package/dist/tag/uint.d.ts.map +0 -1
  146. package/dist/tag/uint.js +0 -49
  147. package/dist/tag/uint.js.map +0 -1
  148. package/dist/test/did.d.ts +0 -2
  149. package/dist/test/did.d.ts.map +0 -1
  150. package/dist/test/did.js +0 -177
  151. package/dist/test/did.js.map +0 -1
  152. package/dist/utils/tag-abi-codec.d.ts +0 -69
  153. package/dist/utils/tag-abi-codec.d.ts.map +0 -1
  154. package/dist/utils/tag-abi-codec.js +0 -144
  155. package/dist/utils/tag-abi-codec.js.map +0 -1
  156. package/examples/crypto-utilities.ts +0 -140
  157. package/examples/ed25519-jwk.ts +0 -73
  158. package/examples/generate-mnemonic.ts +0 -149
  159. package/examples/legacy.ts +0 -33
  160. package/examples/olares-id-format.ts +0 -197
  161. package/examples/tag-builder.ts +0 -235
  162. package/examples/tag-nested-tuple.ts +0 -190
  163. package/examples/tag-simple.ts +0 -149
  164. package/examples/tag-tagger.ts +0 -217
  165. package/examples/test-nested-tuple-conversion.ts +0 -143
  166. package/examples/test-type-bytes-parser.ts +0 -70
  167. package/src/abi/ABITypeABI.ts +0 -379
  168. package/src/abi/RegistryABI.ts +0 -459
  169. package/src/tag/address.ts +0 -48
  170. package/src/tag/array.ts +0 -80
  171. package/src/tag/bool.ts +0 -43
  172. package/src/tag/bytes.ts +0 -38
  173. package/src/tag/flarray.ts +0 -99
  174. package/src/tag/flbytes.ts +0 -48
  175. package/src/tag/index.ts +0 -170
  176. package/src/tag/int.ts +0 -51
  177. package/src/tag/string.ts +0 -38
  178. package/src/tag/tag.ts +0 -229
  179. package/src/tag/tuple.ts +0 -193
  180. package/src/tag/uint.ts +0 -51
  181. package/src/test/did.ts +0 -346
  182. package/src/utils/tag-abi-codec.ts +0 -158
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Tag data structure
3
+ */
4
+ export interface Tag {
5
+ from: string;
6
+ name: string;
7
+ abiType: string; // ABI type string (e.g., "tuple(string,uint8)")
8
+ value: string; // bytes (hex string) - raw encoded value
9
+ fieldNamesHash: string[]; // bytes32[] (hex strings)
10
+ valueFormatted?: string | null; // Decoded value; objects/arrays are JSON.stringify'd; null if tag has no value
11
+ }
12
+
13
+ /**
14
+ * Flattened domain data structure
15
+ */
16
+ export interface FlatDomainData {
17
+ id: string; // tokenId (hex)
18
+ name: string;
19
+ did: string;
20
+ note: string;
21
+ allowSubdomain: boolean;
22
+ owner: string;
23
+ parentId?: string; // ⭐ New: parent domain ID
24
+ level: number; // ⭐ New: level (1=top-level, 2=second-level...)
25
+ tags: Tag[];
26
+ }
27
+
28
+ /**
29
+ * Raw domain data returned by contract
30
+ */
31
+ export interface RawDomainData {
32
+ tokenId: bigint;
33
+ domain: string;
34
+ did: string;
35
+ notes: string;
36
+ allowSubdomain: boolean;
37
+ owner: string;
38
+ tags: RawTagData[];
39
+ }
40
+
41
+ /**
42
+ * Raw Tag data returned by contract
43
+ */
44
+ export interface RawTagData {
45
+ from: string;
46
+ name: string;
47
+ abiType: string; // bytes (hex string)
48
+ value: string; // bytes (hex string)
49
+ fieldNamesHash: string[]; // bytes32[] (hex strings)
50
+ }
51
+
52
+ /**
53
+ * fetchAll options
54
+ */
55
+ export interface FetchAllOptions {
56
+ queryContractAddress?: string;
57
+ batchSize?: number; // Number of domains to fetch per batch, default 100
58
+ onProgress?: (current: number, total: number) => void;
59
+ }
package/src/index.ts CHANGED
@@ -1,21 +1,23 @@
1
- import { PackageDomain } from './domain/index';
2
- import DIDTag from './tag/index';
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
3
  import { ethers } from 'ethers';
4
4
  import DID_ABI from './abi/TerminusDIDABI';
5
5
  import RootResolverABI from './abi/RootResolverABI';
6
6
  import RootResolver2ABI from './abi/RootResolver2ABI';
7
- import { debug } from './debug';
8
7
  import { parseContractError } from './utils/error-parser';
9
- import { normalizeToDomain } from './utils/olares-id';
10
8
 
11
9
  import { DomainContext, TransactionResult } from './business';
12
10
 
13
- // Import Tag utilities
14
- import { TagTypeBuilder } from './utils/tag-type-builder';
15
- import { TagAbiCodec } from './utils/tag-abi-codec';
16
-
17
11
  // Import config utilities
18
- import { getNetworkConfig, getAvailableNetworks } from './config';
12
+ import { getNetworkConfig } from './config';
13
+
14
+ // Import domain functions
15
+ import {
16
+ fetchDomain,
17
+ fetchDomains,
18
+ fetchDomainsByIndices,
19
+ fetchAllFlat
20
+ } from './domain/index';
19
21
 
20
22
  export type {
21
23
  DomainInfo,
@@ -45,23 +47,17 @@ export {
45
47
  getEd25519JwkFromMnemonic
46
48
  } from './business';
47
49
 
48
- type Domain = PackageDomain.Domain;
49
-
50
- type StoreDomain = PackageDomain.DomainData;
51
-
52
- export class DIDConsole implements DIDTag.ABITypeProviderHolder {
50
+ export class DIDConsole {
53
51
  rpcNode: string;
54
52
  contractDid: string;
55
53
  contractRootResolver: string;
56
54
  contractAbiType: string;
57
55
  contractRootResolver2?: string;
58
56
  supportSvcUrl?: string;
57
+ queryContractAddress?: string; // New: query contract address
59
58
 
60
59
  signer?: ethers.Signer;
61
60
 
62
- allDomainCache: Domain[] = [];
63
- treesCache: Domain[] = [];
64
-
65
61
  // caching contract instances
66
62
  private _contractDID?: ethers.Contract;
67
63
  private _signerContractDID?: ethers.Contract;
@@ -78,7 +74,8 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
78
74
  contractRootResolver: string,
79
75
  contractAbiType: string,
80
76
  contractRootResolver2?: string,
81
- supportSvcUrl?: string
77
+ supportSvcUrl?: string,
78
+ queryContractAddress?: string
82
79
  ) {
83
80
  this.rpcNode = rpcNode;
84
81
  this.contractDid = contractDid;
@@ -86,6 +83,7 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
86
83
  this.contractAbiType = contractAbiType;
87
84
  this.contractRootResolver2 = contractRootResolver2;
88
85
  this.supportSvcUrl = supportSvcUrl;
86
+ this.queryContractAddress = queryContractAddress;
89
87
  }
90
88
 
91
89
  getProvider = (): ethers.JsonRpcProvider => {
@@ -247,193 +245,98 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
247
245
  await provider.getSigner()
248
246
  );
249
247
 
250
- fetchAll = () =>
251
- new Promise<Domain[]>(async (resolve, reject) => {
252
- debug.group('fetchAll');
253
- const contract = await this.getContractDID();
254
- const size = await contract.totalSupply();
255
- debug.info('fetchAll--->domain size', size);
256
-
257
- let arr: Domain[] = [];
258
- for (let index = 0; index < size; index++) {
259
- const domain = await PackageDomain.syncByIndex(index, contract);
260
- debug.debug('fetchAll--->synced domain', domain);
261
- debug.info(
262
- `fetchAll--->${((index / parseInt(size)) * 100).toFixed(
263
- 0
264
- )}%`
265
- );
266
- arr.push(domain);
267
- }
268
- this.allDomainCache = arr;
269
- this.treesCache = PackageDomain.buildTree(this.allDomainCache);
270
-
271
- debug.groupEnd();
272
- resolve(this.treesCache);
273
- });
274
-
275
- fetchDomain = (name: string) =>
276
- new Promise<Domain | undefined>(async (resolve, reject) => {
277
- // Support Olares ID format (user@domain.com)
278
- const normalizedName = normalizeToDomain(name);
279
-
280
- debug.group('fetchDomain');
281
- const hasCache = this.allDomainCache.length > 0;
282
- debug.info('fetchDomain--->hasCache', hasCache);
283
-
284
- if (hasCache) {
285
- const domain = PackageDomain.findASubtree(
286
- normalizedName,
287
- this.allDomainCache
288
- );
289
-
290
- debug.groupEnd();
291
- resolve(domain);
292
- } else {
293
- const domain = await PackageDomain.syncByName(
294
- normalizedName,
295
- await this.getContractDID()
296
- );
297
-
298
- debug.groupEnd();
299
- resolve(domain);
300
- }
301
- });
302
-
303
- updateDomain = (name: string) =>
304
- new Promise<Domain>(async (resolve, reject) => {
305
- // Support Olares ID format (user@domain.com)
306
- const normalizedName = normalizeToDomain(name);
307
-
308
- const domain = await PackageDomain.syncByName(
309
- normalizedName,
310
- await this.getContractDID()
311
- );
312
-
313
- if (domain == undefined) {
314
- reject('not found domain');
315
- return;
316
- }
317
-
318
- const [oldDomain] = this.allDomainCache.filter(
319
- (d) => d.name == domain.name
320
- );
321
-
322
- if (oldDomain != undefined) {
323
- for (const tagNew of domain.tags) {
324
- for (const tagOld of oldDomain.tags) {
325
- if (tagNew.name == tagOld.name) {
326
- if (
327
- tagNew.valueFormated == undefined &&
328
- tagOld.valueFormated != undefined
329
- ) {
330
- tagNew.valueFormated = tagOld.valueFormated;
331
- }
332
- if (
333
- tagNew.valueSource == undefined &&
334
- tagOld.valueSource != undefined
335
- ) {
336
- tagNew.valueSource = tagOld.valueSource;
337
- }
338
- if (
339
- tagNew.definition == undefined &&
340
- tagOld.definition != undefined
341
- ) {
342
- tagNew.definition = tagOld.definition;
343
- }
344
- }
345
- }
346
- }
347
- }
348
-
349
- this.allDomainCache = this.allDomainCache.filter(
350
- (d) => d.name != domain.name
248
+ /**
249
+ * Fetch a single domain by name or tokenId
250
+ * Uses the query contract configured for this network
251
+ *
252
+ * @param nameOrTokenId - Domain name or tokenId
253
+ * @returns Domain data or null if not found
254
+ *
255
+ * @example
256
+ * const domain = await console.fetchDomain("alice.olares.com");
257
+ */
258
+ async fetchDomain(nameOrTokenId: string | bigint) {
259
+ if (!this.queryContractAddress) {
260
+ throw new Error(
261
+ 'Query contract address not configured for this network'
351
262
  );
352
- this.allDomainCache.push(domain);
353
-
354
- this.treesCache = PackageDomain.buildTree(this.allDomainCache);
355
-
356
- resolve(domain);
263
+ }
264
+ return fetchDomain(this, nameOrTokenId, {
265
+ queryContractAddress: this.queryContractAddress
357
266
  });
267
+ }
358
268
 
359
- updateDomainById = (id: string) =>
360
- new Promise<Domain>(async (resolve, reject) => {
361
- const domain = await PackageDomain.syncById(
362
- id,
363
- await this.getContractDID()
364
- );
365
-
366
- if (domain == undefined) {
367
- reject('not found domain');
368
- return;
369
- }
370
-
371
- const [oldDomain] = this.allDomainCache.filter(
372
- (d) => d.name == domain.name
373
- );
374
- for (const tagNew of domain.tags) {
375
- for (const tagOld of oldDomain.tags) {
376
- if (tagNew.name == tagOld.name) {
377
- if (
378
- tagNew.valueFormated == undefined &&
379
- tagOld.valueFormated != undefined
380
- ) {
381
- tagNew.valueFormated = tagOld.valueFormated;
382
- }
383
- if (
384
- tagNew.valueSource == undefined &&
385
- tagOld.valueSource != undefined
386
- ) {
387
- tagNew.valueSource = tagOld.valueSource;
388
- }
389
- if (
390
- tagNew.definition == undefined &&
391
- tagOld.definition != undefined
392
- ) {
393
- tagNew.definition = tagOld.definition;
394
- }
395
- }
396
- }
397
- }
398
-
399
- this.allDomainCache = this.allDomainCache.filter(
400
- (d) => d.name != domain.name
269
+ /**
270
+ * Fetch multiple domains with pagination
271
+ *
272
+ * @param offset - Starting index
273
+ * @param limit - Number of domains to fetch
274
+ * @returns Array of domains in the specified range
275
+ *
276
+ * @example
277
+ * const domains = await console.fetchDomains(0, 10);
278
+ */
279
+ async fetchDomains(offset: number, limit: number) {
280
+ if (!this.queryContractAddress) {
281
+ throw new Error(
282
+ 'Query contract address not configured for this network'
401
283
  );
402
- this.allDomainCache.push(domain);
403
-
404
- this.treesCache = PackageDomain.buildTree(this.allDomainCache);
405
-
406
- resolve(domain);
407
- });
408
-
409
- formatData = (doamin: Domain) =>
410
- new Promise<StoreDomain>((resolve, reject) => {
411
- resolve(doamin);
412
- });
413
-
414
- formatDatas = (doamins: Domain[]) =>
415
- new Promise<StoreDomain[]>((resolve, reject) => {
416
- resolve(doamins);
284
+ }
285
+ return fetchDomains(this, {
286
+ offset,
287
+ limit,
288
+ queryContractAddress: this.queryContractAddress
417
289
  });
290
+ }
418
291
 
419
- loadData = (data: StoreDomain) =>
420
- new Promise<Domain>((resolve, reject) => {
421
- resolve(data);
292
+ /**
293
+ * Fetch all domains with flat structure
294
+ *
295
+ * @param options - Additional options (batchSize, onProgress)
296
+ * @returns Array of all domains
297
+ *
298
+ * @example
299
+ * const domains = await console.fetchAllFlat({
300
+ * batchSize: 100,
301
+ * onProgress: (current, total) => console.log(`${current}/${total}`)
302
+ * });
303
+ */
304
+ async fetchAllFlat(
305
+ options: {
306
+ batchSize?: number;
307
+ onProgress?: (current: number, total: number) => void;
308
+ } = {}
309
+ ) {
310
+ if (!this.queryContractAddress) {
311
+ throw new Error(
312
+ 'Query contract address not configured for this network'
313
+ );
314
+ }
315
+ return fetchAllFlat(this, {
316
+ queryContractAddress: this.queryContractAddress,
317
+ ...options
422
318
  });
319
+ }
423
320
 
424
- loadDatas = (datas: StoreDomain[]) =>
425
- new Promise<Domain[]>((resolve, reject) => {
426
- this.treesCache = datas;
427
- let arr = [];
428
- arr.push(...this.treesCache);
429
- for (const StoreDomain of this.treesCache) {
430
- arr.push(...PackageDomain.getAllSubdoamin(StoreDomain));
431
- }
432
-
433
- this.allDomainCache = arr;
434
-
435
- resolve(datas);
321
+ /**
322
+ * Fetch multiple domains by their indices
323
+ *
324
+ * @param indices - Array of domain indices (e.g., [5, 6, 9, 10])
325
+ * @returns Array of domains corresponding to the specified indices
326
+ *
327
+ * @example
328
+ * const domains = await console.fetchDomainsByIndices([5, 6, 9, 10]);
329
+ */
330
+ async fetchDomainsByIndices(indices: number[]) {
331
+ if (!this.queryContractAddress) {
332
+ throw new Error(
333
+ 'Query contract address not configured for this network'
334
+ );
335
+ }
336
+ return fetchDomainsByIndices(this, indices, {
337
+ queryContractAddress: this.queryContractAddress
436
338
  });
339
+ }
437
340
 
438
341
  /**
439
342
  * Uses a chain-style operation design pattern, returning the operation context for the specified domain
@@ -590,13 +493,21 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
590
493
  }
591
494
 
592
495
  namespace OlaresID {
496
+ export const version = (): string => {
497
+ const packageJson = JSON.parse(
498
+ fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8')
499
+ );
500
+ return packageJson.version;
501
+ };
502
+
593
503
  export const createConsole = (
594
504
  rpcNode: string,
595
505
  contractDid: string,
596
506
  contractRootResolver: string,
597
507
  contractAbiType: string,
598
508
  contractRootResolver2?: string,
599
- supportSvcUrl?: string
509
+ supportSvcUrl?: string,
510
+ queryContractAddress?: string
600
511
  ): DIDConsole => {
601
512
  return new DIDConsole(
602
513
  rpcNode,
@@ -604,14 +515,15 @@ namespace OlaresID {
604
515
  contractRootResolver,
605
516
  contractAbiType,
606
517
  contractRootResolver2,
607
- supportSvcUrl
518
+ supportSvcUrl,
519
+ queryContractAddress
608
520
  );
609
521
  };
610
522
 
611
523
  export const createMainnet = (): DIDConsole => {
612
524
  const config = getNetworkConfig('mainnet');
613
525
  if (!config) {
614
- throw new Error('Mainnet configuration not found in config.json');
526
+ throw new Error('Mainnet configuration not found');
615
527
  }
616
528
 
617
529
  return createConsole(
@@ -620,14 +532,15 @@ namespace OlaresID {
620
532
  config.contractRootResolver,
621
533
  config.contractAbiType,
622
534
  config.contractRootResolver2,
623
- config.supportSvcUrl
535
+ config.supportSvcUrl,
536
+ config.queryContract
624
537
  );
625
538
  };
626
539
 
627
540
  export const createTestnet = (): DIDConsole => {
628
541
  const config = getNetworkConfig('sepolia');
629
542
  if (!config) {
630
- throw new Error('Sepolia configuration not found in config.json');
543
+ throw new Error('Sepolia configuration not found');
631
544
  }
632
545
 
633
546
  return createConsole(
@@ -636,15 +549,46 @@ namespace OlaresID {
636
549
  config.contractRootResolver,
637
550
  config.contractAbiType,
638
551
  config.contractRootResolver2,
639
- config.supportSvcUrl
552
+ config.supportSvcUrl,
553
+ config.queryContract
640
554
  );
641
555
  };
642
556
 
643
- export import Domain = PackageDomain;
557
+ /**
558
+ * Create a DIDConsole instance with custom RPC endpoint
559
+ * Contract addresses are loaded from configuration based on network type
560
+ *
561
+ * @param rpc - Custom RPC endpoint URL
562
+ * @param network - Network type: 'mainnet' or 'sepolia' (default: 'mainnet')
563
+ * @returns DIDConsole instance
564
+ *
565
+ * @example
566
+ * // Create mainnet instance with custom RPC
567
+ * const console = OlaresID.createWithRpc('https://my-optimism-rpc.com');
568
+ *
569
+ * // Create sepolia instance with custom RPC
570
+ * const console = OlaresID.createWithRpc('https://my-sepolia-rpc.com', 'sepolia');
571
+ */
572
+ export const createWithRpc = (
573
+ rpc: string,
574
+ network: 'mainnet' | 'sepolia' = 'mainnet'
575
+ ): DIDConsole => {
576
+ const config = getNetworkConfig(network);
644
577
 
645
- export import Tag = DIDTag;
578
+ if (!config) {
579
+ throw new Error(`${network} configuration not found`);
580
+ }
646
581
 
647
- export type StoreDomain = PackageDomain.DomainData;
582
+ return createConsole(
583
+ rpc, // Use custom RPC
584
+ config.contractDid,
585
+ config.contractRootResolver,
586
+ config.contractAbiType,
587
+ config.contractRootResolver2,
588
+ config.supportSvcUrl,
589
+ config.queryContract
590
+ );
591
+ };
648
592
 
649
593
  export const ABI_DID = DID_ABI;
650
594
 
@@ -653,10 +597,89 @@ namespace OlaresID {
653
597
 
654
598
  export { debug } from './debug';
655
599
 
656
- // Export Tag utilities outside namespace
657
- export { TagTypeBuilder, TagAbiCodec };
600
+ // Export Tag utilities
601
+ export { TagTypeBuilder } from './utils/tag-type-builder';
602
+ export { TagTypeParser } from './utils/tag-type-parser';
658
603
 
659
604
  // Export Olares ID utilities
660
605
  export { normalizeToDomain, normalizeToOlaresId } from './utils/olares-id';
661
606
 
607
+ // Export event parser
608
+ export { parseEvents } from './utils/event-parser';
609
+ export type {
610
+ EthLog,
611
+ AnyParsedEvent,
612
+ ParsedEvent,
613
+ TerminusDIDEventName,
614
+ TerminusDIDEventArgsMap,
615
+ TransferArgs,
616
+ ApprovalArgs,
617
+ ApprovalForAllArgs,
618
+ InitializedArgs,
619
+ NewTagTypeArgs,
620
+ OffchainStringArrayArgs,
621
+ OwnershipTransferStartedArgs,
622
+ OwnershipTransferredArgs,
623
+ TagAddedArgs,
624
+ TagElemPoppedArgs,
625
+ TagElemPushedArgs,
626
+ TagElemUpdatedArgs,
627
+ TagRemovedArgs,
628
+ TransferByParentOwnerArgs,
629
+ TransferBySuperAdminArgs,
630
+ UpgradedArgs
631
+ } from './utils/event-parser';
632
+ export {
633
+ isTransferEvent,
634
+ isMintEvent,
635
+ isTagAddedEvent,
636
+ isTagRemovedEvent,
637
+ isTagElemUpdatedEvent,
638
+ isTagElemPushedEvent,
639
+ isTagElemPoppedEvent,
640
+ isNewTagTypeEvent
641
+ } from './utils/event-parser';
642
+
643
+ // Export new domain fetching functions and utilities
644
+ export { QueryContractHelper } from './domain/core';
645
+ export {
646
+ fetchDomain,
647
+ fetchDomains,
648
+ fetchDomainsByIndices,
649
+ fetchAllFlat,
650
+ FetchDomainOptions,
651
+ FetchDomainsOptions,
652
+ FetchDomainsByIndicesOptions
653
+ } from './domain/index';
654
+ export type {
655
+ Tag,
656
+ FlatDomainData,
657
+ RawDomainData,
658
+ RawTagData,
659
+ FetchAllOptions
660
+ } from './domain/types';
661
+
662
+ // Export config utilities
663
+ export { getContractConfig } from './config';
664
+ export type { ContractConfig } from './config';
665
+
666
+ // Export DID utilities
667
+ export type {
668
+ PublicJwk,
669
+ PrivateJwk,
670
+ VerificationMethod,
671
+ DIDDocument,
672
+ Service
673
+ } from './utils/crypto-utils';
674
+ export {
675
+ LDKeyType,
676
+ getPublicJWKFromX,
677
+ getPublicJWKFromDID,
678
+ getPrivateJWKFromD,
679
+ getIDFromEd25519Pubkey,
680
+ getPrivateJWKFromEd25519,
681
+ getFullyQualifiedVerificationMethodID,
682
+ resolveDID
683
+ } from './utils/crypto-utils';
684
+
662
685
  export default OlaresID;