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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +0 -42
  2. package/dist/attr/index.cjs +33 -34
  3. package/dist/attr/index.d.cts +1 -1
  4. package/dist/attr/index.d.ts +1 -2
  5. package/dist/attr/index.js +1 -2
  6. package/dist/{attributes-Df9IsCVs.cjs → attr-BXTkpnoc.cjs} +13 -3
  7. package/dist/{attributes-BhY5DwJp.js → attr-tmyREHtw.js} +14 -4
  8. package/dist/attr-tmyREHtw.js.map +1 -0
  9. package/dist/chains/index.cjs +1 -1
  10. package/dist/chains/index.d.cts +3 -0
  11. package/dist/chains/index.d.cts.map +1 -1
  12. package/dist/chains/index.d.ts +3 -0
  13. package/dist/chains/index.d.ts.map +1 -1
  14. package/dist/chains/index.js +1 -1
  15. package/dist/{chains-BYRTTipa.cjs → chains-BfNQliHU.cjs} +3 -0
  16. package/dist/{chains-BJrZs6sG.js → chains-Du8tql7I.js} +4 -1
  17. package/dist/chains-Du8tql7I.js.map +1 -0
  18. package/dist/{arkivTransactions-NtGD6uk5.d.ts → changeOwnership-B0ar96ub.d.ts} +74 -123
  19. package/dist/changeOwnership-B0ar96ub.d.ts.map +1 -0
  20. package/dist/{arkivTransactions-D74gERHG.d.cts → changeOwnership-BofkLnXJ.d.cts} +74 -123
  21. package/dist/changeOwnership-BofkLnXJ.d.cts.map +1 -0
  22. package/dist/entity/index.cjs +9 -9
  23. package/dist/entity/index.d.cts +3 -3
  24. package/dist/entity/index.d.ts +4 -5
  25. package/dist/entity/index.js +5 -6
  26. package/dist/{entity-BYQR1uoe.js → entity-BIp_df9u.js} +1 -1
  27. package/dist/{entity-BYQR1uoe.js.map → entity-BIp_df9u.js.map} +1 -1
  28. package/dist/{key-D1Bh7MF0.js → entity-CniBgBSd.js} +31 -19
  29. package/dist/entity-CniBgBSd.js.map +1 -0
  30. package/dist/{key-WKhXnXuU.cjs → entity-DJ0Gml9c.cjs} +37 -19
  31. package/dist/{errors-LTe7bOYS.js → errors-D2E1GRjw.js} +2 -2
  32. package/dist/errors-D2E1GRjw.js.map +1 -0
  33. package/dist/{errors-BVbjKVMN.cjs → errors-DhV00966.cjs} +1 -1
  34. package/dist/{expiry-nDbCgZX4.d.ts → expiry-BxOlvVWC.d.ts} +1 -1
  35. package/dist/{expiry-nDbCgZX4.d.ts.map → expiry-BxOlvVWC.d.ts.map} +1 -1
  36. package/dist/{expiry-BELY2Kpw.cjs → expiry-CG9GhVXv.cjs} +1 -1
  37. package/dist/{expiry-BjpxZZQU.js → expiry-Cgdb_dbq.js} +2 -2
  38. package/dist/expiry-Cgdb_dbq.js.map +1 -0
  39. package/dist/expiry-DRV29F1r.d.cts.map +1 -1
  40. package/dist/{flags-CRjPpoh3.d.cts → flags-0Vl5rrHq.d.cts} +1 -1
  41. package/dist/{flags-CRjPpoh3.d.cts.map → flags-0Vl5rrHq.d.cts.map} +1 -1
  42. package/dist/{flags-kr276q6i.cjs → flags-DCD26uhe.cjs} +1 -1
  43. package/dist/{flags-DFBs2J94.js → flags-DUT2gHEU.js} +2 -2
  44. package/dist/{flags-DFBs2J94.js.map → flags-DUT2gHEU.js.map} +1 -1
  45. package/dist/{flags-5dTNRnow.d.ts → flags-wmcMoAnN.d.ts} +1 -1
  46. package/dist/{flags-5dTNRnow.d.ts.map → flags-wmcMoAnN.d.ts.map} +1 -1
  47. package/dist/{index-fX_XyqLp.d.ts → index-BGp2plHs.d.cts} +15 -13
  48. package/dist/index-BGp2plHs.d.cts.map +1 -0
  49. package/dist/{index-DHDud2hC.d.ts → index-BKB875Um.d.ts} +5 -7
  50. package/dist/{index-DHDud2hC.d.ts.map → index-BKB875Um.d.ts.map} +1 -1
  51. package/dist/{index-DvYvrkdk.d.ts → index-CIcHPx2j.d.cts} +110 -6
  52. package/dist/index-CIcHPx2j.d.cts.map +1 -0
  53. package/dist/{index-CV5zCdpa.d.cts → index-Cd2aaWme.d.ts} +13 -6
  54. package/dist/index-Cd2aaWme.d.ts.map +1 -0
  55. package/dist/{index-CA4V7Pdh.d.cts → index-ezMZ2-JH.d.ts} +15 -13
  56. package/dist/index-ezMZ2-JH.d.ts.map +1 -0
  57. package/dist/{index-BF7Mq9Is.d.cts → index-rINthNuU.d.cts} +5 -7
  58. package/dist/{index-BF7Mq9Is.d.cts.map → index-rINthNuU.d.cts.map} +1 -1
  59. package/dist/index.cjs +433 -139
  60. package/dist/index.d.cts +58 -164
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.ts +59 -166
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +376 -75
  65. package/dist/index.js.map +1 -1
  66. package/dist/{payload-CcUj85ys.d.ts → payload-CGvVPZQX.d.ts} +61 -2
  67. package/dist/payload-CGvVPZQX.d.ts.map +1 -0
  68. package/dist/{payload-Bz6651ax.js → payload-DE7wMztL.js} +28 -3
  69. package/dist/payload-DE7wMztL.js.map +1 -0
  70. package/dist/{payload-BNoud2KZ.d.cts → payload-Dfu30njp.d.cts} +60 -1
  71. package/dist/payload-Dfu30njp.d.cts.map +1 -0
  72. package/dist/{payload-KC14SDlN.cjs → payload-DqFweqiO.cjs} +27 -2
  73. package/dist/query/index.cjs +5 -7
  74. package/dist/query/index.d.cts +4 -4
  75. package/dist/query/index.d.ts +4 -5
  76. package/dist/query/index.js +5 -7
  77. package/dist/{queryBuilder-DM6AWCBa.js → queryBuilder-wvA8sn--.js} +169 -23
  78. package/dist/queryBuilder-wvA8sn--.js.map +1 -0
  79. package/dist/{queryBuilder-DbUMEZln.cjs → queryBuilder-zHGhDmaG.cjs} +215 -33
  80. package/dist/{selection-DPg0uyJf.d.cts → selection-Bv8_o-7i.d.cts} +76 -68
  81. package/dist/selection-Bv8_o-7i.d.cts.map +1 -0
  82. package/dist/{selection-C4UhsMOO.d.ts → selection-ox7zdtVm.d.ts} +76 -69
  83. package/dist/selection-ox7zdtVm.d.ts.map +1 -0
  84. package/dist/types/index.cjs +2 -2
  85. package/dist/types/index.d.cts +6 -6
  86. package/dist/types/index.d.ts +7 -8
  87. package/dist/types/index.js +2 -2
  88. package/dist/utils/index.cjs +3 -3
  89. package/dist/utils/index.d.cts +1 -1
  90. package/dist/utils/index.d.ts +2 -2
  91. package/dist/utils/index.js +3 -3
  92. package/package.json +1 -5
  93. package/src/actions/public/getEntity.ts +1 -0
  94. package/src/actions/public/predictEntityKeys.test.ts +17 -1
  95. package/src/actions/public/predictEntityKeys.ts +28 -14
  96. package/src/actions/public/query.ts +1 -5
  97. package/src/actions/wallet/createEntity.ts +7 -6
  98. package/src/actions/wallet/{mutateEntities.test.ts → executeBatch.test.ts} +7 -7
  99. package/src/actions/wallet/{mutateEntities.ts → executeBatch.ts} +26 -11
  100. package/src/actions/wallet/extendEntity.ts +1 -0
  101. package/src/actions/wallet/patchEntity.ts +3 -3
  102. package/src/attr/attributes.ts +8 -2
  103. package/src/attr/errors.ts +2 -2
  104. package/src/attr/types.ts +3 -3
  105. package/src/attr/values.ts +5 -1
  106. package/src/chains/localhost.ts +3 -0
  107. package/src/clients/createPublicClient.test.ts +1 -1
  108. package/src/clients/createPublicClient.ts +5 -5
  109. package/src/clients/createWalletClient.test.ts +2 -2
  110. package/src/clients/createWalletClient.ts +3 -5
  111. package/src/clients/decorators/arkivPublic.ts +13 -24
  112. package/src/clients/decorators/arkivWallet.ts +40 -47
  113. package/src/entity/create.test.ts +20 -1
  114. package/src/entity/errors.ts +4 -3
  115. package/src/entity/expiry.ts +1 -0
  116. package/src/entity/index.ts +2 -2
  117. package/src/entity/key.ts +23 -3
  118. package/src/entity/operations.ts +1 -0
  119. package/src/index.ts +0 -13
  120. package/src/query/engine.ts +0 -11
  121. package/src/query/errors.ts +1 -1
  122. package/src/query/expression.ts +14 -7
  123. package/src/query/queryBuilder.test.ts +1 -21
  124. package/src/query/queryBuilder.ts +3 -10
  125. package/src/types/index.ts +4 -4
  126. package/src/types/rpcSchema.ts +1 -0
  127. package/src/types/txParams.ts +8 -0
  128. package/src/utils/arkivTransactions.test.ts +7 -1
  129. package/src/utils/arkivTransactions.ts +114 -254
  130. package/src/utils/expirationTime.ts +39 -0
  131. package/src/utils/payload.ts +25 -0
  132. package/dist/actions/advanced/index.cjs +0 -13
  133. package/dist/actions/advanced/index.d.cts +0 -8
  134. package/dist/actions/advanced/index.d.ts +0 -9
  135. package/dist/actions/advanced/index.js +0 -9
  136. package/dist/advanced-8ZPTmmaN.js +0 -598
  137. package/dist/advanced-8ZPTmmaN.js.map +0 -1
  138. package/dist/advanced-fPImL6lW.cjs +0 -656
  139. package/dist/arkivTransactions-D74gERHG.d.cts.map +0 -1
  140. package/dist/arkivTransactions-NtGD6uk5.d.ts.map +0 -1
  141. package/dist/attributes-BhY5DwJp.js.map +0 -1
  142. package/dist/chains-BJrZs6sG.js.map +0 -1
  143. package/dist/codec-Car3KkFF.d.ts +0 -102
  144. package/dist/codec-Car3KkFF.d.ts.map +0 -1
  145. package/dist/entity-B7G8q_Eo.cjs +0 -0
  146. package/dist/entity-CD_qFF2M.js +0 -0
  147. package/dist/errors-LTe7bOYS.js.map +0 -1
  148. package/dist/expiry-BjpxZZQU.js.map +0 -1
  149. package/dist/index-B5j76711.d.ts +0 -184
  150. package/dist/index-B5j76711.d.ts.map +0 -1
  151. package/dist/index-CA4V7Pdh.d.cts.map +0 -1
  152. package/dist/index-CV5zCdpa.d.cts.map +0 -1
  153. package/dist/index-DvYvrkdk.d.ts.map +0 -1
  154. package/dist/index-EeUO0nnJ.d.cts +0 -184
  155. package/dist/index-EeUO0nnJ.d.cts.map +0 -1
  156. package/dist/index-fX_XyqLp.d.ts.map +0 -1
  157. package/dist/key-D1Bh7MF0.js.map +0 -1
  158. package/dist/logger-CVpvU8ik.js +0 -153
  159. package/dist/logger-CVpvU8ik.js.map +0 -1
  160. package/dist/logger-Cr15lPAQ.cjs +0 -188
  161. package/dist/payload-BNoud2KZ.d.cts.map +0 -1
  162. package/dist/payload-Bz6651ax.js.map +0 -1
  163. package/dist/payload-CcUj85ys.d.ts.map +0 -1
  164. package/dist/queryBuilder-DM6AWCBa.js.map +0 -1
  165. package/dist/selection-C4UhsMOO.d.ts.map +0 -1
  166. package/dist/selection-DPg0uyJf.d.cts.map +0 -1
  167. package/dist/types-Bu_ZwMbZ.js +0 -0
  168. package/dist/types-NRqymi6S.cjs +0 -0
  169. package/src/actions/advanced/advanced.test.ts +0 -258
  170. package/src/actions/advanced/buildMutation.ts +0 -104
  171. package/src/actions/advanced/getMutationResult.ts +0 -112
  172. package/src/actions/advanced/index.ts +0 -21
  173. package/src/actions/advanced/pingTransaction.ts +0 -43
  174. package/src/actions/advanced/sendMutation.ts +0 -59
  175. package/src/clients/decorators/arkivAdvanced.ts +0 -144
  176. /package/dist/{entity-B00Li04j.cjs → entity-B0t6sN7F.cjs} +0 -0
  177. /package/dist/{attr-DlmErkvR.cjs → types-Bx1EKe0v.js} +0 -0
  178. /package/dist/{attr-GcQKatub.js → types-CKPddlfS.cjs} +0 -0
