@trufnetwork/sdk-js 0.2.1 → 0.2.4

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 (41) hide show
  1. package/README.md +6 -1
  2. package/dist/cjs/client/client.cjs +4 -2
  3. package/dist/cjs/client/client.cjs.map +2 -2
  4. package/dist/cjs/contracts/composed_stream_template_unix.json +2122 -0
  5. package/dist/cjs/contracts/contractsContent.cjs +13 -1
  6. package/dist/cjs/contracts/contractsContent.cjs.map +3 -3
  7. package/dist/cjs/contracts/primitive_stream_template_unix.json +1173 -0
  8. package/dist/cjs/contracts-api/composedStream.cjs.map +2 -2
  9. package/dist/cjs/contracts-api/deployStream.cjs +4 -4
  10. package/dist/cjs/contracts-api/deployStream.cjs.map +2 -2
  11. package/dist/cjs/contracts-api/primitiveStream.cjs.map +1 -1
  12. package/dist/cjs/contracts-api/stream.cjs +48 -0
  13. package/dist/cjs/contracts-api/stream.cjs.map +2 -2
  14. package/dist/esm/client/client.mjs +4 -2
  15. package/dist/esm/client/client.mjs.map +2 -2
  16. package/dist/esm/contracts/composed_stream_template_unix.json +2122 -0
  17. package/dist/esm/contracts/contractsContent.mjs +13 -1
  18. package/dist/esm/contracts/contractsContent.mjs.map +2 -2
  19. package/dist/esm/contracts/primitive_stream_template_unix.json +1173 -0
  20. package/dist/esm/contracts-api/composedStream.mjs.map +2 -2
  21. package/dist/esm/contracts-api/deployStream.mjs +7 -5
  22. package/dist/esm/contracts-api/deployStream.mjs.map +2 -2
  23. package/dist/esm/contracts-api/primitiveStream.mjs.map +1 -1
  24. package/dist/esm/contracts-api/stream.mjs +48 -0
  25. package/dist/esm/contracts-api/stream.mjs.map +2 -2
  26. package/dist/tsconfig.build.tsbuildinfo +1 -1
  27. package/dist/types/client/client.d.ts +2 -1
  28. package/dist/types/client/client.d.ts.map +1 -1
  29. package/dist/types/client/listAllStreams.d.ts.map +1 -1
  30. package/dist/types/contracts/contractsContent.d.ts +3 -1
  31. package/dist/types/contracts/contractsContent.d.ts.map +1 -1
  32. package/dist/types/contracts-api/composedStream.d.ts +1 -1
  33. package/dist/types/contracts-api/composedStream.d.ts.map +1 -1
  34. package/dist/types/contracts-api/deployStream.d.ts +1 -0
  35. package/dist/types/contracts-api/deployStream.d.ts.map +1 -1
  36. package/dist/types/contracts-api/primitiveStream.d.ts +1 -1
  37. package/dist/types/contracts-api/primitiveStream.d.ts.map +1 -1
  38. package/dist/types/contracts-api/stream.d.ts +26 -6
  39. package/dist/types/contracts-api/stream.d.ts.map +1 -1
  40. package/dist/types/util/visibility.d.ts.map +1 -1
  41. package/package.json +9 -8
package/README.md CHANGED
@@ -27,6 +27,10 @@ import { BrowserTNClient } from "@trufnetwork/sdk-js";
27
27
 
