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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +71 -16
  2. package/dist/actions/advanced/index.cjs +13 -0
  3. package/dist/actions/advanced/index.d.cts +8 -0
  4. package/dist/actions/advanced/index.d.ts +9 -0
  5. package/dist/actions/advanced/index.js +9 -0
  6. package/dist/advanced-Ds2XRflQ.cjs +656 -0
  7. package/dist/advanced-FZy7WoYR.js +598 -0
  8. package/dist/advanced-FZy7WoYR.js.map +1 -0
  9. package/dist/arkivTransactions-BpARZOsH.d.cts +584 -0
  10. package/dist/arkivTransactions-BpARZOsH.d.cts.map +1 -0
  11. package/dist/arkivTransactions-DfZ_yVDD.d.ts +584 -0
  12. package/dist/arkivTransactions-DfZ_yVDD.d.ts.map +1 -0
  13. package/dist/attr/index.cjs +35 -0
  14. package/dist/attr/index.d.cts +2 -0
  15. package/dist/attr/index.d.ts +3 -0
  16. package/dist/attr/index.js +4 -0
  17. package/dist/attributes-BJGuhsqp.js +819 -0
  18. package/dist/attributes-BJGuhsqp.js.map +1 -0
  19. package/dist/attributes-CMJlp1wn.cjs +1039 -0
  20. package/dist/chains/index.cjs +2 -3
  21. package/dist/chains/index.d.cts +41 -76
  22. package/dist/chains/index.d.cts.map +1 -1
  23. package/dist/chains/index.d.ts +24 -59
  24. package/dist/chains/index.d.ts.map +1 -1
  25. package/dist/chains/index.js +2 -2
  26. package/dist/chains-BfNQliHU.cjs +76 -0
  27. package/dist/chains-Du8tql7I.js +60 -0
  28. package/dist/chains-Du8tql7I.js.map +1 -0
  29. package/dist/codec-M74UR1_0.d.ts +101 -0
  30. package/dist/codec-M74UR1_0.d.ts.map +1 -0
  31. package/dist/entity/index.cjs +21 -0
  32. package/dist/entity/index.d.cts +4 -0
  33. package/dist/entity/index.d.ts +5 -0
  34. package/dist/entity/index.js +7 -0
  35. package/dist/entity-B00Li04j.cjs +71 -0
  36. package/dist/entity-B7G8q_Eo.cjs +0 -0
  37. package/dist/entity-BYQR1uoe.js +67 -0
  38. package/dist/entity-BYQR1uoe.js.map +1 -0
  39. package/dist/entity-CD_qFF2M.js +0 -0
  40. package/dist/errors-51znTSB1.cjs +56 -0
  41. package/dist/errors-CwPJ16bn.js +33 -0
  42. package/dist/errors-CwPJ16bn.js.map +1 -0
  43. package/dist/expiry-CZErShX6.js +95 -0
  44. package/dist/expiry-CZErShX6.js.map +1 -0
  45. package/dist/expiry-DRV29F1r.d.cts +79 -0
  46. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  47. package/dist/expiry-nDbCgZX4.d.ts +79 -0
  48. package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
  49. package/dist/expiry-xr6mx4f7.cjs +135 -0
  50. package/dist/flags-5dTNRnow.d.ts +41 -0
  51. package/dist/flags-5dTNRnow.d.ts.map +1 -0
  52. package/dist/flags-Bh0HJldY.cjs +43 -0
  53. package/dist/flags-CRjPpoh3.d.cts +41 -0
  54. package/dist/flags-CRjPpoh3.d.cts.map +1 -0
  55. package/dist/flags-Cr76ldwF.js +33 -0
  56. package/dist/flags-Cr76ldwF.js.map +1 -0
  57. package/dist/index-CMeD8uEq.d.cts +280 -0
  58. package/dist/index-CMeD8uEq.d.cts.map +1 -0
  59. package/dist/index-CTDI5pXZ.d.ts +184 -0
  60. package/dist/index-CTDI5pXZ.d.ts.map +1 -0
  61. package/dist/index-CekGjkRx.d.cts +184 -0
  62. package/dist/index-CekGjkRx.d.cts.map +1 -0
  63. package/dist/index-D0IzFwMX.d.ts +328 -0
  64. package/dist/index-D0IzFwMX.d.ts.map +1 -0
  65. package/dist/index-DZxwz2Ky.d.cts +177 -0
  66. package/dist/index-DZxwz2Ky.d.cts.map +1 -0
  67. package/dist/index-Dz4SkQWg.d.ts +280 -0
  68. package/dist/index-Dz4SkQWg.d.ts.map +1 -0
  69. package/dist/index-JP31fjyM.d.ts +177 -0
  70. package/dist/index-JP31fjyM.d.ts.map +1 -0
  71. package/dist/index-NbfnXxgr.d.cts +424 -0
  72. package/dist/index-NbfnXxgr.d.cts.map +1 -0
  73. package/dist/index.cjs +434 -412
  74. package/dist/index.d.cts +401 -235
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +402 -235
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +370 -404
  79. package/dist/index.js.map +1 -1
  80. package/dist/key-E7mv0BYf.cjs +116 -0
  81. package/dist/key-XQkpw2xh.js +82 -0
  82. package/dist/key-XQkpw2xh.js.map +1 -0
  83. package/dist/logger-CVpvU8ik.js +153 -0
  84. package/dist/logger-CVpvU8ik.js.map +1 -0
  85. package/dist/logger-Cr15lPAQ.cjs +188 -0
  86. package/dist/payload-Cvrir3Q-.cjs +108 -0
  87. package/dist/payload-D53ms-Mg.d.ts +153 -0
  88. package/dist/payload-D53ms-Mg.d.ts.map +1 -0
  89. package/dist/payload-DaPzUvEh.js +92 -0
  90. package/dist/payload-DaPzUvEh.js.map +1 -0
  91. package/dist/payload-hluX1rc0.d.cts +153 -0
  92. package/dist/payload-hluX1rc0.d.cts.map +1 -0
  93. package/dist/query/index.cjs +26 -149
  94. package/dist/query/index.d.cts +5 -3
  95. package/dist/query/index.d.ts +6 -3
  96. package/dist/query/index.js +8 -137
  97. package/dist/queryBuilder-BXR-HxD9.cjs +947 -0
  98. package/dist/queryBuilder-BwauPaGO.js +823 -0
  99. package/dist/queryBuilder-BwauPaGO.js.map +1 -0
  100. package/dist/selection-C6KeWJ7g.d.cts +441 -0
  101. package/dist/selection-C6KeWJ7g.d.cts.map +1 -0
  102. package/dist/selection-mjiiAGDO.d.ts +442 -0
  103. package/dist/selection-mjiiAGDO.d.ts.map +1 -0
  104. package/dist/types/index.cjs +4 -1
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +4 -1
  108. package/dist/types-Bu_ZwMbZ.js +0 -0
  109. package/dist/types-NRqymi6S.cjs +0 -0
  110. package/dist/utils/index.cjs +4 -17
  111. package/dist/utils/index.d.cts +3 -17
  112. package/dist/utils/index.d.ts +3 -17
  113. package/dist/utils/index.js +4 -18
  114. package/package.json +26 -9
  115. package/src/actions/advanced/advanced.test.ts +258 -0
  116. package/src/actions/advanced/buildMutation.ts +104 -0
  117. package/src/actions/advanced/getMutationResult.ts +112 -0
  118. package/src/actions/advanced/index.ts +21 -0
  119. package/src/actions/advanced/pingTransaction.ts +43 -0
  120. package/src/actions/advanced/sendMutation.ts +59 -0
  121. package/src/actions/public/getEntity.ts +28 -43
  122. package/src/actions/public/getEntityNonce.ts +30 -0
  123. package/src/actions/public/predictEntityKeys.test.ts +159 -0
  124. package/src/actions/public/predictEntityKeys.ts +152 -0
  125. package/src/actions/public/query.ts +35 -67
  126. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  127. package/src/actions/public/watchEntityEvents.ts +225 -0
  128. package/src/actions/wallet/changeOwnership.ts +8 -8
  129. package/src/actions/wallet/createEntity.ts +105 -26
  130. package/src/actions/wallet/deleteEntity.ts +2 -3
  131. package/src/actions/wallet/executeBatch.test.ts +76 -0
  132. package/src/actions/wallet/executeBatch.ts +51 -0
  133. package/src/actions/wallet/extendEntity.ts +40 -16
  134. package/src/actions/wallet/patchEntity.ts +90 -0
  135. package/src/attr/attributes.test.ts +120 -0
  136. package/src/attr/attributes.ts +196 -0
  137. package/src/attr/codec.test.ts +162 -0
  138. package/src/attr/codec.ts +220 -0
  139. package/src/attr/decimal.ts +86 -0
  140. package/src/attr/errors.ts +145 -0
  141. package/src/attr/index.ts +50 -0
  142. package/src/attr/names.ts +106 -0
  143. package/src/attr/types.ts +150 -0
  144. package/src/attr/values.test.ts +271 -0
  145. package/src/attr/values.ts +506 -0
  146. package/src/chains/cheesecake.ts +22 -0
  147. package/src/chains/index.ts +1 -2
  148. package/src/chains/localhost.ts +3 -0
  149. package/src/clients/createPublicClient.test.ts +4 -6
  150. package/src/clients/createPublicClient.ts +9 -8
  151. package/src/clients/createWalletClient.test.ts +4 -4
  152. package/src/clients/createWalletClient.ts +13 -9
  153. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  154. package/src/clients/decorators/arkivPublic.ts +181 -147
  155. package/src/clients/decorators/arkivWallet.ts +141 -122
  156. package/src/consts.ts +2 -1
  157. package/src/entity/create.test.ts +203 -0
  158. package/src/entity/errors.ts +39 -0
  159. package/src/entity/events.ts +16 -0
  160. package/src/entity/expiry.test.ts +195 -0
  161. package/src/entity/expiry.ts +182 -0
  162. package/src/entity/flags.ts +65 -0
  163. package/src/entity/index.ts +16 -0
  164. package/src/entity/key.ts +88 -0
  165. package/src/entity/operations.ts +135 -0
  166. package/src/entity/params.ts +15 -0
  167. package/src/errors.ts +33 -28
  168. package/src/index.ts +19 -0
  169. package/src/query/engine.ts +68 -132
  170. package/src/query/errors.ts +151 -0
  171. package/src/query/expression.test.ts +286 -0
  172. package/src/query/expression.ts +500 -0
  173. package/src/query/index.ts +40 -4
  174. package/src/query/injection.test.ts +151 -0
  175. package/src/query/queryBuilder.test.ts +342 -637
  176. package/src/query/queryBuilder.ts +133 -359
  177. package/src/query/queryResult.ts +54 -51
  178. package/src/query/selection.test.ts +48 -98
  179. package/src/query/selection.ts +77 -65
  180. package/src/types/entity.test.ts +44 -155
  181. package/src/types/entity.ts +62 -44
  182. package/src/types/events.ts +64 -23
  183. package/src/types/index.ts +24 -20
  184. package/src/types/rpcSchema.ts +71 -33
  185. package/src/types/txParams.ts +8 -0
  186. package/src/utils/arkivTransactions.test.ts +687 -38
  187. package/src/utils/arkivTransactions.ts +400 -115
  188. package/src/utils/chains.test.ts +21 -24
  189. package/src/utils/compression.ts +1 -1
  190. package/src/utils/entities.test.ts +62 -0
  191. package/src/utils/entities.ts +111 -29
  192. package/src/utils/expirationTime.ts +153 -10
  193. package/src/utils/logger.ts +2 -2
  194. package/src/utils/payload.ts +29 -2
  195. package/src/utils/revert.test.ts +99 -0
  196. package/src/utils/revert.ts +145 -0
  197. package/dist/chains-BifaY04V.cjs +0 -108
  198. package/dist/chains-CrtkVbBh.js +0 -86
  199. package/dist/chains-CrtkVbBh.js.map +0 -1
  200. package/dist/consts-AUoL-v42.cjs +0 -18
  201. package/dist/consts-BV4PR-de.js +0 -7
  202. package/dist/consts-BV4PR-de.js.map +0 -1
  203. package/dist/entity-B6g_EPm1.d.cts +0 -382
  204. package/dist/entity-B6g_EPm1.d.cts.map +0 -1
  205. package/dist/entity-qoLMAuuk.d.ts +0 -382
  206. package/dist/entity-qoLMAuuk.d.ts.map +0 -1
  207. package/dist/index-DdspxNAA.d.ts +0 -481
  208. package/dist/index-DdspxNAA.d.ts.map +0 -1
  209. package/dist/index-Ds9dwqb5.d.cts +0 -481
  210. package/dist/index-Ds9dwqb5.d.cts.map +0 -1
  211. package/dist/payload-B2kFJyah.d.ts +0 -6
  212. package/dist/payload-B2kFJyah.d.ts.map +0 -1
  213. package/dist/payload-CJN8fTvX.d.cts +0 -6
  214. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  215. package/dist/payload-Claf2jUO.js +0 -13
  216. package/dist/payload-Claf2jUO.js.map +0 -1
  217. package/dist/payload-DpA5PA-w.cjs +0 -23
  218. package/dist/query/index.js.map +0 -1
  219. package/dist/queryBuilder-D2uwP9jI.js +0 -704
  220. package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
  221. package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
  222. package/dist/utils/index.d.cts.map +0 -1
  223. package/dist/utils/index.d.ts.map +0 -1
  224. package/dist/utils/index.js.map +0 -1
  225. package/src/actions/public/buildQuery.ts +0 -10
  226. package/src/actions/public/subscribeEntityEvents.ts +0 -119
  227. package/src/actions/wallet/mutateEntities.ts +0 -111
  228. package/src/actions/wallet/updateEntity.ts +0 -60
  229. package/src/chains/braga.ts +0 -26
  230. package/src/chains/kaolin.ts +0 -29
  231. package/src/query/engine.test.ts +0 -526
  232. package/src/query/predicate.test.ts +0 -461
  233. package/src/query/predicate.ts +0 -144
  234. package/src/query/queryResult.test.ts +0 -270
  235. package/src/query/selectQueryBuilder.test.ts +0 -210
  236. package/src/types/attributes.ts +0 -16
  237. package/src/utils/validation.test.ts +0 -60
  238. package/src/utils/validation.ts +0 -32
  239. /package/dist/{types-H-TSmRpm.js → attr-DlmErkvR.cjs} +0 -0
  240. /package/dist/{types-o3zWarRp.cjs → attr-GcQKatub.js} +0 -0
