@trufnetwork/sdk-js 0.2.2 → 0.3.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 (113) hide show
  1. package/README.md +91 -13
  2. package/dist/cjs/client/client.cjs +41 -32
  3. package/dist/cjs/client/client.cjs.map +2 -2
  4. package/dist/cjs/client/getLastTransactions.cjs +67 -0
  5. package/dist/cjs/client/getLastTransactions.cjs.map +7 -0
  6. package/dist/cjs/client/listStreams.cjs +46 -0
  7. package/dist/cjs/client/listStreams.cjs.map +7 -0
  8. package/dist/cjs/contracts-api/{stream.cjs → action.cjs} +140 -159
  9. package/dist/cjs/contracts-api/action.cjs.map +7 -0
  10. package/dist/cjs/contracts-api/composedAction.cjs +183 -0
  11. package/dist/cjs/contracts-api/composedAction.cjs.map +7 -0
  12. package/dist/cjs/contracts-api/{destroyStream.cjs → deleteStream.cjs} +16 -16
  13. package/dist/cjs/contracts-api/deleteStream.cjs.map +7 -0
  14. package/dist/cjs/contracts-api/deployStream.cjs +33 -16
  15. package/dist/cjs/contracts-api/deployStream.cjs.map +3 -3
  16. package/dist/cjs/contracts-api/primitiveAction.cjs +92 -0
  17. package/dist/cjs/contracts-api/primitiveAction.cjs.map +7 -0
  18. package/dist/cjs/index.common.cjs +6 -6
  19. package/dist/cjs/index.common.cjs.map +1 -1
  20. package/dist/cjs/types/transaction.cjs +19 -0
  21. package/dist/cjs/types/transaction.cjs.map +7 -0
  22. package/dist/cjs/util/EthereumAddress.cjs +0 -1
  23. package/dist/cjs/util/EthereumAddress.cjs.map +2 -2
  24. package/dist/cjs/util/StreamId.cjs +7 -2
  25. package/dist/cjs/util/StreamId.cjs.map +2 -2
  26. package/dist/esm/client/client.mjs +41 -32
  27. package/dist/esm/client/client.mjs.map +2 -2
  28. package/dist/esm/client/getLastTransactions.mjs +46 -0
  29. package/dist/esm/client/getLastTransactions.mjs.map +7 -0
  30. package/dist/esm/client/listStreams.mjs +25 -0
  31. package/dist/esm/client/listStreams.mjs.map +7 -0
  32. package/dist/esm/contracts-api/{stream.mjs → action.mjs} +137 -156
  33. package/dist/esm/contracts-api/action.mjs.map +7 -0
  34. package/dist/esm/contracts-api/composedAction.mjs +156 -0
  35. package/dist/esm/contracts-api/composedAction.mjs.map +7 -0
  36. package/dist/esm/contracts-api/deleteStream.mjs +24 -0
  37. package/dist/esm/contracts-api/deleteStream.mjs.map +7 -0
  38. package/dist/esm/contracts-api/deployStream.mjs +23 -21
  39. package/dist/esm/contracts-api/deployStream.mjs.map +2 -2
  40. package/dist/esm/contracts-api/primitiveAction.mjs +71 -0
  41. package/dist/esm/contracts-api/primitiveAction.mjs.map +7 -0
  42. package/dist/esm/index.common.mjs +6 -6
  43. package/dist/esm/index.common.mjs.map +1 -1
  44. package/dist/esm/types/transaction.mjs +1 -0
  45. package/dist/esm/types/transaction.mjs.map +7 -0
  46. package/dist/esm/util/EthereumAddress.mjs +0 -1
  47. package/dist/esm/util/EthereumAddress.mjs.map +2 -2
  48. package/dist/esm/util/StreamId.mjs +7 -2
  49. package/dist/esm/util/StreamId.mjs.map +2 -2
  50. package/dist/tsconfig.build.tsbuildinfo +1 -1
  51. package/dist/types/client/client.d.ts +38 -15
  52. package/dist/types/client/client.d.ts.map +1 -1
  53. package/dist/types/client/getLastTransactions.d.ts +5 -0
  54. package/dist/types/client/getLastTransactions.d.ts.map +1 -0
  55. package/dist/types/client/listStreams.d.ts +12 -0
  56. package/dist/types/client/listStreams.d.ts.map +1 -0
  57. package/dist/types/contracts-api/action.d.ts +136 -0
  58. package/dist/types/contracts-api/action.d.ts.map +1 -0
  59. package/dist/types/contracts-api/{composedStream.d.ts → composedAction.d.ts} +11 -22
  60. package/dist/types/contracts-api/composedAction.d.ts.map +1 -0
  61. package/dist/types/contracts-api/{destroyStream.d.ts → deleteStream.d.ts} +7 -7
  62. package/dist/types/contracts-api/deleteStream.d.ts.map +1 -0
  63. package/dist/types/contracts-api/deployStream.d.ts +2 -2
  64. package/dist/types/contracts-api/deployStream.d.ts.map +1 -1
  65. package/dist/types/contracts-api/primitiveAction.d.ts +33 -0
  66. package/dist/types/contracts-api/primitiveAction.d.ts.map +1 -0
  67. package/dist/types/index.common.d.ts +7 -7
  68. package/dist/types/types/transaction.d.ts +11 -0
  69. package/dist/types/types/transaction.d.ts.map +1 -0
  70. package/dist/types/util/EthereumAddress.d.ts.map +1 -1
  71. package/dist/types/util/StreamId.d.ts +2 -0
  72. package/dist/types/util/StreamId.d.ts.map +1 -1
  73. package/dist/types/util/visibility.d.ts.map +1 -1
  74. package/package.json +10 -6
  75. package/dist/cjs/client/listAllStreams.cjs +0 -51
  76. package/dist/cjs/client/listAllStreams.cjs.map +0 -7
  77. package/dist/cjs/contracts/composed_stream_template.json +0 -1638
  78. package/dist/cjs/contracts/composed_stream_template_unix.json +0 -2122
  79. package/dist/cjs/contracts/contractsContent.cjs +0 -65
  80. package/dist/cjs/contracts/contractsContent.cjs.map +0 -7
  81. package/dist/cjs/contracts/primitive_stream_template.json +0 -952
  82. package/dist/cjs/contracts/primitive_stream_template_unix.json +0 -1173
  83. package/dist/cjs/contracts-api/composedStream.cjs +0 -137
  84. package/dist/cjs/contracts-api/composedStream.cjs.map +0 -7
  85. package/dist/cjs/contracts-api/destroyStream.cjs.map +0 -7
  86. package/dist/cjs/contracts-api/primitiveStream.cjs +0 -86
  87. package/dist/cjs/contracts-api/primitiveStream.cjs.map +0 -7
  88. package/dist/cjs/contracts-api/stream.cjs.map +0 -7
  89. package/dist/esm/client/listAllStreams.mjs +0 -30
  90. package/dist/esm/client/listAllStreams.mjs.map +0 -7
  91. package/dist/esm/contracts/composed_stream_template.json +0 -1638
  92. package/dist/esm/contracts/composed_stream_template_unix.json +0 -2122
  93. package/dist/esm/contracts/contractsContent.mjs +0 -33
  94. package/dist/esm/contracts/contractsContent.mjs.map +0 -7
  95. package/dist/esm/contracts/primitive_stream_template.json +0 -952
  96. package/dist/esm/contracts/primitive_stream_template_unix.json +0 -1173
  97. package/dist/esm/contracts-api/composedStream.mjs +0 -116
  98. package/dist/esm/contracts-api/composedStream.mjs.map +0 -7
  99. package/dist/esm/contracts-api/destroyStream.mjs +0 -24
  100. package/dist/esm/contracts-api/destroyStream.mjs.map +0 -7
  101. package/dist/esm/contracts-api/primitiveStream.mjs +0 -65
  102. package/dist/esm/contracts-api/primitiveStream.mjs.map +0 -7
  103. package/dist/esm/contracts-api/stream.mjs.map +0 -7
  104. package/dist/types/client/listAllStreams.d.ts +0 -14
  105. package/dist/types/client/listAllStreams.d.ts.map +0 -1
  106. package/dist/types/contracts/contractsContent.d.ts +0 -6
  107. package/dist/types/contracts/contractsContent.d.ts.map +0 -1
  108. package/dist/types/contracts-api/composedStream.d.ts.map +0 -1
  109. package/dist/types/contracts-api/destroyStream.d.ts.map +0 -1
  110. package/dist/types/contracts-api/primitiveStream.d.ts +0 -39
  111. package/dist/types/contracts-api/primitiveStream.d.ts.map +0 -1
  112. package/dist/types/contracts-api/stream.d.ts +0 -142
  113. package/dist/types/contracts-api/stream.d.ts.map +0 -1