28
28
  ```ts
29
29
  import { NodeTNClient, StreamId } from "@trufnetwork/sdk-js";
30
+ import { Wallet } from "ethers";
31
+
32
+ // Create a wallet
33
+ const wallet = new Wallet("0000000000000000000000000000000000000000000000000000000000000001");
30
34
 
31
35
  // Initialize client
32
36
  const client = new NodeTNClient({
@@ -35,7 +39,7 @@ const client = new NodeTNClient({
35
39
  address: wallet.address,
36
40
  signer: wallet, // Any object that implements signMessage
37
41
  },
38
- chainId: "tsn-1", // or use NodeTNClient.getDefaultChainId()
42
+ chainId: "truflation-staging-2024-11-22", // or use NodeTNClient.getDefaultChainId()
39
43
  });
40
44
 
41
45
  // Deploy and initialize a stream
@@ -66,6 +70,7 @@ For a complete working example:
66
70
  - Check our [TN SDK Demo Repository](https://github.com/truflation/tsn-sdk-demo)
67
71
  - Try the [Live Demo on CodeSandbox](https://codesandbox.io/p/devbox/m2r3tt?file=%2Fsrc%2Froutes%2F%2Bpage.svelte)
68
72
  - Try reading from [a Truflation Stream on CodeSandbox with NodeJS](https://codesandbox.io/p/devbox/rtm7mn?file=%2Findex.ts%3A22%2C11)
73
+ - [**NEW**] Check out the [TN SDK JS Example Directory](./examples). It contains examples for stream deployment, stream initialization, data insertion, data retrieval, and stream destruction.
69
74
 
70
75
  ## Stream Types
71
76
 
@@ -101,15 +101,17 @@ var BaseTNClient = class {
101
101
  * @param streamId - The ID of the stream to deploy.
102
102
  * @param streamType - The type of the stream.
103
103
  * @param synchronous - Whether the deployment should be synchronous.
104
+ * @param contractVersion
104
105
  * @returns A promise that resolves to a generic response containing the transaction receipt.
105
106
  */
106
- async deployStream(streamId, streamType, synchronous) {
107
+ async deployStream(streamId, streamType, synchronous, contractVersion) {
107
108
  return await (0, import_deployStream.deployStream)({
108
109
  streamId,
109
110
  streamType,
110
111
  synchronous,
111
112
  kwilClient: this.getKwilClient(),
112
- kwilSigner: this.getKwilSigner()
113
+ kwilSigner: this.getKwilSigner(),
114
+ contractVersion
113
115
  });
114
116
  }
115
117
  /**
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/client/client.ts"],
4
- "sourcesContent": ["import { Client, KwilSigner, NodeKwil, WebKwil } from \"@kwilteam/kwil-js\";\nimport { KwilConfig } from \"@kwilteam/kwil-js/dist/api_client/config\";\nimport { Kwil } from \"@kwilteam/kwil-js/dist/client/kwil\";\nimport { EthSigner } from \"@kwilteam/kwil-js/dist/core/builders\";\nimport { EnvironmentType } from \"@kwilteam/kwil-js/dist/core/enums\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { TxInfoReceipt } from \"@kwilteam/kwil-js/dist/core/txQuery\";\nimport { ComposedStream } from \"../contracts-api/composedStream\";\nimport { deployStream } from \"../contracts-api/deployStream\";\nimport { destroyStream } from \"../contracts-api/destroyStream\";\nimport { PrimitiveStream } from \"../contracts-api/primitiveStream\";\nimport { Stream } from \"../contracts-api/stream\";\nimport { StreamType } from \"../contracts-api/contractValues\";\nimport { StreamLocator } from \"../types/stream\";\nimport { EthereumAddress } from \"../util/EthereumAddress\";\nimport { StreamId } from \"../util/StreamId\";\nimport { listAllStreams } from \"./listAllStreams\";\n\nexport interface SignerInfo {\n // we need to have the address upfront to create the KwilSigner, instead of relying on the signer to return it asynchronously\n address: string;\n signer: EthSigner;\n}\n\nexport type TNClientOptions = {\n endpoint: string;\n signerInfo: SignerInfo;\n} & Omit<KwilConfig, \"kwilProvider\">;\n\nexport abstract class BaseTNClient<T extends EnvironmentType> {\n protected kwilClient: Kwil<T> | undefined;\n protected signerInfo: SignerInfo;\n\n protected constructor(options: TNClientOptions) {\n this.signerInfo = options.signerInfo;\n }\n\n /**\n * Waits for a transaction to be mined by TN.\n * @param txHash - The transaction hash to wait for.\n * @param timeout - The timeout in milliseconds.\n * @returns A promise that resolves to the transaction info receipt.\n */\n async waitForTx(txHash: string, timeout = 12000): Promise<TxInfoReceipt> {\n return new Promise<TxInfoReceipt>(async (resolve, reject) => {\n const interval = setInterval(async () => {\n const receipt = await this.getKwilClient()\n [\"txInfoClient\"](txHash)\n .catch(() => ({ data: undefined, status: undefined }));\n switch (receipt.status) {\n case 200:\n if (receipt.data?.tx_result.log === \"success\") {\n resolve(receipt.data);\n } else {\n reject(\n new Error(\n `Transaction failed: status ${receipt.status} : log message ${receipt.data?.tx_result.log}`,\n ),\n );\n }\n break;\n case undefined:\n break;\n default:\n reject(\n new Error(\n `Transaction failed: status ${receipt.status} : log message ${receipt.data?.tx_result.log}`,\n ),\n );\n }\n }, 1000);\n setTimeout(() => {\n clearInterval(interval);\n reject(new Error(\"Transaction failed: Timeout\"));\n }, timeout);\n });\n }\n\n /**\n * Returns the Kwil signer used by the client.\n * @returns An instance of KwilSigner.\n */\n getKwilSigner(): KwilSigner {\n return new KwilSigner(\n this.signerInfo.signer,\n this.address().getAddress(),\n );\n }\n\n /**\n * Returns the Kwil client used by the client.\n * @returns An instance of Kwil.\n * @throws If the Kwil client is not initialized.\n */\n getKwilClient(): Kwil<EnvironmentType> {\n if (!this.kwilClient) {\n throw new Error(\"Kwil client not initialized\");\n }\n return this.kwilClient;\n }\n\n /**\n * Deploys a new stream.\n * @param streamId - The ID of the stream to deploy.\n * @param streamType - The type of the stream.\n * @param synchronous - Whether the deployment should be synchronous.\n * @returns A promise that resolves to a generic response containing the transaction receipt.\n */\n async deployStream(\n streamId: StreamId,\n streamType: StreamType,\n synchronous?: boolean,\n ): Promise<GenericResponse<TxReceipt>> {\n return await deployStream({\n streamId,\n streamType,\n synchronous,\n kwilClient: this.getKwilClient(),\n kwilSigner: this.getKwilSigner(),\n });\n }\n\n /**\n * Destroys a stream.\n * @param streamId - The ID of the stream to destroy.\n * @param synchronous - Whether the destruction should be synchronous.\n * @returns A promise that resolves to a generic response containing the transaction receipt.\n */\n async destroyStream(\n streamId: StreamId,\n synchronous?: boolean,\n ): Promise<GenericResponse<TxReceipt>> {\n return await destroyStream({\n streamId,\n synchronous,\n kwilClient: this.getKwilClient(),\n kwilSigner: this.getKwilSigner(),\n });\n }\n\n /**\n * Loads an already deployed stream, permitting its API usage.\n * @param stream - The locator of the stream to load.\n * @returns An instance of IStream.\n */\n loadStream(stream: StreamLocator): Stream {\n return new Stream(\n this.getKwilClient() as WebKwil | NodeKwil,\n this.getKwilSigner(),\n stream,\n );\n }\n\n /**\n * Loads a primitive stream.\n * @param stream - The locator of the primitive stream to load.\n * @returns An instance of IPrimitiveStream.\n */\n loadPrimitiveStream(stream: StreamLocator): PrimitiveStream {\n return PrimitiveStream.fromStream(this.loadStream(stream));\n }\n\n /**\n * Loads a composed stream.\n * @param stream - The locator of the composed stream to load.\n * @returns An instance of IComposedStream.\n */\n loadComposedStream(stream: StreamLocator): ComposedStream {\n return new ComposedStream(\n this.getKwilClient() as WebKwil | NodeKwil,\n this.getKwilSigner(),\n stream,\n );\n }\n\n /**\n * Creates a new stream locator.\n * @param streamId - The ID of the stream.\n * @returns A StreamLocator object.\n */\n ownStreamLocator(streamId: StreamId): StreamLocator {\n return {\n streamId,\n dataProvider: this.address(),\n };\n }\n\n /**\n * Returns the address of the signer used by the client.\n * @returns An instance of EthereumAddress.\n */\n address(): EthereumAddress {\n return new EthereumAddress(this.signerInfo.address);\n }\n\n /**\n * Returns all streams from the TN network.\n * @param owner - The owner of the streams. If not provided, all streams will be returned.\n * @returns A promise that resolves to a list of stream locators.\n */\n async getAllStreams(owner?: EthereumAddress): Promise<StreamLocator[]> {\n return listAllStreams(this.getKwilClient(), owner);\n }\n\n /**\n * Get the default chain id for a provider. Use with caution, as this decreases the security of the TN.\n * @param provider - The provider URL.\n * @returns A promise that resolves to the chain ID.\n */\n public static async getDefaultChainId(provider: string) {\n const kwilClient = new Client({\n kwilProvider: provider,\n });\n const chainInfo = await kwilClient[\"chainInfoClient\"]();\n return chainInfo.data?.chain_id;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsD;AAQtD,4BAA+B;AAC/B,0BAA6B;AAC7B,2BAA8B;AAC9B,6BAAgC;AAChC,oBAAuB;AAGvB,6BAAgC;AAEhC,4BAA+B;AAaxB,IAAe,eAAf,MAAuD;AAAA,EAClD;AAAA,EACA;AAAA,EAEA,YAAY,SAA0B;AAC9C,SAAK,aAAa,QAAQ;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAU,QAAgB,UAAU,MAA+B;AACvE,WAAO,IAAI,QAAuB,OAAO,SAAS,WAAW;AAC3D,YAAM,WAAW,YAAY,YAAY;AACvC,cAAM,UAAU,MAAM,KAAK,cAAc,EACtC,cAAc,EAAE,MAAM,EACtB,MAAM,OAAO,EAAE,MAAM,QAAW,QAAQ,OAAU,EAAE;AACvD,gBAAQ,QAAQ,QAAQ;AAAA,UACtB,KAAK;AACH,gBAAI,QAAQ,MAAM,UAAU,QAAQ,WAAW;AAC7C,sBAAQ,QAAQ,IAAI;AAAA,YACtB,OAAO;AACL;AAAA,gBACE,IAAI;AAAA,kBACF,8BAA8B,QAAQ,MAAM,kBAAkB,QAAQ,MAAM,UAAU,GAAG;AAAA,gBAC3F;AAAA,cACF;AAAA,YACF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AAAA;AAAA,EAOA,oBAAoB,QAAwC;AAC1D,WAAO,uCAAgB,WAAW,KAAK,WAAW,MAAM,CAAC;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB,QAAuC;AACxD,WAAO,IAAI;AAAA,MACT,KAAK,cAAc;AAAA,MACnB,KAAK,cAAc;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAiB,UAAmC;AAClD,WAAO;AAAA,MACL;AAAA,MACA,cAAc,KAAK,QAAQ;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAA2B;AACzB,WAAO,IAAI,uCAAgB,KAAK,WAAW,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,OAAmD;AACrE,eAAO,sCAAe,KAAK,cAAc,GAAG,KAAK;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAoB,kBAAkB,UAAkB;AACtD,UAAM,aAAa,IAAI,sBAAO;AAAA,MAC5B,cAAc;AAAA,IAChB,CAAC;AACD,UAAM,YAAY,MAAM,WAAW,iBAAiB,EAAE;AACtD,WAAO,UAAU,MAAM;AAAA,EACzB;AACF;",
4
+ "sourcesContent": ["import { Client, KwilSigner, NodeKwil, WebKwil } from \"@kwilteam/kwil-js\";\nimport { KwilConfig } from \"@kwilteam/kwil-js/dist/api_client/config\";\nimport { Kwil } from \"@kwilteam/kwil-js/dist/client/kwil\";\nimport { EthSigner } from \"@kwilteam/kwil-js/dist/core/builders\";\nimport { EnvironmentType } from \"@kwilteam/kwil-js/dist/core/enums\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { TxInfoReceipt } from \"@kwilteam/kwil-js/dist/core/txQuery\";\nimport { ComposedStream } from \"../contracts-api/composedStream\";\nimport { deployStream } from \"../contracts-api/deployStream\";\nimport { destroyStream } from \"../contracts-api/destroyStream\";\nimport { PrimitiveStream } from \"../contracts-api/primitiveStream\";\nimport { Stream } from \"../contracts-api/stream\";\nimport { StreamType } from \"../contracts-api/contractValues\";\nimport { StreamLocator } from \"../types/stream\";\nimport { EthereumAddress } from \"../util/EthereumAddress\";\nimport { StreamId } from \"../util/StreamId\";\nimport { listAllStreams } from \"./listAllStreams\";\n\nexport interface SignerInfo {\n // we need to have the address upfront to create the KwilSigner, instead of relying on the signer to return it asynchronously\n address: string;\n signer: EthSigner;\n}\n\nexport type TNClientOptions = {\n endpoint: string;\n signerInfo: SignerInfo;\n} & Omit<KwilConfig, \"kwilProvider\">;\n\nexport abstract class BaseTNClient<T extends EnvironmentType> {\n protected kwilClient: Kwil<T> | undefined;\n protected signerInfo: SignerInfo;\n\n protected constructor(options: TNClientOptions) {\n this.signerInfo = options.signerInfo;\n }\n\n /**\n * Waits for a transaction to be mined by TN.\n * @param txHash - The transaction hash to wait for.\n * @param timeout - The timeout in milliseconds.\n * @returns A promise that resolves to the transaction info receipt.\n */\n async waitForTx(txHash: string, timeout = 12000): Promise<TxInfoReceipt> {\n return new Promise<TxInfoReceipt>(async (resolve, reject) => {\n const interval = setInterval(async () => {\n const receipt = await this.getKwilClient()\n [\"txInfoClient\"](txHash)\n .catch(() => ({ data: undefined, status: undefined }));\n switch (receipt.status) {\n case 200:\n if (receipt.data?.tx_result.log === \"success\") {\n resolve(receipt.data);\n } else {\n reject(\n new Error(\n `Transaction failed: status ${receipt.status} : log message ${receipt.data?.tx_result.log}`,\n ),\n );\n }\n break;\n case undefined:\n break;\n default:\n reject(\n new Error(\n `Transaction failed: status ${receipt.status} : log message ${receipt.data?.tx_result.log}`,\n ),\n );\n }\n }, 1000);\n setTimeout(() => {\n clearInterval(interval);\n reject(new Error(\"Transaction failed: Timeout\"));\n }, timeout);\n });\n }\n\n /**\n * Returns the Kwil signer used by the client.\n * @returns An instance of KwilSigner.\n */\n getKwilSigner(): KwilSigner {\n return new KwilSigner(\n this.signerInfo.signer,\n this.address().getAddress(),\n );\n }\n\n /**\n * Returns the Kwil client used by the client.\n * @returns An instance of Kwil.\n * @throws If the Kwil client is not initialized.\n */\n getKwilClient(): Kwil<EnvironmentType> {\n if (!this.kwilClient) {\n throw new Error(\"Kwil client not initialized\");\n }\n return this.kwilClient;\n }\n\n /**\n * Deploys a new stream.\n * @param streamId - The ID of the stream to deploy.\n * @param streamType - The type of the stream.\n * @param synchronous - Whether the deployment should be synchronous.\n * @param contractVersion\n * @returns A promise that resolves to a generic response containing the transaction receipt.\n */\n async deployStream(\n streamId: StreamId,\n streamType: StreamType,\n synchronous?: boolean,\n contractVersion?: number\n ): Promise<GenericResponse<TxReceipt>> {\n return await deployStream({\n streamId,\n streamType,\n synchronous,\n kwilClient: this.getKwilClient(),\n kwilSigner: this.getKwilSigner(),\n contractVersion: contractVersion\n });\n }\n\n /**\n * Destroys a stream.\n * @param streamId - The ID of the stream to destroy.\n * @param synchronous - Whether the destruction should be synchronous.\n * @returns A promise that resolves to a generic response containing the transaction receipt.\n */\n async destroyStream(\n streamId: StreamId,\n synchronous?: boolean,\n ): Promise<GenericResponse<TxReceipt>> {\n return await destroyStream({\n streamId,\n synchronous,\n kwilClient: this.getKwilClient(),\n kwilSigner: this.getKwilSigner(),\n });\n }\n\n /**\n * Loads an already deployed stream, permitting its API usage.\n * @param stream - The locator of the stream to load.\n * @returns An instance of IStream.\n */\n loadStream(stream: StreamLocator): Stream {\n return new Stream(\n this.getKwilClient() as WebKwil | NodeKwil,\n this.getKwilSigner(),\n stream,\n );\n }\n\n /**\n * Loads a primitive stream.\n * @param stream - The locator of the primitive stream to load.\n * @returns An instance of IPrimitiveStream.\n */\n loadPrimitiveStream(stream: StreamLocator): PrimitiveStream {\n return PrimitiveStream.fromStream(this.loadStream(stream));\n }\n\n /**\n * Loads a composed stream.\n * @param stream - The locator of the composed stream to load.\n * @returns An instance of IComposedStream.\n */\n loadComposedStream(stream: StreamLocator): ComposedStream {\n return new ComposedStream(\n this.getKwilClient() as WebKwil | NodeKwil,\n this.getKwilSigner(),\n stream,\n );\n }\n\n /**\n * Creates a new stream locator.\n * @param streamId - The ID of the stream.\n * @returns A StreamLocator object.\n */\n ownStreamLocator(streamId: StreamId): StreamLocator {\n return {\n streamId,\n dataProvider: this.address(),\n };\n }\n\n /**\n * Returns the address of the signer used by the client.\n * @returns An instance of EthereumAddress.\n */\n address(): EthereumAddress {\n return new EthereumAddress(this.signerInfo.address);\n }\n\n /**\n * Returns all streams from the TN network.\n * @param owner - The owner of the streams. If not provided, all streams will be returned.\n * @returns A promise that resolves to a list of stream locators.\n */\n async getAllStreams(owner?: EthereumAddress): Promise<StreamLocator[]> {\n return listAllStreams(this.getKwilClient(), owner);\n }\n\n /**\n * Get the default chain id for a provider. Use with caution, as this decreases the security of the TN.\n * @param provider - The provider URL.\n * @returns A promise that resolves to the chain ID.\n */\n public static async getDefaultChainId(provider: string) {\n const kwilClient = new Client({\n kwilProvider: provider,\n });\n const chainInfo = await kwilClient[\"chainInfoClient\"]();\n return chainInfo.data?.chain_id;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsD;AAQtD,4BAA+B;AAC/B,0BAA6B;AAC7B,2BAA8B;AAC9B,6BAAgC;AAChC,oBAAuB;AAGvB,6BAAgC;AAEhC,4BAA+B;AAaxB,IAAe,eAAf,MAAuD;AAAA,EAClD;AAAA,EACA;AAAA,EAEA,YAAY,SAA0B;AAC9C,SAAK,aAAa,QAAQ;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAU,QAAgB,UAAU,MAA+B;AACvE,WAAO,IAAI,QAAuB,OAAO,SAAS,WAAW;AAC3D,YAAM,WAAW,YAAY,YAAY;AACvC,cAAM,UAAU,MAAM,KAAK,cAAc,EACtC,cA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