@arkiv-network/sdk 0.6.8 → 0.7.0-dev.1

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 (101) hide show
  1. package/README.md +52 -16
  2. package/dist/consts-Bz0LZQZY.js +7 -0
  3. package/dist/consts-Bz0LZQZY.js.map +1 -0
  4. package/dist/consts-CxT1-RXU.cjs +18 -0
  5. package/dist/entity-BhSXaB23.cjs +81 -0
  6. package/dist/{query-CO6f35AE.d.cts → entity-CN41IOrq.d.cts} +125 -59
  7. package/dist/entity-CN41IOrq.d.cts.map +1 -0
  8. package/dist/entity-DGfVyB-a.js +71 -0
  9. package/dist/entity-DGfVyB-a.js.map +1 -0
  10. package/dist/{query-BhdmAzYg.d.ts → entity-NnEVlePN.d.ts} +125 -59
  11. package/dist/entity-NnEVlePN.d.ts.map +1 -0
  12. package/dist/index-ClkpS6s_.d.ts +481 -0
  13. package/dist/index-ClkpS6s_.d.ts.map +1 -0
  14. package/dist/index-w4qop0Pe.d.cts +481 -0
  15. package/dist/index-w4qop0Pe.d.cts.map +1 -0
  16. package/dist/index.cjs +285 -233
  17. package/dist/index.d.cts +100 -6
  18. package/dist/index.d.cts.map +1 -1
  19. package/dist/index.d.ts +101 -7
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +280 -230
  22. package/dist/index.js.map +1 -1
  23. package/dist/payload-BpNUPOnY.js +13 -0
  24. package/dist/payload-BpNUPOnY.js.map +1 -0
  25. package/dist/{payload-Da9gJMG5.d.ts → payload-C2KHOUoj.d.ts} +1 -1
  26. package/dist/{payload-Da9gJMG5.d.ts.map → payload-C2KHOUoj.d.ts.map} +1 -1
  27. package/dist/{payload-vwU3Rc6P.cjs → payload-D8YLKcJj.cjs} +1 -18
  28. package/dist/query/index.cjs +11 -28
  29. package/dist/query/index.d.cts +3 -3
  30. package/dist/query/index.d.ts +3 -3
  31. package/dist/query/index.js +8 -28
  32. package/dist/query/index.js.map +1 -1
  33. package/dist/{queryBuilder-DonAg1aq.js → queryBuilder-BE_XhLLa.js} +303 -152
  34. package/dist/queryBuilder-BE_XhLLa.js.map +1 -0
  35. package/dist/{queryBuilder-DM-YO1Y7.cjs → queryBuilder-J37buGCi.cjs} +372 -149
  36. package/dist/types/index.cjs +4 -1
  37. package/dist/types/index.d.cts +2 -2
  38. package/dist/types/index.d.ts +2 -2
  39. package/dist/types/index.js +4 -1
  40. package/dist/utils/index.cjs +4 -10
  41. package/dist/utils/index.d.cts +0 -1
  42. package/dist/utils/index.d.cts.map +1 -1
  43. package/dist/utils/index.d.ts +1 -2
  44. package/dist/utils/index.d.ts.map +1 -1
  45. package/dist/utils/index.js +2 -3
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +11 -15
  48. package/src/actions/public/buildQuery.ts +4 -0
  49. package/src/actions/public/query.ts +10 -0
  50. package/src/actions/public/subscribeEntityEvents.ts +25 -51
  51. package/src/actions/wallet/changeOwnership.ts +6 -6
  52. package/src/actions/wallet/createEntity.ts +19 -6
  53. package/src/actions/wallet/deleteEntity.ts +2 -3
  54. package/src/actions/wallet/extendEntity.ts +9 -5
  55. package/src/actions/wallet/mutateEntities.ts +11 -54
  56. package/src/actions/wallet/updateEntity.ts +15 -6
  57. package/src/clients/createPublicClient.test.ts +2 -0
  58. package/src/clients/decorators/arkivPublic.ts +67 -2
  59. package/src/clients/decorators/arkivWallet.ts +23 -1
  60. package/src/consts.ts +2 -1
  61. package/src/errors.ts +46 -0
  62. package/src/index.ts +0 -3
  63. package/src/query/engine.test.ts +45 -0
  64. package/src/query/engine.ts +28 -14
  65. package/src/query/index.ts +1 -0
  66. package/src/query/predicate.test.ts +43 -0
  67. package/src/query/predicate.ts +14 -10
  68. package/src/query/queryBuilder.test.ts +22 -0
  69. package/src/query/queryBuilder.ts +221 -106
  70. package/src/query/queryResult.ts +13 -7
  71. package/src/query/selectQueryBuilder.test.ts +213 -0
  72. package/src/query/selection.test.ts +120 -0
  73. package/src/query/selection.ts +116 -0
  74. package/src/types/attributes.ts +25 -1
  75. package/src/types/entity.ts +12 -2
  76. package/src/types/events.ts +14 -16
  77. package/src/types/index.ts +1 -0
  78. package/src/types/rpcSchema.ts +7 -2
  79. package/src/utils/arkivTransactions.test.ts +260 -0
  80. package/src/utils/arkivTransactions.ts +255 -92
  81. package/src/utils/entities.ts +17 -7
  82. package/src/utils/index.ts +0 -1
  83. package/src/utils/payload.ts +4 -2
  84. package/src/utils/validation.test.ts +106 -0
  85. package/src/utils/validation.ts +80 -0
  86. package/dist/accounts/index.cjs +0 -9
  87. package/dist/accounts/index.d.cts +0 -1
  88. package/dist/accounts/index.d.ts +0 -1
  89. package/dist/accounts/index.js +0 -1
  90. package/dist/payload-DKBYYjeA.js +0 -18
  91. package/dist/payload-DKBYYjeA.js.map +0 -1
  92. package/dist/query-BhdmAzYg.d.ts.map +0 -1
  93. package/dist/query-CO6f35AE.d.cts.map +0 -1
  94. package/dist/queryBuilder-BvoQXa_u.d.ts +0 -328
  95. package/dist/queryBuilder-BvoQXa_u.d.ts.map +0 -1
  96. package/dist/queryBuilder-DonAg1aq.js.map +0 -1
  97. package/dist/queryBuilder-zTsKXctT.d.cts +0 -328
  98. package/dist/queryBuilder-zTsKXctT.d.cts.map +0 -1
  99. package/src/accounts/index.ts +0 -1
  100. /package/dist/{types-H-TSmRpm.js → types-Ci4BRClw.js} +0 -0
  101. /package/dist/{types-o3zWarRp.cjs → types-a8gm_IaQ.cjs} +0 -0
