@arkiv-network/sdk 0.3.2-dev.2 → 0.3.2-dev.4

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 (52) hide show
  1. package/README.md +12 -8
  2. package/dist/chains/index.cjs +1 -0
  3. package/dist/chains/index.d.cts +25 -25
  4. package/dist/chains/index.d.cts.map +1 -1
  5. package/dist/chains/index.d.ts +25 -25
  6. package/dist/{entity-BG8YycYJ.d.ts → entity-Bsvmepwv.d.cts} +25 -13
  7. package/dist/entity-Bsvmepwv.d.cts.map +1 -0
  8. package/dist/{entity-0JJeFAgO.d.cts → entity-ChTOBhd6.d.ts} +25 -13
  9. package/dist/entity-ChTOBhd6.d.ts.map +1 -0
  10. package/dist/index.cjs +40 -23
  11. package/dist/index.d.cts +3 -3
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +41 -24
  14. package/dist/index.js.map +1 -1
  15. package/dist/query/index.cjs +1 -1
  16. package/dist/query/index.d.cts +2 -2
  17. package/dist/query/index.d.ts +2 -2
  18. package/dist/query/index.js +1 -1
  19. package/dist/{queryBuilder-Dc_ii8LH.d.cts → queryBuilder-CNRqyot6.d.cts} +2 -2
  20. package/dist/{queryBuilder-Dc_ii8LH.d.cts.map → queryBuilder-CNRqyot6.d.cts.map} +1 -1
  21. package/dist/{queryBuilder-DEkfSiCF.cjs → queryBuilder-Cn5JJRMM.cjs} +79 -11
  22. package/dist/{queryBuilder-BNhnpewa.d.ts → queryBuilder-DI251Jjp.d.ts} +2 -2
  23. package/dist/{queryBuilder-BNhnpewa.d.ts.map → queryBuilder-DI251Jjp.d.ts.map} +1 -1
  24. package/dist/{queryBuilder-CAQ7TDMZ.js → queryBuilder-DVs4ZIyZ.js} +45 -13
  25. package/dist/queryBuilder-DVs4ZIyZ.js.map +1 -0
  26. package/dist/types/index.d.cts +1 -1
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/utils/index.cjs +1 -0
  29. package/package.json +4 -2
  30. package/src/actions/public/getBlockTiming.ts +4 -1
  31. package/src/actions/public/getEntity.ts +18 -3
  32. package/src/actions/public/subscribeEntityEvents.ts +6 -3
  33. package/src/actions/wallet/changeOwnership.ts +5 -2
  34. package/src/actions/wallet/createEntity.ts +8 -5
  35. package/src/actions/wallet/deleteEntity.ts +8 -5
  36. package/src/actions/wallet/extendEntity.ts +8 -5
  37. package/src/actions/wallet/mutateEntities.ts +8 -4
  38. package/src/actions/wallet/updateEntity.ts +8 -5
  39. package/src/clients/decorators/arkivWallet.ts +1 -1
  40. package/src/query/engine.test.ts +75 -0
  41. package/src/query/engine.ts +28 -9
  42. package/src/query/queryBuilder.test.ts +8 -0
  43. package/src/query/queryResult.ts +4 -1
  44. package/src/types/entity.ts +22 -10
  45. package/src/types/rpcSchema.ts +9 -1
  46. package/src/utils/arkivTransactions.ts +6 -3
  47. package/src/utils/compression.ts +7 -4
  48. package/src/utils/entities.ts +15 -2
  49. package/src/utils/logger.ts +13 -0
  50. package/dist/entity-0JJeFAgO.d.cts.map +0 -1
  51. package/dist/entity-BG8YycYJ.d.ts.map +0 -1
  52. package/dist/queryBuilder-CAQ7TDMZ.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,15 +1,16 @@
1
- const require_queryBuilder = require('./queryBuilder-DEkfSiCF.cjs');
1
+ const require_queryBuilder = require('./queryBuilder-Cn5JJRMM.cjs');
2
2
  const require_consts = require('./consts-BV9DVKgE.cjs');
3
3
  require('./types-CBTc19th.cjs');
