@beclab/olaresid 0.1.13 → 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.
Files changed (181) 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 +80 -23
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +152 -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 +221 -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/tsconfig.json +3 -2
  91. package/dist/abi/ABITypeABI.d.ts +0 -88
  92. package/dist/abi/ABITypeABI.d.ts.map +0 -1
  93. package/dist/abi/ABITypeABI.js +0 -382
  94. package/dist/abi/ABITypeABI.js.map +0 -1
  95. package/dist/abi/RegistryABI.d.ts +0 -77
  96. package/dist/abi/RegistryABI.d.ts.map +0 -1
  97. package/dist/abi/RegistryABI.js +0 -462
  98. package/dist/abi/RegistryABI.js.map +0 -1
  99. package/dist/tag/address.d.ts +0 -11
  100. package/dist/tag/address.d.ts.map +0 -1
  101. package/dist/tag/address.js +0 -44
  102. package/dist/tag/address.js.map +0 -1
  103. package/dist/tag/array.d.ts +0 -14
  104. package/dist/tag/array.d.ts.map +0 -1
  105. package/dist/tag/array.js +0 -72
  106. package/dist/tag/array.js.map +0 -1
  107. package/dist/tag/bool.d.ts +0 -11
  108. package/dist/tag/bool.d.ts.map +0 -1
  109. package/dist/tag/bool.js +0 -43
  110. package/dist/tag/bool.js.map +0 -1
  111. package/dist/tag/bytes.d.ts +0 -11
  112. package/dist/tag/bytes.d.ts.map +0 -1
  113. package/dist/tag/bytes.js +0 -37
  114. package/dist/tag/bytes.js.map +0 -1
  115. package/dist/tag/flarray.d.ts +0 -15
  116. package/dist/tag/flarray.d.ts.map +0 -1
  117. package/dist/tag/flarray.js +0 -81
  118. package/dist/tag/flarray.js.map +0 -1
  119. package/dist/tag/flbytes.d.ts +0 -11
  120. package/dist/tag/flbytes.d.ts.map +0 -1
  121. package/dist/tag/flbytes.js +0 -47
  122. package/dist/tag/flbytes.js.map +0 -1
  123. package/dist/tag/index.d.ts +0 -32
  124. package/dist/tag/index.d.ts.map +0 -1
  125. package/dist/tag/index.js +0 -121
  126. package/dist/tag/index.js.map +0 -1
  127. package/dist/tag/int.d.ts +0 -12
  128. package/dist/tag/int.d.ts.map +0 -1
  129. package/dist/tag/int.js +0 -49
  130. package/dist/tag/int.js.map +0 -1
  131. package/dist/tag/string.d.ts +0 -11
  132. package/dist/tag/string.d.ts.map +0 -1
  133. package/dist/tag/string.js +0 -37
  134. package/dist/tag/string.js.map +0 -1
  135. package/dist/tag/tag.d.ts +0 -67
  136. package/dist/tag/tag.d.ts.map +0 -1
  137. package/dist/tag/tag.js +0 -157
  138. package/dist/tag/tag.js.map +0 -1
  139. package/dist/tag/tuple.d.ts +0 -17
  140. package/dist/tag/tuple.d.ts.map +0 -1
  141. package/dist/tag/tuple.js +0 -162
  142. package/dist/tag/tuple.js.map +0 -1
  143. package/dist/tag/uint.d.ts +0 -12
  144. package/dist/tag/uint.d.ts.map +0 -1
  145. package/dist/tag/uint.js +0 -49
  146. package/dist/tag/uint.js.map +0 -1
  147. package/dist/test/did.d.ts +0 -2
  148. package/dist/test/did.d.ts.map +0 -1
  149. package/dist/test/did.js +0 -177
  150. package/dist/test/did.js.map +0 -1
  151. package/dist/utils/tag-abi-codec.d.ts +0 -69
  152. package/dist/utils/tag-abi-codec.d.ts.map +0 -1
  153. package/dist/utils/tag-abi-codec.js +0 -144
  154. package/dist/utils/tag-abi-codec.js.map +0 -1
  155. package/examples/crypto-utilities.ts +0 -140
  156. package/examples/ed25519-jwk.ts +0 -73
  157. package/examples/generate-mnemonic.ts +0 -149
  158. package/examples/legacy.ts +0 -33
  159. package/examples/olares-id-format.ts +0 -197
  160. package/examples/tag-builder.ts +0 -235
  161. package/examples/tag-nested-tuple.ts +0 -190
  162. package/examples/tag-simple.ts +0 -149
  163. package/examples/tag-tagger.ts +0 -217
  164. package/examples/test-nested-tuple-conversion.ts +0 -143
  165. package/examples/test-type-bytes-parser.ts +0 -70
  166. package/src/abi/ABITypeABI.ts +0 -379
  167. package/src/abi/RegistryABI.ts +0 -459
  168. package/src/tag/address.ts +0 -48
  169. package/src/tag/array.ts +0 -80
  170. package/src/tag/bool.ts +0 -43
  171. package/src/tag/bytes.ts +0 -38
  172. package/src/tag/flarray.ts +0 -99
  173. package/src/tag/flbytes.ts +0 -48
  174. package/src/tag/index.ts +0 -170
  175. package/src/tag/int.ts +0 -51
  176. package/src/tag/string.ts +0 -38
  177. package/src/tag/tag.ts +0 -229
  178. package/src/tag/tuple.ts +0 -193
  179. package/src/tag/uint.ts +0 -51
  180. package/src/test/did.ts +0 -346
  181. 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,21 @@
