@arkiv-network/sdk 0.8.0-dev.1 → 0.8.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/attr/index.cjs +1 -1
  2. package/dist/attr/index.d.cts +1 -1
  3. package/dist/attr/index.d.ts +1 -1
  4. package/dist/attr/index.js +1 -1
  5. package/dist/{attr-BvxHN99W.cjs → attr-BXTkpnoc.cjs} +13 -3
  6. package/dist/{attr-BDZ-APg5.js → attr-tmyREHtw.js} +14 -4
  7. package/dist/attr-tmyREHtw.js.map +1 -0
  8. package/dist/chains/index.cjs +1 -1
  9. package/dist/chains/index.d.cts +3 -0
  10. package/dist/chains/index.d.cts.map +1 -1
  11. package/dist/chains/index.d.ts +3 -0
  12. package/dist/chains/index.d.ts.map +1 -1
  13. package/dist/chains/index.js +1 -1
  14. package/dist/{chains-BYRTTipa.cjs → chains-BfNQliHU.cjs} +3 -0
  15. package/dist/{chains-BJrZs6sG.js → chains-Du8tql7I.js} +4 -1
  16. package/dist/chains-Du8tql7I.js.map +1 -0
  17. package/dist/{changeOwnership-DwgtdSFc.d.ts → changeOwnership-B0ar96ub.d.ts} +47 -34
  18. package/dist/changeOwnership-B0ar96ub.d.ts.map +1 -0
  19. package/dist/{changeOwnership-B7bEgla4.d.cts → changeOwnership-BofkLnXJ.d.cts} +47 -34
  20. package/dist/changeOwnership-BofkLnXJ.d.cts.map +1 -0
  21. package/dist/entity/index.cjs +5 -4
  22. package/dist/entity/index.d.cts +2 -2
  23. package/dist/entity/index.d.ts +2 -2
  24. package/dist/entity/index.js +5 -5
  25. package/dist/{entity-CFhbAv0R.js → entity-CniBgBSd.js} +17 -5
  26. package/dist/entity-CniBgBSd.js.map +1 -0
  27. package/dist/{entity-wfBnZd91.cjs → entity-DJ0Gml9c.cjs} +23 -5
  28. package/dist/{errors-DGB8AgT2.js → errors-D2E1GRjw.js} +2 -2
  29. package/dist/errors-D2E1GRjw.js.map +1 -0
  30. package/dist/{errors-D-eJkGVc.cjs → errors-DhV00966.cjs} +1 -1
  31. package/dist/expiry-BxOlvVWC.d.ts.map +1 -1
  32. package/dist/{expiry-BUYIXTGb.cjs → expiry-CG9GhVXv.cjs} +1 -1
  33. package/dist/{expiry-DGRzrSan.js → expiry-Cgdb_dbq.js} +2 -2
  34. package/dist/expiry-Cgdb_dbq.js.map +1 -0
  35. package/dist/expiry-DRV29F1r.d.cts.map +1 -1
  36. package/dist/{flags-Ct8k0gpB.cjs → flags-DCD26uhe.cjs} +1 -1
  37. package/dist/{flags-ZtlvOIIk.js → flags-DUT2gHEU.js} +2 -2
  38. package/dist/{flags-ZtlvOIIk.js.map → flags-DUT2gHEU.js.map} +1 -1
  39. package/dist/{index-D0CmtiWT.d.cts → index-BGp2plHs.d.cts} +15 -5
  40. package/dist/index-BGp2plHs.d.cts.map +1 -0
  41. package/dist/{index-VCqgn29D.d.ts → index-BKB875Um.d.ts} +4 -4
  42. package/dist/{index-VCqgn29D.d.ts.map → index-BKB875Um.d.ts.map} +1 -1
  43. package/dist/{index-DVYFaXNV.d.ts → index-CIcHPx2j.d.cts} +13 -6
  44. package/dist/index-CIcHPx2j.d.cts.map +1 -0
  45. package/dist/{index-D8LZt-3J.d.cts → index-Cd2aaWme.d.ts} +13 -6
  46. package/dist/index-Cd2aaWme.d.ts.map +1 -0
  47. package/dist/{index-ClgIuxJ8.d.ts → index-ezMZ2-JH.d.ts} +15 -5
  48. package/dist/index-ezMZ2-JH.d.ts.map +1 -0
  49. package/dist/{index-Cgw1u5aY.d.cts → index-rINthNuU.d.cts} +4 -4
  50. package/dist/{index-Cgw1u5aY.d.cts.map → index-rINthNuU.d.cts.map} +1 -1
  51. package/dist/index.cjs +59 -50
  52. package/dist/index.d.cts +58 -50
  53. package/dist/index.d.cts.map +1 -1
  54. package/dist/index.d.ts +58 -50
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +59 -51
  57. package/dist/index.js.map +1 -1
  58. package/dist/{payload-Dgx3PQeK.d.ts → payload-CGvVPZQX.d.ts} +60 -1
  59. package/dist/payload-CGvVPZQX.d.ts.map +1 -0
  60. package/dist/{payload-CIxSn_DW.js → payload-DE7wMztL.js} +28 -3
  61. package/dist/payload-DE7wMztL.js.map +1 -0
  62. package/dist/{payload-P0nWyjLg.d.cts → payload-Dfu30njp.d.cts} +60 -1
  63. package/dist/payload-Dfu30njp.d.cts.map +1 -0
  64. package/dist/{payload-Bnw1hrvb.cjs → payload-DqFweqiO.cjs} +27 -2
  65. package/dist/query/index.cjs +4 -4
  66. package/dist/query/index.d.cts +3 -3
  67. package/dist/query/index.d.ts +3 -3
  68. package/dist/query/index.js +4 -4
  69. package/dist/{queryBuilder-CbLL4pG5.js → queryBuilder-COWt6aIF.js} +17 -12
  70. package/dist/queryBuilder-COWt6aIF.js.map +1 -0
  71. package/dist/{queryBuilder-BXDvX1K_.cjs → queryBuilder-DaLxNgeI.cjs} +16 -11
  72. package/dist/{selection-BvK6yX0g.d.cts → selection-Bv8_o-7i.d.cts} +16 -8
  73. package/dist/selection-Bv8_o-7i.d.cts.map +1 -0
  74. package/dist/{selection-fpmI3ADQ.d.ts → selection-ox7zdtVm.d.ts} +16 -8
  75. package/dist/selection-ox7zdtVm.d.ts.map +1 -0
  76. package/dist/types/index.d.cts +5 -5
  77. package/dist/types/index.d.ts +5 -5
  78. package/dist/utils/index.cjs +3 -3
  79. package/dist/utils/index.d.cts +1 -1
  80. package/dist/utils/index.d.ts +1 -1
  81. package/dist/utils/index.js +3 -3
  82. package/package.json +1 -5
  83. package/src/actions/public/getEntity.ts +1 -0
  84. package/src/actions/public/predictEntityKeys.test.ts +17 -1
  85. package/src/actions/public/predictEntityKeys.ts +28 -14
  86. package/src/actions/wallet/createEntity.ts +8 -6
  87. package/src/actions/wallet/{mutateEntities.test.ts → executeBatch.test.ts} +7 -7
  88. package/src/actions/wallet/{mutateEntities.ts → executeBatch.ts} +9 -9
  89. package/src/actions/wallet/extendEntity.ts +2 -0
  90. package/src/actions/wallet/patchEntity.ts +3 -3
  91. package/src/attr/attributes.ts +8 -2
  92. package/src/attr/errors.ts +2 -2
  93. package/src/attr/types.ts +3 -3
  94. package/src/attr/values.ts +5 -1
  95. package/src/chains/localhost.ts +3 -0
  96. package/src/clients/createPublicClient.test.ts +1 -1
  97. package/src/clients/createPublicClient.ts +5 -5
  98. package/src/clients/createWalletClient.test.ts +2 -2
  99. package/src/clients/createWalletClient.ts +3 -5
  100. package/src/clients/decorators/arkivPublic.ts +13 -12
  101. package/src/clients/decorators/arkivWallet.ts +40 -32
  102. package/src/entity/create.test.ts +20 -1
  103. package/src/entity/errors.ts +4 -3
  104. package/src/entity/expiry.ts +1 -0
  105. package/src/entity/index.ts +2 -1
  106. package/src/entity/key.ts +23 -3
  107. package/src/entity/operations.ts +1 -0
  108. package/src/errors.ts +7 -2
  109. package/src/query/errors.ts +1 -1
  110. package/src/query/expression.ts +14 -7
  111. package/src/query/queryBuilder.ts +1 -1
  112. package/src/types/index.ts +4 -4
  113. package/src/types/rpcSchema.ts +1 -0
  114. package/src/types/txParams.ts +8 -0
  115. package/src/utils/arkivTransactions.test.ts +7 -1
  116. package/src/utils/arkivTransactions.ts +10 -5
  117. package/src/utils/expirationTime.ts +39 -0
  118. package/src/utils/payload.ts +25 -0
  119. package/dist/attr-BDZ-APg5.js.map +0 -1
  120. package/dist/chains-BJrZs6sG.js.map +0 -1
  121. package/dist/changeOwnership-B7bEgla4.d.cts.map +0 -1
  122. package/dist/changeOwnership-DwgtdSFc.d.ts.map +0 -1
  123. package/dist/entity-CFhbAv0R.js.map +0 -1
  124. package/dist/errors-DGB8AgT2.js.map +0 -1
  125. package/dist/expiry-DGRzrSan.js.map +0 -1
  126. package/dist/index-ClgIuxJ8.d.ts.map +0 -1
  127. package/dist/index-D0CmtiWT.d.cts.map +0 -1
  128. package/dist/index-D8LZt-3J.d.cts.map +0 -1
  129. package/dist/index-DVYFaXNV.d.ts.map +0 -1
  130. package/dist/payload-CIxSn_DW.js.map +0 -1
  131. package/dist/payload-Dgx3PQeK.d.ts.map +0 -1
  132. package/dist/payload-P0nWyjLg.d.cts.map +0 -1
  133. package/dist/queryBuilder-CbLL4pG5.js.map +0 -1
  134. package/dist/selection-BvK6yX0g.d.cts.map +0 -1
  135. package/dist/selection-fpmI3ADQ.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- const require_attr = require('../attr-BvxHN99W.cjs');
1
+ const require_attr = require('../attr-BXTkpnoc.cjs');
2
2
 
3
3
  exports.ConflictingMutationError = require_attr.ConflictingMutationError;
4
4
  exports.DECIMAL_SCALE = require_attr.DECIMAL_SCALE;
@@ -1,2 +1,2 @@
1
- import { A as i32, B as Bytes32Value, C as ValueInput, D as dec, E as bytes32, F as u64, G as StrValue, H as DecValue, I as AddrValue, J as U64Value, K as TypeTag, L as AnyArkivValue, M as str, N as toValue, O as decFromUnits, P as u256, R as ArkivValue, S as U64_MAX, T as bool, U as I32Value, V as BytesValue, W as KeyValue, X as isArkivValue, Y as UserTypeTag, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, q as U256Value, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN, z as BoolValue } from "../index-D8LZt-3J.cjs";
1
+ import { A as i32, B as Bytes32Value, C as ValueInput, D as dec, E as bytes32, F as u64, G as StrValue, H as DecValue, I as AddrValue, J as U64Value, K as TypeTag, L as AnyArkivValue, M as str, N as toValue, O as decFromUnits, P as u256, R as ArkivValue, S as U64_MAX, T as bool, U as I32Value, V as BytesValue, W as KeyValue, X as isArkivValue, Y as UserTypeTag, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, q as U256Value, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN, z as BoolValue } from "../index-CIcHPx2j.cjs";
2
2
  export { AddrValue, AnyArkivValue, ArkivValue, AttributeInputs, AttributeSchema, Attributes, BoolValue, Bytes32Value, BytesValue, ConflictingMutationError, DECIMAL_SCALE, DECIMAL_UNIT, DecValue, I32Value, I32_MAX, I32_MIN, InvalidAttributeNameError, InvalidValueError, KeyValue, MAX_ATTRIBUTES, MAX_NAME_BYTES, MAX_PAYLOAD_BYTES, MAX_STRING_BYTES, MissingValueError, StrValue, TooManyAttributesError, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, UserTypeTag, ValueInput, addr, bool, bytes32, dec, decFromUnits, decUnits, i32, isArkivValue, isValidAttributeName, key, str, toValue, u256, u64, validateAttributeName };
