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