@arkiv-network/sdk 0.4.5 → 0.5.0-dev.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 (77) hide show
  1. package/dist/chains/index.cjs +5 -88
  2. package/dist/chains/index.d.cts +33 -33
  3. package/dist/chains/index.d.ts +33 -33
  4. package/dist/chains/index.d.ts.map +1 -1
  5. package/dist/chains/index.js +2 -85
  6. package/dist/chains-BDsOtN2a.js +107 -0
  7. package/dist/chains-BDsOtN2a.js.map +1 -0
  8. package/dist/chains-XCO31x6G.cjs +124 -0
  9. package/dist/chunk-pbleEpgJ.cjs +44 -0
  10. package/dist/index-B801JxcV.d.ts +1003 -0
  11. package/dist/index-B801JxcV.d.ts.map +1 -0
  12. package/dist/index-DQGx5KZ6.d.cts +1003 -0
  13. package/dist/index-DQGx5KZ6.d.cts.map +1 -0
  14. package/dist/index.cjs +57 -15
  15. package/dist/index.d.cts +3 -362
  16. package/dist/index.d.ts +3 -362
  17. package/dist/index.js +49 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/payload-BI2NXPDf.d.ts +6 -0
  20. package/dist/payload-BI2NXPDf.d.ts.map +1 -0
  21. package/dist/payload-D3fyOBWn.d.cts +6 -0
  22. package/dist/payload-D3fyOBWn.d.cts.map +1 -0
  23. package/dist/payload-DKBYYjeA.js +18 -0
  24. package/dist/payload-DKBYYjeA.js.map +1 -0
  25. package/dist/payload-eB1a8vZH.cjs +41 -0
  26. package/dist/query/index.cjs +1 -2
  27. package/dist/query/index.d.cts +3 -6
  28. package/dist/query/index.d.cts.map +1 -1
  29. package/dist/query/index.d.ts +3 -6
  30. package/dist/query/index.d.ts.map +1 -1
  31. package/dist/query/index.js +2 -2
  32. package/dist/{queryBuilder-DVs4ZIyZ.js → queryBuilder-DNUwJvf0.js} +4 -9
  33. package/dist/queryBuilder-DNUwJvf0.js.map +1 -0
  34. package/dist/{queryBuilder-Cn5JJRMM.cjs → queryBuilder-KrdIUVZv.cjs} +4 -43
  35. package/dist/types/index.cjs +1 -1
  36. package/dist/types/index.d.cts +3 -2
  37. package/dist/types/index.d.ts +3 -2
  38. package/dist/types/index.js +1 -1
  39. package/dist/utils/index.cjs +4 -15
  40. package/dist/utils/index.d.cts +1 -4
  41. package/dist/utils/index.d.cts.map +1 -1
  42. package/dist/utils/index.d.ts +1 -4
  43. package/dist/utils/index.d.ts.map +1 -1
  44. package/dist/utils/index.js +1 -11
  45. package/dist/utils/index.js.map +1 -1
  46. package/package.json +8 -5
  47. package/src/actions/public/query.ts +49 -2
  48. package/src/actions/public/subscribeEntityEvents.ts +3 -3
  49. package/src/clients/createPublicClient.ts +1 -1
  50. package/src/clients/createWalletClient.ts +2 -2
  51. package/src/clients/decorators/arkivPublic.ts +42 -7
  52. package/src/clients/decorators/arkivWallet.ts +21 -15
  53. package/src/index.ts +10 -0
  54. package/src/query/errors.ts +0 -6
  55. package/src/query/queryBuilder.ts +7 -4
  56. package/src/types/index.ts +21 -1
  57. package/src/types/rpcSchema.ts +10 -10
  58. package/src/utils/chains.test.ts +97 -0
  59. package/src/utils/chains.ts +19 -0
  60. package/src/utils/compression.ts +1 -1
  61. package/dist/chains/index.js.map +0 -1
  62. package/dist/consts-BV9DVKgE.cjs +0 -18
  63. package/dist/consts-CHtLBwGd.js +0 -7
  64. package/dist/consts-CHtLBwGd.js.map +0 -1
  65. package/dist/entity-BNSCqNpu.d.cts +0 -254
  66. package/dist/entity-BNSCqNpu.d.cts.map +0 -1
  67. package/dist/entity-CWj4qVCX.d.ts +0 -254
  68. package/dist/entity-CWj4qVCX.d.ts.map +0 -1
  69. package/dist/index.d.cts.map +0 -1
  70. package/dist/index.d.ts.map +0 -1
  71. package/dist/queryBuilder-CXcMv0Uc.d.ts +0 -314
  72. package/dist/queryBuilder-CXcMv0Uc.d.ts.map +0 -1
  73. package/dist/queryBuilder-CvAx57pq.d.cts +0 -314
  74. package/dist/queryBuilder-CvAx57pq.d.cts.map +0 -1
  75. package/dist/queryBuilder-DVs4ZIyZ.js.map +0 -1
  76. /package/dist/{types-CBTc19th.cjs → types-H-TSmRpm.js} +0 -0
  77. /package/dist/{types-Cv8NMtbo.js → types-o3zWarRp.cjs} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,363 +1,4 @@
