@arkiv-network/sdk 0.1.1-dev.0 → 0.1.2-dev.0

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 (63) hide show
  1. package/README.md +22 -10
  2. package/dist/chains/index.cjs +1 -0
  3. package/dist/chains/index.d.ts +25 -25
  4. package/dist/chains/index.d.ts.map +1 -1
  5. package/dist/index.cjs +40 -10
  6. package/dist/index.js +13 -8
  7. package/dist/index.js.map +1 -1
  8. package/dist/query/index.cjs +1 -1
  9. package/dist/{queryBuilder-n9ocnT4P.cjs → queryBuilder-okYHE7jd.cjs} +1 -0
  10. package/dist/utils/index.cjs +1 -0
  11. package/dist/utils/index.d.cts.map +1 -1
  12. package/dist/utils/index.d.ts.map +1 -1
  13. package/package.json +22 -8
  14. package/src/accounts/index.ts +1 -0
  15. package/src/actions/public/buildQuery.ts +6 -0
  16. package/src/actions/public/getBlockTiming.ts +20 -0
  17. package/src/actions/public/getEntity.ts +18 -0
  18. package/src/actions/public/getEntityCount.ts +10 -0
  19. package/src/actions/public/query.ts +13 -0
  20. package/src/actions/public/subscribeEntityEvents.ts +105 -0
  21. package/src/actions/wallet/changeOwnership.ts +40 -0
  22. package/src/actions/wallet/createEntity.ts +45 -0
  23. package/src/actions/wallet/deleteEntity.ts +39 -0
  24. package/src/actions/wallet/extendEntity.ts +41 -0
  25. package/src/actions/wallet/mutateEntities.ts +100 -0
  26. package/src/actions/wallet/updateEntity.ts +47 -0
  27. package/src/chains/index.ts +3 -0
  28. package/src/chains/kaolin.ts +26 -0
  29. package/src/chains/localhost.ts +14 -0
  30. package/src/chains/marketplace.ts +26 -0
  31. package/src/clients/baseClient.ts +9 -0
  32. package/src/clients/createPublicClient.test.ts +22 -0
  33. package/src/clients/createPublicClient.ts +65 -0
  34. package/src/clients/createWalletClient.test.ts +23 -0
  35. package/src/clients/createWalletClient.ts +70 -0
  36. package/src/clients/decorators/arkivPublic.ts +203 -0
  37. package/src/clients/decorators/arkivWallet.ts +250 -0
  38. package/src/consts.ts +2 -0
  39. package/src/index.ts +21 -0
  40. package/src/query/engine.test.ts +288 -0
  41. package/src/query/engine.ts +112 -0
  42. package/src/query/errors.ts +23 -0
  43. package/src/query/index.ts +4 -0
  44. package/src/query/predicate.test.ts +418 -0
  45. package/src/query/predicate.ts +140 -0
  46. package/src/query/queryBuilder.test.ts +537 -0
  47. package/src/query/queryBuilder.ts +209 -0
  48. package/src/query/queryResult.test.ts +270 -0
  49. package/src/query/queryResult.ts +61 -0
  50. package/src/types/attributes.ts +4 -0
  51. package/src/types/entity.ts +36 -0
  52. package/src/types/events.ts +34 -0
  53. package/src/types/index.ts +4 -0
  54. package/src/types/mimeTypes.ts +27 -0
  55. package/src/types/rpcSchema.ts +61 -0
  56. package/src/types/txParams.ts +15 -0
  57. package/src/utils/arkivTransactions.ts +100 -0
  58. package/src/utils/compression.test.ts +32 -0
  59. package/src/utils/compression.ts +48 -0
  60. package/src/utils/entities.ts +23 -0
  61. package/src/utils/expirationTime.ts +13 -0
  62. package/src/utils/index.ts +3 -0
  63. package/src/utils/payload.ts +9 -0
package/README.md CHANGED
@@ -23,7 +23,7 @@ import { eq } from '@arkiv-network/sdk/query';
23
23
 
24
24
  // Create a public client
25
25
  const client = createPublicClient({
26
- chain: kaolin,
26
+ chain: kaolin, // Kaolin is the name of Arkiv official testnet
27
27
  transport: http(),
28
28
  });
29
29
 