package/dist/index.cjs CHANGED
@@ -1,28 +1,24 @@
1
- const require_chains = require('./chains-BYRTTipa.cjs');
2
- const require_expiry = require('./expiry-BELY2Kpw.cjs');
3
- const require_advanced = require('./advanced-fPImL6lW.cjs');
4
- const require_attributes = require('./attributes-Df9IsCVs.cjs');
5
- const require_key = require('./key-WKhXnXuU.cjs');
6
- const require_errors = require('./errors-BVbjKVMN.cjs');
7
- const require_flags = require('./flags-kr276q6i.cjs');
8
- const require_logger = require('./logger-Cr15lPAQ.cjs');
9
- require('./attr-DlmErkvR.cjs');
10
- const require_entity = require('./entity-B00Li04j.cjs');
11
- const require_queryBuilder = require('./queryBuilder-DbUMEZln.cjs');
12
- require('./entity-B7G8q_Eo.cjs');
13
- require('./types-NRqymi6S.cjs');
14
- const require_payload = require('./payload-KC14SDlN.cjs');
1
+ const require_chains = require('./chains-BfNQliHU.cjs');
2
+ const require_attr = require('./attr-BXTkpnoc.cjs');
3
+ const require_queryBuilder = require('./queryBuilder-zHGhDmaG.cjs');
4
+ const require_errors = require('./errors-DhV00966.cjs');
5
+ const require_flags = require('./flags-DCD26uhe.cjs');
6
+ const require_entity = require('./entity-B0t6sN7F.cjs');
7
+ const require_expiry = require('./expiry-CG9GhVXv.cjs');
8
+ const require_entity$1 = require('./entity-DJ0Gml9c.cjs');
9
+ require('./types-CKPddlfS.cjs');
10
+ const require_payload = require('./payload-DqFweqiO.cjs');
15
11
  let viem = require("viem");