1
- import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, g as ArkivClient, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "./entity-CWj4qVCX.js";
2
- import { t as QueryBuilder } from "./queryBuilder-CXcMv0Uc.js";
3
- import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
1
+ import { $ as RpcIncludeData, A as CreateEntityParameters, C as MutateEntitiesReturnType, D as ExtendEntityReturnType, E as ExtendEntityParameters, J as QueryOptionsIncludeData, M as ChangeOwnershipParameters, N as ChangeOwnershipReturnType, O as DeleteEntityParameters, P as GetBlockTimingReturnType, Q as RpcEntity, S as MutateEntitiesParameters, T as UpdateEntityReturnType, X as ArkivClient, Y as QueryOptionsOrderBy, Z as ArkivRpcSchema, _ as OnEntityExpiredEvent, a as PublicArkivClient, b as OnEntityUpdatedEvent, et as RpcOrderByAttribute, g as OnEntityDeletedEvent, h as OnEntityCreatedEvent, i as WalletArkivActions, j as CreateEntityReturnType, k as DeleteEntityReturnType, m as TxParams, n as WalletArkivClient, nt as MimeType, o as createPublicClient, p as Entity, q as QueryOptions, r as createWalletClient, s as PublicArkivActions, t as chainFromName, tt as RpcQueryOptions, v as OnEntityExpiresInExtendedEvent, w as UpdateEntityParameters, x as Attribute, y as OnEntityOwnerChangedEvent } from "./index-B801JxcV.js";
2
+ import { n as stringToPayload, t as jsonToPayload } from "./payload-BI2NXPDf.js";
4
3
  export * from "viem";