@@ -0,0 +1,328 @@
1
+ import { a as Bytes32Value, c as I32Value, d as TypeTag, f as U256Value, i as BoolValue, l as KeyValue, n as AnyArkivValue, p as U64Value, r as ArkivValue, s as DecValue, t as AddrValue, u as StrValue } from "./codec-M74UR1_0.js";
2
+ import { Hex } from "viem";
3
+
4
+ //#region src/attr/values.d.ts
5
+ /** The widest `i32`. */
6
+ declare const I32_MAX = 2147483647;
7
+ /** The narrowest `i32`. */
8
+ declare const I32_MIN = -2147483648;
9
+ /** The widest `u64`. */
10
+ declare const U64_MAX: bigint;
11
+ /** The widest `u256`. */
12
+ declare const U256_MAX: bigint;
13
+ /**
14
+ * The longest `str`, in UTF-8 bytes
15
+ */
16
+ declare const MAX_STRING_BYTES = 128;
17
+ /**
18
+ * A boolean.
19
+ *
20
+ * `bool` is the one type that may also be written bare — `{ flagged: true }` and
21
+ * `{ flagged: bool(true) }` are the same attribute.
22
+ *
23
+ * @example
24
+ * bool(true) // { type: "bool", value: true }
25
+ */
26
+ declare function bool(value: boolean): BoolValue;
27
+ /**
28
+ * A 32-bit signed integer, indexed for equality and range queries. This is the default type for a
29
+ * bare number, so `{ level: 10 }` and `{ level: i32(10) }` are the same attribute.
30
+ *
31
+ * @param value - An integer in [-2147483648, 2147483647].
32
+ * @throws {InvalidValueError} If the value is not an integer, or does not fit an `i32`.
33
+ *
34
+ * @example
35
+ * i32(10) // { type: "i32", value: 10 }
36
+ * i32(-42) // negative values are fine — i32 is the signed integer
37
+ */
38
+ declare function i32(value: number | bigint): I32Value;
39
+ /**
40
+ * A 256-bit unsigned integer, indexed for equality and range queries. The type for token amounts
41
+ * and anything else that can outgrow 2⁶⁴ — reach for {@link u64} first for counters, timestamps
42
+ * and block heights.
43
+ *
44
+ * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex
45
+ * string.
46
+ * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 256 bits.
47
+ *
48
+ * @example
49
+ * u256(1_000_000n)
50
+ * u256(Date.now()) // safe integers are accepted
51
+ * u256("0xf4240") // hex, as it comes back over JSON-RPC
52
+ */
53
+ declare function u256(value: bigint | number | string): U256Value;
54
+ /**
55
+ * A 64-bit unsigned integer, indexed for equality and range queries.
56
+ *
57
+ * This is the width the protocol counts in: block heights, `$expiresAt` and the entity-nonce are
58
+ * all `u64`, so it is the type to reach for when a value has to line up with one of them. Use
59
+ * {@link u256} for token amounts and anything else that can exceed 2⁶⁴.
60
+ *
61
+ * @param value - A non-negative integer, as a `bigint`, a safe `number`, or a decimal or `0x` hex
62
+ * string.
63
+ * @throws {InvalidValueError} If the value is negative, non-integral, or wider than 64 bits.
64
+ *
65
+ * @example
66
+ * u64(1_200_000n) // a block height
67
+ * u64(Date.now()) // safe integers are accepted
68
+ * u64("0x124f80") // hex, as it comes back over JSON-RPC
69
+ */
70
+ declare function u64(value: bigint | number | string): U64Value;
71
+ /**
72
+ * A signed fixed-point decimal with exactly 18 decimal places, indexed for equality and range
73
+ * queries.
74
+ *
75
+ * Pass fractional values as **strings**. A JavaScript number cannot represent most decimals
76
+ * exactly, so accepting `dec(0.1 + 0.2)` would quietly store `0.30000000000000004`; requiring the
77
+ * string keeps what you write and what is stored the same thing. Excess precision is likewise an
78
+ * error rather than a rounding.
79
+ *
80
+ * @param value - A decimal string, or an integral `number` / `bigint`.
81
+ * @throws {InvalidValueError} If the value is malformed, has more than 18 fractional digits, or
82
+ * falls outside the `int256` range.
83
+ *
84
+ * @example
85
+ * dec("3.5")
86
+ * dec("-0.000000000000000001") // the smallest step
87
+ * dec(5) // integers may be passed bare
88
+ */
89
+ declare function dec(value: string | number | bigint): DecValue;
90
+ /**
91
+ * The exact scaled integer behind a `dec` — the value multiplied by 10 ** 18, which is what the
92
+ * protocol stores and compares. Use it when you need exact arithmetic; JavaScript has no native
93
+ * decimal type, so the SDK carries the canonical string and leaves the maths to you.
94
+ *
95
+ * @example
96
+ * decUnits(dec("3.5")) // 3500000000000000000n
97
+ */
98
+ declare function decUnits(value: DecValue): bigint;
99
+ /**
100
+ * A `dec` built from its scaled integer units — the inverse of {@link decUnits}.
101
+ *
102
+ * @example
103
+ * decFromUnits(3_500_000_000_000_000_000n) // dec("3.5")
104
+ */
105
+ declare function decFromUnits(units: bigint): DecValue;
106
+ /**
107
+ * A UTF-8 string of at most 128 bytes, indexed for equality and prefix (`STARTSWITH`) matching.
108
+ *
109
+ * The limit is on **bytes**, not characters: a string of 128 emoji does not fit.
110
+ *
111
+ * C0 control characters and DEL are rejected: the query language writes a `str` as `str('...')`,
112
+ * whose only escape is a doubled quote, so a control character could be stored but never queried.
113
+ *
114
+ * @throws {InvalidValueError} If the value is not a string, holds a control character, or exceeds
115
+ * 128 UTF-8 bytes.
116
+ *
117
+ * @example
118
+ * str("Bob")
119
+ */
120
+ declare function str(value: string): StrValue;
121
+ /**
122
+ * A 20-byte Ethereum address, indexed for equality.
123
+ *
124
+ * All-lowercase and all-uppercase input carries no checksum and is accepted as-is; mixed-case
125
+ * input is checked against its EIP-55 checksum, so a mistyped address is caught here rather than
126
+ * being written to a wrong account. The stored value is always EIP-55 checksummed.
127
+ *
128
+ * @throws {InvalidValueError} If the value is not 20 hex bytes, or fails its EIP-55 checksum.
129
+ *
130
+ * @example
131
+ * addr("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
132
+ */
133
+ declare function addr(value: string): AddrValue;
134
+ /**
135
+ * A reference to another entity, indexed for equality.
136
+ *
137
+ * References are **weak**: nothing checks that the target exists when you write it, and a
138
+ * reference to a deleted or expired entity is allowed to dangle.
139
+ *
140
+ * @param value - A 32-byte entity key, as `0x` hex or raw bytes.
141
+ * @throws {InvalidValueError} If the value is not exactly 32 bytes.
142
+ *
143
+ * @example
144
+ * key(parentEntityKey)
145
+ */
146
+ declare function key(value: Hex | Uint8Array): KeyValue;
147
+ /**
148
+ * 32 opaque bytes — a hash, a digest, an identifier from another system — indexed for equality.
149
+ *
150
+ * Use {@link key} instead when the bytes are an Arkiv entity key: same wire width, but the
151
+ * distinct type makes the reference visible to readers and to the query language.
152
+ *
153
+ * @param value - 32 bytes, as `0x` hex or raw bytes.
154
+ * @throws {InvalidValueError} If the value is not exactly 32 bytes.
155
+ *
156
+ * @example
157
+ * bytes32(keccak256(toBytes("hello")))
158
+ */
159
+ declare function bytes32(value: Hex | Uint8Array): Bytes32Value;
160
+ /**
161
+ * A JavaScript value accepted wherever a typed value is expected: either a tagged value, or one of
162
+ * the four bare forms that map unambiguously onto a single type.
163
+ *
164
+ * | bare form | type |
165
+ * | --------- | ------- |
166
+ * | `boolean` | `bool` |
167
+ * | `number` | `i32` |
168
+ * | `bigint` | `u256` |
169
+ * | `string` | `str` |
170
+ *
171
+ * Anything else — a large number, a decimal, an address, an entity key — must name its type, which
172
+ * is what keeps `"0x1234..."` a string rather than silently becoming a key.
173
+ *
174
+ * These defaults apply identically when writing and when querying, so a value written bare and
175
+ * queried bare always agrees with itself. The mismatch to watch for is mixing the two: an attribute
176
+ * written as {@link u64} does not match a bare `bigint` predicate, because that predicate asserts
177
+ * `u256`. A type mismatch is not an error to the engine — it simply matches nothing.
178
+ */
179
+ type ValueInput = ArkivValue | boolean | number | bigint | string;
180
+ /**
181
+ * Resolves a {@link ValueInput} to a typed value, applying the bare-form defaults above. Tagged
182
+ * values pass through untouched.
183
+ *
184
+ * @param input - The value to resolve.
185
+ * @param attributeName - The attribute this value belongs to, used to make errors name it.
186
+ *
187
+ * @throws {MissingValueError} If the input is `undefined` or `null` — an attribute is either set
188
+ * with a value and a type, or not set at all.
189
+ * @throws {UntypedValueError} If the input is not a tagged value or a bare boolean, number, bigint
190
+ * or string.
191
+ * @throws {InvalidValueError} If a bare value does not fit the type it defaults to.
192
+ *
193
+ * @example
194
+ * toValue(10) // i32(10)
195
+ * toValue(10n) // u256(10n)
196
+ * toValue("hello") // str("hello")
197
+ * toValue(dec("3.5")) // unchanged
198
+ */
199
+ declare function toValue(input: ValueInput, attributeName?: string): ArkivValue;
200
+ //#endregion
201
+ //#region src/attr/attributes.d.ts
202
+ /**
203
+ * The most attribute cells one operation may carry.
204
+ */
205
+ declare const MAX_ATTRIBUTES = 32;
206
+ /**
207
+ * The largest payload an entity may carry, in bytes. The payload travels as the `$payload` system
208
+ * cell, so this is a bound on that one attribute rather than on the operation as a whole.
209
+ */
210
+ declare const MAX_PAYLOAD_BYTES: number;
211
+ /**
212
+ * The attributes written on an entity, as a plain object keyed by attribute name.
213
+ *
214
+ * Values may be tagged ({@link ArkivValue}) or bare where the type is unambiguous — see
215
+ * {@link toValue} for the bare-form defaults.
216
+ *
217
+ * @example
218
+ * const attributes = {
219
+ * level: i32(10),
220
+ * balance: u256(1_000_000n),
221
+ * score: dec("3.5"),
222
+ * parent: key(parentKey),
223
+ * name: "Bob", // bare string -> str
224
+ * flagged: true, // bare boolean -> bool
225
+ * } satisfies AttributeInputs
226
+ */
227
+ type AttributeInputs = Readonly<Record<string, ValueInput>>;
228
+ /**
229
+ * The attributes read back from an entity: the same shape, with every value typed.
230
+ *
231
+ * A value read from here drops straight back into an {@link AttributeInputs} — the vocabulary is the
232
+ * same in both directions.
233
+ */
234
+ type Attributes = Readonly<Record<string, AnyArkivValue>>;
235
+ /**
236
+ * The names and types of an entity's attributes, with no values — what the `attributeSchema`
237
+ * projection returns.
238
+ *
239
+ * Useful for asking what shape the data has without paying to transfer it, and for telling apart
240
+ * two entities that use the same name with different types.
241
+ */
242
+ type AttributeSchema = Readonly<Record<string, TypeTag>>;
243
+ //#endregion
244
+ //#region src/attr/decimal.d.ts
245
+ /**
246
+ * Decimal places a `dec` value is scaled by. Fixed by the protocol, so any two decimals are
247
+ * directly comparable — and range-indexable — as plain integers.
248
+ */
249
+ declare const DECIMAL_SCALE = 18;
250
+ /** 10 ** {@link DECIMAL_SCALE} — the scaling factor between a `dec` and its integer units. */
251
+ declare const DECIMAL_UNIT: bigint;
252
+ //#endregion
253
+ //#region src/attr/errors.d.ts
254
+ /**
255
+ * A value was rejected by its tagged constructor — out of range, wrong length, bad checksum, too
256
+ * much precision, and so on.
257
+ *
258
+ * The message names the offending value and, where there is one, the type that *would* hold it, so
259
+ * the fix is in the error rather than in the docs.
260
+ */
261
+ declare class InvalidValueError extends Error {
262
+ /** The type tag whose constructor rejected the value. */
263
+ readonly tag: TypeTag;
264
+ /** The rejected input, as given. */
265
+ readonly input: unknown;
266
+ constructor(tag: TypeTag, input: unknown, reason: string, hint?: string);
267
+ }
268
+ /**
269
+ * A bare JavaScript value could not be given a type. Raised when an attribute or predicate is
270
+ * handed something that is neither a tagged value nor one of the four bare forms
271
+ * (`boolean`, `number`, `bigint`, `string`).
272
+ */
273
+ declare class UntypedValueError extends Error {
274
+ readonly input: unknown;
275
+ constructor(input: unknown);
276
+ }
277
+ /**
278
+ * An attribute was given `undefined` or `null` as its value.
279
+ *
280
+ * There is no such thing as an attribute with no value: an attribute either exists with a type, or
281
+ * is not set. The fix is always to leave the name out of the map rather than to write an empty
282
+ * value, so this is called out separately from {@link UntypedValueError} — the remedy is different.
283
+ */
284
+ declare class MissingValueError extends Error {
285
+ /** The attribute whose value was missing, when raised from an attribute map. */
286
+ readonly attributeName: string | undefined;
287
+ constructor(input: null | undefined, attributeName?: string);
288
+ }
289
+ /** An attribute name violated the on-chain name grammar. */
290
+ declare class InvalidAttributeNameError extends Error {
291
+ readonly attributeName: string;
292
+ constructor(attributeName: string, reason: string);
293
+ }
294
+ /**
295
+ * One patch tried to both write and remove the same attribute.
296
+ */
297
+ declare class ConflictingMutationError extends Error {
298
+ readonly attributeName: string;
299
+ constructor(attributeName: string);
300
+ }
301
+ /** More attributes were supplied than an entity operation can carry. */
302
+ declare class TooManyAttributesError extends Error {
303
+ constructor(count: number, max: number);
304
+ }
305
+ /** The node sent back an attribute this SDK cannot decode. */
306
+ declare class UnknownAttributeTypeError extends Error {
307
+ /** The type as the node named it — a tag over JSON-RPC, a typeId on the wire. */
308
+ readonly type: string | number;
309
+ constructor(type: string | number);
310
+ }
311
+ //#endregion
312
+ //#region src/attr/names.d.ts
313
+ /** The longest attribute name, in bytes — the width of the on-chain `Ident32` name cell. */
314
+ declare const MAX_NAME_BYTES = 32;
315
+ /**
316
+ * Validates an attribute name against the engine's `Ident32` grammar and the query language's
317
+ * reserved words.
318
+ *
319
+ * @param name - The attribute name.
320
+ * @throws {InvalidAttributeNameError} If the name is empty, too long, uses characters outside the
321
+ * grammar, or collides with a reserved word.
322
+ */
323
+ declare function validateAttributeName(name: string): void;
324
+ /** Whether `name` is a valid attribute name — the non-throwing form of {@link validateAttributeName}. */
325
+ declare function isValidAttributeName(name: string): boolean;
326
+ //#endregion
327
+ export { i32 as A, ValueInput as C, dec as D, bytes32 as E, u64 as F, str as M, toValue as N, decFromUnits as O, u256 as P, U64_MAX as S, bool as T, MAX_PAYLOAD_BYTES as _, InvalidAttributeNameError as a, MAX_STRING_BYTES as b, TooManyAttributesError as c, DECIMAL_SCALE as d, DECIMAL_UNIT as f, MAX_ATTRIBUTES as g, Attributes as h, ConflictingMutationError as i, key as j, decUnits as k, UnknownAttributeTypeError as l, AttributeSchema as m, isValidAttributeName as n, InvalidValueError as o, AttributeInputs as p, validateAttributeName as r, MissingValueError as s, MAX_NAME_BYTES as t, UntypedValueError as u, I32_MAX as v, addr as w, U256_MAX as x, I32_MIN as y };
328
+ //# sourceMappingURL=index-D0IzFwMX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D0IzFwMX.d.ts","names":[],"sources":["../src/attr/values.ts","../src/attr/attributes.ts","../src/attr/decimal.ts","../src/attr/errors.ts","../src/attr/names.ts"],"sourcesContent":[],"mappings":";;;;;cA6Ba,OAAA;AAAb;AAE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B,KAAA,CF5CN;;;;AClDzB,cCsGA,yBAAA,SAAkC,KAAA,CDtGrB;EAGb;;;;;;;cENA,cAAA;;;AJ0Bb;AAEA;AAEA;AAEA;AAIA;AAsBA;AAkBgB,iBIzBA,qBAAA,CJyBqC,IAAA,EAAA,MAAA,CAAA,EAAA,IAAA;AA8CrD;AAoBgB,iBI/CA,oBAAA,CJ+C8C,IAAA,EAAA,MAAA,CAAA,EAAA,OAAA"}
@@ -0,0 +1,177 @@
1
+ import { Address, Hex } from "viem";
2
+
3
+ //#region src/entity/operations.d.ts
4
+
5
+ /** One entry of the `execute` batch: the operation tag and its ABI-encoded payload. */
6
+ type Operation = {
7
+ operation: number;
8
+ operationData: Hex;
9
+ };
10
+ //#endregion
11
+ //#region src/entity/key.d.ts
12
+ /** The widest salt the `uint128` wire field carries. */
13
+ declare const MAX_SALT: bigint;
14
+ /**
15
+ * Opts a create out of salting, as {@link CreateEntityParameters.salt}: the key is then derived
16
+ * from the owner and its nonce alone, so anyone who knows both can work it out before the create
17
+ * lands.
18
+ */
19
+ declare const NO_SALT: unique symbol;
20
+ /**
21
+ * A salt as a caller expresses it: an explicit `uint128`, or {@link NO_SALT} to opt out of salting.
22
+ */
23
+ type SaltInput = bigint | typeof NO_SALT;
24
+ /**
25
+ * A cryptographically random 128-bit salt — what {@link CreateEntityParameters.salt} defaults to.
26
+ *
27
+ * The salt exists for unpredictability, not uniqueness: the per-owner nonce already guarantees
28
+ * distinct keys. Random bits mean only the creator can predict the key of an entity they are about
29
+ * to create, so nobody else can reference or squat it in advance.
30
+ *
31
+ * @throws {NoRandomSourceError} If the runtime has no `crypto.getRandomValues`.
32
+ */
33
+ declare function randomSalt(): bigint;
34
+ /**
35
+ * The key an entity will be created with, derived exactly as the engine derives it:
36
+ * `keccak256(domain ++ owner ++ nonce ++ salt)`.
37
+ *
38
+ * Deriving it client-side is what lets a batch compose: predict the key of a create, then have a
39
+ * later operation in the same transaction reference it, or store it as a `key` attribute on a
40
+ * sibling entity.
41
+ */
42
+ declare function predictEntityKey({
43
+ owner,
44
+ nonce,
45
+ salt,
46
+ chainId
47
+ }: {
48
+ /** The account creating the entity. */
49
+ owner: Address;
50
+ /**
51
+ * The owner's entity-nonce at creation time. Each create in a batch consumes one, so the *n*th
52
+ * create in a batch uses `nonce + n`.
53
+ */
54
+ nonce: bigint;
55
+ /** The salt the create will carry, or {@link NO_SALT} if it carries none. */
56
+ salt: SaltInput;
57
+ /** The chain the entity is being created on — half of the derivation domain. */
58
+ chainId: number;
59
+ }): Hex;
60
+ //#endregion
61
+ //#region src/entity/errors.d.ts
62
+ /** An expiry could not be expressed, or would be rejected by the engine. */
63
+ declare class InvalidExpiryError extends Error {
64
+ constructor(reason: string);
65
+ }
66
+ /** A `creationFlags` byte could not be built or read. */
67
+ declare class InvalidCreationFlagsError extends Error {
68
+ constructor(reason: string);
69
+ }
70
+ /** A key salt was outside the `uint128` the wire carries. */
71
+ declare class InvalidSaltError extends Error {
72
+ constructor(salt: unknown);
73
+ }
74
+ /** No cryptographic randomness was available to generate a salt. */
75
+ declare class NoRandomSourceError extends Error {
76
+ constructor();
77
+ }
78
+ //#endregion
79
+ //#region src/entity/events.d.ts
80
+ /**
81
+ * The events the engine emits: one per applied operation, in application order, so an off-chain
82
+ * replica can replay a transaction operation by operation.
83
+ */
84
+ declare const ENTITY_EVENTS_ABI: readonly [{
85
+ readonly name: "EntityCreated";
86
+ readonly type: "event";
87
+ readonly inputs: readonly [{
88
+ readonly type: "bytes32";
89
+ readonly name: "entityKey";
90
+ readonly indexed: true;
91
+ }, {
92
+ readonly type: "address";
93
+ readonly name: "owner";
94
+ readonly indexed: true;
95
+ }, {
96
+ readonly type: "uint64";
97
+ readonly name: "expiresAt";
98
+ }, {
99
+ readonly type: "uint8";
100
+ readonly name: "creationFlags";
101
+ }];
102
+ }, {
103
+ readonly name: "EntityPatched";
104
+ readonly type: "event";
105
+ readonly inputs: readonly [{
106
+ readonly type: "bytes32";
107
+ readonly name: "entityKey";
108
+ readonly indexed: true;
109
+ }, {
110
+ readonly type: "address";
111
+ readonly name: "owner";
112
+ readonly indexed: true;
113
+ }];
114
+ }, {
115
+ readonly name: "ExpiryExtended";
116
+ readonly type: "event";
117
+ readonly inputs: readonly [{
118
+ readonly type: "bytes32";
119
+ readonly name: "entityKey";
120
+ readonly indexed: true;
121
+ }, {
122
+ readonly type: "address";
123
+ readonly name: "owner";
124
+ readonly indexed: true;
125
+ }, {
126
+ readonly type: "uint64";
127
+ readonly name: "expiresAt";
128
+ }];
129
+ }, {
130
+ readonly name: "OwnershipTransferred";
131
+ readonly type: "event";
132
+ readonly inputs: readonly [{
133
+ readonly type: "bytes32";
134
+ readonly name: "entityKey";
135
+ readonly indexed: true;
136
+ }, {
137
+ readonly type: "address";
138
+ readonly name: "previousOwner";
139
+ readonly indexed: true;
140
+ }, {
141
+ readonly type: "address";
142
+ readonly name: "newOwner";
143
+ readonly indexed: true;
144
+ }];
145
+ }, {
146
+ readonly name: "EntityDeleted";
147
+ readonly type: "event";
148
+ readonly inputs: readonly [{
149
+ readonly type: "bytes32";
150
+ readonly name: "entityKey";
151
+ readonly indexed: true;
152
+ }, {
153
+ readonly type: "address";
154
+ readonly name: "owner";
155
+ readonly indexed: true;
156
+ }];
157
+ }];
158
+ /** The name of each event in {@link ENTITY_EVENTS_ABI}. */
159
+ type EntityEventName = (typeof ENTITY_EVENTS_ABI)[number]["name"];
160
+ //#endregion
161
+ //#region src/entity/params.d.ts
162
+ /**
163
+ * Max uint64 value
164
+ */
165
+ declare const MAX_EXPIRES_AT: bigint;
166
+ /** The operation tags of the `execute` ABI's tagged union. */
167
+ declare const OperationType: {
168
+ readonly Create: 1;
169
+ readonly Patch: 2;
170
+ readonly ExtendExpiry: 3;
171
+ readonly TransferOwnership: 4;
172
+ readonly Delete: 5;
173
+ };
174
+ type OperationType = (typeof OperationType)[keyof typeof OperationType];
175
+ //#endregion
176
+ export { InvalidCreationFlagsError as a, NoRandomSourceError as c, SaltInput as d, predictEntityKey as f, EntityEventName as i, MAX_SALT as l, Operation as m, OperationType as n, InvalidExpiryError as o, randomSalt as p, ENTITY_EVENTS_ABI as r, InvalidSaltError as s, MAX_EXPIRES_AT as t, NO_SALT as u };
177
+ //# sourceMappingURL=index-DZxwz2Ky.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DZxwz2Ky.d.cts","names":[],"sources":["../src/entity/operations.ts","../src/entity/key.ts","../src/entity/errors.ts","../src/entity/events.ts","../src/entity/params.ts"],"sourcesContent":[],"mappings":";;;;;KAiDY,SAAA;;iBAEK;;;;;cC7CJ;AD2Cb;;;;AC3CA;AAOa,cAAA,OAA2B,EAAA,OAAA,MAAA;AAKxC;AAWA;AAkCA;AACE,KA9CU,SAAA,GA8CV,MAAA,GAAA,OA9CsC,OA8CtC;;;;;;;;;;iBAnCc,UAAA,CAAA;;AEvBhB;AASA;;;;ACZA;AAGA;AAQY,iBHiDI,gBAAA,CGjDoB;EAAA,KAA4B;EAAA,KAAA;EAAA,IAAa;EAAA;CAAA,EAAA;;SHwDpE;;;;;;;QAOD;;;IAGJ;;;;cC/ES,kBAAA,SAA2B,KAAA;;AFgDxC;;cExCa,yBAAA,SAAkC,KAAA;;ADH/C;AAOA;AAKY,cCDC,gBAAA,SAAyB,KAAA,CDCS;EAW/B,WAAA,CAAA,IAAU,EAAA,OAAA;AAkC1B;;AAEE,cCpCW,mBAAA,SAA4B,KAAA,CDoCvC;EACA,WAAA,CAAA;;;;;;;ADjBF;cG3Ca;;;EFAA,SAAA,MAA0B,EAAA,SAAA,CAAA;IAO1B,SAA2B,IAAA,EAAA,SAAA;IAK5B,SAAS,IAAA,EAAA,WAAmB;IAWxB,SAAU,OAAA,EAAA,IAAA;EAkCV,CAAA,EAAA;IACd,SAAA,IAAA,EAAA,SAAA;IACA,SAAA,IAAA,EAAA,OAAA;IACA,SAAA,OAAA,EAAA,IAAA;EACA,CAAA,EAAA;IAGO,SAAA,IAAA,EAAA,QAAA;IAOD,SAAA,IA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