16
12
  let viem_actions = require("viem/actions");
17
13
 
18
14
  //#region src/actions/public/getBlockTiming.ts
19
- const logger$8 = require_logger.getLogger("actions:public:get-block-timing");
15
+ const logger$9 = require_queryBuilder.getLogger("actions:public:get-block-timing");
20
16
  async function getBlockTiming(client) {
21
17
  const blockTiming = await client.request({
22
18
  method: "arkiv_getBlockTiming",
23
19
  params: []
24
20
  });
25
- logger$8("Block timing %o", blockTiming);
21
+ logger$9("Block timing %o", blockTiming);
26
22
  return {
27
23
  currentBlock: BigInt(blockTiming.current_block),
28
24
  currentBlockTime: blockTiming.current_block_time,
@@ -45,12 +41,12 @@ async function getBlockTiming(client) {
45
41
  */
46
42
  async function getEntity(client, entityKey) {
47
43
  const { entities } = await require_queryBuilder.runQuery(client, {
48
- query: require_queryBuilder.eq("$key", require_attributes.key(entityKey)).toString(),
44
+ query: require_queryBuilder.eq("$key", require_attr.key(entityKey)).toString(),
49
45
  select: require_queryBuilder.toRpcSelect("*"),
50
46
  limit: 1
51
47
  });
52
48
  const entity = entities[0];
53
- if (entity === void 0) throw new require_logger.NoEntityFoundError(entityKey);
49
+ if (entity === void 0) throw new require_queryBuilder.NoEntityFoundError(entityKey);
54
50
  return entity;
55
51
  }
56
52
 
@@ -63,9 +59,93 @@ async function getEntityCount(client) {
63
59
  });
64
60
  }
65
61
 
62
+ //#endregion
63
+ //#region src/entity/operations.ts
64
+ /**
65
+ * The one external entry point. A transaction is an ordered, **atomic** batch of entity operations:
66
+ * all of them apply or none do, operation *n+1* observes operation *n*'s effects, and each applied
67
+ * operation emits one event.
68
+ */
69
+ const EXECUTE_ABI = (0, viem.parseAbi)(["function execute((uint8 operation, bytes operationData)[] ops) external returns (bytes32[] keys)"]);
70
+ /**
71
+ * The engine's one read-only view: an owner's entity-minting nonce, which is the input
72
+ * {@link predictEntityKey} needs and the only part of the derivation the caller cannot know.
73
+ *
74
+ * It is a `view` on the same address `execute` is called on, so it answers over `eth_call` without
75
+ * a transaction.
76
+ */
77
+ const ENTITY_NONCE_ABI = (0, viem.parseAbi)(["function entityNonce(address owner) external view returns (uint64)"]);
78
+ /**
79
+ * The shared attribute shape, used by `create` (attributes) and `patch` (mutations). Written out
80
+ * once and reused by every payload that carries attributes.
81
+ */
82
+ const ATTRIBUTE_TUPLE = "(bytes32 name, uint8 typeId, bytes value)[]";
83
+ /**
84
+ * The payload struct for each operation tag. `operationData` is `abi.encode` of the struct the tag
85
+ * selects — a tagged union, so a new operation is additive rather than a change to `execute`.
86
+ */
87
+ const PAYLOAD_PARAMS = {
88
+ [require_expiry.OperationType.Create]: (0, viem.parseAbiParameters)(`(uint128 salt, uint64 expiresAt, uint64 minLifetime, uint8 creationFlags, ${ATTRIBUTE_TUPLE} attributes)`),
89
+ [require_expiry.OperationType.Patch]: (0, viem.parseAbiParameters)(`(bytes32 entityKey, ${ATTRIBUTE_TUPLE} mutations)`),
90
+ [require_expiry.OperationType.ExtendExpiry]: (0, viem.parseAbiParameters)("(bytes32 entityKey, uint64 expiresAt, uint64 minLifetime)"),
91
+ [require_expiry.OperationType.TransferOwnership]: (0, viem.parseAbiParameters)("(bytes32 entityKey, address newOwner)"),
92
+ [require_expiry.OperationType.Delete]: (0, viem.parseAbiParameters)("(bytes32 entityKey)")
93
+ };
94
+ /** Creates an entity. The key is derived by the engine; predict it with `predictEntityKey`. */
95
+ function createOperation({ salt, expiry, creationFlags, attributes }) {
96
+ return {
97
+ operation: require_expiry.OperationType.Create,
98
+ operationData: (0, viem.encodeAbiParameters)(PAYLOAD_PARAMS[require_expiry.OperationType.Create], [{
99
+ salt,
100
+ expiresAt: expiry.expiresAt,
101
+ minLifetime: expiry.minLifetime,
102
+ creationFlags,
103
+ attributes
104
+ }])
105
+ };
106
+ }
107
+ /** Applies a set of mutations to an existing entity. Tombstones unset attributes. */
108
+ function patchOperation({ entityKey, mutations }) {
109
+ return {
110
+ operation: require_expiry.OperationType.Patch,
111
+ operationData: (0, viem.encodeAbiParameters)(PAYLOAD_PARAMS[require_expiry.OperationType.Patch], [{
112
+ entityKey,
113
+ mutations
114
+ }])
115
+ };
116
+ }
117
+ /** Pushes an entity's expiry further out. Extending is allowed; shortening reverts. */
118
+ function extendExpiryOperation({ entityKey, expiry }) {
119
+ return {
120
+ operation: require_expiry.OperationType.ExtendExpiry,
121
+ operationData: (0, viem.encodeAbiParameters)(PAYLOAD_PARAMS[require_expiry.OperationType.ExtendExpiry], [{
122
+ entityKey,
123
+ expiresAt: expiry.expiresAt,
124
+ minLifetime: expiry.minLifetime
125
+ }])
126
+ };
127
+ }
128
+ /** Hands an entity to a new owner. */
129
+ function transferOwnershipOperation({ entityKey, newOwner }) {
130
+ return {
131
+ operation: require_expiry.OperationType.TransferOwnership,
132
+ operationData: (0, viem.encodeAbiParameters)(PAYLOAD_PARAMS[require_expiry.OperationType.TransferOwnership], [{
133
+ entityKey,
134
+ newOwner
135
+ }])
136
+ };
137
+ }
138
+ /** Deletes an entity before its expiry. */
139
+ function deleteOperation({ entityKey }) {
140
+ return {
141
+ operation: require_expiry.OperationType.Delete,
142
+ operationData: (0, viem.encodeAbiParameters)(PAYLOAD_PARAMS[require_expiry.OperationType.Delete], [{ entityKey }])
143
+ };
144
+ }
145
+
66
146
  //#endregion
67
147
  //#region src/actions/public/getEntityNonce.ts
68
- const logger$7 = require_logger.getLogger("actions:public:get-entity-nonce");
148
+ const logger$8 = require_queryBuilder.getLogger("actions:public:get-entity-nonce");
69
149
  /**
70
150
  * Reads an owner's entity-minting nonce — how many entities that account has created.
71
151
  *
@@ -80,11 +160,11 @@ const logger$7 = require_logger.getLogger("actions:public:get-entity-nonce");
80
160
  async function getEntityNonce(client, owner) {
81
161
  const nonce = await (0, viem_actions.readContract)(client, {
82
162
  address: require_expiry.ARKIV_ADDRESS,
83
- abi: require_advanced.ENTITY_NONCE_ABI,
163
+ abi: ENTITY_NONCE_ABI,
84
164
  functionName: "entityNonce",
85
165
  args: [owner]
86
166
  });
87
- logger$7("entity nonce of %s is %s", owner, nonce);
167
+ logger$8("entity nonce of %s is %s", owner, nonce);
88
168
  return nonce;
89
169
  }
90
170
 
@@ -102,7 +182,7 @@ async function getEntityNonce(client, owner) {
102
182
  *
103
183
  * The prediction is valid only while nothing else from this owner is in flight. Every create that
104
184
  * lands first takes the nonce with it and moves these keys. For a key you can rely on
105
- * unconditionally, read it back from the create instead — `createEntity` and `mutateEntities`
185
+ * unconditionally, read it back from the create instead — `createEntity` and `executeBatch`
106
186
  * report the keys the engine actually minted.
107
187
  *
108
188
  * @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
@@ -112,7 +192,7 @@ async function getEntityNonce(client, owner) {
112
192
  * import { key } from "@arkiv-network/sdk/attr"
113
193
  *
114
194
  * const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
115
- * await wallet.mutateEntities({
195
+ * await client.executeBatch({
116
196
  * creates: [
117
197
  * { payload, contentType, expires, salt: parent.salt },
118
198
  * {
@@ -130,7 +210,7 @@ async function predictEntityKeys(client, { owner, count, salts }) {
130
210
  const chainId = client.chain?.id ?? await (0, viem_actions.getChainId)(client);
131
211
  const nonce = await getEntityNonce(client, owner);
132
212
  return resolvedSalts.map((salt, index) => ({
133
- key: require_key.predictEntityKey({
213
+ key: require_entity$1.predictEntityKey({
134
214
  owner,
135
215
  nonce: nonce + BigInt(index),
136
216
  salt,
@@ -143,11 +223,11 @@ async function predictEntityKeys(client, { owner, count, salts }) {
143
223
  function resolveSalts(count, salts) {
144
224
  if (salts !== void 0) {
145
225
  if (salts.length === 0) throw new Error("predictEntityKeys: `salts` is empty — there is nothing to predict");
146
- return salts.map(require_key.validateSalt);
226
+ return salts.map(require_entity$1.resolveSalt);
147
227
  }
148
228
  if (count === void 0) throw new Error("predictEntityKeys: pass either `count` or `salts`");
149
229
  if (!Number.isInteger(count) || count <= 0) throw new Error(`predictEntityKeys: \`count\` must be a positive whole number, got ${count}`);
150
- return Array.from({ length: count }, () => require_key.randomSalt());
230
+ return Array.from({ length: count }, () => require_entity$1.randomSalt());
151
231
  }
152
232
 
153
233
  //#endregion
@@ -173,7 +253,7 @@ function query(client, query$1, options = {}) {
173
253
 
174
254
  //#endregion
175
255
  //#region src/actions/public/watchEntityEvents.ts
176
- const logger$6 = require_logger.getLogger("actions:public:watch-entity-events");
256
+ const logger$7 = require_queryBuilder.getLogger("actions:public:watch-entity-events");
177
257
  /**
178
258
  * How often to poll, when the caller does not say.
179
259
  *
@@ -248,11 +328,11 @@ function watchEntityEvents(client, parameters) {
248
328
  }
249
329
  return publicClient.watchEvent({
250
330
  address: require_expiry.ARKIV_ADDRESS,
251
- events: require_key.ENTITY_EVENTS_ABI,
331
+ events: require_entity$1.ENTITY_EVENTS_ABI,
252
332
  pollingInterval,
253
333
  ...fromBlock !== void 0 && { fromBlock },
254
334
  onLogs: (logs) => {
255
- logger$6("logs %o", logs);
335
+ logger$7("logs %o", logs);
256
336
  for (const log of logs) {
257
337
  if (log.blockNumber === null || log.transactionHash === null || log.logIndex === null) continue;
258
338
  const context = {
@@ -288,7 +368,7 @@ function asError(error) {
288
368
  */
289
369
  function toEntityEvent(topics, data, context) {
290
370
  const decoded = (0, viem.decodeEventLog)({
291
- abi: require_key.ENTITY_EVENTS_ABI,
371
+ abi: require_entity$1.ENTITY_EVENTS_ABI,
292
372
  topics,
293
373
  data
294
374
  });
@@ -322,23 +402,6 @@ function toEntityEvent(topics, data, context) {
322
402
  }
323
403
  }
324
404
 
325
- //#endregion
326
- //#region src/clients/decorators/arkivAdvanced.ts
327
- function publicAdvancedActions(client) {
328
- return {
329
- pingTransaction: (txHash) => require_advanced.pingTransaction(client, txHash),
330
- getMutationResult: (txHash) => require_advanced.getMutationResult(client, txHash),
331
- decodeMutationResult: (receipt) => require_advanced.decodeMutationResult(receipt)
332
- };
333
- }
334
- function walletAdvancedActions(client) {
335
- return {
336
- ...publicAdvancedActions(client),
337
- buildMutation: (data, options) => require_advanced.buildMutation(client, data, options),
338
- sendMutation: (data, options) => require_advanced.sendMutation(client, data, options)
339
- };
340
- }
341
-
342
405
  //#endregion
343
406
  //#region src/clients/decorators/arkivPublic.ts
344
407
  function publicArkivActions(client) {
@@ -350,22 +413,21 @@ function publicArkivActions(client) {
350
413
  getEntityCount: () => getEntityCount(client),
351
414
  getEntityNonce: (owner) => getEntityNonce(client, owner),
352
415
  predictEntityKeys: (parameters) => predictEntityKeys(client, parameters),
353
- watchEntityEvents: (parameters) => watchEntityEvents(client, parameters),
354
- advanced: publicAdvancedActions(client)
416
+ watchEntityEvents: (parameters) => watchEntityEvents(client, parameters)
355
417
  };
356
418
  }
357
419
 
358
420
  //#endregion
359
421
  //#region src/clients/createPublicClient.ts
360
422
  /**
361
- * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
423
+ * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/chains/introduction).
362
424
  *
363
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/public
364
- *
365
- * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Cheesecake JSON-RPC API](https://rpc.cheesecake.db-chain.devnet.gobas.me) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
425
+ * A Public Client is an interface to the "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/)
426
+ * and the Arkiv JSON-RPC API — retrieving block numbers and transactions, reading from
427
+ * contracts, and querying entities — through {@link PublicArkivActions}.
366
428
  *
367
429
  * @param parameters - Configuration object for the public client (chain, transport, etc.)
368
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
430
+ * @returns An Arkiv Public Client. {@link PublicArkivClient}
369
431
  *
370
432
  * @example
371
433
  * import { createPublicClient } from "@arkiv-network/sdk"
@@ -386,12 +448,254 @@ function createPublicClient(parameters) {
386
448
  }).extend(viem.publicActions).extend(publicArkivActions);
387
449
  }
388
450
 
451
+ //#endregion
452
+ //#region src/utils/revert.ts
453
+ /**
454
+ * Turns a decoded engine revert into a sentence that says what to change.
455
+ *
456
+ * viem decodes the error and then renders it positionally — `Ident32InvalidByte(uint256 position,
457
+ * bytes1 value)` arrives as `(5, 0x41)`, which is the right data and no help at all. The engine's
458
+ * errors carry enough to name the actual problem, so this spends the args rather than printing
459
+ * them.
460
+ *
461
+ * @param error - Anything thrown by a write action.
462
+ * @returns The explanation, or `undefined` if this was not a decodable engine revert — in which
463
+ * case the caller should fall back to whatever the transport said.
464
+ */
465
+ function describeEntityRevert(error) {
466
+ if (!(error instanceof viem.BaseError)) return void 0;
467
+ const reverted = error.walk((e) => e instanceof viem.ContractFunctionRevertedError);
468
+ if (!(reverted instanceof viem.ContractFunctionRevertedError)) return void 0;
469
+ const name = reverted.data?.errorName;
470
+ if (name === void 0) return void 0;
471
+ return explain(name, reverted.data?.args ?? []) ?? `the engine rejected the batch with ${name}`;
472
+ }
473
+ /** The attribute-name charset, quoted the way an error message should read. */
474
+ const CHARSET = "\"A\"-\"Z\", \"a\"-\"z\", \"0\"-\"9\", \".\", \"-\" and \"_\", with a letter first";
475
+ function explain(name, args) {
476
+ switch (name) {
477
+ case "Ident32InvalidByte": {
478
+ const position = Number(args[0] ?? 0);
479
+ return `an attribute name holds ${printable(String(args[1] ?? "0x00"))} at byte ${position}, which is outside the name charset (${CHARSET})`;
480
+ }
481
+ case "Ident32Empty": return "an attribute name is empty";
482
+ case "SystemAttributeNotWritable": return `"${identName(args[0])}" is owned by the engine and cannot be written. Only $payload and \$contentType are yours to set`;
483
+ case "TombstoneInCreate": return `a create cannot unset "${identName(args[0])}" — nothing exists yet, so leave the name out instead`;
484
+ case "TombstoneValueNotEmpty": return `the tombstone for "${identName(args[0])}" carries a value; unsetting takes no value`;
485
+ case "InvalidValueType": return `"${identName(args[0])}" names type id ${String(args[1])}, which is not a known type`;
486
+ case "AttributesNotSorted": return "attributes must be strictly ascending by name, which also makes each name unique";
487
+ case "TooManyAttributes": return `${String(args[0])} attributes exceeds the limit of ${String(args[1])}`;
488
+ case "EmptyMutations": return `the patch of ${short(args[0])} has no mutations, so it would do nothing`;
489
+ case "EntityNotFound": return `no entity ${short(args[0])} — it may have been deleted, or have expired`;
490
+ case "EntityExpired": return `entity ${short(args[0])} expired at block ${String(args[1])}`;
491
+ case "NotOwner": return `entity ${short(args[0])} is owned by ${String(args[2])}, not ${String(args[1])}`;
492
+ case "ReadOnlyEntity": return `entity ${short(args[0])} was created readonly, so its contents can never change. Its expiry can still be extended, and it can be transferred or deleted`;
493
+ case "ReservedCreationFlags": return `creation flags 0b${Number(args[0] ?? 0).toString(2).padStart(8, "0")} set a reserved bit; only readonly and permissionlessExtension are defined`;
494
+ case "ExpiryDeadOnArrival": return `the expiry resolves to block ${String(args[0])}, which is not after the current block ${String(args[1])}`;
495
+ case "ExpiryNotExtended": return `entity ${short(args[0])} already expires at block ${String(args[2])}, so extending it to ${String(args[1])} would shorten its life`;
496
+ case "TransferToZeroAddress": return `entity ${short(args[0])} cannot be transferred to the zero address`;
497
+ case "TransferToSelf": return `entity ${short(args[0])} is already owned by that account`;
498
+ case "EmptyBatch": return "the batch has no operations";
499
+ case "InvalidOpType": return `operation tag ${String(args[0])} is not one the engine knows`;
500
+ case "NonCanonicalOperationData": return `the payload for operation tag ${String(args[0])} is not its canonical encoding, so the engine refused it rather than accept a second spelling of the same operation`;
501
+ default: return;
502
+ }
503
+ }
504
+ /** A `bytes32` Ident32 cell as the name it holds — left-aligned, null-padded. */
505
+ function identName(raw) {
506
+ if (typeof raw !== "string") return String(raw);
507
+ try {
508
+ return (0, viem.hexToString)(raw).split("\0")[0] ?? "";
509
+ } catch {
510
+ return raw;
511
+ }
512
+ }
513
+ /** An entity key, abbreviated */
514
+ function short(raw) {
515
+ const text = String(raw);
516
+ return text.length > 18 ? `${text.slice(0, 10)}…${text.slice(-6)}` : text;
517
+ }
518
+ /** A `bytes1` as something readable: the character it is, plus the byte it was. */
519
+ function printable(byte) {
520
+ const code = Number.parseInt(byte.replace(/^0x/, ""), 16);
521
+ if (!Number.isFinite(code)) return `byte ${byte}`;
522
+ return code >= 33 && code <= 126 ? `"${String.fromCharCode(code)}" (${byte})` : `byte ${byte}`;
523
+ }
524
+
525
+ //#endregion
526
+ //#region src/utils/arkivTransactions.ts
527
+ const logger$6 = require_queryBuilder.getLogger("utils:arkiv-transactions");
528
+ const MIME_REGEX = /^[a-z][a-z0-9!#$&\-^_]*\/[a-z0-9][a-z0-9!#$&\-^_.+]*$/;
529
+ function validateContentType(contentType) {
530
+ if (!MIME_REGEX.test(contentType)) throw new require_queryBuilder.InvalidContentTypeError(contentType);
531
+ }
532
+ const ENTITY_ERRORS_ABI = (0, viem.parseAbi)([
533
+ "error EmptyBatch()",
534
+ "error InvalidOpType(uint8 operation)",
535
+ "error NonCanonicalOperationData(uint8 operation)",
536
+ "error AttributesNotSorted()",
537
+ "error TooManyAttributes(uint256 count, uint256 maxCount)",
538
+ "error EmptyMutations(bytes32 entityKey)",
539
+ "error TombstoneInCreate(bytes32 name)",
540
+ "error TombstoneValueNotEmpty(bytes32 name)",
541
+ "error SystemAttributeNotWritable(bytes32 name)",
542
+ "error InvalidValueType(bytes32 name, uint8 typeId)",
543
+ "error Ident32Empty()",
544
+ "error Ident32InvalidByte(uint256 position, bytes1 value)",
545
+ "error EntityNotFound(bytes32 entityKey)",
546
+ "error EntityExpired(bytes32 entityKey, uint64 expiresAt)",
547
+ "error NotOwner(bytes32 entityKey, address caller, address owner)",
548
+ "error ReadOnlyEntity(bytes32 entityKey)",
549
+ "error ReservedCreationFlags(uint8 creationFlags)",
550
+ "error ExpiryDeadOnArrival(uint64 target, uint64 currentBlock)",
551
+ "error ExpiryNotExtended(bytes32 entityKey, uint64 newExpiresAt, uint64 currentExpiresAt)",
552
+ "error TransferToZeroAddress(bytes32 entityKey)",
553
+ "error TransferToSelf(bytes32 entityKey)"
554
+ ]);
555
+ const EXECUTE_ABI$1 = [...EXECUTE_ABI, ...ENTITY_ERRORS_ABI];
556
+ async function sendArkivTransaction(client, ops, txParams) {
557
+ if (!client.account) throw new Error("Account required");
558
+ if (!client.chain) throw new Error("Chain required");
559
+ const walletClient = client;
560
+ const { creates, patches, deletes, extensions, ownershipChanges } = ops;
561
+ const expiryContext = { currentBlock: creates?.length || extensions?.length ? await walletClient.getBlockNumber() : 0n };
562
+ const createOps = (creates ?? []).map((item) => {
563
+ validateContentType(item.contentType);
564
+ return createOperation({
565
+ salt: item.salt === void 0 ? require_entity$1.randomSalt() : require_entity$1.resolveSalt(item.salt),
566
+ expiry: require_expiry.resolveExpiry(item.expires, expiryContext),
567
+ creationFlags: require_flags.encodeCreationFlags(item.flags),
568
+ attributes: require_attr.encodeAttributes(item.attributes, {
569
+ payload: item.payload,
570
+ contentType: item.contentType
571
+ })
572
+ });
573
+ });
574
+ const patchOps = (patches ?? []).map((item) => {
575
+ if (item.contentType !== void 0) validateContentType(item.contentType);
576
+ const mutations = require_attr.encodeMutations(item);
577
+ if (mutations.length === 0) throw new require_queryBuilder.EmptyPatchError(item.entityKey);
578
+ return patchOperation({
579
+ entityKey: item.entityKey,
580
+ mutations
581
+ });
582
+ });
583
+ const extendOps = (extensions ?? []).map((item) => {
584
+ const expiry = require_expiry.resolveExpiry(item.expires, expiryContext);
585
+ return extendExpiryOperation({
586
+ entityKey: item.entityKey,
587
+ expiry
588
+ });
589
+ });
590
+ const operations = [
591
+ ...createOps,
592
+ ...patchOps,
593
+ ...(deletes ?? []).map((item) => deleteOperation({ entityKey: item.entityKey })),
594
+ ...extendOps,
595
+ ...(ownershipChanges ?? []).map((item) => transferOwnershipOperation({
596
+ entityKey: item.entityKey,
597
+ newOwner: item.newOwner
598
+ }))
599
+ ];
600
+ if (operations.length === 0) throw new Error("No operations to perform");
601
+ logger$6("Sending execute with %d operations %o", operations.length, operations);
602
+ try {
603
+ const txHash = await walletClient.writeContract({
604
+ address: require_expiry.ARKIV_ADDRESS,
605
+ abi: EXECUTE_ABI$1,
606
+ functionName: "execute",
607
+ args: [operations],
608
+ account: client.account,
609
+ chain: client.chain,
610
+ ...txParams
611
+ });
612
+ const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
613
+ logger$6("Tx receipt %o", receipt);
614
+ if (receipt.status === "reverted") {
615
+ try {
616
+ await walletClient.simulateContract({
617
+ address: require_expiry.ARKIV_ADDRESS,
618
+ abi: EXECUTE_ABI$1,
619
+ functionName: "execute",
620
+ args: [operations],
621
+ account: client.account,
622
+ chain: client.chain
623
+ });
624
+ } catch (err) {
625
+ const error = err;
626
+ const reason = describeEntityRevert(err) ?? error.shortMessage ?? error.cause?.details ?? "No reason provided by backend.";
627
+ throw new require_queryBuilder.EntityMutationError(`Transaction ${receipt.transactionHash} reverted. Reason: ${reason}`);
628
+ }
629
+ throw new require_queryBuilder.EntityMutationError(`Transaction ${receipt.transactionHash} reverted. No reason provided by backend.`);
630
+ }
631
+ return {
632
+ receipt,
633
+ ...readAppliedOperations(receipt, {
634
+ creates: createOps.length,
635
+ extensions: extendOps.length
636
+ })
637
+ };
638
+ } catch (error) {
639
+ const described = error instanceof require_queryBuilder.EntityMutationError ? void 0 : describeEntityRevert(error);
640
+ if (described !== void 0) throw new require_queryBuilder.EntityMutationError(`Transaction failed: ${described}`, { cause: error });
641
+ let message = "Transaction failed";
642
+ if (error instanceof viem.TransactionExecutionError) message += `: ${error.details}`;
643
+ else if (error instanceof viem.ContractFunctionExecutionError) {
644
+ logger$6("Contract function execution error data:", error.shortMessage);
645
+ if (error.cause instanceof viem.ContractFunctionRevertedError) message += `: ${error.cause.message}`;
646
+ else message += ": Execution error without revert data";
647
+ } else if (error instanceof require_queryBuilder.EntityMutationError) throw error;
648
+ else if (error instanceof Error) message += `: ${error.message}`;
649
+ throw new require_queryBuilder.EntityMutationError(message, { cause: error });
650
+ }
651
+ }
652
+ /**
653
+ * The keys and expiries the engine recorded, read back from the events the batch emitted.
654
+ */
655
+ function readAppliedOperations(receipt, expected) {
656
+ const createdEntityKeys = [];
657
+ const createdExpiries = [];
658
+ const extendedExpiries = [];
659
+ for (const log of receipt.logs ?? []) {
660
+ if (log.address.toLowerCase() !== require_expiry.ARKIV_ADDRESS.toLowerCase()) continue;
661
+ const decoded = decodeEntityLog(log);
662
+ if (decoded === void 0) continue;
663
+ if (decoded.eventName === "EntityCreated") {
664
+ createdEntityKeys.push(decoded.args.entityKey);
665
+ createdExpiries.push(decoded.args.expiresAt);
666
+ } else if (decoded.eventName === "ExpiryExtended") extendedExpiries.push(decoded.args.expiresAt);
667
+ }
668
+ assertCount(receipt, "create", createdEntityKeys.length, expected.creates);
669
+ assertCount(receipt, "extension", extendedExpiries.length, expected.extensions);
670
+ return {
671
+ createdEntityKeys,
672
+ createdExpiries,
673
+ extendedExpiries
674
+ };
675
+ }
676
+ /** One log as an entity event, or `undefined` for anything this SDK has no name for. */
677
+ function decodeEntityLog(log) {
678
+ try {
679
+ return (0, viem.decodeEventLog)({
680
+ abi: require_entity$1.ENTITY_EVENTS_ABI,
681
+ topics: log.topics,
682
+ data: log.data
683
+ });
684
+ } catch {
685
+ return;
686
+ }
687
+ }
688
+ function assertCount(receipt, what, got, want) {
689
+ if (got === want) return;
690
+ throw new require_queryBuilder.EntityMutationError(`Transaction ${receipt.transactionHash} succeeded — do not retry it — but emitted ${got} ${what} event(s) for ${want} ${what} operation(s). The batch was applied; the SDK cannot say which entity each operation produced, so read them back to find them.`);
691
+ }
692
+
389
693
  //#endregion
390
694
  //#region src/actions/wallet/changeOwnership.ts
391
- const logger$5 = require_logger.getLogger("actions:wallet:change-ownership");
695
+ const logger$5 = require_queryBuilder.getLogger("actions:wallet:change-ownership");
392
696
  async function changeOwnership(client, data, txParams) {
393
697
  logger$5("changeOwnership %o", data);
394
- const { receipt } = await require_advanced.sendArkivTransaction(client, { ownershipChanges: [data] }, txParams);
698
+ const { receipt } = await sendArkivTransaction(client, { ownershipChanges: [data] }, txParams);
395
699
  logger$5("Receipt from changeOwnership %o", receipt);
396
700
  return {
397
701
  txHash: receipt.transactionHash,
@@ -401,14 +705,14 @@ async function changeOwnership(client, data, txParams) {
401
705
 
402
706
  //#endregion
403
707
  //#region src/actions/wallet/createEntity.ts
404
- const logger$4 = require_logger.getLogger("actions:wallet:create-entity");
708
+ const logger$4 = require_queryBuilder.getLogger("actions:wallet:create-entity");
405
709
  async function createEntity(client, data, txParams) {
406
710
  logger$4("createEntity %o", data);
407
- const { receipt, createdEntityKeys, createdExpiries } = await require_advanced.sendArkivTransaction(client, { creates: [data] }, txParams);
711
+ const { receipt, createdEntityKeys, createdExpiries } = await sendArkivTransaction(client, { creates: [data] }, txParams);
408
712
  logger$4("Receipt from createEntity %o", receipt);
409
713
  const [entityKey] = createdEntityKeys;
410
714
  const [expiresAt] = createdExpiries;
411
- if (entityKey === void 0 || expiresAt === void 0) throw new require_logger.EntityMutationError(`Transaction ${receipt.transactionHash} succeeded, but the receipt did not carry the expected entity key or expiry.`);
715
+ if (entityKey === void 0 || expiresAt === void 0) throw new require_queryBuilder.EntityMutationError(`Transaction ${receipt.transactionHash} succeeded, but the receipt did not carry the expected entity key or expiry.`);
412
716
  return {
413
717
  txHash: receipt.transactionHash,
414
718
  entityKey,
@@ -418,10 +722,10 @@ async function createEntity(client, data, txParams) {
418
722
 
419
723
  //#endregion
420
724
  //#region src/actions/wallet/deleteEntity.ts
421
- const logger$3 = require_logger.getLogger("actions:wallet:delete-entity");
725
+ const logger$3 = require_queryBuilder.getLogger("actions:wallet:delete-entity");
422
726
  async function deleteEntity(client, data, txParams) {
423
727
  logger$3("deleteEntity %o", data);
424
- const { receipt } = await require_advanced.sendArkivTransaction(client, { deletes: [data] }, txParams);
728
+ const { receipt } = await sendArkivTransaction(client, { deletes: [data] }, txParams);
425
729
  logger$3("Receipt from deleteEntity %o", receipt);
426
730
  return {
427
731
  txHash: receipt.transactionHash,
@@ -430,43 +734,43 @@ async function deleteEntity(client, data, txParams) {
430
734
  }
431
735
 
432
736
  //#endregion
433
- //#region src/actions/wallet/extendEntity.ts
434
- const logger$2 = require_logger.getLogger("actions:wallet:extend-entity");
435
- async function extendEntity(client, data, txParams) {
436
- logger$2("extendEntity %o", data);
437
- const { receipt, extendedExpiries } = await require_advanced.sendArkivTransaction(client, { extensions: [data] }, txParams);
438
- logger$2("Receipt from extendEntity %o", receipt);
439
- const [expiresAt] = extendedExpiries;
440
- if (expiresAt === void 0) throw new require_logger.EntityMutationError(`Transaction ${receipt.transactionHash} succeeded, but the receipt did not carry the expected entity expiry.`);
737
+ //#region src/actions/wallet/executeBatch.ts
738
+ const logger$2 = require_queryBuilder.getLogger("actions:wallet:execute-batch");
739
+ async function executeBatch(client, data, txParams) {
740
+ const { receipt, createdEntityKeys } = await sendArkivTransaction(client, data, txParams);
741
+ logger$2("Receipt from executeBatch %o", receipt);
441
742
  return {
442
743
  txHash: receipt.transactionHash,
443
- entityKey: data.entityKey,
444
- expiresAt
744
+ createdEntities: createdEntityKeys,
745
+ patchedEntities: (data.patches ?? []).map((p) => p.entityKey),
746
+ deletedEntities: (data.deletes ?? []).map((d) => d.entityKey),
747
+ extendedEntities: (data.extensions ?? []).map((e) => e.entityKey),
748
+ ownershipChanges: (data.ownershipChanges ?? []).map((o) => o.entityKey)
445
749
  };
446
750
  }
447
751
 
448
752
  //#endregion
449
- //#region src/actions/wallet/mutateEntities.ts
450
- const logger$1 = require_logger.getLogger("actions:wallet:mutate-entities");
451
- async function mutateEntities(client, data, txParams) {
452
- const { receipt, createdEntityKeys } = await require_advanced.sendArkivTransaction(client, data, txParams);
453
- logger$1("Receipt from mutateEntities %o", receipt);
753
+ //#region src/actions/wallet/extendEntity.ts
754
+ const logger$1 = require_queryBuilder.getLogger("actions:wallet:extend-entity");
755
+ async function extendEntity(client, data, txParams) {
756
+ logger$1("extendEntity %o", data);
757
+ const { receipt, extendedExpiries } = await sendArkivTransaction(client, { extensions: [data] }, txParams);
758
+ logger$1("Receipt from extendEntity %o", receipt);
759
+ const [expiresAt] = extendedExpiries;
760
+ if (expiresAt === void 0) throw new require_queryBuilder.EntityMutationError(`Transaction ${receipt.transactionHash} succeeded, but the receipt did not carry the expected entity expiry.`);
454
761
  return {
455
762
  txHash: receipt.transactionHash,
456
- createdEntities: createdEntityKeys,
457
- patchedEntities: (data.patches ?? []).map((p) => p.entityKey),
458
- deletedEntities: (data.deletes ?? []).map((d) => d.entityKey),
459
- extendedEntities: (data.extensions ?? []).map((e) => e.entityKey),
460
- ownershipChanges: (data.ownershipChanges ?? []).map((o) => o.entityKey)
763
+ entityKey: data.entityKey,
764
+ expiresAt
461
765
  };
462
766
  }
463
767
 
464
768
  //#endregion
465
769
  //#region src/actions/wallet/patchEntity.ts
466
- const logger = require_logger.getLogger("actions:wallet:patch-entity");
770
+ const logger = require_queryBuilder.getLogger("actions:wallet:patch-entity");
467
771
  async function patchEntity(client, data, txParams) {
468
772
  logger("patchEntity %o", data);
469
- const { receipt } = await require_advanced.sendArkivTransaction(client, { patches: [data] }, txParams);
773
+ const { receipt } = await sendArkivTransaction(client, { patches: [data] }, txParams);
470
774
  logger("Receipt from patchEntity %o", receipt);
471
775
  return {
472
776
  txHash: receipt.transactionHash,
@@ -483,8 +787,7 @@ function walletArkivActions(client) {
483
787
  deleteEntity: (data, txParams) => deleteEntity(client, data, txParams),
484
788
  extendEntity: (data, txParams) => extendEntity(client, data, txParams),
485
789
  changeOwnership: (data, txParams) => changeOwnership(client, data, txParams),
486
- mutateEntities: (data, txParams) => mutateEntities(client, data, txParams),
487
- advanced: walletAdvancedActions(client)
790
+ executeBatch: (data, txParams) => executeBatch(client, data, txParams)
488
791
  };
489
792
  }
490
793
 
@@ -492,16 +795,14 @@ function walletArkivActions(client) {
492
795
  //#region src/clients/createWalletClient.ts
493
796
  /**
494
797
  * Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured
495
- * for a [Chain](https://viem.sh/docs/clients/chains) and an account.
496
- *
497
- * - Docs: https://docs.arkiv.network/ts-sdk/clients/wallet
798
+ * for a [Chain](https://viem.sh/docs/chains/introduction) and an account.
498
799
  *
499
800
  * A Wallet Client signs and sends transactions, so it carries an `account` and exposes everything
500
801
  * that mutates state — `createEntity`, `patchEntity`, `deleteEntity`, `extendEntity`,
501
- * `changeOwnership` and `mutateEntities` — on top of the read actions a Public Client has.
802
+ * `changeOwnership` and `executeBatch` — on top of the read actions a Public Client has.
502
803
  *
503
804
  * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
504
- * @returns A Arkiv Wallet Client. {@link WalletArkivClient}
805
+ * @returns An Arkiv Wallet Client. {@link WalletArkivClient}
505
806
  *
506
807
  * @example
507
808
  * import { createWalletClient } from "@arkiv-network/sdk"
@@ -540,69 +841,62 @@ function chainFromName(name) {
540
841
  }
541
842
 
542
843
  //#endregion
543
- exports.ConflictingMutationError = require_attributes.ConflictingMutationError;
544
- exports.DECIMAL_SCALE = require_attributes.DECIMAL_SCALE;
545
- exports.DECIMAL_UNIT = require_attributes.DECIMAL_UNIT;
546
- exports.ENTITY_EVENTS_ABI = require_key.ENTITY_EVENTS_ABI;
547
- exports.EmptyPatchError = require_logger.EmptyPatchError;
844
+ exports.ConflictingMutationError = require_attr.ConflictingMutationError;
845
+ exports.DECIMAL_SCALE = require_attr.DECIMAL_SCALE;
846
+ exports.DECIMAL_UNIT = require_attr.DECIMAL_UNIT;
847
+ exports.ENTITY_EVENTS_ABI = require_entity$1.ENTITY_EVENTS_ABI;
848
+ exports.EmptyPatchError = require_queryBuilder.EmptyPatchError;
548
849
  exports.Entity = require_entity.Entity;
549
- exports.EntityMutationError = require_logger.EntityMutationError;
850
+ exports.EntityMutationError = require_queryBuilder.EntityMutationError;
550
851
  exports.ExpirationTime = require_payload.ExpirationTime;
551
- exports.I32_MAX = require_attributes.I32_MAX;
552
- exports.I32_MIN = require_attributes.I32_MIN;
553
- exports.InvalidAttributeNameError = require_attributes.InvalidAttributeNameError;
554
- exports.InvalidContentTypeError = require_logger.InvalidContentTypeError;
852
+ exports.I32_MAX = require_attr.I32_MAX;
853
+ exports.I32_MIN = require_attr.I32_MIN;
854
+ exports.InvalidAttributeNameError = require_attr.InvalidAttributeNameError;
855
+ exports.InvalidContentTypeError = require_queryBuilder.InvalidContentTypeError;
555
856
  exports.InvalidCreationFlagsError = require_errors.InvalidCreationFlagsError;
556
857
  exports.InvalidExpiryError = require_errors.InvalidExpiryError;
557
858
  exports.InvalidSaltError = require_errors.InvalidSaltError;
558
- exports.InvalidValueError = require_attributes.InvalidValueError;
559
- exports.MAX_ATTRIBUTES = require_attributes.MAX_ATTRIBUTES;
859
+ exports.InvalidValueError = require_attr.InvalidValueError;
860
+ exports.MAX_ATTRIBUTES = require_attr.MAX_ATTRIBUTES;
560
861
  exports.MAX_EXPIRES_AT = require_expiry.MAX_EXPIRES_AT;
561
- exports.MAX_NAME_BYTES = require_attributes.MAX_NAME_BYTES;
562
- exports.MAX_PAYLOAD_BYTES = require_attributes.MAX_PAYLOAD_BYTES;
563
- exports.MAX_SALT = require_key.MAX_SALT;
564
- exports.MAX_STRING_BYTES = require_attributes.MAX_STRING_BYTES;
565
- exports.MissingValueError = require_attributes.MissingValueError;
566
- exports.NoEntityFoundError = require_logger.NoEntityFoundError;
567
- exports.NoMoreResultsError = require_logger.NoMoreResultsError;
862
+ exports.MAX_NAME_BYTES = require_attr.MAX_NAME_BYTES;
863
+ exports.MAX_PAYLOAD_BYTES = require_attr.MAX_PAYLOAD_BYTES;
864
+ exports.MAX_SALT = require_entity$1.MAX_SALT;
865
+ exports.MAX_STRING_BYTES = require_attr.MAX_STRING_BYTES;
866
+ exports.MissingValueError = require_attr.MissingValueError;
867
+ exports.NO_SALT = require_entity$1.NO_SALT;
868
+ exports.NoEntityFoundError = require_queryBuilder.NoEntityFoundError;
869
+ exports.NoMoreResultsError = require_queryBuilder.NoMoreResultsError;
568
870
  exports.NoRandomSourceError = require_errors.NoRandomSourceError;
569
871
  exports.OperationType = require_expiry.OperationType;
570
- exports.TooManyAttributesError = require_attributes.TooManyAttributesError;
571
- exports.U256_MAX = require_attributes.U256_MAX;
572
- exports.U64_MAX = require_attributes.U64_MAX;
573
- exports.UnknownAttributeTypeError = require_attributes.UnknownAttributeTypeError;
574
- exports.UntypedValueError = require_attributes.UntypedValueError;
575
- exports.addr = require_attributes.addr;
576
- exports.bool = require_attributes.bool;
577
- exports.buildEntityOperations = require_advanced.buildEntityOperations;
578
- exports.buildMutation = require_advanced.buildMutation;
579
- exports.bytes32 = require_attributes.bytes32;
872
+ exports.TooManyAttributesError = require_attr.TooManyAttributesError;
873
+ exports.U256_MAX = require_attr.U256_MAX;
874
+ exports.U64_MAX = require_attr.U64_MAX;
875
+ exports.UnknownAttributeTypeError = require_attr.UnknownAttributeTypeError;
876
+ exports.UntypedValueError = require_attr.UntypedValueError;
877
+ exports.addr = require_attr.addr;
878
+ exports.bool = require_attr.bool;
879
+ exports.bytes32 = require_attr.bytes32;
580
880
  exports.chainFromName = chainFromName;
581
- exports.collectMutationEvents = require_advanced.collectMutationEvents;
582
881
  exports.createPublicClient = createPublicClient;
583
882
  exports.createWalletClient = createWalletClient;
584
- exports.dec = require_attributes.dec;
585
- exports.decFromUnits = require_attributes.decFromUnits;
586
- exports.decUnits = require_attributes.decUnits;
883
+ exports.dec = require_attr.dec;
884
+ exports.decFromUnits = require_attr.decFromUnits;
885
+ exports.decUnits = require_attr.decUnits;
587
886
  exports.decodeCreationFlags = require_flags.decodeCreationFlags;
588
- exports.decodeMutationResult = require_advanced.decodeMutationResult;
589
887
  exports.encodeCreationFlags = require_flags.encodeCreationFlags;
590
- exports.getMutationResult = require_advanced.getMutationResult;
591
- exports.i32 = require_attributes.i32;
592
- exports.isArkivValue = require_attributes.isArkivValue;
593
- exports.isValidAttributeName = require_attributes.isValidAttributeName;
888
+ exports.i32 = require_attr.i32;
889
+ exports.isArkivValue = require_attr.isArkivValue;
890
+ exports.isValidAttributeName = require_attr.isValidAttributeName;
594
891
  exports.jsonToPayload = require_payload.jsonToPayload;
595
- exports.key = require_attributes.key;
596
- exports.mutationNeedsBlockNumber = require_advanced.mutationNeedsBlockNumber;
597
- exports.pingTransaction = require_advanced.pingTransaction;
598
- exports.predictEntityKey = require_key.predictEntityKey;
599
- exports.randomSalt = require_key.randomSalt;
892
+ exports.key = require_attr.key;
893
+ exports.predictEntityKey = require_entity$1.predictEntityKey;
894
+ exports.randomSalt = require_entity$1.randomSalt;
600
895
  exports.resolveExpiry = require_expiry.resolveExpiry;
601
- exports.sendMutation = require_advanced.sendMutation;
602
- exports.str = require_attributes.str;
896
+ exports.str = require_attr.str;
603
897
  exports.stringToPayload = require_payload.stringToPayload;
604
898
  exports.toBlocks = require_expiry.toBlocks;
605
- exports.toValue = require_attributes.toValue;
606
- exports.u256 = require_attributes.u256;
607
- exports.u64 = require_attributes.u64;
608
- exports.validateAttributeName = require_attributes.validateAttributeName;
899
+ exports.toValue = require_attr.toValue;
900
+ exports.u256 = require_attr.u256;
901
+ exports.u64 = require_attr.u64;
902
+ exports.validateAttributeName = require_attr.validateAttributeName;