@arkiv-network/sdk 0.7.0 → 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 +39 -77
  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 +675 -357
  62. package/dist/index.d.cts +251 -203
  63. package/dist/index.d.cts.map +1 -1
  64. package/dist/index.d.ts +251 -203
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +626 -355
  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 -149
  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 -137
  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 +4 -1
  87. package/dist/types/index.d.cts +7 -2
  88. package/dist/types/index.d.ts +7 -2
  89. package/dist/types/index.js +4 -1
  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 +8 -8
  103. package/src/actions/wallet/createEntity.ts +104 -26
  104. package/src/actions/wallet/deleteEntity.ts +2 -3
  105. package/src/actions/wallet/extendEntity.ts +39 -16
  106. package/src/actions/wallet/mutateEntities.test.ts +76 -0
  107. package/src/actions/wallet/mutateEntities.ts +29 -74
  108. package/src/actions/wallet/patchEntity.ts +90 -0
  109. package/src/attr/attributes.test.ts +120 -0
  110. package/src/attr/attributes.ts +190 -0
  111. package/src/attr/codec.test.ts +162 -0
  112. package/src/attr/codec.ts +220 -0
  113. package/src/attr/decimal.ts +86 -0
  114. package/src/attr/errors.ts +145 -0
  115. package/src/attr/index.ts +50 -0
  116. package/src/attr/names.ts +106 -0
  117. package/src/attr/types.ts +150 -0
  118. package/src/attr/values.test.ts +271 -0
  119. package/src/attr/values.ts +502 -0
  120. package/src/chains/cheesecake.ts +22 -0
  121. package/src/chains/index.ts +1 -2
  122. package/src/clients/createPublicClient.test.ts +3 -5
  123. package/src/clients/createPublicClient.ts +5 -4
  124. package/src/clients/createWalletClient.test.ts +2 -2
  125. package/src/clients/createWalletClient.ts +13 -7
  126. package/src/clients/decorators/arkivPublic.ts +160 -139
  127. package/src/clients/decorators/arkivWallet.ts +91 -95
  128. package/src/consts.ts +2 -1
  129. package/src/entity/create.test.ts +184 -0
  130. package/src/entity/errors.ts +38 -0
  131. package/src/entity/events.ts +16 -0
  132. package/src/entity/expiry.test.ts +195 -0
  133. package/src/entity/expiry.ts +181 -0
  134. package/src/entity/flags.ts +65 -0
  135. package/src/entity/index.ts +14 -0
  136. package/src/entity/key.ts +68 -0
  137. package/src/entity/operations.ts +134 -0
  138. package/src/entity/params.ts +15 -0
  139. package/src/errors.ts +33 -28
  140. package/src/index.ts +6 -0
  141. package/src/query/engine.ts +59 -134
  142. package/src/query/errors.ts +151 -0
  143. package/src/query/expression.test.ts +286 -0
  144. package/src/query/expression.ts +493 -0
  145. package/src/query/index.ts +40 -4
  146. package/src/query/injection.test.ts +151 -0
  147. package/src/query/queryBuilder.test.ts +322 -637
  148. package/src/query/queryBuilder.ts +126 -359
  149. package/src/query/queryResult.ts +54 -51
  150. package/src/query/selection.test.ts +48 -98
  151. package/src/query/selection.ts +77 -65
  152. package/src/types/entity.test.ts +44 -155
  153. package/src/types/entity.ts +62 -44
  154. package/src/types/events.ts +64 -23
  155. package/src/types/index.ts +20 -16
  156. package/src/types/rpcSchema.ts +70 -33
  157. package/src/utils/arkivTransactions.test.ts +681 -38
  158. package/src/utils/arkivTransactions.ts +249 -104
  159. package/src/utils/chains.test.ts +21 -24
  160. package/src/utils/compression.ts +1 -1
  161. package/src/utils/entities.test.ts +62 -0
  162. package/src/utils/entities.ts +111 -29
  163. package/src/utils/expirationTime.ts +114 -10
  164. package/src/utils/logger.ts +2 -2
  165. package/src/utils/payload.ts +4 -2
  166. package/src/utils/revert.test.ts +99 -0
  167. package/src/utils/revert.ts +145 -0
  168. package/dist/chains-BifaY04V.cjs +0 -108
  169. package/dist/chains-CrtkVbBh.js +0 -86
  170. package/dist/chains-CrtkVbBh.js.map +0 -1
  171. package/dist/consts-AUoL-v42.cjs +0 -18
  172. package/dist/consts-BV4PR-de.js +0 -7
  173. package/dist/consts-BV4PR-de.js.map +0 -1
  174. package/dist/entity-B6g_EPm1.d.cts +0 -382
  175. package/dist/entity-B6g_EPm1.d.cts.map +0 -1
  176. package/dist/entity-qoLMAuuk.d.ts +0 -382
  177. package/dist/entity-qoLMAuuk.d.ts.map +0 -1
  178. package/dist/index-DdspxNAA.d.ts +0 -481
  179. package/dist/index-DdspxNAA.d.ts.map +0 -1
  180. package/dist/index-Ds9dwqb5.d.cts +0 -481
  181. package/dist/index-Ds9dwqb5.d.cts.map +0 -1
  182. package/dist/payload-B2kFJyah.d.ts +0 -6
  183. package/dist/payload-B2kFJyah.d.ts.map +0 -1
  184. package/dist/payload-CJN8fTvX.d.cts +0 -6
  185. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  186. package/dist/payload-Claf2jUO.js +0 -13
  187. package/dist/payload-Claf2jUO.js.map +0 -1
  188. package/dist/payload-DpA5PA-w.cjs +0 -23
  189. package/dist/query/index.js.map +0 -1
  190. package/dist/queryBuilder-D2uwP9jI.js +0 -704
  191. package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
  192. package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
  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 -119
  198. package/src/actions/wallet/updateEntity.ts +0 -60
  199. package/src/chains/braga.ts +0 -26
  200. package/src/chains/kaolin.ts +0 -29
  201. package/src/query/engine.test.ts +0 -526
  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 -210
  206. package/src/types/attributes.ts +0 -16
  207. package/src/utils/validation.test.ts +0 -60
  208. package/src/utils/validation.ts +0 -32
  209. /package/dist/{types-H-TSmRpm.js → types-Bx1EKe0v.js} +0 -0
  210. /package/dist/{types-o3zWarRp.cjs → types-CKPddlfS.cjs} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