@@ -72,12 +72,12 @@ const client = createWalletClient({
72
72
 
73
73
  // Create an entity
74
74
  const { entityKey, txHash } = await client.createEntity({
75
- payload: toBytes(JSON.stringify({
75
+ payload: jsonToPayload{
76
76
  entity: {
77
77
  entityType: 'document',
78
78
  entityId: 'doc-123',
79
79
  },
80
- })),
80
+ },
81
81
  contentType: 'application/json',
82
82
  attributes: [
83
83
  { key: 'category', value: 'documentation' },
@@ -98,15 +98,14 @@ console.log('Entity:', entity);
98
98
 
99
99
  This package supports multiple module formats for maximum compatibility:
100
100
 
101
- - **CommonJS** (`dist/_cjs/`) - For Node.js `require()`
102
- - **ES Modules** (`dist/_esm/`) - For modern `import` statements
103
- - **TypeScript Source** (`src/`) - For Bun/Deno TypeScript-native runtimes
104
- - **Type Declarations** (`dist/_types/`) - Full TypeScript support
101
+ - **ES Modules** (`dist/*.js`) - For modern `import` statements
102
+ - **CommonJS** (`dist/*.cjs`) - For Node.js `require()`
103
+ - **Type Declarations** (`dist/*.d.ts` and `dist/*.d.cts`) - Full TypeScript support
104
+
105
+ The build uses [tsdown](https://github.com/unjs/tsdown) to generate both ESM and CommonJS formats with proper type declarations.
105
106
 
106
107
  ### Runtime Support
107
108
 
108
- **Bun/Deno (TypeScript native):**
109
- - Runs TypeScript directly from source - no transpilation needed
110
109
 
111
110
  **Node.js (ESM):**
112
111
  ```javascript
@@ -118,6 +117,11 @@ import { createPublicClient } from '@arkiv-network/sdk'; // Uses compiled ESM
118
117
  const { createPublicClient } = require('@arkiv-network/sdk'); // Uses compiled CJS
119
118
  ```
120
119
 
120
+ **Bun (TypeScript native):**
121
+ ```javascript
122
+ import { createPublicClient } from '@arkiv-network/sdk'; // Uses *.ts directly
123
+ ```
124
+
121
125
  All formats provide full type safety and IntelliSense support when using TypeScript.
122
126
 
123
127
  ## Development
@@ -128,12 +132,16 @@ To install dependencies:
128
132
  bun install
129
133
  ```
130
134
 
131
- To build type declarations:
135
+ To build all outputs (ESM, CommonJS, and type declarations):
132
136
 
133
137
  ```bash
134
138
  bun run build
135
139
  ```
136
140
 
141
+ For more information about building this SDK refer to:
142
+ [BUILD.md](./BUILD.md)
143
+
144
+
137
145
  To run type checking:
138
146
 
139
147
  ```bash
@@ -145,3 +153,7 @@ To lint:
145
153
  ```bash
146
154
  bun run lint
147
155
  ```
156
+
157
+ For more information about refer to:
158
+ [CONTRIBUTING.md](./CONTRIBUTING.md)
159
+
@@ -1,3 +1,4 @@
1
+ const require_index = require('../index.cjs');
1
2
  let viem = require("viem");
2
3
 
3
4
  //#region src/chains/kaolin.ts
@@ -1,4 +1,4 @@
1
- import * as viem17 from "viem";
1
+ import * as viem8 from "viem";
2
2
 
3
3
  //#region src/chains/kaolin.d.ts
4
4
  declare const kaolin: {
@@ -11,13 +11,13 @@ declare const kaolin: {
11
11
  };
12
12
  blockTime?: number | undefined | undefined;
13
13
  contracts?: {
14
- [x: string]: viem17.ChainContract | {
15
- [sourceId: number]: viem17.ChainContract | undefined;
14
+ [x: string]: viem8.ChainContract | {
15
+ [sourceId: number]: viem8.ChainContract | undefined;
16
16
  } | undefined;
17
- ensRegistry?: viem17.ChainContract | undefined;
18
- ensUniversalResolver?: viem17.ChainContract | undefined;
19
- multicall3?: viem17.ChainContract | undefined;
20
- erc6492Verifier?: viem17.ChainContract | undefined;
17
+ ensRegistry?: viem8.ChainContract | undefined;
18
+ ensUniversalResolver?: viem8.ChainContract | undefined;
19
+ multicall3?: viem8.ChainContract | undefined;
20
+ erc6492Verifier?: viem8.ChainContract | undefined;
21
21
  } | undefined;
22
22
  ensTlds?: readonly string[] | undefined;
23
23
  id: 60138453025;
@@ -37,9 +37,9 @@ declare const kaolin: {
37
37
  sourceId?: number | undefined | undefined;
38
38
  testnet: true;
39
39
  custom?: Record<string, unknown> | undefined;
40
- fees?: viem17.ChainFees<undefined> | undefined;
40
+ fees?: viem8.ChainFees<undefined> | undefined;
41
41
  formatters?: undefined;
42
- serializers?: viem17.ChainSerializers<undefined, viem17.TransactionSerializable> | undefined;
42
+ serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
43
43
  readonly network: "kaolin";
44
44
  };
45
45
  //#endregion
@@ -59,13 +59,13 @@ declare const localhost: {
59
59
  } | undefined | undefined;
60
60
  blockTime?: number | undefined | undefined;
61
61
  contracts?: {
62
- [x: string]: viem17.ChainContract | {
63
- [sourceId: number]: viem17.ChainContract | undefined;
62
+ [x: string]: viem8.ChainContract | {
63
+ [sourceId: number]: viem8.ChainContract | undefined;
64
64
  } | undefined;
65
- ensRegistry?: viem17.ChainContract | undefined;
66
- ensUniversalResolver?: viem17.ChainContract | undefined;
67
- multicall3?: viem17.ChainContract | undefined;
68
- erc6492Verifier?: viem17.ChainContract | undefined;
65
+ ensRegistry?: viem8.ChainContract | undefined;
66
+ ensUniversalResolver?: viem8.ChainContract | undefined;
67
+ multicall3?: viem8.ChainContract | undefined;
68
+ erc6492Verifier?: viem8.ChainContract | undefined;
69
69
  } | undefined;
70
70
  ensTlds?: readonly string[] | undefined;
71
71
  id: 1337;
@@ -84,9 +84,9 @@ declare const localhost: {
84
84
  sourceId?: number | undefined | undefined;
85
85
  testnet?: boolean | undefined | undefined;
86
86
  custom?: Record<string, unknown> | undefined;
87
- fees?: viem17.ChainFees<undefined> | undefined;
87
+ fees?: viem8.ChainFees<undefined> | undefined;
88
88
  formatters?: undefined;
89
- serializers?: viem17.ChainSerializers<undefined, viem17.TransactionSerializable> | undefined;
89
+ serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
90
90
  };
91
91
  //#endregion
92
92
  //#region src/chains/marketplace.d.ts
@@ -100,13 +100,13 @@ declare const marketplace: {
100
100
  };
101
101
  blockTime?: number | undefined | undefined;
102
102
  contracts?: {
103
- [x: string]: viem17.ChainContract | {
104
- [sourceId: number]: viem17.ChainContract | undefined;
103
+ [x: string]: viem8.ChainContract | {
104
+ [sourceId: number]: viem8.ChainContract | undefined;
105
105
  } | undefined;
106
- ensRegistry?: viem17.ChainContract | undefined;
107
- ensUniversalResolver?: viem17.ChainContract | undefined;
108
- multicall3?: viem17.ChainContract | undefined;
109
- erc6492Verifier?: viem17.ChainContract | undefined;
106
+ ensRegistry?: viem8.ChainContract | undefined;
107
+ ensUniversalResolver?: viem8.ChainContract | undefined;
108
+ multicall3?: viem8.ChainContract | undefined;
109
+ erc6492Verifier?: viem8.ChainContract | undefined;
110
110
  } | undefined;
111
111
  ensTlds?: readonly string[] | undefined;
112
112
  id: 60138453027;
@@ -126,9 +126,9 @@ declare const marketplace: {
126
126
  sourceId?: number | undefined | undefined;
127
127
  testnet: true;
128
128
  custom?: Record<string, unknown> | undefined;
129
- fees?: viem17.ChainFees<undefined> | undefined;
129
+ fees?: viem8.ChainFees<undefined> | undefined;
130
130
  formatters?: undefined;
131
- serializers?: viem17.ChainSerializers<undefined, viem17.TransactionSerializable> | undefined;
131
+ serializers?: viem8.ChainSerializers<undefined, viem8.TransactionSerializable> | undefined;
132
132
  readonly network: "marketplace";
133
133
  };
134
134
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;MAAA,SAuBX,IAAA,EAAA,uBAAA;MAAA,SAAA,GAAA,EAAA,6CAAA;;;;;;iBAAA,MAAA,CAAA,aAAA;;;;;;;;ECvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cDvBW;;;MDAA,IAuBX,EAAA,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCZA,MAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,yBAAA,SAAA;IAAA,oBAAA,CAAA,yBAAA,SAAA;;;;;;;;;;;;;;ICXW,SAAA,OAuBX,EAAA;MAAA,SAAA,IAAA,EAAA,SAAA,CAAA,uBAAA,CAAA;;;;;;;;;;;;cAvBW;;;MFAA,SAuBX,IAAA,EAAA,4BAAA;MAAA,SAAA,GAAA,EAAA,kDAAA;;;;;;iBEAA,MAAA,CAAA,aAAA;;;;;;;;EDvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/chains/kaolin.ts","../../src/chains/localhost.ts","../../src/chains/marketplace.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;MAAA,SAuBX,IAAA,EAAA,uBAAA;MAAA,SAAA,GAAA,EAAA,6CAAA;;;;;;iBAAA,KAAA,CAAA,aAAA;;;;;;;;ECvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA;;;;;;;;;cDvBW;;;MDAA,IAuBX,EAAA,MAAA;MAAA,GAAA,EAAA,MAAA;;;;;;;;;;;iBCZA,KAAA,CAAA,aAAA;;;IAXW,WAWX,CAAA,wBAAA,SAAA;IAAA,oBAAA,CAAA,wBAAA,SAAA;;;;;;;;;;;;;;ICXW,SAAA,OAuBX,EAAA;MAAA,SAAA,IAAA,EAAA,SAAA,CAAA,uBAAA,CAAA;;;;;;;;;;;;cAvBW;;;MFAA,SAuBX,IAAA,EAAA,4BAAA;MAAA,SAAA,GAAA,EAAA,kDAAA;;;;;;iBEAA,KAAA,CAAA,aAAA;;;;;;;;EDvBW,OAAA,CAAA,EAAA,SAWX,MAAA,EAAA,GAAA,SAAA;EAAA,EAAA,EAAA,WAAA;;;;;;;;;;;;;;ECXW,QAAA,CAAA,EAAA,MAuBX,GAAA,SAAA,GAAA,SAAA;EAAA,OAAA,EAAA,IAAA"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,31 @@
1
- const require_queryBuilder = require('./queryBuilder-n9ocnT4P.cjs');
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) => {
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 = __getOwnPropDesc(from, key)) || desc.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
24
+ const require_queryBuilder = require('./queryBuilder-okYHE7jd.cjs');
2
25
  const require_consts = require('./consts-BV9DVKgE.cjs');
3
26
  let viem = require("viem");
27
+ let brotli_wasm = require("brotli-wasm");
28
+ brotli_wasm = __toESM(brotli_wasm);
4
29
 
5
30
  //#region src/actions/public/getBlockTiming.ts
6
31
  async function getBlockTiming(client) {
@@ -175,18 +200,22 @@ function createPublicClient(parameters) {
175
200
  //#endregion
176
201
  //#region src/utils/compression.ts
177
202
  let brotli = null;
178
- let brotliPromise = null;
179
203
  async function getBrotli() {
180
204
  if (brotli) return brotli;
181
- if (!brotliPromise) try {
182
- const module$1 = await import("brotli-wasm");
183
- brotliPromise = Promise.resolve(module$1.default);
184
- brotli = await brotliPromise;
185
- } catch (error) {
186
- console.error("Error importing brotli-wasm", error);
187
- brotli = require("brotli-wasm");
205
+ if (!brotli_wasm.default) {
206
+ console.debug("Importing brotli-wasm");
207
+ try {
208
+ console.debug("Importing brotli-wasm as module");
209
+ brotli = await brotli_wasm.default;
210
+ console.debug("Imported brotli-wasm as module", brotli);
211
+ } catch (error) {
212
+ console.error("Error importing brotli-wasm", error);
213
+ console.debug("Importing brotli-wasm as require");
214
+ brotli = require("brotli-wasm");
215
+ console.debug("Imported brotli-wasm as require", brotli);
216
+ }
188
217
  }
189
- brotli = await brotliPromise;
218
+ brotli = await brotli_wasm.default;
190
219
  return brotli;
191
220
  }
192
221
  async function compress(data) {
@@ -404,6 +433,7 @@ function createWalletClient(parameters) {
404
433
  }
405
434
 
406
435
  //#endregion
436
+ exports.__toESM = __toESM;
407
437
  exports.createPublicClient = createPublicClient;
408
438
  exports.createWalletClient = createWalletClient;
409
439
  Object.defineProperty(exports, 'http', {
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { a as NoEntityFoundError, r as entityFromRpcResult, t as QueryBuilder } from "./queryBuilder-BueP5de6.js";
2
2
  import { n as BLOCK_TIME, t as ARKIV_ADDRESS } from "./consts-CHtLBwGd.js";
3
3
  import { createClient, decodeEventLog, http, parseAbi, publicActions, toBytes, toBytes as toBytes$1, toHex, toHex as toHex$1, toRlp, toRlp as toRlp$1, walletActions, webSocket } from "viem";
4
+ import brotliPromise from "brotli-wasm";
4
5
 
5
6
  //#region rolldown:runtime
6
7
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
@@ -182,16 +183,20 @@ function createPublicClient(parameters) {
182
183
  //#endregion
183
184
  //#region src/utils/compression.ts
184
185
  let brotli = null;
185
- let brotliPromise = null;
186
186
  async function getBrotli() {
187
187
  if (brotli) return brotli;
188
- if (!brotliPromise) try {
189
- const module = await import("brotli-wasm");
190
- brotliPromise = Promise.resolve(module.default);
191
- brotli = await brotliPromise;
192
- } catch (error) {
193
- console.error("Error importing brotli-wasm", error);
194
- brotli = __require("brotli-wasm");
188
+ if (!brotliPromise) {
189
+ console.debug("Importing brotli-wasm");
190
+ try {
191
+ console.debug("Importing brotli-wasm as module");
192
+ brotli = await brotliPromise;
193
+ console.debug("Imported brotli-wasm as module", brotli);
194
+ } catch (error) {
195
+ console.error("Error importing brotli-wasm", error);
196
+ console.debug("Importing brotli-wasm as require");
197
+ brotli = __require("brotli-wasm");
198
+ console.debug("Imported brotli-wasm as require", brotli);
199
+ }
195
200
  }
196
201
  brotli = await brotliPromise;
197
202
  return brotli;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["query","toHex","brotli: BrotliWasmType | null","brotliPromise: Promise<BrotliWasmType> | null","toHex","toRlp","toBytes","createdEntities: Hex[]","updatedEntities: Hex[]","deletedEntities: Hex[]","extendedEntities: Hex[]"],"sources":["../src/actions/public/getBlockTiming.ts","../src/actions/public/getEntity.ts","../src/actions/public/getEntityCount.ts","../src/actions/public/query.ts","../src/actions/public/subscribeEntityEvents.ts","../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/utils/compression.ts","../src/utils/arkivTransactions.ts","../src/actions/wallet/changeOwnership.ts","../src/actions/wallet/createEntity.ts","../src/actions/wallet/deleteEntity.ts","../src/actions/wallet/extendEntity.ts","../src/actions/wallet/mutateEntities.ts","../src/actions/wallet/updateEntity.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts"],"sourcesContent":["import type { ArkivClient } from \"../../clients/baseClient\"\n\nexport type GetBlockTimingReturnType = {\n currentBlock: bigint\n currentBlockTime: number\n blockDuration: number\n}\n\nexport async function getBlockTiming(client: ArkivClient) {\n const blockTiming = await client.request({\n method: \"arkiv_getBlockTiming\",\n params: [],\n })\n console.debug(\"Block timing\", blockTiming)\n return {\n currentBlock: blockTiming.current_block,\n currentBlockTime: blockTiming.current_block_time,\n blockDuration: blockTiming.duration,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport { NoEntityFoundError } from \"../../query/errors\"\nimport { entityFromRpcResult } from \"../../utils/entities\"\n\nexport async function getEntity(client: ArkivClient, key: Hex) {\n const result = await client.request({\n method: \"arkiv_query\",\n params: [`$key = ${key}`],\n })\n console.debug(\"GetEntity result\", result)\n\n if (!result.data) {\n throw new NoEntityFoundError()\n }\n\n return entityFromRpcResult(result.data[0])\n}\n","import type { ArkivClient } from \"../../clients/baseClient\"\n\nexport async function getEntityCount(client: ArkivClient) {\n const count = await client.request({\n method: \"arkiv_getEntityCount\",\n params: [],\n })\n\n return count\n}\n","import type { ArkivClient } from \"../../clients/baseClient\"\nimport { entityFromRpcResult } from \"../../utils/entities\"\n\nexport async function query(client: ArkivClient, query: string) {\n const result = await client.request({\n method: \"arkiv_query\",\n params: [query],\n })\n\n const entities = await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)))\n\n return entities\n}\n","import { decodeEventLog, parseAbi, toHex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { PublicArkivClient } from \"../../clients/createPublicClient\"\nimport type {\n OnEntityCreatedEvent,\n OnEntityDeletedEvent,\n OnEntityExpiredEvent,\n OnEntityExpiresInExtendedEvent,\n OnEntityUpdatedEvent,\n} from \"../../types/events\"\n\nexport const arkivABI = parseAbi([\n \"event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)\",\n \"event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)\",\n \"event ArkivEntityExpired(uint256 indexed entityKey, address indexed ownerAddress)\",\n \"event ArkivEntityDeleted(uint256 indexed entityKey, address indexed ownerAddress)\",\n \"event ArkivEntityBTLExtended(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)\",\n])\n\nexport async function subscribeEntityEvents(\n client: ArkivClient,\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n }: {\n onError: ((error: Error) => void) | undefined\n onEntityCreated?: ((event: OnEntityCreatedEvent) => void) | undefined\n onEntityUpdated?: ((event: OnEntityUpdatedEvent) => void) | undefined\n onEntityDeleted?: ((event: OnEntityDeletedEvent) => void) | undefined\n onEntityExpired?: ((event: OnEntityExpiredEvent) => void) | undefined\n onEntityExpiresInExtended?: ((event: OnEntityExpiresInExtendedEvent) => void) | undefined\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n): Promise<() => void> {\n const unsubscribe = (client as PublicArkivClient).watchEvent({\n pollingInterval: pollingInterval ?? 1000,\n fromBlock: fromBlock ?? 0n,\n events: arkivABI,\n onLogs: (logs) => {\n console.debug(\"logs from subscribeEntityEvents\", logs)\n for (const log of logs) {\n const event = decodeEventLog({\n abi: arkivABI,\n topics: log.topics,\n data: log.data,\n })\n console.debug(\"event from subscribeEntityEvents\", event)\n switch (event.eventName) {\n case \"ArkivEntityCreated\":\n onEntityCreated?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n expirationBlock: Number(event.args.expirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityUpdated\":\n onEntityUpdated?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n oldExpirationBlock: Number(event.args.oldExpirationBlock),\n newExpirationBlock: Number(event.args.newExpirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityDeleted\":\n onEntityDeleted?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n })\n break\n case \"ArkivEntityBTLExtended\":\n onEntityExpiresInExtended?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n oldExpirationBlock: Number(event.args.oldExpirationBlock),\n newExpirationBlock: Number(event.args.newExpirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityExpired\":\n onEntityExpired?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n })\n break\n default:\n console.warn(\"unknown event from subscribeEntityEvents\", event)\n break\n }\n }\n },\n onError: (error) => {\n console.error(\"error from subscribeEntityEvents\", error)\n onError?.(error)\n },\n })\n\n return unsubscribe\n}\n","import type { Account, Chain, Client, Hex, PublicActions, Transport } from \"viem\"\nimport { getBlockTiming } from \"../../actions/public/getBlockTiming\"\nimport { getEntity } from \"../../actions/public/getEntity\"\nimport { getEntityCount } from \"../../actions/public/getEntityCount\"\nimport { query } from \"../../actions/public/query\"\nimport { subscribeEntityEvents } from \"../../actions/public/subscribeEntityEvents\"\nimport { QueryBuilder } from \"../../query/queryBuilder\"\nimport type { Entity } from \"../../types/entity\"\nimport type {\n OnEntityCreatedEvent,\n OnEntityDeletedEvent,\n OnEntityExpiredEvent,\n OnEntityExpiresInExtendedEvent,\n OnEntityUpdatedEvent,\n} from \"../../types/events\"\n\nexport type PublicArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = Pick<\n PublicActions<transport, chain, account>,\n | \"getBalance\"\n | \"getBlock\"\n | \"getBlockNumber\"\n | \"getChainId\"\n | \"getLogs\"\n | \"getTransaction\"\n | \"getTransactionCount\"\n | \"getTransactionReceipt\"\n | \"waitForTransactionReceipt\"\n | \"watchEvent\"\n> & {\n /**\n * Returns the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/getEntity\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const entity = await client.getEntity(\"0x123\")\n * // {\n * // key: \"0x123\",\n * // value: \"0x123\",\n * // }\n */\n getEntity: (key: Hex) => Promise<Entity>\n\n /**\n * Returns a QueryBuilder instance for building and executing queries.\n * The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/query\n *\n * @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const query = client.buildQuery()\n * const entities = await query.where(\"key\", \"=\", \"value\").ownedBy(\"0x123\").fetch()\n *\n */\n buildQuery: () => QueryBuilder\n\n /**\n * Returns a QueryResult instance for fetching the results of a raw query.\n * @returns A QueryResult instance for fetching the results of a raw query. {@link QueryResult}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const queryResult = client.query('key = value && $owner = 0x123')\n *\n */\n query: (query: string) => Promise<Entity[]>\n\n /**\n * Returns the number of entities in the DBChain.\n * @returns The number of entities in the DBChain. {@link number}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const entityCount = await client.getEntityCount()\n * // entityCount = 0\n */\n getEntityCount: () => Promise<number>\n\n /**\n * Returns the current block timing.\n * @returns The current block timing. {@link GetBlockTimingReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const blockTiming = await client.getBlockTiming()\n * // {\n * // currentBlock: 10n, // block number\n * // currentBlockTime: 1234567890, // block timestamp\n * // blockDuration: 2, // in seconds\n * // }\n */\n getBlockTiming: () => Promise<{\n currentBlock: bigint\n currentBlockTime: number\n blockDuration: number\n }>\n\n subscribeEntityEvents: (\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpiresInExtended,\n }: {\n onError?: (error: Error) => void\n onEntityCreated?: (event: OnEntityCreatedEvent) => void\n onEntityUpdated?: (event: OnEntityUpdatedEvent) => void\n onEntityDeleted?: (event: OnEntityDeletedEvent) => void\n onEntityExpired?: (event: OnEntityExpiredEvent) => void\n onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n ) => Promise<() => void>\n}\n\nexport function publicArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(client: Client<transport, chain, account>) {\n return {\n getEntity: (key: Hex) => getEntity(client, key),\n query: (rawQuery: string) => query(client, rawQuery),\n buildQuery: () => new QueryBuilder(client),\n getBlockTiming: () => getBlockTiming(client),\n getEntityCount: () => getEntityCount(client),\n subscribeEntityEvents: (\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n }: {\n onError?: (error: Error) => void\n onEntityCreated?: (event: OnEntityCreatedEvent) => void\n onEntityUpdated?: (event: OnEntityUpdatedEvent) => void\n onEntityDeleted?: (event: OnEntityDeletedEvent) => void\n onEntityExpired?: (event: OnEntityExpiredEvent) => void\n onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n ) =>\n subscribeEntityEvents(\n client,\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n },\n pollingInterval,\n fromBlock,\n ),\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n ParseAccount,\n Prettify,\n PublicClientConfig,\n RpcSchema,\n Transport,\n} from \"viem\"\nimport { createClient, publicActions } from \"viem\"\nimport type { ArkivRpcSchema } from \"../types/rpcSchema\"\nimport { type PublicArkivActions, publicArkivActions } from \"./decorators/arkivPublic\"\n\nexport type PublicArkivClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n> = Prettify<\n Client<transport, chain, accountOrAddress, rpcSchema, PublicArkivActions<transport, chain>>\n>\n\n/**\n * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/clients/public\n *\n * 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.golemdb.io/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.golemdb.io/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).\n *\n * @param config - {@link PublicClientConfig}\n * @returns A Arkiv Public Client. {@link PublicArkivClient}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\nexport function createPublicClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n>(\n parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): PublicArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema> {\n const { key = \"public\", name = \"Public Client\" } = parameters\n const client = createClient({\n ...parameters,\n key,\n name,\n })\n\n return client.extend(publicArkivActions).extend(publicActions) as unknown as PublicArkivClient<\n transport,\n chain,\n ParseAccount<accountOrAddress>,\n rpcSchema\n >\n}\n","// src/utils/compression.ts\nimport type { BrotliWasmType } from \"brotli-wasm\"\n\nlet brotli: BrotliWasmType | null = null\nlet brotliPromise: Promise<BrotliWasmType> | null = null\n\nasync function getBrotli(): Promise<BrotliWasmType | null> {\n if (brotli) return brotli\n\n if (!brotliPromise) {\n try {\n const module = await import(\"brotli-wasm\")\n brotliPromise = Promise.resolve(module.default)\n brotli = await brotliPromise\n } catch (error) {\n console.error(\"Error importing brotli-wasm\", error)\n brotli = require(\"brotli-wasm\")\n }\n }\n\n brotli = await brotliPromise\n return brotli\n}\n\nexport async function compress(data: Uint8Array): Promise<Uint8Array> {\n const brotliInstance = await getBrotli()\n console.debug(`Compressing data (size: ${data.length})`)\n if (!brotliInstance) {\n console.warn(\"Brotli instance not found, not compressing data\")\n return data\n }\n const brotliCompressed = brotliInstance.compress(data)\n console.debug(`Brotli compressed data (size: ${brotliCompressed.length})`)\n return brotliCompressed\n}\n\nexport async function decompress(data: Uint8Array): Promise<Uint8Array> {\n const brotliInstance = await getBrotli()\n if (!brotliInstance) {\n console.warn(\"Brotli instance not found, not decompressing data\")\n return data\n }\n return brotliInstance.decompress(data)\n}\n","import { type Hex, toBytes, toHex, toRlp } from \"viem\"\nimport type { ChangeOwnershipParameters } from \"../actions/wallet/changeOwnership\"\nimport type { CreateEntityParameters } from \"../actions/wallet/createEntity\"\nimport type { DeleteEntityParameters } from \"../actions/wallet/deleteEntity\"\nimport type { ExtendEntityParameters } from \"../actions/wallet/extendEntity\"\nimport type { UpdateEntityParameters } from \"../actions/wallet/updateEntity\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { WalletArkivClient } from \"../clients/createWalletClient\"\nimport { ARKIV_ADDRESS, BLOCK_TIME } from \"../consts\"\nimport type { TxParams } from \"../types\"\nimport { compress } from \"./compression\"\n\nexport function opsToTxData({\n creates,\n updates,\n deletes,\n extensions,\n ownershipChanges,\n}: {\n creates?: CreateEntityParameters[]\n updates?: UpdateEntityParameters[]\n deletes?: DeleteEntityParameters[]\n extensions?: ExtendEntityParameters[]\n ownershipChanges?: ChangeOwnershipParameters[]\n}) {\n function formatAttributes<T extends string | number | bigint | boolean>(attribute: {\n key: string\n value: T\n }): [Hex, Hex] {\n return [toHex(attribute.key), toHex(attribute.value)]\n }\n\n const payload = [\n //creates\n (creates ?? []).map((item) => [\n toHex(item.expiresIn / BLOCK_TIME),\n toHex(item.contentType),\n toHex(item.payload),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"string\")\n .map(formatAttributes),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"number\")\n .map(formatAttributes),\n ]),\n //updates\n (updates ?? []).map((item) => [\n item.entityKey,\n toHex(item.contentType),\n toHex(item.expiresIn / BLOCK_TIME),\n toHex(item.payload),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"string\")\n .map(formatAttributes),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"number\")\n .map(formatAttributes),\n ]),\n //deletes\n (deletes ?? []).map((item) => item.entityKey),\n //extends\n (extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),\n //ownershipChanges TODO\n (ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner]),\n ]\n\n console.debug(\"txData to send as RLP\", payload, payload.length)\n\n return toRlp(payload)\n}\n\nexport async function sendArkivTransaction(client: ArkivClient, data: Hex, txParams?: TxParams) {\n if (!client.account) throw new Error(\"Account required\")\n const walletClient = client as WalletArkivClient\n\n console.debug(\"Sending transaction\", {\n account: client.account,\n chain: client.chain,\n to: ARKIV_ADDRESS,\n value: 0n,\n data,\n ...txParams,\n })\n\n const compressed = await compress(toBytes(data))\n const txHash = await walletClient.sendTransaction({\n account: client.account,\n chain: client.chain,\n to: ARKIV_ADDRESS,\n value: 0n,\n data: toHex(compressed),\n ...txParams,\n })\n\n const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash })\n\n console.debug(\"Tx receipt\", receipt)\n\n return receipt\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the deleteEntity function.\n * - entityKey: The key of the entity to delete.\n */\nexport type ChangeOwnershipParameters = {\n entityKey: Hex\n newOwner: Hex\n}\n\n/**\n * Return type for the deleteEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type ChangeOwnershipReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function changeOwnership(\n client: ArkivClient,\n data: ChangeOwnershipParameters,\n txParams?: TxParams,\n): Promise<ChangeOwnershipReturnType> {\n console.debug(\"changeOwnership\", data)\n const txData = opsToTxData({ ownershipChanges: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from changeOwnership\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: data.entityKey,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { Attribute, MimeType, TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the createEntity function.\n * - payload: The payload of the entity.\n * - attributes: The attributes of the entity.\n * - contentType: The content type of the entity.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type CreateEntityParameters = {\n payload: Uint8Array\n attributes: Attribute[]\n contentType: MimeType\n expiresIn: number\n}\n\n/**\n * Return type for the createEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type CreateEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function createEntity(\n client: ArkivClient,\n data: CreateEntityParameters,\n txParams?: TxParams,\n): Promise<CreateEntityReturnType> {\n console.debug(\"createEntity\", data)\n const txData = opsToTxData({ creates: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from createEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the deleteEntity function.\n * - entityKey: The key of the entity to delete.\n */\nexport type DeleteEntityParameters = {\n entityKey: Hex\n}\n\n/**\n * Return type for the deleteEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type DeleteEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function deleteEntity(\n client: ArkivClient,\n data: DeleteEntityParameters,\n txParams?: TxParams,\n): Promise<DeleteEntityReturnType> {\n console.debug(\"deleteEntity\", data)\n const txData = opsToTxData({ deletes: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from deleteEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: data.entityKey,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the extendEntity function.\n * - entityKey: The key of the entity to extend.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type ExtendEntityParameters = {\n entityKey: Hex\n expiresIn: number\n}\n\n/**\n * Return type for the extendEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type ExtendEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function extendEntity(\n client: ArkivClient,\n data: ExtendEntityParameters,\n txParams?: TxParams,\n): Promise<ExtendEntityReturnType> {\n console.debug(\"extendEntity\", data)\n const txData = opsToTxData({ extensions: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from extendEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Hex, TransactionReceipt } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\nimport type { CreateEntityParameters } from \"./createEntity\"\nimport type { DeleteEntityParameters } from \"./deleteEntity\"\nimport type { ExtendEntityParameters } from \"./extendEntity\"\nimport type { UpdateEntityParameters } from \"./updateEntity\"\n\n/**\n * Parameters for the mutateEntities function.\n * - creates: The creates to perform.\n * - updates: The updates to perform.\n * - deletes: The deletes to perform.\n * - extensions: The extensions to perform.\n */\nexport type MutateEntitiesParameters = {\n creates?: CreateEntityParameters[]\n updates?: UpdateEntityParameters[]\n deletes?: DeleteEntityParameters[]\n extensions?: ExtendEntityParameters[]\n}\n\nfunction parseReceipt(receipt: TransactionReceipt, params: MutateEntitiesParameters) {\n const createdEntities: Hex[] = []\n const updatedEntities: Hex[] = []\n const deletedEntities: Hex[] = []\n const extendedEntities: Hex[] = []\n const totalCreates = params.creates?.length ?? 0\n const totalUpdates = params.updates?.length ?? 0\n const totalDeletes = params.deletes?.length ?? 0\n\n // iterate over all logs and parse the event\n // each odd log is the interested ones, logs goes in order like: creates, deleted, updates, extends\n for (let i = 0; i < receipt.logs.length; i++) {\n const log = receipt.logs[i]\n if (i % 2 === 1) continue\n\n const index = i / 2\n if (index < totalCreates) {\n createdEntities.push(log.topics[1] as Hex)\n } else if (index < totalCreates + totalDeletes) {\n deletedEntities.push(log.topics[1] as Hex)\n } else if (index < totalCreates + totalUpdates + totalDeletes) {\n updatedEntities.push(log.topics[1] as Hex)\n } else {\n extendedEntities.push(log.topics[1] as Hex)\n }\n }\n\n return { createdEntities, updatedEntities, deletedEntities, extendedEntities }\n}\n\n/**\n * Return type for the mutateEntities function.\n * - txHash: The transaction hash.\n * - createdEntities: The keys of the created entities.\n * - updatedEntities: The keys of the updated entities.\n * - deletedEntities: The keys of the deleted entities.\n * - extendedEntities: The keys of the extended entities.\n */\nexport type MutateEntitiesReturnType = {\n txHash: string\n createdEntities: Hex[]\n updatedEntities: Hex[]\n deletedEntities: Hex[]\n extendedEntities: Hex[]\n}\nexport async function mutateEntities(\n client: ArkivClient,\n data: MutateEntitiesParameters,\n txParams?: TxParams,\n): Promise<MutateEntitiesReturnType> {\n if (!data.creates && !data.updates && !data.deletes && !data.extensions) {\n throw new Error(\"No operations to perform\")\n }\n\n const txData = opsToTxData({\n creates: data.creates ?? [],\n updates: data.updates ?? [],\n deletes: data.deletes ?? [],\n extensions: data.extensions ?? [],\n })\n\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from mutateEntities\", receipt)\n\n const { createdEntities, updatedEntities, deletedEntities, extendedEntities } = parseReceipt(\n receipt,\n data,\n )\n return {\n txHash: receipt.transactionHash,\n createdEntities,\n updatedEntities,\n deletedEntities,\n extendedEntities,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { Attribute, MimeType, TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the updateEntity function.\n * - entityKey: The key of the entity to update.\n * - payload: The payload of the entity.\n * - attributes: The attributes of the entity.\n * - contentType: The content type of the entity.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type UpdateEntityParameters = {\n entityKey: Hex\n payload: Uint8Array\n attributes: Attribute[]\n contentType: MimeType\n expiresIn: number\n}\n\n/**\n * Return type for the updateEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type UpdateEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function updateEntity(\n client: ArkivClient,\n data: UpdateEntityParameters,\n txParams?: TxParams,\n): Promise<UpdateEntityReturnType> {\n console.debug(\"updateEntity\", data)\n const txData = opsToTxData({ updates: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from updateEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Account, Chain, Client, Transport, WalletActions } from \"viem\"\nimport type {\n ChangeOwnershipParameters,\n ChangeOwnershipReturnType,\n} from \"../../actions/wallet/changeOwnership\"\nimport { changeOwnership } from \"../../actions/wallet/changeOwnership\"\nimport {\n type CreateEntityParameters,\n type CreateEntityReturnType,\n createEntity,\n} from \"../../actions/wallet/createEntity\"\nimport type {\n DeleteEntityParameters,\n DeleteEntityReturnType,\n} from \"../../actions/wallet/deleteEntity\"\nimport { deleteEntity } from \"../../actions/wallet/deleteEntity\"\nimport type {\n ExtendEntityParameters,\n ExtendEntityReturnType,\n} from \"../../actions/wallet/extendEntity\"\nimport { extendEntity } from \"../../actions/wallet/extendEntity\"\nimport type {\n MutateEntitiesParameters,\n MutateEntitiesReturnType,\n} from \"../../actions/wallet/mutateEntities\"\nimport { mutateEntities } from \"../../actions/wallet/mutateEntities\"\nimport type {\n UpdateEntityParameters,\n UpdateEntityReturnType,\n} from \"../../actions/wallet/updateEntity\"\nimport { updateEntity } from \"../../actions/wallet/updateEntity\"\nimport type { Entity, TxParams } from \"../../types\"\nimport type { PublicArkivActions } from \"./arkivPublic\"\n\nexport type WalletArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = PublicArkivActions<transport, chain, account> &\n Pick<\n WalletActions<chain, account>,\n | \"sendTransaction\"\n | \"sendTransactionSync\"\n | \"sendRawTransaction\"\n | \"sendRawTransactionSync\"\n | \"signMessage\"\n | \"signTransaction\"\n > & {\n /**\n * Returns the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/getEntity\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.createEntity({\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attributes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n createEntity: (\n data: CreateEntityParameters,\n txParams?: TxParams,\n ) => Promise<CreateEntityReturnType>\n\n /**\n * Updates the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/updateEntity\n * - JSON-RPC Methods: [`golembase_updateEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_updateEntity)\n *\n * @param args - {entityKey, data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\n updateEntity: (\n data: UpdateEntityParameters,\n txParams?: TxParams,\n ) => Promise<UpdateEntityReturnType>\n\n /**\n * Deletes the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/deleteEntity\n * - JSON-RPC Methods: [`golembase_deleteEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_deleteEntity)\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.deleteEntity({ entityKey: \"0x123\" })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n deleteEntity: (\n data: DeleteEntityParameters,\n txParams?: TxParams,\n ) => Promise<DeleteEntityReturnType>\n\n /**\n * Extends the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/extendEntity\n * - JSON-RPC Methods: [`golembase_extendEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_extendEntity)\n *\n * @param args - {entityKey, data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.extendEntity(\"0x123\", {\n * expiresIn: 1000,\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n extendEntity: (\n data: ExtendEntityParameters,\n txParams?: TxParams,\n ) => Promise<ExtendEntityReturnType>\n\n /**\n * Changes the ownership of the entity with the given address.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/changeOwnership\n * - JSON-RPC Methods: [`golembase_ownershipChange`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_ownershipChange)\n *\n * @param args - {entityKey, newOwner}\n * @returns The entity with the given address. {@link Entity}\n */\n changeOwnership: (\n data: ChangeOwnershipParameters,\n txParams?: TxParams,\n ) => Promise<ChangeOwnershipReturnType>\n\n /**\n * Mutates the entities with the given keys.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/mutateEntities\n * - JSON-RPC Methods: [`golembase_mutateEntities`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_mutateEntities)\n *\n * @param args - {data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.mutateEntities({\n * creates: [{\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attriubutes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * }],\n * updates: [{\n * entityKey: \"0x123\",\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attributes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * }],\n * deletes: [{\n * entityKey: \"0x321\",\n * }],\n * extensions: [{\n * entityKey: \"0x1234\",\n * expiresIn: 1000,\n * }],\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n mutateEntities: (\n data: MutateEntitiesParameters,\n txParams?: TxParams,\n ) => Promise<MutateEntitiesReturnType>\n }\n\nexport function walletArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(client: Client<transport, chain, account>) {\n return {\n createEntity: (data: CreateEntityParameters, txParams?: TxParams) =>\n createEntity(client, data, txParams),\n updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) =>\n updateEntity(client, data, txParams),\n deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) =>\n deleteEntity(client, data, txParams),\n extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) =>\n extendEntity(client, data, txParams),\n changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) =>\n changeOwnership(client, data, txParams),\n mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) =>\n mutateEntities(client, data, txParams),\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n ParseAccount,\n Prettify,\n RpcSchema,\n Transport,\n WalletClientConfig,\n} from \"viem\"\nimport { createClient, publicActions, walletActions } from \"viem\"\nimport type { ArkivRpcSchema } from \"../types/rpcSchema\"\nimport { publicArkivActions } from \"./decorators/arkivPublic\"\nimport { type WalletArkivActions, walletArkivActions } from \"./decorators/arkivWallet\"\n\nexport type WalletArkivClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n> = Prettify<\n Client<transport, chain, account, rpcSchema, WalletArkivActions<transport, chain, account>>\n>\n\n/**\n * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/clients/public\n *\n * 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.golemdb.io/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.golemdb.io/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).\n *\n * @param config - {@link PublicClientConfig}\n * @returns A Arkiv Public Client. {@link PublicArkivClient}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\nexport function createWalletClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n>(\n parameters: WalletClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): WalletArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema> {\n const { key = \"wallet\", name = \"Wallet Client\" } = parameters\n const client = createClient({\n ...parameters,\n key,\n name,\n })\n\n return client\n .extend(walletActions)\n .extend(publicActions)\n .extend(walletArkivActions)\n .extend(publicArkivActions) as unknown as WalletArkivClient<\n transport,\n chain,\n ParseAccount<accountOrAddress>,\n rpcSchema\n >\n}\n"],"mappings":";;;;;;;;;;;;AAQA,eAAsB,eAAe,QAAqB;CACxD,MAAM,cAAc,MAAM,OAAO,QAAQ;EACvC,QAAQ;EACR,QAAQ,EAAE;EACX,CAAC;AACF,SAAQ,MAAM,gBAAgB,YAAY;AAC1C,QAAO;EACL,cAAc,YAAY;EAC1B,kBAAkB,YAAY;EAC9B,eAAe,YAAY;EAC5B;;;;;ACbH,eAAsB,UAAU,QAAqB,KAAU;CAC7D,MAAM,SAAS,MAAM,OAAO,QAAQ;EAClC,QAAQ;EACR,QAAQ,CAAC,UAAU,MAAM;EAC1B,CAAC;AACF,SAAQ,MAAM,oBAAoB,OAAO;AAEzC,KAAI,CAAC,OAAO,KACV,OAAM,IAAI,oBAAoB;AAGhC,QAAO,oBAAoB,OAAO,KAAK,GAAG;;;;;ACd5C,eAAsB,eAAe,QAAqB;AAMxD,QALc,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;;;;;;;;;;;;;;;AC5MH,SAAgB,mBAMd,YACgF;CAChF,MAAM,EAAE,MAAM,UAAU,OAAO,oBAAoB;AAOnD,QANe,aAAa;EAC1B,GAAG;EACH;EACA;EACD,CAAC,CAGC,OAAO,cAAc,CACrB,OAAO,cAAc,CACrB,OAAO,mBAAmB,CAC1B,OAAO,mBAAmB"}
1
+ {"version":3,"file":"index.js","names":["query","toHex","brotli: BrotliWasmType | null","toHex","toRlp","toBytes","createdEntities: Hex[]","updatedEntities: Hex[]","deletedEntities: Hex[]","extendedEntities: Hex[]"],"sources":["../src/actions/public/getBlockTiming.ts","../src/actions/public/getEntity.ts","../src/actions/public/getEntityCount.ts","../src/actions/public/query.ts","../src/actions/public/subscribeEntityEvents.ts","../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/utils/compression.ts","../src/utils/arkivTransactions.ts","../src/actions/wallet/changeOwnership.ts","../src/actions/wallet/createEntity.ts","../src/actions/wallet/deleteEntity.ts","../src/actions/wallet/extendEntity.ts","../src/actions/wallet/mutateEntities.ts","../src/actions/wallet/updateEntity.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts"],"sourcesContent":["import type { ArkivClient } from \"../../clients/baseClient\"\n\nexport type GetBlockTimingReturnType = {\n currentBlock: bigint\n currentBlockTime: number\n blockDuration: number\n}\n\nexport async function getBlockTiming(client: ArkivClient) {\n const blockTiming = await client.request({\n method: \"arkiv_getBlockTiming\",\n params: [],\n })\n console.debug(\"Block timing\", blockTiming)\n return {\n currentBlock: blockTiming.current_block,\n currentBlockTime: blockTiming.current_block_time,\n blockDuration: blockTiming.duration,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport { NoEntityFoundError } from \"../../query/errors\"\nimport { entityFromRpcResult } from \"../../utils/entities\"\n\nexport async function getEntity(client: ArkivClient, key: Hex) {\n const result = await client.request({\n method: \"arkiv_query\",\n params: [`$key = ${key}`],\n })\n console.debug(\"GetEntity result\", result)\n\n if (!result.data) {\n throw new NoEntityFoundError()\n }\n\n return entityFromRpcResult(result.data[0])\n}\n","import type { ArkivClient } from \"../../clients/baseClient\"\n\nexport async function getEntityCount(client: ArkivClient) {\n const count = await client.request({\n method: \"arkiv_getEntityCount\",\n params: [],\n })\n\n return count\n}\n","import type { ArkivClient } from \"../../clients/baseClient\"\nimport { entityFromRpcResult } from \"../../utils/entities\"\n\nexport async function query(client: ArkivClient, query: string) {\n const result = await client.request({\n method: \"arkiv_query\",\n params: [query],\n })\n\n const entities = await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)))\n\n return entities\n}\n","import { decodeEventLog, parseAbi, toHex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { PublicArkivClient } from \"../../clients/createPublicClient\"\nimport type {\n OnEntityCreatedEvent,\n OnEntityDeletedEvent,\n OnEntityExpiredEvent,\n OnEntityExpiresInExtendedEvent,\n OnEntityUpdatedEvent,\n} from \"../../types/events\"\n\nexport const arkivABI = parseAbi([\n \"event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)\",\n \"event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)\",\n \"event ArkivEntityExpired(uint256 indexed entityKey, address indexed ownerAddress)\",\n \"event ArkivEntityDeleted(uint256 indexed entityKey, address indexed ownerAddress)\",\n \"event ArkivEntityBTLExtended(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)\",\n])\n\nexport async function subscribeEntityEvents(\n client: ArkivClient,\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n }: {\n onError: ((error: Error) => void) | undefined\n onEntityCreated?: ((event: OnEntityCreatedEvent) => void) | undefined\n onEntityUpdated?: ((event: OnEntityUpdatedEvent) => void) | undefined\n onEntityDeleted?: ((event: OnEntityDeletedEvent) => void) | undefined\n onEntityExpired?: ((event: OnEntityExpiredEvent) => void) | undefined\n onEntityExpiresInExtended?: ((event: OnEntityExpiresInExtendedEvent) => void) | undefined\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n): Promise<() => void> {\n const unsubscribe = (client as PublicArkivClient).watchEvent({\n pollingInterval: pollingInterval ?? 1000,\n fromBlock: fromBlock ?? 0n,\n events: arkivABI,\n onLogs: (logs) => {\n console.debug(\"logs from subscribeEntityEvents\", logs)\n for (const log of logs) {\n const event = decodeEventLog({\n abi: arkivABI,\n topics: log.topics,\n data: log.data,\n })\n console.debug(\"event from subscribeEntityEvents\", event)\n switch (event.eventName) {\n case \"ArkivEntityCreated\":\n onEntityCreated?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n expirationBlock: Number(event.args.expirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityUpdated\":\n onEntityUpdated?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n oldExpirationBlock: Number(event.args.oldExpirationBlock),\n newExpirationBlock: Number(event.args.newExpirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityDeleted\":\n onEntityDeleted?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n })\n break\n case \"ArkivEntityBTLExtended\":\n onEntityExpiresInExtended?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n oldExpirationBlock: Number(event.args.oldExpirationBlock),\n newExpirationBlock: Number(event.args.newExpirationBlock),\n cost: event.args.cost,\n })\n break\n case \"ArkivEntityExpired\":\n onEntityExpired?.({\n entityKey: toHex(event.args.entityKey, { size: 32 }),\n owner: event.args.ownerAddress,\n })\n break\n default:\n console.warn(\"unknown event from subscribeEntityEvents\", event)\n break\n }\n }\n },\n onError: (error) => {\n console.error(\"error from subscribeEntityEvents\", error)\n onError?.(error)\n },\n })\n\n return unsubscribe\n}\n","import type { Account, Chain, Client, Hex, PublicActions, Transport } from \"viem\"\nimport { getBlockTiming } from \"../../actions/public/getBlockTiming\"\nimport { getEntity } from \"../../actions/public/getEntity\"\nimport { getEntityCount } from \"../../actions/public/getEntityCount\"\nimport { query } from \"../../actions/public/query\"\nimport { subscribeEntityEvents } from \"../../actions/public/subscribeEntityEvents\"\nimport { QueryBuilder } from \"../../query/queryBuilder\"\nimport type { Entity } from \"../../types/entity\"\nimport type {\n OnEntityCreatedEvent,\n OnEntityDeletedEvent,\n OnEntityExpiredEvent,\n OnEntityExpiresInExtendedEvent,\n OnEntityUpdatedEvent,\n} from \"../../types/events\"\n\nexport type PublicArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = Pick<\n PublicActions<transport, chain, account>,\n | \"getBalance\"\n | \"getBlock\"\n | \"getBlockNumber\"\n | \"getChainId\"\n | \"getLogs\"\n | \"getTransaction\"\n | \"getTransactionCount\"\n | \"getTransactionReceipt\"\n | \"waitForTransactionReceipt\"\n | \"watchEvent\"\n> & {\n /**\n * Returns the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/getEntity\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const entity = await client.getEntity(\"0x123\")\n * // {\n * // key: \"0x123\",\n * // value: \"0x123\",\n * // }\n */\n getEntity: (key: Hex) => Promise<Entity>\n\n /**\n * Returns a QueryBuilder instance for building and executing queries.\n * The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/query\n *\n * @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const query = client.buildQuery()\n * const entities = await query.where(\"key\", \"=\", \"value\").ownedBy(\"0x123\").fetch()\n *\n */\n buildQuery: () => QueryBuilder\n\n /**\n * Returns a QueryResult instance for fetching the results of a raw query.\n * @returns A QueryResult instance for fetching the results of a raw query. {@link QueryResult}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const queryResult = client.query('key = value && $owner = 0x123')\n *\n */\n query: (query: string) => Promise<Entity[]>\n\n /**\n * Returns the number of entities in the DBChain.\n * @returns The number of entities in the DBChain. {@link number}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const entityCount = await client.getEntityCount()\n * // entityCount = 0\n */\n getEntityCount: () => Promise<number>\n\n /**\n * Returns the current block timing.\n * @returns The current block timing. {@link GetBlockTimingReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const blockTiming = await client.getBlockTiming()\n * // {\n * // currentBlock: 10n, // block number\n * // currentBlockTime: 1234567890, // block timestamp\n * // blockDuration: 2, // in seconds\n * // }\n */\n getBlockTiming: () => Promise<{\n currentBlock: bigint\n currentBlockTime: number\n blockDuration: number\n }>\n\n subscribeEntityEvents: (\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpiresInExtended,\n }: {\n onError?: (error: Error) => void\n onEntityCreated?: (event: OnEntityCreatedEvent) => void\n onEntityUpdated?: (event: OnEntityUpdatedEvent) => void\n onEntityDeleted?: (event: OnEntityDeletedEvent) => void\n onEntityExpired?: (event: OnEntityExpiredEvent) => void\n onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n ) => Promise<() => void>\n}\n\nexport function publicArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(client: Client<transport, chain, account>) {\n return {\n getEntity: (key: Hex) => getEntity(client, key),\n query: (rawQuery: string) => query(client, rawQuery),\n buildQuery: () => new QueryBuilder(client),\n getBlockTiming: () => getBlockTiming(client),\n getEntityCount: () => getEntityCount(client),\n subscribeEntityEvents: (\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n }: {\n onError?: (error: Error) => void\n onEntityCreated?: (event: OnEntityCreatedEvent) => void\n onEntityUpdated?: (event: OnEntityUpdatedEvent) => void\n onEntityDeleted?: (event: OnEntityDeletedEvent) => void\n onEntityExpired?: (event: OnEntityExpiredEvent) => void\n onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void\n },\n pollingInterval?: number,\n fromBlock?: bigint,\n ) =>\n subscribeEntityEvents(\n client,\n {\n onError,\n onEntityCreated,\n onEntityUpdated,\n onEntityDeleted,\n onEntityExpired,\n onEntityExpiresInExtended,\n },\n pollingInterval,\n fromBlock,\n ),\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n ParseAccount,\n Prettify,\n PublicClientConfig,\n RpcSchema,\n Transport,\n} from \"viem\"\nimport { createClient, publicActions } from \"viem\"\nimport type { ArkivRpcSchema } from \"../types/rpcSchema\"\nimport { type PublicArkivActions, publicArkivActions } from \"./decorators/arkivPublic\"\n\nexport type PublicArkivClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n> = Prettify<\n Client<transport, chain, accountOrAddress, rpcSchema, PublicArkivActions<transport, chain>>\n>\n\n/**\n * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/clients/public\n *\n * 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.golemdb.io/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.golemdb.io/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).\n *\n * @param config - {@link PublicClientConfig}\n * @returns A Arkiv Public Client. {@link PublicArkivClient}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\nexport function createPublicClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n>(\n parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): PublicArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema> {\n const { key = \"public\", name = \"Public Client\" } = parameters\n const client = createClient({\n ...parameters,\n key,\n name,\n })\n\n return client.extend(publicArkivActions).extend(publicActions) as unknown as PublicArkivClient<\n transport,\n chain,\n ParseAccount<accountOrAddress>,\n rpcSchema\n >\n}\n","// src/utils/compression.ts\n\nimport type { BrotliWasmType } from \"brotli-wasm\"\nimport brotliPromise from \"brotli-wasm\"\n\nlet brotli: BrotliWasmType | null = null\n\nasync function getBrotli(): Promise<BrotliWasmType | null> {\n if (brotli) return brotli\n\n if (!brotliPromise) {\n console.debug(\"Importing brotli-wasm\")\n try {\n console.debug(\"Importing brotli-wasm as module\")\n brotli = await brotliPromise\n console.debug(\"Imported brotli-wasm as module\", brotli)\n } catch (error) {\n console.error(\"Error importing brotli-wasm\", error)\n console.debug(\"Importing brotli-wasm as require\")\n brotli = require(\"brotli-wasm\")\n console.debug(\"Imported brotli-wasm as require\", brotli)\n }\n }\n\n brotli = await brotliPromise\n return brotli\n}\n\nexport async function compress(data: Uint8Array): Promise<Uint8Array> {\n const brotliInstance = await getBrotli()\n console.debug(`Compressing data (size: ${data.length})`)\n if (!brotliInstance) {\n console.warn(\"Brotli instance not found, not compressing data\")\n return data\n }\n const brotliCompressed = brotliInstance.compress(data)\n console.debug(`Brotli compressed data (size: ${brotliCompressed.length})`)\n return brotliCompressed\n}\n\nexport async function decompress(data: Uint8Array): Promise<Uint8Array> {\n const brotliInstance = await getBrotli()\n if (!brotliInstance) {\n console.warn(\"Brotli instance not found, not decompressing data\")\n return data\n }\n return brotliInstance.decompress(data)\n}\n","import { type Hex, toBytes, toHex, toRlp } from \"viem\"\nimport type { ChangeOwnershipParameters } from \"../actions/wallet/changeOwnership\"\nimport type { CreateEntityParameters } from \"../actions/wallet/createEntity\"\nimport type { DeleteEntityParameters } from \"../actions/wallet/deleteEntity\"\nimport type { ExtendEntityParameters } from \"../actions/wallet/extendEntity\"\nimport type { UpdateEntityParameters } from \"../actions/wallet/updateEntity\"\nimport type { ArkivClient } from \"../clients/baseClient\"\nimport type { WalletArkivClient } from \"../clients/createWalletClient\"\nimport { ARKIV_ADDRESS, BLOCK_TIME } from \"../consts\"\nimport type { TxParams } from \"../types\"\nimport { compress } from \"./compression\"\n\nexport function opsToTxData({\n creates,\n updates,\n deletes,\n extensions,\n ownershipChanges,\n}: {\n creates?: CreateEntityParameters[]\n updates?: UpdateEntityParameters[]\n deletes?: DeleteEntityParameters[]\n extensions?: ExtendEntityParameters[]\n ownershipChanges?: ChangeOwnershipParameters[]\n}) {\n function formatAttributes<T extends string | number | bigint | boolean>(attribute: {\n key: string\n value: T\n }): [Hex, Hex] {\n return [toHex(attribute.key), toHex(attribute.value)]\n }\n\n const payload = [\n //creates\n (creates ?? []).map((item) => [\n toHex(item.expiresIn / BLOCK_TIME),\n toHex(item.contentType),\n toHex(item.payload),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"string\")\n .map(formatAttributes),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"number\")\n .map(formatAttributes),\n ]),\n //updates\n (updates ?? []).map((item) => [\n item.entityKey,\n toHex(item.contentType),\n toHex(item.expiresIn / BLOCK_TIME),\n toHex(item.payload),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"string\")\n .map(formatAttributes),\n item.attributes\n .filter((attribute) => typeof attribute.value === \"number\")\n .map(formatAttributes),\n ]),\n //deletes\n (deletes ?? []).map((item) => item.entityKey),\n //extends\n (extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),\n //ownershipChanges TODO\n (ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner]),\n ]\n\n console.debug(\"txData to send as RLP\", payload, payload.length)\n\n return toRlp(payload)\n}\n\nexport async function sendArkivTransaction(client: ArkivClient, data: Hex, txParams?: TxParams) {\n if (!client.account) throw new Error(\"Account required\")\n const walletClient = client as WalletArkivClient\n\n console.debug(\"Sending transaction\", {\n account: client.account,\n chain: client.chain,\n to: ARKIV_ADDRESS,\n value: 0n,\n data,\n ...txParams,\n })\n\n const compressed = await compress(toBytes(data))\n const txHash = await walletClient.sendTransaction({\n account: client.account,\n chain: client.chain,\n to: ARKIV_ADDRESS,\n value: 0n,\n data: toHex(compressed),\n ...txParams,\n })\n\n const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash })\n\n console.debug(\"Tx receipt\", receipt)\n\n return receipt\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the deleteEntity function.\n * - entityKey: The key of the entity to delete.\n */\nexport type ChangeOwnershipParameters = {\n entityKey: Hex\n newOwner: Hex\n}\n\n/**\n * Return type for the deleteEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type ChangeOwnershipReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function changeOwnership(\n client: ArkivClient,\n data: ChangeOwnershipParameters,\n txParams?: TxParams,\n): Promise<ChangeOwnershipReturnType> {\n console.debug(\"changeOwnership\", data)\n const txData = opsToTxData({ ownershipChanges: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from changeOwnership\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: data.entityKey,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { Attribute, MimeType, TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the createEntity function.\n * - payload: The payload of the entity.\n * - attributes: The attributes of the entity.\n * - contentType: The content type of the entity.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type CreateEntityParameters = {\n payload: Uint8Array\n attributes: Attribute[]\n contentType: MimeType\n expiresIn: number\n}\n\n/**\n * Return type for the createEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type CreateEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function createEntity(\n client: ArkivClient,\n data: CreateEntityParameters,\n txParams?: TxParams,\n): Promise<CreateEntityReturnType> {\n console.debug(\"createEntity\", data)\n const txData = opsToTxData({ creates: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from createEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the deleteEntity function.\n * - entityKey: The key of the entity to delete.\n */\nexport type DeleteEntityParameters = {\n entityKey: Hex\n}\n\n/**\n * Return type for the deleteEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type DeleteEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function deleteEntity(\n client: ArkivClient,\n data: DeleteEntityParameters,\n txParams?: TxParams,\n): Promise<DeleteEntityReturnType> {\n console.debug(\"deleteEntity\", data)\n const txData = opsToTxData({ deletes: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from deleteEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: data.entityKey,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the extendEntity function.\n * - entityKey: The key of the entity to extend.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type ExtendEntityParameters = {\n entityKey: Hex\n expiresIn: number\n}\n\n/**\n * Return type for the extendEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type ExtendEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function extendEntity(\n client: ArkivClient,\n data: ExtendEntityParameters,\n txParams?: TxParams,\n): Promise<ExtendEntityReturnType> {\n console.debug(\"extendEntity\", data)\n const txData = opsToTxData({ extensions: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from extendEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Hex, TransactionReceipt } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\nimport type { CreateEntityParameters } from \"./createEntity\"\nimport type { DeleteEntityParameters } from \"./deleteEntity\"\nimport type { ExtendEntityParameters } from \"./extendEntity\"\nimport type { UpdateEntityParameters } from \"./updateEntity\"\n\n/**\n * Parameters for the mutateEntities function.\n * - creates: The creates to perform.\n * - updates: The updates to perform.\n * - deletes: The deletes to perform.\n * - extensions: The extensions to perform.\n */\nexport type MutateEntitiesParameters = {\n creates?: CreateEntityParameters[]\n updates?: UpdateEntityParameters[]\n deletes?: DeleteEntityParameters[]\n extensions?: ExtendEntityParameters[]\n}\n\nfunction parseReceipt(receipt: TransactionReceipt, params: MutateEntitiesParameters) {\n const createdEntities: Hex[] = []\n const updatedEntities: Hex[] = []\n const deletedEntities: Hex[] = []\n const extendedEntities: Hex[] = []\n const totalCreates = params.creates?.length ?? 0\n const totalUpdates = params.updates?.length ?? 0\n const totalDeletes = params.deletes?.length ?? 0\n\n // iterate over all logs and parse the event\n // each odd log is the interested ones, logs goes in order like: creates, deleted, updates, extends\n for (let i = 0; i < receipt.logs.length; i++) {\n const log = receipt.logs[i]\n if (i % 2 === 1) continue\n\n const index = i / 2\n if (index < totalCreates) {\n createdEntities.push(log.topics[1] as Hex)\n } else if (index < totalCreates + totalDeletes) {\n deletedEntities.push(log.topics[1] as Hex)\n } else if (index < totalCreates + totalUpdates + totalDeletes) {\n updatedEntities.push(log.topics[1] as Hex)\n } else {\n extendedEntities.push(log.topics[1] as Hex)\n }\n }\n\n return { createdEntities, updatedEntities, deletedEntities, extendedEntities }\n}\n\n/**\n * Return type for the mutateEntities function.\n * - txHash: The transaction hash.\n * - createdEntities: The keys of the created entities.\n * - updatedEntities: The keys of the updated entities.\n * - deletedEntities: The keys of the deleted entities.\n * - extendedEntities: The keys of the extended entities.\n */\nexport type MutateEntitiesReturnType = {\n txHash: string\n createdEntities: Hex[]\n updatedEntities: Hex[]\n deletedEntities: Hex[]\n extendedEntities: Hex[]\n}\nexport async function mutateEntities(\n client: ArkivClient,\n data: MutateEntitiesParameters,\n txParams?: TxParams,\n): Promise<MutateEntitiesReturnType> {\n if (!data.creates && !data.updates && !data.deletes && !data.extensions) {\n throw new Error(\"No operations to perform\")\n }\n\n const txData = opsToTxData({\n creates: data.creates ?? [],\n updates: data.updates ?? [],\n deletes: data.deletes ?? [],\n extensions: data.extensions ?? [],\n })\n\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from mutateEntities\", receipt)\n\n const { createdEntities, updatedEntities, deletedEntities, extendedEntities } = parseReceipt(\n receipt,\n data,\n )\n return {\n txHash: receipt.transactionHash,\n createdEntities,\n updatedEntities,\n deletedEntities,\n extendedEntities,\n }\n}\n","import type { Hex } from \"viem\"\nimport type { ArkivClient } from \"../../clients/baseClient\"\nimport type { Attribute, MimeType, TxParams } from \"../../types\"\nimport { opsToTxData, sendArkivTransaction } from \"../../utils/arkivTransactions\"\n\n/**\n * Parameters for the updateEntity function.\n * - entityKey: The key of the entity to update.\n * - payload: The payload of the entity.\n * - attributes: The attributes of the entity.\n * - contentType: The content type of the entity.\n * - expiresIn: The expires in of the entity in seconds.\n */\nexport type UpdateEntityParameters = {\n entityKey: Hex\n payload: Uint8Array\n attributes: Attribute[]\n contentType: MimeType\n expiresIn: number\n}\n\n/**\n * Return type for the updateEntity function.\n * - entityKey: The key of the entity.\n * - txHash: The transaction hash.\n */\nexport type UpdateEntityReturnType = {\n entityKey: Hex\n txHash: string\n}\n\nexport async function updateEntity(\n client: ArkivClient,\n data: UpdateEntityParameters,\n txParams?: TxParams,\n): Promise<UpdateEntityReturnType> {\n console.debug(\"updateEntity\", data)\n const txData = opsToTxData({ updates: [data] })\n const receipt = await sendArkivTransaction(client, txData, txParams)\n\n console.debug(\"Receipt from updateEntity\", receipt)\n\n return {\n txHash: receipt.transactionHash,\n entityKey: receipt.logs[0].topics[1] as Hex,\n }\n}\n","import type { Account, Chain, Client, Transport, WalletActions } from \"viem\"\nimport type {\n ChangeOwnershipParameters,\n ChangeOwnershipReturnType,\n} from \"../../actions/wallet/changeOwnership\"\nimport { changeOwnership } from \"../../actions/wallet/changeOwnership\"\nimport {\n type CreateEntityParameters,\n type CreateEntityReturnType,\n createEntity,\n} from \"../../actions/wallet/createEntity\"\nimport type {\n DeleteEntityParameters,\n DeleteEntityReturnType,\n} from \"../../actions/wallet/deleteEntity\"\nimport { deleteEntity } from \"../../actions/wallet/deleteEntity\"\nimport type {\n ExtendEntityParameters,\n ExtendEntityReturnType,\n} from \"../../actions/wallet/extendEntity\"\nimport { extendEntity } from \"../../actions/wallet/extendEntity\"\nimport type {\n MutateEntitiesParameters,\n MutateEntitiesReturnType,\n} from \"../../actions/wallet/mutateEntities\"\nimport { mutateEntities } from \"../../actions/wallet/mutateEntities\"\nimport type {\n UpdateEntityParameters,\n UpdateEntityReturnType,\n} from \"../../actions/wallet/updateEntity\"\nimport { updateEntity } from \"../../actions/wallet/updateEntity\"\nimport type { Entity, TxParams } from \"../../types\"\nimport type { PublicArkivActions } from \"./arkivPublic\"\n\nexport type WalletArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = PublicArkivActions<transport, chain, account> &\n Pick<\n WalletActions<chain, account>,\n | \"sendTransaction\"\n | \"sendTransactionSync\"\n | \"sendRawTransaction\"\n | \"sendRawTransactionSync\"\n | \"signMessage\"\n | \"signTransaction\"\n > & {\n /**\n * Returns the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/public/getEntity\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.createEntity({\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attributes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n createEntity: (\n data: CreateEntityParameters,\n txParams?: TxParams,\n ) => Promise<CreateEntityReturnType>\n\n /**\n * Updates the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/updateEntity\n * - JSON-RPC Methods: [`golembase_updateEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_updateEntity)\n *\n * @param args - {entityKey, data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\n updateEntity: (\n data: UpdateEntityParameters,\n txParams?: TxParams,\n ) => Promise<UpdateEntityReturnType>\n\n /**\n * Deletes the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/deleteEntity\n * - JSON-RPC Methods: [`golembase_deleteEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_deleteEntity)\n *\n * @param args - {entityKey}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.deleteEntity({ entityKey: \"0x123\" })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n deleteEntity: (\n data: DeleteEntityParameters,\n txParams?: TxParams,\n ) => Promise<DeleteEntityReturnType>\n\n /**\n * Extends the entity with the given key.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/extendEntity\n * - JSON-RPC Methods: [`golembase_extendEntity`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_extendEntity)\n *\n * @param args - {entityKey, data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.extendEntity(\"0x123\", {\n * expiresIn: 1000,\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n extendEntity: (\n data: ExtendEntityParameters,\n txParams?: TxParams,\n ) => Promise<ExtendEntityReturnType>\n\n /**\n * Changes the ownership of the entity with the given address.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/changeOwnership\n * - JSON-RPC Methods: [`golembase_ownershipChange`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_ownershipChange)\n *\n * @param args - {entityKey, newOwner}\n * @returns The entity with the given address. {@link Entity}\n */\n changeOwnership: (\n data: ChangeOwnershipParameters,\n txParams?: TxParams,\n ) => Promise<ChangeOwnershipReturnType>\n\n /**\n * Mutates the entities with the given keys.\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/actions/wallet/mutateEntities\n * - JSON-RPC Methods: [`golembase_mutateEntities`](https://docs.golemdb.io/dev/json-rpc-api/#golembase_mutateEntities)\n *\n * @param args - {data}\n * @returns The entity with the given key. {@link Entity}\n *\n * @example\n * import { createWalletClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createWalletClient({\n * chain: kaolin,\n * transport: http(),\n * })\n * const { entityKey, txHash } = await client.mutateEntities({\n * creates: [{\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attriubutes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * }],\n * updates: [{\n * entityKey: \"0x123\",\n * payload: toBytes(JSON.stringify({ entity: { entityType: \"testType\", entityId: \"testId\" } })),\n * attributes: [{ key: \"testKey\", value: \"testValue\" }],\n * expiresIn: 1000,\n * }],\n * deletes: [{\n * entityKey: \"0x321\",\n * }],\n * extensions: [{\n * entityKey: \"0x1234\",\n * expiresIn: 1000,\n * }],\n * })\n * console.log(\"entityKey\", entityKey)\n * console.log(\"txHash\", txHash)\n * // {\n * // entityKey: \"0x123\",\n * // txHash: \"0x123\",\n * // }\n */\n mutateEntities: (\n data: MutateEntitiesParameters,\n txParams?: TxParams,\n ) => Promise<MutateEntitiesReturnType>\n }\n\nexport function walletArkivActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(client: Client<transport, chain, account>) {\n return {\n createEntity: (data: CreateEntityParameters, txParams?: TxParams) =>\n createEntity(client, data, txParams),\n updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) =>\n updateEntity(client, data, txParams),\n deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) =>\n deleteEntity(client, data, txParams),\n extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) =>\n extendEntity(client, data, txParams),\n changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) =>\n changeOwnership(client, data, txParams),\n mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) =>\n mutateEntities(client, data, txParams),\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n ParseAccount,\n Prettify,\n RpcSchema,\n Transport,\n WalletClientConfig,\n} from \"viem\"\nimport { createClient, publicActions, walletActions } from \"viem\"\nimport type { ArkivRpcSchema } from \"../types/rpcSchema\"\nimport { publicArkivActions } from \"./decorators/arkivPublic\"\nimport { type WalletArkivActions, walletArkivActions } from \"./decorators/arkivWallet\"\n\nexport type WalletArkivClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n> = Prettify<\n Client<transport, chain, account, rpcSchema, WalletArkivActions<transport, chain, account>>\n>\n\n/**\n * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).\n *\n * - Docs: https://docs.golemdb.io/ts-sdk/clients/public\n *\n * 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.golemdb.io/json-rpc/), and [Kaolin JSON-RPC API](https://kaolin.holesky.golemdb.io/rpc) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).\n *\n * @param config - {@link PublicClientConfig}\n * @returns A Arkiv Public Client. {@link PublicArkivClient}\n *\n * @example\n * import { createPublicClient, http } from 'arkiv'\n * import { kaolin } from 'arkiv/chains'\n *\n * const client = createPublicClient({\n * chain: kaolin,\n * transport: http(),\n * })\n */\nexport function createWalletClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = ArkivRpcSchema,\n>(\n parameters: WalletClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): WalletArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema> {\n const { key = \"wallet\", name = \"Wallet Client\" } = parameters\n const client = createClient({\n ...parameters,\n key,\n name,\n })\n\n return client\n .extend(walletActions)\n .extend(publicActions)\n .extend(walletArkivActions)\n .extend(publicArkivActions) as unknown as WalletArkivClient<\n transport,\n chain,\n ParseAccount<accountOrAddress>,\n rpcSchema\n >\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,eAAsB,eAAe,QAAqB;CACxD,MAAM,cAAc,MAAM,OAAO,QAAQ;EACvC,QAAQ;EACR,QAAQ,EAAE;EACX,CAAC;AACF,SAAQ,MAAM,gBAAgB,YAAY;AAC1C,QAAO;EACL,cAAc,YAAY;EAC1B,kBAAkB,YAAY;EAC9B,eAAe,YAAY;EAC5B;;;;;ACbH,eAAsB,UAAU,QAAqB,KAAU;CAC7D,MAAM,SAAS,MAAM,OAAO,QAAQ;EAClC,QAAQ;EACR,QAAQ,CAAC,UAAU,MAAM;EAC1B,CAAC;AACF,SAAQ,MAAM,oBAAoB,OAAO;AAEzC,KAAI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AAM,SAAS;EACtC,eAAe,MAA8B,aAC3C,aAAa,QAAQ,MAAM,SAAS;EACtC,kBAAkB,MAAiC,aACjD,gBAAgB,QAAQ,MAAM,SAAS;EACzC,iBAAiB,MAAgC,aAC/C,eAAe,QAAQ,MAAM,SAAS;EACzC;;;;;;;;;;;;;;;;;;;;;;;;AC5MH,SAAgB,mBAMd,YACgF;CAChF,MAAM,EAAE,MAAM,UAAU,OAAO,oBAAoB;AAOnD,QANe,aAAa;EAC1B,GAAG;EACH;EACA;EACD,CAAC,CAGC,OAAO,cAAc,CACrB,OAAO,cAAc,CACrB,OAAO,mBAAmB,CAC1B,OAAO,mBAAmB"}
@@ -1,4 +1,4 @@
1
- const require_queryBuilder = require('../queryBuilder-n9ocnT4P.cjs');
1
+ const require_queryBuilder = require('../queryBuilder-okYHE7jd.cjs');
2
2
 
3
3
  //#region src/query/predicate.ts
4
4
  /**
@@ -1,3 +1,4 @@
1
+ const require_index = require('./index.cjs');
1
2
  let viem = require("viem");
2
3
 
3
4
  //#region src/query/errors.ts
@@ -1,4 +1,5 @@
1
1
  const require_consts = require('../consts-BV9DVKgE.cjs');
2
+ const require_index = require('../index.cjs');
2
3
  let viem = require("viem");
3
4
 
4
5
  //#region src/utils/expirationTime.ts
@@ -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","../../src/utils/payload.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;ECTP,SAAA,EAAA,CAAA,KAAa,EAAA,MAAA,EAAgB,GAAA,MAAA;EAI7B,UAAA,EAAA,CAAA,MAAe,EAAA,MAAA,EAAgB,GAAA,MAAA;mBDK5B;;;;iBCTH,aAAA,gBAA6B;iBAI7B,eAAA,gBAA+B"}
@@ -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,EAAgB,GAAA,MAAA;EAI7B,UAAA,EAAA,CAAA,MAAe,EAAA,MAAA,EAAgB,GAAA,MAAA;mBDK5B;;;;iBCTH,aAAA,gBAA6B;iBAI7B,eAAA,gBAA+B"}
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"}