5
-
6
- //#region src/types/events.d.ts
7
- type OnEntityCreatedEvent = {
8
- entityKey: Hex;
9
- owner: Hex;
10
- expirationBlock: number;
11
- cost: bigint;
12
- };
13
- type OnEntityUpdatedEvent = {
14
- entityKey: Hex;
15
- owner: Hex;
16
- oldExpirationBlock: number;
17
- newExpirationBlock: number;
18
- cost: bigint;
19
- };
20
- type OnEntityDeletedEvent = {
21
- entityKey: Hex;
22
- owner: Hex;
23
- };
24
- type OnEntityExpiredEvent = {
25
- entityKey: Hex;
26
- owner: Hex;
27
- };
28
- type OnEntityExpiresInExtendedEvent = {
29
- entityKey: Hex;
30
- owner: Hex;
31
- oldExpirationBlock: number;
32
- newExpirationBlock: number;
33
- cost: bigint;
34
- };
35
- //#endregion
36
- //#region src/clients/decorators/arkivPublic.d.ts
37
- type PublicArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "getBalance" | "getBlock" | "getBlockNumber" | "getChainId" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "waitForTransactionReceipt" | "watchEvent"> & {
38
- /**
39
- * Returns the entity with the given key.
40
- *
41
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
42
- *
43
- * @param args - {entityKey}
44
- * @returns The entity with the given key. {@link Entity}
45
- *
46
- * @example
47
- * import { createPublicClient, http } from 'arkiv'
48
- * import { kaolin } from 'arkiv/chains'
49
- *
50
- * const client = createPublicClient({
51
- * chain: kaolin,
52
- * transport: http(),
53
- * })
54
- * const entity = await client.getEntity("0x123")
55
- * // {
56
- * // key: "0x123",
57
- * // value: "0x123",
58
- * // }
59
- */
60
- getEntity: (key: Hex) => Promise<Entity>;
61
- /**
62
- * Returns a QueryBuilder instance for building and executing queries.
63
- * The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
64
- *
65
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
66
- *
67
- * @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
68
- *
69
- * @example
70
- * import { createPublicClient, http } from 'arkiv'
71
- * import { kaolin } from 'arkiv/chains'
72
- *
73
- * const client = createPublicClient({
74
- * chain: kaolin,
75
- * transport: http(),
76
- * })
77
- * const query = client.buildQuery()
78
- * const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
79
- *
80
- */
81
- buildQuery: () => QueryBuilder;
82
- /**
83
- * Returns a QueryResult instance for fetching the results of a raw query.
84
- * @returns A QueryResult instance for fetching the results of a raw query. {@link QueryResult}
85
- *
86
- * @example
87
- * import { createPublicClient, http } from 'arkiv'
88
- * import { kaolin } from 'arkiv/chains'
89
- *
90
- * const client = createPublicClient({
91
- * chain: kaolin,
92
- * transport: http(),
93
- * })
94
- * const queryResult = client.query('key = value && $owner = 0x123')
95
- *
96
- */
97
- query: (query: string) => Promise<Entity[]>;
98
- /**
99
- * Returns the number of entities in the DBChain.
100
- * @returns The number of entities in the DBChain. {@link number}
101
- *
102
- * @example
103
- * import { createPublicClient, http } from 'arkiv'
104
- * import { kaolin } from 'arkiv/chains'
105
- *
106
- * const client = createPublicClient({
107
- * chain: kaolin,
108
- * transport: http(),
109
- * })
110
- * const entityCount = await client.getEntityCount()
111
- * // entityCount = 0
112
- */
113
- getEntityCount: () => Promise<number>;
114
- /**
115
- * Returns the current block timing.
116
- * @returns The current block timing. {@link GetBlockTimingReturnType}
117
- *
118
- * @example
119
- * import { createPublicClient, http } from 'arkiv'
120
- * import { kaolin } from 'arkiv/chains'
121
- *
122
- * const client = createPublicClient({
123
- * chain: kaolin,
124
- * transport: http(),
125
- * })
126
- * const blockTiming = await client.getBlockTiming()
127
- * // {
128
- * // currentBlock: 10n, // block number
129
- * // currentBlockTime: 1234567890, // block timestamp
130
- * // blockDuration: 2, // in seconds
131
- * // }
132
- */
133
- getBlockTiming: () => Promise<{
134
- currentBlock: bigint;
135
- currentBlockTime: number;
136
- blockDuration: number;
137
- }>;
138
- subscribeEntityEvents: ({
139
- onError,
140
- onEntityCreated,
141
- onEntityUpdated,
142
- onEntityDeleted,
143
- onEntityExpiresInExtended
144
- }: {
145
- onError?: (error: Error) => void;
146
- onEntityCreated?: (event: OnEntityCreatedEvent) => void;
147
- onEntityUpdated?: (event: OnEntityUpdatedEvent) => void;
148
- onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
149
- onEntityExpired?: (event: OnEntityExpiredEvent) => void;
150
- onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
151
- }, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
152
- };
153
- //#endregion
154
- //#region src/clients/createPublicClient.d.ts
155
- type PublicArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Prettify<Client<transport, chain, accountOrAddress, rpcSchema, PublicArkivActions<transport, chain>>>;
156
- /**
157
- * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
158
- *
159
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
160
- *
161
- * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
162
- *
163
- * @param config - {@link PublicClientConfig}
164
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
165
- *
166
- * @example
167
- * import { createPublicClient, http } from 'arkiv'
168
- * import { kaolin } from 'arkiv/chains'
169
- *
170
- * const client = createPublicClient({
171
- * chain: kaolin,
172
- * transport: http(),
173
- * })
174
- */
175
- declare function createPublicClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema>(parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>): PublicArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>;
176
- //#endregion
177
- //#region src/clients/decorators/arkivWallet.d.ts
178
- type WalletArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "waitForTransactionReceipt"> & Pick<WalletActions<chain, account>, "addChain" | "sendTransaction" | "sendTransactionSync" | "sendRawTransaction" | "sendRawTransactionSync" | "signMessage" | "signTransaction"> & {
179
- /**
180
- * Returns the entity with the given key.
181
- *
182
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
183
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
184
- *
185
- * @param args - {entityKey}
186
- * @returns The entity with the given key. {@link Entity}
187
- *
188
- * @example
189
- * import { createPublicClient, http } from 'arkiv'
190
- * import { kaolin } from 'arkiv/chains'
191
- *
192
- * const client = createPublicClient({
193
- * chain: kaolin,
194
- * transport: http(),
195
- * })
196
- * const { entityKey, txHash } = await client.createEntity({
197
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
198
- * attributes: [{ key: "testKey", value: "testValue" }],
199
- * expiresIn: 1000,
200
- * })
201
- * console.log("entityKey", entityKey)
202
- * console.log("txHash", txHash)
203
- * // {
204
- * // entityKey: "0x123",
205
- * // txHash: "0x123",
206
- * // }
207
- */
208
- createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
209
- /**
210
- * Updates the entity with the given key.
211
- *
212
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
213
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
214
- *
215
- * @param args - {entityKey, data}
216
- * @returns The entity with the given key. {@link Entity}
217
- *
218
- * @example
219
- * import { createWalletClient, http } from 'arkiv'
220
- * import { kaolin } from 'arkiv/chains'
221
- *
222
- * const client = createWalletClient({
223
- * chain: kaolin,
224
- * transport: http(),
225
- * })
226
- */
227
- updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
228
- /**
229
- * Deletes the entity with the given key.
230
- *
231
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
232
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
233
- *
234
- * @param args - {entityKey}
235
- * @returns The entity with the given key. {@link Entity}
236
- *
237
- * @example
238
- * import { createWalletClient, http } from 'arkiv'
239
- * import { kaolin } from 'arkiv/chains'
240
- *
241
- * const client = createWalletClient({
242
- * chain: kaolin,
243
- * transport: http(),
244
- * })
245
- * const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
246
- * console.log("entityKey", entityKey)
247
- * console.log("txHash", txHash)
248
- * // {
249
- * // entityKey: "0x123",
250
- * // txHash: "0x123",
251
- * // }
252
- */
253
- deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
254
- /**
255
- * Extends the entity with the given key.
256
- *
257
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
258
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
259
- *
260
- * @param args - {entityKey, data}
261
- * @returns The entity with the given key. {@link Entity}
262
- *
263
- * @example
264
- * import { createWalletClient, http } from 'arkiv'
265
- * import { kaolin } from 'arkiv/chains'
266
- *
267
- * const client = createWalletClient({
268
- * chain: kaolin,
269
- * transport: http(),
270
- * })
271
- * const { entityKey, txHash } = await client.extendEntity("0x123", {
272
- * expiresIn: 1000,
273
- * })
274
- * console.log("entityKey", entityKey)
275
- * console.log("txHash", txHash)
276
- * // {
277
- * // entityKey: "0x123",
278
- * // txHash: "0x123",
279
- * // }
280
- */
281
- extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
282
- /**
283
- * Changes the ownership of the entity with the given address.
284
- *
285
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
286
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
287
- *
288
- * @param args - {entityKey, newOwner}
289
- * @returns The entity with the given address. {@link Entity}
290
- */
291
- changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>;
292
- /**
293
- * Mutates the entities with the given keys.
294
- *
295
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
296
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
297
- *
298
- * @param args - {data}
299
- * @returns The entity with the given key. {@link Entity}
300
- *
301
- * @example
302
- * import { createWalletClient, http } from 'arkiv'
303
- * import { kaolin } from 'arkiv/chains'
304
- *
305
- * const client = createWalletClient({
306
- * chain: kaolin,
307
- * transport: http(),
308
- * })
309
- * const { entityKey, txHash } = await client.mutateEntities({
310
- * creates: [{
311
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
312
- * attriubutes: [{ key: "testKey", value: "testValue" }],
313
- * expiresIn: 1000,
314
- * }],
315
- * updates: [{
316
- * entityKey: "0x123",
317
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
318
- * attributes: [{ key: "testKey", value: "testValue" }],
319
- * expiresIn: 1000,
320
- * }],
321
- * deletes: [{
322
- * entityKey: "0x321",
323
- * }],
324
- * extensions: [{
325
- * entityKey: "0x1234",
326
- * expiresIn: 1000,
327
- * }],
328
- * })
329
- * console.log("entityKey", entityKey)
330
- * console.log("txHash", txHash)
331
- * // {
332
- * // entityKey: "0x123",
333
- * // txHash: "0x123",
334
- * // }
335
- */
336
- mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
337
- };
338
- //#endregion
339
- //#region src/clients/createWalletClient.d.ts
340
- type WalletArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Prettify<Client<transport, chain, account, rpcSchema, WalletArkivActions<transport, chain, account>>>;
341
- /**
342
- * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
343
- *
344
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
345
- *
346
- * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
347
- *
348
- * @param config - {@link PublicClientConfig}
349
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
350
- *
351
- * @example
352
- * import { createPublicClient, http } from 'arkiv'
353
- * import { kaolin } from 'arkiv/chains'
354
- *
355
- * const client = createPublicClient({
356
- * chain: kaolin,
357
- * transport: http(),
358
- * })
359
- */
360
- declare function createWalletClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema>(parameters: WalletClientConfig<transport, chain, accountOrAddress, rpcSchema>): WalletArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>;
361
- //#endregion
362
- export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, type PublicArkivClient, RpcEntity, RpcIncludeData, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivClient, createPublicClient, createWalletClient };
363
- //# sourceMappingURL=index.d.ts.map
4
+ export { ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, PublicArkivActions, PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, WalletArkivActions, WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
- import { a as entityFromRpcResult, s as NoEntityFoundError, t as QueryBuilder, u as getLogger } from "./queryBuilder-DVs4ZIyZ.js";
2
- import { n as BLOCK_TIME, t as ARKIV_ADDRESS } from "./consts-CHtLBwGd.js";
3
- import "./types-Cv8NMtbo.js";
1
+ import { t as chains_exports } from "./chains-BDsOtN2a.js";
2
+ import { a as entityFromRpcResult, l as getLogger, s as NoEntityFoundError, t as QueryBuilder } from "./queryBuilder-DNUwJvf0.js";
3
+ import { i as BLOCK_TIME, n as stringToPayload, r as ARKIV_ADDRESS, t as jsonToPayload } from "./payload-DKBYYjeA.js";
4
+ import "./types-H-TSmRpm.js";
4
5
  import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
5
6
 
6
7
  export * from "viem"
@@ -61,10 +62,32 @@ async function getEntityCount(client) {
61
62
 
62
63
  //#endregion
63
64
  //#region src/actions/public/query.ts
64
- async function query(client, query$1) {
65
+ async function query(client, query$1, queryOptions) {
66
+ const rpcQueryOptions = {
67
+ includeData: {
68
+ key: true,
69
+ payload: queryOptions?.includeData?.payload ?? true,
70
+ attributes: queryOptions?.includeData?.attributes ?? false,
71
+ contentType: queryOptions?.includeData?.metadata ?? false,
72
+ expiration: queryOptions?.includeData?.metadata ?? false,
73
+ owner: queryOptions?.includeData?.metadata ?? false,
74
+ createdAtBlock: queryOptions?.includeData?.metadata ?? false,
75
+ lastModifiedAtBlock: queryOptions?.includeData?.metadata ?? false,
76
+ transactionIndexInBlock: queryOptions?.includeData?.metadata ?? false,
77
+ operationIndexInTransaction: queryOptions?.includeData?.metadata ?? false
78
+ },
79
+ ...queryOptions?.atBlock !== void 0 && { atBlock: Number(queryOptions.atBlock) },
80
+ ...queryOptions?.orderBy && { orderBy: queryOptions?.orderBy.map((order) => ({
81
+ name: order.name,
82
+ type: order.type,
83
+ desc: order.desc === "desc"
84
+ })) },
85
+ ...queryOptions?.resultsPerPage !== void 0 && { resultsPerPage: queryOptions.resultsPerPage },
86
+ ...queryOptions?.cursor !== void 0 && { cursor: queryOptions?.cursor }
87
+ };
65
88
  const result = await client.request({
66
89
  method: "arkiv_query",
67
- params: [query$1]
90
+ params: [query$1, rpcQueryOptions]
68
91
  });
69
92
  return await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)));
70
93
  }