- import { A as RpcIncludeData, C as QueryOptionsIncludeData, D as ArkivClient, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as QueryOptions, T as QueryReturnType, _ as DeleteEntityReturnType, a as OnEntityExpiredEvent, b as ChangeOwnershipParameters, c as OnEntityUpdatedEvent, d as MutateEntitiesReturnType, f as UpdateEntityParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as OnEntityDeletedEvent, j as RpcOrderByAttribute, k as RpcEntity, l as Attribute, m as ExtendEntityParameters, n as TxParams, o as OnEntityExpiresInExtendedEvent, p as UpdateEntityReturnType, r as OnEntityCreatedEvent, s as OnEntityOwnerChangedEvent, t as Entity, u as MutateEntitiesParameters, v as CreateEntityParameters, w as QueryOptionsOrderBy, x as ChangeOwnershipReturnType, y as CreateEntityReturnType } from "./entity-qoLMAuuk.js";
2
- import { c as FullEntity, i as SelectQueryBuilder, l as ProjectedEntity, r as QueryBuilder, s as EntitySelection, u as SelectArg } from "./index-DdspxNAA.js";
3
- import { n as stringToPayload, t as jsonToPayload } from "./payload-B2kFJyah.js";
1
+ import { A as i32, B as Bytes32Value, C as ValueInput, D as dec, E as bytes32, F as u64, G as StrValue, H as DecValue, I as AddrValue, J as U64Value, K as TypeTag, L as AnyArkivValue, M as str, N as toValue, O as decFromUnits, P as u256, R as ArkivValue, S as U64_MAX, T as bool, U as I32Value, V as BytesValue, W as KeyValue, X as isArkivValue, Y as UserTypeTag, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, q as U256Value, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN, z as BoolValue } from "./index-DVYFaXNV.js";
2
+ import { a as randomSalt, c as InvalidCreationFlagsError, d as NoRandomSourceError, i as predictEntityKey, l as InvalidExpiryError, n as OperationType, o as ENTITY_EVENTS_ABI, r as MAX_SALT, s as EntityEventName, t as MAX_EXPIRES_AT, u as InvalidSaltError } from "./index-ClgIuxJ8.js";
3
+ import { a as ResolvedExpiry, i as Lifetime, n as Expiry, o as resolveExpiry, r as ExpiryContext, s as toBlocks, t as EncodedExpiry } from "./expiry-BxOlvVWC.js";
4
+ import { i as encodeCreationFlags, n as ResolvedCreationFlags, r as decodeCreationFlags, t as CreationFlags } from "./flags-wmcMoAnN.js";
5
+ import { A as EntityFields, F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, d as Expression, i as SelectArg, j as ArkivClient, k as Entity, n as FullEntity, r as ProjectedEntity, t as EntitySelection } from "./selection-fpmI3ADQ.js";
6
+ import { t as SelectQueryBuilder } from "./index-VCqgn29D.js";
7
+ import { C as OwnershipTransferredEvent, D as PredictEntityKeysReturnType, E as PredictEntityKeysParameters, O as PredictedEntityKey, S as ExpiryExtendedEvent, T as QueryReturnType, _ as EntityCreatedEvent, a as MutateEntitiesParameters, b as EntityEventContext, c as PatchEntityReturnType, d as DeleteEntityParameters, f as DeleteEntityReturnType, g as WatchEntityEventsParameters, h as GetBlockTimingReturnType, i as MimeType, l as ExtendEntityParameters, m as CreateEntityReturnType, n as ChangeOwnershipReturnType, o as MutateEntitiesReturnType, p as CreateEntityParameters, r as TxParams, s as PatchEntityParameters, t as ChangeOwnershipParameters, u as ExtendEntityReturnType, v as EntityDeletedEvent, w as QueryOptions, x as EntityPatchedEvent, y as EntityEvent } from "./changeOwnership-DwgtdSFc.js";
8
+ import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "./payload-Dgx3PQeK.js";
4
9
  import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
5
10
 
