@beclab/olaresid 0.1.1 → 0.1.3

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 (93) hide show
  1. package/CLI.md +1300 -0
  2. package/README.md +40 -31
  3. package/TAG.md +589 -0
  4. package/dist/abi/RootResolver2ABI.d.ts +54 -0
  5. package/dist/abi/RootResolver2ABI.d.ts.map +1 -0
  6. package/dist/abi/RootResolver2ABI.js +240 -0
  7. package/dist/abi/RootResolver2ABI.js.map +1 -0
  8. package/dist/business/index.d.ts +302 -0
  9. package/dist/business/index.d.ts.map +1 -0
  10. package/dist/business/index.js +1211 -0
  11. package/dist/business/index.js.map +1 -0
  12. package/dist/business/tag-context.d.ts +219 -0
  13. package/dist/business/tag-context.d.ts.map +1 -0
  14. package/dist/business/tag-context.js +560 -0
  15. package/dist/business/tag-context.js.map +1 -0
  16. package/dist/cli.js +2102 -39
  17. package/dist/cli.js.map +1 -1
  18. package/dist/debug.d.ts.map +1 -1
  19. package/dist/debug.js +14 -2
  20. package/dist/debug.js.map +1 -1
  21. package/dist/index.d.ts +51 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +241 -12
  24. package/dist/index.js.map +1 -1
  25. package/dist/utils/crypto-utils.d.ts +130 -0
  26. package/dist/utils/crypto-utils.d.ts.map +1 -0
  27. package/dist/utils/crypto-utils.js +402 -0
  28. package/dist/utils/crypto-utils.js.map +1 -0
  29. package/dist/utils/error-parser.d.ts +35 -0
  30. package/dist/utils/error-parser.d.ts.map +1 -0
  31. package/dist/utils/error-parser.js +202 -0
  32. package/dist/utils/error-parser.js.map +1 -0
  33. package/dist/utils/olares-id.d.ts +36 -0
  34. package/dist/utils/olares-id.d.ts.map +1 -0
  35. package/dist/utils/olares-id.js +52 -0
  36. package/dist/utils/olares-id.js.map +1 -0
  37. package/dist/utils/tag-abi-codec.d.ts +69 -0
  38. package/dist/utils/tag-abi-codec.d.ts.map +1 -0
  39. package/dist/utils/tag-abi-codec.js +144 -0
  40. package/dist/utils/tag-abi-codec.js.map +1 -0
  41. package/dist/utils/tag-type-builder.d.ts +158 -0
  42. package/dist/utils/tag-type-builder.d.ts.map +1 -0
  43. package/dist/utils/tag-type-builder.js +410 -0
  44. package/dist/utils/tag-type-builder.js.map +1 -0
  45. package/examples/crypto-utilities.ts +140 -0
  46. package/examples/domain-context.ts +80 -0
  47. package/examples/generate-mnemonic.ts +149 -0
  48. package/examples/index.ts +1 -1
  49. package/examples/ip.ts +171 -0
  50. package/examples/legacy.ts +10 -10
  51. package/examples/list-wallets.ts +81 -0
  52. package/examples/olares-id-format.ts +197 -0
  53. package/examples/quasar-demo/.eslintrc.js +23 -0
  54. package/examples/quasar-demo/.quasar/app.js +43 -0
  55. package/examples/quasar-demo/.quasar/client-entry.js +38 -0
  56. package/examples/quasar-demo/.quasar/client-prefetch.js +130 -0
  57. package/examples/quasar-demo/.quasar/quasar-user-options.js +16 -0
  58. package/examples/quasar-demo/README.md +49 -0
  59. package/examples/quasar-demo/index.html +11 -0
  60. package/examples/quasar-demo/package-lock.json +6407 -0
  61. package/examples/quasar-demo/package.json +36 -0
  62. package/examples/quasar-demo/quasar.config.js +73 -0
  63. package/examples/quasar-demo/src/App.vue +13 -0
  64. package/examples/quasar-demo/src/css/app.scss +1 -0
  65. package/examples/quasar-demo/src/layouts/MainLayout.vue +21 -0
  66. package/examples/quasar-demo/src/pages/IndexPage.vue +905 -0
  67. package/examples/quasar-demo/src/router/index.ts +25 -0
  68. package/examples/quasar-demo/src/router/routes.ts +11 -0
  69. package/examples/quasar-demo/tsconfig.json +28 -0
  70. package/examples/register-subdomain.ts +152 -0
  71. package/examples/rsa-keypair.ts +148 -0
  72. package/examples/tag-builder.ts +235 -0
  73. package/examples/tag-management.ts +534 -0
  74. package/examples/tag-nested-tuple.ts +190 -0
  75. package/examples/tag-simple.ts +149 -0
  76. package/examples/tag-tagger.ts +217 -0
  77. package/examples/test-nested-tuple-conversion.ts +143 -0
  78. package/examples/test-type-bytes-parser.ts +70 -0
  79. package/examples/transfer-domain.ts +197 -0
  80. package/examples/wallet-management.ts +196 -0
  81. package/package.json +24 -15
  82. package/src/abi/RootResolver2ABI.ts +237 -0
  83. package/src/business/index.ts +1492 -0
  84. package/src/business/tag-context.ts +747 -0
  85. package/src/cli.ts +2772 -39
  86. package/src/debug.ts +17 -2
  87. package/src/index.ts +313 -17
  88. package/src/utils/crypto-utils.ts +459 -0
  89. package/src/utils/error-parser.ts +225 -0
  90. package/src/utils/olares-id.ts +49 -0
  91. package/src/utils/tag-abi-codec.ts +158 -0
  92. package/src/utils/tag-type-builder.ts +469 -0
  93. package/tsconfig.json +1 -1
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Olares ID Utilities
3
+ *
4
+ * Olares ID is a new format that looks like email addresses: user@domain.com
5
+ * It's essentially a domain name where the first dot (.) is replaced with an at sign (@)
6
+ *
7
+ * Examples:
8
+ * - alice.example.com → alice@example.com (Olares ID)
9
+ * - bob.sub.example.com → bob@sub.example.com (Olares ID)
10
+ */
11
+ /**
12
+ * Convert Olares ID format to standard domain format
13
+ * Replaces the first @ with a dot (.)
14
+ *
15
+ * @param input The input string (can be either Olares ID or domain format)
16
+ * @returns The normalized domain format
17
+ *
18
+ * @example
19
+ * normalizeToDomain('alice@example.com') // returns 'alice.example.com'
20
+ * normalizeToDomain('alice.example.com') // returns 'alice.example.com' (no change)
21
+ * normalizeToDomain('bob@sub.example.com') // returns 'bob.sub.example.com'
22
+ */
23
+ export declare function normalizeToDomain(input: string): string;
24
+ /**
25
+ * Convert standard domain format to Olares ID format
26
+ * Replaces the first dot (.) with an at sign (@)
27
+ *
28
+ * @param domain The domain name
29
+ * @returns The Olares ID format
30
+ *
31
+ * @example
32
+ * normalizeToOlaresId('alice.example.com') // returns 'alice@example.com'
33
+ * normalizeToOlaresId('bob.sub.example.com') // returns 'bob@sub.example.com'
34
+ */
35
+ export declare function normalizeToOlaresId(domain: string): string;
36
+ //# sourceMappingURL=olares-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"olares-id.d.ts","sourceRoot":"","sources":["../../src/utils/olares-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM1D"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Olares ID Utilities
4
+ *
5
+ * Olares ID is a new format that looks like email addresses: user@domain.com
6
+ * It's essentially a domain name where the first dot (.) is replaced with an at sign (@)
7
+ *
8
+ * Examples:
9
+ * - alice.example.com → alice@example.com (Olares ID)
10
+ * - bob.sub.example.com → bob@sub.example.com (Olares ID)
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.normalizeToDomain = normalizeToDomain;
14
+ exports.normalizeToOlaresId = normalizeToOlaresId;
15
+ /**
16
+ * Convert Olares ID format to standard domain format
17
+ * Replaces the first @ with a dot (.)
18
+ *
19
+ * @param input The input string (can be either Olares ID or domain format)
20
+ * @returns The normalized domain format
21
+ *
22
+ * @example
23
+ * normalizeToDomain('alice@example.com') // returns 'alice.example.com'
24
+ * normalizeToDomain('alice.example.com') // returns 'alice.example.com' (no change)
25
+ * normalizeToDomain('bob@sub.example.com') // returns 'bob.sub.example.com'
26
+ */
27
+ function normalizeToDomain(input) {
28
+ if (!input) {
29
+ return input;
30
+ }
31
+ // Replace the first @ with a dot
32
+ return input.replace('@', '.');
33
+ }
34
+ /**
35
+ * Convert standard domain format to Olares ID format
36
+ * Replaces the first dot (.) with an at sign (@)
37
+ *
38
+ * @param domain The domain name
39
+ * @returns The Olares ID format
40
+ *
41
+ * @example
42
+ * normalizeToOlaresId('alice.example.com') // returns 'alice@example.com'
43
+ * normalizeToOlaresId('bob.sub.example.com') // returns 'bob@sub.example.com'
44
+ */
45
+ function normalizeToOlaresId(domain) {
46
+ if (!domain) {
47
+ return domain;
48
+ }
49
+ // Replace the first dot with @
50
+ return domain.replace('.', '@');
51
+ }
52
+ //# sourceMappingURL=olares-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"olares-id.js","sourceRoot":"","sources":["../../src/utils/olares-id.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAcH,8CAMC;AAaD,kDAMC;AArCD;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACd,CAAC;IACD,iCAAiC;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CAAC,MAAc;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IACf,CAAC;IACD,+BAA+B;IAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Tag ABI Codec
3
+ * Unified encoding/decoding utility for Tag values
4
+ *
5
+ * Key Principle: ALL values use abi.encode()
6
+ * - Simple values: abi.encode("value")
7
+ * - Arrays: abi.encode(["a", "b", "c"])
8
+ * - Tuples: abi.encode(struct)
9
+ * - Elements for push: abi.encode(singleElement)
10
+ */
11
+ export declare class TagAbiCodec {
12
+ private static abiCoder;
13
+ /**
14
+ * Parse tuple field types from ABI type string
15
+ * @param abiType e.g., "tuple(string,uint8,tuple(bool,address))"
16
+ * @returns Array of field types: ["string", "uint8", "tuple(bool,address)"]
17
+ */
18
+ private static parseTupleFields;
19
+ /**
20
+ * Convert object to array based on ABI type structure
21
+ * Supports nested tuples recursively
22
+ *
23
+ * @param abiType ABI type string
24
+ * @param value Value (can be object or array)
25
+ * @returns Array value
26
+ */
27
+ private static convertObjectToArray;
28
+ /**
29
+ * Encode a value with given ABI type
30
+ *
31
+ * @param abiType ABI type string (e.g., "string", "uint256", "tuple(string,uint8)")
32
+ * @param value Value to encode (objects are automatically converted to arrays)
33
+ * @returns Encoded bytes (with 0x prefix)
34
+ *
35
+ * @example
36
+ * // Simple value
37
+ * TagAbiCodec.encode("string", "hello");
38
+ *
39
+ * // Array value
40
+ * TagAbiCodec.encode("string[]", ["a", "b", "c"]);
41
+ *
42
+ * // Tuple with object input
43
+ * TagAbiCodec.encode("tuple(string,uint8)", {name: "Alice", age: 30});
44
+ *
45
+ * // Nested tuple with object input
46
+ * TagAbiCodec.encode(
47
+ * "tuple(string,tuple(uint8,bool))",
48
+ * {name: "Alice", profile: {age: 30, verified: true}}
49
+ * );
50
+ *
51
+ * // Tuple with array input (still supported)
52
+ * TagAbiCodec.encode("tuple(string,uint8)", ["Alice", 30]);
53
+ */
54
+ static encode(abiType: string, value: any): string;
55
+ /**
56
+ * Decode bytes with given ABI type
57
+ *
58
+ * @param abiType ABI type string
59
+ * @param encodedData Encoded bytes (with or without 0x prefix)
60
+ * @returns Decoded value
61
+ *
62
+ * @example
63
+ * TagAbiCodec.decode("string", encodedBytes); // → "hello"
64
+ * TagAbiCodec.decode("uint256", encodedBytes); // → 123n (BigInt)
65
+ * TagAbiCodec.decode("tuple(string,uint8)", encodedBytes); // → ["Alice", 30n]
66
+ */
67
+ static decode(abiType: string, encodedData: string): any;
68
+ }
69
+ //# sourceMappingURL=tag-abi-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-abi-codec.d.ts","sourceRoot":"","sources":["../../src/utils/tag-abi-codec.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IAEzC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAkC/B;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IA6CnC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM;IAQlD;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG;CAIxD"}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TagAbiCodec = void 0;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Tag ABI Codec
7
+ * Unified encoding/decoding utility for Tag values
8
+ *
9
+ * Key Principle: ALL values use abi.encode()
10
+ * - Simple values: abi.encode("value")
11
+ * - Arrays: abi.encode(["a", "b", "c"])
12
+ * - Tuples: abi.encode(struct)
13
+ * - Elements for push: abi.encode(singleElement)
14
+ */
15
+ class TagAbiCodec {
16
+ /**
17
+ * Parse tuple field types from ABI type string
18
+ * @param abiType e.g., "tuple(string,uint8,tuple(bool,address))"
19
+ * @returns Array of field types: ["string", "uint8", "tuple(bool,address)"]
20
+ */
21
+ static parseTupleFields(abiType) {
22
+ if (!abiType.startsWith('tuple(')) {
23
+ return [];
24
+ }
25
+ const innerTypes = abiType.slice(6, -1); // Remove "tuple(" and ")"
26
+ const fields = [];
27
+ let depth = 0;
28
+ let currentField = '';
29
+ for (let i = 0; i < innerTypes.length; i++) {
30
+ const char = innerTypes[i];
31
+ if (char === '(') {
32
+ depth++;
33
+ currentField += char;
34
+ }
35
+ else if (char === ')') {
36
+ depth--;
37
+ currentField += char;
38
+ }
39
+ else if (char === ',' && depth === 0) {
40
+ fields.push(currentField.trim());
41
+ currentField = '';
42
+ }
43
+ else {
44
+ currentField += char;
45
+ }
46
+ }
47
+ if (currentField) {
48
+ fields.push(currentField.trim());
49
+ }
50
+ return fields;
51
+ }
52
+ /**
53
+ * Convert object to array based on ABI type structure
54
+ * Supports nested tuples recursively
55
+ *
56
+ * @param abiType ABI type string
57
+ * @param value Value (can be object or array)
58
+ * @returns Array value
59
+ */
60
+ static convertObjectToArray(abiType, value) {
61
+ // If already an array or not an object, return as-is
62
+ if (Array.isArray(value) ||
63
+ typeof value !== 'object' ||
64
+ value === null) {
65
+ return value;
66
+ }
67
+ // If not a tuple type, return as-is
68
+ if (!abiType.startsWith('tuple(')) {
69
+ return value;
70
+ }
71
+ // Parse tuple field types
72
+ const fieldTypes = this.parseTupleFields(abiType);
73
+ const fieldNames = Object.keys(value);
74
+ if (fieldNames.length !== fieldTypes.length) {
75
+ throw new Error(`Tuple field count mismatch: expected ${fieldTypes.length} fields, got ${fieldNames.length} (${fieldNames.join(', ')})`);
76
+ }
77
+ // Convert object to array, recursively handling nested tuples
78
+ const result = [];
79
+ for (let i = 0; i < fieldNames.length; i++) {
80
+ const fieldName = fieldNames[i];
81
+ const fieldType = fieldTypes[i];
82
+ const fieldValue = value[fieldName];
83
+ // Recursively convert nested tuples
84
+ if (fieldType.startsWith('tuple(')) {
85
+ result.push(this.convertObjectToArray(fieldType, fieldValue));
86
+ }
87
+ else {
88
+ result.push(fieldValue);
89
+ }
90
+ }
91
+ return result;
92
+ }
93
+ /**
94
+ * Encode a value with given ABI type
95
+ *
96
+ * @param abiType ABI type string (e.g., "string", "uint256", "tuple(string,uint8)")
97
+ * @param value Value to encode (objects are automatically converted to arrays)
98
+ * @returns Encoded bytes (with 0x prefix)
99
+ *
100
+ * @example
101
+ * // Simple value
102
+ * TagAbiCodec.encode("string", "hello");
103
+ *
104
+ * // Array value
105
+ * TagAbiCodec.encode("string[]", ["a", "b", "c"]);
106
+ *
107
+ * // Tuple with object input
108
+ * TagAbiCodec.encode("tuple(string,uint8)", {name: "Alice", age: 30});
109
+ *
110
+ * // Nested tuple with object input
111
+ * TagAbiCodec.encode(
112
+ * "tuple(string,tuple(uint8,bool))",
113
+ * {name: "Alice", profile: {age: 30, verified: true}}
114
+ * );
115
+ *
116
+ * // Tuple with array input (still supported)
117
+ * TagAbiCodec.encode("tuple(string,uint8)", ["Alice", 30]);
118
+ */
119
+ static encode(abiType, value) {
120
+ // Convert object to array if needed (handles nested tuples recursively)
121
+ const convertedValue = this.convertObjectToArray(abiType, value);
122
+ // Use ethers AbiCoder to encode
123
+ return this.abiCoder.encode([abiType], [convertedValue]);
124
+ }
125
+ /**
126
+ * Decode bytes with given ABI type
127
+ *
128
+ * @param abiType ABI type string
129
+ * @param encodedData Encoded bytes (with or without 0x prefix)
130
+ * @returns Decoded value
131
+ *
132
+ * @example
133
+ * TagAbiCodec.decode("string", encodedBytes); // → "hello"
134
+ * TagAbiCodec.decode("uint256", encodedBytes); // → 123n (BigInt)
135
+ * TagAbiCodec.decode("tuple(string,uint8)", encodedBytes); // → ["Alice", 30n]
136
+ */
137
+ static decode(abiType, encodedData) {
138
+ const decoded = this.abiCoder.decode([abiType], encodedData);
139
+ return decoded[0];
140
+ }
141
+ }
142
+ exports.TagAbiCodec = TagAbiCodec;
143
+ TagAbiCodec.abiCoder = new ethers_1.AbiCoder();
144
+ //# sourceMappingURL=tag-abi-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-abi-codec.js","sourceRoot":"","sources":["../../src/utils/tag-abi-codec.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,MAAa,WAAW;IAGvB;;;;OAIG;IACK,MAAM,CAAC,gBAAgB,CAAC,OAAe;QAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,0BAA0B;QACnE,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,YAAY,GAAG,EAAE,CAA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AC,OAAe,EAAE,WAAmB;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;QAC7D,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;;AAhJF,kCAiJC;AAhJe,oBAAQ,GAAG,IAAI,iBAAQ,EAAE,CAAC"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Tag Type Builder
3
+ * Calculate ABI type bytes offline without contract calls
4
+ * Does NOT handle encoding/decoding - use TagAbiCodec for that
5
+ *
6
+ * Encoding Rules:
7
+ * - uint: 0x01 + size (size = bits/8)
8
+ * - int: 0x00 + size
9
+ * - bool: 0x02
10
+ * - string: 0x03
11
+ * - array: 0x04 + elementType
12
+ * - fixedArray: 0x05 + length (2 bytes) + elementType
13
+ * - tuple: 0x06 + fieldCount (2 bytes) + fieldTypes...
14
+ * - address: 0x07
15
+ * - fixedBytes: 0x08 + size
16
+ * - bytes: 0x09
17
+ */
18
+ export declare class TagTypeBuilder {
19
+ private typeBytes;
20
+ private abiTypeString;
21
+ protected constructor(typeBytes: string, abiTypeString?: string);
22
+ /**
23
+ * Get ABI type bytes (without 0x prefix)
24
+ */
25
+ getTypeBytes(): string;
26
+ /**
27
+ * Get ABI type string (e.g., "string", "uint256", "tuple(string,uint8)")
28
+ */
29
+ getAbiTypeString(): string;
30
+ /**
31
+ * Parse type bytes to ABI type string
32
+ * This is the reverse operation of building type bytes
33
+ * @param typeBytes Hex string of type bytes (with or without 0x prefix)
34
+ * @returns ABI type string
35
+ */
36
+ static parseTypeBytesToAbiString(typeBytes: string): string;
37
+ /**
38
+ * Calculate the byte length of a type bytes string (without 0x prefix)
39
+ * @private
40
+ */
41
+ private static getTypeBytesLength;
42
+ /**
43
+ * Get field names (for Tuple types)
44
+ * Returns format: string[][], each element is a tuple's field name array
45
+ */
46
+ getFieldNames(): string[][];
47
+ /**
48
+ * uint type
49
+ * @param bits Bit count: 8, 16, 24, ..., 256 (must be divisible by 8)
50
+ * @example
51
+ * TagTypeBuilder.uint(8) → "0101"
52
+ * TagTypeBuilder.uint(256) → "0120"
53
+ */
54
+ static uint(bits?: number): TagTypeBuilder;
55
+ /**
56
+ * int type
57
+ * @param bits Bit count: 8, 16, 24, ..., 256 (must be divisible by 8)
58
+ * @example
59
+ * TagTypeBuilder.int(8) → "0001"
60
+ * TagTypeBuilder.int(256) → "0020"
61
+ */
62
+ static int(bits?: number): TagTypeBuilder;
63
+ /**
64
+ * bool type
65
+ * @example
66
+ * TagTypeBuilder.bool() → "02"
67
+ */
68
+ static bool(): TagTypeBuilder;
69
+ /**
70
+ * string type
71
+ * @example
72
+ * TagTypeBuilder.string() → "03"
73
+ */
74
+ static string(): TagTypeBuilder;
75
+ /**
76
+ * address type
77
+ * @example
78
+ * TagTypeBuilder.address() → "07"
79
+ */
80
+ static address(): TagTypeBuilder;
81
+ /**
82
+ * bytes type (dynamic length)
83
+ * @example
84
+ * TagTypeBuilder.bytes() → "09"
85
+ */
86
+ static bytes(): TagTypeBuilder;
87
+ /**
88
+ * bytesN type (fixed length)
89
+ * @param size Byte count: 1-32
90
+ * @example
91
+ * TagTypeBuilder.fixedBytes(32) → "0820"
92
+ */
93
+ static fixedBytes(size: number): TagTypeBuilder;
94
+ /**
95
+ * Dynamic array
96
+ * @param elementType Element type
97
+ * @example
98
+ * TagTypeBuilder.array(TagTypeBuilder.address()) → "0407"
99
+ */
100
+ static array(elementType: TagTypeBuilder): TagTypeBuilder;
101
+ /**
102
+ * Fixed-length array
103
+ * @param elementType Element type
104
+ * @param length Array length (1-65535)
105
+ * @example
106
+ * TagTypeBuilder.fixedArray(TagTypeBuilder.address(), 5) → "05000507"
107
+ */
108
+ static fixedArray(elementType: TagTypeBuilder, length: number): TagTypeBuilder;
109
+ /**
110
+ * tuple type
111
+ * @param fields Field definitions, format: { fieldName: fieldType }
112
+ * @example
113
+ * TagTypeBuilder.tuple({
114
+ * name: TagTypeBuilder.string(),
115
+ * age: TagTypeBuilder.uint8()
116
+ * }) → "060002" + "03" + "0101"
117
+ *
118
+ * Field names are collected in pre-order traversal (DFS pre-order) for nested tuples.
119
+ * Pre-order: Visit root first, then recursively visit children left-to-right.
120
+ *
121
+ * Example tree structure: A{B{D{E, F}}, C}
122
+ * fieldNames = [
123
+ * ["i", "j"], // A's fields (root)
124
+ * ["i"], // B's fields (A's 1st child)
125
+ * ["i", "j"], // D's fields (B's child)
126
+ * ["i", "j"], // E's fields (D's 1st child)
127
+ * ["i", "j"], // F's fields (D's 2nd child)
128
+ * ["i"] // C's fields (A's 2nd child)
129
+ * ]
130
+ */
131
+ static tuple(fields: Record<string, TagTypeBuilder>): TupleTypeBuilder;
132
+ static uint8(): TagTypeBuilder;
133
+ static uint16(): TagTypeBuilder;
134
+ static uint32(): TagTypeBuilder;
135
+ static uint64(): TagTypeBuilder;
136
+ static uint128(): TagTypeBuilder;
137
+ static uint256(): TagTypeBuilder;
138
+ static int8(): TagTypeBuilder;
139
+ static int16(): TagTypeBuilder;
140
+ static int32(): TagTypeBuilder;
141
+ static int64(): TagTypeBuilder;
142
+ static int128(): TagTypeBuilder;
143
+ static int256(): TagTypeBuilder;
144
+ static bytes32(): TagTypeBuilder;
145
+ static addressArray(): TagTypeBuilder;
146
+ static stringArray(): TagTypeBuilder;
147
+ static uint256Array(): TagTypeBuilder;
148
+ }
149
+ /**
150
+ * Tuple Type Builder (supports field names and object encoding)
151
+ */
152
+ export declare class TupleTypeBuilder extends TagTypeBuilder {
153
+ private fieldNames;
154
+ private fieldTypes?;
155
+ constructor(typeBytes: string, fieldNames: string[][], abiTypeString?: string, fieldTypes?: Record<string, TagTypeBuilder>);
156
+ getFieldNames(): string[][];
157
+ }
158
+ //# sourceMappingURL=tag-type-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag-type-builder.d.ts","sourceRoot":"","sources":["../../src/utils/tag-type-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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