@@ -158,7 +181,7 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
158
181
  function publicArkivActions(client) {
159
182
  return {
160
183
  getEntity: (key) => getEntity(client, key),
161
- query: (rawQuery) => query(client, rawQuery),
184
+ query: (rawQuery, queryOptions) => query(client, rawQuery, queryOptions),
162
185
  buildQuery: () => new QueryBuilder(client),
163
186
  getBlockTiming: () => getBlockTiming(client),
164
187
  getEntityCount: () => getEntityCount(client),
@@ -182,7 +205,7 @@ function publicArkivActions(client) {
182
205
  *
183
206
  * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
184
207
  *
185
- * @param config - {@link PublicClientConfig}
208
+ * @param parameters - Configuration object for the public client (chain, transport, etc.)
186
209
  * @returns A Arkiv Public Client. {@link PublicArkivClient}
187
210
  *
188
211
  * @example
@@ -223,7 +246,7 @@ async function getBrotli() {
223
246
  if (brotli) return brotli;
224
247
  try {
225
248
  const brotliModule = await import("brotli-wasm");
226
- brotli = brotliModule.default || brotliModule;
249
+ brotli = brotliModule.default ? await brotliModule.default : brotliModule;
227
250
  } catch (error) {
228
251
  console.error("Error importing brotli-wasm", error);
229
252
  return null;
@@ -448,8 +471,8 @@ function walletArkivActions(client) {
448
471
  *
449
472
  * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
450
473
  *
451
- * @param config - {@link PublicClientConfig}
452
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
474
+ * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
475
+ * @returns A Arkiv Wallet Client. {@link WalletArkivClient}
453
476
  *
454
477
  * @example
455
478
  * import { createPublicClient, http } from 'arkiv'
@@ -470,5 +493,20 @@ function createWalletClient(parameters) {
470
493
  }
471
494
 
472
495
  //#endregion
473
- export { createPublicClient, createWalletClient };
496
+ //#region src/utils/chains.ts
497
+ const chainMap = new Map(Object.entries(chains_exports).map(([key, value]) => [key.toLowerCase(), value]));
498
+ /**
499
+ * Get a chain from its name
500
+ * @param name - The name of the chain, case insensitive
501
+ * @returns The chain
502
+ * @throws An error if the chain is not found
503
+ */
504
+ function chainFromName(name) {
505
+ const chain = chainMap.get(name.toLowerCase());
506
+ if (!chain) throw new Error(`Unknown chain: ${name}`);
507
+ return chain;
508
+ }
509
+
510
+ //#endregion
511
+ export { chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
474
512
  //# sourceMappingURL=index.js.map