6
11
  //#region src/clients/decorators/arkivPublic.d.ts
@@ -11,23 +16,28 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
11
16
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
12
17
  *
13
18
  * @param key - The entity key (hex string)
14
- * @returns The entity with the given key. {@link Entity}
19
+ * @returns The entity with the given key, with every field populated. {@link FullEntity}
15
20
  *
16
21
  * @example
17
- * import { createPublicClient, http } from 'arkiv'
18
- * import { braga } from 'arkiv/chains'
22
+ * import { createPublicClient } from "@arkiv-network/sdk"
23
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
24
+ * import { http } from "viem"
19
25
  *
20
26
  * const client = createPublicClient({
21
- * chain: braga,
27
+ * chain: cheesecake,
22
28
  * transport: http(),
23
29
  * })
24
- * const entity = await client.getEntity("0x123")
25
- * // {
26
- * // key: "0x123",
27
- * // value: "0x123",
30
+ * const entity = await client.getEntity(entityKey)
31
+ * // Entity {
32
+ * // key: "0x9f2c…",
33
+ * // owner: "0xabc…",
34
+ * // contentType: "application/json",
35
+ * // payload: Uint8Array, // entity.toJson() / entity.toText() decode it
36
+ * // attributes: { category: { type: "str", value: "docs" } },
37
+ * // expiresAt: 1_297_000n,
28
38
  * // }
29
39
  */
30
- getEntity: (key: Hex) => Promise<Entity>;
40
+ getEntity: (key: Hex) => Promise<FullEntity>;
31
41
  /**
32
42
  * Returns a SelectQueryBuilder for building and executing queries — the recommended way to
33
43
  * read entities. You declare up front which parts of an entity you want returned, so results
@@ -42,12 +52,13 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
42
52
  * @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder}
43
53
  *
44
54
  * @example
45
- * import { createPublicClient, http } from 'arkiv'
46
- * import { braga } from 'arkiv/chains'
47
- * import { eq } from 'arkiv/query'
55
+ * import { createPublicClient } from "@arkiv-network/sdk"
56
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
57
+ * import { eq } from "@arkiv-network/sdk/query"
58
+ * import { http } from "viem"
48
59
  *
49
60
  * const client = createPublicClient({
50
- * chain: braga,
61
+ * chain: cheesecake,
51
62
  * transport: http(),
52
63
  * })
53
64
  * // select everything
@@ -55,7 +66,7 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
55
66
  * await client.select("*").where(eq("category", "docs")).fetch()
56
67
  * // only the key
57
68
  * await client.select({ key: true }).where(eq("category", "docs")).fetch()
58
- * // select specific fields — result typed { owner: Hex; attributes: Attribute[] }
69
+ * // select specific fields — result typed { owner: Hex; attributes: Attributes }
59
70
  * await client.select({ owner: true, attributes: true }).fetch()
60
71
  * // a single field — result typed { owner: Hex }
61
72
  * await client.select({ owner: true }).fetch()
@@ -67,9 +78,11 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
67
78
  * Pick the entity fields to return. Set the ones you want to `true` (at least one is required);
68
79
  * the result is typed to exactly those fields, so reading anything else is a compile error.
69
80
  *
70
- * Available fields: `key`, `owner`, `creator`, `contentType`, `payload`, `attributes`,
71
- * `expiresAtBlock`, `createdAtBlock`, `lastModifiedAtBlock`, `transactionIndexInBlock`,
72
- * `operationIndexInTransaction`.
81
+ * Available fields: `key`, `owner`, `creator`, `createdAt`, `updatedAt`, `expiresAt`,
82
+ * `creationFlags`, `contentType`, `payload`, `attributeSchema` and `attributes`.
83
+ *
84
+ * `attributes` also takes a map of names, to fetch only those:
85
+ * `select({ key: true, attributes: { projectId: true } })`.
73
86
  *
74
87
  * Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/
75
88
  * `const` variable widens to `boolean` and the result type can no longer be narrowed — annotate
@@ -77,7 +90,8 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
77
90
  *
78
91
  * @example
79
92
  * client.select({ owner: true, attributes: true }) // entities typed { owner, attributes }
80
- * client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
93
+ * client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
94
+ * client.select({ key: true, attributeSchema: true }) // what shape is the data?
81
95
  */
82
96
  <const S extends EntitySelection>(selection: S): SelectQueryBuilder<ProjectedEntity<S>>;
