@arkiv-network/sdk 0.7.0 → 0.8.0-advanced.2

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 (237) hide show
  1. package/README.md +71 -16
  2. package/dist/actions/advanced/index.cjs +13 -0
  3. package/dist/actions/advanced/index.d.cts +8 -0
  4. package/dist/actions/advanced/index.d.ts +9 -0
  5. package/dist/actions/advanced/index.js +9 -0
  6. package/dist/advanced-8ZPTmmaN.js +598 -0
  7. package/dist/advanced-8ZPTmmaN.js.map +1 -0
  8. package/dist/advanced-fPImL6lW.cjs +656 -0
  9. package/dist/arkivTransactions-D74gERHG.d.cts +571 -0
  10. package/dist/arkivTransactions-D74gERHG.d.cts.map +1 -0
  11. package/dist/arkivTransactions-NtGD6uk5.d.ts +571 -0
  12. package/dist/arkivTransactions-NtGD6uk5.d.ts.map +1 -0
  13. package/dist/attr/index.cjs +35 -0
  14. package/dist/attr/index.d.cts +2 -0
  15. package/dist/attr/index.d.ts +3 -0
  16. package/dist/attr/index.js +4 -0
  17. package/dist/attributes-BhY5DwJp.js +809 -0
  18. package/dist/attributes-BhY5DwJp.js.map +1 -0
  19. package/dist/attributes-Df9IsCVs.cjs +1029 -0
  20. package/dist/chains/index.cjs +2 -3
  21. package/dist/chains/index.d.cts +39 -77
  22. package/dist/chains/index.d.cts.map +1 -1
  23. package/dist/chains/index.d.ts +22 -60
  24. package/dist/chains/index.d.ts.map +1 -1
  25. package/dist/chains/index.js +2 -2
  26. package/dist/chains-BJrZs6sG.js +57 -0
  27. package/dist/chains-BJrZs6sG.js.map +1 -0
  28. package/dist/chains-BYRTTipa.cjs +73 -0
  29. package/dist/codec-Car3KkFF.d.ts +102 -0
  30. package/dist/codec-Car3KkFF.d.ts.map +1 -0
  31. package/dist/entity/index.cjs +20 -0
  32. package/dist/entity/index.d.cts +4 -0
  33. package/dist/entity/index.d.ts +5 -0
  34. package/dist/entity/index.js +7 -0
  35. package/dist/entity-B00Li04j.cjs +71 -0
  36. package/dist/entity-B7G8q_Eo.cjs +0 -0
  37. package/dist/entity-BYQR1uoe.js +67 -0
  38. package/dist/entity-BYQR1uoe.js.map +1 -0
  39. package/dist/entity-CD_qFF2M.js +0 -0
  40. package/dist/errors-BVbjKVMN.cjs +56 -0
  41. package/dist/errors-LTe7bOYS.js +33 -0
  42. package/dist/errors-LTe7bOYS.js.map +1 -0
  43. package/dist/expiry-BELY2Kpw.cjs +135 -0
  44. package/dist/expiry-BjpxZZQU.js +95 -0
  45. package/dist/expiry-BjpxZZQU.js.map +1 -0
  46. package/dist/expiry-DRV29F1r.d.cts +79 -0
  47. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  48. package/dist/expiry-nDbCgZX4.d.ts +79 -0
  49. package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
  50. package/dist/flags-5dTNRnow.d.ts +41 -0
  51. package/dist/flags-5dTNRnow.d.ts.map +1 -0
  52. package/dist/flags-CRjPpoh3.d.cts +41 -0
  53. package/dist/flags-CRjPpoh3.d.cts.map +1 -0
  54. package/dist/flags-DFBs2J94.js +33 -0
  55. package/dist/flags-DFBs2J94.js.map +1 -0
  56. package/dist/flags-kr276q6i.cjs +43 -0
  57. package/dist/index-B5j76711.d.ts +184 -0
  58. package/dist/index-B5j76711.d.ts.map +1 -0
  59. package/dist/index-BF7Mq9Is.d.cts +280 -0
  60. package/dist/index-BF7Mq9Is.d.cts.map +1 -0
  61. package/dist/index-CA4V7Pdh.d.cts +167 -0
  62. package/dist/index-CA4V7Pdh.d.cts.map +1 -0
  63. package/dist/index-CV5zCdpa.d.cts +417 -0
  64. package/dist/index-CV5zCdpa.d.cts.map +1 -0
  65. package/dist/index-DHDud2hC.d.ts +280 -0
  66. package/dist/index-DHDud2hC.d.ts.map +1 -0
  67. package/dist/index-DvYvrkdk.d.ts +320 -0
  68. package/dist/index-DvYvrkdk.d.ts.map +1 -0
  69. package/dist/index-EeUO0nnJ.d.cts +184 -0
  70. package/dist/index-EeUO0nnJ.d.cts.map +1 -0
  71. package/dist/index-fX_XyqLp.d.ts +167 -0
  72. package/dist/index-fX_XyqLp.d.ts.map +1 -0
  73. package/dist/index.cjs +422 -399
  74. package/dist/index.d.cts +364 -204
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +365 -204
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +357 -389
  79. package/dist/index.js.map +1 -1
  80. package/dist/key-D1Bh7MF0.js +70 -0
  81. package/dist/key-D1Bh7MF0.js.map +1 -0
  82. package/dist/key-WKhXnXuU.cjs +98 -0
  83. package/dist/logger-CVpvU8ik.js +153 -0
  84. package/dist/logger-CVpvU8ik.js.map +1 -0
  85. package/dist/logger-Cr15lPAQ.cjs +188 -0
  86. package/dist/payload-BNoud2KZ.d.cts +94 -0
  87. package/dist/payload-BNoud2KZ.d.cts.map +1 -0
  88. package/dist/payload-Bz6651ax.js +67 -0
  89. package/dist/payload-Bz6651ax.js.map +1 -0
  90. package/dist/payload-CcUj85ys.d.ts +94 -0
  91. package/dist/payload-CcUj85ys.d.ts.map +1 -0
  92. package/dist/payload-KC14SDlN.cjs +83 -0
  93. package/dist/query/index.cjs +26 -149
  94. package/dist/query/index.d.cts +5 -3
  95. package/dist/query/index.d.ts +6 -3
  96. package/dist/query/index.js +8 -137
  97. package/dist/queryBuilder-DM6AWCBa.js +820 -0
  98. package/dist/queryBuilder-DM6AWCBa.js.map +1 -0
  99. package/dist/queryBuilder-DbUMEZln.cjs +944 -0
  100. package/dist/selection-C4UhsMOO.d.ts +434 -0
  101. package/dist/selection-C4UhsMOO.d.ts.map +1 -0
  102. package/dist/selection-DPg0uyJf.d.cts +433 -0
  103. package/dist/selection-DPg0uyJf.d.cts.map +1 -0
  104. package/dist/types/index.cjs +4 -1
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +4 -1
  108. package/dist/types-Bu_ZwMbZ.js +0 -0
  109. package/dist/types-NRqymi6S.cjs +0 -0
  110. package/dist/utils/index.cjs +4 -17
  111. package/dist/utils/index.d.cts +3 -17
  112. package/dist/utils/index.d.ts +3 -17
  113. package/dist/utils/index.js +4 -18
  114. package/package.json +26 -5
  115. package/src/actions/advanced/advanced.test.ts +258 -0
  116. package/src/actions/advanced/buildMutation.ts +104 -0
  117. package/src/actions/advanced/getMutationResult.ts +112 -0
  118. package/src/actions/advanced/index.ts +21 -0
  119. package/src/actions/advanced/pingTransaction.ts +43 -0
  120. package/src/actions/advanced/sendMutation.ts +59 -0
  121. package/src/actions/public/getEntity.ts +27 -43
  122. package/src/actions/public/getEntityNonce.ts +30 -0
  123. package/src/actions/public/predictEntityKeys.test.ts +143 -0
  124. package/src/actions/public/predictEntityKeys.ts +138 -0
  125. package/src/actions/public/query.ts +35 -67
  126. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  127. package/src/actions/public/watchEntityEvents.ts +225 -0
  128. package/src/actions/wallet/changeOwnership.ts +8 -8
  129. package/src/actions/wallet/createEntity.ts +104 -26
  130. package/src/actions/wallet/deleteEntity.ts +2 -3
  131. package/src/actions/wallet/extendEntity.ts +39 -16
  132. package/src/actions/wallet/mutateEntities.test.ts +76 -0
  133. package/src/actions/wallet/mutateEntities.ts +23 -83
  134. package/src/actions/wallet/patchEntity.ts +90 -0
  135. package/src/attr/attributes.test.ts +120 -0
  136. package/src/attr/attributes.ts +190 -0
  137. package/src/attr/codec.test.ts +162 -0
  138. package/src/attr/codec.ts +220 -0
  139. package/src/attr/decimal.ts +86 -0
  140. package/src/attr/errors.ts +145 -0
  141. package/src/attr/index.ts +50 -0
  142. package/src/attr/names.ts +106 -0
  143. package/src/attr/types.ts +150 -0
  144. package/src/attr/values.test.ts +271 -0
  145. package/src/attr/values.ts +502 -0
  146. package/src/chains/cheesecake.ts +22 -0
  147. package/src/chains/index.ts +1 -2
  148. package/src/clients/createPublicClient.test.ts +3 -5
  149. package/src/clients/createPublicClient.ts +5 -4
  150. package/src/clients/createWalletClient.test.ts +2 -2
  151. package/src/clients/createWalletClient.ts +13 -7
  152. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  153. package/src/clients/decorators/arkivPublic.ts +172 -139
  154. package/src/clients/decorators/arkivWallet.ts +106 -95
  155. package/src/consts.ts +2 -1
  156. package/src/entity/create.test.ts +184 -0
  157. package/src/entity/errors.ts +38 -0
  158. package/src/entity/events.ts +16 -0
  159. package/src/entity/expiry.test.ts +195 -0
  160. package/src/entity/expiry.ts +181 -0
  161. package/src/entity/flags.ts +65 -0
  162. package/src/entity/index.ts +15 -0
  163. package/src/entity/key.ts +68 -0
  164. package/src/entity/operations.ts +134 -0
  165. package/src/entity/params.ts +15 -0
  166. package/src/errors.ts +33 -28
  167. package/src/index.ts +19 -0
  168. package/src/query/engine.ts +68 -132
  169. package/src/query/errors.ts +151 -0
  170. package/src/query/expression.test.ts +286 -0
  171. package/src/query/expression.ts +493 -0
  172. package/src/query/index.ts +40 -4
  173. package/src/query/injection.test.ts +151 -0
  174. package/src/query/queryBuilder.test.ts +342 -637
  175. package/src/query/queryBuilder.ts +133 -359
  176. package/src/query/queryResult.ts +54 -51
  177. package/src/query/selection.test.ts +48 -98
  178. package/src/query/selection.ts +77 -65
  179. package/src/types/entity.test.ts +44 -155
  180. package/src/types/entity.ts +62 -44
  181. package/src/types/events.ts +64 -23
  182. package/src/types/index.ts +20 -16
  183. package/src/types/rpcSchema.ts +70 -33
  184. package/src/utils/arkivTransactions.test.ts +681 -38
  185. package/src/utils/arkivTransactions.ts +400 -115
  186. package/src/utils/chains.test.ts +21 -24
  187. package/src/utils/compression.ts +1 -1
  188. package/src/utils/entities.test.ts +62 -0
  189. package/src/utils/entities.ts +111 -29
  190. package/src/utils/expirationTime.ts +114 -10
  191. package/src/utils/logger.ts +2 -2
  192. package/src/utils/payload.ts +4 -2
  193. package/src/utils/revert.test.ts +99 -0
  194. package/src/utils/revert.ts +145 -0
  195. package/dist/chains-BifaY04V.cjs +0 -108
  196. package/dist/chains-CrtkVbBh.js +0 -86
  197. package/dist/chains-CrtkVbBh.js.map +0 -1
  198. package/dist/consts-AUoL-v42.cjs +0 -18
  199. package/dist/consts-BV4PR-de.js +0 -7
  200. package/dist/consts-BV4PR-de.js.map +0 -1
  201. package/dist/entity-B6g_EPm1.d.cts +0 -382
  202. package/dist/entity-B6g_EPm1.d.cts.map +0 -1
  203. package/dist/entity-qoLMAuuk.d.ts +0 -382
  204. package/dist/entity-qoLMAuuk.d.ts.map +0 -1
  205. package/dist/index-DdspxNAA.d.ts +0 -481
  206. package/dist/index-DdspxNAA.d.ts.map +0 -1
  207. package/dist/index-Ds9dwqb5.d.cts +0 -481
  208. package/dist/index-Ds9dwqb5.d.cts.map +0 -1
  209. package/dist/payload-B2kFJyah.d.ts +0 -6
  210. package/dist/payload-B2kFJyah.d.ts.map +0 -1
  211. package/dist/payload-CJN8fTvX.d.cts +0 -6
  212. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  213. package/dist/payload-Claf2jUO.js +0 -13
  214. package/dist/payload-Claf2jUO.js.map +0 -1
  215. package/dist/payload-DpA5PA-w.cjs +0 -23
  216. package/dist/query/index.js.map +0 -1
  217. package/dist/queryBuilder-D2uwP9jI.js +0 -704
  218. package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
  219. package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
  220. package/dist/utils/index.d.cts.map +0 -1
  221. package/dist/utils/index.d.ts.map +0 -1
  222. package/dist/utils/index.js.map +0 -1
  223. package/src/actions/public/buildQuery.ts +0 -10
  224. package/src/actions/public/subscribeEntityEvents.ts +0 -119
  225. package/src/actions/wallet/updateEntity.ts +0 -60
  226. package/src/chains/braga.ts +0 -26
  227. package/src/chains/kaolin.ts +0 -29
  228. package/src/query/engine.test.ts +0 -526
  229. package/src/query/predicate.test.ts +0 -461
  230. package/src/query/predicate.ts +0 -144
  231. package/src/query/queryResult.test.ts +0 -270
  232. package/src/query/selectQueryBuilder.test.ts +0 -210
  233. package/src/types/attributes.ts +0 -16
  234. package/src/utils/validation.test.ts +0 -60
  235. package/src/utils/validation.ts +0 -32
  236. /package/dist/{types-H-TSmRpm.js → attr-DlmErkvR.cjs} +0 -0
  237. /package/dist/{types-o3zWarRp.cjs → attr-GcQKatub.js} +0 -0
