@arkiv-network/sdk 0.4.5 → 0.5.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/chains/index.cjs +5 -88
  2. package/dist/chains/index.d.cts +33 -33
  3. package/dist/chains/index.d.ts +33 -33
  4. package/dist/chains/index.d.ts.map +1 -1
  5. package/dist/chains/index.js +2 -85
  6. package/dist/chains-BDsOtN2a.js +107 -0
  7. package/dist/chains-BDsOtN2a.js.map +1 -0
  8. package/dist/chains-XCO31x6G.cjs +124 -0
  9. package/dist/chunk-pbleEpgJ.cjs +44 -0
  10. package/dist/index-B801JxcV.d.ts +1003 -0
  11. package/dist/index-B801JxcV.d.ts.map +1 -0
  12. package/dist/index-DQGx5KZ6.d.cts +1003 -0
  13. package/dist/index-DQGx5KZ6.d.cts.map +1 -0
  14. package/dist/index.cjs +57 -15
  15. package/dist/index.d.cts +3 -362
  16. package/dist/index.d.ts +3 -362
  17. package/dist/index.js +49 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/payload-BI2NXPDf.d.ts +6 -0
  20. package/dist/payload-BI2NXPDf.d.ts.map +1 -0
  21. package/dist/payload-D3fyOBWn.d.cts +6 -0
  22. package/dist/payload-D3fyOBWn.d.cts.map +1 -0
  23. package/dist/payload-DKBYYjeA.js +18 -0
  24. package/dist/payload-DKBYYjeA.js.map +1 -0
  25. package/dist/payload-eB1a8vZH.cjs +41 -0
  26. package/dist/query/index.cjs +1 -2
  27. package/dist/query/index.d.cts +3 -6
  28. package/dist/query/index.d.cts.map +1 -1
  29. package/dist/query/index.d.ts +3 -6
  30. package/dist/query/index.d.ts.map +1 -1
  31. package/dist/query/index.js +2 -2
  32. package/dist/{queryBuilder-DVs4ZIyZ.js → queryBuilder-DNUwJvf0.js} +4 -9
  33. package/dist/queryBuilder-DNUwJvf0.js.map +1 -0
  34. package/dist/{queryBuilder-Cn5JJRMM.cjs → queryBuilder-KrdIUVZv.cjs} +4 -43
  35. package/dist/types/index.cjs +1 -1
  36. package/dist/types/index.d.cts +3 -2
  37. package/dist/types/index.d.ts +3 -2
  38. package/dist/types/index.js +1 -1
  39. package/dist/utils/index.cjs +4 -15
  40. package/dist/utils/index.d.cts +1 -4
  41. package/dist/utils/index.d.cts.map +1 -1
  42. package/dist/utils/index.d.ts +1 -4
  43. package/dist/utils/index.d.ts.map +1 -1
  44. package/dist/utils/index.js +1 -11
  45. package/dist/utils/index.js.map +1 -1
  46. package/package.json +8 -5
  47. package/src/actions/public/query.ts +49 -2
  48. package/src/actions/public/subscribeEntityEvents.ts +3 -3
  49. package/src/clients/createPublicClient.ts +1 -1
  50. package/src/clients/createWalletClient.ts +2 -2
  51. package/src/clients/decorators/arkivPublic.ts +42 -7
  52. package/src/clients/decorators/arkivWallet.ts +21 -15
  53. package/src/index.ts +10 -0
  54. package/src/query/errors.ts +0 -6
  55. package/src/query/queryBuilder.ts +7 -4
  56. package/src/types/index.ts +21 -1
  57. package/src/types/rpcSchema.ts +10 -10
  58. package/src/utils/chains.test.ts +97 -0
  59. package/src/utils/chains.ts +19 -0
  60. package/src/utils/compression.ts +1 -1
  61. package/dist/chains/index.js.map +0 -1
  62. package/dist/consts-BV9DVKgE.cjs +0 -18
  63. package/dist/consts-CHtLBwGd.js +0 -7
  64. package/dist/consts-CHtLBwGd.js.map +0 -1
  65. package/dist/entity-BNSCqNpu.d.cts +0 -254
  66. package/dist/entity-BNSCqNpu.d.cts.map +0 -1
  67. package/dist/entity-CWj4qVCX.d.ts +0 -254
  68. package/dist/entity-CWj4qVCX.d.ts.map +0 -1
  69. package/dist/index.d.cts.map +0 -1
  70. package/dist/index.d.ts.map +0 -1
  71. package/dist/queryBuilder-CXcMv0Uc.d.ts +0 -314
  72. package/dist/queryBuilder-CXcMv0Uc.d.ts.map +0 -1
  73. package/dist/queryBuilder-CvAx57pq.d.cts +0 -314
  74. package/dist/queryBuilder-CvAx57pq.d.cts.map +0 -1
  75. package/dist/queryBuilder-DVs4ZIyZ.js.map +0 -1
  76. /package/dist/{types-CBTc19th.cjs → types-H-TSmRpm.js} +0 -0
  77. /package/dist/{types-Cv8NMtbo.js → types-o3zWarRp.cjs} +0 -0