83
97
  /**
@@ -87,87 +101,124 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
87
101
  (selection: SelectArg): SelectQueryBuilder<FullEntity>;
88
102
  };
89
103
  /**
90
- * Returns a QueryBuilder instance for building and executing queries.
91
- * The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
92
- *
93
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
104
+ * Runs one query and returns one page, with no builder in between.
94
105
  *
95
- * @deprecated Use {@link select} instead. `buildQuery()` returns only the entity `key` unless
96
- * you remember to opt in to data with `withAttributes()`/`withMetadata()`/`withPayload()`, which
97
- * is an easy mistake. `select()` makes the selection explicit. This method remains for backwards
98
- * compatibility and will be removed in a future release.
106
+ * Use {@link select} for anything typed — this returns full {@link Entity} objects whatever the
107
+ * selection, and takes a raw string as an escape hatch for a query built elsewhere. A raw string
108
+ * goes to the node exactly as written, with none of the name, type or operator checks the
109
+ * expression combinators apply.
99
110
  *
100
- * @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
111
+ * @param query - An {@link Expression}, or the raw query string.
112
+ * @param queryOptions - Selection, page size, cursor and block. {@link QueryOptions}
113
+ * @returns One page of entities. {@link QueryReturnType}
101
114
  *
102
115
  * @example
103
- * import { createPublicClient, http } from 'arkiv'
104
- * import { braga } from 'arkiv/chains'
116
+ * import { createPublicClient } from "@arkiv-network/sdk"
117
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
118
+ * import { and, eq, gte } from "@arkiv-network/sdk/query"
119
+ * import { i32 } from "@arkiv-network/sdk/attr"
120
+ * import { http } from "viem"
105
121
  *
106
122
  * const client = createPublicClient({
107
- * chain: braga,
123
+ * chain: cheesecake,
108
124
  * transport: http(),
109
125
  * })
110
- * const query = client.buildQuery()
111
- * const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
126
+ * const page = await client.query(and(eq("category", "docs"), gte("level", i32(10))), {
127
+ * select: { key: true, attributes: true },
128
+ * limit: 100,
129
+ * })
130
+ * // { entities: [Entity], cursor: "b64:…", blockNumber: 32223n }
112
131
  *
132
+ * // The raw form, unchecked:
133
+ * await client.query("category = str('docs') AND level >= i32(10)")
113
134
  */