@@ -1 +1,4 @@
1
- require('../types-o3zWarRp.cjs');
1
+ const require_entity = require('../entity-BhSXaB23.cjs');
2
+ require('../types-a8gm_IaQ.cjs');
3
+
4
+ exports.EntityOperationType = require_entity.EntityOperationType;
@@ -1,2 +1,2 @@
1
- import { A as RpcIncludeData, C as CreateEntityReturnType, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as CreateEntityParameters, T as ChangeOwnershipReturnType, _ as UpdateEntityReturnType, a as Entity, b as DeleteEntityParameters, c as OnEntityDeletedEvent, d as OnEntityOwnerChangedEvent, f as OnEntityUpdatedEvent, g as UpdateEntityParameters, h as MutateEntitiesReturnType, i as QueryReturnType, j as RpcOrderByAttribute, k as RpcEntity, l as OnEntityExpiredEvent, m as MutateEntitiesParameters, n as QueryOptionsIncludeData, o as TxParams, p as Attribute, r as QueryOptionsOrderBy, s as OnEntityCreatedEvent, t as QueryOptions, u as OnEntityExpiresInExtendedEvent, v as ExtendEntityParameters, w as ChangeOwnershipParameters, x as DeleteEntityReturnType, y as ExtendEntityReturnType } from "../query-CO6f35AE.cjs";
2
- 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, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
1
+ import { A as RpcEntity, C as QueryOptions, D as GetBlockTimingReturnType, E as QueryReturnType, M as RpcOrderByAttribute, N as RpcQueryOptions, P as MimeType, S as ChangeOwnershipReturnType, T as QueryOptionsOrderBy, _ as DeleteEntityParameters, a as OnEntityDeletedEvent, b as CreateEntityReturnType, c as OnEntityOwnerChangedEvent, d as MutateEntitiesParameters, f as MutateEntitiesReturnType, g as ExtendEntityReturnType, h as ExtendEntityParameters, i as OnEntityCreatedEvent, j as RpcIncludeData, k as ArkivRpcSchema, l as OnEntityUpdatedEvent, m as UpdateEntityReturnType, n as EntityOperationType, o as OnEntityExpiredEvent, p as UpdateEntityParameters, r as TxParams, s as OnEntityExpiresInExtendedEvent, t as Entity, u as Attribute, v as DeleteEntityReturnType, w as QueryOptionsIncludeData, x as ChangeOwnershipParameters, y as CreateEntityParameters } from "../entity-CN41IOrq.cjs";
2
+ export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityOperationType, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1,2 +1,2 @@
1
- import { A as RpcIncludeData, C as CreateEntityReturnType, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as CreateEntityParameters, T as ChangeOwnershipReturnType, _ as UpdateEntityReturnType, a as Entity, b as DeleteEntityParameters, c as OnEntityDeletedEvent, d as OnEntityOwnerChangedEvent, f as OnEntityUpdatedEvent, g as UpdateEntityParameters, h as MutateEntitiesReturnType, i as QueryReturnType, j as RpcOrderByAttribute, k as RpcEntity, l as OnEntityExpiredEvent, m as MutateEntitiesParameters, n as QueryOptionsIncludeData, o as TxParams, p as Attribute, r as QueryOptionsOrderBy, s as OnEntityCreatedEvent, t as QueryOptions, u as OnEntityExpiresInExtendedEvent, v as ExtendEntityParameters, w as ChangeOwnershipParameters, x as DeleteEntityReturnType, y as ExtendEntityReturnType } from "../query-BhdmAzYg.js";
2
- 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, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
1
+ import { A as RpcEntity, C as QueryOptions, D as GetBlockTimingReturnType, E as QueryReturnType, M as RpcOrderByAttribute, N as RpcQueryOptions, P as MimeType, S as ChangeOwnershipReturnType, T as QueryOptionsOrderBy, _ as DeleteEntityParameters, a as OnEntityDeletedEvent, b as CreateEntityReturnType, c as OnEntityOwnerChangedEvent, d as MutateEntitiesParameters, f as MutateEntitiesReturnType, g as ExtendEntityReturnType, h as ExtendEntityParameters, i as OnEntityCreatedEvent, j as RpcIncludeData, k as ArkivRpcSchema, l as OnEntityUpdatedEvent, m as UpdateEntityReturnType, n as EntityOperationType, o as OnEntityExpiredEvent, p as UpdateEntityParameters, r as TxParams, s as OnEntityExpiresInExtendedEvent, t as Entity, u as Attribute, v as DeleteEntityReturnType, w as QueryOptionsIncludeData, x as ChangeOwnershipParameters, y as CreateEntityParameters } from "../entity-NnEVlePN.js";
2
+ export { ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityOperationType, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType };
@@ -1 +1,4 @@
1
- import "../types-H-TSmRpm.js";
1
+ import { n as EntityOperationType } from "../entity-DGfVyB-a.js";
2
+ import "../types-Ci4BRClw.js";
3
+
4
+ export { EntityOperationType };
@@ -1,4 +1,5 @@
1
- const require_payload = require('../payload-vwU3Rc6P.cjs');
1
+ const require_consts = require('../consts-CxT1-RXU.cjs');
2
+ const require_payload = require('../payload-D8YLKcJj.cjs');
2
3
 
