@arkiv-network/sdk 0.7.0-dev.1 → 0.8.0-advanced.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +71 -16
  2. package/dist/actions/advanced/index.cjs +13 -0
  3. package/dist/actions/advanced/index.d.cts +8 -0
  4. package/dist/actions/advanced/index.d.ts +9 -0
  5. package/dist/actions/advanced/index.js +9 -0
  6. package/dist/advanced-8ZPTmmaN.js +598 -0
  7. package/dist/advanced-8ZPTmmaN.js.map +1 -0
  8. package/dist/advanced-fPImL6lW.cjs +656 -0
  9. package/dist/arkivTransactions-D74gERHG.d.cts +571 -0
  10. package/dist/arkivTransactions-D74gERHG.d.cts.map +1 -0
  11. package/dist/arkivTransactions-NtGD6uk5.d.ts +571 -0
  12. package/dist/arkivTransactions-NtGD6uk5.d.ts.map +1 -0
  13. package/dist/attr/index.cjs +35 -0
  14. package/dist/attr/index.d.cts +2 -0
  15. package/dist/attr/index.d.ts +3 -0
  16. package/dist/attr/index.js +4 -0
  17. package/dist/attributes-BhY5DwJp.js +809 -0
  18. package/dist/attributes-BhY5DwJp.js.map +1 -0
  19. package/dist/attributes-Df9IsCVs.cjs +1029 -0
  20. package/dist/chains/index.cjs +2 -3
  21. package/dist/chains/index.d.cts +22 -60
  22. package/dist/chains/index.d.cts.map +1 -1
  23. package/dist/chains/index.d.ts +22 -60
  24. package/dist/chains/index.d.ts.map +1 -1
  25. package/dist/chains/index.js +2 -2
  26. package/dist/chains-BJrZs6sG.js +57 -0
  27. package/dist/chains-BJrZs6sG.js.map +1 -0
  28. package/dist/chains-BYRTTipa.cjs +73 -0
  29. package/dist/codec-Car3KkFF.d.ts +102 -0
  30. package/dist/codec-Car3KkFF.d.ts.map +1 -0
  31. package/dist/entity/index.cjs +20 -0
  32. package/dist/entity/index.d.cts +4 -0
  33. package/dist/entity/index.d.ts +5 -0
  34. package/dist/entity/index.js +7 -0
  35. package/dist/entity-B00Li04j.cjs +71 -0
  36. package/dist/entity-B7G8q_Eo.cjs +0 -0
  37. package/dist/entity-BYQR1uoe.js +67 -0
  38. package/dist/entity-BYQR1uoe.js.map +1 -0
  39. package/dist/entity-CD_qFF2M.js +0 -0
  40. package/dist/errors-BVbjKVMN.cjs +56 -0
  41. package/dist/errors-LTe7bOYS.js +33 -0
  42. package/dist/errors-LTe7bOYS.js.map +1 -0
  43. package/dist/expiry-BELY2Kpw.cjs +135 -0
  44. package/dist/expiry-BjpxZZQU.js +95 -0
  45. package/dist/expiry-BjpxZZQU.js.map +1 -0
  46. package/dist/expiry-DRV29F1r.d.cts +79 -0
  47. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  48. package/dist/expiry-nDbCgZX4.d.ts +79 -0
  49. package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
  50. package/dist/flags-5dTNRnow.d.ts +41 -0
  51. package/dist/flags-5dTNRnow.d.ts.map +1 -0
  52. package/dist/flags-CRjPpoh3.d.cts +41 -0
  53. package/dist/flags-CRjPpoh3.d.cts.map +1 -0
  54. package/dist/flags-DFBs2J94.js +33 -0
  55. package/dist/flags-DFBs2J94.js.map +1 -0
  56. package/dist/flags-kr276q6i.cjs +43 -0
  57. package/dist/index-B5j76711.d.ts +184 -0
  58. package/dist/index-B5j76711.d.ts.map +1 -0
  59. package/dist/index-BF7Mq9Is.d.cts +280 -0
  60. package/dist/index-BF7Mq9Is.d.cts.map +1 -0
  61. package/dist/index-CA4V7Pdh.d.cts +167 -0
  62. package/dist/index-CA4V7Pdh.d.cts.map +1 -0
  63. package/dist/index-CV5zCdpa.d.cts +417 -0
  64. package/dist/index-CV5zCdpa.d.cts.map +1 -0
  65. package/dist/index-DHDud2hC.d.ts +280 -0
  66. package/dist/index-DHDud2hC.d.ts.map +1 -0
  67. package/dist/index-DvYvrkdk.d.ts +320 -0
  68. package/dist/index-DvYvrkdk.d.ts.map +1 -0
  69. package/dist/index-EeUO0nnJ.d.cts +184 -0
  70. package/dist/index-EeUO0nnJ.d.cts.map +1 -0
  71. package/dist/index-fX_XyqLp.d.ts +167 -0
  72. package/dist/index-fX_XyqLp.d.ts.map +1 -0
  73. package/dist/index.cjs +411 -405
  74. package/dist/index.d.cts +360 -209
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +361 -209
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +342 -387
  79. package/dist/index.js.map +1 -1
  80. package/dist/key-D1Bh7MF0.js +70 -0
  81. package/dist/key-D1Bh7MF0.js.map +1 -0
  82. package/dist/key-WKhXnXuU.cjs +98 -0
  83. package/dist/logger-CVpvU8ik.js +153 -0
  84. package/dist/logger-CVpvU8ik.js.map +1 -0
  85. package/dist/logger-Cr15lPAQ.cjs +188 -0
  86. package/dist/payload-BNoud2KZ.d.cts +94 -0
  87. package/dist/payload-BNoud2KZ.d.cts.map +1 -0
  88. package/dist/payload-Bz6651ax.js +67 -0
  89. package/dist/payload-Bz6651ax.js.map +1 -0
  90. package/dist/payload-CcUj85ys.d.ts +94 -0
  91. package/dist/payload-CcUj85ys.d.ts.map +1 -0
  92. package/dist/payload-KC14SDlN.cjs +83 -0
  93. package/dist/query/index.cjs +26 -150
  94. package/dist/query/index.d.cts +5 -3
  95. package/dist/query/index.d.ts +6 -3
  96. package/dist/query/index.js +8 -138
  97. package/dist/queryBuilder-DM6AWCBa.js +820 -0
  98. package/dist/queryBuilder-DM6AWCBa.js.map +1 -0
  99. package/dist/queryBuilder-DbUMEZln.cjs +944 -0
  100. package/dist/selection-C4UhsMOO.d.ts +434 -0
  101. package/dist/selection-C4UhsMOO.d.ts.map +1 -0
  102. package/dist/selection-DPg0uyJf.d.cts +433 -0
  103. package/dist/selection-DPg0uyJf.d.cts.map +1 -0
  104. package/dist/types/index.cjs +3 -3
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +3 -3
  108. package/dist/types-Bu_ZwMbZ.js +0 -0
  109. package/dist/types-NRqymi6S.cjs +0 -0
  110. package/dist/utils/index.cjs +4 -17
  111. package/dist/utils/index.d.cts +3 -17
  112. package/dist/utils/index.d.ts +3 -17
  113. package/dist/utils/index.js +4 -18
  114. package/package.json +26 -5
  115. package/src/actions/advanced/advanced.test.ts +258 -0
  116. package/src/actions/advanced/buildMutation.ts +104 -0
  117. package/src/actions/advanced/getMutationResult.ts +112 -0
  118. package/src/actions/advanced/index.ts +21 -0
  119. package/src/actions/advanced/pingTransaction.ts +43 -0
  120. package/src/actions/advanced/sendMutation.ts +59 -0
  121. package/src/actions/public/getEntity.ts +27 -43
  122. package/src/actions/public/getEntityNonce.ts +30 -0
  123. package/src/actions/public/predictEntityKeys.test.ts +143 -0
  124. package/src/actions/public/predictEntityKeys.ts +138 -0
  125. package/src/actions/public/query.ts +35 -67
  126. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  127. package/src/actions/public/watchEntityEvents.ts +225 -0
  128. package/src/actions/wallet/changeOwnership.ts +2 -2
  129. package/src/actions/wallet/createEntity.ts +99 -24
  130. package/src/actions/wallet/extendEntity.ts +37 -13
  131. package/src/actions/wallet/mutateEntities.test.ts +76 -0
  132. package/src/actions/wallet/mutateEntities.ts +16 -33
  133. package/src/actions/wallet/patchEntity.ts +90 -0
  134. package/src/attr/attributes.test.ts +120 -0
  135. package/src/attr/attributes.ts +190 -0
  136. package/src/attr/codec.test.ts +162 -0
  137. package/src/attr/codec.ts +220 -0
  138. package/src/attr/decimal.ts +86 -0
  139. package/src/attr/errors.ts +145 -0
  140. package/src/attr/index.ts +50 -0
  141. package/src/attr/names.ts +106 -0
  142. package/src/attr/types.ts +150 -0
  143. package/src/attr/values.test.ts +271 -0
  144. package/src/attr/values.ts +502 -0
  145. package/src/chains/cheesecake.ts +22 -0
  146. package/src/chains/index.ts +1 -2
  147. package/src/clients/createPublicClient.test.ts +3 -5
  148. package/src/clients/createPublicClient.ts +5 -4
  149. package/src/clients/createWalletClient.test.ts +2 -2
  150. package/src/clients/createWalletClient.ts +13 -7
  151. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  152. package/src/clients/decorators/arkivPublic.ts +172 -139
  153. package/src/clients/decorators/arkivWallet.ts +101 -94
  154. package/src/entity/create.test.ts +184 -0
  155. package/src/entity/errors.ts +38 -0
  156. package/src/entity/events.ts +16 -0
  157. package/src/entity/expiry.test.ts +195 -0
  158. package/src/entity/expiry.ts +181 -0
  159. package/src/entity/flags.ts +65 -0
  160. package/src/entity/index.ts +15 -0
  161. package/src/entity/key.ts +68 -0
  162. package/src/entity/operations.ts +134 -0
  163. package/src/entity/params.ts +15 -0
  164. package/src/errors.ts +26 -49
  165. package/src/index.ts +19 -0
  166. package/src/query/engine.ts +68 -137
  167. package/src/query/errors.ts +151 -0
  168. package/src/query/expression.test.ts +286 -0
  169. package/src/query/expression.ts +493 -0
  170. package/src/query/index.ts +40 -4
  171. package/src/query/injection.test.ts +151 -0
  172. package/src/query/queryBuilder.test.ts +342 -637
  173. package/src/query/queryBuilder.ts +133 -359
  174. package/src/query/queryResult.ts +54 -51
  175. package/src/query/selection.test.ts +48 -98
  176. package/src/query/selection.ts +77 -65
  177. package/src/types/entity.test.ts +44 -155
  178. package/src/types/entity.ts +60 -52
  179. package/src/types/events.ts +59 -16
  180. package/src/types/index.ts +20 -17
  181. package/src/types/rpcSchema.ts +69 -37
  182. package/src/utils/arkivTransactions.test.ts +600 -155
  183. package/src/utils/arkivTransactions.ts +350 -219
  184. package/src/utils/chains.test.ts +21 -24
  185. package/src/utils/compression.ts +1 -1
  186. package/src/utils/entities.test.ts +62 -0
  187. package/src/utils/entities.ts +109 -37
  188. package/src/utils/expirationTime.ts +114 -10
  189. package/src/utils/logger.ts +2 -2
  190. package/src/utils/revert.test.ts +99 -0
  191. package/src/utils/revert.ts +145 -0
  192. package/dist/chains-BifaY04V.cjs +0 -108
  193. package/dist/chains-CrtkVbBh.js +0 -86
  194. package/dist/chains-CrtkVbBh.js.map +0 -1
  195. package/dist/consts-Bz0LZQZY.js +0 -7
  196. package/dist/consts-Bz0LZQZY.js.map +0 -1
  197. package/dist/consts-CxT1-RXU.cjs +0 -18
  198. package/dist/entity-BhSXaB23.cjs +0 -81
  199. package/dist/entity-CN41IOrq.d.cts +0 -401
  200. package/dist/entity-CN41IOrq.d.cts.map +0 -1
  201. package/dist/entity-DGfVyB-a.js +0 -71
  202. package/dist/entity-DGfVyB-a.js.map +0 -1
  203. package/dist/entity-NnEVlePN.d.ts +0 -401
  204. package/dist/entity-NnEVlePN.d.ts.map +0 -1
  205. package/dist/index-ClkpS6s_.d.ts +0 -481
  206. package/dist/index-ClkpS6s_.d.ts.map +0 -1
  207. package/dist/index-w4qop0Pe.d.cts +0 -481
  208. package/dist/index-w4qop0Pe.d.cts.map +0 -1
  209. package/dist/payload-BpNUPOnY.js +0 -13
  210. package/dist/payload-BpNUPOnY.js.map +0 -1
  211. package/dist/payload-C2KHOUoj.d.ts +0 -6
  212. package/dist/payload-C2KHOUoj.d.ts.map +0 -1
  213. package/dist/payload-CJN8fTvX.d.cts +0 -6
  214. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  215. package/dist/payload-D8YLKcJj.cjs +0 -23
  216. package/dist/query/index.js.map +0 -1
  217. package/dist/queryBuilder-BE_XhLLa.js +0 -735
  218. package/dist/queryBuilder-BE_XhLLa.js.map +0 -1
  219. package/dist/queryBuilder-J37buGCi.cjs +0 -865
  220. package/dist/utils/index.d.cts.map +0 -1
  221. package/dist/utils/index.d.ts.map +0 -1
  222. package/dist/utils/index.js.map +0 -1
  223. package/src/actions/public/buildQuery.ts +0 -10
  224. package/src/actions/public/subscribeEntityEvents.ts +0 -93
  225. package/src/actions/wallet/updateEntity.ts +0 -59
  226. package/src/chains/braga.ts +0 -26
  227. package/src/chains/kaolin.ts +0 -29
  228. package/src/query/engine.test.ts +0 -571
  229. package/src/query/predicate.test.ts +0 -461
  230. package/src/query/predicate.ts +0 -144
  231. package/src/query/queryResult.test.ts +0 -270
  232. package/src/query/selectQueryBuilder.test.ts +0 -213
  233. package/src/types/attributes.ts +0 -28
  234. package/src/utils/validation.test.ts +0 -106
  235. package/src/utils/validation.ts +0 -80
  236. /package/dist/{types-Ci4BRClw.js → attr-DlmErkvR.cjs} +0 -0
  237. /package/dist/{types-a8gm_IaQ.cjs → attr-GcQKatub.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced-8ZPTmmaN.js","names":["logger","EXECUTE_ABI","EXECUTE_FUNCTION_ABI","operations: Operation[]","events: MutationEvents","logger","logger","logger"],"sources":["../src/entity/operations.ts","../src/utils/revert.ts","../src/utils/arkivTransactions.ts","../src/actions/advanced/buildMutation.ts","../src/actions/advanced/getMutationResult.ts","../src/actions/advanced/pingTransaction.ts","../src/actions/advanced/sendMutation.ts"],"sourcesContent":["import { type Address, encodeAbiParameters, type Hex, parseAbi, parseAbiParameters } from \"viem\"\nimport type { AbiAttribute } from \"../attr/codec\"\nimport type { EncodedExpiry } from \"./expiry\"\nimport { OperationType } from \"./params\"\n\n/**\n * The one external entry point. A transaction is an ordered, **atomic** batch of entity operations:\n * all of them apply or none do, operation *n+1* observes operation *n*'s effects, and each applied\n * operation emits one event.\n */\nexport const EXECUTE_ABI = parseAbi([\n \"function execute((uint8 operation, bytes operationData)[] ops) external returns (bytes32[] keys)\",\n])\n\n/**\n * The engine's one read-only view: an owner's entity-minting nonce, which is the input\n * {@link predictEntityKey} needs and the only part of the derivation the caller cannot know.\n *\n * It is a `view` on the same address `execute` is called on, so it answers over `eth_call` without\n * a transaction.\n */\nexport const ENTITY_NONCE_ABI = parseAbi([\n \"function entityNonce(address owner) external view returns (uint64)\",\n])\n\n/**\n * The shared attribute shape, used by `create` (attributes) and `patch` (mutations). Written out\n * once and reused by every payload that carries attributes.\n */\nconst ATTRIBUTE_TUPLE = \"(bytes32 name, uint8 typeId, bytes value)[]\"\n\n/**\n * The payload struct for each operation tag. `operationData` is `abi.encode` of the struct the tag\n * selects — a tagged union, so a new operation is additive rather than a change to `execute`.\n */\nconst PAYLOAD_PARAMS = {\n [OperationType.Create]: parseAbiParameters(\n `(uint128 salt, uint64 expiresAt, uint64 minLifetime, uint8 creationFlags, ${ATTRIBUTE_TUPLE} attributes)`,\n ),\n [OperationType.Patch]: parseAbiParameters(`(bytes32 entityKey, ${ATTRIBUTE_TUPLE} mutations)`),\n [OperationType.ExtendExpiry]: parseAbiParameters(\n \"(bytes32 entityKey, uint64 expiresAt, uint64 minLifetime)\",\n ),\n [OperationType.TransferOwnership]: parseAbiParameters(\"(bytes32 entityKey, address newOwner)\"),\n [OperationType.Delete]: parseAbiParameters(\"(bytes32 entityKey)\"),\n} as const\n\n/** One entry of the `execute` batch: the operation tag and its ABI-encoded payload. */\nexport type Operation = {\n operation: number\n operationData: Hex\n}\n\n/** Creates an entity. The key is derived by the engine; predict it with `predictEntityKey`. */\nexport function createOperation({\n salt,\n expiry,\n creationFlags,\n attributes,\n}: {\n salt: bigint\n expiry: EncodedExpiry\n creationFlags: number\n attributes: AbiAttribute[]\n}): Operation {\n return {\n operation: OperationType.Create,\n operationData: encodeAbiParameters(PAYLOAD_PARAMS[OperationType.Create], [\n {\n salt,\n expiresAt: expiry.expiresAt,\n minLifetime: expiry.minLifetime,\n creationFlags,\n attributes,\n },\n ]),\n }\n}\n\n/** Applies a set of mutations to an existing entity. Tombstones unset attributes. */\nexport function patchOperation({\n entityKey,\n mutations,\n}: {\n entityKey: Hex\n mutations: AbiAttribute[]\n}): Operation {\n return {\n operation: OperationType.Patch,\n operationData: encodeAbiParameters(PAYLOAD_PARAMS[OperationType.Patch], [\n { entityKey, mutations },\n ]),\n }\n}\n\n/** Pushes an entity's expiry further out. Extending is allowed; shortening reverts. */\nexport function extendExpiryOperation({\n entityKey,\n expiry,\n}: {\n entityKey: Hex\n expiry: EncodedExpiry\n}): Operation {\n return {\n operation: OperationType.ExtendExpiry,\n operationData: encodeAbiParameters(PAYLOAD_PARAMS[OperationType.ExtendExpiry], [\n { entityKey, expiresAt: expiry.expiresAt, minLifetime: expiry.minLifetime },\n ]),\n }\n}\n\n/** Hands an entity to a new owner. */\nexport function transferOwnershipOperation({\n entityKey,\n newOwner,\n}: {\n entityKey: Hex\n newOwner: Address\n}): Operation {\n return {\n operation: OperationType.TransferOwnership,\n operationData: encodeAbiParameters(PAYLOAD_PARAMS[OperationType.TransferOwnership], [\n { entityKey, newOwner },\n ]),\n }\n}\n\n/** Deletes an entity before its expiry. */\nexport function deleteOperation({ entityKey }: { entityKey: Hex }): Operation {\n return {\n operation: OperationType.Delete,\n operationData: encodeAbiParameters(PAYLOAD_PARAMS[OperationType.Delete], [{ entityKey }]),\n }\n}\n","import { BaseError, ContractFunctionRevertedError, type Hex, hexToString } from \"viem\"\n\n/**\n * Turns a decoded engine revert into a sentence that says what to change.\n *\n * viem decodes the error and then renders it positionally — `Ident32InvalidByte(uint256 position,\n * bytes1 value)` arrives as `(5, 0x41)`, which is the right data and no help at all. The engine's\n * errors carry enough to name the actual problem, so this spends the args rather than printing\n * them.\n *\n * @param error - Anything thrown by a write action.\n * @returns The explanation, or `undefined` if this was not a decodable engine revert — in which\n * case the caller should fall back to whatever the transport said.\n */\nexport function describeEntityRevert(error: unknown): string | undefined {\n if (!(error instanceof BaseError)) return undefined\n const reverted = error.walk((e) => e instanceof ContractFunctionRevertedError)\n if (!(reverted instanceof ContractFunctionRevertedError)) return undefined\n\n const name = reverted.data?.errorName\n if (name === undefined) return undefined\n const args = (reverted.data?.args ?? []) as readonly unknown[]\n\n return explain(name, args) ?? `the engine rejected the batch with ${name}`\n}\n\n/** The attribute-name charset, quoted the way an error message should read. */\nconst CHARSET = '\"A\"-\"Z\", \"a\"-\"z\", \"0\"-\"9\", \".\", \"-\" and \"_\", with a letter first'\n\nfunction explain(name: string, args: readonly unknown[]): string | undefined {\n switch (name) {\n // ── attribute names ──────────────────────────────────────────────────────\n case \"Ident32InvalidByte\": {\n const position = Number(args[0] ?? 0)\n const char = printable(String(args[1] ?? \"0x00\"))\n return (\n `an attribute name holds ${char} at byte ${position}, which is outside the ` +\n `name charset (${CHARSET})`\n )\n }\n case \"Ident32Empty\":\n return \"an attribute name is empty\"\n\n // ── the attribute list ───────────────────────────────────────────────────\n case \"SystemAttributeNotWritable\":\n return (\n `\"${identName(args[0])}\" is owned by the engine and cannot be written. Only $payload and ` +\n \"$contentType are yours to set\"\n )\n case \"TombstoneInCreate\":\n return (\n `a create cannot unset \"${identName(args[0])}\" — nothing exists yet, so leave the name ` +\n \"out instead\"\n )\n case \"TombstoneValueNotEmpty\":\n return `the tombstone for \"${identName(args[0])}\" carries a value; unsetting takes no value`\n case \"InvalidValueType\":\n return `\"${identName(args[0])}\" names type id ${String(args[1])}, which is not a known type`\n case \"AttributesNotSorted\":\n return \"attributes must be strictly ascending by name, which also makes each name unique\"\n case \"TooManyAttributes\":\n return `${String(args[0])} attributes exceeds the limit of ${String(args[1])}`\n case \"EmptyMutations\":\n return `the patch of ${short(args[0])} has no mutations, so it would do nothing`\n\n // ── entity state and authorisation ───────────────────────────────────────\n case \"EntityNotFound\":\n return `no entity ${short(args[0])} — it may have been deleted, or have expired`\n case \"EntityExpired\":\n return `entity ${short(args[0])} expired at block ${String(args[1])}`\n case \"NotOwner\":\n return `entity ${short(args[0])} is owned by ${String(args[2])}, not ${String(args[1])}`\n case \"ReadOnlyEntity\":\n return (\n `entity ${short(args[0])} was created readonly, so its contents can never change. Its ` +\n \"expiry can still be extended, and it can be transferred or deleted\"\n )\n case \"ReservedCreationFlags\":\n return (\n `creation flags 0b${Number(args[0] ?? 0)\n .toString(2)\n .padStart(8, \"0\")} set a reserved ` +\n \"bit; only readonly and permissionlessExtension are defined\"\n )\n\n // ── expiry ───────────────────────────────────────────────────────────────\n case \"ExpiryDeadOnArrival\":\n return (\n `the expiry resolves to block ${String(args[0])}, which is not after the current block ` +\n `${String(args[1])}`\n )\n case \"ExpiryNotExtended\":\n return (\n `entity ${short(args[0])} already expires at block ${String(args[2])}, so extending it ` +\n `to ${String(args[1])} would shorten its life`\n )\n\n // ── ownership ────────────────────────────────────────────────────────────\n case \"TransferToZeroAddress\":\n return `entity ${short(args[0])} cannot be transferred to the zero address`\n case \"TransferToSelf\":\n return `entity ${short(args[0])} is already owned by that account`\n\n // ── batch framing ────────────────────────────────────────────────────────\n case \"EmptyBatch\":\n return \"the batch has no operations\"\n case \"InvalidOpType\":\n return `operation tag ${String(args[0])} is not one the engine knows`\n case \"NonCanonicalOperationData\":\n return (\n `the payload for operation tag ${String(args[0])} is not its canonical encoding, so the ` +\n \"engine refused it rather than accept a second spelling of the same operation\"\n )\n\n default:\n return undefined\n }\n}\n\n/** A `bytes32` Ident32 cell as the name it holds — left-aligned, null-padded. */\nfunction identName(raw: unknown): string {\n if (typeof raw !== \"string\") return String(raw)\n try {\n // Cut at the first null rather than trimming with a regex: the padding is whatever follows\n // the name, so everything before it is the name and nothing after it is. Written as an escape\n // because a literal NUL byte in source is invisible to every reader after you.\n return hexToString(raw as Hex).split(\"\\u0000\")[0] ?? \"\"\n } catch {\n return raw\n }\n}\n\n/** An entity key, abbreviated */\nfunction short(raw: unknown): string {\n const text = String(raw)\n return text.length > 18 ? `${text.slice(0, 10)}…${text.slice(-6)}` : text\n}\n\n/** A `bytes1` as something readable: the character it is, plus the byte it was. */\nfunction printable(byte: string): string {\n const code = Number.parseInt(byte.replace(/^0x/, \"\"), 16)\n if (!Number.isFinite(code)) return `byte ${byte}`\n const char = String.fromCharCode(code)\n return code >= 0x21 && code <= 0x7e ? `\"${char}\" (${byte})` : `byte ${byte}`\n}\n","import {\n type Address,\n ContractFunctionExecutionError,\n ContractFunctionRevertedError,\n decodeEventLog,\n type Hash,\n type Hex,\n parseAbi,\n TransactionExecutionError,\n type TransactionReceipt,\n} from \"viem\"\nimport type { ChangeOwnershipParameters } from \"../actions/wallet/changeOwnership\"\nimport type { CreateEntityParameters } from \"../actions/wallet/createEntity\"\nimport type { DeleteEntityParameters } from \"../actions/wallet/deleteEntity\"\nimport type { ExtendEntityParameters } from \"../actions/wallet/extendEntity\"\nimport type { PatchEntityParameters } from \"../actions/wallet/patchEntity\"\n// Internal seam: the ABI encoders are not part of the package's public surface.\nimport { encodeAttributes, encodeMutations } from \"../attr/attributes\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { WalletArkivClient } from \"../clients/createWalletClient\"\nimport { ARKIV_ADDRESS } from \"../consts\"\nimport { ENTITY_EVENTS_ABI } from \"../entity/events\"\nimport { type Expiry, type ExpiryContext, resolveExpiry } from \"../entity/expiry\"\nimport { encodeCreationFlags } from \"../entity/flags\"\nimport { randomSalt, validateSalt } from \"../entity/key\"\nimport {\n createOperation,\n deleteOperation,\n EXECUTE_ABI as EXECUTE_FUNCTION_ABI,\n extendExpiryOperation,\n type Operation,\n patchOperation,\n transferOwnershipOperation,\n} from \"../entity/operations\"\nimport { EmptyPatchError, EntityMutationError, InvalidContentTypeError } from \"../errors\"\nimport type { TxParams } from \"../types\"\n\nimport { getLogger } from \"./logger\"\nimport { describeEntityRevert } from \"./revert\"\n\nconst logger = getLogger(\"utils:arkiv-transactions\")\n\n// RFC 2045 token chars, lowercase only. Rejects uppercase to prevent text/plain vs Text/Plain ambiguity.\nconst MIME_REGEX = /^[a-z][a-z0-9!#$&\\-^_]*\\/[a-z0-9][a-z0-9!#$&\\-^_.+]*$/\n\nfunction validateContentType(contentType: string): void {\n if (!MIME_REGEX.test(contentType)) {\n throw new InvalidContentTypeError(contentType)\n }\n}\n\nexport const ENTITY_ERRORS_ABI = parseAbi([\n // Batch and operation framing.\n \"error EmptyBatch()\",\n \"error InvalidOpType(uint8 operation)\",\n \"error NonCanonicalOperationData(uint8 operation)\",\n // The attribute triple list, structural.\n \"error AttributesNotSorted()\",\n \"error TooManyAttributes(uint256 count, uint256 maxCount)\",\n \"error EmptyMutations(bytes32 entityKey)\",\n \"error TombstoneInCreate(bytes32 name)\",\n \"error TombstoneValueNotEmpty(bytes32 name)\",\n \"error SystemAttributeNotWritable(bytes32 name)\",\n \"error InvalidValueType(bytes32 name, uint8 typeId)\",\n // Attribute-name validation. `Ident32` is a bytes32 on the wire.\n \"error Ident32Empty()\",\n \"error Ident32InvalidByte(uint256 position, bytes1 value)\",\n // Entity state and authorisation.\n \"error EntityNotFound(bytes32 entityKey)\",\n \"error EntityExpired(bytes32 entityKey, uint64 expiresAt)\",\n \"error NotOwner(bytes32 entityKey, address caller, address owner)\",\n \"error ReadOnlyEntity(bytes32 entityKey)\",\n \"error ReservedCreationFlags(uint8 creationFlags)\",\n // Expiry. The engine bounds an expiry only by the width of the field and by liveness — there is\n // no MAX_EXPIRES_AT or MAX_LIFETIME, so there is no error for exceeding one.\n \"error ExpiryDeadOnArrival(uint64 target, uint64 currentBlock)\",\n \"error ExpiryNotExtended(bytes32 entityKey, uint64 newExpiresAt, uint64 currentExpiresAt)\",\n // Ownership transfer.\n \"error TransferToZeroAddress(bytes32 entityKey)\",\n \"error TransferToSelf(bytes32 entityKey)\",\n])\n\nconst EXECUTE_ABI = [...EXECUTE_FUNCTION_ABI, ...ENTITY_ERRORS_ABI]\n\nexport type SendArkivTransactionResult = {\n receipt: TransactionReceipt\n /** The keys the engine minted for the entities this transaction created, in batch order. */\n createdEntityKeys: Hex[]\n /** The block each created entity expires at, as the engine recorded it, in the same order. */\n createdExpiries: bigint[]\n /** The block each extended entity now expires at, as the engine recorded it, in batch order. */\n extendedExpiries: bigint[]\n}\n\nexport async function sendArkivTransaction(\n client: ArkivClient,\n ops: EntityMutationOps,\n txParams?: TxParams,\n): Promise<SendArkivTransactionResult> {\n if (!client.account) throw new Error(\"Account required\")\n if (!client.chain) throw new Error(\"Chain required\")\n const walletClient = client as WalletArkivClient\n\n const { creates, extensions } = ops\n\n // The block height, to resolve any relative expiry — which both creates and extensions carry.\n // Skipped entirely for a batch with neither. Deliberately fetched even when every expiry is\n // absolute (where `mutationNeedsBlockNumber` would say no): the head is what makes the local\n // dead-on-arrival check in `resolveExpiry` work, and the everyday path buys that check — the\n // advanced path is where both are traded away for the saved call.\n const currentBlock =\n creates?.length || extensions?.length ? await walletClient.getBlockNumber() : 0n\n\n const operations = buildEntityOperations(ops, { currentBlock })\n\n logger(\"Sending execute with %d operations %o\", operations.length, operations)\n\n const txHash = await submitMutation(client, operations, txParams)\n\n try {\n const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash })\n logger(\"Tx receipt %o\", receipt)\n\n if (receipt.status === \"reverted\") {\n try {\n await walletClient.simulateContract({\n address: ARKIV_ADDRESS,\n abi: EXECUTE_ABI,\n functionName: \"execute\",\n args: [operations],\n account: client.account,\n chain: client.chain,\n })\n } catch (err) {\n const error = err as { shortMessage?: string; cause?: { details?: string } }\n const reason =\n describeEntityRevert(err) ??\n error.shortMessage ??\n error.cause?.details ??\n \"No reason provided by backend.\"\n throw new EntityMutationError(\n `Transaction ${receipt.transactionHash} reverted. Reason: ${reason}`,\n )\n }\n throw new EntityMutationError(\n `Transaction ${receipt.transactionHash} reverted. No reason provided by backend.`,\n )\n }\n\n return {\n receipt,\n ...readAppliedOperations(receipt, {\n creates: creates?.length ?? 0,\n extensions: extensions?.length ?? 0,\n }),\n }\n } catch (error) {\n throw asEntityMutationError(error)\n }\n}\n\n/**\n * Wraps whatever a write step threw into an {@link EntityMutationError} — engine terms when the\n * revert data decodes, the node's own message otherwise. An {@link EntityMutationError} passes\n * through unchanged, so wrapped steps compose without double-wrapping.\n */\nfunction asEntityMutationError(error: unknown): EntityMutationError {\n if (error instanceof EntityMutationError) return error\n\n const described = describeEntityRevert(error)\n if (described !== undefined) {\n return new EntityMutationError(`Transaction failed: ${described}`, { cause: error })\n }\n\n let message = \"Transaction failed\"\n if (error instanceof TransactionExecutionError) {\n message += `: ${error.details}`\n } else if (error instanceof ContractFunctionExecutionError) {\n logger(\"Contract function execution error data:\", error.shortMessage)\n if (error.cause instanceof ContractFunctionRevertedError) {\n message += `: ${error.cause.message}`\n } else {\n message += \": Execution error without revert data\"\n }\n } else if (error instanceof Error) {\n message += `: ${error.message}`\n }\n\n return new EntityMutationError(message, { cause: error })\n}\n\n/**\n * The keys and expiries the engine recorded, read back from the events the batch emitted.\n */\nfunction readAppliedOperations(\n receipt: TransactionReceipt,\n expected: { creates: number; extensions: number },\n): Omit<SendArkivTransactionResult, \"receipt\"> {\n const events = collectMutationEvents(receipt.logs)\n\n const createdEntityKeys = events.created.map((e) => e.entityKey)\n const createdExpiries = events.created.map((e) => e.expiresAt)\n const extendedExpiries = events.extended.map((e) => e.expiresAt)\n\n // Operations apply in batch order and emit one event each, and creates lead the batch — so these\n // arrive already aligned with the parameters they came from. A count that disagrees means that\n // assumption broke, and a misaligned array would hand back a key belonging to another entity.\n assertCount(receipt, \"create\", createdEntityKeys.length, expected.creates)\n assertCount(receipt, \"extension\", extendedExpiries.length, expected.extensions)\n\n return { createdEntityKeys, createdExpiries, extendedExpiries }\n}\n\n/** One log as an entity event, or `undefined` for anything this SDK has no name for. */\nfunction decodeEntityLog(log: TransactionReceipt[\"logs\"][number]) {\n try {\n return decodeEventLog({ abi: ENTITY_EVENTS_ABI, topics: log.topics, data: log.data })\n } catch {\n // An event a newer engine emits and this ABI does not describe. Not this function's business.\n return undefined\n }\n}\n\nfunction assertCount(receipt: TransactionReceipt, what: string, got: number, want: number): void {\n if (got === want) return\n // Deliberately explicit that the write succeeded: this throws *after* a successful transaction,\n // and a caller who reads it as a failure and retries would create the entities a second time.\n throw new EntityMutationError(\n `Transaction ${receipt.transactionHash} succeeded — do not retry it — but emitted ${got} ` +\n `${what} event(s) for ${want} ${what} operation(s). The batch was applied; the SDK cannot ` +\n `say which entity each operation produced, so read them back to find them.`,\n )\n}\n\n// ─────────────────────────────────────────────────────────────────────────────────────────────────\n// The seams the advanced path is built on.\n//\n// `sendArkivTransaction` above is the everyday path: encode, send, wait, decode, diagnose. These\n// are the same steps as separate pieces, so `actions/advanced` can spend exactly the RPC calls a\n// caller asks for and no more — without a second copy of the encoding or the event decoding.\n// ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** The five kinds of entity operation one Arkiv transaction can batch. */\nexport type EntityMutationOps = {\n /** The entities to create. */\n creates?: CreateEntityParameters[]\n /** The patches to apply. */\n patches?: PatchEntityParameters[]\n /** The entities to delete. */\n deletes?: DeleteEntityParameters[]\n /** The expiries to set. */\n extensions?: ExtendEntityParameters[]\n /** The ownership transfers to perform. */\n ownershipChanges?: ChangeOwnershipParameters[]\n}\n\n/**\n * Whether encoding the batch actually requires the chain head.\n *\n * Only a relative lifetime (`minLifetime > 0`) or a wall-clock deadline (a `Date`) is measured\n * from the current block. A purely absolute `atBlock(n)` expiry encodes the same bytes whatever\n * the head is, so a batch of those — or one with no expiries at all — needs no `eth_blockNumber`.\n */\nexport function mutationNeedsBlockNumber(ops: EntityMutationOps): boolean {\n return [...(ops.creates ?? []), ...(ops.extensions ?? [])].some((item) => {\n const expires = item.expires as Expiry | undefined\n // Malformed expiries are rejected by buildEntityOperations without needing the head.\n if (expires === undefined || typeof expires.minLifetime !== \"bigint\") return false\n return expires.minLifetime !== 0n || expires.expiresAt instanceof Date\n })\n}\n\n/**\n * Encodes a batch into the `execute` operations, in the order the engine applies them: creates,\n * patches, deletes, extensions, ownership transfers.\n *\n * Pure — every check here is local (content types, salts, expiry bounds, non-empty patches and a\n * non-empty batch), so the only chain input is `context.currentBlock`. Callers that carry no\n * relative expiry (see {@link mutationNeedsBlockNumber}) can pass `0n`, which disables the\n * dead-on-arrival pre-check and leaves that to the engine.\n */\nexport function buildEntityOperations(ops: EntityMutationOps, context: ExpiryContext): Operation[] {\n const { creates, patches, deletes, extensions, ownershipChanges } = ops\n\n const createOps = (creates ?? []).map((item) => {\n validateContentType(item.contentType)\n\n const salt = item.salt === undefined ? randomSalt() : validateSalt(item.salt)\n const expiry = resolveExpiry(item.expires, context)\n\n return createOperation({\n salt,\n expiry,\n creationFlags: encodeCreationFlags(item.flags),\n attributes: encodeAttributes(item.attributes, {\n payload: item.payload,\n contentType: item.contentType,\n }),\n })\n })\n\n const patchOps = (patches ?? []).map((item) => {\n if (item.contentType !== undefined) validateContentType(item.contentType)\n const mutations = encodeMutations(item)\n if (mutations.length === 0) {\n throw new EmptyPatchError(item.entityKey)\n }\n return patchOperation({ entityKey: item.entityKey, mutations })\n })\n\n // An extension resolves its expiry exactly as a create does — the engine applies the same\n // `max(expiresAt, currentBlock + minLifetime)` to both — so the same bounds are checked here\n // rather than left to a revert.\n const extendOps = (extensions ?? []).map((item) => {\n const expiry = resolveExpiry(item.expires, context)\n return extendExpiryOperation({ entityKey: item.entityKey, expiry })\n })\n\n const operations: Operation[] = [\n ...createOps,\n ...patchOps,\n ...(deletes ?? []).map((item) => deleteOperation({ entityKey: item.entityKey })),\n ...extendOps,\n ...(ownershipChanges ?? []).map((item) =>\n transferOwnershipOperation({\n entityKey: item.entityKey,\n newOwner: item.newOwner as Address,\n }),\n ),\n ]\n\n if (operations.length === 0) {\n throw new Error(\"No operations to perform\")\n }\n\n return operations\n}\n\n/**\n * Signs and sends an encoded batch, wrapping any node rejection in {@link EntityMutationError}.\n *\n * The submission half both write paths share: one `writeContract` — an `eth_sendRawTransaction`,\n * plus only the lookups viem needs for whatever `txParams` leaves out — with no waiting and no\n * polling. A rejection is reported in engine terms when the node returned decodable revert data,\n * and with the node's own message otherwise; either way the caller sees an\n * {@link EntityMutationError}.\n *\n * Internal seam shared with `actions/advanced/sendMutation`; not part of the package's public\n * surface.\n */\nexport async function submitMutation(\n client: ArkivClient,\n operations: Operation[],\n txParams?: TxParams,\n): Promise<Hash> {\n if (!client.account) throw new Error(\"Account required\")\n if (!client.chain) throw new Error(\"Chain required\")\n const walletClient = client as WalletArkivClient\n\n try {\n return await walletClient.writeContract({\n address: ARKIV_ADDRESS,\n abi: EXECUTE_ABI,\n functionName: \"execute\",\n args: [operations],\n account: client.account,\n chain: client.chain,\n ...txParams,\n })\n } catch (error) {\n throw asEntityMutationError(error)\n }\n}\n\n/** Everything the batch's events say happened, one entry per applied operation, per kind. */\nexport type MutationEvents = {\n created: { entityKey: Hex; owner: Address; expiresAt: bigint }[]\n patched: { entityKey: Hex; owner: Address }[]\n deleted: { entityKey: Hex; owner: Address }[]\n extended: { entityKey: Hex; owner: Address; expiresAt: bigint }[]\n ownershipTransferred: { entityKey: Hex; previousOwner: Address; newOwner: Address }[]\n}\n\n/**\n * Reads the entity events out of a receipt's logs, exactly as they were emitted.\n *\n * Lenient by design: it reports what the events say and nothing else — no counting against what\n * was asked for (the caller may not have the request at hand) and no error for a receipt with no\n * entity events at all. Logs from other contracts and events this SDK has no name for are skipped.\n */\nexport function collectMutationEvents(logs: TransactionReceipt[\"logs\"]): MutationEvents {\n const events: MutationEvents = {\n created: [],\n patched: [],\n deleted: [],\n extended: [],\n ownershipTransferred: [],\n }\n\n // `?? []` so a receipt without logs decodes to \"nothing happened\" rather than a TypeError.\n for (const log of logs ?? []) {\n // Only the operation address emits these, and a batch's transaction can carry logs from\n // anything else it touched.\n if (log.address.toLowerCase() !== ARKIV_ADDRESS.toLowerCase()) continue\n const decoded = decodeEntityLog(log)\n if (decoded === undefined) continue\n\n switch (decoded.eventName) {\n case \"EntityCreated\":\n events.created.push({\n entityKey: decoded.args.entityKey,\n owner: decoded.args.owner,\n expiresAt: decoded.args.expiresAt,\n })\n break\n case \"EntityPatched\":\n events.patched.push({ entityKey: decoded.args.entityKey, owner: decoded.args.owner })\n break\n case \"EntityDeleted\":\n events.deleted.push({ entityKey: decoded.args.entityKey, owner: decoded.args.owner })\n break\n case \"ExpiryExtended\":\n events.extended.push({\n entityKey: decoded.args.entityKey,\n owner: decoded.args.owner,\n expiresAt: decoded.args.expiresAt,\n })\n break\n case \"OwnershipTransferred\":\n events.ownershipTransferred.push({\n entityKey: decoded.args.entityKey,\n previousOwner: decoded.args.previousOwner,\n newOwner: decoded.args.newOwner,\n })\n break\n }\n }\n\n return events\n}\n","import { type Address, encodeFunctionData, type Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { PublicArkivClient } from \"../../clients/createPublicClient\"\nimport { ARKIV_ADDRESS } from \"../../consts\"\nimport { EXECUTE_ABI, type Operation } from \"../../entity/operations\"\nimport {\n buildEntityOperations,\n type EntityMutationOps,\n mutationNeedsBlockNumber,\n} from \"../../utils/arkivTransactions\"\nimport { getLogger } from \"../../utils/logger\"\n\nconst logger = getLogger(\"actions:advanced:build-mutation\")\n\n/** Options for the advanced-path builders ({@link buildMutation}, {@link sendMutation}). */\nexport type BuildMutationOptions = {\n /**\n * The chain head to resolve relative expiries against.\n *\n * Pass a block number you already hold — from a previous call, `getBlockTiming()`, or your own\n * tracking — and the build spends no RPC call at all. Without it, one `eth_blockNumber` is made,\n * and only when the batch actually needs the head (a relative lifetime or a `Date` deadline);\n * purely absolute `atBlock(n)` expiries never trigger it.\n *\n * Supplying it also buys back a check: absolute expiries are validated against it, so an\n * `atBlock(n)` already in the past throws {@link InvalidExpiryError} locally instead of\n * reverting on-chain. When the head is neither supplied nor fetched, that dead-on-arrival\n * check is skipped — the one local validation of the everyday path this path trades away.\n */\n currentBlock?: bigint\n}\n\n/** What {@link buildMutation} hands back: the batch in every form a sender might want. */\nexport type BuildMutationReturnType = {\n /** The encoded batch, in engine order, for `writeContract`-style sends. */\n operations: Operation[]\n /** The Arkiv engine address the transaction must be sent to. */\n to: Address\n /**\n * The full `execute(operations)` calldata. Sign a transaction carrying it offline (with your own\n * nonce, gas and fees) and the whole mutation costs exactly one `eth_sendRawTransaction`.\n */\n data: Hex\n /**\n * How many operations of each kind went into the batch — which is how many events of each kind a\n * successful transaction emits, in batch order, for cross-checking a decoded result.\n */\n expected: {\n creates: number\n patches: number\n deletes: number\n extensions: number\n ownershipChanges: number\n }\n}\n\n/**\n * Encodes a mutation batch without sending anything.\n *\n * This is the first step of the advanced path: it performs only local validation and encoding, so\n * it costs **zero RPC calls** when `options.currentBlock` is provided (or no expiry is relative),\n * and at most one `eth_blockNumber` otherwise. Send the result however you like: pass `operations`\n * to `writeContract`, or sign `{ to, data }` offline and push it with `eth_sendRawTransaction`.\n *\n * One check rides on knowing the head: an absolute `atBlock(n)` already in the past is rejected\n * locally only when the head is supplied or was fetched anyway. With neither, a dead-on-arrival\n * expiry encodes cleanly and the engine reverts it on-chain — see\n * {@link BuildMutationOptions.currentBlock}.\n *\n * @throws {InvalidExpiryError} If an expiry exceeds a protocol bound.\n * @throws {InvalidValueError} If an attribute value does not fit the type it names.\n * @throws {EmptyPatchError} If a patch has nothing to apply.\n */\nexport async function buildMutation(\n client: ArkivClient,\n data: EntityMutationOps,\n options: BuildMutationOptions = {},\n): Promise<BuildMutationReturnType> {\n // The head is fetched only when an expiry is actually measured from it and the caller did not\n // supply one — the advanced path never spends an RPC call it can avoid.\n const currentBlock =\n options.currentBlock ??\n (mutationNeedsBlockNumber(data)\n ? // Every SDK-built client carries viem's `publicActions`; `PublicArkivClient` is the type\n // that says so, the same narrowing `sendArkivTransaction` does to `WalletArkivClient`.\n await (client as PublicArkivClient).getBlockNumber()\n : 0n)\n\n const operations = buildEntityOperations(data, { currentBlock })\n logger(\"Built %d operations at block %d\", operations.length, currentBlock)\n\n return {\n operations,\n to: ARKIV_ADDRESS,\n data: encodeFunctionData({ abi: EXECUTE_ABI, functionName: \"execute\", args: [operations] }),\n expected: {\n creates: data.creates?.length ?? 0,\n patches: data.patches?.length ?? 0,\n deletes: data.deletes?.length ?? 0,\n extensions: data.extensions?.length ?? 0,\n ownershipChanges: data.ownershipChanges?.length ?? 0,\n },\n }\n}\n","import { type Hash, type Hex, type TransactionReceipt, TransactionReceiptNotFoundError } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { PublicArkivClient } from \"../../clients/createPublicClient\"\nimport { collectMutationEvents } from \"../../utils/arkivTransactions\"\nimport { getLogger } from \"../../utils/logger\"\n\nconst logger = getLogger(\"actions:advanced:get-mutation-result\")\n\n/**\n * A mined mutation, decoded from its receipt alone.\n *\n * Everything here comes out of the events the batch emitted, so no request context is needed to\n * read it — a process that holds nothing but the transaction hash gets the full picture. Arrays\n * are in batch order, which is the order the operations were applied in.\n */\nexport type MutationResult = {\n /** `success` means the whole batch applied; `reverted` means none of it did (arrays are empty). */\n status: \"success\" | \"reverted\"\n /** The transaction hash. */\n txHash: Hash\n /** The block the transaction landed in. */\n blockNumber: bigint\n /** The keys the engine minted for the created entities, in batch order. */\n createdEntities: Hex[]\n /** The block each created entity expires at, as the engine recorded it, in the same order. */\n createdExpiries: bigint[]\n /** The keys of the patched entities. */\n patchedEntities: Hex[]\n /** The keys of the deleted entities. */\n deletedEntities: Hex[]\n /** The keys of the extended entities. */\n extendedEntities: Hex[]\n /** The block each extended entity now expires at, in the same order. */\n extendedExpiries: bigint[]\n /** The keys of the entities handed to a new owner. */\n ownershipChanges: Hex[]\n /** The raw receipt, so nothing the chain said is lost. */\n receipt: TransactionReceipt\n}\n\n/** Return type for {@link getMutationResult}: the decoded result, or still pending. */\nexport type GetMutationResultReturnType = MutationResult | { status: \"pending\" }\n\n/**\n * Decodes a receipt you already hold into a {@link MutationResult}. **Zero RPC calls.**\n *\n * The pure tail of the advanced path: if a receipt reached you some other way — your own\n * `waitForTransactionReceipt`, a webhook, a block watcher — this turns it into entity keys and\n * expiries without touching the network. Lenient by design: it reports what the events say,\n * without counting them against a request it never saw.\n */\nexport function decodeMutationResult(receipt: TransactionReceipt): MutationResult {\n const events = collectMutationEvents(receipt.logs)\n return {\n status: receipt.status,\n txHash: receipt.transactionHash,\n blockNumber: receipt.blockNumber,\n createdEntities: events.created.map((e) => e.entityKey),\n createdExpiries: events.created.map((e) => e.expiresAt),\n patchedEntities: events.patched.map((e) => e.entityKey),\n deletedEntities: events.deleted.map((e) => e.entityKey),\n extendedEntities: events.extended.map((e) => e.entityKey),\n extendedExpiries: events.extended.map((e) => e.expiresAt),\n ownershipChanges: events.ownershipTransferred.map((e) => e.entityKey),\n receipt,\n }\n}\n\n/**\n * Fetches a transaction's receipt — once — and decodes what the mutation did.\n *\n * Exactly one `eth_getTransactionReceipt`, like `pingTransaction`, but the answer carries the\n * decoded entity events as well: created keys, recorded expiries, and the keys of everything\n * patched, deleted, extended or handed over. A transaction that is not mined yet comes back as\n * `{ status: \"pending\" }` — check `status` before reading the rest.\n *\n * No revert diagnosis is run: a `reverted` result reports the fact and the raw receipt, and\n * spending a `simulateContract` on the why is your call, not the SDK's.\n */\nexport async function getMutationResult(\n client: ArkivClient,\n txHash: Hash,\n): Promise<GetMutationResultReturnType> {\n const receipt = await fetchReceipt(client, txHash)\n if (receipt === undefined) {\n logger(\"Tx %s still pending\", txHash)\n return { status: \"pending\" }\n }\n return decodeMutationResult(receipt)\n}\n\n/**\n * One `eth_getTransactionReceipt`, with \"not there yet\" as a value instead of an exception.\n *\n * Internal seam shared with `pingTransaction`; not part of the package's public surface.\n */\nexport async function fetchReceipt(\n client: ArkivClient,\n txHash: Hash,\n): Promise<TransactionReceipt | undefined> {\n // The one action this needs is on every SDK-built client — both factories extend viem's\n // `publicActions` — and `PublicArkivClient` is the type that says so, the same way\n // `sendArkivTransaction` narrows to `WalletArkivClient`.\n const reader = client as PublicArkivClient\n try {\n return await reader.getTransactionReceipt({ hash: txHash })\n } catch (error) {\n // viem models an unmined transaction as a throw; the advanced path models it as a state.\n if (error instanceof TransactionReceiptNotFoundError) return undefined\n throw error\n }\n}\n","import type { Hash } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport { getLogger } from \"../../utils/logger\"\nimport { fetchReceipt } from \"./getMutationResult\"\n\nconst logger = getLogger(\"actions:advanced:ping-transaction\")\n\n/** Return type for {@link pingTransaction}. */\nexport type PingTransactionReturnType =\n | {\n /** Not mined yet (or unknown to this node). Ping again later. */\n status: \"pending\"\n blockNumber?: undefined\n }\n | {\n /** Mined. `success` means the whole batch applied; `reverted` means none of it did. */\n status: \"success\" | \"reverted\"\n /** The block the transaction landed in. */\n blockNumber: bigint\n }\n\n/**\n * Asks the chain — once — whether a transaction has landed.\n *\n * Exactly one `eth_getTransactionReceipt`, never a poll: a transaction that is not mined yet comes\n * back as `{ status: \"pending\" }` rather than being waited on. This is the \"ping\" of the advanced\n * path — you own the schedule, the SDK owns nothing.\n *\n * When it reports `success` and you need the created keys or recorded expiries, spend the next\n * call on `getMutationResult` — or none at all, if you predicted the keys up front with\n * `predictEntityKeys`.\n */\nexport async function pingTransaction(\n client: ArkivClient,\n txHash: Hash,\n): Promise<PingTransactionReturnType> {\n const receipt = await fetchReceipt(client, txHash)\n if (receipt === undefined) {\n logger(\"Tx %s still pending\", txHash)\n return { status: \"pending\" }\n }\n return { status: receipt.status, blockNumber: receipt.blockNumber }\n}\n","import type { Hash } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { type EntityMutationOps, submitMutation } from \"../../utils/arkivTransactions\"\nimport { getLogger } from \"../../utils/logger\"\nimport {\n type BuildMutationOptions,\n type BuildMutationReturnType,\n buildMutation,\n} from \"./buildMutation\"\n\nconst logger = getLogger(\"actions:advanced:send-mutation\")\n\n/** Options for {@link sendMutation}. */\nexport type SendMutationOptions = BuildMutationOptions & {\n /**\n * Transaction parameters. Supply `nonce`, `gas` and the fee fields and viem has nothing left to\n * look up — the send collapses to a single `eth_sendRawTransaction`.\n */\n txParams?: TxParams\n}\n\n/** Return type for {@link sendMutation}. */\nexport type SendMutationReturnType = {\n /** The transaction hash. Poll it with `pingTransaction` / fetch it with `getMutationResult`. */\n txHash: Hash\n /** The per-kind operation counts of the batch that was sent, for cross-checking the result. */\n expected: BuildMutationReturnType[\"expected\"]\n}\n\n/**\n * Signs and sends a mutation batch, returning as soon as the transaction is submitted.\n *\n * The fire-and-forget half of the advanced path. Unlike `mutateEntities`, this does **not** wait\n * for a receipt, does not poll, and runs no revert diagnosis — it spends only what submitting\n * costs. With `options.currentBlock` and full `txParams` (nonce, gas, fees) that is exactly one\n * RPC call; each omitted piece adds only the lookup viem needs to fill it.\n *\n * Follow up separately, on your own schedule:\n * - `pingTransaction(txHash)` — one `eth_getTransactionReceipt`, tells you pending/success/reverted.\n * - `getMutationResult(txHash)` — the same single call, plus the decoded entity keys and expiries.\n *\n * @throws {EntityMutationError} If the node rejects the submission (the batch never made it into\n * the mempool) — in engine terms when the rejection decodes, with the node's message otherwise.\n * Anything after that — inclusion, success — is yours to check.\n */\nexport async function sendMutation(\n client: ArkivClient,\n data: EntityMutationOps,\n options: SendMutationOptions = {},\n): Promise<SendMutationReturnType> {\n const { operations, expected } = await buildMutation(client, data, options)\n\n logger(\"Sending execute with %d operations (no wait)\", operations.length)\n\n const txHash = await submitMutation(client, operations, options.txParams)\n\n return { txHash, expected }\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,MAAa,cAAc,SAAS,CAClC,mGACD,CAAC;;;;;;;;AASF,MAAa,mBAAmB,SAAS,CACvC,qEACD,CAAC;;;;;AAMF,MAAM,kBAAkB;;;;;AAMxB,MAAM,iBAAiB;EACpB,cAAc,SAAS,mBACtB,6EAA6E,gBAAgB,cAC9F;EACA,cAAc,QAAQ,mBAAmB,uBAAuB,gBAAgB,aAAa;EAC7F,cAAc,eAAe,mBAC5B,4DACD;EACA,cAAc,oBAAoB,mBAAmB,wCAAwC;EAC7F,cAAc,SAAS,mBAAmB,sBAAsB;CAClE;;AASD,SAAgB,gBAAgB,EAC9B,MACA,QACA,eACA,cAMY;AACZ,QAAO;EACL,WAAW,cAAc;EACzB,eAAe,oBAAoB,eAAe,cAAc,SAAS,CACvE;GACE;GACA,WAAW,OAAO;GAClB,aAAa,OAAO;GACpB;GACA;GACD,CACF,CAAC;EACH;;;AAIH,SAAgB,eAAe,EAC7B,WACA,aAIY;AACZ,QAAO;EACL,WAAW,cAAc;EACzB,eAAe,oBAAoB,eAAe,cAAc,QAAQ,CACtE;GAAE;GAAW;GAAW,CACzB,CAAC;EACH;;;AAIH,SAAgB,sBAAsB,EACpC,WACA,UAIY;AACZ,QAAO;EACL,WAAW,cAAc;EACzB,eAAe,oBAAoB,eAAe,cAAc,eAAe,CAC7E;GAAE;GAAW,WAAW,OAAO;GAAW,aAAa,OAAO;GAAa,CAC5E,CAAC;EACH;;;AAIH,SAAgB,2BAA2B,EACzC,WACA,YAIY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