@arkiv-network/sdk 0.7.0-dev.1 → 0.8.0-dev.1

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 (210) hide show
  1. package/README.md +29 -16
  2. package/dist/attr/index.cjs +34 -0
  3. package/dist/attr/index.d.cts +2 -0
  4. package/dist/attr/index.d.ts +2 -0
  5. package/dist/attr/index.js +3 -0
  6. package/dist/attr-BDZ-APg5.js +809 -0
  7. package/dist/attr-BDZ-APg5.js.map +1 -0
  8. package/dist/attr-BvxHN99W.cjs +1029 -0
  9. package/dist/chains/index.cjs +2 -3
  10. package/dist/chains/index.d.cts +22 -60
  11. package/dist/chains/index.d.cts.map +1 -1
  12. package/dist/chains/index.d.ts +22 -60
  13. package/dist/chains/index.d.ts.map +1 -1
  14. package/dist/chains/index.js +2 -2
  15. package/dist/chains-BJrZs6sG.js +57 -0
  16. package/dist/chains-BJrZs6sG.js.map +1 -0
  17. package/dist/chains-BYRTTipa.cjs +73 -0
  18. package/dist/changeOwnership-B7bEgla4.d.cts +509 -0
  19. package/dist/changeOwnership-B7bEgla4.d.cts.map +1 -0
  20. package/dist/changeOwnership-DwgtdSFc.d.ts +509 -0
  21. package/dist/changeOwnership-DwgtdSFc.d.ts.map +1 -0
  22. package/dist/entity/index.cjs +19 -0
  23. package/dist/entity/index.d.cts +4 -0
  24. package/dist/entity/index.d.ts +4 -0
  25. package/dist/entity/index.js +6 -0
  26. package/dist/entity-B0t6sN7F.cjs +71 -0
  27. package/dist/entity-BIp_df9u.js +67 -0
  28. package/dist/entity-BIp_df9u.js.map +1 -0
  29. package/dist/entity-CFhbAv0R.js +70 -0
  30. package/dist/entity-CFhbAv0R.js.map +1 -0
  31. package/dist/entity-wfBnZd91.cjs +98 -0
  32. package/dist/errors-D-eJkGVc.cjs +56 -0
  33. package/dist/errors-DGB8AgT2.js +33 -0
  34. package/dist/errors-DGB8AgT2.js.map +1 -0
  35. package/dist/expiry-BUYIXTGb.cjs +135 -0
  36. package/dist/expiry-BxOlvVWC.d.ts +79 -0
  37. package/dist/expiry-BxOlvVWC.d.ts.map +1 -0
  38. package/dist/expiry-DGRzrSan.js +95 -0
  39. package/dist/expiry-DGRzrSan.js.map +1 -0
  40. package/dist/expiry-DRV29F1r.d.cts +79 -0
  41. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  42. package/dist/flags-0Vl5rrHq.d.cts +41 -0
  43. package/dist/flags-0Vl5rrHq.d.cts.map +1 -0
  44. package/dist/flags-Ct8k0gpB.cjs +43 -0
  45. package/dist/flags-ZtlvOIIk.js +33 -0
  46. package/dist/flags-ZtlvOIIk.js.map +1 -0
  47. package/dist/flags-wmcMoAnN.d.ts +41 -0
  48. package/dist/flags-wmcMoAnN.d.ts.map +1 -0
  49. package/dist/index-Cgw1u5aY.d.cts +278 -0
  50. package/dist/index-Cgw1u5aY.d.cts.map +1 -0
  51. package/dist/index-ClgIuxJ8.d.ts +159 -0
  52. package/dist/index-ClgIuxJ8.d.ts.map +1 -0
  53. package/dist/index-D0CmtiWT.d.cts +159 -0
  54. package/dist/index-D0CmtiWT.d.cts.map +1 -0
  55. package/dist/index-D8LZt-3J.d.cts +417 -0
  56. package/dist/index-D8LZt-3J.d.cts.map +1 -0
  57. package/dist/index-DVYFaXNV.d.ts +417 -0
  58. package/dist/index-DVYFaXNV.d.ts.map +1 -0
  59. package/dist/index-VCqgn29D.d.ts +278 -0
  60. package/dist/index-VCqgn29D.d.ts.map +1 -0
  61. package/dist/index.cjs +676 -375
  62. package/dist/index.d.cts +247 -208
  63. package/dist/index.d.cts.map +1 -1
  64. package/dist/index.d.ts +247 -208
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +626 -368
  67. package/dist/index.js.map +1 -1
  68. package/dist/payload-Bnw1hrvb.cjs +83 -0
  69. package/dist/payload-CIxSn_DW.js +67 -0
  70. package/dist/payload-CIxSn_DW.js.map +1 -0
  71. package/dist/payload-Dgx3PQeK.d.ts +94 -0
  72. package/dist/payload-Dgx3PQeK.d.ts.map +1 -0
  73. package/dist/payload-P0nWyjLg.d.cts +94 -0
  74. package/dist/payload-P0nWyjLg.d.cts.map +1 -0
  75. package/dist/query/index.cjs +24 -150
  76. package/dist/query/index.d.cts +5 -3
  77. package/dist/query/index.d.ts +5 -3
  78. package/dist/query/index.js +6 -138
  79. package/dist/queryBuilder-BXDvX1K_.cjs +1123 -0
  80. package/dist/queryBuilder-CbLL4pG5.js +963 -0
  81. package/dist/queryBuilder-CbLL4pG5.js.map +1 -0
  82. package/dist/selection-BvK6yX0g.d.cts +433 -0
  83. package/dist/selection-BvK6yX0g.d.cts.map +1 -0
  84. package/dist/selection-fpmI3ADQ.d.ts +433 -0
  85. package/dist/selection-fpmI3ADQ.d.ts.map +1 -0
  86. package/dist/types/index.cjs +3 -3
  87. package/dist/types/index.d.cts +7 -2
  88. package/dist/types/index.d.ts +7 -2
  89. package/dist/types/index.js +3 -3
  90. package/dist/utils/index.cjs +4 -17
  91. package/dist/utils/index.d.cts +3 -17
  92. package/dist/utils/index.d.ts +3 -17
  93. package/dist/utils/index.js +4 -18
  94. package/package.json +26 -5
  95. package/src/actions/public/getEntity.ts +27 -43
  96. package/src/actions/public/getEntityNonce.ts +30 -0
  97. package/src/actions/public/predictEntityKeys.test.ts +143 -0
  98. package/src/actions/public/predictEntityKeys.ts +138 -0
  99. package/src/actions/public/query.ts +33 -69
  100. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  101. package/src/actions/public/watchEntityEvents.ts +225 -0
  102. package/src/actions/wallet/changeOwnership.ts +2 -2
  103. package/src/actions/wallet/createEntity.ts +99 -24
  104. package/src/actions/wallet/extendEntity.ts +37 -13
  105. package/src/actions/wallet/mutateEntities.test.ts +76 -0
  106. package/src/actions/wallet/mutateEntities.ts +19 -21
  107. package/src/actions/wallet/patchEntity.ts +90 -0
  108. package/src/attr/attributes.test.ts +120 -0
  109. package/src/attr/attributes.ts +190 -0
  110. package/src/attr/codec.test.ts +162 -0
  111. package/src/attr/codec.ts +220 -0
  112. package/src/attr/decimal.ts +86 -0
  113. package/src/attr/errors.ts +145 -0
  114. package/src/attr/index.ts +50 -0
  115. package/src/attr/names.ts +106 -0
  116. package/src/attr/types.ts +150 -0
  117. package/src/attr/values.test.ts +271 -0
  118. package/src/attr/values.ts +502 -0
  119. package/src/chains/cheesecake.ts +22 -0
  120. package/src/chains/index.ts +1 -2
  121. package/src/clients/createPublicClient.test.ts +3 -5
  122. package/src/clients/createPublicClient.ts +5 -4
  123. package/src/clients/createWalletClient.test.ts +2 -2
  124. package/src/clients/createWalletClient.ts +13 -7
  125. package/src/clients/decorators/arkivPublic.ts +160 -139
  126. package/src/clients/decorators/arkivWallet.ts +86 -94
  127. package/src/entity/create.test.ts +184 -0
  128. package/src/entity/errors.ts +38 -0
  129. package/src/entity/events.ts +16 -0
  130. package/src/entity/expiry.test.ts +195 -0
  131. package/src/entity/expiry.ts +181 -0
  132. package/src/entity/flags.ts +65 -0
  133. package/src/entity/index.ts +14 -0
  134. package/src/entity/key.ts +68 -0
  135. package/src/entity/operations.ts +134 -0
  136. package/src/entity/params.ts +15 -0
  137. package/src/errors.ts +26 -49
  138. package/src/index.ts +6 -0
  139. package/src/query/engine.ts +59 -139
  140. package/src/query/errors.ts +151 -0
  141. package/src/query/expression.test.ts +286 -0
  142. package/src/query/expression.ts +493 -0
  143. package/src/query/index.ts +40 -4
  144. package/src/query/injection.test.ts +151 -0
  145. package/src/query/queryBuilder.test.ts +322 -637
  146. package/src/query/queryBuilder.ts +126 -359
  147. package/src/query/queryResult.ts +54 -51
  148. package/src/query/selection.test.ts +48 -98
  149. package/src/query/selection.ts +77 -65
  150. package/src/types/entity.test.ts +44 -155
  151. package/src/types/entity.ts +60 -52
  152. package/src/types/events.ts +59 -16
  153. package/src/types/index.ts +20 -17
  154. package/src/types/rpcSchema.ts +69 -37
  155. package/src/utils/arkivTransactions.test.ts +600 -155
  156. package/src/utils/arkivTransactions.ts +181 -190
  157. package/src/utils/chains.test.ts +21 -24
  158. package/src/utils/compression.ts +1 -1
  159. package/src/utils/entities.test.ts +62 -0
  160. package/src/utils/entities.ts +109 -37
  161. package/src/utils/expirationTime.ts +114 -10
  162. package/src/utils/logger.ts +2 -2
  163. package/src/utils/revert.test.ts +99 -0
  164. package/src/utils/revert.ts +145 -0
  165. package/dist/chains-BifaY04V.cjs +0 -108
  166. package/dist/chains-CrtkVbBh.js +0 -86
  167. package/dist/chains-CrtkVbBh.js.map +0 -1
  168. package/dist/consts-Bz0LZQZY.js +0 -7
  169. package/dist/consts-Bz0LZQZY.js.map +0 -1
  170. package/dist/consts-CxT1-RXU.cjs +0 -18
  171. package/dist/entity-BhSXaB23.cjs +0 -81
  172. package/dist/entity-CN41IOrq.d.cts +0 -401
  173. package/dist/entity-CN41IOrq.d.cts.map +0 -1
  174. package/dist/entity-DGfVyB-a.js +0 -71
  175. package/dist/entity-DGfVyB-a.js.map +0 -1
  176. package/dist/entity-NnEVlePN.d.ts +0 -401
  177. package/dist/entity-NnEVlePN.d.ts.map +0 -1
  178. package/dist/index-ClkpS6s_.d.ts +0 -481
  179. package/dist/index-ClkpS6s_.d.ts.map +0 -1
  180. package/dist/index-w4qop0Pe.d.cts +0 -481
  181. package/dist/index-w4qop0Pe.d.cts.map +0 -1
  182. package/dist/payload-BpNUPOnY.js +0 -13
  183. package/dist/payload-BpNUPOnY.js.map +0 -1
  184. package/dist/payload-C2KHOUoj.d.ts +0 -6
  185. package/dist/payload-C2KHOUoj.d.ts.map +0 -1
  186. package/dist/payload-CJN8fTvX.d.cts +0 -6
  187. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  188. package/dist/payload-D8YLKcJj.cjs +0 -23
  189. package/dist/query/index.js.map +0 -1
  190. package/dist/queryBuilder-BE_XhLLa.js +0 -735
  191. package/dist/queryBuilder-BE_XhLLa.js.map +0 -1
  192. package/dist/queryBuilder-J37buGCi.cjs +0 -865
  193. package/dist/utils/index.d.cts.map +0 -1
  194. package/dist/utils/index.d.ts.map +0 -1
  195. package/dist/utils/index.js.map +0 -1
  196. package/src/actions/public/buildQuery.ts +0 -10
  197. package/src/actions/public/subscribeEntityEvents.ts +0 -93
  198. package/src/actions/wallet/updateEntity.ts +0 -59
  199. package/src/chains/braga.ts +0 -26
  200. package/src/chains/kaolin.ts +0 -29
  201. package/src/query/engine.test.ts +0 -571
  202. package/src/query/predicate.test.ts +0 -461
  203. package/src/query/predicate.ts +0 -144
  204. package/src/query/queryResult.test.ts +0 -270
  205. package/src/query/selectQueryBuilder.test.ts +0 -213
  206. package/src/types/attributes.ts +0 -28
  207. package/src/utils/validation.test.ts +0 -106
  208. package/src/utils/validation.ts +0 -80
  209. /package/dist/{types-Ci4BRClw.js → types-Bx1EKe0v.js} +0 -0
  210. /package/dist/{types-a8gm_IaQ.cjs → types-CKPddlfS.cjs} +0 -0