4
4
  let viem = require("viem");
5
5
 
6
6
  //#region src/actions/public/getBlockTiming.ts
7
+ const logger$9 = require_queryBuilder.getLogger("actions:public:get-block-timing");
7
8
  async function getBlockTiming(client) {
8
9
  const blockTiming = await client.request({
9
10
  method: "arkiv_getBlockTiming",
10
11
  params: []
11
12
  });
12
- console.debug("Block timing", blockTiming);
13
+ logger$9("Block timing %o", blockTiming);
13
14
  return {
14
15
  currentBlock: blockTiming.current_block,
15
16
  currentBlockTime: blockTiming.current_block_time,
@@ -20,11 +21,18 @@ async function getBlockTiming(client) {
20
21
  //#endregion
21
22
  //#region src/actions/public/getEntity.ts
22
23
  async function getEntity(client, key) {
24
+ let bytes;
25
+ try {
26
+ bytes = (0, viem.hexToBytes)(key);
27
+ } catch {
28
+ throw new Error(`Invalid key format: ${key}. Key must be a valid hex string.`);
29
+ }
30
+ if (bytes.length !== 32) throw new Error(`Invalid key length: ${bytes.length} bytes. Key must be 32 bytes (64 hex characters) long.`);
31
+ const hexKey = (0, viem.bytesToHex)(bytes);
23
32
  const result = await client.request({
24
33
  method: "arkiv_query",
25
- params: [`$key = ${key}`]
34
+ params: [`$key = ${hexKey}`]
26
35
  });
27
- console.debug("GetEntity result", result);
28
36
  if (!result.data) throw new require_queryBuilder.NoEntityFoundError();
29
37
  return require_queryBuilder.entityFromRpcResult(result.data[0]);
30
38
  }
@@ -50,6 +58,7 @@ async function query(client, query$1) {
50
58
 
51
59
  //#endregion
52
60
  //#region src/actions/public/subscribeEntityEvents.ts
61
+ const logger$8 = require_queryBuilder.getLogger("actions:public:subscribe-entity-events");
53
62
  const arkivABI = (0, viem.parseAbi)([
54
63
  "event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
55
64
  "event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
@@ -64,14 +73,14 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
64
73
  fromBlock: fromBlock ?? 0n,
65
74
  events: arkivABI,
66
75
  onLogs: (logs) => {
67
- console.debug("logs from subscribeEntityEvents", logs);
76
+ logger$8("logs from subscribeEntityEvents %o", logs);
68
77
  for (const log of logs) {
69
78
  const event = (0, viem.decodeEventLog)({
70
79
  abi: arkivABI,
71
80
  topics: log.topics,
72
81
  data: log.data
73
82
  });
74
- console.debug("event from subscribeEntityEvents", event);
83
+ logger$8("event from subscribeEntityEvents %o", event);
75
84
  switch (event.eventName) {
76
85
  case "ArkivEntityCreated":
77
86
  onEntityCreated?.({
@@ -183,6 +192,7 @@ function createPublicClient(parameters) {
183
192
 
184
193
  //#endregion
185
194
  //#region src/utils/compression.ts
195
+ const logger$7 = require_queryBuilder.getLogger("utils:compression");
186
196
  const isNode = typeof process !== "undefined" && process.versions?.node != null;
187
197
  let zlib = null;
188
198
  let brotli = null;
@@ -208,14 +218,14 @@ async function getBrotli() {
208
218
  return brotli;
209
219
  }
210
220
  async function compress(data) {
211
- console.debug(`Compressing data (size: ${data.length})`);
221
+ logger$7("Compressing data size %d", data.length);
212
222
  if (isNode) {
213
223
  const zlibModule = await getZlib();
214
224
  if (zlibModule) try {
215
225
  const buffer = Buffer.from(data);
216
226
  const compressed = zlibModule.brotliCompressSync(buffer);
217
227
  const result = new Uint8Array(compressed);
218
- console.debug(`Brotli compressed with zlib (size: ${result.length})`);
228
+ logger$7("Brotli compressed with zlib size %d", result.length);
219
229
  return result;
220
230
  } catch (error) {
221
231
  console.warn("zlib compression failed, falling back to brotli-wasm", error);
@@ -227,12 +237,13 @@ async function compress(data) {
227
237
  return data;
228
238
  }
229
239
  const brotliCompressed = brotliInstance.compress(data);
230
- console.debug(`Brotli compressed with wasm (size: ${brotliCompressed.length})`);
240
+ logger$7("Brotli compressed with wasm size %d", brotliCompressed.length);
231
241
  return brotliCompressed;
232
242
  }
233
243
 
234
244
  //#endregion
235
245
  //#region src/utils/arkivTransactions.ts
246
+ const logger$6 = require_queryBuilder.getLogger("utils:arkiv-transactions");
236
247
  function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }) {
237
248
  function formatAttributes(attribute) {
238
249
  return [(0, viem.toHex)(attribute.key), (0, viem.toHex)(attribute.value)];
@@ -257,13 +268,13 @@ function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }
257
268
  (extensions ?? []).map((item) => [item.entityKey, (0, viem.toHex)(item.expiresIn / require_consts.BLOCK_TIME)]),
258
269
  (ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner])
259
270
  ];
260
- console.debug("txData to send as RLP", payload, payload.length);
271
+ logger$6("txData to send as RLP %o length %d", payload, payload.length);
261
272
  return (0, viem.toRlp)(payload);
262
273
  }
263
274
  async function sendArkivTransaction(client, data, txParams) {
264
275
  if (!client.account) throw new Error("Account required");
265
276
  const walletClient = client;
266
- console.debug("Sending transaction", {
277
+ logger$6("Sending transaction %o", {
267
278
  account: client.account,
268
279
  chain: client.chain,
269
280
  to: require_consts.ARKIV_ADDRESS,
@@ -281,16 +292,17 @@ async function sendArkivTransaction(client, data, txParams) {
281
292
  ...txParams
282
293
  });
283
294
  const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
284
- console.debug("Tx receipt", receipt);
295
+ logger$6("Tx receipt %o", receipt);
285
296
  return receipt;
286
297
  }
287
298
 
288
299
  //#endregion
289
300
  //#region src/actions/wallet/changeOwnership.ts
301
+ const logger$5 = require_queryBuilder.getLogger("actions:wallet:change-ownership");
290
302
  async function changeOwnership(client, data, txParams) {
291
- console.debug("changeOwnership", data);
303
+ logger$5("changeOwnership %o", data);
292
304
  const receipt = await sendArkivTransaction(client, opsToTxData({ ownershipChanges: [data] }), txParams);
293
- console.debug("Receipt from changeOwnership", receipt);
305
+ logger$5("Receipt from changeOwnership %o", receipt);
294
306
  return {
295
307
  txHash: receipt.transactionHash,
296
308
  entityKey: data.entityKey
@@ -299,10 +311,11 @@ async function changeOwnership(client, data, txParams) {
299
311
 
300
312
  //#endregion
301
313
  //#region src/actions/wallet/createEntity.ts
314
+ const logger$4 = require_queryBuilder.getLogger("actions:wallet:create-entity");
302
315
  async function createEntity(client, data, txParams) {
303
- console.debug("createEntity", data);
316
+ logger$4("createEntity %o", data);
304
317
  const receipt = await sendArkivTransaction(client, opsToTxData({ creates: [data] }), txParams);
305
- console.debug("Receipt from createEntity", receipt);
318
+ logger$4("Receipt from createEntity %o", receipt);
306
319
  return {
307
320
  txHash: receipt.transactionHash,
308
321
  entityKey: receipt.logs[0].topics[1]
@@ -311,10 +324,11 @@ async function createEntity(client, data, txParams) {
311
324
 
312
325
  //#endregion
313
326
  //#region src/actions/wallet/deleteEntity.ts
327
+ const logger$3 = require_queryBuilder.getLogger("actions:wallet:delete-entity");
314
328
  async function deleteEntity(client, data, txParams) {
315
- console.debug("deleteEntity", data);
329
+ logger$3("deleteEntity %o", data);
316
330
  const receipt = await sendArkivTransaction(client, opsToTxData({ deletes: [data] }), txParams);
317
- console.debug("Receipt from deleteEntity", receipt);
331
+ logger$3("Receipt from deleteEntity %o", receipt);
318
332
  return {
319
333
  txHash: receipt.transactionHash,
320
334
  entityKey: data.entityKey
@@ -323,10 +337,11 @@ async function deleteEntity(client, data, txParams) {
323
337
 
324
338
  //#endregion
325
339
  //#region src/actions/wallet/extendEntity.ts
340
+ const logger$2 = require_queryBuilder.getLogger("actions:wallet:extend-entity");
326
341
  async function extendEntity(client, data, txParams) {
327
- console.debug("extendEntity", data);
342
+ logger$2("extendEntity %o", data);
328
343
  const receipt = await sendArkivTransaction(client, opsToTxData({ extensions: [data] }), txParams);
329
- console.debug("Receipt from extendEntity", receipt);
344
+ logger$2("Receipt from extendEntity %o", receipt);
330
345
  return {
331
346
  txHash: receipt.transactionHash,
332
347
  entityKey: receipt.logs[0].topics[1]
@@ -335,6 +350,7 @@ async function extendEntity(client, data, txParams) {
335
350
 
336
351
  //#endregion
337
352
  //#region src/actions/wallet/mutateEntities.ts
353
+ const logger$1 = require_queryBuilder.getLogger("actions:wallet:mutate-entities");
338
354
  function parseReceipt(receipt, params) {
339
355
  const createdEntities = [];
340
356
  const updatedEntities = [];
@@ -372,7 +388,7 @@ async function mutateEntities(client, data, txParams) {
372
388
  extensions: data.extensions ?? [],
373
389
  ownershipChanges: data.ownershipChanges ?? []
374
390
  }), txParams);
375
- console.debug("Receipt from mutateEntities", receipt);
391
+ logger$1("Receipt from mutateEntities %o", receipt);
376
392
  const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } = parseReceipt(receipt, data);
377
393
  return {
378
394
  txHash: receipt.transactionHash,
@@ -386,10 +402,11 @@ async function mutateEntities(client, data, txParams) {
386
402
 
387
403
  //#endregion
388
404
  //#region src/actions/wallet/updateEntity.ts
405
+ const logger = require_queryBuilder.getLogger("actions:wallet:update-entity");
389
406
  async function updateEntity(client, data, txParams) {
390
- console.debug("updateEntity", data);
407
+ logger("updateEntity %o", data);
391
408
  const receipt = await sendArkivTransaction(client, opsToTxData({ updates: [data] }), txParams);
392
- console.debug("Receipt from updateEntity", receipt);
409
+ logger("Receipt from updateEntity %o", receipt);
393
410
  return {
394
411
  txHash: receipt.transactionHash,
395
412
  entityKey: receipt.logs[0].topics[1]
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, g as ArkivClient, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "./entity-0JJeFAgO.cjs";
2
- import { t as QueryBuilder } from "./queryBuilder-Dc_ii8LH.cjs";
1
+ import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, g as ArkivClient, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "./entity-Bsvmepwv.cjs";
2
+ import { t as QueryBuilder } from "./queryBuilder-CNRqyot6.cjs";
3
3
  import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
4
4
  export * from "viem";
5
5
 
@@ -293,7 +293,7 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
293
293
  * Mutates the entities with the given keys.
294
294
  *
295
295
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
296
- * - JSON-RPC Methods: [`golembase_mutateEntities`](https://docs.arkiv.network/dev/json-rpc-api/#golembase_mutateEntities)
296
+ * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
297
297
  *
298
298
  * @param args - {data}
299
299
  * @returns The entity with the given key. {@link Entity}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, g as ArkivClient, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "./entity-BG8YycYJ.js";
2
- import { t as QueryBuilder } from "./queryBuilder-BNhnpewa.js";
1
+ import { _ as ArkivRpcSchema, a as MutateEntitiesReturnType, b as RpcQueryOptions, c as ExtendEntityParameters, d as DeleteEntityReturnType, f as CreateEntityParameters, g as ArkivClient, h as ChangeOwnershipReturnType, i as MutateEntitiesParameters, l as ExtendEntityReturnType, m as ChangeOwnershipParameters, n as TxParams, o as UpdateEntityParameters, p as CreateEntityReturnType, r as Attribute, s as UpdateEntityReturnType, t as Entity, u as DeleteEntityParameters, v as RpcEntity, x as MimeType, y as RpcIncludeData } from "./entity-ChTOBhd6.js";
2
+ import { t as QueryBuilder } from "./queryBuilder-DI251Jjp.js";
3
3
  import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
4
4
  export * from "viem";
5
5
 
@@ -293,7 +293,7 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
293
293
  * Mutates the entities with the given keys.
294
294
  *
295
295
  * - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
296
- * - JSON-RPC Methods: [`golembase_mutateEntities`](https://docs.arkiv.network/dev/json-rpc-api/#golembase_mutateEntities)
296
+ * - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
297
297
  *
298
298
  * @param args - {data}
299
299
  * @returns The entity with the given key. {@link Entity}
package/dist/index.js CHANGED
@@ -1,17 +1,18 @@
1
- import { a as entityFromRpcResult, s as NoEntityFoundError, t as QueryBuilder } from "./queryBuilder-CAQ7TDMZ.js";
1
+ import { a as entityFromRpcResult, s as NoEntityFoundError, t as QueryBuilder, u as getLogger } from "./queryBuilder-DVs4ZIyZ.js";
2
2
  import { n as BLOCK_TIME, t as ARKIV_ADDRESS } from "./consts-CHtLBwGd.js";
3
3
  import "./types-Cv8NMtbo.js";
4
- import { createClient, decodeEventLog, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
4
+ import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
5
5
 
6
6
  export * from "viem"
7
7
 
8
8
  //#region src/actions/public/getBlockTiming.ts
9
+ const logger$9 = getLogger("actions:public:get-block-timing");
9
10
  async function getBlockTiming(client) {
10
11
  const blockTiming = await client.request({
11
12
  method: "arkiv_getBlockTiming",
12
13
  params: []
13
14
  });
14
- console.debug("Block timing", blockTiming);
15
+ logger$9("Block timing %o", blockTiming);
15
16
  return {
16
17
  currentBlock: blockTiming.current_block,
17
18
  currentBlockTime: blockTiming.current_block_time,
@@ -22,11 +23,18 @@ async function getBlockTiming(client) {
22
23
  //#endregion
23
24
  //#region src/actions/public/getEntity.ts
24
25
  async function getEntity(client, key) {
26
+ let bytes;
27
+ try {
28
+ bytes = hexToBytes(key);
29
+ } catch {
30
+ throw new Error(`Invalid key format: ${key}. Key must be a valid hex string.`);
31
+ }
32
+ if (bytes.length !== 32) throw new Error(`Invalid key length: ${bytes.length} bytes. Key must be 32 bytes (64 hex characters) long.`);
33
+ const hexKey = bytesToHex(bytes);
25
34
  const result = await client.request({
26
35
  method: "arkiv_query",
27
- params: [`$key = ${key}`]
36
+ params: [`$key = ${hexKey}`]
28
37
  });
29
- console.debug("GetEntity result", result);
30
38
  if (!result.data) throw new NoEntityFoundError();
31
39
  return entityFromRpcResult(result.data[0]);
32
40
  }
@@ -52,6 +60,7 @@ async function query(client, query$1) {
52
60
 
53
61
  //#endregion
54
62
  //#region src/actions/public/subscribeEntityEvents.ts
63
+ const logger$8 = getLogger("actions:public:subscribe-entity-events");
55
64
  const arkivABI = parseAbi([
56
65
  "event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
57
66
  "event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
@@ -66,14 +75,14 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
66
75
  fromBlock: fromBlock ?? 0n,
67
76
  events: arkivABI,
68
77
  onLogs: (logs) => {
69
- console.debug("logs from subscribeEntityEvents", logs);
78
+ logger$8("logs from subscribeEntityEvents %o", logs);
70
79
  for (const log of logs) {
71
80
  const event = decodeEventLog({
72
81
  abi: arkivABI,
73
82
  topics: log.topics,
74
83
  data: log.data
75
84
  });
76
- console.debug("event from subscribeEntityEvents", event);
85
+ logger$8("event from subscribeEntityEvents %o", event);
77
86
  switch (event.eventName) {
78
87
  case "ArkivEntityCreated":
79
88
  onEntityCreated?.({
@@ -185,6 +194,7 @@ function createPublicClient(parameters) {
185
194
 
186
195
  //#endregion
187
196
  //#region src/utils/compression.ts
197
+ const logger$7 = getLogger("utils:compression");
188
198
  const isNode = typeof process !== "undefined" && process.versions?.node != null;
189
199
  let zlib = null;
190
200
  let brotli = null;
@@ -210,14 +220,14 @@ async function getBrotli() {
210
220
  return brotli;
211
221
  }
212
222
  async function compress(data) {
213
- console.debug(`Compressing data (size: ${data.length})`);
223
+ logger$7("Compressing data size %d", data.length);
214
224
  if (isNode) {
215
225
  const zlibModule = await getZlib();
216
226
  if (zlibModule) try {
217
227
  const buffer = Buffer.from(data);
218
228
  const compressed = zlibModule.brotliCompressSync(buffer);
219
229
  const result = new Uint8Array(compressed);
220
- console.debug(`Brotli compressed with zlib (size: ${result.length})`);
230
+ logger$7("Brotli compressed with zlib size %d", result.length);
221
231
  return result;
222
232
  } catch (error) {
223
233
  console.warn("zlib compression failed, falling back to brotli-wasm", error);
@@ -229,12 +239,13 @@ async function compress(data) {
229
239
  return data;
230
240
  }
231
241
  const brotliCompressed = brotliInstance.compress(data);
232
- console.debug(`Brotli compressed with wasm (size: ${brotliCompressed.length})`);
242
+ logger$7("Brotli compressed with wasm size %d", brotliCompressed.length);
233
243
  return brotliCompressed;
234
244
  }
235
245
 
236
246
  //#endregion
237
247
  //#region src/utils/arkivTransactions.ts
248
+ const logger$6 = getLogger("utils:arkiv-transactions");
238
249
  function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }) {
239
250
  function formatAttributes(attribute) {
240
251
  return [toHex(attribute.key), toHex(attribute.value)];
@@ -259,13 +270,13 @@ function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }
259
270
  (extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),
260
271
  (ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner])
261
272
  ];
262
- console.debug("txData to send as RLP", payload, payload.length);
273
+ logger$6("txData to send as RLP %o length %d", payload, payload.length);
263
274
  return toRlp(payload);
264
275
  }
265
276
  async function sendArkivTransaction(client, data, txParams) {
266
277
  if (!client.account) throw new Error("Account required");
267
278
  const walletClient = client;
268
- console.debug("Sending transaction", {
279
+ logger$6("Sending transaction %o", {
269
280
  account: client.account,
270
281
  chain: client.chain,
271
282
  to: ARKIV_ADDRESS,
@@ -283,16 +294,17 @@ async function sendArkivTransaction(client, data, txParams) {
283
294
  ...txParams
284
295
  });
285
296
  const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
286
- console.debug("Tx receipt", receipt);
297
+ logger$6("Tx receipt %o", receipt);
287
298
  return receipt;
288
299
  }
289
300
 
290
301
  //#endregion
291
302
  //#region src/actions/wallet/changeOwnership.ts
303
+ const logger$5 = getLogger("actions:wallet:change-ownership");
292
304
  async function changeOwnership(client, data, txParams) {
293
- console.debug("changeOwnership", data);
305
+ logger$5("changeOwnership %o", data);
294
306
  const receipt = await sendArkivTransaction(client, opsToTxData({ ownershipChanges: [data] }), txParams);
295
- console.debug("Receipt from changeOwnership", receipt);
307
+ logger$5("Receipt from changeOwnership %o", receipt);
296
308
  return {
297
309
  txHash: receipt.transactionHash,
298
310
  entityKey: data.entityKey
@@ -301,10 +313,11 @@ async function changeOwnership(client, data, txParams) {
301
313
 
302
314
  //#endregion
303
315
  //#region src/actions/wallet/createEntity.ts
316
+ const logger$4 = getLogger("actions:wallet:create-entity");
304
317
  async function createEntity(client, data, txParams) {
305
- console.debug("createEntity", data);
318
+ logger$4("createEntity %o", data);
306
319
  const receipt = await sendArkivTransaction(client, opsToTxData({ creates: [data] }), txParams);
307
- console.debug("Receipt from createEntity", receipt);
320
+ logger$4("Receipt from createEntity %o", receipt);
308
321
  return {
309
322
  txHash: receipt.transactionHash,
310
323
  entityKey: receipt.logs[0].topics[1]
@@ -313,10 +326,11 @@ async function createEntity(client, data, txParams) {
313
326
 
314
327
  //#endregion
315
328
  //#region src/actions/wallet/deleteEntity.ts
329
+ const logger$3 = getLogger("actions:wallet:delete-entity");
316
330
  async function deleteEntity(client, data, txParams) {
317
- console.debug("deleteEntity", data);
331
+ logger$3("deleteEntity %o", data);
318
332
  const receipt = await sendArkivTransaction(client, opsToTxData({ deletes: [data] }), txParams);
319
- console.debug("Receipt from deleteEntity", receipt);
333
+ logger$3("Receipt from deleteEntity %o", receipt);
320
334
  return {
321
335
  txHash: receipt.transactionHash,
322
336
  entityKey: data.entityKey
@@ -325,10 +339,11 @@ async function deleteEntity(client, data, txParams) {
325
339
 
326
340
  //#endregion
327
341
  //#region src/actions/wallet/extendEntity.ts
342
+ const logger$2 = getLogger("actions:wallet:extend-entity");
328
343
  async function extendEntity(client, data, txParams) {
329
- console.debug("extendEntity", data);
344
+ logger$2("extendEntity %o", data);
330
345
  const receipt = await sendArkivTransaction(client, opsToTxData({ extensions: [data] }), txParams);
331
- console.debug("Receipt from extendEntity", receipt);
346
+ logger$2("Receipt from extendEntity %o", receipt);
332
347
  return {
333
348
  txHash: receipt.transactionHash,
334
349
  entityKey: receipt.logs[0].topics[1]
@@ -337,6 +352,7 @@ async function extendEntity(client, data, txParams) {
337
352
 
338
353
  //#endregion
339
354
  //#region src/actions/wallet/mutateEntities.ts
355
+ const logger$1 = getLogger("actions:wallet:mutate-entities");
340
356
  function parseReceipt(receipt, params) {
341
357
  const createdEntities = [];
342
358
  const updatedEntities = [];
@@ -374,7 +390,7 @@ async function mutateEntities(client, data, txParams) {
374
390
  extensions: data.extensions ?? [],
375
391
  ownershipChanges: data.ownershipChanges ?? []
376
392
  }), txParams);
377
- console.debug("Receipt from mutateEntities", receipt);
393
+ logger$1("Receipt from mutateEntities %o", receipt);
378
394
  const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } = parseReceipt(receipt, data);
379
395
  return {
380
396
  txHash: receipt.transactionHash,
@@ -388,10 +404,11 @@ async function mutateEntities(client, data, txParams) {
388
404
 
389
405
  //#endregion
390
406
  //#region src/actions/wallet/updateEntity.ts
407
+ const logger = getLogger("actions:wallet:update-entity");
391
408
  async function updateEntity(client, data, txParams) {
392
- console.debug("updateEntity", data);
409
+ logger("updateEntity %o", data);
393
410
  const receipt = await sendArkivTransaction(client, opsToTxData({ updates: [data] }), txParams);
394
- console.debug("Receipt from updateEntity", receipt);
411
+ logger("Receipt from updateEntity %o", receipt);
395
412
  return {
396
413
  txHash: receipt.transactionHash,
397
414
  entityKey: receipt.logs[0].topics[1]