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

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 (240) 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-Ds2XRflQ.cjs +656 -0
  7. package/dist/advanced-FZy7WoYR.js +598 -0
  8. package/dist/advanced-FZy7WoYR.js.map +1 -0
  9. package/dist/arkivTransactions-BpARZOsH.d.cts +584 -0
  10. package/dist/arkivTransactions-BpARZOsH.d.cts.map +1 -0
  11. package/dist/arkivTransactions-DfZ_yVDD.d.ts +584 -0
  12. package/dist/arkivTransactions-DfZ_yVDD.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-BJGuhsqp.js +819 -0
  18. package/dist/attributes-BJGuhsqp.js.map +1 -0
  19. package/dist/attributes-CMJlp1wn.cjs +1039 -0
  20. package/dist/chains/index.cjs +2 -3
  21. package/dist/chains/index.d.cts +41 -76
  22. package/dist/chains/index.d.cts.map +1 -1
  23. package/dist/chains/index.d.ts +24 -59
  24. package/dist/chains/index.d.ts.map +1 -1
  25. package/dist/chains/index.js +2 -2
  26. package/dist/chains-BfNQliHU.cjs +76 -0
  27. package/dist/chains-Du8tql7I.js +60 -0
  28. package/dist/chains-Du8tql7I.js.map +1 -0
  29. package/dist/codec-M74UR1_0.d.ts +101 -0
  30. package/dist/codec-M74UR1_0.d.ts.map +1 -0
  31. package/dist/entity/index.cjs +21 -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-51znTSB1.cjs +56 -0
  41. package/dist/errors-CwPJ16bn.js +33 -0
  42. package/dist/errors-CwPJ16bn.js.map +1 -0
  43. package/dist/expiry-CZErShX6.js +95 -0
  44. package/dist/expiry-CZErShX6.js.map +1 -0
  45. package/dist/expiry-DRV29F1r.d.cts +79 -0
  46. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  47. package/dist/expiry-nDbCgZX4.d.ts +79 -0
  48. package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
  49. package/dist/expiry-xr6mx4f7.cjs +135 -0
  50. package/dist/flags-5dTNRnow.d.ts +41 -0
  51. package/dist/flags-5dTNRnow.d.ts.map +1 -0
  52. package/dist/flags-Bh0HJldY.cjs +43 -0
  53. package/dist/flags-CRjPpoh3.d.cts +41 -0
  54. package/dist/flags-CRjPpoh3.d.cts.map +1 -0
  55. package/dist/flags-Cr76ldwF.js +33 -0
  56. package/dist/flags-Cr76ldwF.js.map +1 -0
  57. package/dist/index-CMeD8uEq.d.cts +280 -0
  58. package/dist/index-CMeD8uEq.d.cts.map +1 -0
  59. package/dist/index-CTDI5pXZ.d.ts +184 -0
  60. package/dist/index-CTDI5pXZ.d.ts.map +1 -0
  61. package/dist/index-CekGjkRx.d.cts +184 -0
  62. package/dist/index-CekGjkRx.d.cts.map +1 -0
  63. package/dist/index-D0IzFwMX.d.ts +328 -0
  64. package/dist/index-D0IzFwMX.d.ts.map +1 -0
  65. package/dist/index-DZxwz2Ky.d.cts +177 -0
  66. package/dist/index-DZxwz2Ky.d.cts.map +1 -0
  67. package/dist/index-Dz4SkQWg.d.ts +280 -0
  68. package/dist/index-Dz4SkQWg.d.ts.map +1 -0
  69. package/dist/index-JP31fjyM.d.ts +177 -0
  70. package/dist/index-JP31fjyM.d.ts.map +1 -0
  71. package/dist/index-NbfnXxgr.d.cts +424 -0
  72. package/dist/index-NbfnXxgr.d.cts.map +1 -0
  73. package/dist/index.cjs +434 -412
  74. package/dist/index.d.cts +401 -235
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +402 -235
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +370 -404
  79. package/dist/index.js.map +1 -1
  80. package/dist/key-E7mv0BYf.cjs +116 -0
  81. package/dist/key-XQkpw2xh.js +82 -0
  82. package/dist/key-XQkpw2xh.js.map +1 -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-Cvrir3Q-.cjs +108 -0
  87. package/dist/payload-D53ms-Mg.d.ts +153 -0
  88. package/dist/payload-D53ms-Mg.d.ts.map +1 -0
  89. package/dist/payload-DaPzUvEh.js +92 -0
  90. package/dist/payload-DaPzUvEh.js.map +1 -0
  91. package/dist/payload-hluX1rc0.d.cts +153 -0
  92. package/dist/payload-hluX1rc0.d.cts.map +1 -0
  93. package/dist/query/index.cjs +26 -149
  94. package/dist/query/index.d.cts +5 -3
  95. package/dist/query/index.d.ts +6 -3
  96. package/dist/query/index.js +8 -137
  97. package/dist/queryBuilder-BXR-HxD9.cjs +947 -0
  98. package/dist/queryBuilder-BwauPaGO.js +823 -0
  99. package/dist/queryBuilder-BwauPaGO.js.map +1 -0
  100. package/dist/selection-C6KeWJ7g.d.cts +441 -0
  101. package/dist/selection-C6KeWJ7g.d.cts.map +1 -0
  102. package/dist/selection-mjiiAGDO.d.ts +442 -0
  103. package/dist/selection-mjiiAGDO.d.ts.map +1 -0
  104. package/dist/types/index.cjs +4 -1
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +4 -1
  108. package/dist/types-Bu_ZwMbZ.js +0 -0
  109. package/dist/types-NRqymi6S.cjs +0 -0
  110. package/dist/utils/index.cjs +4 -17
  111. package/dist/utils/index.d.cts +3 -17
  112. package/dist/utils/index.d.ts +3 -17
  113. package/dist/utils/index.js +4 -18
  114. package/package.json +26 -9
  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 +28 -43
  122. package/src/actions/public/getEntityNonce.ts +30 -0
  123. package/src/actions/public/predictEntityKeys.test.ts +159 -0
  124. package/src/actions/public/predictEntityKeys.ts +152 -0
  125. package/src/actions/public/query.ts +35 -67
  126. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  127. package/src/actions/public/watchEntityEvents.ts +225 -0
  128. package/src/actions/wallet/changeOwnership.ts +8 -8
  129. package/src/actions/wallet/createEntity.ts +105 -26
  130. package/src/actions/wallet/deleteEntity.ts +2 -3
  131. package/src/actions/wallet/executeBatch.test.ts +76 -0
  132. package/src/actions/wallet/executeBatch.ts +51 -0
  133. package/src/actions/wallet/extendEntity.ts +40 -16
  134. package/src/actions/wallet/patchEntity.ts +90 -0
  135. package/src/attr/attributes.test.ts +120 -0
  136. package/src/attr/attributes.ts +196 -0
  137. package/src/attr/codec.test.ts +162 -0
  138. package/src/attr/codec.ts +220 -0
  139. package/src/attr/decimal.ts +86 -0
  140. package/src/attr/errors.ts +145 -0
  141. package/src/attr/index.ts +50 -0
  142. package/src/attr/names.ts +106 -0
  143. package/src/attr/types.ts +150 -0
  144. package/src/attr/values.test.ts +271 -0
  145. package/src/attr/values.ts +506 -0
  146. package/src/chains/cheesecake.ts +22 -0
  147. package/src/chains/index.ts +1 -2
  148. package/src/chains/localhost.ts +3 -0
  149. package/src/clients/createPublicClient.test.ts +4 -6
  150. package/src/clients/createPublicClient.ts +9 -8
  151. package/src/clients/createWalletClient.test.ts +4 -4
  152. package/src/clients/createWalletClient.ts +13 -9
  153. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  154. package/src/clients/decorators/arkivPublic.ts +181 -147
  155. package/src/clients/decorators/arkivWallet.ts +141 -122
  156. package/src/consts.ts +2 -1
  157. package/src/entity/create.test.ts +203 -0
  158. package/src/entity/errors.ts +39 -0
  159. package/src/entity/events.ts +16 -0
  160. package/src/entity/expiry.test.ts +195 -0
  161. package/src/entity/expiry.ts +182 -0
  162. package/src/entity/flags.ts +65 -0
  163. package/src/entity/index.ts +16 -0
  164. package/src/entity/key.ts +88 -0
  165. package/src/entity/operations.ts +135 -0
  166. package/src/entity/params.ts +15 -0
  167. package/src/errors.ts +33 -28
  168. package/src/index.ts +19 -0
  169. package/src/query/engine.ts +68 -132
  170. package/src/query/errors.ts +151 -0
  171. package/src/query/expression.test.ts +286 -0
  172. package/src/query/expression.ts +500 -0
  173. package/src/query/index.ts +40 -4
  174. package/src/query/injection.test.ts +151 -0
  175. package/src/query/queryBuilder.test.ts +342 -637
  176. package/src/query/queryBuilder.ts +133 -359
  177. package/src/query/queryResult.ts +54 -51
  178. package/src/query/selection.test.ts +48 -98
  179. package/src/query/selection.ts +77 -65
  180. package/src/types/entity.test.ts +44 -155
  181. package/src/types/entity.ts +62 -44
  182. package/src/types/events.ts +64 -23
  183. package/src/types/index.ts +24 -20
  184. package/src/types/rpcSchema.ts +71 -33
  185. package/src/types/txParams.ts +8 -0
  186. package/src/utils/arkivTransactions.test.ts +687 -38
  187. package/src/utils/arkivTransactions.ts +400 -115
  188. package/src/utils/chains.test.ts +21 -24
  189. package/src/utils/compression.ts +1 -1
  190. package/src/utils/entities.test.ts +62 -0
  191. package/src/utils/entities.ts +111 -29
  192. package/src/utils/expirationTime.ts +153 -10
  193. package/src/utils/logger.ts +2 -2
  194. package/src/utils/payload.ts +29 -2
  195. package/src/utils/revert.test.ts +99 -0
  196. package/src/utils/revert.ts +145 -0
  197. package/dist/chains-BifaY04V.cjs +0 -108
  198. package/dist/chains-CrtkVbBh.js +0 -86
  199. package/dist/chains-CrtkVbBh.js.map +0 -1
  200. package/dist/consts-AUoL-v42.cjs +0 -18
  201. package/dist/consts-BV4PR-de.js +0 -7
  202. package/dist/consts-BV4PR-de.js.map +0 -1
  203. package/dist/entity-B6g_EPm1.d.cts +0 -382
  204. package/dist/entity-B6g_EPm1.d.cts.map +0 -1
  205. package/dist/entity-qoLMAuuk.d.ts +0 -382
  206. package/dist/entity-qoLMAuuk.d.ts.map +0 -1
  207. package/dist/index-DdspxNAA.d.ts +0 -481
  208. package/dist/index-DdspxNAA.d.ts.map +0 -1
  209. package/dist/index-Ds9dwqb5.d.cts +0 -481
  210. package/dist/index-Ds9dwqb5.d.cts.map +0 -1
  211. package/dist/payload-B2kFJyah.d.ts +0 -6
  212. package/dist/payload-B2kFJyah.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-Claf2jUO.js +0 -13
  216. package/dist/payload-Claf2jUO.js.map +0 -1
  217. package/dist/payload-DpA5PA-w.cjs +0 -23
  218. package/dist/query/index.js.map +0 -1
  219. package/dist/queryBuilder-D2uwP9jI.js +0 -704
  220. package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
  221. package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
  222. package/dist/utils/index.d.cts.map +0 -1
  223. package/dist/utils/index.d.ts.map +0 -1
  224. package/dist/utils/index.js.map +0 -1
  225. package/src/actions/public/buildQuery.ts +0 -10
  226. package/src/actions/public/subscribeEntityEvents.ts +0 -119
  227. package/src/actions/wallet/mutateEntities.ts +0 -111
  228. package/src/actions/wallet/updateEntity.ts +0 -60
  229. package/src/chains/braga.ts +0 -26
  230. package/src/chains/kaolin.ts +0 -29
  231. package/src/query/engine.test.ts +0 -526
  232. package/src/query/predicate.test.ts +0 -461
  233. package/src/query/predicate.ts +0 -144
  234. package/src/query/queryResult.test.ts +0 -270
  235. package/src/query/selectQueryBuilder.test.ts +0 -210
  236. package/src/types/attributes.ts +0 -16
  237. package/src/utils/validation.test.ts +0 -60
  238. package/src/utils/validation.ts +0 -32
  239. /package/dist/{types-H-TSmRpm.js → attr-DlmErkvR.cjs} +0 -0
  240. /package/dist/{types-o3zWarRp.cjs → attr-GcQKatub.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,39 +1,145 @@
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";
4
- import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
1
+ import { F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, c as EntityFields, i as SelectArg, j as ArkivClient, n as FullEntity, p as Expression, r as ProjectedEntity, s as Entity, t as EntitySelection } from "./selection-mjiiAGDO.js";
2
+ import { a as Bytes32Value, c as I32Value, d as TypeTag, f as U256Value, h as isArkivValue, i as BoolValue, l as KeyValue, m as UserTypeTag, n as AnyArkivValue, o as BytesValue, p as U64Value, r as ArkivValue, s as DecValue, t as AddrValue, u as StrValue } from "./codec-M74UR1_0.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-nDbCgZX4.js";
4
+ import { a as InvalidCreationFlagsError, c as NoRandomSourceError, d as SaltInput, f as predictEntityKey, i as EntityEventName, l as MAX_SALT, m as Operation, n as OperationType, o as InvalidExpiryError, p as randomSalt, r as ENTITY_EVENTS_ABI, s as InvalidSaltError, t as MAX_EXPIRES_AT, u as NO_SALT } from "./index-JP31fjyM.js";
5
+ import { A as PredictEntityKeysParameters, C as EntityEvent, D as OwnershipTransferredEvent, E as ExpiryExtendedEvent, M as PredictedEntityKey, N as GetBlockTimingReturnType, O as QueryOptions, S as EntityDeletedEvent, T as EntityPatchedEvent, _ as DeleteEntityReturnType, a as mutationNeedsBlockNumber, b as WatchEntityEventsParameters, c as TxParams, d as PatchEntityReturnType, f as ExtendEntityParameters, g as DeleteEntityParameters, h as ExecuteBatchReturnType, i as collectMutationEvents, j as PredictEntityKeysReturnType, k as QueryReturnType, l as MimeType, m as ExecuteBatchParameters, n as MutationEvents, o as ChangeOwnershipParameters, p as ExtendEntityReturnType, r as buildEntityOperations, s as ChangeOwnershipReturnType, t as EntityMutationOps, u as PatchEntityParameters, v as CreateEntityParameters, w as EntityEventContext, x as EntityCreatedEvent, y as CreateEntityReturnType } from "./arkivTransactions-DfZ_yVDD.js";
6
+ import { A as i32, C as ValueInput, D as dec, E as bytes32, F as u64, M as str, N as toValue, O as decFromUnits, P as u256, S as U64_MAX, T as bool, _ 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, 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 } from "./index-D0IzFwMX.js";
7
+ import { i as encodeCreationFlags, n as ResolvedCreationFlags, r as decodeCreationFlags, t as CreationFlags } from "./flags-5dTNRnow.js";
8
+ import { a as pingTransaction, c as decodeMutationResult, d as BuildMutationReturnType, f as buildMutation, i as PingTransactionReturnType, l as getMutationResult, n as SendMutationReturnType, o as GetMutationResultReturnType, r as sendMutation, s as MutationResult, t as SendMutationOptions, u as BuildMutationOptions } from "./index-CTDI5pXZ.js";
9
+ import { t as SelectQueryBuilder } from "./index-Dz4SkQWg.js";
10
+ import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "./payload-D53ms-Mg.js";
11
+ import { Account, Address, Chain, Client, Hash, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, TransactionReceipt, Transport, WalletActions, WalletClientConfig } from "viem";
5
12
 
13
+ //#region src/clients/decorators/arkivAdvanced.d.ts
14
+ /**
15
+ * The read-only half of the advanced path — checking on a transaction and decoding its result —
16
+ * which needs no account, so a Public Client carries it too.
17
+ *
18
+ * Every action here costs at most one RPC call, and says exactly which.
19
+ */
20
+ type PublicAdvancedActions = {
21
+ /**
22
+ * Asks the chain — once — whether a transaction has landed. Exactly one
23
+ * `eth_getTransactionReceipt`, never a poll: an unmined transaction comes back as
24
+ * `{ status: "pending" }` and the schedule stays yours.
25
+ *
26
+ * @param txHash - The transaction hash returned by `sendMutation` (or any other send)
27
+ * @returns `{ status: "pending" }`, or `{ status: "success" | "reverted", blockNumber }`
28
+ *
29
+ * @example
30
+ * const { status } = await client.advanced.pingTransaction(txHash)
31
+ * if (status === "pending") scheduleAnotherPing()
32
+ */
33
+ pingTransaction: (txHash: Hash) => Promise<PingTransactionReturnType>;
34
+ /**
35
+ * Fetches a transaction's receipt — once — and decodes what the mutation did: created keys and
36
+ * expiries, plus the keys of everything patched, deleted, extended or handed over. One
37
+ * `eth_getTransactionReceipt`; `{ status: "pending" }` if not mined yet. No revert diagnosis is
38
+ * run on a `reverted` result — that extra call is yours to spend or skip.
39
+ *
40
+ * @param txHash - The transaction hash
41
+ * @returns The decoded {@link MutationResult}, or `{ status: "pending" }`
42
+ *
43
+ * @example
44
+ * const result = await client.advanced.getMutationResult(txHash)
45
+ * if (result.status === "success") console.log(result.createdEntities)
46
+ */
47
+ getMutationResult: (txHash: Hash) => Promise<GetMutationResultReturnType>;
48
+ /**
49
+ * Decodes a receipt you already hold into a {@link MutationResult}. **Zero RPC calls** — for
50
+ * receipts that reached you through your own `waitForTransactionReceipt`, a block watcher, or a
51
+ * webhook.
52
+ *
53
+ * @param receipt - The transaction receipt
54
+ * @returns The decoded {@link MutationResult}
55
+ */
56
+ decodeMutationResult: (receipt: TransactionReceipt) => MutationResult;
57
+ };
58
+ /**
59
+ * The advanced path on a Wallet Client: build, send, ping and read results as separate steps, each
60
+ * costing the minimum number of RPC calls — down to one per transaction when you supply what the
61
+ * SDK would otherwise look up.
62
+ *
63
+ * The everyday actions (`createEntity`, `executeBatch`, …) bundle send + wait + decode and are
64
+ * the right default. This namespace unbundles them for callers optimising their RPC budget.
65
+ *
66
+ * @example Minimal-call flow: one send, one ping, done.
67
+ * const { txHash } = await client.advanced.sendMutation(
68
+ * { creates: [{ payload, contentType: "application/json", expires }] },
69
+ * { currentBlock, txParams: { nonce, gas: 1_000_000n, maxFeePerGas, maxPriorityFeePerGas } },
70
+ * ) // exactly 1 RPC call: eth_sendRawTransaction
71
+ * // ... later, on your own schedule:
72
+ * const result = await client.advanced.getMutationResult(txHash) // 1 RPC call
73
+ * if (result.status === "success") console.log(result.createdEntities)
74
+ */
75
+ type WalletAdvancedActions = PublicAdvancedActions & {
76
+ /**
77
+ * Encodes a mutation batch without sending anything: zero RPC calls with `currentBlock` supplied
78
+ * (or when no expiry is relative), at most one `eth_blockNumber` otherwise. Returns the
79
+ * operations for `writeContract`, and the `{ to, data }` calldata for offline signing.
80
+ *
81
+ * @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
82
+ * @param options - Optional `currentBlock` to avoid the `eth_blockNumber` lookup
83
+ */
84
+ buildMutation: (data: EntityMutationOps, options?: BuildMutationOptions) => Promise<BuildMutationReturnType>;
85
+ /**
86
+ * Signs and sends a mutation batch, returning the hash as soon as the transaction is submitted —
87
+ * no waiting, no polling, no revert diagnosis. With `currentBlock` and full `txParams` (nonce,
88
+ * gas, fees) supplied this is exactly one `eth_sendRawTransaction`; each omitted piece adds only
89
+ * the lookup viem needs to fill it.
90
+ *
91
+ * @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
92
+ * @param options - Optional `currentBlock` and `txParams`
93
+ * @returns The transaction hash and the batch's per-kind operation counts
94
+ *
95
+ * @example
96
+ * const { txHash } = await client.advanced.sendMutation({
97
+ * creates: [{ payload, contentType: "application/json", expires: ExpirationTime.atBlock(1_200_000n) }],
98
+ * })
99
+ */
100
+ sendMutation: (data: EntityMutationOps, options?: SendMutationOptions) => Promise<SendMutationReturnType>;
101
+ };
102
+ //#endregion
6
103
  //#region src/clients/decorators/arkivPublic.d.ts
7
104
  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"> & {
8
105
  /**
9
106
  * Returns the entity with the given key.
10
107
  *
11
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
108
+ * - JSON-RPC Methods: `arkiv_query`
12
109
  *
13
110
  * @param key - The entity key (hex string)
14
- * @returns The entity with the given key. {@link Entity}
111
+ * @returns The entity with the given key, with every field populated. {@link FullEntity}
112
+ *
113
+ * @throws {InvalidValueError} If the key is not 32 bytes.
114
+ * @throws {NoEntityFoundError} If no live entity has that key — it never existed, or it was
115
+ * deleted or has expired.
15
116
  *
16
117
  * @example
17
- * import { createPublicClient, http } from 'arkiv'
18
- * import { braga } from 'arkiv/chains'
118
+ * import { createPublicClient } from "@arkiv-network/sdk"
119
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
120
+ * import { http } from "viem"
19
121
  *
20
122
  * const client = createPublicClient({
21
- * chain: braga,
123
+ * chain: cheesecake,
22
124
  * transport: http(),
23
125
  * })
24
- * const entity = await client.getEntity("0x123")
25
- * // {
26
- * // key: "0x123",
27
- * // value: "0x123",
126
+ * const entity = await client.getEntity(entityKey)
127
+ * // Entity {
128
+ * // key: "0x9f2c…",
129
+ * // owner: "0xabc…",
130
+ * // contentType: "application/json",
131
+ * // payload: Uint8Array, // entity.toJson() / entity.toText() decode it
132
+ * // attributes: { category: { type: "str", value: "docs" } },
133
+ * // expiresAt: 1_297_000n,
28
134
  * // }
29
135
  */
30
- getEntity: (key: Hex) => Promise<Entity>;
136
+ getEntity: (key: Hex) => Promise<FullEntity>;
31
137
  /**
32
138
  * Returns a SelectQueryBuilder for building and executing queries — the recommended way to
33
139
  * read entities. You declare up front which parts of an entity you want returned, so results
34
140
  * always contain exactly the data you asked for.
35
141
  *
36
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
142
+ * - JSON-RPC Methods: `arkiv_query`
37
143
  *
38
144
  * @param selection - What to include in the results. Omit it (or pass `"*"`) to select everything,
39
145
  * or pass an object to select specific parts (at least one field is required). Every part is
@@ -42,12 +148,13 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
42
148
  * @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder}
43
149
  *
44
150
  * @example
45
- * import { createPublicClient, http } from 'arkiv'
46
- * import { braga } from 'arkiv/chains'
47
- * import { eq } from 'arkiv/query'
151
+ * import { createPublicClient } from "@arkiv-network/sdk"
152
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
153
+ * import { eq } from "@arkiv-network/sdk/query"
154
+ * import { http } from "viem"
48
155
  *
49
156
  * const client = createPublicClient({
50
- * chain: braga,
157
+ * chain: cheesecake,
51
158
  * transport: http(),
52
159
  * })
53
160
  * // select everything
@@ -55,7 +162,7 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
55
162
  * await client.select("*").where(eq("category", "docs")).fetch()
56
163
  * // only the key
57
164
  * await client.select({ key: true }).where(eq("category", "docs")).fetch()
58
- * // select specific fields — result typed { owner: Hex; attributes: Attribute[] }
165
+ * // select specific fields — result typed { owner: Hex; attributes: Attributes }
59
166
  * await client.select({ owner: true, attributes: true }).fetch()
60
167
  * // a single field — result typed { owner: Hex }
61
168
  * await client.select({ owner: true }).fetch()
@@ -67,9 +174,11 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
67
174
  * Pick the entity fields to return. Set the ones you want to `true` (at least one is required);
68
175
  * the result is typed to exactly those fields, so reading anything else is a compile error.
69
176
  *
70
- * Available fields: `key`, `owner`, `creator`, `contentType`, `payload`, `attributes`,
71
- * `expiresAtBlock`, `createdAtBlock`, `lastModifiedAtBlock`, `transactionIndexInBlock`,
72
- * `operationIndexInTransaction`.
177
+ * Available fields: `key`, `owner`, `creator`, `createdAt`, `updatedAt`, `expiresAt`,
178
+ * `creationFlags`, `contentType`, `payload`, `attributeSchema` and `attributes`.
179
+ *
180
+ * `attributes` also takes a map of names, to fetch only those:
181
+ * `select({ key: true, attributes: { projectId: true } })`.
73
182
  *
74
183
  * Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/
75
184
  * `const` variable widens to `boolean` and the result type can no longer be narrowed — annotate
@@ -77,7 +186,8 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
77
186
  *
78
187
  * @example
79
188
  * client.select({ owner: true, attributes: true }) // entities typed { owner, attributes }
80
- * client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
189
+ * client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
190
+ * client.select({ key: true, attributeSchema: true }) // what shape is the data?
81
191
  */
82
192
  <const S extends EntitySelection>(selection: S): SelectQueryBuilder<ProjectedEntity<S>>;
83
193
  /**
@@ -87,87 +197,124 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
87
197
  (selection: SelectArg): SelectQueryBuilder<FullEntity>;
88
198
  };
89
199
  /**
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.
200
+ * Runs one query and returns one page, with no builder in between.
92
201
  *
93
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
202
+ * Use {@link PublicArkivActions.select} for anything typed — this returns full {@link Entity} objects whatever the
203
+ * selection, and takes a raw string as an escape hatch for a query built elsewhere. A raw string
204
+ * goes to the node exactly as written, with none of the name, type or operator checks the
205
+ * expression combinators apply.
94
206
  *
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.
99
- *
100
- * @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
207
+ * @param query - An {@link Expression}, or the raw query string.
208
+ * @param queryOptions - Selection, page size, cursor and block. {@link QueryOptions}
209
+ * @returns One page of entities. {@link QueryReturnType}
101
210
  *
102
211
  * @example
103
- * import { createPublicClient, http } from 'arkiv'
104
- * import { braga } from 'arkiv/chains'
212
+ * import { createPublicClient } from "@arkiv-network/sdk"
213
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
214
+ * import { and, eq, gte } from "@arkiv-network/sdk/query"
215
+ * import { i32 } from "@arkiv-network/sdk/attr"
216
+ * import { http } from "viem"
105
217
  *
106
218
  * const client = createPublicClient({
107
- * chain: braga,
219
+ * chain: cheesecake,
108
220
  * transport: http(),
109
221
  * })
110
- * const query = client.buildQuery()
111
- * const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
222
+ * const page = await client.query(and(eq("category", "docs"), gte("level", i32(10))), {
223
+ * select: { key: true, attributes: true },
224
+ * limit: 100,
225
+ * })
226
+ * // { entities: [Entity], cursor: "b64:…", blockNumber: 32223n }
112
227
  *
228
+ * // The raw form, unchecked:
229
+ * await client.query("category = str('docs') AND level >= i32(10)")
113
230
  */
114
- buildQuery: () => QueryBuilder;
231
+ query: (query: Expression | string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
115
232
  /**
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}
233
+ * Returns the total number of entities on the chain.
234
+ * @returns The number of entities currently stored
121
235
  *
122
236
  * @example
123
- * import { createPublicClient, http } from 'arkiv'
124
- * import { braga } from 'arkiv/chains'
237
+ * import { createPublicClient } from "@arkiv-network/sdk"
238
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
239
+ * import { http } from "viem"
125
240
  *
126
241
  * const client = createPublicClient({
127
- * chain: braga,
242
+ * chain: cheesecake,
128
243
  * transport: http(),
129
244
  * })
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 }
245
+ * const entityCount = await client.getEntityCount()
246
+ * // entityCount = 0
143
247
  */
144
- query: (query: string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
248
+ getEntityCount: () => Promise<number>;
145
249
  /**
146
- * Returns the number of entities in the DBChain.
147
- * @returns The number of entities in the DBChain
250
+ * Returns how many entities an account has created — its entity-minting nonce.
251
+ *
252
+ * Not the account's transaction nonce: the engine keeps its own counter per creator and mixes it
253
+ * into every key it mints, which is why two identical creates from one account never collide.
254
+ *
255
+ * @param owner - The account whose nonce to read.
256
+ * @returns The nonce the account's next create will use.
148
257
  *
149
258
  * @example
150
- * import { createPublicClient, http } from 'arkiv'
151
- * import { braga } from 'arkiv/chains'
259
+ * import { createPublicClient } from "@arkiv-network/sdk"
260
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
261
+ * import { http } from "viem"
152
262
  *
153
263
  * const client = createPublicClient({
154
- * chain: braga,
264
+ * chain: cheesecake,
155
265
  * transport: http(),
156
266
  * })
157
- * const entityCount = await client.getEntityCount()
158
- * // entityCount = 0
267
+ * const nonce = await client.getEntityNonce("0xabc…")
268
+ * // 7n — the next entity this account creates is its eighth
159
269
  */
160
- getEntityCount: () => Promise<number>;
270
+ getEntityNonce: (owner: Address) => Promise<bigint>;
271
+ /**
272
+ * Works out the keys an account's next creates will be given, before sending them.
273
+ *
274
+ * The engine derives a key from the chain, the registry, the owner, the owner's nonce and a
275
+ * salt — everything but the nonce is known to the caller, and the nonce is read here. This is
276
+ * what lets a batch reference an entity it is about to mint.
277
+ *
278
+ * Each key arrives paired with the salt that mints it, because a create defaults to a *random*
279
+ * salt: a predicted key only holds if the create carries the salt it was predicted with. And the
280
+ * prediction holds only while nothing else from this owner is in flight — for a key you can rely
281
+ * on unconditionally, read it back from the create instead.
282
+ *
283
+ * A literal `count` comes back as a fixed-length tuple, so the pairs destructure into names.
284
+ *
285
+ * @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
286
+ * @returns One `{ key, salt }` pair per create, in batch order.
287
+ * {@link PredictEntityKeysReturnType}
288
+ *
289
+ * @example A batch whose second entity points at its first.
290
+ * import { key } from "@arkiv-network/sdk/attr"
291
+ *
292
+ * const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
293
+ * await wallet.executeBatch({
294
+ * creates: [
295
+ * { payload, contentType, expires, salt: parent.salt },
296
+ * {
297
+ * payload,
298
+ * contentType,
299
+ * expires,
300
+ * salt: child.salt,
301
+ * attributes: { parent: key(parent.key) },
302
+ * },
303
+ * ],
304
+ * })
305
+ */
306
+ predictEntityKeys: <const TCount extends number = number, const TSalts extends readonly SaltInput[] | undefined = undefined>(parameters: PredictEntityKeysParameters<TCount, TSalts>) => Promise<PredictEntityKeysReturnType<TCount, TSalts>>;
161
307
  /**
162
308
  * Returns the current block timing.
163
309
  * @returns The current block timing. {@link GetBlockTimingReturnType}
164
310
  *
165
311
  * @example
166
- * import { createPublicClient, http } from 'arkiv'
167
- * import { braga } from 'arkiv/chains'
312
+ * import { createPublicClient } from "@arkiv-network/sdk"
313
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
314
+ * import { http } from "viem"
168
315
  *
169
316
  * const client = createPublicClient({
170
- * chain: braga,
317
+ * chain: cheesecake,
171
318
  * transport: http(),
172
319
  * })
173
320
  * const blockTiming = await client.getBlockTiming()
@@ -177,297 +324,317 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
177
324
  * // blockDuration: 2, // in seconds
178
325
  * // }
179
326
  */
180
- getBlockTiming: () => Promise<{
181
- currentBlock: bigint;
182
- currentBlockTime: number;
183
- blockDuration: number;
184
- }>;
327
+ getBlockTiming: () => Promise<GetBlockTimingReturnType>;
185
328
  /**
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
329
+ * Watches entity events, calling the handlers you pass as they arrive.
330
+ *
331
+ * All five are decoded from logs — `onEntityCreated`, `onEntityPatched`, `onExpiryExtended`,
332
+ * `onOwnershipTransferred`, `onEntityDeleted` — and each carries the block, transaction and log
333
+ * index it came from, which is the order the operations were applied in. `onEvent` receives all
334
+ * of them, whatever their type.
335
+ *
336
+ * @param parameters - Handlers and options, all optional. {@link WatchEntityEventsParameters}
337
+ * @returns A function that stops the watcher.
191
338
  *
192
339
  * @example
193
- * import { createPublicClient, http } from 'arkiv'
194
- * import { braga } from 'arkiv/chains'
340
+ * import { createPublicClient } from "@arkiv-network/sdk"
341
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
342
+ * import { http } from "viem"
195
343
  *
196
344
  * const client = createPublicClient({
197
- * chain: braga,
345
+ * chain: cheesecake,
198
346
  * transport: http(),
199
347
  * })
200
- * const unsubscribe = await client.subscribeEntityEvents({
201
- * onError: (error) => console.error("subscribeEntityEvents error", error),
348
+ * const unwatch = client.watchEntityEvents({
349
+ * onEntityCreated: ({ entityKey, expiresAt }) => console.log(entityKey, "until", expiresAt),
350
+ * onError: (error) => console.error("watchEntityEvents error", error),
202
351
  * })
203
- * unsubscribe() // unsubscribe from the events
352
+ * unwatch() // stop watching
204
353
  */
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>;
354
+ watchEntityEvents: (parameters: WatchEntityEventsParameters) => () => void;
355
+ /**
356
+ * The read-only half of the advanced path: check on a transaction and decode its result with at
357
+ * most one RPC call per action — so a process that holds nothing but a transaction hash can
358
+ * follow it without a wallet. {@link PublicAdvancedActions}
359
+ *
360
+ * @example
361
+ * const { status } = await client.advanced.pingTransaction(txHash) // 1 eth_getTransactionReceipt
362
+ */
363
+ advanced: PublicAdvancedActions;
219
364
  };
220
365
  //#endregion
221
366
  //#region src/clients/createPublicClient.d.ts
222
367
  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>>>;
223
368
  /**
224
- * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
225
- *
226
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
369
+ * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/chains/introduction).
227
370
  *
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).
371
+ * A Public Client is an interface to the "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/)
372
+ * and the Arkiv JSON-RPC API — retrieving block numbers and transactions, reading from
373
+ * contracts, and querying entities — through {@link PublicArkivActions}.
229
374
  *
230
375
  * @param parameters - Configuration object for the public client (chain, transport, etc.)
231
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
376
+ * @returns An Arkiv Public Client. {@link PublicArkivClient}
232
377
  *
233
378
  * @example
234
- * import { createPublicClient, http } from 'arkiv'
235
- * import { braga } from 'arkiv/chains'
379
+ * import { createPublicClient } from "@arkiv-network/sdk"
380
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
381
+ * import { http } from "viem"
236
382
  *
237
383
  * const client = createPublicClient({
238
- * chain: braga,
384
+ * chain: cheesecake,
239
385
  * transport: http(),
240
386
  * })
241
387
  */
242
388
  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
389
  //#endregion
244
390
  //#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"> & {
391
+ 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
392
  /**
247
393
  * Creates a new entity.
248
394
  *
249
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/createEntity
250
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
395
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
251
396
  *
252
397
  * @param data - The entity creation parameters
253
398
  * @param txParams - Optional transaction parameters
254
- * @returns The created entity with transaction hash
399
+ * @returns The new entity's key, the transaction hash, and the block it is expected to
400
+ * expire at. {@link CreateEntityReturnType}
255
401
  *
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.
402
+ * @throws {InvalidExpiryError} If the expiry exceeds a protocol bound or would leave the
403
+ * entity dead on arrival.
404
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
405
+ * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
260
406
  *
261
407
  * @example
262
- * import { createPublicClient, http } from 'arkiv'
263
- * import { braga } from 'arkiv/chains'
408
+ * import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
409
+ * import { i32 } from "@arkiv-network/sdk/attr"
410
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
411
+ * import { http } from "viem"
412
+ * import { privateKeyToAccount } from "viem/accounts"
264
413
  *
265
- * const client = createPublicClient({
266
- * chain: braga,
414
+ * const client = createWalletClient({
415
+ * account: privateKeyToAccount("0x..."),
416
+ * chain: cheesecake,
267
417
  * transport: http(),
268
418
  * })
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,
419
+ * const { entityKey, txHash, expiresAt } = await client.createEntity({
420
+ * payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
421
+ * contentType: "application/json",
422
+ * attributes: { testKey: "testValue", level: i32(3) },
423
+ * expires: ExpirationTime.fromDays(30),
273
424
  * })
274
- * console.log("entityKey", entityKey)
275
- * console.log("txHash", txHash)
276
- * // {
277
- * // entityKey: "0x123",
278
- * // txHash: "0x123",
279
- * // }
280
425
  */
281
426
  createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
282
427
  /**
283
- * Updates the entity with the given key.
428
+ * Applies a patch to the entity with the given key: sets some fields, unsets others, and leaves
429
+ * everything it does not name alone.
284
430
  *
285
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
286
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
431
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
287
432
  *
288
- * @param data - The entity update parameters
433
+ * @param data - The entity key and the mutations to apply
289
434
  * @param txParams - Optional transaction parameters
290
- * @returns The updated entity with transaction hash
435
+ * @returns The patched entity's key and the transaction hash. {@link PatchEntityReturnType}
291
436
  *
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.
437
+ * @throws {EmptyPatchError} If the patch has nothing to apply.
438
+ * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.
439
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
440
+ * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
296
441
  *
297
442
  * @example
298
- * import { createWalletClient, http } from 'arkiv'
299
- * import { braga } from 'arkiv/chains'
443
+ * import { createWalletClient, jsonToPayload } from "@arkiv-network/sdk"
444
+ * import { i32 } from "@arkiv-network/sdk/attr"
445
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
446
+ * import { http } from "viem"
447
+ * import { privateKeyToAccount } from "viem/accounts"
300
448
  *
301
449
  * const client = createWalletClient({
302
- * chain: braga,
450
+ * account: privateKeyToAccount("0x..."),
451
+ * chain: cheesecake,
303
452
  * transport: http(),
304
453
  * })
454
+ * // Publish the entity: one attribute changes, one goes away, the payload is replaced.
455
+ * const { txHash } = await client.patchEntity({
456
+ * entityKey,
457
+ * set: { status: "published", revision: i32(2) },
458
+ * unset: ["draft"],
459
+ * payload: jsonToPayload({ title: "Hello" }),
460
+ * })
305
461
  */
306
- updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
462
+ patchEntity: (data: PatchEntityParameters, txParams?: TxParams) => Promise<PatchEntityReturnType>;
307
463
  /**
308
464
  * Deletes the entity with the given key.
309
465
  *
310
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
311
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
466
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
312
467
  *
313
468
  * @param data - The entity deletion parameters
314
469
  * @param txParams - Optional transaction parameters
315
- * @returns The deleted entity with transaction hash
470
+ * @returns The deleted entity's key and the transaction hash. {@link DeleteEntityReturnType}
316
471
  *
317
472
  * @example
318
- * import { createWalletClient, http } from 'arkiv'
319
- * import { braga } from 'arkiv/chains'
473
+ * import { createWalletClient } from "@arkiv-network/sdk"
474
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
475
+ * import { http } from "viem"
476
+ * import { privateKeyToAccount } from "viem/accounts"
320
477
  *
321
478
  * const client = createWalletClient({
322
- * chain: braga,
479
+ * account: privateKeyToAccount("0x..."),
480
+ * chain: cheesecake,
323
481
  * transport: http(),
324
482
  * })
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
- * // }
483
+ * // entityKey is the bytes32 key returned by createEntity.
484
+ * const { txHash } = await client.deleteEntity({ entityKey })
332
485
  */
333
486
  deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
334
487
  /**
335
- * Extends the entity with the given key.
488
+ * Sets a new expiry on the entity with the given key.
336
489
  *
337
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
338
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
490
+ * The new lifetime is resolved the same way a create's is: a duration counts from now rather
491
+ * than adding to what the entity has left, and `atBlock` / `atDate` pin an absolute deadline.
492
+ * The engine rejects an extension that would not move the expiry later.
339
493
  *
340
- * @param data - The entity update parameters
494
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
495
+ *
496
+ * @param data - The entity key and its new lifetime
341
497
  * @param txParams - Optional transaction parameters
342
- * @returns The updated entity with transaction hash
498
+ * @returns The entity's key, the transaction hash, and the block it is now expected to expire
499
+ * at. {@link ExtendEntityReturnType}
343
500
  *
344
- * @throws {InvalidExpirationError} If `expiresIn` is not a positive integer
345
- * that is a multiple of the block time (2 seconds).
501
+ * @throws {InvalidExpiryError} If the expiry is malformed, exceeds a protocol bound, or would
502
+ * leave the entity dead on arrival.
346
503
  *
347
504
  * @example
348
- * import { createWalletClient, http } from 'arkiv'
349
- * import { braga } from 'arkiv/chains'
505
+ * import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk"
506
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
507
+ * import { http } from "viem"
508
+ * import { privateKeyToAccount } from "viem/accounts"
350
509
  *
351
510
  * const client = createWalletClient({
352
- * chain: braga,
511
+ * account: privateKeyToAccount("0x..."),
512
+ * chain: cheesecake,
353
513
  * transport: http(),
354
514
  * })
355
- * const { entityKey, txHash } = await client.extendEntity("0x123", {
356
- * expiresIn: 1000,
515
+ * const { txHash, expiresAt } = await client.extendEntity({
516
+ * entityKey,
517
+ * expires: ExpirationTime.fromDays(30),
357
518
  * })
358
- * console.log("entityKey", entityKey)
359
- * console.log("txHash", txHash)
360
- * // {
361
- * // entityKey: "0x123",
362
- * // txHash: "0x123",
363
- * // }
364
519
  */
365
520
  extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
366
521
  /**
367
- * Changes the ownership of the entity with the given address.
522
+ * Hands the entity with the given key to a new owner.
368
523
  *
369
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
370
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
524
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
371
525
  *
372
526
  * @param data - The ownership change parameters
373
527
  * @param txParams - Optional transaction parameters
374
- * @returns The entity with updated ownership and transaction hash
528
+ * @returns The entity's key and the transaction hash. {@link ChangeOwnershipReturnType}
375
529
  */
376
530
  changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>;
377
531
  /**
378
- * Mutates the entities with the given keys.
532
+ * Applies a batch of entity operations — creates, patches, deletes, extensions and ownership
533
+ * transfers — in one transaction.
379
534
  *
380
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
381
- * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
535
+ * - JSON-RPC Methods: `eth_sendRawTransaction`
382
536
  *
383
- * @param data - The mutation parameters (creates, updates, deletes, extensions)
537
+ * Every operation lands in one transaction, so the whole batch applies or none of it does.
538
+ * At least one operation is required.
539
+ *
540
+ * @param data - The batch parameters (creates, patches, deletes, extensions, ownershipChanges)
384
541
  * @param txParams - Optional transaction parameters
385
- * @returns The mutation result with transaction hash
542
+ * @returns The transaction hash, plus the keys touched by each kind of operation.
543
+ * {@link ExecuteBatchReturnType}
386
544
  *
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.
545
+ * @throws {InvalidExpiryError} If an expiry exceeds a protocol bound or would leave the entity
546
+ * dead on arrival.
547
+ * @throws {InvalidValueError} If an attribute value does not fit the type it names.
391
548
  *
392
549
  * @example
393
- * import { createWalletClient, http } from 'arkiv'
394
- * import { braga } from 'arkiv/chains'
550
+ * import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
551
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
552
+ * import { http } from "viem"
553
+ * import { privateKeyToAccount } from "viem/accounts"
395
554
  *
396
555
  * const client = createWalletClient({
397
- * chain: braga,
556
+ * account: privateKeyToAccount("0x..."),
557
+ * chain: cheesecake,
398
558
  * transport: http(),
399
559
  * })
400
- * const { entityKey, txHash } = await client.mutateEntities({
560
+ * const { txHash, createdEntities } = await client.executeBatch({
401
561
  * 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",
562
+ * payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
563
+ * contentType: "application/json",
564
+ * attributes: { testKey: "testValue" },
565
+ * expires: ExpirationTime.fromDays(30),
414
566
  * }],
567
+ * patches: [{ entityKey: keyToRevise, set: { status: "archived" }, unset: ["draft"] }],
568
+ * deletes: [{ entityKey: staleKey }],
415
569
  * extensions: [{
416
- * entityKey: "0x1234",
417
- * expiresIn: 1000,
570
+ * entityKey: keyToKeepAlive,
571
+ * expires: ExpirationTime.atBlock(1_200_000n),
418
572
  * }],
573
+ * ownershipChanges: [{ entityKey: keyToHandOver, newOwner }],
419
574
  * })
420
- * console.log("entityKey", entityKey)
421
- * console.log("txHash", txHash)
422
- * // {
423
- * // entityKey: "0x123",
424
- * // txHash: "0x123",
425
- * // }
426
575
  */
427
- mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
576
+ executeBatch: (data: ExecuteBatchParameters, txParams?: TxParams) => Promise<ExecuteBatchReturnType>;
577
+ /**
578
+ * The advanced path: build, send, ping and read mutation results as separate steps, each
579
+ * costing the minimum number of RPC calls. Use it when you are optimising your RPC budget;
580
+ * the everyday actions above remain the right default. {@link WalletAdvancedActions}
581
+ *
582
+ * @example
583
+ * const { txHash } = await client.advanced.sendMutation({ creates: [entity] }) // no waiting
584
+ * // ... later, one eth_getTransactionReceipt on your own schedule:
585
+ * const result = await client.advanced.getMutationResult(txHash)
586
+ * if (result.status === "success") console.log(result.createdEntities)
587
+ */
588
+ advanced: WalletAdvancedActions;
428
589
  };
429
590
  //#endregion
430
591
  //#region src/clients/createWalletClient.d.ts
431
592
  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
593
  /**
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).
434
- *
435
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
594
+ * Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured
595
+ * for a [Chain](https://viem.sh/docs/chains/introduction) and an account.
436
596
  *
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).
597
+ * A Wallet Client signs and sends transactions, so it carries an `account` and exposes everything
598
+ * that mutates state — `createEntity`, `patchEntity`, `deleteEntity`, `extendEntity`,
599
+ * `changeOwnership` and `executeBatch` — on top of the read actions a Public Client has.
438
600
  *
439
601
  * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
440
- * @returns A Arkiv Wallet Client. {@link WalletArkivClient}
602
+ * @returns An Arkiv Wallet Client. {@link WalletArkivClient}
441
603
  *
442
604
  * @example
443
- * import { createPublicClient, http } from 'arkiv'
444
- * import { braga } from 'arkiv/chains'
605
+ * import { createWalletClient } from "@arkiv-network/sdk"
606
+ * import { cheesecake } from "@arkiv-network/sdk/chains"
607
+ * import { http } from "viem"
608
+ * import { privateKeyToAccount } from "viem/accounts"
445
609
  *
446
- * const client = createPublicClient({
447
- * chain: braga,
610
+ * const client = createWalletClient({
611
+ * chain: cheesecake,
448
612
  * transport: http(),
613
+ * account: privateKeyToAccount("0x..."),
449
614
  * })
450
615
  */
451
616
  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
617
  //#endregion
453
618
  //#region src/errors.d.ts
454
619
  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);