@@ -1,2 +1,2 @@
1
- import { A as i32, B as Bytes32Value, C as ValueInput, D as dec, E as bytes32, F as u64, G as StrValue, H as DecValue, I as AddrValue, J as U64Value, K as TypeTag, L as AnyArkivValue, M as str, N as toValue, O as decFromUnits, P as u256, R as ArkivValue, S as U64_MAX, T as bool, U as I32Value, V as BytesValue, W as KeyValue, X as isArkivValue, Y as UserTypeTag, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, q as U256Value, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN, z as BoolValue } from "../index-DVYFaXNV.js";
1
+ import { A as i32, B as Bytes32Value, C as ValueInput, D as dec, E as bytes32, F as u64, G as StrValue, H as DecValue, I as AddrValue, J as U64Value, K as TypeTag, L as AnyArkivValue, M as str, N as toValue, O as decFromUnits, P as u256, R as ArkivValue, S as U64_MAX, T as bool, U as I32Value, V as BytesValue, W as KeyValue, X as isArkivValue, Y as UserTypeTag, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, q as U256Value, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN, z as BoolValue } from "../index-Cd2aaWme.js";
2
2
  export { AddrValue, AnyArkivValue, ArkivValue, AttributeInputs, AttributeSchema, Attributes, BoolValue, Bytes32Value, BytesValue, ConflictingMutationError, DECIMAL_SCALE, DECIMAL_UNIT, DecValue, I32Value, I32_MAX, I32_MIN, InvalidAttributeNameError, InvalidValueError, KeyValue, MAX_ATTRIBUTES, MAX_NAME_BYTES, MAX_PAYLOAD_BYTES, MAX_STRING_BYTES, MissingValueError, StrValue, TooManyAttributesError, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, UserTypeTag, ValueInput, addr, bool, bytes32, dec, decFromUnits, decUnits, i32, isArkivValue, isValidAttributeName, key, str, toValue, u256, u64, validateAttributeName };
@@ -1,3 +1,3 @@
1
- import { A as DECIMAL_UNIT, C as str, E as u64, F as TooManyAttributesError, I as UnknownAttributeTypeError, L as UntypedValueError, M as InvalidAttributeNameError, N as InvalidValueError, O as isArkivValue, P as MissingValueError, S as key, T as u256, _ as bytes32, a as MAX_NAME_BYTES, b as decUnits, d as I32_MIN, f as MAX_STRING_BYTES, g as bool, h as addr, j as ConflictingMutationError, k as DECIMAL_SCALE, m as U64_MAX, n as MAX_PAYLOAD_BYTES, o as isValidAttributeName, p as U256_MAX, s as validateAttributeName, t as MAX_ATTRIBUTES, u as I32_MAX, v as dec, w as toValue, x as i32, y as decFromUnits } from "../attr-BDZ-APg5.js";
1
+ import { A as DECIMAL_UNIT, C as str, E as u64, F as TooManyAttributesError, I as UnknownAttributeTypeError, L as UntypedValueError, M as InvalidAttributeNameError, N as InvalidValueError, O as isArkivValue, P as MissingValueError, S as key, T as u256, _ as bytes32, a as MAX_NAME_BYTES, b as decUnits, d as I32_MIN, f as MAX_STRING_BYTES, g as bool, h as addr, j as ConflictingMutationError, k as DECIMAL_SCALE, m as U64_MAX, n as MAX_PAYLOAD_BYTES, o as isValidAttributeName, p as U256_MAX, s as validateAttributeName, t as MAX_ATTRIBUTES, u as I32_MAX, v as dec, w as toValue, x as i32, y as decFromUnits } from "../attr-tmyREHtw.js";
2
2
 
3
3
  export { ConflictingMutationError, DECIMAL_SCALE, DECIMAL_UNIT, I32_MAX, I32_MIN, InvalidAttributeNameError, InvalidValueError, MAX_ATTRIBUTES, MAX_NAME_BYTES, MAX_PAYLOAD_BYTES, MAX_STRING_BYTES, MissingValueError, TooManyAttributesError, U256_MAX, U64_MAX, UnknownAttributeTypeError, UntypedValueError, addr, bool, bytes32, dec, decFromUnits, decUnits, i32, isArkivValue, isValidAttributeName, key, str, toValue, u256, u64, validateAttributeName };