@@ -1,29 +1,7 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc$1) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc$1 = __getOwnPropDesc(from, key)) || desc$1.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
1
+ const require_chunk = require('./chunk-pbleEpgJ.cjs');
24
2
  let viem = require("viem");
25
3
  let debug = require("debug");
26
- debug = __toESM(debug);
4
+ debug = require_chunk.__toESM(debug);
27
5
 
28
6
  //#region src/utils/logger.ts
29
7
  const ROOT_NAMESPACE = "arkiv";
@@ -41,11 +19,6 @@ var NoCursorOrLimitError = class extends Error {
41
19
  super("Cursor and limit must be defined to fetch next");
42
20
  }
43
21
  };
44
- var OffsetCannotBeLessThanZeroError = class extends Error {
45
- constructor() {
46
- super("Offset cannot be less than 0");
47
- }
48
- };
49
22
  var NoEntityFoundError = class extends Error {
50
23
  constructor() {
51
24
  super("No entity found");
@@ -216,7 +189,7 @@ var QueryResult = class {
216
189
  * Helper function to create an ascending order by attribute
217
190
  * @param attributeName - The name of the attribute to order by
218
191
  * @param attributeType - The type of the attribute to order by (string or number)
219
- * @returns The OrderByAttribute instance
192
+ * @returns Input for orderBy method
220
193
  *
221
194
  * @example
222
195
  * const ascAttribute = asc("name", "string")
@@ -232,7 +205,7 @@ function asc(attributeName, attributeType) {
232
205
  * Helper function to create a descending order by attribute
233
206
  * @param attributeName - The name of the attribute to order by
234
207
  * @param attributeType - The type of the attribute to order by (string or number)
235
- * @returns The OrderByAttribute instance
208
+ * @returns Input for orderBy method
236
209
  *
237
210
  * @example
238
211
  * const descAttribute = desc("name", "string")
@@ -467,12 +440,6 @@ Object.defineProperty(exports, 'NoMoreResultsError', {
467
440
  return NoMoreResultsError;
468
441
  }
469
442
  });
470
- Object.defineProperty(exports, 'OffsetCannotBeLessThanZeroError', {
471
- enumerable: true,
472
- get: function () {
473
- return OffsetCannotBeLessThanZeroError;
474
- }
475
- });
476
443
  Object.defineProperty(exports, 'QueryBuilder', {
477
444
  enumerable: true,
478
445
  get: function () {
@@ -485,12 +452,6 @@ Object.defineProperty(exports, 'QueryResult', {
485
452
  return QueryResult;
486
453
  }
487
454
  });
488
- Object.defineProperty(exports, '__toESM', {
489
- enumerable: true,
490
- get: function () {
491
- return __toESM;
492
- }
493
- });
494
455
  Object.defineProperty(exports, 'asc', {
495
456
  enumerable: true,
496
457
  get: function () {
@@ -1 +1 @@
1
- require('../types-CBTc19th.cjs');
1
+ require('../types-o3zWarRp.cjs');
@@ -1,2 +1,3 @@
1
- import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "../entity-BNSCqNpu.cjs";
2
- export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, RpcEntity, RpcIncludeData, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
1
+ import { $ as RpcIncludeData, A as CreateEntityParameters, C as MutateEntitiesReturnType, D as ExtendEntityReturnType, E as ExtendEntityParameters, J as QueryOptionsIncludeData, M as ChangeOwnershipParameters, N as ChangeOwnershipReturnType, O as DeleteEntityParameters, P as GetBlockTimingReturnType, Q as RpcEntity, S as MutateEntitiesParameters, T as UpdateEntityReturnType, Y as QueryOptionsOrderBy, Z as ArkivRpcSchema, _ as OnEntityExpiredEvent, b as OnEntityUpdatedEvent, et as RpcOrderByAttribute, g as OnEntityDeletedEvent, h as OnEntityCreatedEvent, j as CreateEntityReturnType, k as DeleteEntityReturnType, m as TxParams, nt as MimeType, p as Entity, q as QueryOptions, tt as RpcQueryOptions, v as OnEntityExpiresInExtendedEvent, w as UpdateEntityParameters, x as Attribute, y as OnEntityOwnerChangedEvent } from "../index-DQGx5KZ6.cjs";
2
+ import "../payload-D3fyOBWn.cjs";
3
+ export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1,2 +1,3 @@
1
- import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "../entity-CWj4qVCX.js";
2
- export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, RpcEntity, RpcIncludeData, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
1
+ import { $ as RpcIncludeData, A as CreateEntityParameters, C as MutateEntitiesReturnType, D as ExtendEntityReturnType, E as ExtendEntityParameters, J as QueryOptionsIncludeData, M as ChangeOwnershipParameters, N as ChangeOwnershipReturnType, O as DeleteEntityParameters, P as GetBlockTimingReturnType, Q as RpcEntity, S as MutateEntitiesParameters, T as UpdateEntityReturnType, Y as QueryOptionsOrderBy, Z as ArkivRpcSchema, _ as OnEntityExpiredEvent, b as OnEntityUpdatedEvent, et as RpcOrderByAttribute, g as OnEntityDeletedEvent, h as OnEntityCreatedEvent, j as CreateEntityReturnType, k as DeleteEntityReturnType, m as TxParams, nt as MimeType, p as Entity, q as QueryOptions, tt as RpcQueryOptions, v as OnEntityExpiresInExtendedEvent, w as UpdateEntityParameters, x as Attribute, y as OnEntityOwnerChangedEvent } from "../index-B801JxcV.js";
2
+ import "../payload-BI2NXPDf.js";
3
+ export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1 +1 @@
1
- import "../types-Cv8NMtbo.js";
1
+ import "../types-H-TSmRpm.js";
@@ -1,6 +1,4 @@
1
- const require_queryBuilder = require('../queryBuilder-Cn5JJRMM.cjs');
2
- const require_consts = require('../consts-BV9DVKgE.cjs');
3
- let viem = require("viem");
1
+ const require_payload = require('../payload-eB1a8vZH.cjs');
4
2
 
5
3
  //#region src/utils/expirationTime.ts
6
4
  const ExpirationTime = {
@@ -11,23 +9,14 @@ const ExpirationTime = {
11
9
  fromWeeks: (weeks) => weeks * 7 * 24 * 60 * 60,
12
10
  fromMonths: (months) => months * 30 * 24 * 60 * 60,
13
11
  fromYears: (years) => years * 365 * 24 * 60 * 60,
14
- fromBlocks: (blocks) => blocks * require_consts.BLOCK_TIME,
12
+ fromBlocks: (blocks) => blocks * require_payload.BLOCK_TIME,
15
13
  fromDate: (date) => Math.floor(date.getTime() / 1e3) - Math.floor(Date.now() / 1e3)
16
14
  };
17
15
 
18
- //#endregion
19
- //#region src/utils/payload.ts
20
- function jsonToPayload(json) {
21
- return (0, viem.toBytes)(JSON.stringify(json));
22
- }
23
- function stringToPayload(data) {
24
- return (0, viem.toBytes)(data);
25
- }
26
-
27
16
  //#endregion
28
17
  exports.ExpirationTime = ExpirationTime;
29
- exports.jsonToPayload = jsonToPayload;
30
- exports.stringToPayload = stringToPayload;
18
+ exports.jsonToPayload = require_payload.jsonToPayload;
19
+ exports.stringToPayload = require_payload.stringToPayload;
31
20
  var viem_utils = require("viem/utils");
32
21
  Object.keys(viem_utils).forEach(function (k) {
33
22
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -1,3 +1,4 @@
1
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-D3fyOBWn.cjs";
1
2
  export * from "viem/utils";
2
3
 
3
4
  //#region src/utils/expirationTime.d.ts
@@ -13,9 +14,5 @@ declare const ExpirationTime: {
13
14
  fromDate: (date: Date) => number;
14
15
  };
15
16
  //#endregion
16
- //#region src/utils/payload.d.ts
17
- declare function jsonToPayload(json: object): Uint8Array;
18
- declare function stringToPayload(data: string): Uint8Array;
19
- //#endregion
20
17
  export { ExpirationTime, jsonToPayload, stringToPayload };
21
18
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/expirationTime.ts","../../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;ECTP,SAAA,EAAA,CAAA,KAAa,EAAA,MAAA,EAAA,GAAgB,MAAA;EAI7B,UAAA,EAAA,CAAA,MAAe,EAAA,MAAA,EAAA,GAAgB,MAAA;mBDK5B;;;;iBCTH,aAAA,gBAA6B;iBAI7B,eAAA,gBAA+B"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;;cAEa;;;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;mBAAJ"}
@@ -1,3 +1,4 @@
1
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-BI2NXPDf.js";
1
2
  export * from "viem/utils";
2
3
 
3
4
  //#region src/utils/expirationTime.d.ts
@@ -13,9 +14,5 @@ declare const ExpirationTime: {
13
14
  fromDate: (date: Date) => number;
14
15
  };
15
16
  //#endregion
16
- //#region src/utils/payload.d.ts
17
- declare function jsonToPayload(json: object): Uint8Array;
18
- declare function stringToPayload(data: string): Uint8Array;
19
- //#endregion
20
17
  export { ExpirationTime, jsonToPayload, stringToPayload };
21
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts","../../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;ECTP,SAAA,EAAA,CAAA,KAAa,EAAA,MAAA,EAAA,GAAgB,MAAA;EAI7B,UAAA,EAAA,CAAA,MAAe,EAAA,MAAA,EAAA,GAAgB,MAAA;mBDK5B;;;;iBCTH,aAAA,gBAA6B;iBAI7B,eAAA,gBAA+B"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;;cAEa;;;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;mBAAJ"}
@@ -1,5 +1,4 @@
1
- import { n as BLOCK_TIME } from "../consts-CHtLBwGd.js";
2
- import { toBytes } from "viem";
1
+ import { i as BLOCK_TIME, n as stringToPayload, t as jsonToPayload } from "../payload-DKBYYjeA.js";
3
2
 
4
3
  export * from "viem/utils"
5
4
 
@@ -16,15 +15,6 @@ const ExpirationTime = {
16
15
  fromDate: (date) => Math.floor(date.getTime() / 1e3) - Math.floor(Date.now() / 1e3)
17
16
  };
18
17
 
19
- //#endregion
20
- //#region src/utils/payload.ts
21
- function jsonToPayload(json) {
22
- return toBytes(JSON.stringify(json));
23
- }
24
- function stringToPayload(data) {
25
- return toBytes(data);
26
- }
27
-
28
18
  //#endregion
29
19
  export { ExpirationTime, jsonToPayload, stringToPayload };
30
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/expirationTime.ts","../../src/utils/payload.ts"],"sourcesContent":["import { BLOCK_TIME } from \"../consts\"\n\nexport const ExpirationTime = {\n fromSeconds: (seconds: number) => seconds,\n fromMinutes: (minutes: number) => minutes * 60,\n fromHours: (hours: number) => hours * 60 * 60,\n fromDays: (days: number) => days * 24 * 60 * 60,\n fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,\n fromMonths: (months: number) => months * 30 * 24 * 60 * 60,\n fromYears: (years: number) => years * 365 * 24 * 60 * 60,\n fromBlocks: (blocks: number) => blocks * BLOCK_TIME,\n fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),\n}\n","import { toBytes } from \"viem\"\n\nexport function jsonToPayload(json: object): Uint8Array {\n return toBytes(JSON.stringify(json))\n}\n\nexport function stringToPayload(data: string): Uint8Array {\n return toBytes(data)\n}\n"],"mappings":";;;;;;AAEA,MAAa,iBAAiB;CAC5B,cAAc,YAAoB;CAClC,cAAc,YAAoB,UAAU;CAC5C,YAAY,UAAkB,QAAQ,KAAK;CAC3C,WAAW,SAAiB,OAAO,KAAK,KAAK;CAC7C,YAAY,UAAkB,QAAQ,IAAI,KAAK,KAAK;CACpD,aAAa,WAAmB,SAAS,KAAK,KAAK,KAAK;CACxD,YAAY,UAAkB,QAAQ,MAAM,KAAK,KAAK;CACtD,aAAa,WAAmB,SAAS;CACzC,WAAW,SAAe,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;CAC5F;;;;ACVD,SAAgB,cAAc,MAA0B;AACtD,QAAO,QAAQ,KAAK,UAAU,KAAK,CAAC;;AAGtC,SAAgB,gBAAgB,MAA0B;AACxD,QAAO,QAAQ,KAAK"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":["import { BLOCK_TIME } from \"../consts\"\n\nexport const ExpirationTime = {\n fromSeconds: (seconds: number) => seconds,\n fromMinutes: (minutes: number) => minutes * 60,\n fromHours: (hours: number) => hours * 60 * 60,\n fromDays: (days: number) => days * 24 * 60 * 60,\n fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,\n fromMonths: (months: number) => months * 30 * 24 * 60 * 60,\n fromYears: (years: number) => years * 365 * 24 * 60 * 60,\n fromBlocks: (blocks: number) => blocks * BLOCK_TIME,\n fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),\n}\n"],"mappings":";;;;;AAEA,MAAa,iBAAiB;CAC5B,cAAc,YAAoB;CAClC,cAAc,YAAoB,UAAU;CAC5C,YAAY,UAAkB,QAAQ,KAAK;CAC3C,WAAW,SAAiB,OAAO,KAAK,KAAK;CAC7C,YAAY,UAAkB,QAAQ,IAAI,KAAK,KAAK;CACpD,aAAa,WAAmB,SAAS,KAAK,KAAK,KAAK;CACxD,YAAY,UAAkB,QAAQ,MAAM,KAAK,KAAK;CACtD,aAAa,WAAmB,SAAS;CACzC,WAAW,SAAe,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;CAC5F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkiv-network/sdk",
3
- "version": "0.4.5",
3
+ "version": "0.5.0-dev.2",
4
4
  "description": "TypeScript client library for Arkiv's blockchains interactions",
5
5
  "type": "module",
6
6
  "target": "esnext",
@@ -73,6 +73,7 @@
73
73
  "lint": "biome check src/",
74
74
  "lint:fix": "biome check --write src/",
75
75
  "test:unit": "bun test src/**/*",
76
+ "docs": "bunx typedoc --plugin typedoc-plugin-markdown",
76
77
  "package": "rimraf arkiv-network-sdk-*.tgz && bun run build && bun pm pack --no-cache",
77
78
  "package:test": "bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
78
79
  "prepublishOnly": "bun run build && bun run package && mv arkiv-network-sdk-*.tgz arkiv-network-sdk-latest.tgz",
@@ -84,11 +85,12 @@
84
85
  "publish-dev:dry": "npm publish ./arkiv-network-sdk-latest.tgz --access public --tag dev --dry-run"
85
86
  },
86
87
  "devDependencies": {
87
- "@types/debug": "^4.1.12",
88
88
  "@biomejs/biome": "2.2.4",
89
89
  "@types/bun": "latest",
90
+ "@types/debug": "^4.1.12",
90
91
  "rimraf": "^6.0.1",
91
- "tsdown": "^0.16.0"
92
+ "tsdown": "^0.16.0",
93
+ "typedoc": "^0.28.14"
92
94
  },
93
95
  "peerDependencies": {
94
96
  "typescript": "^5.0.0"
@@ -117,7 +119,8 @@
117
119
  "homepage": "https://arkiv.network",
118
120
  "dependencies": {
119
121
  "brotli-wasm": "^3.0.1",
120
- "viem": "^2.38.2",
121
- "debug": "^4.3.7"
122
+ "debug": "^4.3.7",
123
+ "typedoc-plugin-markdown": "^4.9.0",
124
+ "viem": "^2.38.2"
122
125
  }
123
126
  }
@@ -1,10 +1,57 @@
1
1
  import type { ArkivClient } from "../../clients/baseClient"
2
+ import type { RpcQueryOptions } from "../../types/rpcSchema"
2
3
  import { entityFromRpcResult } from "../../utils/entities"
3
4
 
4
- export async function query(client: ArkivClient, query: string) {
5
+ export type QueryOptionsIncludeData = {
6
+ attributes?: boolean
7
+ payload?: boolean
8
+ metadata?: boolean
9
+ }
10
+ export type QueryOptionsOrderBy = {
11
+ name: string
12
+ type: "string" | "numeric"
13
+ desc: "asc" | "desc"
14
+ }
15
+
16
+ export type QueryOptions = {
17
+ includeData?: QueryOptionsIncludeData
18
+ atBlock?: bigint
19
+ orderBy?: QueryOptionsOrderBy[]
20
+ resultsPerPage?: number | undefined
21
+ cursor?: string | undefined
22
+ }
23
+
24
+ export async function query(client: ArkivClient, query: string, queryOptions?: QueryOptions) {
25
+ const rpcQueryOptions: RpcQueryOptions = {
26
+ includeData: {
27
+ key: true,
28
+ payload: queryOptions?.includeData?.payload ?? true,
29
+ attributes: queryOptions?.includeData?.attributes ?? false,
30
+ contentType: queryOptions?.includeData?.metadata ?? false,
31
+ expiration: queryOptions?.includeData?.metadata ?? false,
32
+ owner: queryOptions?.includeData?.metadata ?? false,
33
+ createdAtBlock: queryOptions?.includeData?.metadata ?? false,
34
+ lastModifiedAtBlock: queryOptions?.includeData?.metadata ?? false,
35
+ transactionIndexInBlock: queryOptions?.includeData?.metadata ?? false,
36
+ operationIndexInTransaction: queryOptions?.includeData?.metadata ?? false,
37
+ },
38
+ ...(queryOptions?.atBlock !== undefined && { atBlock: Number(queryOptions.atBlock) }),
39
+ ...(queryOptions?.orderBy && {
40
+ orderBy: queryOptions?.orderBy.map((order) => ({
41
+ name: order.name,
42
+ type: order.type,
43
+ desc: order.desc === "desc",
44
+ })),
45
+ }),
46
+ ...(queryOptions?.resultsPerPage !== undefined && {
47
+ resultsPerPage: queryOptions.resultsPerPage,
48
+ }),
49
+ ...(queryOptions?.cursor !== undefined && { cursor: queryOptions?.cursor }),
50
+ }
51
+
5
52
  const result = await client.request({
6
53
  method: "arkiv_query",
7
- params: [query],
54
+ params: [query, rpcQueryOptions],
8
55
  })
9
56
 
10
57
  const entities = await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)))
@@ -1,4 +1,4 @@
1
- import { decodeEventLog, parseAbi, toHex } from "viem"
1
+ import { decodeEventLog, type Hex, parseAbi, toHex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { PublicArkivClient } from "../../clients/createPublicClient"
4
4
  import type {
@@ -46,14 +46,14 @@ export async function subscribeEntityEvents(
46
46
  ): Promise<() => void> {
47
47
  const unsubscribe = (client as PublicArkivClient).watchEvent({
48
48
  pollingInterval: pollingInterval ?? 1000,
49
- fromBlock: fromBlock,
49
+ fromBlock,
50
50
  events: arkivABI,
51
51
  onLogs: (logs) => {
52
52
  logger("logs from subscribeEntityEvents %o", logs)
53
53
  for (const log of logs) {
54
54
  const event = decodeEventLog({
55
55
  abi: arkivABI,
56
- topics: log.topics as [string, string, string] | [string, string, string, string],
56
+ topics: log.topics as [Hex, ...Hex[]] | [],
57
57
  data: log.data,
58
58
  })
59
59
  logger("event from subscribeEntityEvents %o", event)
@@ -29,7 +29,7 @@ export type PublicArkivClient<
29
29
  *
30
30
  * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
31
31
  *
32
- * @param config - {@link PublicClientConfig}
32
+ * @param parameters - Configuration object for the public client (chain, transport, etc.)
33
33
  * @returns A Arkiv Public Client. {@link PublicArkivClient}
34
34
  *
35
35
  * @example
@@ -29,8 +29,8 @@ export type WalletArkivClient<
29
29
  *
30
30
  * A Public Client is an interface to "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/), [Arkiv JSON-RPC API](https://docs.arkiv.network/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.arkiv.network/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
31
31
  *
32
- * @param config - {@link PublicClientConfig}
33
- * @returns A Arkiv Public Client. {@link PublicArkivClient}
32
+ * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
33
+ * @returns A Arkiv Wallet Client. {@link WalletArkivClient}
34
34
  *
35
35
  * @example
36
36
  * import { createPublicClient, http } from 'arkiv'
@@ -2,7 +2,7 @@ import type { Account, Chain, Client, Hex, PublicActions, Transport } from "viem
2
2
  import { getBlockTiming } from "../../actions/public/getBlockTiming"
3
3
  import { getEntity } from "../../actions/public/getEntity"
4
4
  import { getEntityCount } from "../../actions/public/getEntityCount"
5
- import { query } from "../../actions/public/query"
5
+ import { type QueryOptions, query } from "../../actions/public/query"
6
6
  import { subscribeEntityEvents } from "../../actions/public/subscribeEntityEvents"
7
7
  import { QueryBuilder } from "../../query/queryBuilder"
8
8
  import type { Entity } from "../../types/entity"
@@ -36,7 +36,7 @@ export type PublicArkivActions<
36
36
  *
37
37
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
38
38
  *
39
- * @param args - {entityKey}
39
+ * @param key - The entity key (hex string)
40
40
  * @returns The entity with the given key. {@link Entity}
41
41
  *
42
42
  * @example
@@ -79,7 +79,10 @@ export type PublicArkivActions<
79
79
 
80
80
  /**
81
81
  * Returns a QueryResult instance for fetching the results of a raw query.
82
- * @returns A QueryResult instance for fetching the results of a raw query. {@link QueryResult}
82
+ * If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
83
+ * @param query - The raw query string
84
+ * @param queryOptions - The optional query options - {@link QueryOptions}
85
+ * @returns An array of entities matching the query. {@link Entity}
83
86
  *
84
87
  * @example
85
88
  * import { createPublicClient, http } from 'arkiv'
@@ -90,13 +93,25 @@ export type PublicArkivActions<
90
93
  * transport: http(),
91
94
  * })
92
95
  * const queryResult = client.query('key = value && $owner = 0x123')
93
- *
96
+ * // queryResult = [{ key: "0x123", value: "0x123" }]
97
+ * const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
98
+ * includeData: {
99
+ * attributes: false,
100
+ * payload: true,
101
+ * metadata: true,
102
+ * },
103
+ * orderBy: [{ name: "key", type: "string", desc: "asc" }],
104
+ * resultsPerPage: 10,
105
+ * cursor: undefined,
106
+ * atBlock: undefined,
107
+ * })
108
+ * // queryResultWithOptions = [{ key: "0x123", value: "0x123" }]
94
109
  */
95
- query: (query: string) => Promise<Entity[]>
110
+ query: (query: string, queryOptions?: QueryOptions) => Promise<Entity[]>
96
111
 
97
112
  /**
98
113
  * Returns the number of entities in the DBChain.
99
- * @returns The number of entities in the DBChain. {@link number}
114
+ * @returns The number of entities in the DBChain
100
115
  *
101
116
  * @example
102
117
  * import { createPublicClient, http } from 'arkiv'
@@ -136,6 +151,26 @@ export type PublicArkivActions<
136
151
  blockDuration: number
137
152
  }>
138
153
 
154
+ /**
155
+ * Subscribes to entity events.
156
+ * Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
157
+ * @param pollingInterval - The polling interval in milliseconds
158
+ * @param fromBlock - The block number to start from
159
+ * @returns A function to unsubscribe from the events
160
+ *
161
+ * @example
162
+ * import { createPublicClient, http } from 'arkiv'
163
+ * import { kaolin } from 'arkiv/chains'
164
+ *
165
+ * const client = createPublicClient({
166
+ * chain: kaolin,
167
+ * transport: http(),
168
+ * })
169
+ * const unsubscribe = await client.subscribeEntityEvents({
170
+ * onError: (error) => console.error("subscribeEntityEvents error", error),
171
+ * })
172
+ * unsubscribe() // unsubscribe from the events
173
+ */
139
174
  subscribeEntityEvents: (
140
175
  {
141
176
  onError,
@@ -163,7 +198,7 @@ export function publicArkivActions<
163
198
  >(client: Client<transport, chain, account>) {
164
199
  return {
165
200
  getEntity: (key: Hex) => getEntity(client, key),
166
- query: (rawQuery: string) => query(client, rawQuery),
201
+ query: (rawQuery: string, queryOptions?: QueryOptions) => query(client, rawQuery, queryOptions),
167
202
  buildQuery: () => new QueryBuilder(client),
168
203
  getBlockTiming: () => getBlockTiming(client),
169
204
  getEntityCount: () => getEntityCount(client),
@@ -29,7 +29,7 @@ import type {
29
29
  UpdateEntityReturnType,
30
30
  } from "../../actions/wallet/updateEntity"
31
31
  import { updateEntity } from "../../actions/wallet/updateEntity"
32
- import type { Entity, TxParams } from "../../types"
32
+ import type { TxParams } from "../../types"
33
33
 
34
34
  export type WalletArkivActions<
35
35
  transport extends Transport = Transport,
@@ -47,13 +47,14 @@ export type WalletArkivActions<
47
47
  | "signTransaction"
48
48
  > & {
49
49
  /**
50
- * Returns the entity with the given key.
50
+ * Creates a new entity.
51
51
  *
52
- * - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
52
+ * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/createEntity
53
53
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
54
54
  *
55
- * @param args - {entityKey}
56
- * @returns The entity with the given key. {@link Entity}
55
+ * @param data - The entity creation parameters
56
+ * @param txParams - Optional transaction parameters
57
+ * @returns The created entity with transaction hash
57
58
  *
58
59
  * @example
59
60
  * import { createPublicClient, http } from 'arkiv'
@@ -86,8 +87,9 @@ export type WalletArkivActions<
86
87
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
87
88
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
88
89
  *
89
- * @param args - {entityKey, data}
90
- * @returns The entity with the given key. {@link Entity}
90
+ * @param data - The entity update parameters
91
+ * @param txParams - Optional transaction parameters
92
+ * @returns The updated entity with transaction hash
91
93
  *
92
94
  * @example
93
95
  * import { createWalletClient, http } from 'arkiv'
@@ -109,8 +111,9 @@ export type WalletArkivActions<
109
111
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
110
112
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
111
113
  *
112
- * @param args - {entityKey}
113
- * @returns The entity with the given key. {@link Entity}
114
+ * @param data - The entity deletion parameters
115
+ * @param txParams - Optional transaction parameters
116
+ * @returns The deleted entity with transaction hash
114
117
  *
115
118
  * @example
116
119
  * import { createWalletClient, http } from 'arkiv'
@@ -139,8 +142,9 @@ export type WalletArkivActions<
139
142
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
140
143
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
141
144
  *
142
- * @param args - {entityKey, data}
143
- * @returns The entity with the given key. {@link Entity}
145
+ * @param data - The entity update parameters
146
+ * @param txParams - Optional transaction parameters
147
+ * @returns The updated entity with transaction hash
144
148
  *
145
149
  * @example
146
150
  * import { createWalletClient, http } from 'arkiv'
@@ -171,8 +175,9 @@ export type WalletArkivActions<
171
175
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
172
176
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
173
177
  *
174
- * @param args - {entityKey, newOwner}
175
- * @returns The entity with the given address. {@link Entity}
178
+ * @param data - The ownership change parameters
179
+ * @param txParams - Optional transaction parameters
180
+ * @returns The entity with updated ownership and transaction hash
176
181
  */
177
182
  changeOwnership: (
178
183
  data: ChangeOwnershipParameters,
@@ -185,8 +190,9 @@ export type WalletArkivActions<
185
190
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
186
191
  * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
187
192
  *
188
- * @param args - {data}
189
- * @returns The entity with the given key. {@link Entity}
193
+ * @param data - The mutation parameters (creates, updates, deletes, extensions)
194
+ * @param txParams - Optional transaction parameters
195
+ * @returns The mutation result with transaction hash
190
196
  *
191
197
  * @example
192
198
  * import { createWalletClient, http } from 'arkiv'
package/src/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module main
3
+ */
4
+
1
5
  // Re-export all viem stuff
2
6
  export * from "viem"
3
7
 
@@ -7,6 +11,12 @@ export type { PublicArkivClient } from "./clients/createPublicClient"
7
11
  export { createPublicClient } from "./clients/createPublicClient"
8
12
  export type { WalletArkivClient } from "./clients/createWalletClient"
9
13
  export { createWalletClient } from "./clients/createWalletClient"
14
+ export type { PublicArkivActions } from "./clients/decorators/arkivPublic"
15
+ export type { WalletArkivActions } from "./clients/decorators/arkivWallet"
10
16
 
11
17
  // re-export arkiv types in main index file
12
18
  export * from "./types"
19
+
20
+ // re-export chosen utils
21
+ export { chainFromName } from "./utils/chains"
22
+ export { jsonToPayload, stringToPayload } from "./utils/payload"
@@ -10,12 +10,6 @@ export class NoCursorOrLimitError extends Error {
10
10
  }
11
11
  }
12
12
 
13
- export class OffsetCannotBeLessThanZeroError extends Error {
14
- constructor() {
15
- super("Offset cannot be less than 0")
16
- }
17
- }
18
-
19
13
  export class NoEntityFoundError extends Error {
20
14
  constructor() {
21
15
  super("No entity found")
@@ -6,7 +6,7 @@ import { processQuery } from "./engine"
6
6
  import type { Predicate } from "./predicate"
7
7
  import { QueryResult } from "./queryResult"
8
8
 
9
- type OrderByAttribute = {
9
+ export type OrderByAttribute = {
10
10
  name: string
11
11
  type: "string" | "number"
12
12
  order: "asc" | "desc"
@@ -16,7 +16,7 @@ type OrderByAttribute = {
16
16
  * Helper function to create an ascending order by attribute
17
17
  * @param attributeName - The name of the attribute to order by
18
18
  * @param attributeType - The type of the attribute to order by (string or number)
19
- * @returns The OrderByAttribute instance
19
+ * @returns Input for orderBy method
20
20
  *
21
21
  * @example
22
22
  * const ascAttribute = asc("name", "string")
@@ -33,7 +33,7 @@ export function asc(attributeName: string, attributeType: "string" | "number"):
33
33
  * Helper function to create a descending order by attribute
34
34
  * @param attributeName - The name of the attribute to order by
35
35
  * @param attributeType - The type of the attribute to order by (string or number)
36
- * @returns The OrderByAttribute instance
36
+ * @returns Input for orderBy method
37
37
  *
38
38
  * @example
39
39
  * const descAttribute = desc("name", "string")
@@ -86,14 +86,17 @@ export class QueryBuilder {
86
86
  * Sets the orderBy for the query.
87
87
  * It can be called multiple times to order by multiple attributes.
88
88
  * The order of the attributes is important. The first attribute is the primary order by attribute.
89
+ * You can use the helper functions asc() and desc() as input for this method.
89
90
  * @param attributeName - The name of the attribute to order by
90
91
  * @param attributeType - The type of the attribute to order by (string or number)
91
92
  * @param order - The order to set the order by (asc or desc)
92
93
  * @returns The QueryBuilder instance
93
94
  *
94
95
  * @example
95
- * const builder = new QueryBuilder(client)
96
+ * const builder = client.buildQuery()
96
97
  * builder.orderBy("name", "string", "desc")
98
+ * builder.orderBy(asc("name", "string"))
99
+ * builder.orderBy(desc("name", "string"))
97
100
  */
98
101
  orderBy(attributeName: string, attributeType: "string" | "number", order?: "asc" | "desc"): this
99
102
  /**