@beclab/olaresid 0.1.12 → 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.
- package/CLI-TREE.md +107 -0
- package/CLI.md +122 -1329
- package/README.md +30 -12
- package/SDK-TREE.md +151 -0
- package/TAG.md +95 -41
- package/config.json +6 -4
- package/dist/abi/TerminusDIDQueryABI.d.ts +397 -0
- package/dist/abi/TerminusDIDQueryABI.d.ts.map +1 -0
- package/dist/abi/TerminusDIDQueryABI.js +519 -0
- package/dist/abi/TerminusDIDQueryABI.js.map +1 -0
- package/dist/business/index.d.ts +1 -1
- package/dist/business/index.d.ts.map +1 -1
- package/dist/business/index.js +11 -24
- package/dist/business/index.js.map +1 -1
- package/dist/business/tag-context.d.ts +1 -0
- package/dist/business/tag-context.d.ts.map +1 -1
- package/dist/business/tag-context.js +13 -7
- package/dist/business/tag-context.js.map +1 -1
- package/dist/cli.js +238 -107
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts +16 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +28 -14
- package/dist/config/index.js.map +1 -1
- package/dist/domain/core.d.ts +65 -0
- package/dist/domain/core.d.ts.map +1 -0
- package/dist/domain/core.js +317 -0
- package/dist/domain/core.js.map +1 -0
- package/dist/domain/index.d.ts +104 -57
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +188 -428
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/types.d.ts +56 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +3 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/index.d.ts +81 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -143
- package/dist/index.js.map +1 -1
- package/dist/utils/crypto-utils.d.ts +124 -0
- package/dist/utils/crypto-utils.d.ts.map +1 -1
- package/dist/utils/crypto-utils.js +156 -8
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/error-parser.d.ts.map +1 -1
- package/dist/utils/error-parser.js +2 -1
- package/dist/utils/error-parser.js.map +1 -1
- package/dist/utils/event-parser.d.ts +161 -0
- package/dist/utils/event-parser.d.ts.map +1 -0
- package/dist/utils/event-parser.js +140 -0
- package/dist/utils/event-parser.js.map +1 -0
- package/dist/utils/tag-type-builder.d.ts +43 -0
- package/dist/utils/tag-type-builder.d.ts.map +1 -1
- package/dist/utils/tag-type-builder.js +122 -0
- package/dist/utils/tag-type-builder.js.map +1 -1
- package/dist/utils/tag-type-parser.d.ts +70 -0
- package/dist/utils/tag-type-parser.d.ts.map +1 -0
- package/dist/utils/tag-type-parser.js +190 -0
- package/dist/utils/tag-type-parser.js.map +1 -0
- package/examples/create-with-rpc-demo.ts +142 -0
- package/examples/fetch-all-flat-demo.ts +159 -0
- package/examples/fetch-by-indices-demo.ts +235 -0
- package/examples/fetch-domain-demo.ts +137 -0
- package/examples/fetch-domains-demo.ts +221 -0
- package/examples/frontend-demo/index.html +2 -2
- package/examples/frontend-demo/package-lock.json +4 -1
- package/examples/index.ts +3 -5
- package/jest.config.js +25 -0
- package/package.json +6 -2
- package/src/abi/TerminusDIDQueryABI.ts +516 -0
- package/src/business/index.ts +10 -33
- package/src/business/tag-context.ts +35 -7
- package/src/cli.ts +344 -121
- package/src/config/index.ts +34 -19
- package/src/domain/core.ts +382 -0
- package/src/domain/index.ts +271 -641
- package/src/domain/types.ts +59 -0
- package/src/index.ts +222 -207
- package/src/utils/crypto-utils.ts +239 -2
- package/src/utils/error-parser.ts +2 -1
- package/src/utils/event-parser.ts +353 -0
- package/src/utils/tag-type-builder.ts +138 -0
- package/src/utils/tag-type-parser.ts +246 -0
- package/tests/unit/crypto-utils.test.ts +338 -0
- package/tests/unit/ed25519-jwk.test.ts +201 -0
- package/tests/unit/event-parser.test.ts +690 -0
- package/tests/unit/generate-mnemonic.test.ts +268 -0
- package/tests/unit/olares-id-format.test.ts +321 -0
- package/tests/unit/tag-type-parser.test.ts +802 -0
- package/tests/unit/tag-types.test.ts +821 -0
- package/tsconfig.json +3 -2
- package/dist/abi/ABITypeABI.d.ts +0 -88
- package/dist/abi/ABITypeABI.d.ts.map +0 -1
- package/dist/abi/ABITypeABI.js +0 -382
- package/dist/abi/ABITypeABI.js.map +0 -1
- package/dist/abi/RegistryABI.d.ts +0 -77
- package/dist/abi/RegistryABI.d.ts.map +0 -1
- package/dist/abi/RegistryABI.js +0 -462
- package/dist/abi/RegistryABI.js.map +0 -1
- package/dist/tag/address.d.ts +0 -11
- package/dist/tag/address.d.ts.map +0 -1
- package/dist/tag/address.js +0 -44
- package/dist/tag/address.js.map +0 -1
- package/dist/tag/array.d.ts +0 -14
- package/dist/tag/array.d.ts.map +0 -1
- package/dist/tag/array.js +0 -72
- package/dist/tag/array.js.map +0 -1
- package/dist/tag/bool.d.ts +0 -11
- package/dist/tag/bool.d.ts.map +0 -1
- package/dist/tag/bool.js +0 -43
- package/dist/tag/bool.js.map +0 -1
- package/dist/tag/bytes.d.ts +0 -11
- package/dist/tag/bytes.d.ts.map +0 -1
- package/dist/tag/bytes.js +0 -37
- package/dist/tag/bytes.js.map +0 -1
- package/dist/tag/flarray.d.ts +0 -15
- package/dist/tag/flarray.d.ts.map +0 -1
- package/dist/tag/flarray.js +0 -81
- package/dist/tag/flarray.js.map +0 -1
- package/dist/tag/flbytes.d.ts +0 -11
- package/dist/tag/flbytes.d.ts.map +0 -1
- package/dist/tag/flbytes.js +0 -47
- package/dist/tag/flbytes.js.map +0 -1
- package/dist/tag/index.d.ts +0 -32
- package/dist/tag/index.d.ts.map +0 -1
- package/dist/tag/index.js +0 -121
- package/dist/tag/index.js.map +0 -1
- package/dist/tag/int.d.ts +0 -12
- package/dist/tag/int.d.ts.map +0 -1
- package/dist/tag/int.js +0 -49
- package/dist/tag/int.js.map +0 -1
- package/dist/tag/string.d.ts +0 -11
- package/dist/tag/string.d.ts.map +0 -1
- package/dist/tag/string.js +0 -37
- package/dist/tag/string.js.map +0 -1
- package/dist/tag/tag.d.ts +0 -67
- package/dist/tag/tag.d.ts.map +0 -1
- package/dist/tag/tag.js +0 -157
- package/dist/tag/tag.js.map +0 -1
- package/dist/tag/tuple.d.ts +0 -17
- package/dist/tag/tuple.d.ts.map +0 -1
- package/dist/tag/tuple.js +0 -162
- package/dist/tag/tuple.js.map +0 -1
- package/dist/tag/uint.d.ts +0 -12
- package/dist/tag/uint.d.ts.map +0 -1
- package/dist/tag/uint.js +0 -49
- package/dist/tag/uint.js.map +0 -1
- package/dist/test/did.d.ts +0 -2
- package/dist/test/did.d.ts.map +0 -1
- package/dist/test/did.js +0 -177
- package/dist/test/did.js.map +0 -1
- package/dist/utils/tag-abi-codec.d.ts +0 -69
- package/dist/utils/tag-abi-codec.d.ts.map +0 -1
- package/dist/utils/tag-abi-codec.js +0 -144
- package/dist/utils/tag-abi-codec.js.map +0 -1
- package/examples/crypto-utilities.ts +0 -140
- package/examples/ed25519-jwk.ts +0 -73
- package/examples/generate-mnemonic.ts +0 -149
- package/examples/legacy.ts +0 -33
- package/examples/olares-id-format.ts +0 -197
- package/examples/tag-builder.ts +0 -235
- package/examples/tag-nested-tuple.ts +0 -190
- package/examples/tag-simple.ts +0 -149
- package/examples/tag-tagger.ts +0 -217
- package/examples/test-nested-tuple-conversion.ts +0 -143
- package/examples/test-type-bytes-parser.ts +0 -70
- package/src/abi/ABITypeABI.ts +0 -379
- package/src/abi/RegistryABI.ts +0 -459
- package/src/tag/address.ts +0 -48
- package/src/tag/array.ts +0 -80
- package/src/tag/bool.ts +0 -43
- package/src/tag/bytes.ts +0 -38
- package/src/tag/flarray.ts +0 -99
- package/src/tag/flbytes.ts +0 -48
- package/src/tag/index.ts +0 -170
- package/src/tag/int.ts +0 -51
- package/src/tag/string.ts +0 -38
- package/src/tag/tag.ts +0 -229
- package/src/tag/tuple.ts +0 -193
- package/src/tag/uint.ts +0 -51
- package/src/test/did.ts +0 -346
- 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
|
|
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,
|
|
@@ -37,6 +37,7 @@ export {
|
|
|
37
37
|
bytes4ToIpv4,
|
|
38
38
|
generateMnemonic,
|
|
39
39
|
getEthereumAddressFromMnemonic,
|
|
40
|
+
getEthereumAddressFromPrivateKey,
|
|
40
41
|
getEVMPrivateKeyFromMnemonic,
|
|
41
42
|
getDIDFromMnemonic,
|
|
42
43
|
generateDIDKeyData,
|
|
@@ -44,23 +45,17 @@ export {
|
|
|
44
45
|
getEd25519JwkFromMnemonic
|
|
45
46
|
} from './business';
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
type StoreDomain = PackageDomain.DomainData;
|
|
50
|
-
|
|
51
|
-
export class DIDConsole implements DIDTag.ABITypeProviderHolder {
|
|
48
|
+
export class DIDConsole {
|
|
52
49
|
rpcNode: string;
|
|
53
50
|
contractDid: string;
|
|
54
51
|
contractRootResolver: string;
|
|
55
52
|
contractAbiType: string;
|
|
56
53
|
contractRootResolver2?: string;
|
|
57
54
|
supportSvcUrl?: string;
|
|
55
|
+
queryContractAddress?: string; // New: query contract address
|
|
58
56
|
|
|
59
57
|
signer?: ethers.Signer;
|
|
60
58
|
|
|
61
|
-
allDomainCache: Domain[] = [];
|
|
62
|
-
treesCache: Domain[] = [];
|
|
63
|
-
|
|
64
59
|
// caching contract instances
|
|
65
60
|
private _contractDID?: ethers.Contract;
|
|
66
61
|
private _signerContractDID?: ethers.Contract;
|
|
@@ -77,7 +72,8 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
|
|
|
77
72
|
contractRootResolver: string,
|
|
78
73
|
contractAbiType: string,
|
|
79
74
|
contractRootResolver2?: string,
|
|
80
|
-
supportSvcUrl?: string
|
|
75
|
+
supportSvcUrl?: string,
|
|
76
|
+
queryContractAddress?: string
|
|
81
77
|
) {
|
|
82
78
|
this.rpcNode = rpcNode;
|
|
83
79
|
this.contractDid = contractDid;
|
|
@@ -85,6 +81,7 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
|
|
|
85
81
|
this.contractAbiType = contractAbiType;
|
|
86
82
|
this.contractRootResolver2 = contractRootResolver2;
|
|
87
83
|
this.supportSvcUrl = supportSvcUrl;
|
|
84
|
+
this.queryContractAddress = queryContractAddress;
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
getProvider = (): ethers.JsonRpcProvider => {
|
|
@@ -246,193 +243,98 @@ export class DIDConsole implements DIDTag.ABITypeProviderHolder {
|
|
|
246
243
|
await provider.getSigner()
|
|
247
244
|
);
|
|
248
245
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
)}%`
|
|
264
|
-
);
|
|
265
|
-
arr.push(domain);
|
|
266
|
-
}
|
|
267
|
-
this.allDomainCache = arr;
|
|
268
|
-
this.treesCache = PackageDomain.buildTree(this.allDomainCache);
|
|
269
|
-
|
|
270
|
-
debug.groupEnd();
|
|
271
|
-
resolve(this.treesCache);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
fetchDomain = (name: string) =>
|
|
275
|
-
new Promise<Domain | undefined>(async (resolve, reject) => {
|
|
276
|
-
// Support Olares ID format (user@domain.com)
|
|
277
|
-
const normalizedName = normalizeToDomain(name);
|
|
278
|
-
|
|
279
|
-
debug.group('fetchDomain');
|
|
280
|
-
const hasCache = this.allDomainCache.length > 0;
|
|
281
|
-
debug.info('fetchDomain--->hasCache', hasCache);
|
|
282
|
-
|
|
283
|
-
if (hasCache) {
|
|
284
|
-
const domain = PackageDomain.findASubtree(
|
|
285
|
-
normalizedName,
|
|
286
|
-
this.allDomainCache
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
debug.groupEnd();
|
|
290
|
-
resolve(domain);
|
|
291
|
-
} else {
|
|
292
|
-
const domain = await PackageDomain.syncByName(
|
|
293
|
-
normalizedName,
|
|
294
|
-
await this.getContractDID()
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
debug.groupEnd();
|
|
298
|
-
resolve(domain);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
updateDomain = (name: string) =>
|
|
303
|
-
new Promise<Domain>(async (resolve, reject) => {
|
|
304
|
-
// Support Olares ID format (user@domain.com)
|
|
305
|
-
const normalizedName = normalizeToDomain(name);
|
|
306
|
-
|
|
307
|
-
const domain = await PackageDomain.syncByName(
|
|
308
|
-
normalizedName,
|
|
309
|
-
await this.getContractDID()
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
if (domain == undefined) {
|
|
313
|
-
reject('not found domain');
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const [oldDomain] = this.allDomainCache.filter(
|
|
318
|
-
(d) => d.name == domain.name
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
if (oldDomain != undefined) {
|
|
322
|
-
for (const tagNew of domain.tags) {
|
|
323
|
-
for (const tagOld of oldDomain.tags) {
|
|
324
|
-
if (tagNew.name == tagOld.name) {
|
|
325
|
-
if (
|
|
326
|
-
tagNew.valueFormated == undefined &&
|
|
327
|
-
tagOld.valueFormated != undefined
|
|
328
|
-
) {
|
|
329
|
-
tagNew.valueFormated = tagOld.valueFormated;
|
|
330
|
-
}
|
|
331
|
-
if (
|
|
332
|
-
tagNew.valueSource == undefined &&
|
|
333
|
-
tagOld.valueSource != undefined
|
|
334
|
-
) {
|
|
335
|
-
tagNew.valueSource = tagOld.valueSource;
|
|
336
|
-
}
|
|
337
|
-
if (
|
|
338
|
-
tagNew.definition == undefined &&
|
|
339
|
-
tagOld.definition != undefined
|
|
340
|
-
) {
|
|
341
|
-
tagNew.definition = tagOld.definition;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
this.allDomainCache = this.allDomainCache.filter(
|
|
349
|
-
(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'
|
|
350
260
|
);
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
resolve(domain);
|
|
261
|
+
}
|
|
262
|
+
return fetchDomain(this, nameOrTokenId, {
|
|
263
|
+
queryContractAddress: this.queryContractAddress
|
|
356
264
|
});
|
|
265
|
+
}
|
|
357
266
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
);
|
|
373
|
-
for (const tagNew of domain.tags) {
|
|
374
|
-
for (const tagOld of oldDomain.tags) {
|
|
375
|
-
if (tagNew.name == tagOld.name) {
|
|
376
|
-
if (
|
|
377
|
-
tagNew.valueFormated == undefined &&
|
|
378
|
-
tagOld.valueFormated != undefined
|
|
379
|
-
) {
|
|
380
|
-
tagNew.valueFormated = tagOld.valueFormated;
|
|
381
|
-
}
|
|
382
|
-
if (
|
|
383
|
-
tagNew.valueSource == undefined &&
|
|
384
|
-
tagOld.valueSource != undefined
|
|
385
|
-
) {
|
|
386
|
-
tagNew.valueSource = tagOld.valueSource;
|
|
387
|
-
}
|
|
388
|
-
if (
|
|
389
|
-
tagNew.definition == undefined &&
|
|
390
|
-
tagOld.definition != undefined
|
|
391
|
-
) {
|
|
392
|
-
tagNew.definition = tagOld.definition;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
this.allDomainCache = this.allDomainCache.filter(
|
|
399
|
-
(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'
|
|
400
281
|
);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
formatData = (doamin: Domain) =>
|
|
409
|
-
new Promise<StoreDomain>((resolve, reject) => {
|
|
410
|
-
resolve(doamin);
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
formatDatas = (doamins: Domain[]) =>
|
|
414
|
-
new Promise<StoreDomain[]>((resolve, reject) => {
|
|
415
|
-
resolve(doamins);
|
|
282
|
+
}
|
|
283
|
+
return fetchDomains(this, {
|
|
284
|
+
offset,
|
|
285
|
+
limit,
|
|
286
|
+
queryContractAddress: this.queryContractAddress
|
|
416
287
|
});
|
|
288
|
+
}
|
|
417
289
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
|
421
316
|
});
|
|
317
|
+
}
|
|
422
318
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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
|
|
435
336
|
});
|
|
337
|
+
}
|
|
436
338
|
|
|
437
339
|
/**
|
|
438
340
|
* Uses a chain-style operation design pattern, returning the operation context for the specified domain
|
|
@@ -595,7 +497,8 @@ namespace OlaresID {
|
|
|
595
497
|
contractRootResolver: string,
|
|
596
498
|
contractAbiType: string,
|
|
597
499
|
contractRootResolver2?: string,
|
|
598
|
-
supportSvcUrl?: string
|
|
500
|
+
supportSvcUrl?: string,
|
|
501
|
+
queryContractAddress?: string
|
|
599
502
|
): DIDConsole => {
|
|
600
503
|
return new DIDConsole(
|
|
601
504
|
rpcNode,
|
|
@@ -603,14 +506,15 @@ namespace OlaresID {
|
|
|
603
506
|
contractRootResolver,
|
|
604
507
|
contractAbiType,
|
|
605
508
|
contractRootResolver2,
|
|
606
|
-
supportSvcUrl
|
|
509
|
+
supportSvcUrl,
|
|
510
|
+
queryContractAddress
|
|
607
511
|
);
|
|
608
512
|
};
|
|
609
513
|
|
|
610
514
|
export const createMainnet = (): DIDConsole => {
|
|
611
515
|
const config = getNetworkConfig('mainnet');
|
|
612
516
|
if (!config) {
|
|
613
|
-
throw new Error('Mainnet configuration not found
|
|
517
|
+
throw new Error('Mainnet configuration not found');
|
|
614
518
|
}
|
|
615
519
|
|
|
616
520
|
return createConsole(
|
|
@@ -619,14 +523,15 @@ namespace OlaresID {
|
|
|
619
523
|
config.contractRootResolver,
|
|
620
524
|
config.contractAbiType,
|
|
621
525
|
config.contractRootResolver2,
|
|
622
|
-
config.supportSvcUrl
|
|
526
|
+
config.supportSvcUrl,
|
|
527
|
+
config.queryContract
|
|
623
528
|
);
|
|
624
529
|
};
|
|
625
530
|
|
|
626
531
|
export const createTestnet = (): DIDConsole => {
|
|
627
532
|
const config = getNetworkConfig('sepolia');
|
|
628
533
|
if (!config) {
|
|
629
|
-
throw new Error('Sepolia configuration not found
|
|
534
|
+
throw new Error('Sepolia configuration not found');
|
|
630
535
|
}
|
|
631
536
|
|
|
632
537
|
return createConsole(
|
|
@@ -635,15 +540,46 @@ namespace OlaresID {
|
|
|
635
540
|
config.contractRootResolver,
|
|
636
541
|
config.contractAbiType,
|
|
637
542
|
config.contractRootResolver2,
|
|
638
|
-
config.supportSvcUrl
|
|
543
|
+
config.supportSvcUrl,
|
|
544
|
+
config.queryContract
|
|
639
545
|
);
|
|
640
546
|
};
|
|
641
547
|
|
|
642
|
-
|
|
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);
|
|
643
568
|
|
|
644
|
-
|
|
569
|
+
if (!config) {
|
|
570
|
+
throw new Error(`${network} configuration not found`);
|
|
571
|
+
}
|
|
645
572
|
|
|
646
|
-
|
|
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
|
+
};
|
|
647
583
|
|
|
648
584
|
export const ABI_DID = DID_ABI;
|
|
649
585
|
|
|
@@ -652,10 +588,89 @@ namespace OlaresID {
|
|
|
652
588
|
|
|
653
589
|
export { debug } from './debug';
|
|
654
590
|
|
|
655
|
-
// Export Tag utilities
|
|
656
|
-
export { TagTypeBuilder
|
|
591
|
+
// Export Tag utilities
|
|
592
|
+
export { TagTypeBuilder } from './utils/tag-type-builder';
|
|
593
|
+
export { TagTypeParser } from './utils/tag-type-parser';
|
|
657
594
|
|
|
658
595
|
// Export Olares ID utilities
|
|
659
596
|
export { normalizeToDomain, normalizeToOlaresId } from './utils/olares-id';
|
|
660
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
|
+
|
|
661
676
|
export default OlaresID;
|