1
- import { PackageDomain } from './domain/index';
2
- import DIDTag from './tag/index';
3
1
  import { ethers } from 'ethers';
4
2
  import DID_ABI from './abi/TerminusDIDABI';
5
3
  import RootResolverABI from './abi/RootResolverABI';
6
4
  import RootResolver2ABI from './abi/RootResolver2ABI';
7
- import { debug } from './debug';
8
5
  import { parseContractError } from './utils/error-parser';
9
- import { normalizeToDomain } from './utils/olares-id';
10
6
 
11
7
  import { DomainContext, TransactionResult } from './business';
12
8
 
13
- // Import Tag utilities
14
- import { TagTypeBuilder } from './utils/tag-type-builder';
15
- import { TagAbiCodec } from './utils/tag-abi-codec';
16
-
17
9
  // Import config utilities
18
- import { getNetworkConfig, getAvailableNetworks } from './config';
10
+ import { getNetworkConfig } from './config';
11
+
12
+ // Import domain functions
13
+ import {
14
+ fetchDomain,
15
+ fetchDomains,
16
+ fetchDomainsByIndices,
17
+ fetchAllFlat
18
+ } from './domain/index';
19
19
 
20
20
  export type {
21
21
  DomainInfo,
@@ -45,23 +45,17 @@ export {
45
45
  getEd25519JwkFromMnemonic
46
46
  } from './business';
47
47
 
48
- type Domain = PackageDomain.Domain;
49
-
50
- type StoreDomain = PackageDomain.DomainData;
51
-
52
- export class DIDConsole implements DIDTag.ABITypeProviderHolder {
48
+ export class DIDConsole {
53
49
  rpcNode: string;
54
50
  contractDid: string;
55
51
  contractRootResolver: string;
56
52
  contractAbiType: string;
57
53
  contractRootResolver2?: string;
58
54
  supportSvcUrl?: string;
55
+ queryContractAddress?: string; // New: query contract address
59
56
 
60
57
  signer?: ethers.Signer;
61
58
 
62
- allDomainCache: Domain[] = [];
63
- treesCache: Domain[] = [];
64
-
65
59
  // caching contract instances
66
60
  private _contractDID?: ethers.Contract;
67
61
  private _signerContractDID?: ethers.Contract;
@@ -78,7 +72,8 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
78
72
  contractRootResolver: string,
79
73
  contractAbiType: string,
80
74
  contractRootResolver2?: string,
81
- supportSvcUrl?: string
75
+ supportSvcUrl?: string,
76
+ queryContractAddress?: string
82
77
  ) {
83
78
  this.rpcNode = rpcNode;
84
79
  this.contractDid = contractDid;
@@ -86,6 +81,7 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
86
81
  this.contractAbiType = contractAbiType;
87
82
  this.contractRootResolver2 = contractRootResolver2;
88
83
  this.supportSvcUrl = supportSvcUrl;
84
+ this.queryContractAddress = queryContractAddress;
89
85
  }
90
86
 
91
87
  getProvider = (): ethers.JsonRpcProvider => {
@@ -247,193 +243,98 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
247
243
  await provider.getSigner()
248
244
  );
249
245
 
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
246
+ /**
247
+ * Fetch a single domain by name or tokenId
248
+ * Uses the query contract configured for this network
249
+ *
250
+ * @param nameOrTokenId - Domain name or tokenId
251
+ * @returns Domain data or null if not found
252
+ *
253
+ * @example
254
+ * const domain = await console.fetchDomain("alice.olares.com");
255
+ */
256
+ async fetchDomain(nameOrTokenId: string | bigint) {
257
+ if (!this.queryContractAddress) {
258
+ throw new Error(
259
+ 'Query contract address not configured for this network'
351
260
  );
352
- this.allDomainCache.push(domain);
353
-
354
- this.treesCache = PackageDomain.buildTree(this.allDomainCache);
355
-
356
- resolve(domain);
261
+ }
262
+ return fetchDomain(this, nameOrTokenId, {
263
+ queryContractAddress: this.queryContractAddress
357
264
  });
265
+ }
358
266
 
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
267
+ /**
268
+ * Fetch multiple domains with pagination
269
+ *
270
+ * @param offset - Starting index
271
+ * @param limit - Number of domains to fetch
272
+ * @returns Array of domains in the specified range
273
+ *
274
+ * @example
275
+ * const domains = await console.fetchDomains(0, 10);
276
+ */
277
+ async fetchDomains(offset: number, limit: number) {
278
+ if (!this.queryContractAddress) {
279
+ throw new Error(
280
+ 'Query contract address not configured for this network'
401
281
  );
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);
282
+ }
283
+ return fetchDomains(this, {
284
+ offset,
285
+ limit,
286
+ queryContractAddress: this.queryContractAddress
417
287
  });
288
+ }
418
289
 
419
- loadData = (data: StoreDomain) =>
420
- new Promise<Domain>((resolve, reject) => {
421
- resolve(data);
290
+ /**
291
+ * Fetch all domains with flat structure
292
+ *
293
+ * @param options - Additional options (batchSize, onProgress)
294
+ * @returns Array of all domains
295
+ *
296
+ * @example
297
+ * const domains = await console.fetchAllFlat({
298
+ * batchSize: 100,
299
+ * onProgress: (current, total) => console.log(`${current}/${total}`)
300
+ * });
301
+ */
302
+ async fetchAllFlat(
303
+ options: {
304
+ batchSize?: number;
305
+ onProgress?: (current: number, total: number) => void;
306
+ } = {}
307
+ ) {
308
+ if (!this.queryContractAddress) {
309
+ throw new Error(
310
+ 'Query contract address not configured for this network'
311
+ );
312
+ }
313
+ return fetchAllFlat(this, {
314
+ queryContractAddress: this.queryContractAddress,
315
+ ...options
422
316
  });
317
+ }
423
318
 
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);
319
+ /**
320
+ * Fetch multiple domains by their indices
321
+ *
322
+ * @param indices - Array of domain indices (e.g., [5, 6, 9, 10])
323
+ * @returns Array of domains corresponding to the specified indices
324
+ *
325
+ * @example
326
+ * const domains = await console.fetchDomainsByIndices([5, 6, 9, 10]);
327
+ */
328
+ async fetchDomainsByIndices(indices: number[]) {
329
+ if (!this.queryContractAddress) {
330
+ throw new Error(
331
+ 'Query contract address not configured for this network'
332
+ );
333
+ }
334
+ return fetchDomainsByIndices(this, indices, {
335
+ queryContractAddress: this.queryContractAddress
436
336
  });
337
+ }
437
338
 
438
339
  /**
439
340
  * Uses a chain-style operation design pattern, returning the operation context for the specified domain
@@ -596,7 +497,8 @@ namespace OlaresID {
596
497
  contractRootResolver: string,
597
498
  contractAbiType: string,
598
499
  contractRootResolver2?: string,
599
- supportSvcUrl?: string
500
+ supportSvcUrl?: string,
501
+ queryContractAddress?: string
600
502
  ): DIDConsole => {
601
503
  return new DIDConsole(
602
504
  rpcNode,
@@ -604,14 +506,15 @@ namespace OlaresID {
604
506
  contractRootResolver,
605
507
  contractAbiType,
606
508
  contractRootResolver2,
607
- supportSvcUrl
509
+ supportSvcUrl,
510
+ queryContractAddress
608
511
  );
609
512
  };
610
513
 
611
514
  export const createMainnet = (): DIDConsole => {
612
515
  const config = getNetworkConfig('mainnet');
613
516
  if (!config) {
614
- throw new Error('Mainnet configuration not found in config.json');
517
+ throw new Error('Mainnet configuration not found');
615
518
  }
616
519
 
617
520
  return createConsole(
@@ -620,14 +523,15 @@ namespace OlaresID {
620
523
  config.contractRootResolver,
621
524
  config.contractAbiType,
622
525
  config.contractRootResolver2,
623
- config.supportSvcUrl
526
+ config.supportSvcUrl,
527
+ config.queryContract
624
528
  );
625
529
  };
626
530
 
627
531
  export const createTestnet = (): DIDConsole => {
628
532
  const config = getNetworkConfig('sepolia');
629
533
  if (!config) {
630
- throw new Error('Sepolia configuration not found in config.json');
534
+ throw new Error('Sepolia configuration not found');
631
535
  }
632
536
 
633
537
  return createConsole(
@@ -636,15 +540,46 @@ namespace OlaresID {
636
540
  config.contractRootResolver,
637
541
  config.contractAbiType,
638
542
  config.contractRootResolver2,
639
- config.supportSvcUrl
543
+ config.supportSvcUrl,
544
+ config.queryContract
640
545
  );
641
546
  };
642
547
 
643
- export import Domain = PackageDomain;
548
+ /**
549
+ * Create a DIDConsole instance with custom RPC endpoint
550
+ * Contract addresses are loaded from configuration based on network type
551
+ *
552
+ * @param rpc - Custom RPC endpoint URL
553
+ * @param network - Network type: 'mainnet' or 'sepolia' (default: 'mainnet')
554
+ * @returns DIDConsole instance
555
+ *
556
+ * @example
557
+ * // Create mainnet instance with custom RPC
558
+ * const console = OlaresID.createWithRpc('https://my-optimism-rpc.com');
559
+ *
560
+ * // Create sepolia instance with custom RPC
561
+ * const console = OlaresID.createWithRpc('https://my-sepolia-rpc.com', 'sepolia');
562
+ */
563
+ export const createWithRpc = (
564
+ rpc: string,
565
+ network: 'mainnet' | 'sepolia' = 'mainnet'
566
+ ): DIDConsole => {
567
+ const config = getNetworkConfig(network);
644
568
 
645
- export import Tag = DIDTag;
569
+ if (!config) {
570
+ throw new Error(`${network} configuration not found`);
571
+ }
646
572
 
647
- export type StoreDomain = PackageDomain.DomainData;
573
+ return createConsole(
574
+ rpc, // Use custom RPC
575
+ config.contractDid,
576
+ config.contractRootResolver,
577
+ config.contractAbiType,
578
+ config.contractRootResolver2,
579
+ config.supportSvcUrl,
580
+ config.queryContract
581
+ );
582
+ };
648
583
 
649
584
  export const ABI_DID = DID_ABI;
650
585
 
@@ -653,10 +588,89 @@ namespace OlaresID {
653
588
 
654
589
  export { debug } from './debug';
655
590
 
656
- // Export Tag utilities outside namespace
657
- export { TagTypeBuilder, TagAbiCodec };
591
+ // Export Tag utilities
592
+ export { TagTypeBuilder } from './utils/tag-type-builder';
593
+ export { TagTypeParser } from './utils/tag-type-parser';
658
594
 
659
595
  // Export Olares ID utilities
660
596
  export { normalizeToDomain, normalizeToOlaresId } from './utils/olares-id';
661
597
 
598
+ // Export event parser
599
+ export { parseEvents } from './utils/event-parser';
600
+ export type {
601
+ EthLog,
602
+ AnyParsedEvent,
603
+ ParsedEvent,
604
+ TerminusDIDEventName,
605
+ TerminusDIDEventArgsMap,
606
+ TransferArgs,
607
+ ApprovalArgs,
608
+ ApprovalForAllArgs,
609
+ InitializedArgs,
610
+ NewTagTypeArgs,
611
+ OffchainStringArrayArgs,
612
+ OwnershipTransferStartedArgs,
613
+ OwnershipTransferredArgs,
614
+ TagAddedArgs,
615
+ TagElemPoppedArgs,
616
+ TagElemPushedArgs,
617
+ TagElemUpdatedArgs,
618
+ TagRemovedArgs,
619
+ TransferByParentOwnerArgs,
620
+ TransferBySuperAdminArgs,
621
+ UpgradedArgs
622
+ } from './utils/event-parser';
623
+ export {
624
+ isTransferEvent,
625
+ isMintEvent,
626
+ isTagAddedEvent,
627
+ isTagRemovedEvent,
628
+ isTagElemUpdatedEvent,
629
+ isTagElemPushedEvent,
630
+ isTagElemPoppedEvent,
631
+ isNewTagTypeEvent
632
+ } from './utils/event-parser';
633
+
634
+ // Export new domain fetching functions and utilities
635
+ export { QueryContractHelper } from './domain/core';
636
+ export {
637
+ fetchDomain,
638
+ fetchDomains,
639
+ fetchDomainsByIndices,
640
+ fetchAllFlat,
641
+ FetchDomainOptions,
642
+ FetchDomainsOptions,
643
+ FetchDomainsByIndicesOptions
644
+ } from './domain/index';
645
+ export type {
646
+ Tag,
647
+ FlatDomainData,
648
+ RawDomainData,
649
+ RawTagData,
650
+ FetchAllOptions
651
+ } from './domain/types';
652
+
653
+ // Export config utilities
654
+ export { getContractConfig } from './config';
655
+ export type { ContractConfig } from './config';
656
+
657
+ // Export DID utilities
658
+ export type {
659
+ PublicJwk,
660
+ PrivateJwk,
661
+ VerificationMethod,
662
+ DIDDocument,
663
+ Service
664
+ } from './utils/crypto-utils';
665
+ export {
666
+ LDKeyType,
667
+ getPublicJWKFromX,
668
+ getPublicJWKFromDID,
669
+ getPrivateJWKFromD,
670
+ getIDFromEd25519Pubkey,
671
+ getPrivateJWKFromEd25519,
672
+ getFullyQualifiedVerificationMethodID,
673
+ resolveDID
674
+ } from './utils/crypto-utils';
675
+
662
676
  export default OlaresID;