@cds.id/podoru-sdk 1.1.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 (154) hide show
  1. package/README.md +155 -0
  2. package/dist/cjs/client/PodoruClient.js +153 -0
  3. package/dist/cjs/client/PodoruClient.js.map +1 -0
  4. package/dist/cjs/client/WebSocketClient.js +193 -0
  5. package/dist/cjs/client/WebSocketClient.js.map +1 -0
  6. package/dist/cjs/client/index.js +8 -0
  7. package/dist/cjs/client/index.js.map +1 -0
  8. package/dist/cjs/errors/index.js +78 -0
  9. package/dist/cjs/errors/index.js.map +1 -0
  10. package/dist/cjs/index.js +33 -0
  11. package/dist/cjs/index.js.map +1 -0
  12. package/dist/cjs/transaction/Signer.js +82 -0
  13. package/dist/cjs/transaction/Signer.js.map +1 -0
  14. package/dist/cjs/transaction/TransactionBuilder.js +127 -0
  15. package/dist/cjs/transaction/TransactionBuilder.js.map +1 -0
  16. package/dist/cjs/transaction/index.js +9 -0
  17. package/dist/cjs/transaction/index.js.map +1 -0
  18. package/dist/cjs/types/api.js +3 -0
  19. package/dist/cjs/types/api.js.map +1 -0
  20. package/dist/cjs/types/chain.js +3 -0
  21. package/dist/cjs/types/chain.js.map +1 -0
  22. package/dist/cjs/types/events.js +3 -0
  23. package/dist/cjs/types/events.js.map +1 -0
  24. package/dist/cjs/types/index.js +3 -0
  25. package/dist/cjs/types/index.js.map +1 -0
  26. package/dist/cjs/types/node.js +3 -0
  27. package/dist/cjs/types/node.js.map +1 -0
  28. package/dist/cjs/types/state.js +3 -0
  29. package/dist/cjs/types/state.js.map +1 -0
  30. package/dist/cjs/types/transaction.js +3 -0
  31. package/dist/cjs/types/transaction.js.map +1 -0
  32. package/dist/cjs/utils/address.js +36 -0
  33. package/dist/cjs/utils/address.js.map +1 -0
  34. package/dist/cjs/utils/encoding.js +49 -0
  35. package/dist/cjs/utils/encoding.js.map +1 -0
  36. package/dist/cjs/utils/hash.js +28 -0
  37. package/dist/cjs/utils/hash.js.map +1 -0
  38. package/dist/cjs/utils/index.js +17 -0
  39. package/dist/cjs/utils/index.js.map +1 -0
  40. package/dist/esm/client/PodoruClient.d.ts +79 -0
  41. package/dist/esm/client/PodoruClient.d.ts.map +1 -0
  42. package/dist/esm/client/PodoruClient.js +149 -0
  43. package/dist/esm/client/PodoruClient.js.map +1 -0
  44. package/dist/esm/client/WebSocketClient.d.ts +89 -0
  45. package/dist/esm/client/WebSocketClient.d.ts.map +1 -0
  46. package/dist/esm/client/WebSocketClient.js +189 -0
  47. package/dist/esm/client/WebSocketClient.js.map +1 -0
  48. package/dist/esm/client/index.d.ts +5 -0
  49. package/dist/esm/client/index.d.ts.map +1 -0
  50. package/dist/esm/client/index.js +3 -0
  51. package/dist/esm/client/index.js.map +1 -0
  52. package/dist/esm/errors/index.d.ts +41 -0
  53. package/dist/esm/errors/index.d.ts.map +1 -0
  54. package/dist/esm/errors/index.js +69 -0
  55. package/dist/esm/errors/index.js.map +1 -0
  56. package/dist/esm/index.d.ts +8 -0
  57. package/dist/esm/index.d.ts.map +1 -0
  58. package/dist/esm/index.js +9 -0
  59. package/dist/esm/index.js.map +1 -0
  60. package/dist/esm/transaction/Signer.d.ts +48 -0
  61. package/dist/esm/transaction/Signer.d.ts.map +1 -0
  62. package/dist/esm/transaction/Signer.js +77 -0
  63. package/dist/esm/transaction/Signer.js.map +1 -0
  64. package/dist/esm/transaction/TransactionBuilder.d.ts +44 -0
  65. package/dist/esm/transaction/TransactionBuilder.d.ts.map +1 -0
  66. package/dist/esm/transaction/TransactionBuilder.js +123 -0
  67. package/dist/esm/transaction/TransactionBuilder.js.map +1 -0
  68. package/dist/esm/transaction/index.d.ts +4 -0
  69. package/dist/esm/transaction/index.d.ts.map +1 -0
  70. package/dist/esm/transaction/index.js +3 -0
  71. package/dist/esm/transaction/index.js.map +1 -0
  72. package/dist/esm/types/api.d.ts +16 -0
  73. package/dist/esm/types/api.d.ts.map +1 -0
  74. package/dist/esm/types/api.js +2 -0
  75. package/dist/esm/types/api.js.map +1 -0
  76. package/dist/esm/types/chain.d.ts +32 -0
  77. package/dist/esm/types/chain.d.ts.map +1 -0
  78. package/dist/esm/types/chain.js +2 -0
  79. package/dist/esm/types/chain.js.map +1 -0
  80. package/dist/esm/types/events.d.ts +58 -0
  81. package/dist/esm/types/events.d.ts.map +1 -0
  82. package/dist/esm/types/events.js +2 -0
  83. package/dist/esm/types/events.js.map +1 -0
  84. package/dist/esm/types/index.d.ts +7 -0
  85. package/dist/esm/types/index.d.ts.map +1 -0
  86. package/dist/esm/types/index.js +2 -0
  87. package/dist/esm/types/index.js.map +1 -0
  88. package/dist/esm/types/node.d.ts +32 -0
  89. package/dist/esm/types/node.d.ts.map +1 -0
  90. package/dist/esm/types/node.js +2 -0
  91. package/dist/esm/types/node.js.map +1 -0
  92. package/dist/esm/types/state.d.ts +23 -0
  93. package/dist/esm/types/state.d.ts.map +1 -0
  94. package/dist/esm/types/state.js +2 -0
  95. package/dist/esm/types/state.js.map +1 -0
  96. package/dist/esm/types/transaction.d.ts +39 -0
  97. package/dist/esm/types/transaction.d.ts.map +1 -0
  98. package/dist/esm/types/transaction.js +2 -0
  99. package/dist/esm/types/transaction.js.map +1 -0
  100. package/dist/esm/utils/address.d.ts +14 -0
  101. package/dist/esm/utils/address.d.ts.map +1 -0
  102. package/dist/esm/utils/address.js +31 -0
  103. package/dist/esm/utils/address.js.map +1 -0
  104. package/dist/esm/utils/encoding.d.ts +21 -0
  105. package/dist/esm/utils/encoding.d.ts.map +1 -0
  106. package/dist/esm/utils/encoding.js +42 -0
  107. package/dist/esm/utils/encoding.js.map +1 -0
  108. package/dist/esm/utils/hash.d.ts +9 -0
  109. package/dist/esm/utils/hash.d.ts.map +1 -0
  110. package/dist/esm/utils/hash.js +24 -0
  111. package/dist/esm/utils/hash.js.map +1 -0
  112. package/dist/esm/utils/index.d.ts +4 -0
  113. package/dist/esm/utils/index.d.ts.map +1 -0
  114. package/dist/esm/utils/index.js +4 -0
  115. package/dist/esm/utils/index.js.map +1 -0
  116. package/dist/types/client/PodoruClient.d.ts +79 -0
  117. package/dist/types/client/PodoruClient.d.ts.map +1 -0
  118. package/dist/types/client/WebSocketClient.d.ts +89 -0
  119. package/dist/types/client/WebSocketClient.d.ts.map +1 -0
  120. package/dist/types/client/index.d.ts +5 -0
  121. package/dist/types/client/index.d.ts.map +1 -0
  122. package/dist/types/errors/index.d.ts +41 -0
  123. package/dist/types/errors/index.d.ts.map +1 -0
  124. package/dist/types/index.d.ts +8 -0
  125. package/dist/types/index.d.ts.map +1 -0
  126. package/dist/types/transaction/Signer.d.ts +48 -0
  127. package/dist/types/transaction/Signer.d.ts.map +1 -0
  128. package/dist/types/transaction/TransactionBuilder.d.ts +44 -0
  129. package/dist/types/transaction/TransactionBuilder.d.ts.map +1 -0
  130. package/dist/types/transaction/index.d.ts +4 -0
  131. package/dist/types/transaction/index.d.ts.map +1 -0
  132. package/dist/types/types/api.d.ts +16 -0
  133. package/dist/types/types/api.d.ts.map +1 -0
  134. package/dist/types/types/chain.d.ts +32 -0
  135. package/dist/types/types/chain.d.ts.map +1 -0
  136. package/dist/types/types/events.d.ts +58 -0
  137. package/dist/types/types/events.d.ts.map +1 -0
  138. package/dist/types/types/index.d.ts +7 -0
  139. package/dist/types/types/index.d.ts.map +1 -0
  140. package/dist/types/types/node.d.ts +32 -0
  141. package/dist/types/types/node.d.ts.map +1 -0
  142. package/dist/types/types/state.d.ts +23 -0
  143. package/dist/types/types/state.d.ts.map +1 -0
  144. package/dist/types/types/transaction.d.ts +39 -0
  145. package/dist/types/types/transaction.d.ts.map +1 -0
  146. package/dist/types/utils/address.d.ts +14 -0
  147. package/dist/types/utils/address.d.ts.map +1 -0
  148. package/dist/types/utils/encoding.d.ts +21 -0
  149. package/dist/types/utils/encoding.d.ts.map +1 -0
  150. package/dist/types/utils/hash.d.ts +9 -0
  151. package/dist/types/utils/hash.d.ts.map +1 -0
  152. package/dist/types/utils/index.d.ts +4 -0
  153. package/dist/types/utils/index.d.ts.map +1 -0
  154. package/package.json +69 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Signer.d.ts","sourceRoot":"","sources":["../../../src/transaction/Signer.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,qBAAa,YAAa,YAAW,MAAM;IACzC,OAAO,CAAC,MAAM,CAAwB;gBAE1B,UAAU,EAAE,MAAM;IAQ9B;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;IAUlE;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,YAAY;IAKnC;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;CAcvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,EAAE,CAMjE"}