@@ -1,526 +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 process all simple predicates - flat", async () => {
51
- const predicates = [
52
- { type: "eq" as const, key: "key", value: "value" },
53
- { type: "gt" as const, key: "key2", value: 1 },
54
- { type: "gte" as const, key: "key3", value: 2 },
55
- { type: "lt" as const, key: "key4", value: 3 },
56
- { type: "lte" as const, key: "key5", value: 4 },
57
- { type: "neq" as const, key: "key6", value: "value6" },
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
- })
70
-
71
- expect(client.request).lastCalledWith({
72
- method: "arkiv_query",
73
- params: [
74
- `key = "value" && key2 > 1 && key3 >= 2 && key4 < 3 && key5 <= 4 && key6 != "value6"`,
75
- {
76
- includeData: {
77
- key: true,
78
- attributes: false,
79
- contentType: false,
80
- payload: false,
81
- expiration: false,
82
- owner: false,
83
- creator: false,
84
- createdAtBlock: false,
85
- lastModifiedAtBlock: false,
86
- transactionIndexInBlock: false,
87
- operationIndexInTransaction: false,
88
- },
89
- },
90
- ],
91
- })
92
- })
93
-
94
- it("should process multiple predicates - nested with or", async () => {
95
- const predicates = [
96
- { type: "eq" as const, key: "key", value: "value" },
97
- {
98
- type: "or" as const,
99
- predicates: [
100
- { type: "eq" as const, key: "key2", value: "value2" },
101
- { type: "eq" as const, key: "key3", value: "value3" },
102
- ],
103
- },
104
- ]
105
- await processQuery(client, {
106
- predicates,
107
- limit: undefined,
108
- cursor: undefined,
109
- ownedBy: undefined,
110
- createdBy: undefined,
111
- orderBy: undefined,
112
- validAtBlock: undefined,
113
- withAttributes: undefined,
114
- withMetadata: undefined,
115
- })
116
-
117
- expect(client.request).lastCalledWith({
118
- method: "arkiv_query",
119
- params: [
120
- `key = "value" && (key2 = "value2" || key3 = "value3")`,
121
- {
122
- includeData: {
123
- key: true,
124
- attributes: false,
125
- contentType: false,
126
- payload: false,
127
- expiration: false,
128
- owner: false,
129
- creator: false,
130
- createdAtBlock: false,
131
- lastModifiedAtBlock: false,
132
- transactionIndexInBlock: false,
133
- operationIndexInTransaction: false,
134
- },
135
- },
136
- ],
137
- })
138
- })
139
-
140
- it("should process multiple predicates - nested with and", async () => {
141
- const predicates = [
142
- { type: "eq" as const, key: "key", value: "value" },
143
- {
144
- type: "and" as const,
145
- predicates: [
146
- { type: "eq" as const, key: "key2", value: "value2" },
147
- { type: "eq" as const, key: "key3", value: "value3" },
148
- ],
149
- },
150
- ]
151
- await processQuery(client, {
152
- predicates,
153
- limit: undefined,
154
- cursor: undefined,
155
- ownedBy: undefined,
156
- createdBy: undefined,
157
- orderBy: undefined,
158
- validAtBlock: undefined,
159
- withAttributes: undefined,
160
- withMetadata: undefined,
161
- })
162
-
163
- expect(client.request).lastCalledWith({
164
- method: "arkiv_query",
165
- params: [
166
- `key = "value" && (key2 = "value2" && key3 = "value3")`,
167
- {
168
- includeData: {
169
- key: true,
170
- attributes: false,
171
- contentType: false,
172
- payload: false,
173
- expiration: false,
174
- owner: false,
175
- creator: false,
176
- createdAtBlock: false,
177
- lastModifiedAtBlock: false,
178
- transactionIndexInBlock: false,
179
- operationIndexInTransaction: false,
180
- },
181
- },
182
- ],
183
- })
184
- })
185
-
186
- it("should process multiple predicates - nested with and and or", async () => {
187
- const predicates = [
188
- { type: "eq" as const, key: "key", value: "value" },
189
- {
190
- type: "and" as const,
191
- predicates: [
192
- { type: "eq" as const, key: "key2", value: "value2" },
193
- {
194
- type: "or" as const,
195
- predicates: [
196
- { type: "eq" as const, key: "key3", value: "value3" },
197
- { type: "eq" as const, key: "key4", value: "value4" },
198
- ],
199
- },
200
- ],
201
- },
202
- ]
203
- await processQuery(client, {
204
- predicates,
205
- limit: undefined,
206
- cursor: undefined,
207
- ownedBy: undefined,
208
- createdBy: undefined,
209
- orderBy: undefined,
210
- validAtBlock: undefined,
211
- withAttributes: undefined,
212
- withMetadata: undefined,
213
- })
214
-
215
- expect(client.request).lastCalledWith({
216
- method: "arkiv_query",
217
- params: [
218
- `key = "value" && (key2 = "value2" && (key3 = "value3" || key4 = "value4"))`,
219
- {
220
- includeData: {
221
- key: true,
222
- attributes: false,
223
- contentType: false,
224
- payload: false,
225
- expiration: false,
226
- owner: false,
227
- creator: false,
228
- createdAtBlock: false,
229
- lastModifiedAtBlock: false,
230
- transactionIndexInBlock: false,
231
- operationIndexInTransaction: false,
232
- },
233
- },
234
- ],
235
- })
236
- })
237
-
238
- it("should process simple predicates with ownedBy", async () => {
239
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
240
- await processQuery(client, {
241
- predicates,
242
- orderBy: undefined,
243
- limit: undefined,
244
- cursor: undefined,
245
- ownedBy: "0x123",
246
- createdBy: undefined,
247
- })
248
-
249
- expect(client.request).lastCalledWith({
250
- method: "arkiv_query",
251
- params: [
252
- `key = "value" && $owner=0x123`,
253
- {
254
- includeData: {
255
- key: true,
256
- attributes: false,
257
- contentType: false,
258
- payload: false,
259
- expiration: false,
260
- owner: false,
261
- creator: false,
262
- createdAtBlock: false,
263
- lastModifiedAtBlock: false,
264
- transactionIndexInBlock: false,
265
- operationIndexInTransaction: false,
266
- },
267
- },
268
- ],
269
- })
270
- })
271
-
272
- it("should process only ownedBy", async () => {
273
- const predicates = [] as Predicate[]
274
- await processQuery(client, {
275
- predicates,
276
- limit: undefined,
277
- cursor: undefined,
278
- orderBy: undefined,
279
- validAtBlock: undefined,
280
- withAttributes: undefined,
281
- withMetadata: undefined,
282
- ownedBy: "0x123",
283
- createdBy: undefined,
284
- })
285
-
286
- expect(client.request).lastCalledWith({
287
- method: "arkiv_query",
288
- params: [
289
- `$owner=0x123`,
290
- {
291
- includeData: {
292
- key: true,
293
- attributes: false,
294
- contentType: false,
295
- payload: false,
296
- expiration: false,
297
- owner: false,
298
- creator: false,
299
- createdAtBlock: false,
300
- lastModifiedAtBlock: false,
301
- transactionIndexInBlock: false,
302
- operationIndexInTransaction: false,
303
- },
304
- },
305
- ],
306
- })
307
- })
308
-
309
- it("should process simple predicates with createdBy", async () => {
310
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
311
- await processQuery(client, {
312
- predicates,
313
- orderBy: undefined,
314
- limit: undefined,
315
- cursor: undefined,
316
- ownedBy: undefined,
317
- createdBy: "0x123",
318
- })
319
-
320
- expect(client.request).lastCalledWith({
321
- method: "arkiv_query",
322
- params: [
323
- `key = "value" && $creator=0x123`,
324
- {
325
- includeData: {
326
- key: true,
327
- attributes: false,
328
- contentType: false,
329
- payload: false,
330
- expiration: false,
331
- owner: false,
332
- creator: false,
333
- createdAtBlock: false,
334
- lastModifiedAtBlock: false,
335
- transactionIndexInBlock: false,
336
- operationIndexInTransaction: false,
337
- },
338
- },
339
- ],
340
- })
341
- })
342
-
343
- it("should process only createdBy", async () => {
344
- const predicates = [] as Predicate[]
345
- await processQuery(client, {
346
- predicates,
347
- limit: undefined,
348
- cursor: undefined,
349
- orderBy: undefined,
350
- validAtBlock: undefined,
351
- withAttributes: undefined,
352
- withMetadata: undefined,
353
- ownedBy: undefined,
354
- createdBy: "0x123",
355
- })
356
-
357
- expect(client.request).lastCalledWith({
358
- method: "arkiv_query",
359
- params: [
360
- `$creator=0x123`,
361
- {
362
- includeData: {
363
- key: true,
364
- attributes: false,
365
- contentType: false,
366
- payload: false,
367
- expiration: false,
368
- owner: false,
369
- creator: false,
370
- createdAtBlock: false,
371
- lastModifiedAtBlock: false,
372
- transactionIndexInBlock: false,
373
- operationIndexInTransaction: false,
374
- },
375
- },
376
- ],
377
- })
378
- })
379
-
380
- it("should process simple predicates with orderBy", async () => {
381
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
382
- await processQuery(client, {
383
- predicates,
384
- orderBy: [{ name: "key", type: "string", desc: true }],
385
- limit: undefined,
386
- cursor: undefined,
387
- ownedBy: undefined,
388
- createdBy: undefined,
389
- })
390
-
391
- expect(client.request).lastCalledWith({
392
- method: "arkiv_query",
393
- params: [
394
- `key = "value"`,
395
- {
396
- orderBy: [{ name: "key", type: "string", desc: true }],
397
- includeData: {
398
- key: true,
399
- attributes: false,
400
- contentType: false,
401
- payload: false,
402
- expiration: false,
403
- owner: false,
404
- creator: false,
405
- createdAtBlock: false,
406
- lastModifiedAtBlock: false,
407
- transactionIndexInBlock: false,
408
- operationIndexInTransaction: false,
409
- },
410
- },
411
- ],
412
- })
413
- })
414
-
415
- it("should process only orderBy", async () => {
416
- const predicates = [] as Predicate[]
417
- await processQuery(client, {
418
- predicates,
419
- limit: undefined,
420
- cursor: undefined,
421
- ownedBy: undefined,
422
- createdBy: undefined,
423
- orderBy: [{ name: "key", type: "string", desc: true }],
424
- validAtBlock: undefined,
425
- withAttributes: undefined,
426
- withMetadata: undefined,
427
- })
428
-
429
- expect(client.request).lastCalledWith({
430
- method: "arkiv_query",
431
- params: [
432
- "",
433
- {
434
- orderBy: [{ name: "key", type: "string", desc: true }],
435
- includeData: {
436
- key: true,
437
- attributes: false,
438
- contentType: false,
439
- payload: false,
440
- expiration: false,
441
- owner: false,
442
- creator: false,
443
- createdAtBlock: false,
444
- lastModifiedAtBlock: false,
445
- transactionIndexInBlock: false,
446
- operationIndexInTransaction: false,
447
- },
448
- },
449
- ],
450
- })
451
- })
452
-
453
- it("should process simple predicate with validAtBlock and paging", async () => {
454
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
455
- await processQuery(client, {
456
- predicates,
457
- limit: 10,
458
- cursor: undefined,
459
- orderBy: undefined,
460
- validAtBlock: 123n,
461
- ownedBy: "0x123",
462
- createdBy: undefined,
463
- })
464
-
465
- expect(client.request).lastCalledWith({
466
- method: "arkiv_query",
467
- params: [
468
- `key = "value" && $owner=0x123`,
469
- {
470
- atBlock: numberToHex(123n),
471
- resultsPerPage: numberToHex(10),
472
- includeData: {
473
- key: true,
474
- attributes: false,
475
- contentType: false,
476
- payload: false,
477
- expiration: false,
478
- owner: false,
479
- creator: false,
480
- createdAtBlock: false,
481
- lastModifiedAtBlock: false,
482
- transactionIndexInBlock: false,
483
- operationIndexInTransaction: false,
484
- },
485
- },
486
- ],
487
- })
488
- })
489
-
490
- it("should includeData all metadata if withMetadata is true", async () => {
491
- const predicates = [{ type: "eq" as const, key: "key", value: "value" }]
492
- await processQuery(client, {
493
- predicates,
494
- limit: 10,
495
- cursor: undefined,
496
- orderBy: undefined,
497
- validAtBlock: undefined,
498
- ownedBy: "0x123",
499
- createdBy: undefined,
500
- withMetadata: true,
501
- })
502
-
503
- expect(client.request).lastCalledWith({
504
- method: "arkiv_query",
505
- params: [
506
- `key = "value" && $owner=0x123`,
507
- {
508
- resultsPerPage: numberToHex(10),
509
- includeData: {
510
- key: true,
511
- attributes: false,
512
- contentType: true,
513
- payload: false,
514
- expiration: true,
515
- owner: true,
516
- creator: true,
517
- createdAtBlock: true,
518
- lastModifiedAtBlock: true,
519
- transactionIndexInBlock: true,
520
- operationIndexInTransaction: true,
521
- },
522
- },
523
- ],
524
- })
525
- })
526
- })