114
- buildQuery: () => QueryBuilder;
135
+ query: (query: Expression | string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
115
136
  /**
116
- * Returns a QueryResult instance for fetching the results of a raw query.
117
- * If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
118
- * @param query - The raw query string
119
- * @param queryOptions - The optional query options - {@link QueryOptions}
120
- * @returns A QueryReturnType instance - {@link QueryReturnType}
137
+ * Returns the total number of entities on the chain.
138
+ * @returns The number of entities currently stored
121
139
  *
122
140
  * @example
123
- * import { createPublicClient, http } from 'arkiv'
124
- * import { braga } from 'arkiv/chains'
141
+ * import { createPublicClient } from "@arkiv-network/sdk"
142
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
143
+ * import { http } from "viem"
125
144
  *
126
145
  * const client = createPublicClient({
127
- * chain: braga,
146
+ * chain: cheesecake,
128
147
  * transport: http(),
129
148
  * })
130
- * const queryResult = client.query('key = value && $owner = 0x123')
131
- * // queryResult = { entities: [{ key: "0x123", value: "0x123" }], cursor: undefined, blockNumber: undefined }
132
- * const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
133
- * includeData: {
134
- * attributes: false,
135
- * payload: true,
136
- * metadata: true,
137
- * },
138
- * resultsPerPage: 10,
139
- * cursor: undefined,
140
- * atBlock: undefined,
141
- * })
142
- * // queryResultWithOptions = { entities: [{ key: "0x123", value: "0x123" }], cursor: "...", blockNumber: 32223n }
149
+ * const entityCount = await client.getEntityCount()
150
+ * // entityCount = 0
143
151
  */
144
- query: (query: string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
152
+ getEntityCount: () => Promise<number>;
145
153
  /**
146
- * Returns the number of entities in the DBChain.
147
- * @returns The number of entities in the DBChain
154
+ * Returns how many entities an account has created — its entity-minting nonce.
155
+ *
156
+ * Not the account's transaction nonce: the engine keeps its own counter per creator and mixes it
157
+ * into every key it mints, which is why two identical creates from one account never collide.
158
+ *
159
+ * @param owner - The account whose nonce to read.
160
+ * @returns The nonce the account's next create will use.
148
161
  *
149
162
  * @example
150
- * import { createPublicClient, http } from 'arkiv'
151
- * import { braga } from 'arkiv/chains'
163
+ * import { createPublicClient } from "@arkiv-network/sdk"
164
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
165
+ * import { http } from "viem"
152
166
  *
153
167
  * const client = createPublicClient({
154
- * chain: braga,
168
+ * chain: cheesecake,
155
169
  * transport: http(),
156
170
  * })
157
- * const entityCount = await client.getEntityCount()
158
- * // entityCount = 0
171
+ * const nonce = await client.getEntityNonce("0xabc…")
172
+ * // 7n — the next entity this account creates is its eighth
159
173
  */
160
- getEntityCount: () => Promise<number>;
174
+ getEntityNonce: (owner: Address) => Promise<bigint>;
175
+ /**
176
+ * Works out the keys an account's next creates will be given, before sending them.
177
+ *
178
+ * The engine derives a key from the chain, the registry, the owner, the owner's nonce and a
179
+ * salt — everything but the nonce is known to the caller, and the nonce is read here. This is
180
+ * what lets a batch reference an entity it is about to mint.
181
+ *
182
+ * Each key arrives paired with the salt that mints it, because a create defaults to a *random*
183
+ * salt: a predicted key only holds if the create carries the salt it was predicted with. And the
184
+ * prediction holds only while nothing else from this owner is in flight — for a key you can rely
185
+ * on unconditionally, read it back from the create instead.
186
+ *
187
+ * A literal `count` comes back as a fixed-length tuple, so the pairs destructure into names.
188
+ *
189
+ * @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
190
+ * @returns One `{ key, salt }` pair per create, in batch order.
191
+ * {@link PredictEntityKeysReturnType}
192
+ *
193
+ * @example A batch whose second entity points at its first.
194
+ * import { key } from "@arkiv-network/sdk/attr"
195
+ *
196
+ * const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
197
+ * await wallet.mutateEntities({
198
+ * creates: [
199
+ * { payload, contentType, expires, salt: parent.salt },
200
+ * {
201
+ * payload,
202
+ * contentType,
203
+ * expires,
204
+ * salt: child.salt,
205
+ * attributes: { parent: key(parent.key) },
206
+ * },
207
+ * ],
208
+ * })
209
+ */
210
+ predictEntityKeys: <const TCount extends number = number, const TSalts extends readonly bigint[] | undefined = undefined>(parameters: PredictEntityKeysParameters<TCount, TSalts>) => Promise<PredictEntityKeysReturnType<TCount, TSalts>>;
161
211
  /**
162
212
  * Returns the current block timing.
163
213
  * @returns The current block timing. {@link GetBlockTimingReturnType}
164
214
  *
165
215
  * @example
166
- * import { createPublicClient, http } from 'arkiv'
167
- * import { braga } from 'arkiv/chains'
216
+ * import { createPublicClient } from "@arkiv-network/sdk"
217
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
218
+ * import { http } from "viem"
168
219
  *
169
220
  * const client = createPublicClient({
170
- * chain: braga,
221
+ * chain: cheesecake,
171
222
  * transport: http(),
172
223
  * })
173
224
  * const blockTiming = await client.getBlockTiming()
@@ -183,39 +234,32 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
183
234
  blockDuration: number;
184
235
  }>;
185
236
  /**
186
- * Subscribes to entity events.
187
- * Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
188
- * @param pollingInterval - The polling interval in milliseconds
189
- * @param fromBlock - The block number to start from
190
- * @returns A function to unsubscribe from the events
237
+ * Watches entity events, calling the handlers you pass as they arrive.
238
+ *
239
+ * All five are decoded from logs — `onEntityCreated`, `onEntityPatched`, `onExpiryExtended`,
240
+ * `onOwnershipTransferred`, `onEntityDeleted` — and each carries the block, transaction and log
241
+ * index it came from, which is the order the operations were applied in. `onEvent` receives all
242
+ * of them, whatever their type.
243
+ *
244
+ * @param parameters - Handlers and options, all optional. {@link WatchEntityEventsParameters}
245
+ * @returns A function that stops the watcher.
191
246
  *
192
247
  * @example
193
- * import { createPublicClient, http } from 'arkiv'
194
- * import { braga } from 'arkiv/chains'
248
+ * import { createPublicClient } from "@arkiv-network/sdk"
249
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
250
+ * import { http } from "viem"
195
251
  *
196
252
  * const client = createPublicClient({
197
- * chain: braga,
253
+ * chain: cheesecake,
198
254
  * transport: http(),
199
255
  * })
200
- * const unsubscribe = await client.subscribeEntityEvents({
201
- * onError: (error) => console.error("subscribeEntityEvents error", error),
256
+ * const unwatch = client.watchEntityEvents({
257
+ * onEntityCreated: ({ entityKey, expiresAt }) => console.log(entityKey, "until", expiresAt),
258
+ * onError: (error) => console.error("watchEntityEvents error", error),
202
259
  * })
203
- * unsubscribe() // unsubscribe from the events
260
+ * unwatch() // stop watching
204
261
  */
205
- subscribeEntityEvents: ({
206
- onError,
207
- onEntityCreated,
208
- onEntityUpdated,
209
- onEntityDeleted,
210
- onEntityExpiresInExtended
211
- }: {
212
- onError?: (error: Error) => void;
213
- onEntityCreated?: (event: OnEntityCreatedEvent) => void;
214
- onEntityUpdated?: (event: OnEntityUpdatedEvent) => void;
215
- onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
216
- onEntityExpired?: (event: OnEntityExpiredEvent) => void;
217
- onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
218
- }, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
262
+ watchEntityEvents: (parameters: WatchEntityEventsParameters) => () => void;
219
263
  };
220
264
  //#endregion
221
265
  //#region src/clients/createPublicClient.d.ts
@@ -225,24 +269,25 @@ type PublicArkivClient<transport extends Transport = Transport, chain extends Ch
225
269
  *
226
270
  * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
227
271
  *
228
- * 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 [Braga JSON-RPC API](https://braga.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
272
+ * 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 [Cheesecake JSON-RPC API](https://rpc.cheesecake.db-chain.devnet.gobas.me) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
229
273
  *
230
274
  * @param parameters - Configuration object for the public client (chain, transport, etc.)
231
275
  * @returns A Arkiv Public Client. {@link PublicArkivClient}
232
276
  *
233
277
  * @example
234
- * import { createPublicClient, http } from 'arkiv'
235
- * import { braga } from 'arkiv/chains'
278
+ * import { createPublicClient } from "@arkiv-network/sdk"
279
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
280
+ * import { http } from "viem"
236
281
  *
237
282
  * const client = createPublicClient({
238
- * chain: braga,
283
+ * chain: cheesecake,
239
284
  * transport: http(),
240
285
  * })
241
286
  */
242
287
  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>;
243
288
  //#endregion
244
289
  //#region src/clients/decorators/arkivWallet.d.ts
245
- type WalletArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "waitForTransactionReceipt" | "call"> & Pick<WalletActions<chain, account>, "addChain" | "sendCalls" | "waitForCallsStatus" | "sendTransaction" | "sendRawTransaction" | "signMessage" | "signTransaction"> & {
290
+ type WalletArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "waitForTransactionReceipt" | "call" | "simulateContract" | "readContract" | "getBlockNumber"> & Pick<WalletActions<chain, account>, "addChain" | "sendCalls" | "waitForCallsStatus" | "sendTransaction" | "sendRawTransaction" | "signMessage" | "signTransaction" | "writeContract"> & {
246
291
  /**
247
292
  * Creates a new entity.
248
293
  *
@@ -253,57 +298,64 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
253
298
  * @param txParams - Optional transaction parameters
254
299
  * @returns The created entity with transaction hash
255
300
  *
256
- * @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
257
- * that is a multiple of the block time (2 seconds).
258
- * @throws {InvalidAttributeError} If a numeric attribute value is not an
259
- * integer.
301
+ * @throws {InvalidExpiryError} If the expiry exceeds a protocol bound or would leave the
302
+ * entity dead on arrival.
303
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
304
+ * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
260
305
  *
261
306
  * @example
262
- * import { createPublicClient, http } from 'arkiv'
263
- * import { braga } from 'arkiv/chains'
307
+ * import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
308
+ * import { i32 } from "@arkiv-network/sdk/attr"
309
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
310
+ * import { http } from "viem"
264
311
  *
265
- * const client = createPublicClient({
266
- * chain: braga,
312
+ * const client = createWalletClient({
313
+ * chain: cheesecake,
267
314
  * transport: http(),
268
315
  * })
269
- * const { entityKey, txHash } = await client.createEntity({
270
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
271
- * attributes: [{ key: "testKey", value: "testValue" }],
272
- * expiresIn: 1000,
316
+ * const { entityKey, txHash, expiresAt } = await client.createEntity({
317
+ * payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
318
+ * contentType: "application/json",
319
+ * attributes: { testKey: "testValue", level: i32(3) },
320
+ * expires: ExpirationTime.fromDays(30),
273
321
  * })
274
- * console.log("entityKey", entityKey)
275
- * console.log("txHash", txHash)
276
- * // {
277
- * // entityKey: "0x123",
278
- * // txHash: "0x123",
279
- * // }
280
322
  */
281
323
  createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
282
324
  /**
283
- * Updates the entity with the given key.
325
+ * Applies a patch to the entity with the given key: sets some fields, unsets others, and leaves
326
+ * everything it does not name alone.
284
327
  *
285
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
328
+ * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/patchEntity
286
329
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
287
330
  *
288
- * @param data - The entity update parameters
331
+ * @param data - The entity key and the mutations to apply
289
332
  * @param txParams - Optional transaction parameters
290
- * @returns The updated entity with transaction hash
333
+ * @returns The entity key and the transaction hash
291
334
  *
292
- * @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
293
- * that is a multiple of the block time (2 seconds).
294
- * @throws {InvalidAttributeError} If a numeric attribute value is not an
295
- * integer.
335
+ * @throws {EmptyPatchError} If the patch has nothing to apply.
336
+ * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.
337
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
338
+ * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
296
339
  *
297
340
  * @example
298
- * import { createWalletClient, http } from 'arkiv'
299
- * import { braga } from 'arkiv/chains'
341
+ * import { createWalletClient, jsonToPayload } from "@arkiv-network/sdk"
342
+ * import { i32 } from "@arkiv-network/sdk/attr"
343
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
344
+ * import { http } from "viem"
300
345
  *
301
346
  * const client = createWalletClient({
302
- * chain: braga,
347
+ * chain: cheesecake,
303
348
  * transport: http(),
304
349
  * })
350
+ * // Publish the entity: one attribute changes, one goes away, the payload is replaced.
351
+ * const { txHash } = await client.patchEntity({
352
+ * entityKey,
353
+ * set: { status: "published", revision: i32(2) },
354
+ * unset: ["draft"],
355
+ * payload: jsonToPayload({ title: "Hello" }),
356
+ * })
305
357
  */
306
- updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
358
+ patchEntity: (data: PatchEntityParameters, txParams?: TxParams) => Promise<PatchEntityReturnType>;
307
359
  /**
308
360
  * Deletes the entity with the given key.
309
361
  *
@@ -315,52 +367,48 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
315
367
  * @returns The deleted entity with transaction hash
316
368
  *
317
369
  * @example
318
- * import { createWalletClient, http } from 'arkiv'
319
- * import { braga } from 'arkiv/chains'
370
+ * import { createWalletClient } from "@arkiv-network/sdk"
371
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
372
+ * import { http } from "viem"
320
373
  *
321
374
  * const client = createWalletClient({
322
- * chain: braga,
375
+ * chain: cheesecake,
323
376
  * transport: http(),
324
377
  * })
325
- * const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
326
- * console.log("entityKey", entityKey)
327
- * console.log("txHash", txHash)
328
- * // {
329
- * // entityKey: "0x123",
330
- * // txHash: "0x123",
331
- * // }
378
+ * // entityKey is the bytes32 key returned by createEntity.
379
+ * const { txHash } = await client.deleteEntity({ entityKey })
332
380
  */
333
381
  deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
334
382
  /**
335
- * Extends the entity with the given key.
383
+ * Sets a new expiry on the entity with the given key.
384
+ *
385
+ * The new lifetime is resolved the same way a create's is: a duration counts from now rather
386
+ * than adding to what the entity has left, and `atBlock` / `atDate` pin an absolute deadline.
387
+ * The engine rejects an extension that would not move the expiry later.
336
388
  *
337
389
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
338
390
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
339
391
  *
340
- * @param data - The entity update parameters
392
+ * @param data - The entity key and its new lifetime
341
393
  * @param txParams - Optional transaction parameters
342
- * @returns The updated entity with transaction hash
394
+ * @returns The entity key, transaction hash, and the block it is now expected to expire at
343
395
  *
344
- * @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
345
- * that is a multiple of the block time (2 seconds).
396
+ * @throws {InvalidExpiryError} If the expiry is malformed, exceeds a protocol bound, or would
397
+ * leave the entity dead on arrival.
346
398
  *
347
399
  * @example
348
- * import { createWalletClient, http } from 'arkiv'
349
- * import { braga } from 'arkiv/chains'
400
+ * import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk"
401
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
402
+ * import { http } from "viem"
350
403
  *
351
404
  * const client = createWalletClient({
352
- * chain: braga,
405
+ * chain: cheesecake,
353
406
  * transport: http(),
354
407
  * })
355
- * const { entityKey, txHash } = await client.extendEntity("0x123", {
356
- * expiresIn: 1000,
408
+ * const { txHash, expiresAt } = await client.extendEntity({
409
+ * entityKey,
410
+ * expires: ExpirationTime.fromDays(30),
357
411
  * })
358
- * console.log("entityKey", entityKey)
359
- * console.log("txHash", txHash)
360
- * // {
361
- * // entityKey: "0x123",
362
- * // txHash: "0x123",
363
- * // }
364
412
  */
365
413
  extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
366
414
  /**
@@ -380,49 +428,41 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
380
428
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
381
429
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
382
430
  *
383
- * @param data - The mutation parameters (creates, updates, deletes, extensions)
431
+ * Every operation lands in one transaction, so the whole batch applies or none of it does.
432
+ * At least one operation is required.
433
+ *
434
+ * @param data - The mutation parameters (creates, patches, deletes, extensions, ownershipChanges)
384
435
  * @param txParams - Optional transaction parameters
385
436
  * @returns The mutation result with transaction hash
386
437
  *
387
- * @throws {InvalidExpirationError} If any create/update/extension `expiresIn`
388
- * is not a positive integer that is a multiple of the block time (2 seconds).
389
- * @throws {InvalidAttributeError} If a numeric attribute value is not an
390
- * integer.
438
+ * @throws {InvalidExpiryError} If an expiry exceeds a protocol bound or would leave the entity
439
+ * dead on arrival.
440
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
391
441
  *
392
442
  * @example
393
- * import { createWalletClient, http } from 'arkiv'
394
- * import { braga } from 'arkiv/chains'
443
+ * import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
444
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
445
+ * import { http } from "viem"
395
446
  *
396
447
  * const client = createWalletClient({
397
- * chain: braga,
448
+ * chain: cheesecake,
398
449
  * transport: http(),
399
450
  * })
400
- * const { entityKey, txHash } = await client.mutateEntities({
451
+ * const { txHash, createdEntities } = await client.mutateEntities({
401
452
  * creates: [{
402
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
403
- * attriubutes: [{ key: "testKey", value: "testValue" }],
404
- * expiresIn: 1000,
405
- * }],
406
- * updates: [{
407
- * entityKey: "0x123",
408
- * payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
409
- * attributes: [{ key: "testKey", value: "testValue" }],
410
- * expiresIn: 1000,
411
- * }],
412
- * deletes: [{
413
- * entityKey: "0x321",
453
+ * payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
454
+ * contentType: "application/json",
455
+ * attributes: { testKey: "testValue" },
456
+ * expires: ExpirationTime.fromDays(30),
414
457
  * }],
458
+ * patches: [{ entityKey: keyToRevise, set: { status: "archived" }, unset: ["draft"] }],
459
+ * deletes: [{ entityKey: staleKey }],
415
460
  * extensions: [{
416
- * entityKey: "0x1234",
417
- * expiresIn: 1000,
461
+ * entityKey: keyToKeepAlive,
462
+ * expires: ExpirationTime.atBlock(1_200_000n),
418
463
  * }],
464
+ * ownershipChanges: [{ entityKey: keyToHandOver, newOwner }],
419
465
  * })
420
- * console.log("entityKey", entityKey)
421
- * console.log("txHash", txHash)
422
- * // {
423
- * // entityKey: "0x123",
424
- * // txHash: "0x123",
425
- * // }
426
466
  */
427
467
  mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
428
468
  };
@@ -430,44 +470,52 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
430
470
  //#region src/clients/createWalletClient.d.ts
431
471
  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>>>;
432
472
  /**
433
- * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
473
+ * Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured
474
+ * for a [Chain](https://viem.sh/docs/clients/chains) and an account.
434
475
  *
435
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
476
+ * - Docs: https://docs.arkiv.network/ts-sdk/clients/wallet
436
477
  *
437
- * 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 [Braga JSON-RPC API](https://braga.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
478
+ * A Wallet Client signs and sends transactions, so it carries an `account` and exposes everything
479
+ * that mutates state — `createEntity`, `patchEntity`, `deleteEntity`, `extendEntity`,
480
+ * `changeOwnership` and `mutateEntities` — on top of the read actions a Public Client has.
438
481
  *
439
482
  * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
440
483
  * @returns A Arkiv Wallet Client. {@link WalletArkivClient}
441
484
  *
442
485
  * @example
443
- * import { createPublicClient, http } from 'arkiv'
444
- * import { braga } from 'arkiv/chains'
486
+ * import { createWalletClient } from "@arkiv-network/sdk"
487
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
488
+ * import { http } from "viem"
489
+ * import { privateKeyToAccount } from "viem/accounts"
445
490
  *
446
- * const client = createPublicClient({
447
- * chain: braga,
491
+ * const client = createWalletClient({
492
+ * chain: cheesecake,
448
493
  * transport: http(),
494
+ * account: privateKeyToAccount("0x..."),
449
495
  * })
450
496
  */
451
497
  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>;
452
498
  //#endregion
453
499
  //#region src/errors.d.ts
454
500
  declare class EntityMutationError extends Error {
455
- constructor(message: string);
456
- }
457
- declare class InvalidExpirationError extends Error {
458
- constructor(expiresIn: unknown);
459
- }
460
- declare class InvalidAttributeError extends Error {
461
- constructor(key: string, value: number);
501
+ constructor(message: string, options?: {
502
+ cause?: unknown;
503
+ });
462
504
  }
463
505
  declare class NoMoreResultsError extends Error {
464
506
  constructor();
465
507
  }
466
- declare class NoCursorOrLimitError extends Error {
467
- constructor();
468
- }
469
508
  declare class NoEntityFoundError extends Error {
470
- constructor();
509
+ /** The key that matched nothing, when the lookup was by key. */
510
+ readonly entityKey: string | undefined;
511
+ constructor(entityKey?: string);
512
+ }
513
+ declare class EmptyPatchError extends Error {
514
+ readonly entityKey: string;
515
+ constructor(entityKey: string);
516
+ }
517
+ declare class InvalidContentTypeError extends Error {
518
+ constructor(contentType: string);
471
519
  }
472
520
  //#endregion
473
521
  //#region src/utils/chains.d.ts
@@ -479,5 +527,5 @@ declare class NoEntityFoundError extends Error {
479
527
  */
480
528
  declare function chainFromName(name: string): Chain;
481
529
  //#endregion
482
- export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, InvalidAttributeError, InvalidExpirationError, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
530
+ export { AddrValue, AnyArkivValue, type ArkivClient, ArkivRpcSchema, ArkivValue, AttributeInputs, AttributeSchema, Attributes, BoolValue, Bytes32Value, BytesValue, ChangeOwnershipParameters, ChangeOwnershipReturnType, ConflictingMutationError, CreateEntityParameters, CreateEntityReturnType, CreationFlags, DECIMAL_SCALE, DECIMAL_UNIT, type DeadlineOptions, DecValue, DeleteEntityParameters, DeleteEntityReturnType, ENTITY_EVENTS_ABI, EmptyPatchError, EncodedExpiry, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityEventName, EntityFields, EntityMutationError, EntityPatchedEvent, ExpirationTime, Expiry, ExpiryContext, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, I32Value, I32_MAX, I32_MIN, InvalidAttributeNameError, InvalidContentTypeError, InvalidCreationFlagsError, InvalidExpiryError, InvalidSaltError, InvalidValueError, KeyValue, Lifetime, MAX_ATTRIBUTES, MAX_EXPIRES_AT, MAX_NAME_BYTES, MAX_PAYLOAD_BYTES, MAX_SALT, MAX_STRING_BYTES, MimeType, MissingValueError, MutateEntitiesParameters, MutateEntitiesReturnType, NoEntityFoundError, NoMoreResultsError, NoRandomSourceError, OperationType, OwnershipTransferredEvent, PatchEntityParameters, PatchEntityReturnType, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryReturnType, ResolvedCreationFlags, ResolvedExpiry, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, StrValue, TooManyAttributesError, TxParams, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, UserTypeTag, ValueInput, type WalletArkivActions, type WalletArkivClient, WatchEntityEventsParameters, addr, bool, bytes32, chainFromName, createPublicClient, createWalletClient, dec, decFromUnits, decUnits, decodeCreationFlags, encodeCreationFlags, i32, isArkivValue, isValidAttributeName, jsonToPayload, key, predictEntityKey, randomSalt, resolveExpiry, str, stringToPayload, toBlocks, toValue, u256, u64, validateAttributeName };
483
531
  //# sourceMappingURL=index.d.ts.map