@arkiv-network/sdk 0.7.0-dev.1 → 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 +22 -60
  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 +411 -405
  74. package/dist/index.d.cts +360 -209
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +361 -209
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +342 -387
  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 -150
  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 -138
  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 +3 -3
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +3 -3
  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 +2 -2
  129. package/src/actions/wallet/createEntity.ts +99 -24
  130. package/src/actions/wallet/extendEntity.ts +37 -13
  131. package/src/actions/wallet/mutateEntities.test.ts +76 -0
  132. package/src/actions/wallet/mutateEntities.ts +16 -33
  133. package/src/actions/wallet/patchEntity.ts +90 -0
  134. package/src/attr/attributes.test.ts +120 -0
  135. package/src/attr/attributes.ts +190 -0
  136. package/src/attr/codec.test.ts +162 -0
  137. package/src/attr/codec.ts +220 -0
  138. package/src/attr/decimal.ts +86 -0
  139. package/src/attr/errors.ts +145 -0
  140. package/src/attr/index.ts +50 -0
  141. package/src/attr/names.ts +106 -0
  142. package/src/attr/types.ts +150 -0
  143. package/src/attr/values.test.ts +271 -0
  144. package/src/attr/values.ts +502 -0
  145. package/src/chains/cheesecake.ts +22 -0
  146. package/src/chains/index.ts +1 -2
  147. package/src/clients/createPublicClient.test.ts +3 -5
  148. package/src/clients/createPublicClient.ts +5 -4
  149. package/src/clients/createWalletClient.test.ts +2 -2
  150. package/src/clients/createWalletClient.ts +13 -7
  151. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  152. package/src/clients/decorators/arkivPublic.ts +172 -139
  153. package/src/clients/decorators/arkivWallet.ts +101 -94
  154. package/src/entity/create.test.ts +184 -0
  155. package/src/entity/errors.ts +38 -0
  156. package/src/entity/events.ts +16 -0
  157. package/src/entity/expiry.test.ts +195 -0
  158. package/src/entity/expiry.ts +181 -0
  159. package/src/entity/flags.ts +65 -0
  160. package/src/entity/index.ts +15 -0
  161. package/src/entity/key.ts +68 -0
  162. package/src/entity/operations.ts +134 -0
  163. package/src/entity/params.ts +15 -0
  164. package/src/errors.ts +26 -49
  165. package/src/index.ts +19 -0
  166. package/src/query/engine.ts +68 -137
  167. package/src/query/errors.ts +151 -0
  168. package/src/query/expression.test.ts +286 -0
  169. package/src/query/expression.ts +493 -0
  170. package/src/query/index.ts +40 -4
  171. package/src/query/injection.test.ts +151 -0
  172. package/src/query/queryBuilder.test.ts +342 -637
  173. package/src/query/queryBuilder.ts +133 -359
  174. package/src/query/queryResult.ts +54 -51
  175. package/src/query/selection.test.ts +48 -98
  176. package/src/query/selection.ts +77 -65
  177. package/src/types/entity.test.ts +44 -155
  178. package/src/types/entity.ts +60 -52
  179. package/src/types/events.ts +59 -16
  180. package/src/types/index.ts +20 -17
  181. package/src/types/rpcSchema.ts +69 -37
  182. package/src/utils/arkivTransactions.test.ts +600 -155
  183. package/src/utils/arkivTransactions.ts +350 -219
  184. package/src/utils/chains.test.ts +21 -24
  185. package/src/utils/compression.ts +1 -1
  186. package/src/utils/entities.test.ts +62 -0
  187. package/src/utils/entities.ts +109 -37
  188. package/src/utils/expirationTime.ts +114 -10
  189. package/src/utils/logger.ts +2 -2
  190. package/src/utils/revert.test.ts +99 -0
  191. package/src/utils/revert.ts +145 -0
  192. package/dist/chains-BifaY04V.cjs +0 -108
  193. package/dist/chains-CrtkVbBh.js +0 -86
  194. package/dist/chains-CrtkVbBh.js.map +0 -1
  195. package/dist/consts-Bz0LZQZY.js +0 -7
  196. package/dist/consts-Bz0LZQZY.js.map +0 -1
  197. package/dist/consts-CxT1-RXU.cjs +0 -18
  198. package/dist/entity-BhSXaB23.cjs +0 -81
  199. package/dist/entity-CN41IOrq.d.cts +0 -401
  200. package/dist/entity-CN41IOrq.d.cts.map +0 -1
  201. package/dist/entity-DGfVyB-a.js +0 -71
  202. package/dist/entity-DGfVyB-a.js.map +0 -1
  203. package/dist/entity-NnEVlePN.d.ts +0 -401
  204. package/dist/entity-NnEVlePN.d.ts.map +0 -1
  205. package/dist/index-ClkpS6s_.d.ts +0 -481
  206. package/dist/index-ClkpS6s_.d.ts.map +0 -1
  207. package/dist/index-w4qop0Pe.d.cts +0 -481
  208. package/dist/index-w4qop0Pe.d.cts.map +0 -1
  209. package/dist/payload-BpNUPOnY.js +0 -13
  210. package/dist/payload-BpNUPOnY.js.map +0 -1
  211. package/dist/payload-C2KHOUoj.d.ts +0 -6
  212. package/dist/payload-C2KHOUoj.d.ts.map +0 -1
  213. package/dist/payload-CJN8fTvX.d.cts +0 -6
  214. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  215. package/dist/payload-D8YLKcJj.cjs +0 -23
  216. package/dist/query/index.js.map +0 -1
  217. package/dist/queryBuilder-BE_XhLLa.js +0 -735
  218. package/dist/queryBuilder-BE_XhLLa.js.map +0 -1
  219. package/dist/queryBuilder-J37buGCi.cjs +0 -865
  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 -93
  225. package/src/actions/wallet/updateEntity.ts +0 -59
  226. package/src/chains/braga.ts +0 -26
  227. package/src/chains/kaolin.ts +0 -29
  228. package/src/query/engine.test.ts +0 -571
  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 -213
  233. package/src/types/attributes.ts +0 -28
  234. package/src/utils/validation.test.ts +0 -106
  235. package/src/utils/validation.ts +0 -80
  236. /package/dist/{types-Ci4BRClw.js → attr-DlmErkvR.cjs} +0 -0
  237. /package/dist/{types-a8gm_IaQ.cjs → attr-GcQKatub.js} +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
- })