3
4
  //#region src/utils/expirationTime.ts
4
5
  const ExpirationTime = {
@@ -9,18 +10,11 @@ const ExpirationTime = {
9
10
  fromWeeks: (weeks) => weeks * 7 * 24 * 60 * 60,
10
11
  fromMonths: (months) => months * 30 * 24 * 60 * 60,
11
12
  fromYears: (years) => years * 365 * 24 * 60 * 60,
12
- fromBlocks: (blocks) => blocks * require_payload.BLOCK_TIME,
13
+ fromBlocks: (blocks) => blocks * require_consts.BLOCK_TIME,
13
14
  fromDate: (date) => Math.floor(date.getTime() / 1e3) - Math.floor(Date.now() / 1e3)
14
15
  };
15
16
 
16
17
  //#endregion
17
18
  exports.ExpirationTime = ExpirationTime;
18
19
  exports.jsonToPayload = require_payload.jsonToPayload;
19
- exports.stringToPayload = require_payload.stringToPayload;
20
- var viem_utils = require("viem/utils");
21
- Object.keys(viem_utils).forEach(function (k) {
22
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
- enumerable: true,
24
- get: function () { return viem_utils[k]; }
25
- });
26
- });
20
+ exports.stringToPayload = require_payload.stringToPayload;
@@ -1,5 +1,4 @@
1
1
  import { n as stringToPayload, t as jsonToPayload } from "../payload-CJN8fTvX.cjs";
2
- export * from "viem/utils";
3
2
 
4
3
  //#region src/utils/expirationTime.d.ts