@@ -1,116 +0,0 @@
1
- // src/contracts-api/composedStream.ts
2
- import { ActionInput } from "@kwilteam/kwil-js/dist/core/action.js";
3
- import { EthereumAddress } from "../util/EthereumAddress.mjs";
4
- import { StreamId } from "../util/StreamId.mjs";
5
- import { StreamType } from "./contractValues.mjs";
6
- import { Stream } from "./stream.mjs";
7
- var ErrorStreamNotComposed = "stream is not a composed stream";
8
- var ComposedStream = class _ComposedStream extends Stream {
9
- constructor(kwilClient, kwilSigner, locator) {
10
- super(kwilClient, kwilSigner, locator);
11
- }
12
- /**
13
- * Checks if the stream is a valid composed stream.
14
- * A valid composed stream must be:
15
- * - initialized
16
- * - of type composed
17
- */
18
- async checkValidComposedStream() {
19
- await this.checkInitialized(StreamType.Composed);
20
- const streamType = await this.getType();
21
- if (streamType !== StreamType.Composed) {
22
- throw new Error(ErrorStreamNotComposed);
23
- }
24
- }
25
- /**
26
- * Executes a method after checking if the stream is a valid composed stream
27
- * @param method The method name to execute
28
- * @param inputs The inputs for the action
29
- * @returns A generic response containing the transaction receipt
30
- */
31
- async checkedComposedExecute(method, inputs) {
32
- await this.checkValidComposedStream();
33
- return this.execute(method, inputs);
34
- }
35
- /**
36
- * Returns the taxonomy of the stream
37
- * @param params Parameters for describing taxonomies
38
- * @returns A promise that resolves to the taxonomy
39
- */
40
- async describeTaxonomies(params) {
41
- const result = await this.call("describe_taxonomies", [
42
- ActionInput.fromObject({ $latest_version: params.latestVersion })
43
- ]);
44
- return result.mapRight((records) => {
45
- const taxonomyItems = records.reduce(
46
- (acc, record) => {
47
- const currentArray = acc.get(record.start_date) || [];
48
- currentArray.push({
49
- childStream: {
50
- streamId: StreamId.fromString(record.child_stream_id).throw(),
51
- dataProvider: EthereumAddress.fromString(
52
- record.child_data_provider
53
- ).throw()
54
- },
55
- weight: record.weight
56
- });
57
- acc.set(record.start_date, currentArray);
58
- return acc;
59
- },
60
- /* @__PURE__ */ new Map()
61
- );
62
- let startDate;
63
- if (records.length > 0 && records[0].start_date) {
64
- startDate = records[0].start_date;
65
- }
66
- return Array.from(taxonomyItems.entries()).map(
67
- ([startDate2, taxonomyItems2]) => ({
68
- startDate: startDate2,
69
- taxonomyItems: taxonomyItems2
70
- })
71
- );
72
- }).throw();
73
- }
74
- /**
75
- * Sets the taxonomy of the stream
76
- * @param taxonomy The taxonomy to set
77
- * @returns A promise that resolves to the transaction receipt
78
- */
79
- async setTaxonomy(taxonomy) {
80
- const dataProviders = [];
81
- const streamIds = [];
82
- const weights = [];
83
- const startDate = taxonomy.startDate;
84
- for (const item of taxonomy.taxonomyItems) {
85
- const dataProviderHex = item.childStream.dataProvider.getAddress().slice(2);
86
- dataProviders.push(dataProviderHex);
87
- streamIds.push(item.childStream.streamId.getId());
88
- weights.push(item.weight.toString());
89
- }
90
- return this.checkedComposedExecute("set_taxonomy", [
91
- ActionInput.fromObject({
92
- $data_providers: dataProviders,
93
- $stream_ids: streamIds,
94
- $weights: weights,
95
- $start_date: startDate
96
- })
97
- ]);
98
- }
99
- /**
100
- * Creates a ComposedStream from a base Stream
101
- * @param stream The base stream to convert
102
- * @returns A ComposedStream instance
103
- */
104
- static fromStream(stream) {
105
- return new _ComposedStream(
106
- stream["kwilClient"],
107
- stream["kwilSigner"],
108
- stream["locator"]
109
- );
110
- }
111
- };
112
- export {
113
- ComposedStream,
114
- ErrorStreamNotComposed
115
- };
116
- //# sourceMappingURL=composedStream.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/contracts-api/composedStream.ts"],
4
- "sourcesContent": ["import { KwilSigner, NodeKwil, WebKwil } from \"@kwilteam/kwil-js\";\nimport { ActionInput } from \"@kwilteam/kwil-js/dist/core/action\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { DateString } from \"../types/other\";\nimport { StreamLocator } from \"../types/stream\";\nimport { EthereumAddress } from \"../util/EthereumAddress\";\nimport { StreamId } from \"../util/StreamId\";\nimport { StreamType } from \"./contractValues\";\nimport { Stream } from \"./stream\";\n\nexport const ErrorStreamNotComposed = \"stream is not a composed stream\";\n\nexport interface TaxonomySet {\n taxonomyItems: TaxonomyItem[];\n startDate: DateString | number;\n}\n\nexport interface TaxonomyItem {\n childStream: StreamLocator;\n weight: string;\n}\n\nexport interface DescribeTaxonomiesParams {\n /**\n * if true, will return the latest version of the taxonomy only\n */\n latestVersion: boolean;\n}\n\nexport class ComposedStream extends Stream {\n constructor(\n kwilClient: WebKwil | NodeKwil,\n kwilSigner: KwilSigner,\n locator: StreamLocator,\n ) {\n super(kwilClient, kwilSigner, locator);\n }\n\n /**\n * Checks if the stream is a valid composed stream.\n * A valid composed stream must be:\n * - initialized\n * - of type composed\n */\n private async checkValidComposedStream(): Promise<void> {\n // First check if initialized\n await this.checkInitialized(StreamType.Composed);\n\n // Then check if is composed\n const streamType = await this.getType();\n if (streamType !== StreamType.Composed) {\n throw new Error(ErrorStreamNotComposed);\n }\n }\n\n /**\n * Executes a method after checking if the stream is a valid composed stream\n * @param method The method name to execute\n * @param inputs The inputs for the action\n * @returns A generic response containing the transaction receipt\n */\n private async checkedComposedExecute(\n method: string,\n inputs: ActionInput[],\n ): Promise<GenericResponse<TxReceipt>> {\n await this.checkValidComposedStream();\n return this.execute(method, inputs);\n }\n\n /**\n * Returns the taxonomy of the stream\n * @param params Parameters for describing taxonomies\n * @returns A promise that resolves to the taxonomy\n */\n public async describeTaxonomies(\n params: DescribeTaxonomiesParams,\n ): Promise<TaxonomySet[]> {\n type TaxonomyResult = {\n child_stream_id: string;\n child_data_provider: string;\n weight: string;\n created_at: number;\n version: number;\n start_date: string | number;\n }[];\n\n const result = await this.call<TaxonomyResult>(\"describe_taxonomies\", [\n ActionInput.fromObject({ $latest_version: params.latestVersion }),\n ]);\n\n return result\n .mapRight((records) => {\n const taxonomyItems: Map<DateString, TaxonomyItem[]> = records.reduce(\n (acc, record) => {\n const currentArray = acc.get(<string>record.start_date) || [];\n currentArray.push({\n childStream: {\n streamId: StreamId.fromString(record.child_stream_id).throw(),\n dataProvider: EthereumAddress.fromString(\n record.child_data_provider,\n ).throw(),\n },\n weight: record.weight,\n });\n acc.set(<string>record.start_date, currentArray);\n return acc;\n },\n new Map<DateString, TaxonomyItem[]>(),\n );\n\n let startDate: string | number;\n if (records.length > 0 && records[0].start_date) {\n startDate = records[0].start_date;\n }\n\n return Array.from(taxonomyItems.entries()).map(\n ([startDate, taxonomyItems]) => ({\n startDate,\n taxonomyItems,\n }),\n );\n })\n .throw();\n }\n\n /**\n * Sets the taxonomy of the stream\n * @param taxonomy The taxonomy to set\n * @returns A promise that resolves to the transaction receipt\n */\n public async setTaxonomy(\n taxonomy: TaxonomySet,\n ): Promise<GenericResponse<TxReceipt>> {\n const dataProviders: string[] = [];\n const streamIds: string[] = [];\n const weights: string[] = [];\n const startDate = taxonomy.startDate;\n\n for (const item of taxonomy.taxonomyItems) {\n const dataProviderHex = item.childStream.dataProvider\n .getAddress()\n .slice(2); // Remove 0x prefix\n dataProviders.push(dataProviderHex);\n streamIds.push(item.childStream.streamId.getId());\n weights.push(item.weight.toString());\n }\n\n return this.checkedComposedExecute(\"set_taxonomy\", [\n ActionInput.fromObject({\n $data_providers: dataProviders,\n $stream_ids: streamIds,\n $weights: weights,\n $start_date: startDate,\n }),\n ]);\n }\n\n /**\n * Creates a ComposedStream from a base Stream\n * @param stream The base stream to convert\n * @returns A ComposedStream instance\n */\n public static fromStream(stream: Stream): ComposedStream {\n return new ComposedStream(\n stream[\"kwilClient\"],\n stream[\"kwilSigner\"],\n stream[\"locator\"],\n );\n }\n}\n"],
5
- "mappings": ";AACA,SAAS,mBAAmB;AAK5B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AAEhB,IAAM,yBAAyB;AAmB/B,IAAM,iBAAN,MAAM,wBAAuB,OAAO;AAAA,EACzC,YACE,YACA,YACA,SACA;AACA,UAAM,YAAY,YAAY,OAAO;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,2BAA0C;AAEtD,UAAM,KAAK,iBAAiB,WAAW,QAAQ;AAG/C,UAAM,aAAa,MAAM,KAAK,QAAQ;AACtC,QAAI,eAAe,WAAW,UAAU;AACtC,YAAM,IAAI,MAAM,sBAAsB;AAAA,IACxC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,uBACZ,QACA,QACqC;AACrC,UAAM,KAAK,yBAAyB;AACpC,WAAO,KAAK,QAAQ,QAAQ,MAAM;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,mBACX,QACwB;AAUxB,UAAM,SAAS,MAAM,KAAK,KAAqB,uBAAuB;AAAA,MACpE,YAAY,WAAW,EAAE,iBAAiB,OAAO,cAAc,CAAC;AAAA,IAClE,CAAC;AA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A,QACjB,aAAa;AAAA,QACb,UAAU;AAAA,QACV,aAAa;AAAA,MACf,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAAgC;AACvD,WAAO,IAAI;AAAA,MACT,OAAO,YAAY;AAAA,MACnB,OAAO,YAAY;AAAA,MACnB,OAAO,SAAS;AAAA,IAClB;AAAA,EACF;AACF;",
6
- "names": ["startDate", "taxonomyItems"]
7
- }
@@ -1,24 +0,0 @@
1
- // src/contracts-api/destroyStream.ts
2
- import { generateDBID } from "@kwilteam/kwil-js/dist/utils/dbid.js";
3
- async function destroyStream(input) {
4
- const dbid = generateDBID(
5
- input.kwilSigner.identifier,
6
- input.streamId.getId()
7
- );
8
- try {
9
- const txReceipt = await input.kwilClient.drop(
10
- {
11
- dbid
12
- },
13
- input.kwilSigner,
14
- input.synchronous
15
- );
16
- return txReceipt;
17
- } catch (error) {
18
- throw new Error(`Failed to destroy stream: ${error}`);
19
- }
20
- }
21
- export {
22
- destroyStream
23
- };
24
- //# sourceMappingURL=destroyStream.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/contracts-api/destroyStream.ts"],
4
- "sourcesContent": ["import { StreamId } from \"../util/StreamId\";\nimport { Kwil } from \"@kwilteam/kwil-js/dist/client/kwil\";\nimport { KwilSigner } from \"@kwilteam/kwil-js\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { generateDBID } from \"@kwilteam/kwil-js/dist/utils/dbid\";\n\n/**\n * Input parameters for destroying a stream.\n */\nexport interface DestroyStreamInput {\n streamId: StreamId;\n kwilClient: Kwil<any>;\n kwilSigner: KwilSigner;\n synchronous?: boolean;\n}\n\n/**\n * Output after destroying a stream.\n */\nexport interface DestroyStreamOutput {\n receipt: TxReceipt;\n}\n\n/**\n * Destroys a stream from TN.\n * @param input - The input parameters for destroying the stream.\n * @returns The transaction receipt of the destruction.\n */\nexport async function destroyStream(\n input: DestroyStreamInput,\n): Promise<GenericResponse<TxReceipt>> {\n const dbid = generateDBID(\n input.kwilSigner.identifier,\n input.streamId.getId(),\n );\n try {\n const txReceipt = await input.kwilClient.drop(\n {\n dbid,\n },\n input.kwilSigner,\n input.synchronous,\n );\n\n return txReceipt;\n } catch (error) {\n throw new Error(`Failed to destroy stream: ${error}`);\n }\n}\n"],
5
- "mappings": ";AAKA,SAAS,oBAAoB;AAwB7B,eAAsB,cACpB,OACqC;AACrC,QAAM,OAAO;AAAA,IACX,MAAM,WAAW;AAAA,IACjB,MAAM,SAAS,MAAM;AAAA,EACvB;AACA,MAAI;AACF,UAAM,YAAY,MAAM,MAAM,WAAW;AAAA,MACvC;AAAA,QACE;AAAA,MACF;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,6BAA6B,KAAK,EAAE;AAAA,EACtD;AACF;",
6
- "names": []
7
- }
@@ -1,65 +0,0 @@
1
- // src/contracts-api/primitiveStream.ts
2
- import { ActionInput } from "@kwilteam/kwil-js/dist/core/action.js";
3
- import { StreamType } from "./contractValues.mjs";
4
- import { Stream } from "./stream.mjs";
5
- var ErrorStreamNotPrimitive = "stream is not a primitive stream";
6
- var PrimitiveStream = class _PrimitiveStream extends Stream {
7
- constructor(kwilClient, kwilSigner, locator) {
8
- super(kwilClient, kwilSigner, locator);
9
- }
10
- /**
11
- * Checks if the stream is a valid primitive stream.
12
- * A valid primitive stream must be:
13
- * - initialized
14
- * - of type primitive
15
- */
16
- async checkValidPrimitiveStream() {
17
- await this.checkInitialized(StreamType.Primitive);
18
- const streamType = await this.getType();
19
- if (streamType !== StreamType.Primitive) {
20
- throw new Error(ErrorStreamNotPrimitive);
21
- }
22
- }
23
- /**
24
- * Executes a method after checking if the stream is a valid primitive stream
25
- * @param method The method name to execute
26
- * @param inputs The inputs for the action
27
- * @returns A generic response containing the transaction receipt
28
- */
29
- async checkedPrimitiveExecute(method, inputs) {
30
- await this.checkValidPrimitiveStream();
31
- return this.execute(method, inputs);
32
- }
33
- /**
34
- * Inserts records into the stream
35
- * @param inputs Array of records to insert
36
- * @returns Transaction receipt
37
- */
38
- async insertRecords(inputs) {
39
- await this.checkValidPrimitiveStream();
40
- const actionInputs = inputs.map(
41
- (input) => ActionInput.fromObject({
42
- $date_value: input.dateValue,
43
- $value: input.value
44
- })
45
- );
46
- return await this.checkedPrimitiveExecute("insert_record", actionInputs);
47
- }
48
- /**
49
- * Creates a PrimitiveStream from a base Stream
50
- * @param stream The base stream to convert
51
- * @returns A Promise that resolves to a PrimitiveStream instance
52
- */
53
- static fromStream(stream) {
54
- const primitiveStream = new _PrimitiveStream(
55
- stream["kwilClient"],
56
- stream["kwilSigner"],
57
- stream["locator"]
58
- );
59
- return primitiveStream;
60
- }
61
- };
62
- export {
63
- PrimitiveStream
64
- };
65
- //# sourceMappingURL=primitiveStream.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/contracts-api/primitiveStream.ts"],
4
- "sourcesContent": ["import { KwilSigner, NodeKwil, WebKwil } from \"@kwilteam/kwil-js\";\nimport { ActionInput } from \"@kwilteam/kwil-js/dist/core/action\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { StreamType } from \"./contractValues\";\nimport { StreamLocator } from \"../types/stream\";\nimport { Stream } from \"./stream\";\n\nconst ErrorStreamNotPrimitive = \"stream is not a primitive stream\";\n\nexport class PrimitiveStream extends Stream {\n constructor(\n kwilClient: WebKwil | NodeKwil,\n kwilSigner: KwilSigner,\n locator: StreamLocator,\n ) {\n super(kwilClient, kwilSigner, locator);\n }\n\n /**\n * Checks if the stream is a valid primitive stream.\n * A valid primitive stream must be:\n * - initialized\n * - of type primitive\n */\n private async checkValidPrimitiveStream(): Promise<void> {\n // First check if initialized\n await this.checkInitialized(StreamType.Primitive);\n\n // Then check if is primitive\n const streamType = await this.getType();\n if (streamType !== StreamType.Primitive) {\n throw new Error(ErrorStreamNotPrimitive);\n }\n }\n\n /**\n * Executes a method after checking if the stream is a valid primitive stream\n * @param method The method name to execute\n * @param inputs The inputs for the action\n * @returns A generic response containing the transaction receipt\n */\n private async checkedPrimitiveExecute(\n method: string,\n inputs: ActionInput[],\n ): Promise<GenericResponse<TxReceipt>> {\n await this.checkValidPrimitiveStream();\n return this.execute(method, inputs);\n }\n\n /**\n * Inserts records into the stream\n * @param inputs Array of records to insert\n * @returns Transaction receipt\n */\n public async insertRecords(\n inputs: InsertRecordInput[],\n ): Promise<GenericResponse<TxReceipt>> {\n await this.checkValidPrimitiveStream();\n\n const actionInputs = inputs.map((input) =>\n ActionInput.fromObject({\n $date_value: input.dateValue,\n $value: input.value,\n }),\n );\n\n return await this.checkedPrimitiveExecute(\"insert_record\", actionInputs);\n }\n\n /**\n * Creates a PrimitiveStream from a base Stream\n * @param stream The base stream to convert\n * @returns A Promise that resolves to a PrimitiveStream instance\n */\n public static fromStream(stream: Stream): PrimitiveStream {\n const primitiveStream = new PrimitiveStream(\n stream[\"kwilClient\"],\n stream[\"kwilSigner\"],\n stream[\"locator\"],\n );\n\n return primitiveStream;\n }\n}\nexport interface InsertRecordInput {\n dateValue: string | number;\n // value is a string to support arbitrary precision\n value: string;\n}\n"],
5
- "mappings": ";AACA,SAAS,mBAAmB;AAG5B,SAAS,kBAAkB;AAE3B,SAAS,cAAc;AAEvB,IAAM,0BAA0B;AAEzB,IAAM,kBAAN,MAAM,yBAAwB,OAAO;AAAA,EAC1C,YACE,YACA,YACA,SACA;AACA,UAAM,YAAY,YAAY,OAAO;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,4BAA2C;AAEvD,UAAM,KAAK,iBAAiB,WAAW,SAAS;AAGhD,UAAM,aAAa,MAAM,KAAK,QAAQ;AACtC,QAAI,eAAe,WAAW,WAAW;AACvC,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,wBACZ,QACA,QACqC;AACrC,UAAM,KAAK,0BAA0B;AACrC,WAAO,KAAK,QAAQ,QAAQ,MAAM;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,cACX,QACqC;AACrC,UAAM,KAAK,0BAA0B;AAErC,UAAM,eAAe,OAAO;AAAA,MAAI,CAAC,UAC/B,YAAY,WAAW;AAAA,QACrB,aAAa,MAAM;AAAA,QACnB,QAAQ,MAAM;AAAA,MAChB,CAAC;AAAA,IACH;AAEA,WAAO,MAAM,KAAK,wBAAwB,iBAAiB,YAAY;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAc,WAAW,QAAiC;AACxD,UAAM,kBAAkB,IAAI;AAAA,MAC1B,OAAO,YAAY;AAAA,MACnB,OAAO,YAAY;AAAA,MACnB,OAAO,SAAS;AAAA,IAClB;AAEA,WAAO;AAAA,EACT;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/contracts-api/stream.ts"],
4
- "sourcesContent": ["import { KwilSigner, NodeKwil, WebKwil } from \"@kwilteam/kwil-js\";\nimport { ActionInput } from \"@kwilteam/kwil-js/dist/core/action\";\nimport { Database } from \"@kwilteam/kwil-js/dist/core/database\";\nimport { GenericResponse } from \"@kwilteam/kwil-js/dist/core/resreq\";\nimport { TxReceipt } from \"@kwilteam/kwil-js/dist/core/tx\";\nimport { generateDBID } from \"@kwilteam/kwil-js/dist/utils/dbid\";\nimport { Either } from \"monads-io\";\nimport { DateString } from \"../types/other\";\nimport { StreamLocator } from \"../types/stream\";\nimport { EthereumAddress } from \"../util/EthereumAddress\";\nimport { head } from \"../util/head\";\nimport { StreamId } from \"../util/StreamId\";\nimport { toVisibilityEnum, VisibilityEnum } from \"../util/visibility\";\nimport {\n MetadataKey,\n MetadataKeyValueMap,\n MetadataTableKey,\n MetadataValueTypeForKey,\n StreamType,\n} from \"./contractValues\";\n\nexport interface GetRecordInput {\n dateFrom?: DateString | number;\n dateTo?: DateString | number;\n frozenAt?: number;\n baseDate?: DateString | number;\n}\n\nexport interface GetFirstRecordInput {\n afterDate?: DateString | number;\n frozenAt?: DateString | number;\n}\n\nexport interface StreamRecord {\n dateValue: DateString | number;\n value: string;\n}\n\nexport interface GetIndexChangeInput extends GetRecordInput {\n daysInterval: number;\n}\n\nexport class Stream {\n protected kwilClient: WebKwil | NodeKwil;\n protected kwilSigner: KwilSigner;\n protected locator: StreamLocator;\n protected dbid: string;\n protected schema?: Database;\n protected deployed: boolean = false;\n protected initialized: boolean = false;\n constructor(\n kwilClient: WebKwil | NodeKwil,\n kwilSigner: KwilSigner,\n locator: StreamLocator,\n ) {\n this.kwilClient = kwilClient;\n this.kwilSigner = kwilSigner;\n this.locator = locator;\n this.dbid = generateDBID(\n locator.dataProvider.getAddress(),\n locator.streamId.getId(),\n );\n }\n\n /**\n * Loads the schema for this stream from the network.\n * Throws if the stream is not deployed.\n */\n public async loadSchema(): Promise<void> {\n const response = await this.kwilClient.getSchema(this.dbid);\n if (response.status !== 200 || !response.data) {\n throw new Error(\n `Failed to load schema for stream ${this.locator.streamId.getId()}`,\n );\n }\n this.schema = response.data;\n }\n\n /**\n * Executes a method on the stream\n */\n protected async execute(\n method: string,\n inputs: ActionInput[],\n ): Promise<GenericResponse<TxReceipt>> {\n return this.kwilClient.execute(\n {\n dbid: this.dbid,\n name: method,\n inputs,\n description: `TN SDK - Executing method on stream: ${method}`,\n },\n this.kwilSigner,\n );\n }\n\n /**\n * Executes a method on the stream after checking if it's initialized\n */\n protected async checkedExecute(\n method: string,\n inputs: ActionInput[],\n ): Promise<GenericResponse<TxReceipt>> {\n await this.checkInitialized();\n return this.execute(method, inputs);\n }\n\n /**\n * Calls a method on the stream\n */\n protected async call<T>(\n method: string,\n inputs: ActionInput[],\n ): Promise<Either<number, T>> {\n const result = await this.kwilClient.call(\n {\n dbid: this.dbid,\n name: method,\n inputs,\n },\n this.kwilSigner,\n );\n\n if (result.status !== 200) {\n return Either.left(result.status);\n }\n\n return Either.right(result.data?.result as T);\n }\n\n /**\n * Checks if the stream is initialized\n */\n protected async checkInitialized(expectedType?: StreamType): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n this.checkDeployed();\n\n // check if is initialized by trying to get its type\n const type = await this.getType();\n\n // check if type is valid\n const expectedTypes = expectedType\n ? [expectedType]\n : [StreamType.Primitive, StreamType.Composed];\n if (!expectedTypes.includes(type)) {\n throw new Error(`Invalid stream type: ${type}`);\n }\n\n this.initialized = true;\n }\n\n /**\n * Checks if the stream is deployed\n */\n protected async checkDeployed(): Promise<void> {\n if (this.deployed) {\n return;\n }\n await this.loadSchema();\n this.deployed = true;\n }\n\n /**\n * Initializes the stream\n */\n public async initializeStream(): Promise<GenericResponse<TxReceipt>> {\n // shouldn't use checkedExecute, because it's not initialized yet\n return this.execute(\"init\", []);\n }\n\n /**\n * Returns the records of the stream within the given date range\n */\n public async getRecord(input: GetRecordInput): Promise<StreamRecord[]> {\n // TODO: change value to string when kwil-js is updated\n const result = await this.call<{ date_value: string; value: string }[]>(\n \"get_record\",\n [\n ActionInput.fromObject({\n $date_from: input.dateFrom,\n $date_to: input.dateTo,\n $frozen_at: input.frozenAt,\n $base_date: input.baseDate,\n }),\n ],\n );\n return result\n .mapRight((result) =>\n result.map((row) => ({\n dateValue: row.date_value,\n value: row.value,\n })),\n )\n .throw();\n }\n\n /**\n * Returns the index of the stream within the given date range\n */\n public async getIndex(input: GetRecordInput): Promise<StreamRecord[]> {\n const result = await this.call<{ date_value: string; value: string }[]>(\n \"get_index\",\n [\n ActionInput.fromObject({\n $date_from: input.dateFrom,\n $date_to: input.dateTo,\n $frozen_at: input.frozenAt,\n $base_date: input.baseDate,\n }),\n ],\n );\n return result\n .mapRight((result) =>\n result.map((row) => ({\n dateValue: row.date_value,\n value: row.value,\n })),\n )\n .throw();\n }\n\n /**\n * Returns the type of the stream\n */\n public async getType(): Promise<StreamType> {\n const result = await this.getMetadata(MetadataKey.TypeKey, true);\n\n if (!result) {\n throw new Error(\"Failed to get stream type\");\n }\n\n const type = head(result).unwrapOrElse(() => {\n throw new Error(\n \"Failed to get stream type. Check if the stream is initialized.\",\n );\n });\n\n const validTypes = [StreamType.Primitive, StreamType.Composed];\n\n if (!validTypes.includes(type.value as StreamType)) {\n throw new Error(`Invalid stream type: ${type.value}`);\n }\n\n return type.value as StreamType;\n }\n\n /**\n * Returns the first record of the stream\n */\n public async getFirstRecord(\n input: GetFirstRecordInput,\n ): Promise<StreamRecord | null> {\n const result = await this.call<{ date_value: string; value: string }[]>(\n \"get_first_record\",\n [\n ActionInput.fromObject({\n $after_date: input.afterDate,\n $frozen_at: input.frozenAt,\n }),\n ],\n );\n\n return result\n .mapRight(head)\n .mapRight((result) =>\n result\n .map((result) => ({\n dateValue: result.date_value,\n value: result.value,\n }))\n .unwrapOr(null),\n )\n .throw();\n }\n\n protected async setMetadata<K extends MetadataKey>(\n key: K,\n value: MetadataValueTypeForKey<K>,\n ): Promise<GenericResponse<TxReceipt>> {\n return await this.execute(\"insert_metadata\", [\n ActionInput.fromObject({\n $key: key,\n $value: value,\n $val_type: MetadataKeyValueMap[key],\n }),\n ]);\n }\n\n protected async getMetadata<K extends MetadataKey>(\n key: K,\n onlyLatest: boolean = true,\n filteredRef?: string,\n ): Promise<\n { rowId: string; value: MetadataValueTypeForKey<K>; createdAt: number }[]\n > {\n const result = await this.call<\n {\n row_id: string;\n value_i: number;\n value_f: string;\n value_b: boolean;\n value_s: string;\n value_ref: string;\n created_at: number;\n }[]\n >(\"get_metadata\", [\n ActionInput.fromObject({\n $key: key,\n $only_latest: onlyLatest,\n $ref: filteredRef,\n }),\n ]);\n return result\n .mapRight((result) =>\n result.map((row) => ({\n rowId: row.row_id,\n value: row[\n MetadataTableKey[MetadataKeyValueMap[key as MetadataKey]]\n ] as MetadataValueTypeForKey<K>,\n createdAt: row.created_at,\n })),\n )\n .throw();\n }\n\n /**\n * Sets the read visibility of the stream\n */\n public async setReadVisibility(\n visibility: VisibilityEnum,\n ): Promise<GenericResponse<TxReceipt>> {\n return await this.setMetadata(\n MetadataKey.ReadVisibilityKey,\n visibility.toString(),\n );\n }\n\n /**\n * Returns the read visibility of the stream\n */\n public async getReadVisibility(): Promise<VisibilityEnum | null> {\n const result = await this.getMetadata(MetadataKey.ReadVisibilityKey, true);\n\n return head(result)\n .map((row) => toVisibilityEnum(row.value))\n .unwrapOr(null);\n }\n\n /**\n * Sets the compose visibility of the stream\n */\n public async setComposeVisibility(\n visibility: VisibilityEnum,\n ): Promise<GenericResponse<TxReceipt>> {\n return await this.setMetadata(\n MetadataKey.ComposeVisibilityKey,\n visibility.toString(),\n );\n }\n\n /**\n * Returns the compose visibility of the stream\n */\n public async getComposeVisibility(): Promise<VisibilityEnum | null> {\n const result = await this.getMetadata(\n MetadataKey.ComposeVisibilityKey,\n true,\n );\n\n return head(result)\n .map((row) => toVisibilityEnum(row.value))\n .unwrapOr(null);\n }\n\n /**\n * Allows a wallet to read the stream\n */\n public async allowReadWallet(\n wallet: EthereumAddress,\n ): Promise<GenericResponse<TxReceipt>> {\n return await this.setMetadata(\n MetadataKey.AllowReadWalletKey,\n wallet.getAddress(),\n );\n }\n\n /**\n * Disables a wallet from reading the stream\n */\n public async disableReadWallet(\n wallet: EthereumAddress,\n ): Promise<GenericResponse<TxReceipt>> {\n const result = await this.getMetadata(\n MetadataKey.AllowReadWalletKey,\n true,\n wallet.getAddress(),\n );\n\n const row_id = head(result)\n .map((row) => row.rowId)\n .unwrapOr(null);\n\n if (!row_id) {\n throw new Error(\"Wallet not found in allowed list\");\n }\n\n return await this.disableMetadata(row_id);\n }\n\n /**\n * Allows a stream to use this stream as child\n */\n public async allowComposeStream(\n locator: StreamLocator,\n ): Promise<GenericResponse<TxReceipt>> {\n const streamDbId = generateDBID(\n locator.dataProvider.getAddress(),\n locator.streamId.getId(),\n );\n return await this.setMetadata(\n MetadataKey.AllowComposeStreamKey,\n streamDbId,\n );\n }\n\n /**\n * Disables a stream from using this stream as child\n */\n public async disableComposeStream(\n locator: StreamLocator,\n ): Promise<GenericResponse<TxReceipt>> {\n const result = await this.getMetadata(\n MetadataKey.AllowComposeStreamKey,\n true,\n locator.toString(),\n );\n\n const row_id = head(result)\n .map((row) => row.rowId)\n .unwrapOr(null);\n\n if (!row_id) {\n throw new Error(\"Stream not found in allowed list\");\n }\n\n return await this.disableMetadata(row_id);\n }\n\n protected async disableMetadata(\n rowId: string,\n ): Promise<GenericResponse<TxReceipt>> {\n return await this.execute(\"disable_metadata\", [\n ActionInput.fromObject({\n $row_id: rowId,\n }),\n ]);\n }\n\n /**\n * Returns the wallets allowed to read the stream\n */\n public async getAllowedReadWallets(): Promise<EthereumAddress[]> {\n const result = await this.getMetadata(MetadataKey.AllowReadWalletKey);\n\n return result\n .filter((row) => row.value)\n .map((row) => new EthereumAddress(row.value));\n }\n\n /**\n * Returns the streams allowed to compose the stream\n */\n public async getAllowedComposeStreams(): Promise<StreamLocator[]> {\n const result = await this.getMetadata(MetadataKey.AllowComposeStreamKey);\n\n return result\n .filter((row) => row.value)\n .map((row) => {\n const [streamId, dataProvider] = row.value.split(\":\");\n return {\n streamId: StreamId.fromString(streamId).throw(),\n dataProvider: new EthereumAddress(dataProvider),\n };\n });\n }\n\n /**\n * Returns the index change of the stream within the given date range\n */\n public async getIndexChange(\n input: GetIndexChangeInput,\n ): Promise<StreamRecord[]> {\n const result = await this.call<{ date_value: string; value: string }[]>(\n \"get_index_change\",\n [\n ActionInput.fromObject({\n $date_from: input.dateFrom,\n $date_to: input.dateTo,\n $frozen_at: input.frozenAt,\n $base_date: input.baseDate,\n $days_interval: input.daysInterval,\n }),\n ],\n );\n\n return result\n .mapRight((result) =>\n result.map((row) => ({\n dateValue: row.date_value,\n value: row.value,\n })),\n )\n .throw();\n }\n\n /**\n * A custom method that accepts the procedure name and the input of GetRecordInput\n * Returns the result of the procedure in the same format as StreamRecord\n * I.e. a custom procedure named \"get_price\" that returns a list of date_value and value\n * can be called with customGetProcedure(\"get_price\", { dateFrom: \"2021-01-01\", dateTo: \"2021-01-31\" })\n */\n public async customGetProcedure(\n procedure: string,\n input: GetRecordInput,\n ): Promise<StreamRecord[]> {\n const result = await this.call<{ date_value: string; value: string }[]>(\n procedure,\n [\n ActionInput.fromObject({\n $date_from: input.dateFrom,\n $date_to: input.dateTo,\n $frozen_at: input.frozenAt,\n $base_date: input.baseDate,\n }),\n ],\n );\n return result\n .mapRight((result) =>\n result.map((row) => ({\n dateValue: row.date_value,\n value: row.value,\n })),\n )\n .throw();\n }\n}\n"],
5
- "mappings": ";;;;;AACA,SAAS,mBAAmB;AAI5B,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAGvB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,wBAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAuBA,IAAM,SAAN,MAAa;AAAA,EAQlB,YACE,YACA,YACA,SACA;AAXF,wBAAU;AACV,wBAAU;AACV,wBAAU;AACV,wBAAU;AACV,wBAAU;AACV,wBAAU,YAAoB;AAC9B,wBAAU,eAAuB;AAM/B,SAAK,aAAa;AAClB,SAAK,aAAa;AAClB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,MACV,QAAQ,aAAa,WAAW;AAAA,MAChC,QAAQ,SAAS,MAAM;AAAA,IACzB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,aAA4B;AACvC,UAAM,WAAW,MAAM,KAAK,WAAW,UAAU,KAAK,IAAI;AAC1D,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM,I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QAAQ,EAAE,MAAM;AAAA,QAC9C,cAAc,IAAI,gBAAgB,YAAY;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,eACX,OACyB;AACzB,UAAM,SAAS,MAAM,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,QACE,YAAY,WAAW;AAAA,UACrB,YAAY,MAAM;AAAA,UAClB,UAAU,MAAM;AAAA,UAChB,YAAY,MAAM;AAAA,UAClB,YAAY,MAAM;AAAA,UAClB,gBAAgB,MAAM;AAAA,QACxB,CAAC;AAAA,MACH;AAAA,IACF;AAEA,WAAO,OACJ;AAAA,MAAS,CAACA,YACTA,QAAO,IAAI,CAAC,SAAS;AAAA,QACnB,WAAW,IAAI;AAAA,QACf,OAAO,IAAI;AAAA,MACb,EAAE;AAAA,IACJ,EACC,MAAM;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAa,mBACX,WACA,OACyB;AACzB,UAAM,SAAS,MAAM,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,QACE,YAAY,WAAW;AAAA,UACrB,YAAY,MAAM;AAAA,UAClB,UAAU,MAAM;AAAA,UAChB,YAAY,MAAM;AAAA,UAClB,YAAY,MAAM;AAAA,QACpB,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO,OACJ;AAAA,MAAS,CAACA,YACTA,QAAO,IAAI,CAAC,SAAS;AAAA,QACnB,WAAW,IAAI;AAAA,QACf,OAAO,IAAI;AAAA,MACb,EAAE;AAAA,IACJ,EACC,MAAM;AAAA,EACX;AACF;",
6
- "names": ["result"]
7
- }
@@ -1,14 +0,0 @@
1
- import { Kwil } from "@kwilteam/kwil-js/dist/client/kwil";
2
- import { EnvironmentType } from "@kwilteam/kwil-js/dist/core/enums";
3
- import { StreamLocator } from "../types/stream";
4
- import { EthereumAddress } from "../util/EthereumAddress";
5
- import { Database } from "@kwilteam/kwil-js/dist/core/database";
6
- /**
7
- * List all streams from the TN network.
8
- * @param kwilClient - The Kwil client.
9
- * @param owner - The owner of the streams. If not provided, all streams will be returned.
10
- * @returns A list of stream locators.
11
- */
12
- export declare function listAllStreams(kwilClient: Kwil<EnvironmentType>, owner?: EthereumAddress): Promise<StreamLocator[]>;
13
- export declare const isStream: (schema: Database) => boolean;
14
- //# sourceMappingURL=listAllStreams.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listAllStreams.d.ts","sourceRoot":"","sources":["../../../src/client/listAllStreams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,EACjC,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CAiB1B;AAED,eAAO,MAAM,QAAQ,WAAY,QAAQ,YAKxC,CAAC"}
@@ -1,6 +0,0 @@
1
- import composedStreamTemplate from "./composed_stream_template.json";
2
- import primitiveStreamTemplate from "./primitive_stream_template.json";
3
- import composedStreamTemplateUnix from "./composed_stream_template_unix.json";
4
- import primitiveStreamTemplateUnix from "./primitive_stream_template_unix.json";
5
- export { composedStreamTemplate, primitiveStreamTemplate, composedStreamTemplateUnix, primitiveStreamTemplateUnix };
6
- //# sourceMappingURL=contractsContent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contractsContent.d.ts","sourceRoot":"","sources":["../../../src/contracts/contractsContent.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,iCAAiC,CAAuB;AAC3F,OAAO,uBAAuB,MA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U,WAAW,CACtB,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAyBtC;;;;OAIG;WACW,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;CAOzD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"destroyStream.d.ts","sourceRoot":"","sources":["../../../src/contracts-api/destroyStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAGrE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,SAAS,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAkBrC"}
@@ -1,39 +0,0 @@
1
- import { KwilSigner, NodeKwil, WebKwil } from "@kwilteam/kwil-js";
2
- import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq";
3
- import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx";
4
- import { StreamLocator } from "../types/stream";
5
- import { Stream } from "./stream";
6
- export declare class PrimitiveStream extends Stream {
7
- constructor(kwilClient: WebKwil | NodeKwil, kwilSigner: KwilSigner, locator: StreamLocator);
8
- /**
9
- * Checks if the stream is a valid primitive stream.
10
- * A valid primitive stream must be:
11
- * - initialized
12
- * - of type primitive
13
- */
14
- private checkValidPrimitiveStream;
15
- /**
16
- * Executes a method after checking if the stream is a valid primitive stream
17
- * @param method The method name to execute
18
- * @param inputs The inputs for the action
19
- * @returns A generic response containing the transaction receipt
20
- */
21
- private checkedPrimitiveExecute;
22
- /**
23
- * Inserts records into the stream
24
- * @param inputs Array of records to insert
25
- * @returns Transaction receipt
26
- */
27
- insertRecords(inputs: InsertRecordInput[]): Promise<GenericResponse<TxReceipt>>;
28
- /**
29
- * Creates a PrimitiveStream from a base Stream
30
- * @param stream The base stream to convert
31
- * @returns A Promise that resolves to a PrimitiveStream instance
32
- */
33
- static fromStream(stream: Stream): PrimitiveStream;
34
- }
35
- export interface InsertRecordInput {
36
- dateValue: string | number;
37
- value: string;
38
- }
39
- //# sourceMappingURL=primitiveStream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitiveStream.d.ts","sourceRoot":"","sources":["../../../src/contracts-api/primitiveStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,qBAAa,eAAgB,SAAQ,MAAM;gBAEvC,UAAU,EAAE,OAAO,GAAG,QAAQ,EAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,aAAa;IAKxB;;;;;OAKG;YACW,yBAAyB;IAWvC;;;;;OAKG;YACW,uBAAuB;IAQrC;;;;OAIG;IACU,aAAa,CACxB,MAAM,EAAE,iBAAiB,EAAE,GAC1B,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAatC;;;;OAIG;WACW,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAS1D;AACD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1,142 +0,0 @@
1
- import { KwilSigner, NodeKwil, WebKwil } from "@kwilteam/kwil-js";
2
- import { ActionInput } from "@kwilteam/kwil-js/dist/core/action";
3
- import { Database } from "@kwilteam/kwil-js/dist/core/database";
4
- import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq";
5
- import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx";
6
- import { Either } from "monads-io";
7
- import { DateString } from "../types/other";
8
- import { StreamLocator } from "../types/stream";
9
- import { EthereumAddress } from "../util/EthereumAddress";
10
- import { VisibilityEnum } from "../util/visibility";
11
- import { MetadataKey, MetadataValueTypeForKey, StreamType } from "./contractValues";
12
- export interface GetRecordInput {
13
- dateFrom?: DateString | number;
14
- dateTo?: DateString | number;
15
- frozenAt?: number;
16
- baseDate?: DateString | number;
17
- }
18
- export interface GetFirstRecordInput {
19
- afterDate?: DateString | number;
20
- frozenAt?: DateString | number;
21
- }
22
- export interface StreamRecord {
23
- dateValue: DateString | number;
24
- value: string;
25
- }
26
- export interface GetIndexChangeInput extends GetRecordInput {
27
- daysInterval: number;
28
- }
29
- export declare class Stream {
30
- protected kwilClient: WebKwil | NodeKwil;
31
- protected kwilSigner: KwilSigner;
32
- protected locator: StreamLocator;
33
- protected dbid: string;
34
- protected schema?: Database;
35
- protected deployed: boolean;
36
- protected initialized: boolean;
37
- constructor(kwilClient: WebKwil | NodeKwil, kwilSigner: KwilSigner, locator: StreamLocator);
38
- /**
39
- * Loads the schema for this stream from the network.
40
- * Throws if the stream is not deployed.
41
- */
42
- loadSchema(): Promise<void>;
43
- /**
44
- * Executes a method on the stream
45
- */
46
- protected execute(method: string, inputs: ActionInput[]): Promise<GenericResponse<TxReceipt>>;
47
- /**
48
- * Executes a method on the stream after checking if it's initialized
49
- */
50
- protected checkedExecute(method: string, inputs: ActionInput[]): Promise<GenericResponse<TxReceipt>>;
51
- /**
52
- * Calls a method on the stream
53
- */
54
- protected call<T>(method: string, inputs: ActionInput[]): Promise<Either<number, T>>;
55
- /**
56
- * Checks if the stream is initialized
57
- */
58
- protected checkInitialized(expectedType?: StreamType): Promise<void>;
59
- /**
60
- * Checks if the stream is deployed
61
- */
62
- protected checkDeployed(): Promise<void>;
63
- /**
64
- * Initializes the stream
65
- */
66
- initializeStream(): Promise<GenericResponse<TxReceipt>>;
67
- /**
68
- * Returns the records of the stream within the given date range
69
- */
70
- getRecord(input: GetRecordInput): Promise<StreamRecord[]>;
71
- /**
72
- * Returns the index of the stream within the given date range
73
- */
74
- getIndex(input: GetRecordInput): Promise<StreamRecord[]>;
75
- /**
76
- * Returns the type of the stream
77
- */
78
- getType(): Promise<StreamType>;
79
- /**
80
- * Returns the first record of the stream
81
- */
82
- getFirstRecord(input: GetFirstRecordInput): Promise<StreamRecord | null>;
83
- protected setMetadata<K extends MetadataKey>(key: K, value: MetadataValueTypeForKey<K>): Promise<GenericResponse<TxReceipt>>;
84
- protected getMetadata<K extends MetadataKey>(key: K, onlyLatest?: boolean, filteredRef?: string): Promise<{
85
- rowId: string;
86
- value: MetadataValueTypeForKey<K>;
87
- createdAt: number;
88
- }[]>;
89
- /**
90
- * Sets the read visibility of the stream
91
- */
92
- setReadVisibility(visibility: VisibilityEnum): Promise<GenericResponse<TxReceipt>>;
93
- /**
94
- * Returns the read visibility of the stream
95
- */
96
- getReadVisibility(): Promise<VisibilityEnum | null>;
97
- /**
98
- * Sets the compose visibility of the stream
99
- */
100
- setComposeVisibility(visibility: VisibilityEnum): Promise<GenericResponse<TxReceipt>>;
101
- /**
102
- * Returns the compose visibility of the stream
103
- */
104
- getComposeVisibility(): Promise<VisibilityEnum | null>;
105
- /**
106
- * Allows a wallet to read the stream
107
- */
108
- allowReadWallet(wallet: EthereumAddress): Promise<GenericResponse<TxReceipt>>;
109
- /**
110
- * Disables a wallet from reading the stream
111
- */
112
- disableReadWallet(wallet: EthereumAddress): Promise<GenericResponse<TxReceipt>>;
113
- /**
114
- * Allows a stream to use this stream as child
115
- */
116
- allowComposeStream(locator: StreamLocator): Promise<GenericResponse<TxReceipt>>;
117
- /**
118
- * Disables a stream from using this stream as child
119
- */
120
- disableComposeStream(locator: StreamLocator): Promise<GenericResponse<TxReceipt>>;
121
- protected disableMetadata(rowId: string): Promise<GenericResponse<TxReceipt>>;
122
- /**
123
- * Returns the wallets allowed to read the stream
124
- */
125
- getAllowedReadWallets(): Promise<EthereumAddress[]>;
126
- /**
127
- * Returns the streams allowed to compose the stream
128
- */
129
- getAllowedComposeStreams(): Promise<StreamLocator[]>;
130
- /**
131
- * Returns the index change of the stream within the given date range
132
- */
133
- getIndexChange(input: GetIndexChangeInput): Promise<StreamRecord[]>;
134
- /**
135
- * A custom method that accepts the procedure name and the input of GetRecordInput
136
- * Returns the result of the procedure in the same format as StreamRecord
137
- * I.e. a custom procedure named "get_price" that returns a list of date_value and value
138
- * can be called with customGetProcedure("get_price", { dateFrom: "2021-01-01", dateTo: "2021-01-31" })
139
- */
140
- customGetProcedure(procedure: string, input: GetRecordInput): Promise<StreamRecord[]>;
141
- }
142
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/contracts-api/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,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