@@ -28,7 +28,7 @@ var InvalidValueError = class extends Error {
28
28
  var UntypedValueError = class extends Error {
29
29
  input;
30
30
  constructor(input) {
31
- super(`Cannot infer an Arkiv type for ${describe(input)}. Attribute values must be a tagged value (i32, u256, dec, str, addr, key, bytes32, bool) or a bare boolean, number, bigint or string.`);
31
+ super(`Cannot infer an Arkiv type for ${describe(input)}. Attribute values must be a tagged value (i32, u64, u256, dec, str, addr, key, bytes32, bool) or a bare boolean, number, bigint or string.`);
32
32
  this.name = "UntypedValueError";
33
33
  this.input = input;
34
34
  }
@@ -391,7 +391,11 @@ function decFromUnits(units) {
391
391
  *
392
392
  * The limit is on **bytes**, not characters: a string of 128 emoji does not fit.
393
393
  *
394
- * @throws {InvalidValueError} If the string exceeds 128 UTF-8 bytes.
394
+ * C0 control characters and DEL are rejected: the query language writes a `str` as `str('...')`,
395
+ * whose only escape is a doubled quote, so a control character could be stored but never queried.
396
+ *
397
+ * @throws {InvalidValueError} If the value is not a string, holds a control character, or exceeds
398
+ * 128 UTF-8 bytes.
395
399
  *
396
400
  * @example
397
401
  * str("Bob")
@@ -716,6 +720,10 @@ function isValidAttributeName(name) {
716
720
  * The most attribute cells one operation may carry.
717
721
  */
718
722
  const MAX_ATTRIBUTES = 32;
723
+ /**
724
+ * The largest payload an entity may carry, in bytes. The payload travels as the `$payload` system
725
+ * cell, so this is a bound on that one attribute rather than on the operation as a whole.
726
+ */
719
727
  const MAX_PAYLOAD_BYTES = 128 * 1024;
720
728
  /** The system attribute holding an entity's opaque payload. */
721
729
  const PAYLOAD_CELL = "$payload";
@@ -767,8 +775,10 @@ function encodeAttributes(attributes = {}, system = {}) {
767
775
  *
768
776
  * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.
769
777
  * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
778
+ * @throws {MissingValueError} If a value is `undefined` or `null`.
770
779
  * @throws {InvalidValueError} If a value does not fit its type.
771
- * @throws {TooManyAttributesError} If `set` names more than {@link MAX_ATTRIBUTES} attributes.
780
+ * @throws {TooManyAttributesError} If the mutations exceed {@link MAX_ATTRIBUTES}.
781
+ * @throws {TypeError} If `unset` is not an array.
772
782
  */
773
783
  function encodeMutations({ set, unset, payload, contentType }) {
774
784
  const written = encodeAttributes(set, {
@@ -28,7 +28,7 @@ var InvalidValueError = class extends Error {
28
28
  var UntypedValueError = class extends Error {
29
29
  input;
30
30
  constructor(input) {
31
- super(`Cannot infer an Arkiv type for ${describe(input)}. Attribute values must be a tagged value (i32, u256, dec, str, addr, key, bytes32, bool) or a bare boolean, number, bigint or string.`);
31
+ super(`Cannot infer an Arkiv type for ${describe(input)}. Attribute values must be a tagged value (i32, u64, u256, dec, str, addr, key, bytes32, bool) or a bare boolean, number, bigint or string.`);
32
32
  this.name = "UntypedValueError";
33
33
  this.input = input;
34
34
  }
@@ -391,7 +391,11 @@ function decFromUnits(units) {
391
391
  *
392
392
  * The limit is on **bytes**, not characters: a string of 128 emoji does not fit.
393
393
  *
394
- * @throws {InvalidValueError} If the string exceeds 128 UTF-8 bytes.
394
+ * C0 control characters and DEL are rejected: the query language writes a `str` as `str('...')`,
395
+ * whose only escape is a doubled quote, so a control character could be stored but never queried.
396
+ *
397
+ * @throws {InvalidValueError} If the value is not a string, holds a control character, or exceeds
398
+ * 128 UTF-8 bytes.
395
399
  *
396
400
  * @example
397
401
  * str("Bob")
@@ -716,6 +720,10 @@ function isValidAttributeName(name) {
716
720
  * The most attribute cells one operation may carry.
717
721
  */
718
722
  const MAX_ATTRIBUTES = 32;
723
+ /**
724
+ * The largest payload an entity may carry, in bytes. The payload travels as the `$payload` system
725
+ * cell, so this is a bound on that one attribute rather than on the operation as a whole.
726
+ */
719
727
  const MAX_PAYLOAD_BYTES = 128 * 1024;
720
728
  /** The system attribute holding an entity's opaque payload. */
721
729
  const PAYLOAD_CELL = "$payload";
@@ -767,8 +775,10 @@ function encodeAttributes(attributes = {}, system = {}) {
767
775
  *
768
776
  * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.
769
777
  * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
778
+ * @throws {MissingValueError} If a value is `undefined` or `null`.
770
779
  * @throws {InvalidValueError} If a value does not fit its type.
771
- * @throws {TooManyAttributesError} If `set` names more than {@link MAX_ATTRIBUTES} attributes.
780
+ * @throws {TooManyAttributesError} If the mutations exceed {@link MAX_ATTRIBUTES}.
781
+ * @throws {TypeError} If `unset` is not an array.
772
782
  */
773
783
  function encodeMutations({ set, unset, payload, contentType }) {
774
784
  const written = encodeAttributes(set, {
@@ -806,4 +816,4 @@ function toHexBytes(bytes) {
806
816
 
807
817
  //#endregion
808
818
  export { DECIMAL_UNIT as A, str as C, TYPE_IDS as D, u64 as E, TooManyAttributesError as F, UnknownAttributeTypeError as I, UntypedValueError as L, InvalidAttributeNameError as M, InvalidValueError as N, isArkivValue as O, MissingValueError as P, key as S, u256 as T, bytes32 as _, MAX_NAME_BYTES as a, decUnits as b, asTypeTag as c, I32_MIN as d, MAX_STRING_BYTES as f, bool as g, addr as h, encodeMutations as i, ConflictingMutationError as j, DECIMAL_SCALE as k, decodeRpcValue as l, U64_MAX as m, MAX_PAYLOAD_BYTES as n, isValidAttributeName as o, U256_MAX as p, encodeAttributes as r, validateAttributeName as s, MAX_ATTRIBUTES as t, I32_MAX as u, dec as v, toValue as w, i32 as x, decFromUnits as y };
809
- //# sourceMappingURL=attr-BDZ-APg5.js.map
819
+ //# sourceMappingURL=attr-tmyREHtw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr-tmyREHtw.js","names":["size","resolved: Record<string, ArkivValue>","cells: [string, AnyArkivValue][]"],"sources":["../src/attr/errors.ts","../src/attr/decimal.ts","../src/attr/types.ts","../src/attr/values.ts","../src/attr/codec.ts","../src/attr/names.ts","../src/attr/attributes.ts"],"sourcesContent":["import type { TypeTag } from \"./types\"\n\n/**\n * A value was rejected by its tagged constructor — out of range, wrong length, bad checksum, too\n * much precision, and so on.\n *\n * The message names the offending value and, where there is one, the type that *would* hold it, so\n * the fix is in the error rather than in the docs.\n */\nexport class InvalidValueError extends Error {\n /** The type tag whose constructor rejected the value. */\n readonly tag: TypeTag\n /** The rejected input, as given. */\n readonly input: unknown\n\n constructor(tag: TypeTag, input: unknown, reason: string, hint?: string) {\n super(`Invalid ${tag} value ${describe(input)}: ${reason}.${hint ? ` ${hint}` : \"\"}`)\n this.name = \"InvalidValueError\"\n this.tag = tag\n this.input = input\n }\n}\n\n/**\n * A bare JavaScript value could not be given a type. Raised when an attribute or predicate is\n * handed something that is neither a tagged value nor one of the four bare forms\n * (`boolean`, `number`, `bigint`, `string`).\n */\nexport class UntypedValueError extends Error {\n readonly input: unknown\n\n constructor(input: unknown) {\n super(\n `Cannot infer an Arkiv type for ${describe(input)}. ` +\n \"Attribute values must be a tagged value (i32, u64, u256, dec, str, addr, key, bytes32, \" +\n \"bool) or a bare boolean, number, bigint or string.\",\n )\n this.name = \"UntypedValueError\"\n this.input = input\n }\n}\n\n/**\n * An attribute was given `undefined` or `null` as its value.\n *\n * There is no such thing as an attribute with no value: an attribute either exists with a type, or\n * is not set. The fix is always to leave the name out of the map rather than to write an empty\n * value, so this is called out separately from {@link UntypedValueError} — the remedy is different.\n */\nexport class MissingValueError extends Error {\n /** The attribute whose value was missing, when raised from an attribute map. */\n readonly attributeName: string | undefined\n\n constructor(input: null | undefined, attributeName?: string) {\n const subject = attributeName ? `attribute \"${attributeName}\"` : \"attribute value\"\n super(\n `The ${subject} is ${input === null ? \"null\" : \"undefined\"}. An attribute is either set ` +\n \"with a value and a type or not set at all, so there is nothing to write here. \" +\n (attributeName\n ? `Omit \"${attributeName}\" from the attributes instead — e.g. build the map ` +\n \"conditionally, or drop the key when the value is absent.\"\n : \"Omit the attribute instead of giving it an empty value.\"),\n )\n this.name = \"MissingValueError\"\n this.attributeName = attributeName\n }\n}\n\n/** An attribute name violated the on-chain name grammar. */\nexport class InvalidAttributeNameError extends Error {\n readonly attributeName: string\n\n constructor(attributeName: string, reason: string) {\n super(\n `Invalid attribute name \"${attributeName}\": ${reason}. Names must be 1-32 bytes, start with ` +\n 'a letter, and contain only A-Z, a-z, 0-9, \".\", \"-\" or \"_\". Names are case-sensitive.',\n )\n this.name = \"InvalidAttributeNameError\"\n this.attributeName = attributeName\n }\n}\n\n/**\n * One patch tried to both write and remove the same attribute.\n */\nexport class ConflictingMutationError extends Error {\n readonly attributeName: string\n\n constructor(attributeName: string) {\n super(\n `The patch both sets and unsets \"${attributeName}\". A patch applies one mutation per ` +\n 'attribute, so say which you mean: drop it from \"unset\" to write the value, or from ' +\n '\"set\" to remove the attribute.',\n )\n this.name = \"ConflictingMutationError\"\n this.attributeName = attributeName\n }\n}\n\n/** More attributes were supplied than an entity operation can carry. */\nexport class TooManyAttributesError extends Error {\n constructor(count: number, max: number) {\n super(`An entity may carry at most ${max} attributes, got ${count}.`)\n this.name = \"TooManyAttributesError\"\n }\n}\n\n/** The node sent back an attribute this SDK cannot decode. */\nexport class UnknownAttributeTypeError extends Error {\n /** The type as the node named it — a tag over JSON-RPC, a typeId on the wire. */\n readonly type: string | number\n\n constructor(type: string | number) {\n super(\n `Unknown attribute type ${describe(type)}. The node is using a type this SDK version does ` +\n \"not know about — upgrade @arkiv-network/sdk.\",\n )\n this.name = \"UnknownAttributeTypeError\"\n this.type = type\n }\n}\n\n/** Renders an arbitrary input for an error message, without ever throwing. */\nfunction describe(input: unknown): string {\n switch (typeof input) {\n case \"string\":\n return JSON.stringify(input.length > 64 ? `${input.slice(0, 61)}...` : input)\n case \"bigint\":\n return `${input}n`\n case \"object\":\n return input === null ? \"null\" : safeJson(input)\n case \"undefined\":\n return \"undefined\"\n default:\n return String(input)\n }\n}\n\nfunction safeJson(input: object): string {\n try {\n return JSON.stringify(input) ?? String(input)\n } catch {\n return Object.prototype.toString.call(input)\n }\n}\n","import { InvalidValueError } from \"./errors\"\n\n/**\n * Decimal places a `dec` value is scaled by. Fixed by the protocol, so any two decimals are\n * directly comparable — and range-indexable — as plain integers.\n */\nexport const DECIMAL_SCALE = 18\n\n/** 10 ** {@link DECIMAL_SCALE} — the scaling factor between a `dec` and its integer units. */\nexport const DECIMAL_UNIT = 10n ** BigInt(DECIMAL_SCALE)\n\n/** The widest scaled value an `int256` holds. */\nconst INT256_MAX = 2n ** 255n - 1n\n/** The narrowest scaled value an `int256` holds. */\nconst INT256_MIN = -(2n ** 255n)\n\n/**\n * A decimal literal: an optional sign, at least one integer digit, and an optional fraction of at\n * most {@link DECIMAL_SCALE} digits. Exponents are not part of the grammar — `1e18` is a parse\n * error rather than a silent reinterpretation.\n */\nconst DECIMAL_RE = /^([+-]?)(\\d+)(?:\\.(\\d+))?$/\n\n/**\n * Parses a decimal literal into its scaled integer units.\n *\n * Excess fractional precision is an **error, never a rounding**: the protocol stores exactly 18\n * decimal places, and silently dropping the 19th digit would make a stored value differ from the\n * one that was written.\n *\n * @param input - The decimal literal, e.g. `\"3.5\"` or `\"-0.000001\"`.\n * @returns The value scaled by 10 ** 18.\n * @throws {InvalidValueError} If the literal is malformed, too precise, or out of `int256` range.\n */\nexport function decimalToUnits(input: string): bigint {\n const match = DECIMAL_RE.exec(input)\n if (!match) {\n throw new InvalidValueError(\n \"dec\",\n input,\n \"not a decimal literal\",\n 'Write it as sign, digits, and an optional \".\" with up to 18 fractional digits — e.g. ' +\n 'dec(\"3.5\") or dec(\"-0.25\"). Exponents such as \"1e18\" are not accepted.',\n )\n }\n\n const [, sign, whole, fraction = \"\"] = match\n if (fraction.length > DECIMAL_SCALE) {\n throw new InvalidValueError(\n \"dec\",\n input,\n `${fraction.length} fractional digits exceeds the ${DECIMAL_SCALE} the protocol stores`,\n \"Round it yourself before storing — a dec is never rounded for you, so that what you \" +\n \"write is exactly what is stored.\",\n )\n }\n\n const digits = BigInt(whole + fraction.padEnd(DECIMAL_SCALE, \"0\"))\n const units = sign === \"-\" ? -digits : digits\n if (units > INT256_MAX || units < INT256_MIN) {\n throw new InvalidValueError(\"dec\", input, \"exceeds the int256 range a dec is stored in\")\n }\n return units\n}\n\n/**\n * Renders scaled integer units back as a canonical decimal string: no leading zeros, no trailing\n * fractional zeros, no `-0`. Parsing the result yields the same units, so this is the inverse of\n * {@link decimalToUnits} on every value it accepts.\n *\n * @param units - The value scaled by 10 ** 18.\n * @returns The canonical decimal string, e.g. `\"3.5\"`.\n * @throws {InvalidValueError} If the units are outside the `int256` range.\n */\nexport function unitsToDecimal(units: bigint): string {\n if (units > INT256_MAX || units < INT256_MIN) {\n throw new InvalidValueError(\"dec\", units, \"exceeds the int256 range a dec is stored in\")\n }\n const negative = units < 0n\n const magnitude = negative ? -units : units\n const whole = magnitude / DECIMAL_UNIT\n const fraction = (magnitude % DECIMAL_UNIT).toString().padStart(DECIMAL_SCALE, \"0\")\n const trimmed = fraction.replace(/0+$/, \"\")\n const sign = negative ? \"-\" : \"\"\n return trimmed ? `${sign}${whole}.${trimmed}` : `${sign}${whole}`\n}\n","import type { Address, Hex } from \"viem\"\nimport type { decUnits } from \"./values\"\n\n/**\n * The protocol's attribute type vocabulary, mapping each short **tag** (the name used by the\n * client, the query language and this SDK) to its **typeId** (the byte carried on the wire and in\n * the entity record).\n *\n * The typeIds are consensus-critical: they are written into entity records and mixed into index\n * keys, so this table must never drift from the node's `AttributeType`.\n *\n * | tag | typeId | ABI wire type | indexing |\n * | --------- | ------ | ------------------- | ----------------- |\n * | `bool` | 1 | `bool` | equality |\n * | `i32` | 2 | `int32` | equality + range |\n * | `u64` | 3 | `uint64` | equality + range |\n * | `u256` | 4 | `uint256` | equality + range |\n * | `dec` | 5 | `int256` (18 dp) | equality + range |\n * | `bytes32` | 6 | `bytes32` | equality |\n * | `bytes` | 7 | `bytes` | none — system-only |\n * | `str` | 8 | `string` (<= 128 B) | equality + prefix |\n * | `addr` | 9 | `address` | equality |\n * | `key` | 10 | `bytes32` | equality |\n */\nexport const TYPE_IDS = {\n bool: 1,\n i32: 2,\n u64: 3,\n u256: 4,\n dec: 5,\n bytes32: 6,\n bytes: 7,\n str: 8,\n addr: 9,\n key: 10,\n} as const\n\n/** Every type tag, including the system-only `bytes`. */\nexport type TypeTag = keyof typeof TYPE_IDS\n\n/** Every typeId, including the system-only `7` (`bytes`). */\nexport type TypeId = (typeof TYPE_IDS)[TypeTag]\n\n/**\n * The tags a client may set on an attribute. `bytes` is excluded: it backs the system `$payload`\n * cell, which travels in its own operation field and is never carried in an attribute array.\n */\nexport type UserTypeTag = Exclude<TypeTag, \"bytes\">\n\n/** Whether a client may set an attribute of this type — everything except `bytes`. */\nexport function isUserSettable(tag: TypeTag): tag is UserTypeTag {\n return tag !== \"bytes\"\n}\n\n/**\n * Marks a value as having passed its constructor's validation. The symbol is module-private, so a\n * hand-written object literal is not assignable to {@link ArkivValue} — every value crossing the\n * wire has been range-, length- and format-checked by `i32`, `u256`, `dec`, and friends.\n */\ndeclare const validated: unique symbol\n\n/**\n * A typed attribute value: the tag it was created with, plus the JavaScript representation of that\n * type. Constructed only by the tagged constructors in `@arkiv-network/sdk/attr`.\n *\n * @typeParam tag - The type tag, which also discriminates the {@link ArkivValue} union.\n * @typeParam value - The decoded JavaScript representation.\n */\nexport type Value<tag extends TypeTag, value> = {\n readonly type: tag\n readonly value: value\n readonly [validated]: tag\n}\n\n/** A boolean. */\nexport type BoolValue = Value<\"bool\", boolean>\n/** A 32-bit signed integer — the default for an untagged number. */\nexport type I32Value = Value<\"i32\", number>\n/**\n * A 64-bit unsigned integer — block heights, the\n * entity-nonce and `$expiresAt` are all `u64` */\nexport type U64Value = Value<\"u64\", bigint>\n/** A 256-bit unsigned integer. */\nexport type U256Value = Value<\"u256\", bigint>\n/**\n * A fixed-point decimal with 18 decimal places, held as its canonical decimal string (`\"3.5\"`).\n * Use {@link decUnits} for the exact scaled integer when you need to do arithmetic.\n */\nexport type DecValue = Value<\"dec\", string>\n/** 32 opaque bytes, as lowercase `0x` hex. */\nexport type Bytes32Value = Value<\"bytes32\", Hex>\n/** A UTF-8 string of at most 128 bytes, free of C0 control characters and DEL. */\nexport type StrValue = Value<\"str\", string>\n/** A 20-byte Ethereum address, as EIP-55 checksummed hex. */\nexport type AddrValue = Value<\"addr\", Address>\n/** A reference to another entity. Weak by spec: dangling references are permitted. */\nexport type KeyValue = Value<\"key\", Hex>\n/**\n * Opaque variable-length bytes, as lowercase `0x` hex. System-only — it backs `$payload` and is\n * never settable as an attribute, so it is produced by decoding but has no constructor.\n */\nexport type BytesValue = Value<\"bytes\", Hex>\n\n/** Any value a client may set on an attribute. */\nexport type ArkivValue =\n | BoolValue\n | I32Value\n | U64Value\n | U256Value\n | DecValue\n | Bytes32Value\n | StrValue\n | AddrValue\n | KeyValue\n\n/** Any value that can come back from the node, including the system-only `bytes`. */\nexport type AnyArkivValue = ArkivValue | BytesValue\n\n/** The value type for a given tag — e.g. `ValueOf<\"u256\">` is {@link U256Value}. */\nexport type ValueOf<tag extends TypeTag> = Extract<AnyArkivValue, { type: tag }>\n\n/** The JavaScript representation carried by a value — e.g. `Decoded<U256Value>` is `bigint`. */\nexport type Decoded<value extends AnyArkivValue> = value[\"value\"]\n\n/**\n * Builds a validated value. Module-internal: the constructors in `values.ts` call this **after**\n * validating, which is what makes the {@link validated} brand meaningful.\n */\nexport function makeValue<tag extends TypeTag>(\n type: tag,\n value: Decoded<ValueOf<tag>>,\n): ValueOf<tag> {\n return { type, value } as unknown as ValueOf<tag>\n}\n\n/**\n * Whether `input` has the *shape* of an {@link ArkivValue} — a known type tag and a value.\n */\nexport function isArkivValue(input: unknown): input is AnyArkivValue {\n return (\n typeof input === \"object\" &&\n input !== null &&\n \"type\" in input &&\n \"value\" in input &&\n typeof (input as { type: unknown }).type === \"string\" &&\n // `Object.hasOwn`, not `in`: `in` walks the prototype chain, so `{ type: \"constructor\" }` would\n // be accepted as a typed value and then decode to nothing.\n Object.hasOwn(TYPE_IDS, (input as { type: string }).type)\n )\n}\n","import {\n type Address,\n checksumAddress,\n type Hex,\n isAddress,\n isHex,\n stringToBytes,\n toHex,\n} from \"viem\"\nimport { DECIMAL_UNIT, decimalToUnits, unitsToDecimal } from \"./decimal\"\nimport { InvalidValueError, MissingValueError, UntypedValueError } from \"./errors\"\nimport {\n type AddrValue,\n type AnyArkivValue,\n type ArkivValue,\n type BoolValue,\n type Bytes32Value,\n type BytesValue,\n type DecValue,\n type I32Value,\n isArkivValue,\n type KeyValue,\n makeValue,\n type StrValue,\n type U64Value,\n type U256Value,\n} from \"./types\"\n\n/** The widest `i32`. */\nexport const I32_MAX = 2147483647\n/** The narrowest `i32`. */\nexport const I32_MIN = -2147483648\n/** The widest `u64`. */\nexport const U64_MAX = 2n ** 64n - 1n\n/** The widest `u256`. */\nexport const U256_MAX = 2n ** 256n - 1n\n/**\n * The longest `str`, in UTF-8 bytes\n */\nexport const MAX_STRING_BYTES = 128\n\n/**\n * Finds the first C0 control or DEL — the characters a `str` may not contain.\n */\nfunction findControlChar(value: string): { index: number; code: number } | undefined {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index)\n if (code <= 0x1f || code === 0x7f) return { index, code }\n }\n return undefined\n}\n\n/**\n * A boolean.\n *\n * `bool` is the one type that may also be written bare — `{ flagged: true }` and\n * `{ flagged: bool(true) }` are the same attribute.\n *\n * @example\n * bool(true) // { type: \"bool\", value: true }\n */\nexport function bool(value: boolean): BoolValue {\n if (typeof value !== \"boolean\") {\n throw new InvalidValueError(\"bool\", value, \"not a boolean\")\n }\n return makeValue(\"bool\", value)\n}\n\n/**\n * A 32-bit signed integer, indexed for equality and range queries. This is the default type for a\n * bare number, so `{ level: 10 }` and `{ level: i32(10) }` are the same attribute.\n *\n * @param value - An integer in [-2147483648, 2147483647].\n * @throws {InvalidValueError} If the value is not an integer, or does not fit an `i32`.\n *\n * @example\n * i32(10) // { type: \"i32\", value: 10 }\n * i32(-42) // negative values are fine — i32 is the signed integer\n */\nexport function i32(value: number | bigint): I32Value {\n if (typeof value === \"bigint\") {\n if (value > BigInt(I32_MAX) || value < BigInt(I32_MIN)) {\n throw new InvalidValueError(\"i32\", value, outOfI32Range(value >= 0n))\n }\n return makeValue(\"i32\", Number(value))\n }\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new InvalidValueError(\"i32\", value, \"not a number\")\n }\n if (!Number.isInteger(value)) {\n throw new InvalidValueError(\n \"i32\",\n value,\n \"not an integer\",\n `Use dec(${JSON.stringify(String(value))}) for a fixed-point decimal.`,\n )\n }\n if (value > I32_MAX || value < I32_MIN) {\n throw new InvalidValueError(\"i32\", value, outOfI32Range(value >= 0))\n }\n return makeValue(\"i32\", value)\n}\n\nfunction outOfI32Range(nonNegative: boolean): string {\n const range = `outside the i32 range [${I32_MIN}, ${I32_MAX}]`\n return nonNegative\n ? `${range} — use u64(...) for large counters, timestamps and block heights (Date.now() does ` +\n `not fit an i32), or u256(...) beyond 2**64 - 1`\n : `${range} — use dec(...) for values that need more range than an i32`\n}\n\n/**\n * A 256-bit unsigned integer, indexed for equality and range queries. The type for token amounts\n * and anything else that can outgrow 2⁶⁴ — reach for {@link u64} first for counters, timestamps\n * and block heights.\n *\n * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex\n * string.\n * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 256 bits.\n *\n * @example\n * u256(1_000_000n)\n * u256(Date.now()) // safe integers are accepted\n * u256(\"0xf4240\") // hex, as it comes back over JSON-RPC\n */\nexport function u256(value: bigint | number | string): U256Value {\n return makeValue(\"u256\", toUnsigned(\"u256\", value, U256_MAX))\n}\n\n/**\n * A 64-bit unsigned integer, indexed for equality and range queries.\n *\n * This is the width the protocol counts in: block heights, `$expiresAt` and the entity-nonce are\n * all `u64`, so it is the type to reach for when a value has to line up with one of them. Use\n * {@link u256} for token amounts and anything else that can exceed 2⁶⁴.\n *\n * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex\n * string.\n * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 64 bits.\n *\n * @example\n * u64(1_200_000n) // a block height\n * u64(Date.now()) // safe integers are accepted\n * u64(\"0x124f80\") // hex, as it comes back over JSON-RPC\n */\nexport function u64(value: bigint | number | string): U64Value {\n return makeValue(\"u64\", toUnsigned(\"u64\", value, U64_MAX))\n}\n\n/**\n * Parses and range-checks an unsigned integer for `tag`, whose widest value is `max`.\n *\n * Shared by {@link u64} and {@link u256} so the two differ in exactly one thing — their width —\n * rather than in how they read a string or how they explain a failure.\n */\nfunction toUnsigned(tag: \"u64\" | \"u256\", value: bigint | number | string, max: bigint): bigint {\n const parsed = toUnsignedBigint(tag, value)\n if (parsed < 0n) {\n throw new InvalidValueError(\n tag,\n value,\n `negative — ${tag} is unsigned`,\n \"Use i32(...) for small signed integers, or dec(...) for a signed fixed-point value.\",\n )\n }\n if (parsed > max) {\n const bits = tag === \"u64\" ? 64 : 256\n throw new InvalidValueError(\n tag,\n value,\n `wider than ${bits} bits`,\n tag === \"u64\" ? \"Use u256(...) for values beyond 2**64 - 1.\" : undefined,\n )\n }\n return parsed\n}\n\nfunction toUnsignedBigint(tag: \"u64\" | \"u256\", value: bigint | number | string): bigint {\n if (typeof value === \"bigint\") return value\n if (typeof value === \"number\") {\n if (!Number.isInteger(value)) {\n throw new InvalidValueError(\n tag,\n value,\n \"not an integer\",\n `Use dec(${JSON.stringify(String(value))}) for a fixed-point decimal.`,\n )\n }\n if (!Number.isSafeInteger(value)) {\n throw new InvalidValueError(\n tag,\n value,\n \"beyond the safe integer range, so it may already have lost precision\",\n \"Pass it as a bigint literal (e.g. 12345678901234567890n) or a string instead.\",\n )\n }\n return BigInt(value)\n }\n if (typeof value === \"string\") {\n if (!/^(0x[0-9a-fA-F]+|\\d+)$/.test(value)) {\n throw new InvalidValueError(tag, value, \"not a decimal or 0x-hex integer\")\n }\n return BigInt(value)\n }\n throw new InvalidValueError(tag, value, \"not a bigint, number or string\")\n}\n\n/**\n * A signed fixed-point decimal with exactly 18 decimal places, indexed for equality and range\n * queries.\n *\n * Pass fractional values as **strings**. A JavaScript number cannot represent most decimals\n * exactly, so accepting `dec(0.1 + 0.2)` would quietly store `0.30000000000000004`; requiring the\n * string keeps what you write and what is stored the same thing. Excess precision is likewise an\n * error rather than a rounding.\n *\n * @param value - A decimal string, or an integral `number` / `bigint`.\n * @throws {InvalidValueError} If the value is malformed, has more than 18 fractional digits, or\n * falls outside the `int256` range.\n *\n * @example\n * dec(\"3.5\")\n * dec(\"-0.000000000000000001\") // the smallest step\n * dec(5) // integers may be passed bare\n */\nexport function dec(value: string | number | bigint): DecValue {\n if (typeof value === \"string\") {\n return makeValue(\"dec\", unitsToDecimal(decimalToUnits(value)))\n }\n if (typeof value === \"bigint\") {\n return decFromUnits(value * DECIMAL_UNIT)\n }\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new InvalidValueError(\"dec\", value, \"not a number\")\n }\n if (!Number.isInteger(value)) {\n throw new InvalidValueError(\n \"dec\",\n value,\n \"a fractional number cannot be represented exactly in binary floating point\",\n `Pass it as a string instead: dec(${JSON.stringify(String(value))}).`,\n )\n }\n return decFromUnits(BigInt(value) * DECIMAL_UNIT)\n}\n\n/**\n * The exact scaled integer behind a `dec` — the value multiplied by 10 ** 18, which is what the\n * protocol stores and compares. Use it when you need exact arithmetic; JavaScript has no native\n * decimal type, so the SDK carries the canonical string and leaves the maths to you.\n *\n * @example\n * decUnits(dec(\"3.5\")) // 3500000000000000000n\n */\nexport function decUnits(value: DecValue): bigint {\n return decimalToUnits(value.value)\n}\n\n/**\n * A `dec` built from its scaled integer units — the inverse of {@link decUnits}.\n *\n * @example\n * decFromUnits(3_500_000_000_000_000_000n) // dec(\"3.5\")\n */\nexport function decFromUnits(units: bigint): DecValue {\n return makeValue(\"dec\", unitsToDecimal(units))\n}\n\n/**\n * A UTF-8 string of at most 128 bytes, indexed for equality and prefix (`STARTSWITH`) matching.\n *\n * The limit is on **bytes**, not characters: a string of 128 emoji does not fit.\n *\n * C0 control characters and DEL are rejected: the query language writes a `str` as `str('...')`,\n * whose only escape is a doubled quote, so a control character could be stored but never queried.\n *\n * @throws {InvalidValueError} If the value is not a string, holds a control character, or exceeds\n * 128 UTF-8 bytes.\n *\n * @example\n * str(\"Bob\")\n */\nexport function str(value: string): StrValue {\n if (typeof value !== \"string\") {\n throw new InvalidValueError(\"str\", value, \"not a string\")\n }\n const control = findControlChar(value)\n if (control !== undefined) {\n const code = control.code.toString(16).padStart(4, \"0\").toUpperCase()\n throw new InvalidValueError(\n \"str\",\n value,\n `contains the control character U+${code} at index ${control.index}`,\n \"A str is written into a query as str('...'), whose only escape is a doubled quote — there \" +\n \"is no spelling for a control character, so this value could be stored but never queried. \" +\n \"Free-form text belongs in the entity payload; keep a short, printable key here.\",\n )\n }\n const bytes = stringToBytes(value).length\n if (bytes > MAX_STRING_BYTES) {\n throw new InvalidValueError(\n \"str\",\n value,\n `${bytes} UTF-8 bytes exceeds the ${MAX_STRING_BYTES}-byte limit on a str`,\n \"Store the long form in the entity payload and keep a short, queryable key here.\",\n )\n }\n return makeValue(\"str\", value)\n}\n\n/**\n * A 20-byte Ethereum address, indexed for equality.\n *\n * All-lowercase and all-uppercase input carries no checksum and is accepted as-is; mixed-case\n * input is checked against its EIP-55 checksum, so a mistyped address is caught here rather than\n * being written to a wrong account. The stored value is always EIP-55 checksummed.\n *\n * @throws {InvalidValueError} If the value is not 20 hex bytes, or fails its EIP-55 checksum.\n *\n * @example\n * addr(\"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\")\n */\nexport function addr(value: string): AddrValue {\n if (typeof value !== \"string\" || !/^0x[0-9a-fA-F]{40}$/.test(value)) {\n throw new InvalidValueError(\"addr\", value, \"not a 20-byte 0x-prefixed hex address\")\n }\n const body = value.slice(2)\n const cased = body !== body.toLowerCase() && body !== body.toUpperCase()\n if (cased && !isAddress(value, { strict: true })) {\n throw new InvalidValueError(\n \"addr\",\n value,\n \"fails its EIP-55 checksum, so a digit is probably mistyped\",\n `If those hex digits are right, the correctly checksummed form is ` +\n `${checksumAddress(value as Address)}.`,\n )\n }\n return makeValue(\"addr\", checksumAddress(value as Address))\n}\n\n/**\n * A reference to another entity, indexed for equality.\n *\n * References are **weak**: nothing checks that the target exists when you write it, and a\n * reference to a deleted or expired entity is allowed to dangle.\n *\n * @param value - A 32-byte entity key, as `0x` hex or raw bytes.\n * @throws {InvalidValueError} If the value is not exactly 32 bytes.\n *\n * @example\n * key(parentEntityKey)\n */\nexport function key(value: Hex | Uint8Array): KeyValue {\n return makeValue(\"key\", asFixedHex(\"key\", value, 32))\n}\n\n/**\n * 32 opaque bytes — a hash, a digest, an identifier from another system — indexed for equality.\n *\n * Use {@link key} instead when the bytes are an Arkiv entity key: same wire width, but the\n * distinct type makes the reference visible to readers and to the query language.\n *\n * @param value - 32 bytes, as `0x` hex or raw bytes.\n * @throws {InvalidValueError} If the value is not exactly 32 bytes.\n *\n * @example\n * bytes32(keccak256(toBytes(\"hello\")))\n */\nexport function bytes32(value: Hex | Uint8Array): Bytes32Value {\n return makeValue(\"bytes32\", asFixedHex(\"bytes32\", value, 32))\n}\n\n/** Normalizes hex-or-bytes input of a known width into lowercase `0x` hex. */\nfunction asFixedHex(tag: \"key\" | \"bytes32\", value: Hex | Uint8Array, size: number): Hex {\n if (value instanceof Uint8Array) {\n if (value.length !== size) {\n throw new InvalidValueError(tag, `<${value.length} bytes>`, `not exactly ${size} bytes`)\n }\n return toHex(value)\n }\n if (typeof value !== \"string\" || !isHex(value, { strict: true })) {\n throw new InvalidValueError(tag, value, \"not 0x-prefixed hex\")\n }\n if (value.length !== 2 + size * 2) {\n throw new InvalidValueError(\n tag,\n value,\n `${(value.length - 2) / 2} bytes, not exactly ${size} bytes`,\n )\n }\n return value.toLowerCase() as Hex\n}\n\n/**\n * A JavaScript value accepted wherever a typed value is expected: either a tagged value, or one of\n * the four bare forms that map unambiguously onto a single type.\n *\n * | bare form | type |\n * | --------- | ------- |\n * | `boolean` | `bool` |\n * | `number` | `i32` |\n * | `bigint` | `u256` |\n * | `string` | `str` |\n *\n * Anything else — a large number, a decimal, an address, an entity key — must name its type, which\n * is what keeps `\"0x1234...\"` a string rather than silently becoming a key.\n *\n * These defaults apply identically when writing and when querying, so a value written bare and\n * queried bare always agrees with itself. The mismatch to watch for is mixing the two: an attribute\n * written as {@link u64} does not match a bare `bigint` predicate, because that predicate asserts\n * `u256`. A type mismatch is not an error to the engine — it simply matches nothing.\n */\nexport type ValueInput = ArkivValue | boolean | number | bigint | string\n\n/**\n * Resolves a {@link ValueInput} to a typed value, applying the bare-form defaults above. Tagged\n * values pass through untouched.\n *\n * @param input - The value to resolve.\n * @param attributeName - The attribute this value belongs to, used to make errors name it.\n *\n * @throws {MissingValueError} If the input is `undefined` or `null` — an attribute is either set\n * with a value and a type, or not set at all.\n * @throws {UntypedValueError} If the input is not a tagged value or a bare boolean, number, bigint\n * or string.\n * @throws {InvalidValueError} If a bare value does not fit the type it defaults to.\n *\n * @example\n * toValue(10) // i32(10)\n * toValue(10n) // u256(10n)\n * toValue(\"hello\") // str(\"hello\")\n * toValue(dec(\"3.5\")) // unchanged\n */\nexport function toValue(input: ValueInput, attributeName?: string): ArkivValue {\n // `undefined` and `null` are rejected before the type switch. They are not assignable to\n // ValueInput, but they still arrive at runtime — from a spread of an optional-shaped object, or\n // from data that never went through the type system — and \"cannot infer a type for undefined\"\n // does not tell you the fix, which is always to leave the attribute out.\n if (input === undefined || input === null) {\n throw new MissingValueError(input, attributeName)\n }\n switch (typeof input) {\n case \"boolean\":\n return bool(input)\n case \"number\":\n return i32(input)\n case \"bigint\":\n return u256(input)\n case \"string\":\n return str(input)\n default: {\n // Widened to AnyArkivValue: `bytes` is not a member of ValueInput, but it is what a decoded\n // `$payload` carries, so a round-trip through a decoded entity must be rejected by name\n // rather than fall through to \"cannot infer a type\".\n const candidate = input as AnyArkivValue\n if (isArkivValue(candidate)) {\n if (candidate.type === \"bytes\") {\n throw new InvalidValueError(\n \"bytes\",\n candidate.value,\n \"system-only — bytes backs the entity payload and cannot be set as an attribute\",\n \"Pass the bytes as the entity payload instead.\",\n )\n }\n return revalidate(candidate)\n }\n throw new UntypedValueError(input)\n }\n }\n}\n\n/**\n * Re-runs a tagged value through its own constructor.\n *\n * {@link isArkivValue} can only check shape — the `validated` brand is a type-level construct with\n * no runtime existence, so a hand-written `{ type: \"u256\", value: \"1000\" }` (from `JSON.parse`, a\n * config file, an `as any` boundary) is indistinguishable from a real `u256(1000n)`. Passing it\n * through unchecked was silent corruption rather than an error: the ABI encoder would take the\n * *string* \"1000\" and write its UTF-8 bytes into the word, storing 2.27e76 on chain.\n *\n * Running the constructor again is what makes the brand's promise — \"every value crossing the wire\n * has been range-, length- and format-checked\" — true at runtime. For a value that really did come\n * from a constructor it is a no-op that returns an equal value.\n */\nfunction revalidate(value: Exclude<AnyArkivValue, BytesValue>): ArkivValue {\n switch (value.type) {\n case \"bool\":\n return bool(value.value)\n case \"i32\":\n return i32(value.value)\n case \"u64\":\n return u64(value.value)\n case \"u256\":\n return u256(value.value)\n case \"dec\":\n return dec(value.value)\n case \"bytes32\":\n return bytes32(value.value)\n case \"str\":\n return str(value.value)\n case \"addr\":\n return addr(value.value)\n case \"key\":\n return key(value.value)\n }\n}\n","import { bytesToString, type Hex, hexToBytes, pad, size, stringToBytes, toHex } from \"viem\"\nimport { unitsToDecimal } from \"./decimal\"\nimport { InvalidValueError, UnknownAttributeTypeError } from \"./errors\"\nimport { type AnyArkivValue, makeValue, type StrValue, TYPE_IDS, type TypeTag } from \"./types\"\nimport { addr, bool, bytes32, dec, decUnits, i32, key, u64, u256 } from \"./values\"\n\nfunction strFromChain(value: string): StrValue {\n return makeValue(\"str\", value)\n}\n\n/**\n * The `typeId` marking a tombstone — an attribute being unset. It carries a zero-length value and\n * is legal only in a patch's mutation list, never in a create.\n */\nexport const TOMBSTONE_TYPE_ID = 0\n\n/**\n * An attribute in its ABI form: `(Ident32 name, uint8 typeId, bytes value)`.\n *\n * The `value` encoding is selected by `typeId`: an exact 32-byte word for the word types, the raw\n * bytes for `str` and `bytes`, and zero-length for a tombstone.\n */\nexport type AbiAttribute = {\n name: Hex\n typeId: number\n value: Hex\n}\n\n/**\n * Encodes a typed value into the `bytes` the ABI carries for it.\n *\n * This and {@link decodeValueBytes} are the only place the value/wire mapping is written down.\n *\n * - Word types (`bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `addr`, `key`) become exactly 32\n * bytes, in the encoding Solidity would use — right-aligned, and sign-extended for `i32`.\n * - `str` becomes its raw UTF-8 bytes, and `bytes` its raw bytes: variable length, no padding.\n */\nexport function encodeValueBytes(value: AnyArkivValue): Hex {\n switch (value.type) {\n case \"bool\":\n return pad(value.value ? \"0x01\" : \"0x00\", { size: 32 })\n case \"i32\":\n // int32 is sign-extended across the whole word, as Solidity encodes it.\n return toHex(BigInt.asUintN(256, BigInt(value.value)), { size: 32 })\n case \"u64\":\n case \"u256\":\n return toHex(value.value, { size: 32 })\n case \"dec\":\n return toHex(BigInt.asUintN(256, decUnits(value)), { size: 32 })\n case \"bytes32\":\n case \"key\":\n return value.value\n case \"addr\":\n return pad(value.value.toLowerCase() as Hex, { size: 32 })\n case \"str\":\n return toHex(stringToBytes(value.value))\n case \"bytes\":\n return value.value\n }\n}\n\n/**\n * Decodes the ABI `bytes` of an attribute of type `tag`.\n *\n * Rejects anything a well-formed encoder would not have produced — a word type whose value is not\n * 32 bytes, an `i32` that is not sign-extended, a `bool` that is neither 0 nor 1 — rather than\n * silently truncating it.\n */\nexport function decodeValueBytes(tag: TypeTag, value: Hex): AnyArkivValue {\n if (tag === \"str\") return strFromChain(bytesToString(hexToBytes(value)))\n if (tag === \"bytes\") return makeValue(\"bytes\", value.toLowerCase() as Hex)\n\n const width = size(value)\n if (width !== 32) {\n throw new InvalidValueError(tag, value, `a ${tag} value must be 32 bytes, got ${width}`)\n }\n const raw = BigInt(value)\n\n switch (tag) {\n case \"bool\":\n if (raw !== 0n && raw !== 1n) {\n throw new InvalidValueError(\"bool\", value, \"a bool word must hold exactly 0 or 1\")\n }\n return bool(raw === 1n)\n case \"i32\": {\n const narrowed = BigInt.asIntN(32, raw)\n if (BigInt.asUintN(256, narrowed) !== raw) {\n throw new InvalidValueError(\"i32\", value, \"an i32 word must be sign-extended\")\n }\n return i32(narrowed)\n }\n case \"u64\":\n if (raw >> 64n !== 0n) {\n throw new InvalidValueError(\"u64\", value, \"a u64 word must be zero-padded to 8 bytes\")\n }\n return u64(raw)\n case \"u256\":\n return u256(raw)\n case \"dec\":\n return dec(unitsToDecimal(BigInt.asIntN(256, raw)))\n case \"bytes32\":\n return bytes32(value)\n case \"key\":\n return key(value)\n case \"addr\": {\n if (raw >> 160n !== 0n) {\n throw new InvalidValueError(\n \"addr\",\n value,\n \"an address word must be zero-padded to 20 bytes\",\n )\n }\n return addr(`0x${value.slice(-40)}`)\n }\n }\n}\n\n/**\n * Encodes a named, typed attribute into its ABI form.\n *\n * @param name - The attribute name. Assumed already validated, or a system (`$`) name the SDK sets\n * itself.\n */\nexport function encodeAbiAttribute(name: string, value: AnyArkivValue): AbiAttribute {\n return {\n // Ident32 is left-aligned and null-padded, which is what `toHex` does for a string.\n name: toHex(name, { size: 32 }),\n typeId: TYPE_IDS[value.type],\n value: encodeValueBytes(value),\n }\n}\n\n/** Encodes a tombstone — the mutation that unsets `name`. Legal only in a patch. */\nexport function encodeTombstone(name: string): AbiAttribute {\n return { name: toHex(name, { size: 32 }), typeId: TOMBSTONE_TYPE_ID, value: \"0x\" }\n}\n\n/**\n * Decodes an attribute value as it comes back over JSON-RPC.\n *\n * The JSON encoding follows the value's **declared type**, never its magnitude: `bool` is a JSON\n * boolean, `i32` a JSON number, `u64`/`u256` a `0x` QUANTITY, `dec` a decimal string, `str` a\n * string, and\n * the byte-shaped types `0x` DATA. Decimal strings are also accepted for the integer types, so this\n * keeps working against a node that renders them that way.\n *\n * @param type - The type tag the response declared, e.g. `\"u256\"`.\n * @param value - The JSON value.\n * @throws {UnknownAttributeTypeError} If the tag names no known type.\n * @throws {InvalidValueError} If the value does not parse as that type.\n */\nexport function decodeRpcValue(type: string, value: unknown): AnyArkivValue {\n const tag = asTypeTag(type)\n switch (tag) {\n case \"bool\":\n return bool(asBoolean(value))\n case \"i32\":\n return i32(Number(asIntegerish(\"i32\", value)))\n case \"u64\":\n return u64(asIntegerish(\"u64\", value))\n case \"u256\":\n return u256(asIntegerish(\"u256\", value))\n case \"dec\":\n return dec(asString(\"dec\", value))\n case \"bytes32\":\n return bytes32(asString(\"bytes32\", value) as Hex)\n case \"key\":\n return key(asString(\"key\", value) as Hex)\n case \"addr\":\n return addr(asString(\"addr\", value))\n case \"str\":\n return strFromChain(asString(\"str\", value))\n case \"bytes\":\n return makeValue(\"bytes\", asString(\"bytes\", value).toLowerCase() as Hex)\n }\n}\n\n/**\n * Narrows a type tag as the node spelled it.\n *\n * @throws {UnknownAttributeTypeError} If it names no type this SDK knows.\n */\nexport function asTypeTag(type: string): TypeTag {\n // `Object.hasOwn`, not `in`: `in` walks the prototype chain, so \"constructor\" and \"toString\"\n // would pass as type tags and then fall off the end of the exhaustive switch below as `undefined`.\n if (typeof type !== \"string\" || !Object.hasOwn(TYPE_IDS, type)) {\n throw new UnknownAttributeTypeError(type)\n }\n return type as TypeTag\n}\n\nfunction asBoolean(value: unknown): boolean {\n if (typeof value === \"boolean\") return value\n // Tolerated because a node may render it as text; anything else is a protocol error.\n if (value === \"true\" || value === \"false\") return value === \"true\"\n throw new InvalidValueError(\"bool\", value, \"not a boolean\")\n}\n\nfunction asString(tag: TypeTag, value: unknown): string {\n if (typeof value !== \"string\") {\n throw new InvalidValueError(tag, value, `expected a string, got ${typeof value}`)\n }\n return value\n}\n\n/** A `0x` QUANTITY, a JSON number, or a decimal string — all of which name one integer. */\nfunction asIntegerish(tag: TypeTag, value: unknown): bigint {\n if (typeof value === \"number\") {\n if (!Number.isInteger(value)) {\n throw new InvalidValueError(tag, value, \"not an integer\")\n }\n return BigInt(value)\n }\n if (typeof value === \"bigint\") return value\n if (typeof value === \"string\") {\n if (/^0x[0-9a-fA-F]+$/.test(value)) return BigInt(value)\n if (/^-?\\d+$/.test(value)) return BigInt(value)\n }\n throw new InvalidValueError(tag, value, \"not an integer\")\n}\n","import { InvalidAttributeNameError } from \"./errors\"\n\n/** The longest attribute name, in bytes — the width of the on-chain `Ident32` name cell. */\nexport const MAX_NAME_BYTES = 32\n\n/**\n * The attribute-name grammar (`Ident32`): a leading letter, then letters, digits, `.`, `-` or `_`.\n *\n * Names are **case-sensitive** — `Level` and `level` are two different attributes.\n *\n * The charset is ASCII-only, so a name's length in characters is also its length in bytes.\n */\nconst NAME_RE = /^[A-Za-z][A-Za-z0-9._-]*$/\n\n/**\n * Words the query language reserves. They are rejected as attribute names because an attribute\n * named `not` or `str` could be written but never queried — the parser would read the name as an\n * operator or a type tag.\n *\n * Matched **case-insensitively**: query keywords are case-insensitive, so `NOT` and `not` are the\n * same operator, and the type tags are held to the same rule so that what is reserved does not\n * depend on how you happen to capitalise it.\n */\nconst RESERVED = new Set([\n // operators and keywords\n \"and\",\n \"or\",\n \"not\",\n \"true\",\n \"false\",\n \"startswith\",\n \"exists\",\n \"typeof\",\n // type tags\n \"bool\",\n \"i32\",\n \"u64\",\n \"u256\",\n \"dec\",\n \"bytes32\",\n \"bytes\",\n \"str\",\n \"addr\",\n \"key\",\n])\n\n/**\n * Validates an attribute name against the engine's `Ident32` grammar and the query language's\n * reserved words.\n *\n * @param name - The attribute name.\n * @throws {InvalidAttributeNameError} If the name is empty, too long, uses characters outside the\n * grammar, or collides with a reserved word.\n */\nexport function validateAttributeName(name: string): void {\n if (typeof name !== \"string\" || name.length === 0) {\n throw new InvalidAttributeNameError(String(name), \"the name is empty\")\n }\n if (name.startsWith(\"$\")) {\n throw new InvalidAttributeNameError(\n name,\n '\"$\" is reserved for system attributes, which the engine sets and you cannot write',\n )\n }\n if (!NAME_RE.test(name)) {\n const chars = [...name]\n const at = chars.findIndex(\n (char, index) => !(index === 0 ? /[A-Za-z]/ : /[A-Za-z0-9._-]/).test(char),\n )\n throw new InvalidAttributeNameError(\n name,\n at === 0\n ? `it starts with \"${chars[0]}\" rather than a letter`\n : `it contains \"${chars[at]}\" at position ${at}`,\n )\n }\n if (name.length > MAX_NAME_BYTES) {\n throw new InvalidAttributeNameError(name, `the name is ${name.length} bytes long`)\n }\n // `-` is a legal name character and `--` opens a comment that runs to the end of the line, so a\n // name containing one renders a query whose whole remainder is discarded\n if (name.includes(\"--\")) {\n throw new InvalidAttributeNameError(\n name,\n '\"--\" opens a comment in the query language, so everything after it in a query would be ' +\n \"discarded — an attribute with this name could be written but never safely queried\",\n )\n }\n if (RESERVED.has(name.toLowerCase())) {\n throw new InvalidAttributeNameError(\n name,\n `\"${name}\" is reserved by the query language, so an attribute with this name could never ` +\n \"be queried\",\n )\n }\n}\n\n/** Whether `name` is a valid attribute name — the non-throwing form of {@link validateAttributeName}. */\nexport function isValidAttributeName(name: string): boolean {\n try {\n validateAttributeName(name)\n return true\n } catch {\n return false\n }\n}\n","import { type AbiAttribute, encodeAbiAttribute, encodeTombstone } from \"./codec\"\nimport { ConflictingMutationError, InvalidValueError, TooManyAttributesError } from \"./errors\"\nimport { validateAttributeName } from \"./names\"\nimport type { AnyArkivValue, ArkivValue, TypeTag } from \"./types\"\nimport { makeValue } from \"./types\"\nimport { str, toValue, type ValueInput } from \"./values\"\n\n/**\n * The most attribute cells one operation may carry.\n */\nexport const MAX_ATTRIBUTES = 32\n\n/**\n * The largest payload an entity may carry, in bytes. The payload travels as the `$payload` system\n * cell, so this is a bound on that one attribute rather than on the operation as a whole.\n */\nexport const MAX_PAYLOAD_BYTES = 128 * 1024\n\n/** The system attribute holding an entity's opaque payload. */\nconst PAYLOAD_CELL = \"$payload\"\n/** The system attribute holding an entity's content type. */\nconst CONTENT_TYPE_CELL = \"$contentType\"\n\n/**\n * The attributes written on an entity, as a plain object keyed by attribute name.\n *\n * Values may be tagged ({@link ArkivValue}) or bare where the type is unambiguous — see\n * {@link toValue} for the bare-form defaults.\n *\n * @example\n * const attributes = {\n * level: i32(10),\n * balance: u256(1_000_000n),\n * score: dec(\"3.5\"),\n * parent: key(parentKey),\n * name: \"Bob\", // bare string -> str\n * flagged: true, // bare boolean -> bool\n * } satisfies AttributeInputs\n */\nexport type AttributeInputs = Readonly<Record<string, ValueInput>>\n\n/**\n * The attributes read back from an entity: the same shape, with every value typed.\n *\n * A value read from here drops straight back into an {@link AttributeInputs} — the vocabulary is the\n * same in both directions.\n */\nexport type Attributes = Readonly<Record<string, AnyArkivValue>>\n\n/**\n * The names and types of an entity's attributes, with no values — what the `attributeSchema`\n * projection returns.\n *\n * Useful for asking what shape the data has without paying to transfer it, and for telling apart\n * two entities that use the same name with different types.\n */\nexport type AttributeSchema = Readonly<Record<string, TypeTag>>\n\n/**\n * The typed form of an attribute map: names validated, bare values resolved to their default type.\n *\n * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.\n * @throws {MissingValueError} If a value is `undefined` or `null` — omit the name instead.\n * @throws {InvalidValueError} If a value does not fit the type it names or defaults to.\n * @throws {TooManyAttributesError} If there are more than {@link MAX_ATTRIBUTES} attributes.\n *\n * @example\n * resolveAttributes({ level: 10, name: \"Bob\" })\n * // { level: { type: \"i32\", value: 10 }, name: { type: \"str\", value: \"Bob\" } }\n */\nexport function resolveAttributes(attributes: AttributeInputs): Record<string, ArkivValue> {\n const entries = Object.entries(attributes)\n if (entries.length > MAX_ATTRIBUTES) {\n throw new TooManyAttributesError(entries.length, MAX_ATTRIBUTES)\n }\n const resolved: Record<string, ArkivValue> = {}\n for (const [name, input] of entries) {\n validateAttributeName(name)\n resolved[name] = toValue(input, name)\n }\n return resolved\n}\n\n/**\n * The payload and content type, which travel to the engine as system attributes.\n *\n * They are separate fields on the SDK's surface because that is what they are to an application —\n * an entity's contents and its type — but on the wire an operation carries no dedicated field for\n * either: `$payload` is the one `bytes`-typed cell, and `$contentType` is a `str`.\n */\nexport type SystemCells = {\n payload?: Uint8Array | undefined\n contentType?: string | undefined\n}\n\n/**\n * Encodes an attribute map, plus the payload and content-type system cells, into the ABI attribute\n * array an operation carries.\n *\n * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.\n * @throws {MissingValueError} If a value is `undefined` or `null`.\n * @throws {InvalidValueError} If a value does not fit its type.\n * @throws {TooManyAttributesError} If there are more than {@link MAX_ATTRIBUTES} attributes.\n */\nexport function encodeAttributes(\n attributes: AttributeInputs = {},\n system: SystemCells = {},\n): AbiAttribute[] {\n const cells: [string, AnyArkivValue][] = Object.entries(resolveAttributes(attributes))\n\n // Written whenever the field is given, empty or not: an empty payload is a payload, and dropping\n // it would mean the entity does not hold what the caller passed. Absence is for the operations\n // that genuinely leave a cell alone, not for a value that happens to be empty.\n if (system.payload !== undefined) {\n if (system.payload.length > MAX_PAYLOAD_BYTES) {\n throw new InvalidValueError(\n \"bytes\",\n `<${system.payload.length} bytes>`,\n `${system.payload.length} bytes exceeds the ${MAX_PAYLOAD_BYTES}-byte payload limit`,\n \"Store the bulk elsewhere and keep a reference to it on the entity.\",\n )\n }\n cells.push([PAYLOAD_CELL, makeValue(\"bytes\", toHexBytes(system.payload))])\n }\n if (system.contentType !== undefined) {\n cells.push([CONTENT_TYPE_CELL, str(system.contentType)])\n }\n\n if (cells.length > MAX_ATTRIBUTES) {\n throw new TooManyAttributesError(cells.length, MAX_ATTRIBUTES)\n }\n\n return cells.map(([name, value]) => encodeAbiAttribute(name, value)).sort(byName)\n}\n\nexport type MutationInputs = SystemCells & {\n /** Attributes to write. Existing ones are overwritten; new ones are added. */\n set?: AttributeInputs | undefined\n /** Attribute names to remove. Each becomes a tombstone on the wire. */\n unset?: readonly string[] | undefined\n}\n\n/**\n * Encodes a patch's mutations into the ABI attribute array the operation carries.\n *\n * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.\n * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.\n * @throws {MissingValueError} If a value is `undefined` or `null`.\n * @throws {InvalidValueError} If a value does not fit its type.\n * @throws {TooManyAttributesError} If the mutations exceed {@link MAX_ATTRIBUTES}.\n * @throws {TypeError} If `unset` is not an array.\n */\nexport function encodeMutations({\n set,\n unset,\n payload,\n contentType,\n}: MutationInputs): AbiAttribute[] {\n const written = encodeAttributes(set, { payload, contentType })\n const tombstones = resolveUnset(unset, set).map(encodeTombstone)\n const mutations = [...written, ...tombstones]\n if (mutations.length > MAX_ATTRIBUTES) {\n throw new TooManyAttributesError(mutations.length, MAX_ATTRIBUTES)\n }\n return mutations.sort(byName)\n}\n\nfunction resolveUnset(unset: readonly string[] = [], set: AttributeInputs = {}): string[] {\n if (!Array.isArray(unset)) {\n throw new TypeError(`\"unset\" must be an array of attribute names`)\n }\n const names = new Set(unset)\n for (const name of names) {\n validateAttributeName(name)\n if (Object.hasOwn(set, name)) {\n throw new ConflictingMutationError(name)\n }\n }\n return [...names]\n}\n\n/**\n * The engine requires attributes **strictly ascending by their `bytes32` name**: that ordering is\n * what the canonical serialization hashes into the state root, and it doubles as the uniqueness\n * check.\n */\nfunction byName(a: AbiAttribute, b: AbiAttribute): number {\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0\n}\n\n/** Raw bytes as lowercase `0x` hex, without viem's hex-string ambiguity. */\nfunction toHexBytes(bytes: Uint8Array): `0x${string}` {\n let out = \"0x\"\n for (const byte of bytes) out += byte.toString(16).padStart(2, \"0\")\n return out as `0x${string}`\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,oBAAb,cAAuC,MAAM;;CAE3C,AAAS;;CAET,AAAS;CAET,YAAY,KAAc,OAAgB,QAAgB,MAAe;AACvE,QAAM,WAAW,IAAI,SAAS,SAAS,MAAM,CAAC,IAAI,OAAO,GAAG,OAAO,IAAI,SAAS,KAAK;AACrF,OAAK,OAAO;AACZ,OAAK,MAAM;AACX,OAAK,QAAQ;;;;;;;;AASjB,IAAa,oBAAb,cAAuC,MAAM;CAC3C,AAAS;CAET,YAAY,OAAgB;AAC1B,QACE,kCAAkC,SAAS,MAAM,CAAC,6IAGnD;AACD,OAAK,OAAO;AACZ,OAAK,QAAQ;;;;;;;;;;AAWjB,IAAa,oBAAb,cAAuC,MAAM;;CAE3C,AAAS;CAET,YAAY,OAAyB,eAAwB;EAC3D,MAAM,UAAU,gBAAgB,cAAc,cAAc,KAAK;AACjE,QACE,OAAO,QAAQ,MAAM,UAAU,OAAO,SAAS,YAAY,gHAExD,gBACG,SAAS,cAAc,+GAEvB,2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;;;;;;;;;;;AAoBnF,SAAgB,gBAAgB,EAC9B,KACA,OACA,SACA,eACiC;CACjC,MAAM,UAAU,iBAAiB,KAAK;EAAE;EAAS;EAAa,CAAC;CAC/D,MAAM,aAAa,aAAa,OAAO,IAAI,CAAC,IAAI,gBAAgB;CAChE,MAAM,YAAY,CAAC,GAAG,SAAS,GAAG,WAAW;AAC7C,KAAI,UAAU,SAAS,eACrB,OAAM,IAAI,uBAAuB,UAAU,QAAQ,eAAe;AAEpE,QAAO,UAAU,KAAK,OAAO;;AAG/B,SAAS,aAAa,QAA2B,EAAE,EAAE,MAAuB,EAAE,EAAY;AACxF,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,OAAM,IAAI,UAAU,8CAA8C;CAEpE,MAAM,QAAQ,IAAI,IAAI,MAAM;AAC5B,MAAK,MAAM,QAAQ,OAAO;AACxB,wBAAsB,KAAK;AAC3B,MAAI,OAAO,OAAO,KAAK,KAAK,CAC1B,OAAM,IAAI,yBAAyB,KAAK;;AAG5C,QAAO,CAAC,GAAG,MAAM;;;;;;;AAQnB,SAAS,OAAO,GAAiB,GAAyB;AACxD,QAAO,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,IAAI;;;AAItD,SAAS,WAAW,OAAkC;CACpD,IAAI,MAAM;AACV,MAAK,MAAM,QAAQ,MAAO,QAAO,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI;AACnE,QAAO"}
@@ -1,4 +1,4 @@
1
- const require_chains = require('../chains-BYRTTipa.cjs');
1
+ const require_chains = require('../chains-BfNQliHU.cjs');
2
2
 
3
3
  exports.cheesecake = require_chains.cheesecake;
4
4
  exports.localhost = require_chains.localhost;
@@ -52,6 +52,9 @@ declare const cheesecake: {
52
52
  };
53
53
  //#endregion
54
54
  //#region src/chains/localhost.d.ts
55
+ /**
56
+ * A node running on the local machine
57
+ */
55
58
  declare const localhost: {
56
59
  blockExplorers?: {
57
60
  [key: string]: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/chains/cheesecake.ts","../../src/chains/localhost.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,UAgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;ICnBW,CAAA,CAAA,EAAA,MAWX,CAAA,EDQA,KAAA,CAAA,aAAA,GCRA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAXW;;;MDGA,IAAA,EAgBX,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCRA,KAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,wBAAA,SAAA;IAAA,oBAAA,CAAA,wBAAA,SAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/chains/cheesecake.ts","../../src/chains/localhost.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,UAgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;IChBW,CAAA,CAAA,EAAA,MAWX,CAAA,EDKA,KAAA,CAAA,aAAA,GCLA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ADXW,cCAA,SDgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;IChBW,CAAA,CAAA,EAAA,MAWX,CAAA,EAAA,KAAA,CAAA,aAAA,GAAA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA"}
@@ -52,6 +52,9 @@ declare const cheesecake: {
52
52
  };
53
53
  //#endregion
54
54
  //#region src/chains/localhost.d.ts
55
+ /**
56
+ * A node running on the local machine
57
+ */
55
58
  declare const localhost: {
56
59
  blockExplorers?: {
57
60
  [key: string]: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/cheesecake.ts","../../src/chains/localhost.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,UAgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;ICnBW,CAAA,CAAA,EAAA,MAWX,CAAA,EDQA,KAAA,CAAA,aAAA,GCRA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAXW;;;MDGA,IAAA,EAgBX,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCRA,KAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,wBAAA,SAAA;IAAA,oBAAA,CAAA,wBAAA,SAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/cheesecake.ts","../../src/chains/localhost.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,UAgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;IChBW,CAAA,CAAA,EAAA,MAWX,CAAA,EDKA,KAAA,CAAA,aAAA,GCLA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ADXW,cCAA,SDgBX,EAAA;EAAA,cAAA,CAAA,EAAA;;;;;;;;;;;;;;IChBW,CAAA,CAAA,EAAA,MAWX,CAAA,EAAA,KAAA,CAAA,aAAA,GAAA;MAAA,CAAA,QAAA,EAAA,MAAA,CAAA,wBAAA,SAAA"}
@@ -1,3 +1,3 @@
1
- import { n as localhost, r as cheesecake } from "../chains-BJrZs6sG.js";
1
+ import { n as localhost, r as cheesecake } from "../chains-Du8tql7I.js";
2
2
 
3
3
  export { cheesecake, localhost };
@@ -34,6 +34,9 @@ const cheesecake = (0, viem.defineChain)({
34
34
 
35
35
  //#endregion
36
36
  //#region src/chains/localhost.ts
37
+ /**
38
+ * A node running on the local machine
39
+ */
37
40
  const localhost = (0, viem.defineChain)({
38
41
  id: 1337,
39
42
  name: "Localhost",
@@ -34,6 +34,9 @@ const cheesecake = defineChain({
34
34
 
35
35
  //#endregion
36
36
  //#region src/chains/localhost.ts
37
+ /**
38
+ * A node running on the local machine
39
+ */
37
40
  const localhost = defineChain({
38
41
  id: 1337,
39
42
  name: "Localhost",
@@ -54,4 +57,4 @@ var chains_exports = /* @__PURE__ */ __export({
54
57
 
55
58
  //#endregion
56
59
  export { localhost as n, cheesecake as r, chains_exports as t };
57
- //# sourceMappingURL=chains-BJrZs6sG.js.map
60
+ //# sourceMappingURL=chains-Du8tql7I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains-Du8tql7I.js","names":[],"sources":["../src/chains/cheesecake.ts","../src/chains/localhost.ts","../src/chains/index.ts"],"sourcesContent":["import { defineChain } from \"viem\"\n\n/**\n * Cheesecake is Arkiv's testnet.\n */\nexport const cheesecake = defineChain({\n id: 7733102,\n name: \"Cheesecake\",\n network: \"cheesecake\",\n nativeCurrency: {\n name: \"Golem\",\n symbol: \"GLM\",\n decimals: 18,\n },\n rpcUrls: {\n default: {\n http: [\"https://rpc.cheesecake.db-chain.devnet.gobas.me\"],\n webSocket: [\"wss://rpc.cheesecake.db-chain.devnet.gobas.me\"],\n },\n },\n testnet: true,\n})\n","import { defineChain } from \"viem\"\n\n/**\n * A node running on the local machine\n */\nexport const localhost = defineChain({\n id: 1337,\n name: \"Localhost\",\n nativeCurrency: {\n decimals: 18,\n name: \"Ether\",\n symbol: \"ETH\",\n },\n rpcUrls: {\n default: { http: [\"http://127.0.0.1:8545\"] },\n },\n})\n","export { cheesecake } from \"./cheesecake\"\nexport { localhost } from \"./localhost\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,MAAa,aAAa,YAAY;CACpC,IAAI;CACJ,MAAM;CACN,SAAS;CACT,gBAAgB;EACd,MAAM;EACN,QAAQ;EACR,UAAU;EACX;CACD,SAAS,EACP,SAAS;EACP,MAAM,CAAC,kDAAkD;EACzD,WAAW,CAAC,gDAAgD;EAC7D,EACF;CACD,SAAS;CACV,CAAC;;;;;;;AChBF,MAAa,YAAY,YAAY;CACnC,IAAI;CACJ,MAAM;CACN,gBAAgB;EACd,UAAU;EACV,MAAM;EACN,QAAQ;EACT;CACD,SAAS,EACP,SAAS,EAAE,MAAM,CAAC,wBAAwB,EAAE,EAC7C;CACF,CAAC"}
@@ -1,11 +1,18 @@
1
- import { p as AttributeInputs } from "./index-DVYFaXNV.js";
1
+ import { p as AttributeInputs } from "./index-Cd2aaWme.js";
2
+ import { a as SaltInput } from "./index-ezMZ2-JH.js";
2
3
  import { n as Expiry } from "./expiry-BxOlvVWC.js";
3
4
  import { n as ResolvedCreationFlags, t as CreationFlags } from "./flags-wmcMoAnN.js";
4
- import { i as SelectArg, k as Entity } from "./selection-fpmI3ADQ.js";
5
+ import { i as SelectArg, k as Entity } from "./selection-ox7zdtVm.js";
5
6
  import { Address, Hash, Hex } from "viem";
6
7
 
8
+ //#region src/actions/public/getBlockTiming.d.ts
9
+ type GetBlockTimingReturnType = {
10
+ currentBlock: bigint;
11
+ currentBlockTime: number;
12
+ blockDuration: number;
13
+ };
14
+ //#endregion
7
15
  //#region src/actions/public/predictEntityKeys.d.ts
8
-
9
16
  /**
10
17
  * A key a create will be given, together with the salt that mints it.
11
18
  *
@@ -15,11 +22,15 @@ import { Address, Hash, Hex } from "viem";
15
22
  type PredictedEntityKey = {
16
23
  /** The key the create will be given. */
17
24
  key: Hex;
18
- /** The salt the create must carry for its key to come out as {@link PredictedEntityKey.key}. */
25
+ /**
26
+ * The salt the create must carry for its key to come out as {@link PredictedEntityKey.key}.
27
+ * Always a plain `uint128` — a requested {@link NO_SALT} comes back as the `0n` it resolves to,
28
+ * which a create accepts just the same.
29
+ */
19
30
  salt: bigint;
20
31
  };
21
- /** Parameters for {@link predictEntityKeys}. */
22
- type PredictEntityKeysParameters<TCount extends number = number, TSalts extends readonly bigint[] | undefined = readonly bigint[] | undefined> = {
32
+ /** Parameters for `client.predictEntityKeys`. */
33
+ type PredictEntityKeysParameters<TCount extends number = number, TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined> = {
23
34
  /** The account that will sign the creates. Its nonce is what the keys are derived from. */
24
35
  owner: Address;
25
36
  /**
@@ -32,7 +43,8 @@ type PredictEntityKeysParameters<TCount extends number = number, TSalts extends
32
43
  count?: TCount | undefined;
33
44
  /**
34
45
  * The salt each create will carry, in batch order. Defaults to `count` fresh random salts —
35
- * either way each key comes back paired with the salt that mints it.
46
+ * either way each key comes back paired with the salt that mints it. Pass {@link NO_SALT} in a
47
+ * slot whose create opts out of salting.
36
48
  */
37
49
  salts?: TSalts;
38
50
  };
@@ -43,10 +55,10 @@ type PredictEntityKeysParameters<TCount extends number = number, TSalts extends
43
55
  * tuple, gives a fixed-length tuple; a count computed at runtime gives a plain array.
44
56
  *
45
57
  * `TSalts` is wrapped in a tuple to stop the conditional distributing over it. Left naked, the
46
- * `readonly bigint[] | undefined` default would take both branches and union a tuple with an array,
47
- * which widens the length straight back to `number`.
58
+ * `readonly SaltInput[] | undefined` default would take both branches and union a tuple with an
59
+ * array, which widens the length straight back to `number`.
48
60
  */
49
- type PredictEntityKeysReturnType<TCount extends number = number, TSalts extends readonly bigint[] | undefined = readonly bigint[] | undefined> = [TSalts] extends [readonly bigint[]] ? { -readonly [Index in keyof TSalts]: PredictedEntityKey } : Repeat<PredictedEntityKey, TCount>;
61
+ type PredictEntityKeysReturnType<TCount extends number = number, TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined> = [TSalts] extends [readonly SaltInput[]] ? { -readonly [Index in keyof TSalts]: PredictedEntityKey } : Repeat<PredictedEntityKey, TCount>;
50
62
  /**
51
63
  * A tuple of `TLength` × `T`, or a plain array when the length is only known at runtime.
52
64
  *
@@ -65,7 +77,7 @@ type Repeat<T, TLength extends number, TAcc extends T[] = []> = number extends T
65
77
  *
66
78
  * The prediction is valid only while nothing else from this owner is in flight. Every create that
67
79
  * lands first takes the nonce with it and moves these keys. For a key you can rely on
68
- * unconditionally, read it back from the create instead — `createEntity` and `mutateEntities`
80
+ * unconditionally, read it back from the create instead — `createEntity` and `executeBatch`
69
81
  * report the keys the engine actually minted.
70
82
  *
71
83
  * @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
@@ -75,7 +87,7 @@ type Repeat<T, TLength extends number, TAcc extends T[] = []> = number extends T
75
87
  * import { key } from "@arkiv-network/sdk/attr"
76
88
  *
77
89
  * const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
78
- * await wallet.mutateEntities({
90
+ * await client.executeBatch({
79
91
  * creates: [
80
92
  * { payload, contentType, expires, salt: parent.salt },
81
93
  * {
@@ -209,13 +221,6 @@ type WatchEntityEventsParameters = {
209
221
  pollingInterval?: number | undefined;
210
222
  };
211
223
  //#endregion
212
- //#region src/actions/public/getBlockTiming.d.ts
213
- type GetBlockTimingReturnType = {
214
- currentBlock: bigint;
215
- currentBlockTime: number;
216
- blockDuration: number;
217
- };
218
- //#endregion
219
224
  //#region src/actions/wallet/createEntity.d.ts
220
225
  /**
221
226
  * Parameters for creating an entity.
@@ -274,8 +279,8 @@ type CreateEntityParameters = {
274
279
  contentType: MimeType | (string & {});
275
280
  /**
276
281
  * The entity's queryable attributes, keyed by name. Values are the tagged constructors from
277
- * `@arkiv-network/sdk/attr` — `i32`, `u256`, `dec`, `str`, `addr`, `key`, `bytes32`, `bool` — or
278
- * a bare `boolean`, `number`, `bigint` or `string` where the type is unambiguous.
282
+ * `@arkiv-network/sdk/attr` — `i32`, `u64`, `u256`, `dec`, `str`, `addr`, `key`, `bytes32`,
283
+ * `bool` — or a bare `boolean`, `number`, `bigint` or `string` where the type is unambiguous.
279
284
  *
280
285
  * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
281
286
  * @throws {InvalidValueError} If a value does not fit the type it names or defaults to.
@@ -290,10 +295,10 @@ type CreateEntityParameters = {
290
295
  * The salt mixed into the entity key. Defaults to 128 random bits, which makes the key
291
296
  * unpredictable to everyone but the creator.
292
297
  *
293
- * Pass `0n` for a key derived from the owner and nonce alone — predictable by anyone, which is
294
- * what you want only when a third party must be able to compute the key in advance.
298
+ * Pass {@link NO_SALT} for a key derived from the owner and nonce alone — predictable by anyone,
299
+ * which is what you want only when a third party must be able to compute the key in advance.
295
300
  */
296
- salt?: bigint | undefined;
301
+ salt?: SaltInput | undefined;
297
302
  };
298
303
  /**
299
304
  * The result of creating an entity.
@@ -398,9 +403,9 @@ type PatchEntityParameters = {
398
403
  * Attributes to write, keyed by name. An existing attribute is overwritten — including with a
399
404
  * different type — and a name the entity does not carry yet is added.
400
405
  *
401
- * Values are the tagged constructors from `@arkiv-network/sdk/attr` — `i32`, `u256`, `dec`, `str`,
402
- * `addr`, `key`, `bytes32`, `bool` — or a bare `boolean`, `number`, `bigint` or `string` where the
403
- * type is unambiguous.
406
+ * Values are the tagged constructors from `@arkiv-network/sdk/attr` — `i32`, `u64`, `u256`,
407
+ * `dec`, `str`, `addr`, `key`, `bytes32`, `bool` — or a bare `boolean`, `number`, `bigint` or
408
+ * `string` where the type is unambiguous.
404
409
  *
405
410
  * @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
406
411
  * @throws {InvalidValueError} If a value does not fit the type it names or defaults to.
@@ -432,14 +437,14 @@ type PatchEntityReturnType = {
432
437
  txHash: Hash;
433
438
  };
434
439
  //#endregion
435
- //#region src/actions/wallet/mutateEntities.d.ts
440
+ //#region src/actions/wallet/executeBatch.d.ts
436
441
  /**
437
- * Parameters for the mutateEntities function.
442
+ * Parameters for the executeBatch function.
438
443
  *
439
444
  * At least one operation is required; a batch with nothing in it throws rather than spending gas on
440
445
  * an empty transaction.
441
446
  */
442
- type MutateEntitiesParameters = {
447
+ type ExecuteBatchParameters = {
443
448
  /** The entities to create. */
444
449
  creates?: CreateEntityParameters[];
445
450
  /** The patches to apply. */
@@ -451,8 +456,8 @@ type MutateEntitiesParameters = {
451
456
  /** The ownership transfers to perform. */
452
457
  ownershipChanges?: ChangeOwnershipParameters[];
453
458
  };
454
- /** Return type for the mutateEntities function. */
455
- type MutateEntitiesReturnType = {
459
+ /** Return type for the executeBatch function. */
460
+ type ExecuteBatchReturnType = {
456
461
  /** The transaction hash. */
457
462
  txHash: Hash;
458
463
  /** The keys of the created entities, in batch order. */
@@ -471,6 +476,14 @@ type MutateEntitiesReturnType = {
471
476
  type MimeType = "text/plain" | "text/html" | "text/css" | "text/csv" | "text/xml" | "text/javascript" | "application/json" | "application/xml" | "application/pdf" | "application/zip" | "application/gzip" | "application/octet-stream" | "application/javascript" | "application/x-www-form-urlencoded" | "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "video/mp4" | "video/webm" | "video/ogg" | "multipart/form-data";
472
477
  //#endregion
473
478
  //#region src/types/txParams.d.ts
479
+ /**
480
+ * Transaction fields a write action passes through to the wallet, for the cases where the defaults
481
+ * are not what you want.
482
+ *
483
+ * Fee style is either/or: give `gasPrice` for a legacy transaction, or `maxFeePerGas` /
484
+ * `maxPriorityFeePerGas` for an EIP-1559 one. Mixing the two does not typecheck. Anything left out
485
+ * is estimated.
486
+ */
474
487
  type TxParams = {
475
488
  gas?: bigint;
476
489
  nonce?: number;
@@ -505,5 +518,5 @@ type ChangeOwnershipReturnType = {
505
518
  txHash: Hash;
506
519
  };
507
520
  //#endregion
508
- export { OwnershipTransferredEvent as C, PredictEntityKeysReturnType as D, PredictEntityKeysParameters as E, PredictedEntityKey as O, ExpiryExtendedEvent as S, QueryReturnType as T, EntityCreatedEvent as _, MutateEntitiesParameters as a, EntityEventContext as b, PatchEntityReturnType as c, DeleteEntityParameters as d, DeleteEntityReturnType as f, WatchEntityEventsParameters as g, GetBlockTimingReturnType as h, MimeType as i, ExtendEntityParameters as l, CreateEntityReturnType as m, ChangeOwnershipReturnType as n, MutateEntitiesReturnType as o, CreateEntityParameters as p, TxParams as r, PatchEntityParameters as s, ChangeOwnershipParameters as t, ExtendEntityReturnType as u, EntityDeletedEvent as v, QueryOptions as w, EntityPatchedEvent as x, EntityEvent as y };
509
- //# sourceMappingURL=changeOwnership-DwgtdSFc.d.ts.map
521
+ export { QueryOptions as C, PredictedEntityKey as D, PredictEntityKeysReturnType as E, GetBlockTimingReturnType as O, OwnershipTransferredEvent as S, PredictEntityKeysParameters as T, EntityDeletedEvent as _, ExecuteBatchParameters as a, EntityPatchedEvent as b, PatchEntityReturnType as c, DeleteEntityParameters as d, DeleteEntityReturnType as f, EntityCreatedEvent as g, WatchEntityEventsParameters as h, MimeType as i, ExtendEntityParameters as l, CreateEntityReturnType as m, ChangeOwnershipReturnType as n, ExecuteBatchReturnType as o, CreateEntityParameters as p, TxParams as r, PatchEntityParameters as s, ChangeOwnershipParameters as t, ExtendEntityReturnType as u, EntityEvent as v, QueryReturnType as w, ExpiryExtendedEvent as x, EntityEventContext as y };
522
+ //# sourceMappingURL=changeOwnership-B0ar96ub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeOwnership-B0ar96ub.d.ts","names":[],"sources":["../src/actions/public/getBlockTiming.ts","../src/actions/public/predictEntityKeys.ts","../src/actions/public/query.ts","../src/types/events.ts","../src/actions/public/watchEntityEvents.ts","../src/actions/wallet/createEntity.ts","../src/actions/wallet/deleteEntity.ts","../src/actions/wallet/extendEntity.ts","../src/actions/wallet/patchEntity.ts","../src/actions/wallet/executeBatch.ts","../src/types/mimeTypes.ts","../src/types/txParams.ts","../src/actions/wallet/changeOwnership.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAKY,wBAAA;;;;;;;;;;;;AAAZ;KCaY,kBAAA;;OAEL;EAFK;AAYZ;;;;EAaU,IAAA,EAAA,MAAA;CAMA;;AAaE,KAhCA,2BAgC2B,CAAA,eAAA,MAAA,GAAA,MAAA,EAAA,eAAA,SA9Bb,SA8Ba,EAAA,GAAA,SAAA,GAAA,SA9BsB,SA8BtB,EAAA,GAAA,SAAA,CAAA,GAAA;EAEb;EAAmC,KAAA,EA7BpD,OA6BoD;EACxD;;;;;;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