620
+ constructor(message: string, options?: {
621
+ cause?: unknown;
622
+ });
462
623
  }
463
624
  declare class NoMoreResultsError extends Error {
464
625
  constructor();
465
626
  }
466
- declare class NoCursorOrLimitError extends Error {
467
- constructor();
468
- }
469
627
  declare class NoEntityFoundError extends Error {
470
- constructor();
628
+ /** The key that matched nothing, when the lookup was by key. */
629
+ readonly entityKey: string | undefined;
630
+ constructor(entityKey?: string);
631
+ }
632
+ declare class EmptyPatchError extends Error {
633
+ readonly entityKey: string;
634
+ constructor(entityKey: string);
635
+ }
636
+ declare class InvalidContentTypeError extends Error {
637
+ constructor(contentType: string);
471
638
  }
472
639
  //#endregion
473
640
  //#region src/utils/chains.d.ts
@@ -479,5 +646,5 @@ declare class NoEntityFoundError extends Error {
479
646
  */
480
647
  declare function chainFromName(name: string): Chain;
481
648
  //#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 };
649
+ export { AddrValue, AnyArkivValue, type ArkivClient, ArkivRpcSchema, ArkivValue, AttributeInputs, AttributeSchema, Attributes, BoolValue, BuildMutationOptions, BuildMutationReturnType, 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, type EntityMutationOps, EntityPatchedEvent, ExecuteBatchParameters, ExecuteBatchReturnType, ExpirationTime, Expiry, ExpiryContext, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, GetMutationResultReturnType, 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, type MutationEvents, MutationResult, NO_SALT, NoEntityFoundError, NoMoreResultsError, NoRandomSourceError, Operation, OperationType, OwnershipTransferredEvent, PatchEntityParameters, PatchEntityReturnType, PingTransactionReturnType, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, type PublicAdvancedActions, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryReturnType, ResolvedCreationFlags, ResolvedExpiry, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, SaltInput, SendMutationOptions, SendMutationReturnType, StrValue, TooManyAttributesError, TxParams, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, UserTypeTag, ValueInput, type WalletAdvancedActions, type WalletArkivActions, type WalletArkivClient, WatchEntityEventsParameters, addr, bool, buildEntityOperations, buildMutation, bytes32, chainFromName, collectMutationEvents, createPublicClient, createWalletClient, dec, decFromUnits, decUnits, decodeCreationFlags, decodeMutationResult, encodeCreationFlags, getMutationResult, i32, isArkivValue, isValidAttributeName, jsonToPayload, key, mutationNeedsBlockNumber, pingTransaction, predictEntityKey, randomSalt, resolveExpiry, sendMutation, str, stringToPayload, toBlocks, toValue, u256, u64, validateAttributeName };
483
650
  //# sourceMappingURL=index.d.ts.map