@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_attr = require('./attr-
|
|
2
|
-
const require_flags = require('./flags-
|
|
1
|
+
const require_attr = require('./attr-BXTkpnoc.cjs');
|
|
2
|
+
const require_flags = require('./flags-DCD26uhe.cjs');
|
|
3
3
|
const require_entity = require('./entity-B0t6sN7F.cjs');
|
|
4
4
|
let viem = require("viem");
|
|
5
5
|
|
|
@@ -118,9 +118,11 @@ const getLogger = (scope) => {
|
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/errors.ts
|
|
120
120
|
var EntityMutationError = class extends Error {
|
|
121
|
+
txHash;
|
|
121
122
|
constructor(message, options) {
|
|
122
|
-
super(message, options);
|
|
123
|
+
super(message, { cause: options?.cause });
|
|
123
124
|
this.name = "EntityMutationError";
|
|
125
|
+
this.txHash = options?.txHash;
|
|
124
126
|
}
|
|
125
127
|
};
|
|
126
128
|
var NoMoreResultsError = class extends Error {
|
|
@@ -240,7 +242,7 @@ function toFlagsByte(value) {
|
|
|
240
242
|
* | | `=` `!=` | `<` `<=` `>` `>=` | `STARTSWITH` |
|
|
241
243
|
* | --- | --- | --- | --- |
|
|
242
244
|
* | `bool` | yes | no | no |
|
|
243
|
-
* | `i32` `u256` `dec` | yes | yes | no |
|
|
245
|
+
* | `i32` `u64` `u256` `dec` | yes | yes | no |
|
|
244
246
|
* | `str` | yes | no | yes |
|
|
245
247
|
* | `addr` `key` `bytes32` | yes | no | no |
|
|
246
248
|
*/
|
|
@@ -490,7 +492,7 @@ function ne(name, value) {
|
|
|
490
492
|
return comparison(name, "!=", value);
|
|
491
493
|
}
|
|
492
494
|
/**
|
|
493
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
495
|
+
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
494
496
|
*
|
|
495
497
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
496
498
|
*
|
|
@@ -502,7 +504,7 @@ function gt(name, value) {
|
|
|
502
504
|
return comparison(name, ">", value);
|
|
503
505
|
}
|
|
504
506
|
/**
|
|
505
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
507
|
+
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
506
508
|
*
|
|
507
509
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
508
510
|
*
|
|
@@ -513,7 +515,7 @@ function gte(name, value) {
|
|
|
513
515
|
return comparison(name, ">=", value);
|
|
514
516
|
}
|
|
515
517
|
/**
|
|
516
|
-
* Attribute is less than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
518
|
+
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
517
519
|
*
|
|
518
520
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
519
521
|
*
|
|
@@ -524,7 +526,7 @@ function lt(name, value) {
|
|
|
524
526
|
return comparison(name, "<", value);
|
|
525
527
|
}
|
|
526
528
|
/**
|
|
527
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
529
|
+
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
528
530
|
*
|
|
529
531
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
530
532
|
*
|
|
@@ -541,7 +543,9 @@ function lte(name, value) {
|
|
|
541
543
|
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
542
544
|
*
|
|
543
545
|
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
544
|
-
* @throws {
|
|
546
|
+
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
547
|
+
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
548
|
+
* (none of which is a `str`).
|
|
545
549
|
*
|
|
546
550
|
* @example
|
|
547
551
|
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
@@ -580,7 +584,8 @@ function exists(name) {
|
|
|
580
584
|
* Useful when the same name is written with different types across entities — a comparison already
|
|
581
585
|
* asserts the type, so this is for asking about the type alone.
|
|
582
586
|
*
|
|
583
|
-
* @param tag - The type tag: `bool`, `i32`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
587
|
+
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
588
|
+
* `key`.
|
|
584
589
|
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
585
590
|
* attribute (whose type is fixed).
|
|
586
591
|
*
|
|
@@ -590,7 +595,7 @@ function exists(name) {
|
|
|
590
595
|
function hasType(name, tag) {
|
|
591
596
|
const system = resolveReference(name);
|
|
592
597
|
if (system !== void 0) throw new InvalidPredicateError(`"${name}" is always a ${system} — a system attribute has a fixed type, so TYPEOF(${name}) is a constant.`, name);
|
|
593
|
-
if (!isUserTypeTag(tag)) throw new InvalidPredicateError(`"${tag}" is not a settable attribute type. Use one of bool, i32, u256, dec, bytes32, str, addr, key.`, name);
|
|
598
|
+
if (!isUserTypeTag(tag)) throw new InvalidPredicateError(`"${tag}" is not a settable attribute type. Use one of bool, i32, u64, u256, dec, bytes32, str, addr, key.`, name);
|
|
594
599
|
return node({
|
|
595
600
|
kind: "typeOf",
|
|
596
601
|
name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ValueInput, G as StrValue, R as ArkivValue, Y as UserTypeTag, h as Attributes, m as AttributeSchema } from "./index-
|
|
1
|
+
import { C as ValueInput, G as StrValue, R as ArkivValue, Y as UserTypeTag, h as Attributes, m as AttributeSchema } from "./index-CIcHPx2j.cjs";
|
|
2
2
|
import { n as ResolvedCreationFlags } from "./flags-0Vl5rrHq.cjs";
|
|
3
3
|
import { Account, Chain, Client, Hex, RpcSchema, Transport } from "viem";
|
|
4
4
|
|
|
@@ -68,6 +68,7 @@ type RpcSelect = {
|
|
|
68
68
|
attributeSchema?: boolean;
|
|
69
69
|
attributes?: boolean | Record<string, boolean>;
|
|
70
70
|
};
|
|
71
|
+
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
|
|
71
72
|
type RpcQueryOptions = {
|
|
72
73
|
/** Block height to read at, as a hex quantity. Defaults to the head, and must be within the node's retained range. */
|
|
73
74
|
atBlock?: Hex;
|
|
@@ -163,6 +164,10 @@ declare class Entity implements EntityFields {
|
|
|
163
164
|
}
|
|
164
165
|
//#endregion
|
|
165
166
|
//#region src/query/expression.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* The comparison operators the query language defines. `<` `<=` `>` `>=` need an ordered type —
|
|
169
|
+
* `i32`, `u64`, `u256` or `dec`; every type accepts `=` and `!=`.
|
|
170
|
+
*/
|
|
166
171
|
type ComparisonOperator = "=" | "!=" | "<" | "<=" | ">" | ">=";
|
|
167
172
|
/** A comparison between an attribute and a typed literal. */
|
|
168
173
|
type ComparisonNode = {
|
|
@@ -239,7 +244,7 @@ declare function eq(name: string, value: ValueInput): ComparisonNode;
|
|
|
239
244
|
*/
|
|
240
245
|
declare function ne(name: string, value: ValueInput): ComparisonNode;
|
|
241
246
|
/**
|
|
242
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
247
|
+
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
243
248
|
*
|
|
244
249
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
245
250
|
*
|
|
@@ -249,7 +254,7 @@ declare function ne(name: string, value: ValueInput): ComparisonNode;
|
|
|
249
254
|
*/
|
|
250
255
|
declare function gt(name: string, value: ValueInput): ComparisonNode;
|
|
251
256
|
/**
|
|
252
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
257
|
+
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
253
258
|
*
|
|
254
259
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
255
260
|
*
|
|
@@ -258,7 +263,7 @@ declare function gt(name: string, value: ValueInput): ComparisonNode;
|
|
|
258
263
|
*/
|
|
259
264
|
declare function gte(name: string, value: ValueInput): ComparisonNode;
|
|
260
265
|
/**
|
|
261
|
-
* Attribute is less than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
266
|
+
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
262
267
|
*
|
|
263
268
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
264
269
|
*
|
|
@@ -267,7 +272,7 @@ declare function gte(name: string, value: ValueInput): ComparisonNode;
|
|
|
267
272
|
*/
|
|
268
273
|
declare function lt(name: string, value: ValueInput): ComparisonNode;
|
|
269
274
|
/**
|
|
270
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
275
|
+
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
271
276
|
*
|
|
272
277
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
273
278
|
*
|
|
@@ -282,7 +287,9 @@ declare function lte(name: string, value: ValueInput): ComparisonNode;
|
|
|
282
287
|
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
283
288
|
*
|
|
284
289
|
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
285
|
-
* @throws {
|
|
290
|
+
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
291
|
+
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
292
|
+
* (none of which is a `str`).
|
|
286
293
|
*
|
|
287
294
|
* @example
|
|
288
295
|
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
@@ -305,7 +312,8 @@ declare function exists(name: string): ExistsNode;
|
|
|
305
312
|
* Useful when the same name is written with different types across entities — a comparison already
|
|
306
313
|
* asserts the type, so this is for asking about the type alone.
|
|
307
314
|
*
|
|
308
|
-
* @param tag - The type tag: `bool`, `i32`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
315
|
+
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
316
|
+
* `key`.
|
|
309
317
|
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
310
318
|
* attribute (whose type is fixed).
|
|
311
319
|
*
|
|
@@ -430,4 +438,4 @@ type FullEntity = ProjectedEntity<AllSelected>;
|
|
|
430
438
|
declare function toRpcSelect(selection?: SelectArg): RpcSelect;
|
|
431
439
|
//#endregion
|
|
432
440
|
export { EntityFields as A, lte as C, render as D, or as E, RpcCreationFlags as F, RpcEntity as I, RpcQueryOptions as L, ArkivRpcSchema as M, RpcAttribute as N, startsWith as O, RpcAttributeSchemaEntry as P, RpcSelect as R, lt as S, not as T, eq as _, SelectionFields as a, gte as b, ComparisonNode as c, Expression as d, NotNode as f, and as g, TypeOfNode as h, SelectArg as i, ArkivClient as j, Entity as k, ComparisonOperator as l, StartsWithNode as m, FullEntity as n, toRpcSelect as o, OrNode as p, ProjectedEntity as r, AndNode as s, EntitySelection as t, ExistsNode as u, exists as v, ne as w, hasType as x, gt as y };
|
|
433
|
-
//# sourceMappingURL=selection-
|
|
441
|
+
//# sourceMappingURL=selection-Bv8_o-7i.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-Bv8_o-7i.d.cts","names":[],"sources":["../src/types/rpcSchema.ts","../src/clients/baseClient.ts","../src/types/entity.ts","../src/query/expression.ts","../src/query/selection.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAWA;AAOA;AAQA;AAUA;;AAEU,KA3BE,YAAA,GA2BF;EACE,IAAA,EAAA,MAAA;EACE,IAAA,EAAA,MAAA;EACA,KAAA,EAAA,OAAA;CACA;;AAGF,KA3BA,uBAAA,GA2BA;EACQ,IAAA,EAAA,MAAA;EACL,IAAA,EAAA,MAAA;CAAY;AAU3B;AAeA;;AAIW,KAlDC,gBAAA,GAkDD;EAED,QAAA,CAAA,EAAA,OAAA;EAAG,uBAAA,CAAA,EAAA,OAAA;EAKD,GAAA,EAAA,MAAA;CAGoC;;;;;KAlDpC,SAAA;QACJ;EClCI,KAAA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,uBG6Da,KAAK,SAAS,EAAE,mBAAmB,YAAY,gBAAgB,SAChF,YAAY,OAAO,iBAEpB;;AFhEL,CAAA,GEgEmC,IFhEvB,CEgE4B,MFhE5B,EAAA,QAAY,GAAA,QAAA,CAAA,GAAA,OAAA,CAAA;;KEmEnB,WAAA,GFjEK,QACE,CAAA,OEgEuB,cFhEvB,CAAA,CAAA,MAAA,CAAA,GAAA,IAAA,EAQM;;AAIE,KEuDR,UAAA,GAAa,eFvDL,CEuDqB,WFvDrB,CAAA;;;AAYpB;;;;;;;;;;;;;;ACjBY,iBC8EI,WAAA,CD9Ec,SAAA,CAAA,EC8EU,SD9EV,CAAA,EC8EsB,SD9EtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ValueInput, G as StrValue, R as ArkivValue, Y as UserTypeTag, h as Attributes, m as AttributeSchema } from "./index-
|
|
1
|
+
import { C as ValueInput, G as StrValue, R as ArkivValue, Y as UserTypeTag, h as Attributes, m as AttributeSchema } from "./index-Cd2aaWme.js";
|
|
2
2
|
import { n as ResolvedCreationFlags } from "./flags-wmcMoAnN.js";
|
|
3
3
|
import { Account, Chain, Client, Hex, RpcSchema, Transport } from "viem";
|
|
4
4
|
|
|
@@ -68,6 +68,7 @@ type RpcSelect = {
|
|
|
68
68
|
attributeSchema?: boolean;
|
|
69
69
|
attributes?: boolean | Record<string, boolean>;
|
|
70
70
|
};
|
|
71
|
+
/** The second parameter of `arkiv_query` — what to return, and where in the results to start. */
|
|
71
72
|
type RpcQueryOptions = {
|
|
72
73
|
/** Block height to read at, as a hex quantity. Defaults to the head, and must be within the node's retained range. */
|
|
73
74
|
atBlock?: Hex;
|
|
@@ -163,6 +164,10 @@ declare class Entity implements EntityFields {
|
|
|
163
164
|
}
|
|
164
165
|
//#endregion
|
|
165
166
|
//#region src/query/expression.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* The comparison operators the query language defines. `<` `<=` `>` `>=` need an ordered type —
|
|
169
|
+
* `i32`, `u64`, `u256` or `dec`; every type accepts `=` and `!=`.
|
|
170
|
+
*/
|
|
166
171
|
type ComparisonOperator = "=" | "!=" | "<" | "<=" | ">" | ">=";
|
|
167
172
|
/** A comparison between an attribute and a typed literal. */
|
|
168
173
|
type ComparisonNode = {
|
|
@@ -239,7 +244,7 @@ declare function eq(name: string, value: ValueInput): ComparisonNode;
|
|
|
239
244
|
*/
|
|
240
245
|
declare function ne(name: string, value: ValueInput): ComparisonNode;
|
|
241
246
|
/**
|
|
242
|
-
* Attribute is greater than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
247
|
+
* Attribute is greater than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
243
248
|
*
|
|
244
249
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
245
250
|
*
|
|
@@ -249,7 +254,7 @@ declare function ne(name: string, value: ValueInput): ComparisonNode;
|
|
|
249
254
|
*/
|
|
250
255
|
declare function gt(name: string, value: ValueInput): ComparisonNode;
|
|
251
256
|
/**
|
|
252
|
-
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
257
|
+
* Attribute is greater than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
253
258
|
*
|
|
254
259
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
255
260
|
*
|
|
@@ -258,7 +263,7 @@ declare function gt(name: string, value: ValueInput): ComparisonNode;
|
|
|
258
263
|
*/
|
|
259
264
|
declare function gte(name: string, value: ValueInput): ComparisonNode;
|
|
260
265
|
/**
|
|
261
|
-
* Attribute is less than value. Ordered types only (`i32`, `u256`, `dec`).
|
|
266
|
+
* Attribute is less than value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
262
267
|
*
|
|
263
268
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
264
269
|
*
|
|
@@ -267,7 +272,7 @@ declare function gte(name: string, value: ValueInput): ComparisonNode;
|
|
|
267
272
|
*/
|
|
268
273
|
declare function lt(name: string, value: ValueInput): ComparisonNode;
|
|
269
274
|
/**
|
|
270
|
-
* Attribute is less than or equal to value. Ordered types only (`i32`, `u256`, `dec`).
|
|
275
|
+
* Attribute is less than or equal to value. Ordered types only (`i32`, `u64`, `u256`, `dec`).
|
|
271
276
|
*
|
|
272
277
|
* @throws {UnsupportedOperatorError} If the value's type carries no ordered index.
|
|
273
278
|
*
|
|
@@ -282,7 +287,9 @@ declare function lte(name: string, value: ValueInput): ComparisonNode;
|
|
|
282
287
|
* `startsWith("name", "é")` matches only the same byte sequence, not another normal form of it.
|
|
283
288
|
*
|
|
284
289
|
* @param prefix - The prefix, as a bare string or a `str` value.
|
|
285
|
-
* @throws {
|
|
290
|
+
* @throws {InvalidPredicateError} If the name is not a queryable attribute.
|
|
291
|
+
* @throws {UnsupportedOperatorError} If given a value that is not a `str`, or a system attribute
|
|
292
|
+
* (none of which is a `str`).
|
|
286
293
|
*
|
|
287
294
|
* @example
|
|
288
295
|
* startsWith("desc", "ab") // desc STARTSWITH str('ab')
|
|
@@ -305,7 +312,8 @@ declare function exists(name: string): ExistsNode;
|
|
|
305
312
|
* Useful when the same name is written with different types across entities — a comparison already
|
|
306
313
|
* asserts the type, so this is for asking about the type alone.
|
|
307
314
|
*
|
|
308
|
-
* @param tag - The type tag: `bool`, `i32`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
315
|
+
* @param tag - The type tag: `bool`, `i32`, `u64`, `u256`, `dec`, `bytes32`, `str`, `addr` or
|
|
316
|
+
* `key`.
|
|
309
317
|
* @throws {InvalidPredicateError} If the tag is not a settable type, or the name is a system
|
|
310
318
|
* attribute (whose type is fixed).
|
|
311
319
|
*
|
|
@@ -430,4 +438,4 @@ type FullEntity = ProjectedEntity<AllSelected>;
|
|
|
430
438
|
declare function toRpcSelect(selection?: SelectArg): RpcSelect;
|
|
431
439
|
//#endregion
|
|
432
440
|
export { EntityFields as A, lte as C, render as D, or as E, RpcCreationFlags as F, RpcEntity as I, RpcQueryOptions as L, ArkivRpcSchema as M, RpcAttribute as N, startsWith as O, RpcAttributeSchemaEntry as P, RpcSelect as R, lt as S, not as T, eq as _, SelectionFields as a, gte as b, ComparisonNode as c, Expression as d, NotNode as f, and as g, TypeOfNode as h, SelectArg as i, ArkivClient as j, Entity as k, ComparisonOperator as l, StartsWithNode as m, FullEntity as n, toRpcSelect as o, OrNode as p, ProjectedEntity as r, AndNode as s, EntitySelection as t, ExistsNode as u, exists as v, ne as w, hasType as x, gt as y };
|
|
433
|
-
//# sourceMappingURL=selection-
|
|
441
|
+
//# sourceMappingURL=selection-ox7zdtVm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-ox7zdtVm.d.ts","names":[],"sources":["../src/types/rpcSchema.ts","../src/clients/baseClient.ts","../src/types/entity.ts","../src/query/expression.ts","../src/query/selection.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAWA;AAOA;AAQA;AAUA;;AAEU,KA3BE,YAAA,GA2BF;EACE,IAAA,EAAA,MAAA;EACE,IAAA,EAAA,MAAA;EACA,KAAA,EAAA,OAAA;CACA;;AAGF,KA3BA,uBAAA,GA2BA;EACQ,IAAA,EAAA,MAAA;EACL,IAAA,EAAA,MAAA;CAAY;AAU3B;AAeA;;AAIW,KAlDC,gBAAA,GAkDD;EAED,QAAA,CAAA,EAAA,OAAA;EAAG,uBAAA,CAAA,EAAA,OAAA;EAKD,GAAA,EAAA,MAAA;CAGoC;;;;;KAlDpC,SAAA;QACJ;EClCI,KAAA,CAAA,EDmCF,GCnCE;EACQ,OAAA,CAAA,EDmCR,GCnCQ;EAAY,SAAA,CAAA,EDoClB,GCpCkB;EAChB,SAAA,CAAA,EDoCF,GCpCE;EAAoB,SAAA,CAAA,EDqCtB,GCrCsB;EACT,aAAA,CAAA,EDqCT,gBCrCS,GAAA,MAAA;EAAsB,WAAA,CAAA,EAAA,MAAA;EAC7B,OAAA,CAAA,EDsCR,GCtCQ;EAAwB,eAAA,CAA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,GAAa,eFvDL,CEuDqB,WFvDrB,CAAA;;;AAYpB;;;;;;;;;;;;;;ACjBY,iBC8EI,WAAA,CD9Ec,SAAA,CAAA,EC8EU,SD9EV,CAAA,EC8EsB,SD9EtB"}
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import "../index-
|
|
1
|
+
import "../index-CIcHPx2j.cjs";
|
|
2
|
+
import "../index-BGp2plHs.cjs";
|
|
3
3
|
import "../expiry-DRV29F1r.cjs";
|
|
4
4
|
import "../flags-0Vl5rrHq.cjs";
|
|
5
|
-
import { A as EntityFields, F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, k as Entity } from "../selection-
|
|
6
|
-
import { C as
|
|
7
|
-
export { ArkivRpcSchema, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityFields, EntityPatchedEvent, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType,
|
|
5
|
+
import { A as EntityFields, F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, k as Entity } from "../selection-Bv8_o-7i.cjs";
|
|
6
|
+
import { C as QueryOptions, D as PredictedEntityKey, E as PredictEntityKeysReturnType, O as GetBlockTimingReturnType, S as OwnershipTransferredEvent, T as PredictEntityKeysParameters, _ as EntityDeletedEvent, a as ExecuteBatchParameters, b as EntityPatchedEvent, c as PatchEntityReturnType, d as DeleteEntityParameters, f as DeleteEntityReturnType, g as EntityCreatedEvent, h as WatchEntityEventsParameters, i as MimeType, l as ExtendEntityParameters, m as CreateEntityReturnType, n as ChangeOwnershipReturnType, o as ExecuteBatchReturnType, p as CreateEntityParameters, r as TxParams, s as PatchEntityParameters, t as ChangeOwnershipParameters, u as ExtendEntityReturnType, v as EntityEvent, w as QueryReturnType, x as ExpiryExtendedEvent, y as EntityEventContext } from "../changeOwnership-BofkLnXJ.cjs";
|
|
7
|
+
export { ArkivRpcSchema, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityFields, EntityPatchedEvent, ExecuteBatchParameters, ExecuteBatchReturnType, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, OwnershipTransferredEvent, PatchEntityParameters, PatchEntityReturnType, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, QueryOptions, QueryReturnType, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, TxParams, WatchEntityEventsParameters };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../index-
|
|
2
|
-
import "../index-
|
|
1
|
+
import "../index-Cd2aaWme.js";
|
|
2
|
+
import "../index-ezMZ2-JH.js";
|
|
3
3
|
import "../expiry-BxOlvVWC.js";
|
|
4
4
|
import "../flags-wmcMoAnN.js";
|
|
5
|
-
import { A as EntityFields, F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, k as Entity } from "../selection-
|
|
6
|
-
import { C as
|
|
7
|
-
export { ArkivRpcSchema, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityFields, EntityPatchedEvent, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType,
|
|
5
|
+
import { A as EntityFields, F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, k as Entity } from "../selection-ox7zdtVm.js";
|
|
6
|
+
import { C as QueryOptions, D as PredictedEntityKey, E as PredictEntityKeysReturnType, O as GetBlockTimingReturnType, S as OwnershipTransferredEvent, T as PredictEntityKeysParameters, _ as EntityDeletedEvent, a as ExecuteBatchParameters, b as EntityPatchedEvent, c as PatchEntityReturnType, d as DeleteEntityParameters, f as DeleteEntityReturnType, g as EntityCreatedEvent, h as WatchEntityEventsParameters, i as MimeType, l as ExtendEntityParameters, m as CreateEntityReturnType, n as ChangeOwnershipReturnType, o as ExecuteBatchReturnType, p as CreateEntityParameters, r as TxParams, s as PatchEntityParameters, t as ChangeOwnershipParameters, u as ExtendEntityReturnType, v as EntityEvent, w as QueryReturnType, x as ExpiryExtendedEvent, y as EntityEventContext } from "../changeOwnership-B0ar96ub.js";
|
|
7
|
+
export { ArkivRpcSchema, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityFields, EntityPatchedEvent, ExecuteBatchParameters, ExecuteBatchReturnType, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, OwnershipTransferredEvent, PatchEntityParameters, PatchEntityReturnType, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, QueryOptions, QueryReturnType, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, TxParams, WatchEntityEventsParameters };
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require('../errors-
|
|
2
|
-
require('../expiry-
|
|
3
|
-
const require_payload = require('../payload-
|
|
1
|
+
require('../errors-DhV00966.cjs');
|
|
2
|
+
require('../expiry-CG9GhVXv.cjs');
|
|
3
|
+
const require_payload = require('../payload-DqFweqiO.cjs');
|
|
4
4
|
|
|
5
5
|
exports.ExpirationTime = require_payload.ExpirationTime;
|
|
6
6
|
exports.jsonToPayload = require_payload.jsonToPayload;
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "../expiry-DRV29F1r.cjs";
|
|
2
|
-
import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "../payload-
|
|
2
|
+
import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "../payload-Dfu30njp.cjs";
|
|
3
3
|
export { DeadlineOptions, ExpirationTime, jsonToPayload, stringToPayload };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "../expiry-BxOlvVWC.js";
|
|
2
|
-
import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "../payload-
|
|
2
|
+
import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "../payload-CGvVPZQX.js";
|
|
3
3
|
export { DeadlineOptions, ExpirationTime, jsonToPayload, stringToPayload };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../errors-
|
|
2
|
-
import "../expiry-
|
|
3
|
-
import { n as stringToPayload, r as ExpirationTime, t as jsonToPayload } from "../payload-
|
|
1
|
+
import "../errors-D2E1GRjw.js";
|
|
2
|
+
import "../expiry-Cgdb_dbq.js";
|
|
3
|
+
import { n as stringToPayload, r as ExpirationTime, t as jsonToPayload } from "../payload-DE7wMztL.js";
|
|
4
4
|
|
|
5
5
|
export { ExpirationTime, jsonToPayload, stringToPayload };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkiv-network/sdk",
|
|
3
|
-
"version": "0.8.0-dev.
|
|
3
|
+
"version": "0.8.0-dev.3",
|
|
4
4
|
"description": "TypeScript client library for Arkiv's blockchains interactions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"target": "esnext",
|
|
@@ -85,8 +85,6 @@
|
|
|
85
85
|
"lint": "biome check src/",
|
|
86
86
|
"lint:fix": "biome check --write src/",
|
|
87
87
|
"test:unit": "bun test src/**/*",
|
|
88
|
-
"docs": "bunx typedoc --plugin typedoc-plugin-markdown",
|
|
89
|
-
"docs:verify": "bunx typedoc --emit none --plugin typedoc-plugin-markdown",
|
|
90
88
|
"package": "rimraf arkiv-network-sdk-*.tgz && bun run build && bun pm pack --no-cache",
|
|
91
89
|
"package:test": "bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
|
|
92
90
|
"prepublishOnly": "bun run build && bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
|
|
@@ -102,8 +100,6 @@
|
|
|
102
100
|
"@types/bun": "latest",
|
|
103
101
|
"rimraf": "^6.0.1",
|
|
104
102
|
"tsdown": "^0.16.0",
|
|
105
|
-
"typedoc": "^0.28.14",
|
|
106
|
-
"typedoc-plugin-markdown": "^4.9.0",
|
|
107
103
|
"typescript": "^5.9.2",
|
|
108
104
|
"viem": "^2.38.2"
|
|
109
105
|
},
|
|
@@ -5,6 +5,7 @@ import { NoEntityFoundError } from "../../errors"
|
|
|
5
5
|
import { runQuery } from "../../query/engine"
|
|
6
6
|
import { eq } from "../../query/expression"
|
|
7
7
|
import { type FullEntity, toRpcSelect } from "../../query/selection"
|
|
8
|
+
import type { Entity } from "../../types/entity"
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Reads one entity by key, with every field selected.
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "bun:test"
|
|
|
2
2
|
import { encodeFunctionResult, type Hex } from "viem"
|
|
3
3
|
import type { ArkivClient } from "../../clients/baseClient"
|
|
4
4
|
import { ARKIV_ADDRESS } from "../../consts"
|
|
5
|
-
import { predictEntityKey } from "../../entity/key"
|
|
5
|
+
import { NO_SALT, predictEntityKey } from "../../entity/key"
|
|
6
6
|
import { ENTITY_NONCE_ABI } from "../../entity/operations"
|
|
7
7
|
import { getEntityNonce } from "./getEntityNonce"
|
|
8
8
|
import { predictEntityKeys } from "./predictEntityKeys"
|
|
@@ -105,6 +105,22 @@ describe("predictEntityKeys", () => {
|
|
|
105
105
|
)
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
it("takes NO_SALT in a slot, and pairs the key with the zero it resolves to", async () => {
|
|
109
|
+
const { client } = makeClient(4n)
|
|
110
|
+
const [first, second] = await predictEntityKeys(client, {
|
|
111
|
+
owner: OWNER,
|
|
112
|
+
salts: [NO_SALT, 5n],
|
|
113
|
+
})
|
|
114
|
+
expect(first).toEqual({
|
|
115
|
+
salt: 0n,
|
|
116
|
+
key: predictEntityKey({ owner: OWNER, nonce: 4n, salt: 0n, chainId: CHAIN_ID }),
|
|
117
|
+
})
|
|
118
|
+
expect(second).toEqual({
|
|
119
|
+
salt: 5n,
|
|
120
|
+
key: predictEntityKey({ owner: OWNER, nonce: 5n, salt: 5n, chainId: CHAIN_ID }),
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
108
124
|
it("prefers the salts it was given over the count", async () => {
|
|
109
125
|
const { client } = makeClient(0n)
|
|
110
126
|
const pairs = await predictEntityKeys(client, { owner: OWNER, count: 5, salts: [9n] })
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { Address, Hex } from "viem"
|
|
2
2
|
import { getChainId } from "viem/actions"
|
|
3
3
|
import type { ArkivClient } from "../../clients/baseClient"
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
NO_SALT,
|
|
6
|
+
predictEntityKey,
|
|
7
|
+
randomSalt,
|
|
8
|
+
resolveSalt,
|
|
9
|
+
type SaltInput,
|
|
10
|
+
} from "../../entity/key"
|
|
5
11
|
import { getEntityNonce } from "./getEntityNonce"
|
|
6
12
|
|
|
7
13
|
/**
|
|
@@ -13,14 +19,18 @@ import { getEntityNonce } from "./getEntityNonce"
|
|
|
13
19
|
export type PredictedEntityKey = {
|
|
14
20
|
/** The key the create will be given. */
|
|
15
21
|
key: Hex
|
|
16
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The salt the create must carry for its key to come out as {@link PredictedEntityKey.key}.
|
|
24
|
+
* Always a plain `uint128` — a requested {@link NO_SALT} comes back as the `0n` it resolves to,
|
|
25
|
+
* which a create accepts just the same.
|
|
26
|
+
*/
|
|
17
27
|
salt: bigint
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
/** Parameters for
|
|
30
|
+
/** Parameters for `client.predictEntityKeys`. */
|
|
21
31
|
export type PredictEntityKeysParameters<
|
|
22
32
|
TCount extends number = number,
|
|
23
|
-
TSalts extends readonly
|
|
33
|
+
TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined,
|
|
24
34
|
> = {
|
|
25
35
|
/** The account that will sign the creates. Its nonce is what the keys are derived from. */
|
|
26
36
|
owner: Address
|
|
@@ -34,7 +44,8 @@ export type PredictEntityKeysParameters<
|
|
|
34
44
|
count?: TCount | undefined
|
|
35
45
|
/**
|
|
36
46
|
* The salt each create will carry, in batch order. Defaults to `count` fresh random salts —
|
|
37
|
-
* either way each key comes back paired with the salt that mints it.
|
|
47
|
+
* either way each key comes back paired with the salt that mints it. Pass {@link NO_SALT} in a
|
|
48
|
+
* slot whose create opts out of salting.
|
|
38
49
|
*/
|
|
39
50
|
salts?: TSalts
|
|
40
51
|
}
|
|
@@ -46,13 +57,13 @@ export type PredictEntityKeysParameters<
|
|
|
46
57
|
* tuple, gives a fixed-length tuple; a count computed at runtime gives a plain array.
|
|
47
58
|
*
|
|
48
59
|
* `TSalts` is wrapped in a tuple to stop the conditional distributing over it. Left naked, the
|
|
49
|
-
* `readonly
|
|
50
|
-
* which widens the length straight back to `number`.
|
|
60
|
+
* `readonly SaltInput[] | undefined` default would take both branches and union a tuple with an
|
|
61
|
+
* array, which widens the length straight back to `number`.
|
|
51
62
|
*/
|
|
52
63
|
export type PredictEntityKeysReturnType<
|
|
53
64
|
TCount extends number = number,
|
|
54
|
-
TSalts extends readonly
|
|
55
|
-
> = [TSalts] extends [readonly
|
|
65
|
+
TSalts extends readonly SaltInput[] | undefined = readonly SaltInput[] | undefined,
|
|
66
|
+
> = [TSalts] extends [readonly SaltInput[]]
|
|
56
67
|
? { -readonly [Index in keyof TSalts]: PredictedEntityKey }
|
|
57
68
|
: Repeat<PredictedEntityKey, TCount>
|
|
58
69
|
|
|
@@ -79,7 +90,7 @@ type Repeat<T, TLength extends number, TAcc extends T[] = []> = number extends T
|
|
|
79
90
|
*
|
|
80
91
|
* The prediction is valid only while nothing else from this owner is in flight. Every create that
|
|
81
92
|
* lands first takes the nonce with it and moves these keys. For a key you can rely on
|
|
82
|
-
* unconditionally, read it back from the create instead — `createEntity` and `
|
|
93
|
+
* unconditionally, read it back from the create instead — `createEntity` and `executeBatch`
|
|
83
94
|
* report the keys the engine actually minted.
|
|
84
95
|
*
|
|
85
96
|
* @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
|
|
@@ -89,7 +100,7 @@ type Repeat<T, TLength extends number, TAcc extends T[] = []> = number extends T
|
|
|
89
100
|
* import { key } from "@arkiv-network/sdk/attr"
|
|
90
101
|
*
|
|
91
102
|
* const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
|
|
92
|
-
* await
|
|
103
|
+
* await client.executeBatch({
|
|
93
104
|
* creates: [
|
|
94
105
|
* { payload, contentType, expires, salt: parent.salt },
|
|
95
106
|
* {
|
|
@@ -104,7 +115,7 @@ type Repeat<T, TLength extends number, TAcc extends T[] = []> = number extends T
|
|
|
104
115
|
*/
|
|
105
116
|
export async function predictEntityKeys<
|
|
106
117
|
const TCount extends number = number,
|
|
107
|
-
const TSalts extends readonly
|
|
118
|
+
const TSalts extends readonly SaltInput[] | undefined = undefined,
|
|
108
119
|
>(
|
|
109
120
|
client: ArkivClient,
|
|
110
121
|
{ owner, count, salts }: PredictEntityKeysParameters<TCount, TSalts>,
|
|
@@ -121,12 +132,15 @@ export async function predictEntityKeys<
|
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
/** The salts to derive from: the ones given, or `count` fresh random ones. */
|
|
124
|
-
function resolveSalts(
|
|
135
|
+
function resolveSalts(
|
|
136
|
+
count: number | undefined,
|
|
137
|
+
salts: readonly SaltInput[] | undefined,
|
|
138
|
+
): bigint[] {
|
|
125
139
|
if (salts !== undefined) {
|
|
126
140
|
if (salts.length === 0) {
|
|
127
141
|
throw new Error("predictEntityKeys: `salts` is empty — there is nothing to predict")
|
|
128
142
|
}
|
|
129
|
-
return salts.map(
|
|
143
|
+
return salts.map(resolveSalt)
|
|
130
144
|
}
|
|
131
145
|
if (count === undefined) {
|
|
132
146
|
throw new Error("predictEntityKeys: pass either `count` or `salts`")
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Hash, Hex } from "viem"
|
|
2
2
|
import type { AttributeInputs } from "../../attr"
|
|
3
3
|
import type { ArkivClient } from "../../clients/baseClient"
|
|
4
|
-
import type { CreationFlags, Expiry } from "../../entity"
|
|
4
|
+
import type { CreationFlags, Expiry, NO_SALT, SaltInput } from "../../entity"
|
|
5
5
|
import { EntityMutationError } from "../../errors"
|
|
6
6
|
import type { MimeType, TxParams } from "../../types"
|
|
7
7
|
import { sendArkivTransaction } from "../../utils/arkivTransactions"
|
|
8
|
+
import type { ExpirationTime } from "../../utils/expirationTime"
|
|
8
9
|
import { getLogger } from "../../utils/logger"
|
|
9
10
|
|
|
10
11
|
const logger = getLogger("actions:wallet:create-entity")
|
|
@@ -66,8 +67,8 @@ export type CreateEntityParameters = {
|
|
|
66
67
|
contentType: MimeType | (string & {})
|
|
67
68
|
/**
|
|
68
69
|
* The entity's queryable attributes, keyed by name. Values are the tagged constructors from
|
|
69
|
-
* `@arkiv-network/sdk/attr` — `i32`, `u256`, `dec`, `str`, `addr`, `key`, `bytes32`,
|
|
70
|
-
* a bare `boolean`, `number`, `bigint` or `string` where the type is unambiguous.
|
|
70
|
+
* `@arkiv-network/sdk/attr` — `i32`, `u64`, `u256`, `dec`, `str`, `addr`, `key`, `bytes32`,
|
|
71
|
+
* `bool` — or a bare `boolean`, `number`, `bigint` or `string` where the type is unambiguous.
|
|
71
72
|
*
|
|
72
73
|
* @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
|
|
73
74
|
* @throws {InvalidValueError} If a value does not fit the type it names or defaults to.
|
|
@@ -82,10 +83,10 @@ export type CreateEntityParameters = {
|
|
|
82
83
|
* The salt mixed into the entity key. Defaults to 128 random bits, which makes the key
|
|
83
84
|
* unpredictable to everyone but the creator.
|
|
84
85
|
*
|
|
85
|
-
* Pass
|
|
86
|
-
* what you want only when a third party must be able to compute the key in advance.
|
|
86
|
+
* Pass {@link NO_SALT} for a key derived from the owner and nonce alone — predictable by anyone,
|
|
87
|
+
* which is what you want only when a third party must be able to compute the key in advance.
|
|
87
88
|
*/
|
|
88
|
-
salt?:
|
|
89
|
+
salt?: SaltInput | undefined
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
@@ -125,6 +126,7 @@ export async function createEntity(
|
|
|
125
126
|
if (entityKey === undefined || expiresAt === undefined) {
|
|
126
127
|
throw new EntityMutationError(
|
|
127
128
|
`Transaction ${receipt.transactionHash} succeeded, but the receipt did not carry the expected entity key or expiry.`,
|
|
129
|
+
{ txHash: receipt.transactionHash },
|
|
128
130
|
)
|
|
129
131
|
}
|
|
130
132
|
|