@@ -0,0 +1,77 @@
1
+ import { Wallet, HDNodeWallet } from 'ethers';
2
+ import { SigningError } from '../errors/index.js';
3
+ import { hexToBytes } from '../utils/encoding.js';
4
+ /**
5
+ * Wallet-based signer using ethers.js
6
+ */
7
+ export class WalletSigner {
8
+ wallet;
9
+ constructor(privateKey) {
10
+ try {
11
+ this.wallet = new Wallet(privateKey);
12
+ }
13
+ catch (error) {
14
+ throw new SigningError(`Invalid private key: ${error instanceof Error ? error.message : 'unknown error'}`);
15
+ }
16
+ }
17
+ /**
18
+ * Create a signer from a mnemonic phrase
19
+ */
20
+ static fromMnemonic(mnemonic, path) {
21
+ try {
22
+ const wallet = HDNodeWallet.fromPhrase(mnemonic, undefined, path);
23
+ const signer = new WalletSigner(wallet.privateKey);
24
+ return signer;
25
+ }
26
+ catch (error) {
27
+ throw new SigningError(`Invalid mnemonic: ${error instanceof Error ? error.message : 'unknown error'}`);
28
+ }
29
+ }
30
+ /**
31
+ * Create a random signer (for testing)
32
+ */
33
+ static createRandom() {
34
+ const wallet = Wallet.createRandom();
35
+ return new WalletSigner(wallet.privateKey);
36
+ }
37
+ /**
38
+ * Get the signer's address
39
+ */
40
+ get address() {
41
+ return this.wallet.address;
42
+ }
43
+ /**
44
+ * Get the private key (use with caution)
45
+ */
46
+ get privateKey() {
47
+ return this.wallet.privateKey;
48
+ }
49
+ /**
50
+ * Sign a hash and return the signature components
51
+ */
52
+ async sign(hash) {
53
+ try {
54
+ const hashHex = '0x' + Array.from(hash).map(b => b.toString(16).padStart(2, '0')).join('');
55
+ const signature = this.wallet.signingKey.sign(hashHex);
56
+ return {
57
+ r: signature.r,
58
+ s: signature.s,
59
+ v: signature.v,
60
+ };
61
+ }
62
+ catch (error) {
63
+ throw new SigningError(`Failed to sign: ${error instanceof Error ? error.message : 'unknown error'}`);
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * Serialize signature to 65-byte array (r + s + v)
69
+ * v is normalized to 0 or 1 (not 27/28)
70
+ */
71
+ export function serializeSignature(sig) {
72
+ const r = hexToBytes(sig.r); // 32 bytes
73
+ const s = hexToBytes(sig.s); // 32 bytes
74
+ const v = sig.v - 27; // Normalize to 0 or 1
75
+ return [...Array.from(r), ...Array.from(s), v];
76
+ }
77
+ //# sourceMappingURL=Signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Signer.js","sourceRoot":"","sources":["../../../src/transaction/Signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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jD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { Operation, Transaction, UnsignedTransaction } from '../types/transaction.js';
2
+ import { Signer } from './Signer.js';
3
+ /**
4
+ * Builder for creating and signing transactions
5
+ */
6
+ export declare class TransactionBuilder {
7
+ private from;
8
+ private operations;
9
+ private _nonce?;
10
+ private _timestamp?;
11
+ constructor(from: string);
12
+ /**
13
+ * Add a SET operation
14
+ * @param key - The key to set
15
+ * @param value - The value (string or Buffer)
16
+ */
17
+ set(key: string, value: string | Uint8Array): TransactionBuilder;
18
+ /**
19
+ * Add a DELETE operation
20
+ * @param key - The key to delete
21
+ */
22
+ delete(key: string): TransactionBuilder;
23
+ /**
24
+ * Add a raw operation
25
+ */
26
+ addOperation(op: Operation): TransactionBuilder;
27
+ /**
28
+ * Set a custom nonce (defaults to Date.now())
29
+ */
30
+ withNonce(nonce: number): TransactionBuilder;
31
+ /**
32
+ * Set a custom timestamp (defaults to current Unix timestamp)
33
+ */
34
+ withTimestamp(timestamp: number): TransactionBuilder;
35
+ /**
36
+ * Build an unsigned transaction
37
+ */
38
+ build(): UnsignedTransaction;
39
+ /**
40
+ * Build and sign the transaction
41
+ */
42
+ buildAndSign(signer: Signer): Promise<Transaction>;
43
+ }
44
+ //# sourceMappingURL=TransactionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/transaction/TransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAmB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAK5G,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AAEzD;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAS;gBAEhB,IAAI,EAAE,MAAM;IAOxB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,kBAAkB;IAahE;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IAWvC;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,kBAAkB;IAK/C;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAK5C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB;IAKpD;;OAEG;IACH,KAAK,IAAI,mBAAmB;IAoB5B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzD"}
@@ -0,0 +1,123 @@
1
+ import { ValidationError } from '../errors/index.js';
2
+ import { base64Encode } from '../utils/encoding.js';
3
+ import { sha256 } from '../utils/hash.js';
4
+ import { isValidAddress } from '../utils/address.js';
5
+ import { serializeSignature } from './Signer.js';
6
+ /**
7
+ * Builder for creating and signing transactions
8
+ */
9
+ export class TransactionBuilder {
10
+ from;
11
+ operations = [];
12
+ _nonce;
13
+ _timestamp;
14
+ constructor(from) {
15
+ if (!isValidAddress(from)) {
16
+ throw new ValidationError(`Invalid address: ${from}`);
17
+ }
18
+ this.from = from;
19
+ }
20
+ /**
21
+ * Add a SET operation
22
+ * @param key - The key to set
23
+ * @param value - The value (string or Buffer)
24
+ */
25
+ set(key, value) {
26
+ if (!key) {
27
+ throw new ValidationError('Key cannot be empty');
28
+ }
29
+ const encodedValue = base64Encode(value);
30
+ this.operations.push({
31
+ type: 'SET',
32
+ key,
33
+ value: encodedValue,
34
+ });
35
+ return this;
36
+ }
37
+ /**
38
+ * Add a DELETE operation
39
+ * @param key - The key to delete
40
+ */
41
+ delete(key) {
42
+ if (!key) {
43
+ throw new ValidationError('Key cannot be empty');
44
+ }
45
+ this.operations.push({
46
+ type: 'DELETE',
47
+ key,
48
+ });
49
+ return this;
50
+ }
51
+ /**
52
+ * Add a raw operation
53
+ */
54
+ addOperation(op) {
55
+ this.operations.push(op);
56
+ return this;
57
+ }
58
+ /**
59
+ * Set a custom nonce (defaults to Date.now())
60
+ */
61
+ withNonce(nonce) {
62
+ this._nonce = nonce;
63
+ return this;
64
+ }
65
+ /**
66
+ * Set a custom timestamp (defaults to current Unix timestamp)
67
+ */
68
+ withTimestamp(timestamp) {
69
+ this._timestamp = timestamp;
70
+ return this;
71
+ }
72
+ /**
73
+ * Build an unsigned transaction
74
+ */
75
+ build() {
76
+ if (this.operations.length === 0) {
77
+ throw new ValidationError('Transaction must have at least one operation');
78
+ }
79
+ const timestamp = this._timestamp ?? Math.floor(Date.now() / 1000);
80
+ const nonce = this._nonce ?? Date.now();
81
+ const data = {
82
+ operations: this.operations,
83
+ };
84
+ return {
85
+ from: this.from,
86
+ timestamp,
87
+ data,
88
+ nonce,
89
+ };
90
+ }
91
+ /**
92
+ * Build and sign the transaction
93
+ */
94
+ async buildAndSign(signer) {
95
+ // Verify signer address matches
96
+ if (signer.address.toLowerCase() !== this.from.toLowerCase()) {
97
+ throw new ValidationError(`Signer address ${signer.address} does not match transaction from address ${this.from}`);
98
+ }
99
+ const unsigned = this.build();
100
+ // Compute hash: SHA256 of JSON stringified transaction
101
+ // Order must be: from, timestamp, data, nonce (to match Go implementation)
102
+ const hashData = {
103
+ from: unsigned.from,
104
+ timestamp: unsigned.timestamp,
105
+ data: unsigned.data,
106
+ nonce: unsigned.nonce,
107
+ };
108
+ const hashString = JSON.stringify(hashData);
109
+ const hash = sha256(hashString);
110
+ // Sign the hash
111
+ const signatureResult = await signer.sign(hash);
112
+ const signature = serializeSignature(signatureResult);
113
+ return {
114
+ id: Array.from(hash),
115
+ from: unsigned.from,
116
+ timestamp: unsigned.timestamp,
117
+ data: unsigned.data,
118
+ nonce: unsigned.nonce,
119
+ signature,
120
+ };
121
+ }
122
+ }
123
+ //# sourceMappingURL=TransactionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionBuilder.js","sourceRoot":"","sources":["../../../src/transaction/TransactionBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAU,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACrB,IAAI,CAAS;IACb,UAAU,GAAgB,EAAE,CAAC;IAC7B,MAAM,CAAU;IAChB,UAAU,CAAU;IAE5B,YAAY,IAAY;QACtB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,eAAe,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,GAAW,EAAE,KAA0B;QACzC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,eAAe,CAAC,qBAAqB,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,KAAK;YACX,GAAG;YACH,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,eAAe,CAAC,qBAAqB,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,IAAI,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H,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAE9B,uDAAuD;QACvD,2EAA2E;QAC3E,MAAM,QAAQ,GAAG;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;SACtB,CAAC;QACF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QAEhC,gBAAgB;QAChB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;QAEtD,OAAO;YACL,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YACpB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,SAAS;SACV,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { WalletSigner, serializeSignature } from './Signer.js';
2
+ export type { Signer, SignatureResult } from './Signer.js';
3
+ export { TransactionBuilder } from './TransactionBuilder.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC/D,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { WalletSigner, serializeSignature } from './Signer.js';
2
+ export { TransactionBuilder } from './TransactionBuilder.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Standard API response wrapper
3
+ */
4
+ export interface ApiResponse<T> {
5
+ success: boolean;
6
+ data?: T;
7
+ error?: string;
8
+ }
9
+ /**
10
+ * Response from transaction submission
11
+ */
12
+ export interface SubmitTransactionResponse {
13
+ transaction_hash: string;
14
+ status: 'submitted';
15
+ }
16
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/types/api.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import type { Transaction } from './transaction.js';
2
+ /**
3
+ * Blockchain metadata
4
+ */
5
+ export interface ChainInfo {
6
+ height: number;
7
+ current_hash: string;
8
+ genesis_hash: string;
9
+ authorities: string[];
10
+ }
11
+ /**
12
+ * Block header information
13
+ */
14
+ export interface BlockHeader {
15
+ version: number;
16
+ height: number;
17
+ previous_hash: string;
18
+ timestamp: number;
19
+ merkle_root: string;
20
+ state_root: string;
21
+ producer_addr: string;
22
+ nonce: number;
23
+ }
24
+ /**
25
+ * Complete block with transactions
26
+ */
27
+ export interface Block {
28
+ header: BlockHeader;
29
+ transactions: Transaction[];
30
+ signature: string;
31
+ }
32
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * WebSocket event types
3
+ */
4
+ export type EventType = 'new_block' | 'new_transaction' | 'chain_update' | 'mempool_update';
5
+ /**
6
+ * New block event data
7
+ */
8
+ export interface BlockEvent {
9
+ height: number;
10
+ hash: string;
11
+ timestamp: number;
12
+ transaction_count: number;
13
+ producer: string;
14
+ previous_hash: string;
15
+ }
16
+ /**
17
+ * New transaction event data
18
+ */
19
+ export interface TransactionEvent {
20
+ hash: string;
21
+ from: string;
22
+ timestamp: number;
23
+ status: 'pending' | 'confirmed';
24
+ nonce: number;
25
+ }
26
+ /**
27
+ * Chain update event data
28
+ */
29
+ export interface ChainUpdateEvent {
30
+ height: number;
31
+ current_hash: string;
32
+ authorities: string[];
33
+ }
34
+ /**
35
+ * Mempool update event data
36
+ */
37
+ export interface MempoolUpdateEvent {
38
+ count: number;
39
+ recent_hashes: string[];
40
+ }
41
+ /**
42
+ * Generic WebSocket event wrapper
43
+ */
44
+ export interface WebSocketEvent<T = unknown> {
45
+ type: EventType;
46
+ data: T;
47
+ timestamp: number;
48
+ }
49
+ /**
50
+ * Map event types to their data types
51
+ */
52
+ export interface EventDataMap {
53
+ new_block: BlockEvent;
54
+ new_transaction: TransactionEvent;
55
+ chain_update: ChainUpdateEvent;
56
+ mempool_update: MempoolUpdateEvent;
57
+ }
58
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,UAAU,CAAC;IACtB,eAAe,EAAE,gBAAgB,CAAC;IAClC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,kBAAkB,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/types/events.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export type { ApiResponse, SubmitTransactionResponse } from './api.js';
2
+ export type { ChainInfo, BlockHeader, Block } from './chain.js';
3
+ export type { OperationType, Operation, TransactionData, Transaction, UnsignedTransaction, } from './transaction.js';
4
+ export type { StateEntry, PrefixQueryResult, StateValueResponse } from './state.js';
5
+ export type { NodeInfo, Peer, MempoolInfo, HealthResponse } from './node.js';
6
+ export type { EventType, BlockEvent, TransactionEvent, ChainUpdateEvent, MempoolUpdateEvent, WebSocketEvent, EventDataMap, } from './events.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGvE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGhE,YAAY,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGpF,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG7E,YAAY,EACV,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import type { Transaction } from './transaction.js';
2
+ /**
3
+ * Node information
4
+ */
5
+ export interface NodeInfo {
6
+ version: string;
7
+ node_type: string;
8
+ address: string;
9
+ p2p_address: string;
10
+ }
11
+ /**
12
+ * Connected peer information
13
+ */
14
+ export interface Peer {
15
+ id: string;
16
+ address: string;
17
+ connected_at: number;
18
+ }
19
+ /**
20
+ * Mempool information with pending transactions
21
+ */
22
+ export interface MempoolInfo {
23
+ count: number;
24
+ transactions: Transaction[];
25
+ }
26
+ /**
27
+ * Health check response
28
+ */
29
+ export interface HealthResponse {
30
+ status: string;
31
+ }
32
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/types/node.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Single state entry
3
+ */
4
+ export interface StateEntry {
5
+ key: string;
6
+ value: string;
7
+ }
8
+ /**
9
+ * Result of a prefix query
10
+ */
11
+ export interface PrefixQueryResult {
12
+ prefix: string;
13
+ count: number;
14
+ results: Record<string, string>;
15
+ }
16
+ /**
17
+ * State value response
18
+ */
19
+ export interface StateValueResponse {
20
+ key: string;
21
+ value: string;
22
+ }
23
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/types/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/types/state.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Operation type for key-value store
3
+ */
4
+ export type OperationType = 'SET' | 'DELETE';
5
+ /**
6
+ * Single operation on the key-value store
7
+ */
8
+ export interface Operation {
9
+ type: OperationType;
10
+ key: string;
11
+ value?: string;
12
+ }
13
+ /**
14
+ * Transaction data containing operations
15
+ */
16
+ export interface TransactionData {
17
+ operations: Operation[];
18
+ }
19
+ /**
20
+ * Complete signed transaction
21
+ */
22
+ export interface Transaction {
23
+ id: number[];
24
+ from: string;
25
+ timestamp: number;
26
+ data: TransactionData;
27
+ signature: number[];
28
+ nonce: number;
29
+ }
30
+ /**
31
+ * Unsigned transaction (before signing)
32
+ */
33
+ export interface UnsignedTransaction {
34
+ from: string;
35
+ timestamp: number;
36
+ data: TransactionData;
37
+ nonce: number;
38
+ }
39
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/types/transaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/types/transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if a string is a valid Ethereum-style address
3
+ */
4
+ export declare function isValidAddress(address: string): boolean;
5
+ /**
6
+ * Normalize an address to checksum format
7
+ * For now, just lowercases the hex part
8
+ */
9
+ export declare function normalizeAddress(address: string): string;
10
+ /**
11
+ * Compare two addresses for equality (case-insensitive)
12
+ */
13
+ export declare function addressEquals(a: string, b: string): boolean;
14
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAE3D"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Check if a string is a valid Ethereum-style address
3
+ */
4
+ export function isValidAddress(address) {
5
+ if (!address.startsWith('0x')) {
6
+ return false;
7
+ }
8
+ if (address.length !== 42) {
9
+ return false;
10
+ }
11
+ // Check if it's valid hex
12
+ const hexPart = address.slice(2);
13
+ return /^[0-9a-fA-F]+$/.test(hexPart);
14
+ }
15
+ /**
16
+ * Normalize an address to checksum format
17
+ * For now, just lowercases the hex part
18
+ */
19
+ export function normalizeAddress(address) {
20
+ if (!isValidAddress(address)) {
21
+ throw new Error(`Invalid address: ${address}`);
22
+ }
23
+ return address.toLowerCase();
24
+ }
25
+ /**
26
+ * Compare two addresses for equality (case-insensitive)
27
+ */
28
+ export function addressEquals(a, b) {
29
+ return normalizeAddress(a) === normalizeAddress(b);
30
+ }
31
+ //# sourceMappingURL=address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/utils/address.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,0BAA0B;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS;IAChD,OAAO,gBAAgB,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}