@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.
- package/dist/attr/index.cjs +1 -1
- package/dist/attr/index.d.cts +1 -1
- package/dist/attr/index.d.ts +1 -1
- package/dist/attr/index.js +1 -1
- package/dist/{attr-BvxHN99W.cjs → attr-BXTkpnoc.cjs} +13 -3
- package/dist/{attr-BDZ-APg5.js → attr-tmyREHtw.js} +14 -4
- package/dist/attr-tmyREHtw.js.map +1 -0
- package/dist/chains/index.cjs +1 -1
- package/dist/chains/index.d.cts +3 -0
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +3 -0
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/{chains-BYRTTipa.cjs → chains-BfNQliHU.cjs} +3 -0
- package/dist/{chains-BJrZs6sG.js → chains-Du8tql7I.js} +4 -1
- package/dist/chains-Du8tql7I.js.map +1 -0
- package/dist/{changeOwnership-DwgtdSFc.d.ts → changeOwnership-B0ar96ub.d.ts} +47 -34
- package/dist/changeOwnership-B0ar96ub.d.ts.map +1 -0
- package/dist/{changeOwnership-B7bEgla4.d.cts → changeOwnership-BofkLnXJ.d.cts} +47 -34
- package/dist/changeOwnership-BofkLnXJ.d.cts.map +1 -0
- package/dist/entity/index.cjs +5 -4
- package/dist/entity/index.d.cts +2 -2
- package/dist/entity/index.d.ts +2 -2
- package/dist/entity/index.js +5 -5
- package/dist/{entity-CFhbAv0R.js → entity-CniBgBSd.js} +17 -5
- package/dist/entity-CniBgBSd.js.map +1 -0
- package/dist/{entity-wfBnZd91.cjs → entity-DJ0Gml9c.cjs} +23 -5
- package/dist/{errors-DGB8AgT2.js → errors-D2E1GRjw.js} +2 -2
- package/dist/errors-D2E1GRjw.js.map +1 -0
- package/dist/{errors-D-eJkGVc.cjs → errors-DhV00966.cjs} +1 -1
- package/dist/expiry-BxOlvVWC.d.ts.map +1 -1
- package/dist/{expiry-BUYIXTGb.cjs → expiry-CG9GhVXv.cjs} +1 -1
- package/dist/{expiry-DGRzrSan.js → expiry-Cgdb_dbq.js} +2 -2
- package/dist/expiry-Cgdb_dbq.js.map +1 -0
- package/dist/expiry-DRV29F1r.d.cts.map +1 -1
- package/dist/{flags-Ct8k0gpB.cjs → flags-DCD26uhe.cjs} +1 -1
- package/dist/{flags-ZtlvOIIk.js → flags-DUT2gHEU.js} +2 -2
- package/dist/{flags-ZtlvOIIk.js.map → flags-DUT2gHEU.js.map} +1 -1
- package/dist/{index-D0CmtiWT.d.cts → index-BGp2plHs.d.cts} +15 -5
- package/dist/index-BGp2plHs.d.cts.map +1 -0
- package/dist/{index-VCqgn29D.d.ts → index-BKB875Um.d.ts} +4 -4
- package/dist/{index-VCqgn29D.d.ts.map → index-BKB875Um.d.ts.map} +1 -1
- package/dist/{index-DVYFaXNV.d.ts → index-CIcHPx2j.d.cts} +13 -6
- package/dist/index-CIcHPx2j.d.cts.map +1 -0
- package/dist/{index-D8LZt-3J.d.cts → index-Cd2aaWme.d.ts} +13 -6
- package/dist/index-Cd2aaWme.d.ts.map +1 -0
- package/dist/{index-ClgIuxJ8.d.ts → index-ezMZ2-JH.d.ts} +15 -5
- package/dist/index-ezMZ2-JH.d.ts.map +1 -0
- package/dist/{index-Cgw1u5aY.d.cts → index-rINthNuU.d.cts} +4 -4
- package/dist/{index-Cgw1u5aY.d.cts.map → index-rINthNuU.d.cts.map} +1 -1
- package/dist/index.cjs +59 -50
- package/dist/index.d.cts +58 -50
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +58 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -51
- package/dist/index.js.map +1 -1
- package/dist/{payload-Dgx3PQeK.d.ts → payload-CGvVPZQX.d.ts} +60 -1
- package/dist/payload-CGvVPZQX.d.ts.map +1 -0
- package/dist/{payload-CIxSn_DW.js → payload-DE7wMztL.js} +28 -3
- package/dist/payload-DE7wMztL.js.map +1 -0
- package/dist/{payload-P0nWyjLg.d.cts → payload-Dfu30njp.d.cts} +60 -1
- package/dist/payload-Dfu30njp.d.cts.map +1 -0
- package/dist/{payload-Bnw1hrvb.cjs → payload-DqFweqiO.cjs} +27 -2
- package/dist/query/index.cjs +4 -4
- package/dist/query/index.d.cts +3 -3
- package/dist/query/index.d.ts +3 -3
- package/dist/query/index.js +4 -4
- package/dist/{queryBuilder-CbLL4pG5.js → queryBuilder-COWt6aIF.js} +17 -12
- package/dist/queryBuilder-COWt6aIF.js.map +1 -0
- package/dist/{queryBuilder-BXDvX1K_.cjs → queryBuilder-DaLxNgeI.cjs} +16 -11
- package/dist/{selection-BvK6yX0g.d.cts → selection-Bv8_o-7i.d.cts} +16 -8
- package/dist/selection-Bv8_o-7i.d.cts.map +1 -0
- package/dist/{selection-fpmI3ADQ.d.ts → selection-ox7zdtVm.d.ts} +16 -8
- package/dist/selection-ox7zdtVm.d.ts.map +1 -0
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -3
- package/package.json +1 -5
- package/src/actions/public/getEntity.ts +1 -0
- package/src/actions/public/predictEntityKeys.test.ts +17 -1
- package/src/actions/public/predictEntityKeys.ts +28 -14
- package/src/actions/wallet/createEntity.ts +8 -6
- package/src/actions/wallet/{mutateEntities.test.ts → executeBatch.test.ts} +7 -7
- package/src/actions/wallet/{mutateEntities.ts → executeBatch.ts} +9 -9
- package/src/actions/wallet/extendEntity.ts +2 -0
- package/src/actions/wallet/patchEntity.ts +3 -3
- package/src/attr/attributes.ts +8 -2
- package/src/attr/errors.ts +2 -2
- package/src/attr/types.ts +3 -3
- package/src/attr/values.ts +5 -1
- package/src/chains/localhost.ts +3 -0
- package/src/clients/createPublicClient.test.ts +1 -1
- package/src/clients/createPublicClient.ts +5 -5
- package/src/clients/createWalletClient.test.ts +2 -2
- package/src/clients/createWalletClient.ts +3 -5
- package/src/clients/decorators/arkivPublic.ts +13 -12
- package/src/clients/decorators/arkivWallet.ts +40 -32
- package/src/entity/create.test.ts +20 -1
- package/src/entity/errors.ts +4 -3
- package/src/entity/expiry.ts +1 -0
- package/src/entity/index.ts +2 -1
- package/src/entity/key.ts +23 -3
- package/src/entity/operations.ts +1 -0
- package/src/errors.ts +7 -2
- package/src/query/errors.ts +1 -1
- package/src/query/expression.ts +14 -7
- package/src/query/queryBuilder.ts +1 -1
- package/src/types/index.ts +4 -4
- package/src/types/rpcSchema.ts +1 -0
- package/src/types/txParams.ts +8 -0
- package/src/utils/arkivTransactions.test.ts +7 -1
- package/src/utils/arkivTransactions.ts +10 -5
- package/src/utils/expirationTime.ts +39 -0
- package/src/utils/payload.ts +25 -0
- package/dist/attr-BDZ-APg5.js.map +0 -1
- package/dist/chains-BJrZs6sG.js.map +0 -1
- package/dist/changeOwnership-B7bEgla4.d.cts.map +0 -1
- package/dist/changeOwnership-DwgtdSFc.d.ts.map +0 -1
- package/dist/entity-CFhbAv0R.js.map +0 -1
- package/dist/errors-DGB8AgT2.js.map +0 -1
- package/dist/expiry-DGRzrSan.js.map +0 -1
- package/dist/index-ClgIuxJ8.d.ts.map +0 -1
- package/dist/index-D0CmtiWT.d.cts.map +0 -1
- package/dist/index-D8LZt-3J.d.cts.map +0 -1
- package/dist/index-DVYFaXNV.d.ts.map +0 -1
- package/dist/payload-CIxSn_DW.js.map +0 -1
- package/dist/payload-Dgx3PQeK.d.ts.map +0 -1
- package/dist/payload-P0nWyjLg.d.cts.map +0 -1
- package/dist/queryBuilder-CbLL4pG5.js.map +0 -1
- package/dist/selection-BvK6yX0g.d.cts.map +0 -1
- package/dist/selection-fpmI3ADQ.d.ts.map +0 -1
package/src/entity/index.ts
CHANGED
|
@@ -10,5 +10,6 @@ export type { EncodedExpiry, Expiry, ExpiryContext, Lifetime, ResolvedExpiry } f
|
|
|
10
10
|
export { resolveExpiry, toBlocks } from "./expiry"
|
|
11
11
|
export type { CreationFlags, ResolvedCreationFlags } from "./flags"
|
|
12
12
|
export { decodeCreationFlags, encodeCreationFlags } from "./flags"
|
|
13
|
-
export {
|
|
13
|
+
export type { SaltInput } from "./key"
|
|
14
|
+
export { MAX_SALT, NO_SALT, predictEntityKey, randomSalt } from "./key"
|
|
14
15
|
export { MAX_EXPIRES_AT, OperationType } from "./params"
|
package/src/entity/key.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { type Address, encodePacked, type Hex, keccak256 } from "viem"
|
|
2
|
+
import type { CreateEntityParameters } from "../actions/wallet/createEntity"
|
|
2
3
|
import { ARKIV_ADDRESS } from "../consts"
|
|
3
4
|
import { InvalidSaltError, NoRandomSourceError } from "./errors"
|
|
4
5
|
|
|
5
6
|
/** The widest salt the `uint128` wire field carries. */
|
|
6
7
|
export const MAX_SALT = 2n ** 128n - 1n
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Opts a create out of salting, as {@link CreateEntityParameters.salt}: the key is then derived
|
|
11
|
+
* from the owner and its nonce alone, so anyone who knows both can work it out before the create
|
|
12
|
+
* lands.
|
|
13
|
+
*/
|
|
14
|
+
export const NO_SALT = Symbol("NO_SALT")
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A salt as a caller expresses it: an explicit `uint128`, or {@link NO_SALT} to opt out of salting.
|
|
18
|
+
*/
|
|
19
|
+
export type SaltInput = bigint | typeof NO_SALT
|
|
20
|
+
|
|
8
21
|
/**
|
|
9
22
|
* A cryptographically random 128-bit salt — what {@link CreateEntityParameters.salt} defaults to.
|
|
10
23
|
*
|
|
@@ -25,6 +38,13 @@ export function randomSalt(): bigint {
|
|
|
25
38
|
return salt
|
|
26
39
|
}
|
|
27
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Resolves a caller-supplied salt to a `uint128`.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveSalt(salt: SaltInput): bigint {
|
|
45
|
+
return salt === NO_SALT ? 0n : validateSalt(salt)
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
/** Validates a caller-supplied salt against the `uint128` wire field. */
|
|
29
49
|
export function validateSalt(salt: bigint): bigint {
|
|
30
50
|
if (typeof salt !== "bigint" || salt < 0n || salt > MAX_SALT) {
|
|
@@ -54,15 +74,15 @@ export function predictEntityKey({
|
|
|
54
74
|
* create in a batch uses `nonce + n`.
|
|
55
75
|
*/
|
|
56
76
|
nonce: bigint
|
|
57
|
-
/** The salt the create will carry. */
|
|
58
|
-
salt:
|
|
77
|
+
/** The salt the create will carry, or {@link NO_SALT} if it carries none. */
|
|
78
|
+
salt: SaltInput
|
|
59
79
|
/** The chain the entity is being created on — half of the derivation domain. */
|
|
60
80
|
chainId: number
|
|
61
81
|
}): Hex {
|
|
62
82
|
return keccak256(
|
|
63
83
|
encodePacked(
|
|
64
84
|
["uint256", "address", "address", "uint64", "uint128"],
|
|
65
|
-
[BigInt(chainId), ARKIV_ADDRESS, owner, nonce,
|
|
85
|
+
[BigInt(chainId), ARKIV_ADDRESS, owner, nonce, resolveSalt(salt)],
|
|
66
86
|
),
|
|
67
87
|
)
|
|
68
88
|
}
|
package/src/entity/operations.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address, encodeAbiParameters, type Hex, parseAbi, parseAbiParameters } from "viem"
|
|
2
2
|
import type { AbiAttribute } from "../attr/codec"
|
|
3
3
|
import type { EncodedExpiry } from "./expiry"
|
|
4
|
+
import type { predictEntityKey } from "./key"
|
|
4
5
|
import { OperationType } from "./params"
|
|
5
6
|
|
|
6
7
|
/**
|
package/src/errors.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { Hex } from "viem"
|
|
2
|
+
|
|
1
3
|
export class EntityMutationError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
readonly txHash: Hex | undefined
|
|
5
|
+
|
|
6
|
+
constructor(message: string, options?: { cause?: unknown; txHash?: Hex | undefined }) {
|
|
7
|
+
super(message, { cause: options?.cause })
|
|
4
8
|
this.name = "EntityMutationError"
|
|
9
|
+
this.txHash = options?.txHash
|
|
5
10
|
}
|
|
6
11
|
}
|
|
7
12
|
export class NoMoreResultsError extends Error {
|
package/src/query/errors.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { TypeTag } from "../attr"
|
|
|
10
10
|
* | | `=` `!=` | `<` `<=` `>` `>=` | `STARTSWITH` |
|
|
11
11
|
* | --- | --- | --- | --- |
|
|
12
12
|
* | `bool` | yes | no | no |
|
|
13
|
-
* | `i32` `u256` `dec` | yes | yes | no |
|
|
13
|
+
* | `i32` `u64` `u256` `dec` | yes | yes | no |
|
|
14
14
|
* | `str` | yes | no | yes |
|
|
15
15
|
* | `addr` `key` `bytes32` | yes | no | no |
|
|
16
16
|
*/
|
package/src/query/expression.ts
CHANGED
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
import { TYPE_IDS } from "../attr/types"
|
|
13
13
|
import { InvalidPredicateError, UnsupportedOperatorError } from "./errors"
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The comparison operators the query language defines. `<` `<=` `>` `>=` need an ordered type —
|
|
17
|
+
* `i32`, `u64`, `u256` or `dec`; every type accepts `=` and `!=`.
|
|
18
|
+
*/
|
|
15
19
|
export type ComparisonOperator = "=" | "!=" | "<" | "<=" | ">" | ">="
|
|
16
20
|
|
|
17
21
|
/** A comparison between an attribute and a typed literal. */
|
|
@@ -216,7 +220,7 @@ export function ne(name: string, value: ValueInput): ComparisonNode {
|
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
/**
|
|
219
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
223
|
+
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
220
224
|
*
|
|
221
225
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
222
226
|
*
|
|
@@ -229,7 +233,7 @@ export function gt(name: string, value: ValueInput): ComparisonNode {
|
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
/**
|
|
232
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
236
|
+
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
233
237
|
*
|
|
234
238
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
235
239
|
*
|
|
@@ -241,7 +245,7 @@ export function gte(name: string, value: ValueInput): ComparisonNode {
|
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
/**
|
|
244
|
-
* Attribute is less than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
248
|
+
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
245
249
|
*
|
|
246
250
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
247
251
|
*
|
|
@@ -253,7 +257,7 @@ export function lt(name: string, value: ValueInput): ComparisonNode {
|
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
/**
|
|
256
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
260
|
+
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
257
261
|
*
|
|
258
262
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
259
263
|
*
|
|
@@ -271,7 +275,9 @@ export function lte(name: string, value: ValueInput): ComparisonNode {
|
|
|
271
275
|
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
272
276
|
*
|
|
273
277
|
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
274
|
-
* @throws {
|
|
278
|
+
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
279
|
+
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
280
|
+
* (none of which is a `str`).
|
|
275
281
|
*
|
|
276
282
|
* @example
|
|
277
283
|
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
@@ -325,7 +331,8 @@ export function exists(name: string): ExistsNode {
|
|
|
325
331
|
* Useful when the same name is written with different types across entities — a comparison already
|
|
326
332
|
* asserts the type, so this is for asking about the type alone.
|
|
327
333
|
*
|
|
328
|
-
* @param tag - The type tag: `bool`, `i32`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
334
|
+
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
335
|
+
* `key`.
|
|
329
336
|
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
330
337
|
* attribute (whose type is fixed).
|
|
331
338
|
*
|
|
@@ -344,7 +351,7 @@ export function hasType(name: string, tag: UserTypeTag): TypeOfNode {
|
|
|
344
351
|
if (!isUserTypeTag(tag)) {
|
|
345
352
|
throw new InvalidPredicateError(
|
|
346
353
|
`"${tag}" is not a settable attribute type. Use one of ` +
|
|
347
|
-
"bool, i32, u256, dec, bytes32, str, addr, key.",
|
|
354
|
+
"bool, i32, u64, u256, dec, bytes32, str, addr, key.",
|
|
348
355
|
name,
|
|
349
356
|
)
|
|
350
357
|
}
|
|
@@ -5,7 +5,7 @@ import type { Entity } from "../types/entity"
|
|
|
5
5
|
import type { RpcSelect } from "../types/rpcSchema"
|
|
6
6
|
import { type QueryRequest, runQuery } from "./engine"
|
|
7
7
|
import { InvalidPredicateError } from "./errors"
|
|
8
|
-
import { and, type Expression, eq } from "./expression"
|
|
8
|
+
import { and, type Expression, eq, type or } from "./expression"
|
|
9
9
|
import { QueryResult } from "./queryResult"
|
|
10
10
|
import { type SelectArg, toRpcSelect } from "./selection"
|
|
11
11
|
|
package/src/types/index.ts
CHANGED
|
@@ -12,11 +12,11 @@ export type {
|
|
|
12
12
|
} from "../actions/wallet/changeOwnership"
|
|
13
13
|
export type { CreateEntityParameters, CreateEntityReturnType } from "../actions/wallet/createEntity"
|
|
14
14
|
export type { DeleteEntityParameters, DeleteEntityReturnType } from "../actions/wallet/deleteEntity"
|
|
15
|
-
export type { ExtendEntityParameters, ExtendEntityReturnType } from "../actions/wallet/extendEntity"
|
|
16
15
|
export type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "../actions/wallet/
|
|
16
|
+
ExecuteBatchParameters,
|
|
17
|
+
ExecuteBatchReturnType,
|
|
18
|
+
} from "../actions/wallet/executeBatch"
|
|
19
|
+
export type { ExtendEntityParameters, ExtendEntityReturnType } from "../actions/wallet/extendEntity"
|
|
20
20
|
export type { PatchEntityParameters, PatchEntityReturnType } from "../actions/wallet/patchEntity"
|
|
21
21
|
export type { EntityFields } from "./entity"
|
|
22
22
|
export { Entity } from "./entity"
|
package/src/types/rpcSchema.ts
CHANGED
|
@@ -69,6 +69,7 @@ export type RpcSelect = {
|
|
|
69
69
|
attributes?: boolean | Record<string, boolean>
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
|
|
72
73
|
export type RpcQueryOptions = {
|
|
73
74
|
/** Block height to read at, as a hex quantity. Defaults to the head, and must be within the node's retained range. */
|
|
74
75
|
atBlock?: Hex
|
package/src/types/txParams.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction fields a write action passes through to the wallet, for the cases where the defaults
|
|
3
|
+
* are not what you want.
|
|
4
|
+
*
|
|
5
|
+
* Fee style is either/or: give `gasPrice` for a legacy transaction, or `maxFeePerGas` /
|
|
6
|
+
* `maxPriorityFeePerGas` for an EIP-1559 one. Mixing the two does not typecheck. Anything left out
|
|
7
|
+
* is estimated.
|
|
8
|
+
*/
|
|
1
9
|
export type TxParams =
|
|
2
10
|
| {
|
|
3
11
|
gas?: bigint
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "../attr"
|
|
24
24
|
import type { ArkivClient } from "../clients/baseClient"
|
|
25
25
|
import { ARKIV_ADDRESS } from "../consts"
|
|
26
|
-
import { InvalidExpiryError } from "../entity"
|
|
26
|
+
import { InvalidExpiryError, NO_SALT } from "../entity"
|
|
27
27
|
import { ENTITY_EVENTS_ABI, type EntityEventName } from "../entity/events"
|
|
28
28
|
import { MAX_EXPIRES_AT, OperationType } from "../entity/params"
|
|
29
29
|
import { EmptyPatchError, EntityMutationError } from "../errors"
|
|
@@ -304,6 +304,12 @@ describe("creation flags and salt", () => {
|
|
|
304
304
|
expect(sentCreate(w2).salt).toBe(0n)
|
|
305
305
|
})
|
|
306
306
|
|
|
307
|
+
it("sends a zero salt for a create that opts out with NO_SALT", async () => {
|
|
308
|
+
const { client, writeContract } = makeClient()
|
|
309
|
+
await sendArkivTransaction(client, { creates: [{ ...validCreate, salt: NO_SALT }] })
|
|
310
|
+
expect(sentCreate(writeContract).salt).toBe(0n)
|
|
311
|
+
})
|
|
312
|
+
|
|
307
313
|
it("rejects a salt wider than the uint128 field", async () => {
|
|
308
314
|
const { client } = makeClient()
|
|
309
315
|
await expect(
|
|
@@ -21,7 +21,7 @@ import { ARKIV_ADDRESS } from "../consts"
|
|
|
21
21
|
import { ENTITY_EVENTS_ABI } from "../entity/events"
|
|
22
22
|
import { resolveExpiry } from "../entity/expiry"
|
|
23
23
|
import { encodeCreationFlags } from "../entity/flags"
|
|
24
|
-
import { randomSalt,
|
|
24
|
+
import { randomSalt, resolveSalt } from "../entity/key"
|
|
25
25
|
import {
|
|
26
26
|
createOperation,
|
|
27
27
|
deleteOperation,
|
|
@@ -118,7 +118,7 @@ export async function sendArkivTransaction(
|
|
|
118
118
|
const createOps = (creates ?? []).map((item) => {
|
|
119
119
|
validateContentType(item.contentType)
|
|
120
120
|
|
|
121
|
-
const salt = item.salt === undefined ? randomSalt() :
|
|
121
|
+
const salt = item.salt === undefined ? randomSalt() : resolveSalt(item.salt)
|
|
122
122
|
const expiry = resolveExpiry(item.expires, expiryContext)
|
|
123
123
|
|
|
124
124
|
return createOperation({
|
|
@@ -168,8 +168,10 @@ export async function sendArkivTransaction(
|
|
|
168
168
|
|
|
169
169
|
logger("Sending execute with %d operations %o", operations.length, operations)
|
|
170
170
|
|
|
171
|
+
let txHash: Hex | undefined
|
|
172
|
+
|
|
171
173
|
try {
|
|
172
|
-
|
|
174
|
+
txHash = await walletClient.writeContract({
|
|
173
175
|
address: ARKIV_ADDRESS,
|
|
174
176
|
abi: EXECUTE_ABI,
|
|
175
177
|
functionName: "execute",
|
|
@@ -201,10 +203,12 @@ export async function sendArkivTransaction(
|
|
|
201
203
|
"No reason provided by backend."
|
|
202
204
|
throw new EntityMutationError(
|
|
203
205
|
`Transaction ${receipt.transactionHash} reverted. Reason: ${reason}`,
|
|
206
|
+
{ cause: err, txHash: receipt.transactionHash },
|
|
204
207
|
)
|
|
205
208
|
}
|
|
206
209
|
throw new EntityMutationError(
|
|
207
210
|
`Transaction ${receipt.transactionHash} reverted. No reason provided by backend.`,
|
|
211
|
+
{ txHash: receipt.transactionHash },
|
|
208
212
|
)
|
|
209
213
|
}
|
|
210
214
|
|
|
@@ -218,7 +222,7 @@ export async function sendArkivTransaction(
|
|
|
218
222
|
} catch (error) {
|
|
219
223
|
const described = error instanceof EntityMutationError ? undefined : describeEntityRevert(error)
|
|
220
224
|
if (described !== undefined) {
|
|
221
|
-
throw new EntityMutationError(`Transaction failed: ${described}`, { cause: error })
|
|
225
|
+
throw new EntityMutationError(`Transaction failed: ${described}`, { cause: error, txHash })
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
let message = "Transaction failed"
|
|
@@ -237,7 +241,7 @@ export async function sendArkivTransaction(
|
|
|
237
241
|
message += `: ${error.message}`
|
|
238
242
|
}
|
|
239
243
|
|
|
240
|
-
throw new EntityMutationError(message, { cause: error })
|
|
244
|
+
throw new EntityMutationError(message, { cause: error, txHash })
|
|
241
245
|
}
|
|
242
246
|
}
|
|
243
247
|
|
|
@@ -296,5 +300,6 @@ function assertCount(receipt: TransactionReceipt, what: string, got: number, wan
|
|
|
296
300
|
`Transaction ${receipt.transactionHash} succeeded — do not retry it — but emitted ${got} ` +
|
|
297
301
|
`${what} event(s) for ${want} ${what} operation(s). The batch was applied; the SDK cannot ` +
|
|
298
302
|
`say which entity each operation produced, so read them back to find them.`,
|
|
303
|
+
{ txHash: receipt.transactionHash },
|
|
299
304
|
)
|
|
300
305
|
}
|
|
@@ -51,11 +51,50 @@ export const ExpirationTime = {
|
|
|
51
51
|
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
52
52
|
*/
|
|
53
53
|
fromSeconds: (seconds: number): Lifetime => lifetimeOf(seconds),
|
|
54
|
+
/**
|
|
55
|
+
* A number of minutes.
|
|
56
|
+
*
|
|
57
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
58
|
+
*/
|
|
54
59
|
fromMinutes: (minutes: number): Lifetime => lifetimeOf(minutes * 60),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A number of hours.
|
|
63
|
+
*
|
|
64
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
65
|
+
*/
|
|
55
66
|
fromHours: (hours: number): Lifetime => lifetimeOf(hours * 60 * 60),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A number of days. The everyday form — `fromDays(30)` is what most creates want.
|
|
70
|
+
*
|
|
71
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
72
|
+
*/
|
|
56
73
|
fromDays: (days: number): Lifetime => lifetimeOf(days * 24 * 60 * 60),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A number of weeks, each of 7 days.
|
|
77
|
+
*
|
|
78
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
79
|
+
*/
|
|
57
80
|
fromWeeks: (weeks: number): Lifetime => lifetimeOf(weeks * 7 * 24 * 60 * 60),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A number of months, each of exactly **30 days** — calendar months are not all the same length,
|
|
84
|
+
* and a lifetime is a duration rather than a date. Use {@link ExpirationTime.atDate} when the
|
|
85
|
+
* expiry has to land on a particular calendar day.
|
|
86
|
+
*
|
|
87
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
88
|
+
*/
|
|
58
89
|
fromMonths: (months: number): Lifetime => lifetimeOf(months * 30 * 24 * 60 * 60),
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A number of years, each of exactly **365 days** — leap days are not counted, so `fromYears(4)`
|
|
93
|
+
* is a day short of four calendar years. Use {@link ExpirationTime.atDate} for a calendar
|
|
94
|
+
* deadline.
|
|
95
|
+
*
|
|
96
|
+
* @throws {InvalidExpiryError} If the duration is not a positive multiple of the block time.
|
|
97
|
+
*/
|
|
59
98
|
fromYears: (years: number): Lifetime => lifetimeOf(years * 365 * 24 * 60 * 60),
|
|
60
99
|
|
|
61
100
|
/**
|
package/src/utils/payload.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import { stringToBytes, toBytes } from "viem"
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A JSON-serialisable value as an entity payload — `JSON.stringify` then UTF-8.
|
|
5
|
+
*
|
|
6
|
+
* Pair it with `contentType: "application/json"`, which is what lets `entity.toJson()` read it back.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* await client.createEntity({
|
|
10
|
+
* payload: jsonToPayload({ hello: "world" }),
|
|
11
|
+
* contentType: "application/json",
|
|
12
|
+
* expires: ExpirationTime.fromDays(30),
|
|
13
|
+
* })
|
|
14
|
+
*/
|
|
3
15
|
export function jsonToPayload(json: object): Uint8Array {
|
|
4
16
|
return toBytes(JSON.stringify(json))
|
|
5
17
|
}
|
|
6
18
|
|
|
19
|
+
/**
|
|
20
|
+
* A string as an entity payload, encoded as UTF-8.
|
|
21
|
+
*
|
|
22
|
+
* Hex-looking text is encoded as text: `stringToPayload("0xab")` gives the four bytes of that
|
|
23
|
+
* string, not the single byte `0xab`. Read it back with `entity.toText()`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* await client.createEntity({
|
|
27
|
+
* payload: stringToPayload("hello"),
|
|
28
|
+
* contentType: "text/plain",
|
|
29
|
+
* expires: ExpirationTime.fromDays(30),
|
|
30
|
+
* })
|
|
31
|
+
*/
|
|
7
32
|
export function stringToPayload(data: string): Uint8Array {
|
|
8
33
|
// stringToBytes, not toBytes: toBytes hex-decodes hex-looking strings, which
|
|
9
34
|
// would corrupt payloads like "0xab" instead of UTF-8 encoding them
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attr-BDZ-APg5.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, u256, dec, str, addr, key, bytes32, bool) \" +\n \"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\"\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 {@link i32}, {@link u256}, {@link dec}, and\n * 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. */\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 * @throws {InvalidValueError} If the string exceeds 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\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 ValueInput}) 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 {InvalidValueError} If a value does not fit its type.\n * @throws {TooManyAttributesError} If `set` names more than {@link MAX_ATTRIBUTES} attributes.\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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AO,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chains-BJrZs6sG.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\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;;;;ACnBF,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"changeOwnership-B7bEgla4.d.cts","names":[],"sources":["../src/actions/public/predictEntityKeys.ts","../src/actions/public/query.ts","../src/types/events.ts","../src/actions/public/watchEntityEvents.ts","../src/actions/public/getBlockTiming.ts","../src/actions/wallet/createEntity.ts","../src/actions/wallet/deleteEntity.ts","../src/actions/wallet/extendEntity.ts","../src/actions/wallet/patchEntity.ts","../src/actions/wallet/mutateEntities.ts","../src/types/mimeTypes.ts","../src/types/txParams.ts","../src/actions/wallet/changeOwnership.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAYA;AAQY,KARA,kBAAA,GAQA;EAKH;EAQC,GAAA,EAnBH,GAmBG;EAKA;EAAM,IAAA,EAAA,MAAA;AAahB,CAAA;;AAIgC,KAnCpB,2BAmCoB,CAAA,eAAA,MAAA,GAAA,MAAA,EAAA,eAAA,SAAA,MAAA,EAAA,GAAA,SAAA,GAAA,SAAA,MAAA,EAAA,GAAA,SAAA,CAAA,GAAA;EAAS;EAC9B,KAAA,EA/BF,OA+BE;EAAoB;;;AAAO;;;;EASlC,KAAA,CAAA,EAhCM,MAgCN,GAAA,SAAA;EAAuB;;;;EAEE,KAAA,CAAA,EA7BnB,MA6BmB;CAAM;;;;;;AC7DnC;AAWA;;;;ACPY,KFyCA,2BErCO,CAAA,eAAG,MAAA,GAAA,MAAA,EAAA,eAAA,SAAA,MAAA,EAAA,GAAA,SAAA,GAAA,SAAA,MAAA,EAAA,GAAA,SAAA,CAAA,GAAA,CFwCjB,MExCiB,CAAA,SAAA,CAAA,SAAA,MAAA,EAAA,CAAA,GAAA,sBAMV,MFmCoB,MEnCF,GFmCW,kBEnCX,EAAG,GFoC7B,MEpC6B,CFoCtB,kBEpCsB,EFoCF,MEpCE,CAAA;;;;;AAiBjC;KF0BK,ME1B4B,CAAA,CAAA,EAAA,gBAAA,MAAA,EAAA,aF0BmB,CE1BnB,E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.ts","../src/actions/public/query.ts","../src/types/events.ts","../src/actions/public/watchEntityEvents.ts","../src/actions/public/getBlockTiming.ts","../src/actions/wallet/createEntity.ts","../src/actions/wallet/deleteEntity.ts","../src/actions/wallet/extendEntity.ts","../src/actions/wallet/patchEntity.ts","../src/actions/wallet/mutateEntities.ts","../src/types/mimeTypes.ts","../src/types/txParams.ts","../src/actions/wallet/changeOwnership.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAYA;AAQY,KARA,kBAAA,GAQA;EAKH;EAQC,GAAA,EAnBH,GAmBG;EAKA;EAAM,IAAA,EAAA,MAAA;AAahB,CAAA;;AAIgC,KAnCpB,2BAmCoB,CAAA,eAAA,MAAA,GAAA,MAAA,EAAA,eAAA,SAAA,MAAA,EAAA,GAAA,SAAA,GAAA,SAAA,MAAA,EAAA,GAAA,SAAA,CAAA,GAAA;EAAS;EAC9B,KAAA,EA/BF,OA+BE;EAAoB;;;AAAO;;;;EASlC,KAAA,CAAA,EAhCM,MAgCN,GAAA,SAAA;EAAuB;;;;EAEE,KAAA,CAAA,EA7BnB,MA6BmB;CAAM;;;;;;AC7DnC;AAWA;;;;ACPY,KFyCA,2BErCO,CAAA,eAAG,MAAA,GAAA,MAAA,EAAA,eAAA,SAAA,MAAA,EAAA,GAAA,SAAA,GAAA,SAAA,MAAA,EAAA,GAAA,SAAA,CAAA,GAAA,CFwCjB,MExCiB,CAAA,SAAA,CAAA,SAAA,MAAA,EAAA,CAAA,GAAA,sBAMV,MFmCoB,MEnCF,GFmCW,kBEnCX,EAAG,GFoC7B,MEpC6B,CFoCtB,kBEpCsB,EFoCF,MEpCE,CAAA;;;;;AAiBjC;KF0BK,ME1B4B,CAAA,CAAA,EAAA,gBAAA,MAAA,EAAA,aF0BmB,CE1BnB,EAAA,GAAA,EAAA,CAAA,GAAA,MAAA,SF0B8C,OE1B9C,GF2B7B,CE3B6B,EAAA,GF4B7B,IE5B6B,CAAA,QAAA,CAAA,SF4BN,OE5BM,GF6B3B,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;;AAED,KMOA,qBAAA,GNPA;EAAO;EAIP,SAAA,EMKC,GNLD;EAAqB,MAAA,EMMvB,INNuB;CAEpB;;;AFhDb;;;;;AA+BA;AAGK,KSnCO,wBAAA,GTmCP;EAC2B;EAAS,OAAA,CAAA,ESlC7B,sBTkC6B,EAAA;EAC9B;EAAoB,OAAA,CAAA,ESjCnB,qBTiCmB,EAAA;EAA3B;EAAM,OAAA,CAAA,ES/BE,sBT+BF,EAAA;EAOL;EAA+C,UAAA,CAAA,ESpCrC,sBToCqC,EAAA;EAA2B;EAC3E,gBAAA,CAAA,ESnCiB,yBTmCjB,EAAA;CACA;;AACE,KSjCM,wBAAA,GTiCN;EACO;EAAG,MAAA,EShCN,ITgCM;EAAa;EAAM,eAAA,ES9BhB,GT8BgB,EAAA;EAA7B;EAAM,eAAA,ES5BO,GT4BP,EAAA;;mBS1BO;;ERnCP,gBAAY,EQqCJ,GRrCI,EAAA;EAWZ;oBQ4BQ;;;;KC7CR,QAAA;;;KCAA,QAAA;;;;;;;EXYA,GAAA,CAAA,EAAA,MAAA;EAQA,KAAA,CAAA,EAAA,MAAA;EAKH,YAAA,CAAA,EAAA,MAAA;EAQC,oBAAA,CAAA,EAAA,MAAA;EAKA,QAAA,CAAA,EAAA,KAAA;CAAM;;;;;;;AA1BhB;AAQY,KYPA,yBAAA,GZO2B;EAK9B,SAAA,EYXI,GZWJ;EAQC,QAAA,EYlBE,GZkBF;CAKA;;AAaV;;;;AAKW,KYjCC,yBAAA,GZiCD;EAAoB,SAAA,EYhClB,GZgCkB;EAA3B,MAAA,EY/BM,IZ+BN;CAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-CFhbAv0R.js","names":[],"sources":["../src/entity/key.ts","../src/entity/events.ts"],"sourcesContent":["import { type Address, encodePacked, type Hex, keccak256 } from \"viem\"\nimport { ARKIV_ADDRESS } from \"../consts\"\nimport { InvalidSaltError, NoRandomSourceError } from \"./errors\"\n\n/** The widest salt the `uint128` wire field carries. */\nexport const MAX_SALT = 2n ** 128n - 1n\n\n/**\n * A cryptographically random 128-bit salt — what {@link CreateEntityParameters.salt} defaults to.\n *\n * The salt exists for unpredictability, not uniqueness: the per-owner nonce already guarantees\n * distinct keys. Random bits mean only the creator can predict the key of an entity they are about\n * to create, so nobody else can reference or squat it in advance.\n *\n * @throws {NoRandomSourceError} If the runtime has no `crypto.getRandomValues`.\n */\nexport function randomSalt(): bigint {\n const source = globalThis.crypto\n if (typeof source?.getRandomValues !== \"function\") {\n throw new NoRandomSourceError()\n }\n const bytes = source.getRandomValues(new Uint8Array(16))\n let salt = 0n\n for (const byte of bytes) salt = (salt << 8n) | BigInt(byte)\n return salt\n}\n\n/** Validates a caller-supplied salt against the `uint128` wire field. */\nexport function validateSalt(salt: bigint): bigint {\n if (typeof salt !== \"bigint\" || salt < 0n || salt > MAX_SALT) {\n throw new InvalidSaltError(salt)\n }\n return salt\n}\n\n/**\n * The key an entity will be created with, derived exactly as the engine derives it:\n * `keccak256(domain ++ owner ++ nonce ++ salt)`.\n *\n * Deriving it client-side is what lets a batch compose: predict the key of a create, then have a\n * later operation in the same transaction reference it, or store it as a `key` attribute on a\n * sibling entity.\n */\nexport function predictEntityKey({\n owner,\n nonce,\n salt,\n chainId,\n}: {\n /** The account creating the entity. */\n owner: Address\n /**\n * The owner's entity-nonce at creation time. Each create in a batch consumes one, so the *n*th\n * create in a batch uses `nonce + n`.\n */\n nonce: bigint\n /** The salt the create will carry. */\n salt: bigint\n /** The chain the entity is being created on — half of the derivation domain. */\n chainId: number\n}): Hex {\n return keccak256(\n encodePacked(\n [\"uint256\", \"address\", \"address\", \"uint64\", \"uint128\"],\n [BigInt(chainId), ARKIV_ADDRESS, owner, nonce, validateSalt(salt)],\n ),\n )\n}\n","import { parseAbi } from \"viem\"\n\n/**\n * The events the engine emits: one per applied operation, in application order, so an off-chain\n * replica can replay a transaction operation by operation.\n */\nexport const ENTITY_EVENTS_ABI = parseAbi([\n \"event EntityCreated(bytes32 indexed entityKey, address indexed owner, uint64 expiresAt, uint8 creationFlags)\",\n \"event EntityPatched(bytes32 indexed entityKey, address indexed owner)\",\n \"event ExpiryExtended(bytes32 indexed entityKey, address indexed owner, uint64 expiresAt)\",\n \"event OwnershipTransferred(bytes32 indexed entityKey, address indexed previousOwner, address indexed newOwner)\",\n \"event EntityDeleted(bytes32 indexed entityKey, address indexed owner)\",\n])\n\n/** The name of each event in {@link ENTITY_EVENTS_ABI}. */\nexport type EntityEventName = (typeof ENTITY_EVENTS_ABI)[number][\"name\"]\n"],"mappings":";;;;;;AAKA,MAAa,WAAW,MAAM,OAAO;;;;;;;;;;AAWrC,SAAgB,aAAqB;CACnC,MAAM,SAAS,WAAW;AAC1B,KAAI,OAAO,QAAQ,oBAAoB,WACrC,OAAM,IAAI,qBAAqB;CAEjC,MAAM,QAAQ,OAAO,gBAAgB,IAAI,WAAW,GAAG,CAAC;CACxD,IAAI,OAAO;AACX,MAAK,MAAM,QAAQ,MAAO,QAAQ,QAAQ,KAAM,OAAO,KAAK;AAC5D,QAAO;;;AAIT,SAAgB,aAAa,MAAsB;AACjD,KAAI,OAAO,SAAS,YAAY,OAAO,MAAM,OAAO,SAClD,OAAM,IAAI,iBAAiB,KAAK;AAElC,QAAO;;;;;;;;;;AAWT,SAAgB,iBAAiB,EAC/B,OACA,OACA,MACA,WAaM;AACN,QAAO,UACL,aACE;EAAC;EAAW;EAAW;EAAW;EAAU;EAAU,EACtD;EAAC,OAAO,QAAQ;EAAE;EAAe;EAAO;EAAO,aAAa,KAAK;EAAC,CACnE,CACF;;;;;;;;;AC5DH,MAAa,oBAAoB,SAAS;CACxC;CACA;CACA;CACA;CACA;CACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-DGB8AgT2.js","names":[],"sources":["../src/entity/errors.ts"],"sourcesContent":["/** An expiry could not be expressed, or would be rejected by the engine. */\nexport class InvalidExpiryError extends Error {\n constructor(reason: string) {\n super(`Invalid expiry: ${reason}`)\n this.name = \"InvalidExpiryError\"\n }\n}\n\n/** A `creationFlags` byte could not be built or read. */\nexport class InvalidCreationFlagsError extends Error {\n constructor(reason: string) {\n super(`Invalid creation flags: ${reason}`)\n this.name = \"InvalidCreationFlagsError\"\n }\n}\n\n/** A key salt was outside the `uint128` the wire carries. */\nexport class InvalidSaltError extends Error {\n constructor(salt: bigint) {\n super(\n `Invalid salt ${salt}. A salt is a uint128, so it must be between 0 and ` +\n `${2n ** 128n - 1n}. Omit it to get 128 random bits, or pass 0 for a predictable key.`,\n )\n this.name = \"InvalidSaltError\"\n }\n}\n\n/** No cryptographic randomness was available to generate a salt. */\nexport class NoRandomSourceError extends Error {\n constructor() {\n super(\n \"No cryptographic random source is available (globalThis.crypto.getRandomValues is \" +\n \"missing), so a key salt cannot be generated. Upgrade to Node 18+ or a modern browser, \" +\n \"or pass an explicit salt.\",\n )\n this.name = \"NoRandomSourceError\"\n }\n}\n"],"mappings":";;AACA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YAAY,QAAgB;AAC1B,QAAM,mBAAmB,SAAS;AAClC,OAAK,OAAO;;;;AAKhB,IAAa,4BAAb,cAA+C,MAAM;CACnD,YAAY,QAAgB;AAC1B,QAAM,2BAA2B,SAAS;AAC1C,OAAK,OAAO;;;;AAKhB,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,MAAc;AACxB,QACE,gBAAgB,KAAK,qDAChB,MAAM,OAAO,GAAG,oEACtB;AACD,OAAK,OAAO;;;;AAKhB,IAAa,sBAAb,cAAyC,MAAM;CAC7C,cAAc;AACZ,QACE,oMAGD;AACD,OAAK,OAAO"}
|