5
4
  declare const ExpirationTime: {
@@ -1 +1 @@
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
+ {"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,5 +1,4 @@
1
- import { n as stringToPayload, t as jsonToPayload } from "../payload-Da9gJMG5.js";
2
- export * from "viem/utils";
1
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-C2KHOUoj.js";
3
2
 
4
3
  //#region src/utils/expirationTime.d.ts
5
4
  declare const ExpirationTime: {
@@ -1 +1 @@
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
+ {"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,6 +1,5 @@
1
- import { i as BLOCK_TIME, n as stringToPayload, t as jsonToPayload } from "../payload-DKBYYjeA.js";
2
-
3
- export * from "viem/utils"
1
+ import { n as BLOCK_TIME } from "../consts-Bz0LZQZY.js";
2
+ import { n as stringToPayload, t as jsonToPayload } from "../payload-BpNUPOnY.js";
4
3
 
5
4
  //#region src/utils/expirationTime.ts
6
5
  const ExpirationTime = {
@@ -1 +1 @@
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"}
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.6.8",
3
+ "version": "0.7.0-dev.1",
4
4
  "description": "TypeScript client library for Arkiv's blockchains interactions",
5
5
  "type": "module",
6
6
  "target": "esnext",
@@ -15,12 +15,6 @@
15
15
  "require": "./dist/index.cjs",
16
16
  "default": "./dist/index.js"
17
17
  },
18
- "./accounts": {
19
- "bun": "./src/accounts/index.ts",
20
- "import": "./dist/accounts/index.js",
21
- "require": "./dist/accounts/index.cjs",
22
- "default": "./dist/accounts/index.js"
23
- },
24
18
  "./chains": {
25
19
  "bun": "./src/chains/index.ts",
26
20
  "import": "./dist/chains/index.js",
@@ -52,9 +46,6 @@
52
46
  "chains": [
53
47
  "./dist/_types/chains/index.d.ts"
54
48
  ],
55
- "accounts": [
56
- "./dist/_types/accounts/index.d.ts"
57
- ],
58
49
  "utils": [
59
50
  "./dist/_types/utils/index.d.ts"
60
51
  ],
@@ -90,13 +81,20 @@
90
81
  "@types/bun": "latest",
91
82
  "rimraf": "^6.0.1",
92
83
  "tsdown": "^0.16.0",
93
- "typedoc": "^0.28.14"
84
+ "typedoc": "^0.28.14",
85
+ "typedoc-plugin-markdown": "^4.9.0",
86
+ "typescript": "^5.9.2",
87
+ "viem": "^2.38.2"
94
88
  },
95
89
  "peerDependencies": {
96
- "typescript": "^5.0.0"
90
+ "typescript": ">=5.0.0",
91
+ "viem": "^2.0.0"
97
92
  },
98
93
  "peerDependenciesMeta": {
99
94
  "typescript": {
95
+ "optional": true
96
+ },
97
+ "viem": {
100
98
  "optional": false
101
99
  }
102
100
  },
@@ -118,8 +116,6 @@
118
116
  },
119
117
  "homepage": "https://arkiv.network",
120
118
  "dependencies": {
121
- "brotli-wasm": "^3.0.1",
122
- "typedoc-plugin-markdown": "^4.9.0",
123
- "viem": "^2.38.2"
119
+ "brotli-wasm": "^3.0.1"
124
120
  }
125
121
  }
@@ -1,6 +1,10 @@
1
1
  import type { ArkivClient } from "../../clients/baseClient"
2
2
  import { QueryBuilder } from "../../query/queryBuilder"
3
3
 
4
+ /**
5
+ * @deprecated Use `client.select()` (see SelectQueryBuilder) instead. `buildQuery()` returns
6
+ * only the entity `key` unless data is explicitly opted in to, which is an easy mistake.
7
+ */
4
8
  export async function buildQuery(client: ArkivClient) {
5
9
  return new QueryBuilder(client)
6
10
  }
@@ -9,6 +9,11 @@ export type QueryOptionsIncludeData = {
9
9
  payload?: boolean
10
10
  metadata?: boolean
11
11
  }
12
+ /**
13
+ * @deprecated Server-side ordering is not supported by the network. Sort the fetched
14
+ * entities in JavaScript instead (e.g. `entities.sort(...)`). This type will be removed
15
+ * in a future release.
16
+ */
12
17
  export type QueryOptionsOrderBy = {
13
18
  name: string
14
19
  type: "string" | "numeric"
@@ -18,6 +23,11 @@ export type QueryOptionsOrderBy = {
18
23
  export type QueryOptions = {
19
24
  includeData?: QueryOptionsIncludeData
20
25
  atBlock?: bigint
26
+ /**
27
+ * @deprecated Server-side ordering is not supported by the network, so this option has no
28
+ * effect on the returned order. Sort the fetched entities in JavaScript instead
29
+ * (e.g. `entities.sort(...)`). This option will be removed in a future release.
30
+ */
21
31
  orderBy?: QueryOptionsOrderBy[]
22
32
  resultsPerPage?: number | undefined
23
33
  cursor?: string | undefined
@@ -1,6 +1,7 @@
1
- import { decodeEventLog, type Hex, parseAbi, toHex } from "viem"
1
+ import { decodeEventLog, type Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { PublicArkivClient } from "../../clients/createPublicClient"
4
+ import { EntityOperationType } from "../../types/entity"
4
5
  import type {
5
6
  OnEntityCreatedEvent,
6
7
  OnEntityDeletedEvent,
@@ -9,18 +10,12 @@ import type {
9
10
  OnEntityOwnerChangedEvent,
10
11
  OnEntityUpdatedEvent,
11
12
  } from "../../types/events"
13
+ import { ENTITY_OPERATION_EVENT_ABI } from "../../utils/arkivTransactions"
12
14
  import { getLogger } from "../../utils/logger"
13
15
 
14
16
  const logger = getLogger("actions:public:subscribe-entity-events")
15
17
 
16
- export const arkivABI = parseAbi([
17
- "event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
18
- "event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
19
- "event ArkivEntityExpired(uint256 indexed entityKey, address indexed ownerAddress)",
20
- "event ArkivEntityDeleted(uint256 indexed entityKey, address indexed ownerAddress)",
21
- "event ArkivEntityBTLExtended(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
22
- "event ArkivEntityOwnerChanged(uint256 indexed entityKey, address indexed oldOwnerAddress, address indexed newOwnerAddress)",
23
- ])
18
+ export const arkivABI = ENTITY_OPERATION_EVENT_ABI
24
19
 
25
20
  export async function subscribeEntityEvents(
26
21
  client: ArkivClient,
@@ -57,54 +52,33 @@ export async function subscribeEntityEvents(
57
52
  data: log.data,
58
53
  })
59
54
  logger("event from subscribeEntityEvents %o", event)
60
- switch (event.eventName) {
61
- case "ArkivEntityCreated":
62
- onEntityCreated?.({
63
- entityKey: toHex(event.args.entityKey, { size: 32 }),
64
- owner: event.args.ownerAddress,
65
- expirationBlock: Number(event.args.expirationBlock),
66
- cost: event.args.cost,
67
- })
68
- break
69
- case "ArkivEntityUpdated":
70
- onEntityUpdated?.({
71
- entityKey: toHex(event.args.entityKey, { size: 32 }),
72
- owner: event.args.ownerAddress,
73
- oldExpirationBlock: Number(event.args.oldExpirationBlock),
74
- newExpirationBlock: Number(event.args.newExpirationBlock),
75
- cost: event.args.cost,
76
- })
55
+
56
+ if (event.eventName !== "EntityOperation") continue
57
+
58
+ const entityKey = event.args.entityKey as Hex
59
+ const owner = event.args.owner
60
+ const expiresAt = event.args.expiresAt
61
+ const entityHash = event.args.entityHash as Hex
62
+ const opType = Number(event.args.operationType)
63
+
64
+ switch (opType) {
65
+ case EntityOperationType.Create:
66
+ onEntityCreated?.({ entityKey, owner, expiresAt, entityHash })
77
67
  break
78
- case "ArkivEntityDeleted":
79
- onEntityDeleted?.({
80
- entityKey: toHex(event.args.entityKey, { size: 32 }),
81
- owner: event.args.ownerAddress,
82
- })
68
+ case EntityOperationType.Update:
69
+ onEntityUpdated?.({ entityKey, owner, expiresAt, entityHash })
83
70
  break
84
- case "ArkivEntityBTLExtended":
85
- onEntityExpiresInExtended?.({
86
- entityKey: toHex(event.args.entityKey, { size: 32 }),
87
- owner: event.args.ownerAddress,
88
- oldExpirationBlock: Number(event.args.oldExpirationBlock),
89
- newExpirationBlock: Number(event.args.newExpirationBlock),
90
- cost: event.args.cost,
91
- })
71
+ case EntityOperationType.Extend:
72
+ onEntityExpiresInExtended?.({ entityKey, owner, expiresAt, entityHash })
92
73
  break
93
- case "ArkivEntityExpired":
94
- onEntityExpired?.({
95
- entityKey: toHex(event.args.entityKey, { size: 32 }),
96
- owner: event.args.ownerAddress,
97
- })
74
+ case EntityOperationType.Transfer:
75
+ onEntityOwnerChanged?.({ entityKey, owner, entityHash })
98
76
  break
99
- case "ArkivEntityOwnerChanged":
100
- onEntityOwnerChanged?.({
101
- entityKey: toHex(event.args.entityKey, { size: 32 }),
102
- oldOwner: event.args.oldOwnerAddress,
103
- newOwner: event.args.newOwnerAddress,
104
- })
77
+ case EntityOperationType.Delete:
78
+ onEntityDeleted?.({ entityKey, owner })
105
79
  break
106
80
  default:
107
- console.warn("unknown event from subscribeEntityEvents", event)
81
+ onEntityExpired?.({ entityKey, owner })
108
82
  break
109
83
  }
110
84
  }
@@ -1,14 +1,15 @@
1
1
  import type { Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
 
7
7
  const logger = getLogger("actions:wallet:change-ownership")
8
8
 
9
9
  /**
10
- * Parameters for the deleteEntity function.
11
- * - entityKey: The key of the entity to delete.
10
+ * Parameters for the changeOwnership function.
11
+ * - entityKey: The key of the entity.
12
+ * - newOwner: The address of the new owner.
12
13
  */
13
14
  export type ChangeOwnershipParameters = {
14
15
  entityKey: Hex
@@ -16,7 +17,7 @@ export type ChangeOwnershipParameters = {
16
17
  }
17
18
 
18
19
  /**
19
- * Return type for the deleteEntity function.
20
+ * Return type for the changeOwnership function.
20
21
  * - entityKey: The key of the entity.
21
22
  * - txHash: The transaction hash.
22
23
  */
@@ -31,8 +32,7 @@ export async function changeOwnership(
31
32
  txParams?: TxParams,
32
33
  ): Promise<ChangeOwnershipReturnType> {
33
34
  logger("changeOwnership %o", data)
34
- const txData = opsToTxData({ ownershipChanges: [data] })
35
- const receipt = await sendArkivTransaction(client, txData, txParams)
35
+ const { receipt } = await sendArkivTransaction(client, { ownershipChanges: [data] }, txParams)
36
36
 
37
37
  logger("Receipt from changeOwnership %o", receipt)
38
38
 
@@ -1,7 +1,7 @@
1
1
  import type { Hash, Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { Attribute, MimeType, TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
 
7
7
  const logger = getLogger("actions:wallet:create-entity")
@@ -9,14 +9,24 @@ const logger = getLogger("actions:wallet:create-entity")
9
9
  /**
10
10
  * Parameters for the createEntity function.
11
11
  * - payload: The payload of the entity.
12
- * - attributes: The attributes of the entity.
12
+ * - attributes: The attributes of the entity. Attribute values may be strings
13
+ * or numbers, but numeric values **must be integers**. To store a non-integer,
14
+ * scale it to an integer (e.g. `1.5` -> `1500`) to preserve numeric ordering,
15
+ * or pass it as a string (e.g. `"1.5"`). A non-integer numeric value throws an
16
+ * {@link InvalidAttributeError}.
13
17
  * - contentType: The content type of the entity.
14
- * - expiresIn: The expires in of the entity in seconds.
18
+ * - expiresIn: How long until the entity expires, in seconds. Because Arkiv
19
+ * measures expiration in blocks (1 block = 2 seconds), this **must be a
20
+ * positive integer and a multiple of the block time (2 seconds)**
21
+ * Invalid values throw an {@link InvalidExpirationError}.
15
22
  */
16
23
  export type CreateEntityParameters = {
17
24
  payload: Uint8Array
25
+ /** Entity attributes. Numeric values must be integers (scale non-integers, e.g. `1.5` -> `1500`, or use a string). Throws {@link InvalidAttributeError} otherwise. */
18
26
  attributes: Attribute[]
19
27
  contentType: MimeType | string
28
+ /** Seconds until expiry. Must be a positive integer and a multiple of the 2s block time.
29
+ * Throws {@link InvalidExpirationError} otherwise. */
20
30
  expiresIn: number
21
31
  }
22
32
 
@@ -36,13 +46,16 @@ export async function createEntity(
36
46
  txParams?: TxParams,
37
47
  ): Promise<CreateEntityReturnType> {
38
48
  logger("createEntity %o", data)
39
- const txData = opsToTxData({ creates: [data] })
40
- const receipt = await sendArkivTransaction(client, txData, txParams)
49
+ const { receipt, createdEntityKeys } = await sendArkivTransaction(
50
+ client,
51
+ { creates: [data] },
52
+ txParams,
53
+ )
41
54
 
42
55
  logger("Receipt from createEntity %o", receipt)
43
56
 
44
57
  return {
45
58
  txHash: receipt.transactionHash as Hash,
46
- entityKey: receipt.logs[0].topics[1] as Hex,
59
+ entityKey: createdEntityKeys[0],
47
60
  }
48
61
  }
@@ -1,7 +1,7 @@
1
1
  import type { Hash, Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
 
7
7
  const logger = getLogger("actions:wallet:delete-entity")
@@ -30,8 +30,7 @@ export async function deleteEntity(
30
30
  txParams?: TxParams,
31
31
  ): Promise<DeleteEntityReturnType> {
32
32
  logger("deleteEntity %o", data)
33
- const txData = opsToTxData({ deletes: [data] })
34
- const receipt = await sendArkivTransaction(client, txData, txParams)
33
+ const { receipt } = await sendArkivTransaction(client, { deletes: [data] }, txParams)
35
34
 
36
35
  logger("Receipt from deleteEntity %o", receipt)
37
36
 
@@ -1,7 +1,7 @@
1
1
  import type { Hash, Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
 
7
7
  const logger = getLogger("actions:wallet:extend-entity")
@@ -9,10 +9,15 @@ const logger = getLogger("actions:wallet:extend-entity")
9
9
  /**
10
10
  * Parameters for the extendEntity function.
11
11
  * - entityKey: The key of the entity to extend.
12
- * - expiresIn: The expires in of the entity in seconds.
12
+ * - expiresIn: How long to extend the entity by, in seconds. Because Arkiv
13
+ * measures expiration in blocks (1 block = 2 seconds), this **must be a
14
+ * positive integer and a multiple of the block time (2 seconds)**.
15
+ * Invalid values throw an {@link InvalidExpirationError}.
13
16
  */
14
17
  export type ExtendEntityParameters = {
15
18
  entityKey: Hex
19
+ /** Seconds to extend by. Must be a positive integer and a multiple of the 2s block time.
20
+ * Throws {@link InvalidExpirationError} otherwise. */
16
21
  expiresIn: number
17
22
  }
18
23
 
@@ -32,13 +37,12 @@ export async function extendEntity(
32
37
  txParams?: TxParams,
33
38
  ): Promise<ExtendEntityReturnType> {
34
39
  logger("extendEntity %o", data)
35
- const txData = opsToTxData({ extensions: [data] })
36
- const receipt = await sendArkivTransaction(client, txData, txParams)
40
+ const { receipt } = await sendArkivTransaction(client, { extensions: [data] }, txParams)
37
41
 
38
42
  logger("Receipt from extendEntity %o", receipt)
39
43
 
40
44
  return {
41
45
  txHash: receipt.transactionHash as Hash,
42
- entityKey: receipt.logs[0].topics[1] as Hex,
46
+ entityKey: data.entityKey,
43
47
  }
44
48
  }
@@ -1,17 +1,16 @@
1
- import type { Hash, Hex, TransactionReceipt } from "viem"
1
+ import type { Hash, Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
  import type { ChangeOwnershipParameters } from "./changeOwnership"
7
-
8
- const logger = getLogger("actions:wallet:mutate-entities")
9
-
10
7
  import type { CreateEntityParameters } from "./createEntity"
11
8
  import type { DeleteEntityParameters } from "./deleteEntity"
12
9
  import type { ExtendEntityParameters } from "./extendEntity"
13
10
  import type { UpdateEntityParameters } from "./updateEntity"
14
11
 
12
+ const logger = getLogger("actions:wallet:mutate-entities")
13
+
15
14
  /**
16
15
  * Parameters for the mutateEntities function.
17
16
  * - creates: The creates to perform.
@@ -27,39 +26,6 @@ export type MutateEntitiesParameters = {
27
26
  ownershipChanges?: ChangeOwnershipParameters[]
28
27
  }
29
28
 
30
- function parseReceipt(receipt: TransactionReceipt, params: MutateEntitiesParameters) {
31
- const createdEntities: Hex[] = []
32
- const updatedEntities: Hex[] = []
33
- const deletedEntities: Hex[] = []
34
- const extendedEntities: Hex[] = []
35
- const ownershipChanges: Hex[] = []
36
-
37
- const totalCreates = params.creates?.length ?? 0
38
- const totalUpdates = params.updates?.length ?? 0
39
- const totalDeletes = params.deletes?.length ?? 0
40
- const totalExtensions = params.extensions?.length ?? 0
41
-
42
- // iterate over all logs and parse the event
43
- // logs go in the following order: creates, deleted, updates, extends, ownership changes
44
- for (let index = 0; index < receipt.logs.length; index++) {
45
- const log = receipt.logs[index]
46
-
47
- if (index < totalCreates) {
48
- createdEntities.push(log.topics[1] as Hex)
49
- } else if (index < totalCreates + totalDeletes) {
50
- deletedEntities.push(log.topics[1] as Hex)
51
- } else if (index < totalCreates + totalUpdates + totalDeletes) {
52
- updatedEntities.push(log.topics[1] as Hex)
53
- } else if (index < totalCreates + totalUpdates + totalDeletes + totalExtensions) {
54
- extendedEntities.push(log.topics[1] as Hex)
55
- } else {
56
- ownershipChanges.push(log.topics[1] as Hex)
57
- }
58
- }
59
-
60
- return { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges }
61
- }
62
-
63
29
  /**
64
30
  * Return type for the mutateEntities function.
65
31
  * - txHash: The transaction hash.
@@ -77,6 +43,7 @@ export type MutateEntitiesReturnType = {
77
43
  extendedEntities: Hex[]
78
44
  ownershipChanges: Hex[]
79
45
  }
46
+
80
47
  export async function mutateEntities(
81
48
  client: ArkivClient,
82
49
  data: MutateEntitiesParameters,
@@ -86,26 +53,16 @@ export async function mutateEntities(
86
53
  throw new Error("No operations to perform")
87
54
  }
88
55
 
89
- const txData = opsToTxData({
90
- creates: data.creates ?? [],
91
- updates: data.updates ?? [],
92
- deletes: data.deletes ?? [],
93
- extensions: data.extensions ?? [],
94
- ownershipChanges: data.ownershipChanges ?? [],
95
- })
96
-
97
- const receipt = await sendArkivTransaction(client, txData, txParams)
56
+ const { receipt, createdEntityKeys } = await sendArkivTransaction(client, data, txParams)
98
57
 
99
58
  logger("Receipt from mutateEntities %o", receipt)
100
59
 
101
- const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } =
102
- parseReceipt(receipt, data)
103
60
  return {
104
61
  txHash: receipt.transactionHash as Hash,
105
- createdEntities,
106
- updatedEntities,
107
- deletedEntities,
108
- extendedEntities,
109
- ownershipChanges,
62
+ createdEntities: createdEntityKeys,
63
+ updatedEntities: (data.updates ?? []).map((u) => u.entityKey),
64
+ deletedEntities: (data.deletes ?? []).map((d) => d.entityKey),
65
+ extendedEntities: (data.extensions ?? []).map((e) => e.entityKey),
66
+ ownershipChanges: (data.ownershipChanges ?? []).map((o) => o.entityKey),
110
67
  }
111
68
  }
@@ -1,7 +1,7 @@
1
1
  import type { Hash, Hex } from "viem"
2
2
  import type { ArkivClient } from "../../clients/baseClient"
3
3
  import type { Attribute, MimeType, TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
4
+ import { sendArkivTransaction } from "../../utils/arkivTransactions"
5
5
  import { getLogger } from "../../utils/logger"
6
6
 
7
7
  const logger = getLogger("actions:wallet:update-entity")
@@ -10,15 +10,25 @@ const logger = getLogger("actions:wallet:update-entity")
10
10
  * Parameters for the updateEntity function.
11
11
  * - entityKey: The key of the entity to update.
12
12
  * - payload: The payload of the entity.
13
- * - attributes: The attributes of the entity.
13
+ * - attributes: The attributes of the entity. Attribute values may be strings
14
+ * or numbers, but numeric values **must be integers**. To store a non-integer,
15
+ * scale it to an integer (e.g. `1.5` -> `1500`) to preserve numeric ordering,
16
+ * or pass it as a string (e.g. `"1.5"`). A non-integer numeric value throws an
17
+ * {@link InvalidAttributeError}.
14
18
  * - contentType: The content type of the entity.
15
- * - expiresIn: The expires in of the entity in seconds.
19
+ * - expiresIn: How long until the entity expires, in seconds. Because Arkiv
20
+ * measures expiration in blocks (1 block = 2 seconds), this **must be a
21
+ * positive integer and a multiple of the block time (2 seconds)**.
22
+ * Invalid values throw an {@link InvalidExpirationError}.
16
23
  */
17
24
  export type UpdateEntityParameters = {
18
25
  entityKey: Hex
19
26
  payload: Uint8Array
27
+ /** Entity attributes. Numeric values must be integers (scale non-integers, e.g. `1.5` -> `1500`, or use a string). Throws {@link InvalidAttributeError} otherwise. */
20
28
  attributes: Attribute[]
21
29
  contentType: MimeType | string
30
+ /** Seconds until expiry. Must be a positive integer and a multiple of the 2s block time.
31
+ * Throws {@link InvalidExpirationError} otherwise. */
22
32
  expiresIn: number
23
33
  }
24
34
 
@@ -38,13 +48,12 @@ export async function updateEntity(
38
48
  txParams?: TxParams,
39
49
  ): Promise<UpdateEntityReturnType> {
40
50
  logger("updateEntity %o", data)
41
- const txData = opsToTxData({ updates: [data] })
42
- const receipt = await sendArkivTransaction(client, txData, txParams)
51
+ const { receipt } = await sendArkivTransaction(client, { updates: [data] }, txParams)
43
52
 
44
53
  logger("Receipt from updateEntity %o", receipt)
45
54
 
46
55
  return {
47
56
  txHash: receipt.transactionHash as Hash,
48
- entityKey: receipt.logs[0].topics[1] as Hex,
57
+ entityKey: data.entityKey,
49
58
  }
50
59
  }
@@ -20,6 +20,8 @@ test("creates", () => {
20
20
  expect(typeof client.getEntity).toBe("function")
21
21
  expect(client.buildQuery).toBeDefined()
22
22
  expect(typeof client.buildQuery).toBe("function")
23
+ expect(client.select).toBeDefined()
24
+ expect(typeof client.select).toBe("function")
23
25
  expect(client.query).toBeDefined()
24
26
  expect(typeof client.query).toBe("function")
25
27
  expect(client.getEntityCount).toBeDefined()