@@ -1,571 +0,0 @@
1
- import { describe, expect, it, jest } from "bun:test"
2
- import { numberToHex } from "viem"
3
- import type { ArkivClient } from "../clients/baseClient"
4
- import { processQuery } from "./engine"
5
- import type { Predicate } from "./predicate"
6
-
7
- describe("processQuery tests", () => {
8
- const client = {
9
- request: jest.fn(),
10
- } as unknown as ArkivClient
11
-
12
- it("should process single predicate", async () => {
13
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
14
- await processQuery(client, {
15
- predicates,
16
- limit: undefined,
17
- cursor: undefined,
18
- ownedBy: undefined,
19
- createdBy: undefined,
20
- orderBy: undefined,
21
- validAtBlock: undefined,
22
- withAttributes: undefined,
23
- withMetadata: undefined,
24
- withPayload: undefined,
25
- })
26
-
27
- expect(client.request).lastCalledWith({
28
- method: "arkiv_query",
29
- params: [
30
- `key = "value"`,
31
- {
32
- includeData: {
33
- key: true,
34
- attributes: false,
35
- contentType: false,
36
- payload: false,
37
- expiration: false,
38
- owner: false,
39
- creator: false,
40
- createdAtBlock: false,
41
- lastModifiedAtBlock: false,
42
- transactionIndexInBlock: false,
43
- operationIndexInTransaction: false,
44
- },
45
- },
46
- ],
47
- })
48
- })
49
-
50
- it("should serialize 32-byte hex values as unquoted literals and other hex as strings", async () => {
51
- const hexValue = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
52
- const predicates = [
53
- { type: "eq" as const, key: "hexattr", value: hexValue },
54
- { type: "eq" as const, key: "strattr", value: "value" },
55
- // hex-looking but not 32 bytes — stored as strings, so compared quoted
56
- { type: "eq" as const, key: "shorthex", value: "0xab" },
57
- { type: "eq" as const, key: "addrhex", value: "0x6186b0dba9652262942d5a465d49686eb560834c" },
58
- ]
59
- await processQuery(client, {
60
- predicates,
61
- limit: undefined,
62
- cursor: undefined,
63
- ownedBy: undefined,
64
- createdBy: undefined,
65
- orderBy: undefined,
66
- validAtBlock: undefined,
67
- withAttributes: undefined,
68
- withMetadata: undefined,
69
- withPayload: undefined,
70
- })
71
-
72
- expect(client.request).lastCalledWith({
73
- method: "arkiv_query",
74
- params: [
75
- `hexattr = ${hexValue} && strattr = "value" && shorthex = "0xab" && addrhex = "0x6186b0dba9652262942d5a465d49686eb560834c"`,
76
- {
77
- includeData: {
78
- key: true,
79
- attributes: false,
80
- contentType: false,
81
- payload: false,
82
- expiration: false,
83
- owner: false,
84
- creator: false,
85
- createdAtBlock: false,
86
- lastModifiedAtBlock: false,
87
- transactionIndexInBlock: false,
88
- operationIndexInTransaction: false,
89
- },
90
- },
91
- ],
92
- })
93
- })
94
-
95
- it("should process all simple predicates - flat", async () => {
96
- const predicates = [
97
- { type: "eq" as const, key: "key", value: "value" },
98
- { type: "gt" as const, key: "key2", value: 1 },
99
- { type: "gte" as const, key: "key3", value: 2 },
100
- { type: "lt" as const, key: "key4", value: 3 },
101
- { type: "lte" as const, key: "key5", value: 4 },
102
- { type: "neq" as const, key: "key6", value: "value6" },
103
- ]
104
- await processQuery(client, {
105
- predicates,
106
- limit: undefined,
107
- cursor: undefined,
108
- ownedBy: undefined,
109
- createdBy: undefined,
110
- orderBy: undefined,
111
- validAtBlock: undefined,
112
- withAttributes: undefined,
113
- withMetadata: undefined,
114
- })
115
-
116
- expect(client.request).lastCalledWith({
117
- method: "arkiv_query",
118
- params: [
119
- `key = "value" && key2 > 1 && key3 >= 2 && key4 < 3 && key5 <= 4 && key6 != "value6"`,
120
- {
121
- includeData: {
122
- key: true,
123
- attributes: false,
124
- contentType: false,
125
- payload: false,
126
- expiration: false,
127
- owner: false,
128
- creator: false,
129
- createdAtBlock: false,
130
- lastModifiedAtBlock: false,
131
- transactionIndexInBlock: false,
132
- operationIndexInTransaction: false,
133
- },
134
- },
135
- ],
136
- })
137
- })
138
-
139
- it("should process multiple predicates - nested with or", async () => {
140
- const predicates = [
141
- { type: "eq" as const, key: "key", value: "value" },
142
- {
143
- type: "or" as const,
144
- predicates: [
145
- { type: "eq" as const, key: "key2", value: "value2" },
146
- { type: "eq" as const, key: "key3", value: "value3" },
147
- ],
148
- },
149
- ]
150
- await processQuery(client, {
151
- predicates,
152
- limit: undefined,
153
- cursor: undefined,
154
- ownedBy: undefined,
155
- createdBy: undefined,
156
- orderBy: undefined,
157
- validAtBlock: undefined,
158
- withAttributes: undefined,
159
- withMetadata: undefined,
160
- })
161
-
162
- expect(client.request).lastCalledWith({
163
- method: "arkiv_query",
164
- params: [
165
- `key = "value" && (key2 = "value2" || key3 = "value3")`,
166
- {
167
- includeData: {
168
- key: true,
169
- attributes: false,
170
- contentType: false,
171
- payload: false,
172
- expiration: false,
173
- owner: false,
174
- creator: false,
175
- createdAtBlock: false,
176
- lastModifiedAtBlock: false,
177
- transactionIndexInBlock: false,
178
- operationIndexInTransaction: false,
179
- },
180
- },
181
- ],
182
- })
183
- })
184
-
185
- it("should process multiple predicates - nested with and", async () => {
186
- const predicates = [
187
- { type: "eq" as const, key: "key", value: "value" },
188
- {
189
- type: "and" as const,
190
- predicates: [
191
- { type: "eq" as const, key: "key2", value: "value2" },
192
- { type: "eq" as const, key: "key3", value: "value3" },
193
- ],
194
- },
195
- ]
196
- await processQuery(client, {
197
- predicates,
198
- limit: undefined,
199
- cursor: undefined,
200
- ownedBy: undefined,
201
- createdBy: undefined,
202
- orderBy: undefined,
203
- validAtBlock: undefined,
204
- withAttributes: undefined,
205
- withMetadata: undefined,
206
- })
207
-
208
- expect(client.request).lastCalledWith({
209
- method: "arkiv_query",
210
- params: [
211
- `key = "value" && (key2 = "value2" && key3 = "value3")`,
212
- {
213
- includeData: {
214
- key: true,
215
- attributes: false,
216
- contentType: false,
217
- payload: false,
218
- expiration: false,
219
- owner: false,
220
- creator: false,
221
- createdAtBlock: false,
222
- lastModifiedAtBlock: false,
223
- transactionIndexInBlock: false,
224
- operationIndexInTransaction: false,
225
- },
226
- },
227
- ],
228
- })
229
- })
230
-
231
- it("should process multiple predicates - nested with and and or", async () => {
232
- const predicates = [
233
- { type: "eq" as const, key: "key", value: "value" },
234
- {
235
- type: "and" as const,
236
- predicates: [
237
- { type: "eq" as const, key: "key2", value: "value2" },
238
- {
239
- type: "or" as const,
240
- predicates: [
241
- { type: "eq" as const, key: "key3", value: "value3" },
242
- { type: "eq" as const, key: "key4", value: "value4" },
243
- ],
244
- },
245
- ],
246
- },
247
- ]
248
- await processQuery(client, {
249
- predicates,
250
- limit: undefined,
251
- cursor: undefined,
252
- ownedBy: undefined,
253
- createdBy: undefined,
254
- orderBy: undefined,
255
- validAtBlock: undefined,
256
- withAttributes: undefined,
257
- withMetadata: undefined,
258
- })
259
-
260
- expect(client.request).lastCalledWith({
261
- method: "arkiv_query",
262
- params: [
263
- `key = "value" && (key2 = "value2" && (key3 = "value3" || key4 = "value4"))`,
264
- {
265
- includeData: {
266
- key: true,
267
- attributes: false,
268
- contentType: false,
269
- payload: false,
270
- expiration: false,
271
- owner: false,
272
- creator: false,
273
- createdAtBlock: false,
274
- lastModifiedAtBlock: false,
275
- transactionIndexInBlock: false,
276
- operationIndexInTransaction: false,
277
- },
278
- },
279
- ],
280
- })
281
- })
282
-
283
- it("should process simple predicates with ownedBy", async () => {
284
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
285
- await processQuery(client, {
286
- predicates,
287
- orderBy: undefined,
288
- limit: undefined,
289
- cursor: undefined,
290
- ownedBy: "0x123",
291
- createdBy: undefined,
292
- })
293
-
294
- expect(client.request).lastCalledWith({
295
- method: "arkiv_query",
296
- params: [
297
- `key = "value" && $owner=0x123`,
298
- {
299
- includeData: {
300
- key: true,
301
- attributes: false,
302
- contentType: false,
303
- payload: false,
304
- expiration: false,
305
- owner: false,
306
- creator: false,
307
- createdAtBlock: false,
308
- lastModifiedAtBlock: false,
309
- transactionIndexInBlock: false,
310
- operationIndexInTransaction: false,
311
- },
312
- },
313
- ],
314
- })
315
- })
316
-
317
- it("should process only ownedBy", async () => {
318
- const predicates = [] as Predicate[]
319
- await processQuery(client, {
320
- predicates,
321
- limit: undefined,
322
- cursor: undefined,
323
- orderBy: undefined,
324
- validAtBlock: undefined,
325
- withAttributes: undefined,
326
- withMetadata: undefined,
327
- ownedBy: "0x123",
328
- createdBy: undefined,
329
- })
330
-
331
- expect(client.request).lastCalledWith({
332
- method: "arkiv_query",
333
- params: [
334
- `$owner=0x123`,
335
- {
336
- includeData: {
337
- key: true,
338
- attributes: false,
339
- contentType: false,
340
- payload: false,
341
- expiration: false,
342
- owner: false,
343
- creator: false,
344
- createdAtBlock: false,
345
- lastModifiedAtBlock: false,
346
- transactionIndexInBlock: false,
347
- operationIndexInTransaction: false,
348
- },
349
- },
350
- ],
351
- })
352
- })
353
-
354
- it("should process simple predicates with createdBy", async () => {
355
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
356
- await processQuery(client, {
357
- predicates,
358
- orderBy: undefined,
359
- limit: undefined,
360
- cursor: undefined,
361
- ownedBy: undefined,
362
- createdBy: "0x123",
363
- })
364
-
365
- expect(client.request).lastCalledWith({
366
- method: "arkiv_query",
367
- params: [
368
- `key = "value" && $creator=0x123`,
369
- {
370
- includeData: {
371
- key: true,
372
- attributes: false,
373
- contentType: false,
374
- payload: false,
375
- expiration: false,
376
- owner: false,
377
- creator: false,
378
- createdAtBlock: false,
379
- lastModifiedAtBlock: false,
380
- transactionIndexInBlock: false,
381
- operationIndexInTransaction: false,
382
- },
383
- },
384
- ],
385
- })
386
- })
387
-
388
- it("should process only createdBy", async () => {
389
- const predicates = [] as Predicate[]
390
- await processQuery(client, {
391
- predicates,
392
- limit: undefined,
393
- cursor: undefined,
394
- orderBy: undefined,
395
- validAtBlock: undefined,
396
- withAttributes: undefined,
397
- withMetadata: undefined,
398
- ownedBy: undefined,
399
- createdBy: "0x123",
400
- })
401
-
402
- expect(client.request).lastCalledWith({
403
- method: "arkiv_query",
404
- params: [
405
- `$creator=0x123`,
406
- {
407
- includeData: {
408
- key: true,
409
- attributes: false,
410
- contentType: false,
411
- payload: false,
412
- expiration: false,
413
- owner: false,
414
- creator: false,
415
- createdAtBlock: false,
416
- lastModifiedAtBlock: false,
417
- transactionIndexInBlock: false,
418
- operationIndexInTransaction: false,
419
- },
420
- },
421
- ],
422
- })
423
- })
424
-
425
- it("should process simple predicates with orderBy", async () => {
426
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
427
- await processQuery(client, {
428
- predicates,
429
- orderBy: [{ name: "key", type: "string", desc: true }],
430
- limit: undefined,
431
- cursor: undefined,
432
- ownedBy: undefined,
433
- createdBy: undefined,
434
- })
435
-
436
- expect(client.request).lastCalledWith({
437
- method: "arkiv_query",
438
- params: [
439
- `key = "value"`,
440
- {
441
- orderBy: [{ name: "key", type: "string", desc: true }],
442
- includeData: {
443
- key: true,
444
- attributes: false,
445
- contentType: false,
446
- payload: false,
447
- expiration: false,
448
- owner: false,
449
- creator: false,
450
- createdAtBlock: false,
451
- lastModifiedAtBlock: false,
452
- transactionIndexInBlock: false,
453
- operationIndexInTransaction: false,
454
- },
455
- },
456
- ],
457
- })
458
- })
459
-
460
- it("should process only orderBy", async () => {
461
- const predicates = [] as Predicate[]
462
- await processQuery(client, {
463
- predicates,
464
- limit: undefined,
465
- cursor: undefined,
466
- ownedBy: undefined,
467
- createdBy: undefined,
468
- orderBy: [{ name: "key", type: "string", desc: true }],
469
- validAtBlock: undefined,
470
- withAttributes: undefined,
471
- withMetadata: undefined,
472
- })
473
-
474
- expect(client.request).lastCalledWith({
475
- method: "arkiv_query",
476
- params: [
477
- "",
478
- {
479
- orderBy: [{ name: "key", type: "string", desc: true }],
480
- includeData: {
481
- key: true,
482
- attributes: false,
483
- contentType: false,
484
- payload: false,
485
- expiration: false,
486
- owner: false,
487
- creator: false,
488
- createdAtBlock: false,
489
- lastModifiedAtBlock: false,
490
- transactionIndexInBlock: false,
491
- operationIndexInTransaction: false,
492
- },
493
- },
494
- ],
495
- })
496
- })
497
-
498
- it("should process simple predicate with validAtBlock and paging", async () => {
499
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
500
- await processQuery(client, {
501
- predicates,
502
- limit: 10,
503
- cursor: undefined,
504
- orderBy: undefined,
505
- validAtBlock: 123n,
506
- ownedBy: "0x123",
507
- createdBy: undefined,
508
- })
509
-
510
- expect(client.request).lastCalledWith({
511
- method: "arkiv_query",
512
- params: [
513
- `key = "value" && $owner=0x123`,
514
- {
515
- atBlock: numberToHex(123n),
516
- resultsPerPage: numberToHex(10),
517
- includeData: {
518
- key: true,
519
- attributes: false,
520
- contentType: false,
521
- payload: false,
522
- expiration: false,
523
- owner: false,
524
- creator: false,
525
- createdAtBlock: false,
526
- lastModifiedAtBlock: false,
527
- transactionIndexInBlock: false,
528
- operationIndexInTransaction: false,
529
- },
530
- },
531
- ],
532
- })
533
- })
534
-
535
- it("should includeData all metadata if withMetadata is true", async () => {
536
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
537
- await processQuery(client, {
538
- predicates,
539
- limit: 10,
540
- cursor: undefined,
541
- orderBy: undefined,
542
- validAtBlock: undefined,
543
- ownedBy: "0x123",
544
- createdBy: undefined,
545
- withMetadata: true,
546
- })
547
-
548
- expect(client.request).lastCalledWith({
549
- method: "arkiv_query",
550
- params: [
551
- `key = "value" && $owner=0x123`,
552
- {
553
- resultsPerPage: numberToHex(10),
554
- includeData: {
555
- key: true,
556
- attributes: false,
557
- contentType: true,
558
- payload: false,
559
- expiration: true,
560
- owner: true,
561
- creator: true,
562
- createdAtBlock: true,
563
- lastModifiedAtBlock: true,
564
- transactionIndexInBlock: true,
565
- operationIndexInTransaction: true,
566
- },
567
- },
568
- ],
569
- })
570
- })
571
- })