@arkiv-network/sdk 0.3.2-dev.3 → 0.4.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -13
- package/dist/chains/index.cjs +26 -1
- package/dist/chains/index.d.cts +44 -1
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +69 -26
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +24 -1
- package/dist/chains/index.js.map +1 -1
- package/dist/{entity-BG8YycYJ.d.ts → entity-Bsvmepwv.d.cts} +25 -13
- package/dist/entity-Bsvmepwv.d.cts.map +1 -0
- package/dist/{entity-0JJeFAgO.d.cts → entity-ChTOBhd6.d.ts} +25 -13
- package/dist/entity-ChTOBhd6.d.ts.map +1 -0
- package/dist/index.cjs +31 -21
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +31 -21
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +1 -1
- package/dist/query/index.d.cts +2 -2
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +1 -1
- package/dist/{queryBuilder-Dc_ii8LH.d.cts → queryBuilder-CNRqyot6.d.cts} +2 -2
- package/dist/{queryBuilder-Dc_ii8LH.d.cts.map → queryBuilder-CNRqyot6.d.cts.map} +1 -1
- package/dist/{queryBuilder-DEkfSiCF.cjs → queryBuilder-Cn5JJRMM.cjs} +79 -11
- package/dist/{queryBuilder-BNhnpewa.d.ts → queryBuilder-DI251Jjp.d.ts} +2 -2
- package/dist/{queryBuilder-BNhnpewa.d.ts.map → queryBuilder-DI251Jjp.d.ts.map} +1 -1
- package/dist/{queryBuilder-CAQ7TDMZ.js → queryBuilder-DVs4ZIyZ.js} +45 -13
- package/dist/queryBuilder-DVs4ZIyZ.js.map +1 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts.map +1 -1
- package/package.json +4 -2
- package/src/actions/public/getBlockTiming.ts +4 -1
- package/src/actions/public/subscribeEntityEvents.ts +6 -3
- package/src/actions/wallet/changeOwnership.ts +5 -2
- package/src/actions/wallet/createEntity.ts +8 -5
- package/src/actions/wallet/deleteEntity.ts +8 -5
- package/src/actions/wallet/extendEntity.ts +8 -5
- package/src/actions/wallet/mutateEntities.ts +8 -4
- package/src/actions/wallet/updateEntity.ts +8 -5
- package/src/chains/index.ts +1 -0
- package/src/chains/mendoza.ts +26 -0
- package/src/clients/decorators/arkivWallet.ts +1 -1
- package/src/query/engine.test.ts +75 -0
- package/src/query/engine.ts +28 -9
- package/src/query/queryBuilder.test.ts +8 -0
- package/src/query/queryResult.ts +4 -1
- package/src/types/entity.ts +22 -10
- package/src/types/rpcSchema.ts +9 -1
- package/src/utils/arkivTransactions.ts +6 -3
- package/src/utils/compression.ts +7 -4
- package/src/utils/entities.ts +15 -2
- package/src/utils/logger.ts +13 -0
- package/dist/entity-0JJeFAgO.d.cts.map +0 -1
- package/dist/entity-BG8YycYJ.d.ts.map +0 -1
- package/dist/queryBuilder-CAQ7TDMZ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
const require_queryBuilder = require('./queryBuilder-
|
|
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
|
-
|
|
13
|
+
logger$9("Block timing %o", blockTiming);
|
|
13
14
|
return {
|
|
14
15
|
currentBlock: blockTiming.current_block,
|
|
15
16
|
currentBlockTime: blockTiming.current_block_time,
|
|
@@ -57,6 +58,7 @@ async function query(client, query$1) {
|
|
|
57
58
|
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region src/actions/public/subscribeEntityEvents.ts
|
|
61
|
+
const logger$8 = require_queryBuilder.getLogger("actions:public:subscribe-entity-events");
|
|
60
62
|
const arkivABI = (0, viem.parseAbi)([
|
|
61
63
|
"event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
|
|
62
64
|
"event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
|
|
@@ -71,14 +73,14 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
|
|
|
71
73
|
fromBlock: fromBlock ?? 0n,
|
|
72
74
|
events: arkivABI,
|
|
73
75
|
onLogs: (logs) => {
|
|
74
|
-
|
|
76
|
+
logger$8("logs from subscribeEntityEvents %o", logs);
|
|
75
77
|
for (const log of logs) {
|
|
76
78
|
const event = (0, viem.decodeEventLog)({
|
|
77
79
|
abi: arkivABI,
|
|
78
80
|
topics: log.topics,
|
|
79
81
|
data: log.data
|
|
80
82
|
});
|
|
81
|
-
|
|
83
|
+
logger$8("event from subscribeEntityEvents %o", event);
|
|
82
84
|
switch (event.eventName) {
|
|
83
85
|
case "ArkivEntityCreated":
|
|
84
86
|
onEntityCreated?.({
|
|
@@ -190,6 +192,7 @@ function createPublicClient(parameters) {
|
|
|
190
192
|
|
|
191
193
|
//#endregion
|
|
192
194
|
//#region src/utils/compression.ts
|
|
195
|
+
const logger$7 = require_queryBuilder.getLogger("utils:compression");
|
|
193
196
|
const isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
194
197
|
let zlib = null;
|
|
195
198
|
let brotli = null;
|
|
@@ -215,14 +218,14 @@ async function getBrotli() {
|
|
|
215
218
|
return brotli;
|
|
216
219
|
}
|
|
217
220
|
async function compress(data) {
|
|
218
|
-
|
|
221
|
+
logger$7("Compressing data size %d", data.length);
|
|
219
222
|
if (isNode) {
|
|
220
223
|
const zlibModule = await getZlib();
|
|
221
224
|
if (zlibModule) try {
|
|
222
225
|
const buffer = Buffer.from(data);
|
|
223
226
|
const compressed = zlibModule.brotliCompressSync(buffer);
|
|
224
227
|
const result = new Uint8Array(compressed);
|
|
225
|
-
|
|
228
|
+
logger$7("Brotli compressed with zlib size %d", result.length);
|
|
226
229
|
return result;
|
|
227
230
|
} catch (error) {
|
|
228
231
|
console.warn("zlib compression failed, falling back to brotli-wasm", error);
|
|
@@ -234,12 +237,13 @@ async function compress(data) {
|
|
|
234
237
|
return data;
|
|
235
238
|
}
|
|
236
239
|
const brotliCompressed = brotliInstance.compress(data);
|
|
237
|
-
|
|
240
|
+
logger$7("Brotli compressed with wasm size %d", brotliCompressed.length);
|
|
238
241
|
return brotliCompressed;
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
//#endregion
|
|
242
245
|
//#region src/utils/arkivTransactions.ts
|
|
246
|
+
const logger$6 = require_queryBuilder.getLogger("utils:arkiv-transactions");
|
|
243
247
|
function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }) {
|
|
244
248
|
function formatAttributes(attribute) {
|
|
245
249
|
return [(0, viem.toHex)(attribute.key), (0, viem.toHex)(attribute.value)];
|
|
@@ -264,13 +268,13 @@ function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }
|
|
|
264
268
|
(extensions ?? []).map((item) => [item.entityKey, (0, viem.toHex)(item.expiresIn / require_consts.BLOCK_TIME)]),
|
|
265
269
|
(ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner])
|
|
266
270
|
];
|
|
267
|
-
|
|
271
|
+
logger$6("txData to send as RLP %o length %d", payload, payload.length);
|
|
268
272
|
return (0, viem.toRlp)(payload);
|
|
269
273
|
}
|
|
270
274
|
async function sendArkivTransaction(client, data, txParams) {
|
|
271
275
|
if (!client.account) throw new Error("Account required");
|
|
272
276
|
const walletClient = client;
|
|
273
|
-
|
|
277
|
+
logger$6("Sending transaction %o", {
|
|
274
278
|
account: client.account,
|
|
275
279
|
chain: client.chain,
|
|
276
280
|
to: require_consts.ARKIV_ADDRESS,
|
|
@@ -288,16 +292,17 @@ async function sendArkivTransaction(client, data, txParams) {
|
|
|
288
292
|
...txParams
|
|
289
293
|
});
|
|
290
294
|
const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
|
|
291
|
-
|
|
295
|
+
logger$6("Tx receipt %o", receipt);
|
|
292
296
|
return receipt;
|
|
293
297
|
}
|
|
294
298
|
|
|
295
299
|
//#endregion
|
|
296
300
|
//#region src/actions/wallet/changeOwnership.ts
|
|
301
|
+
const logger$5 = require_queryBuilder.getLogger("actions:wallet:change-ownership");
|
|
297
302
|
async function changeOwnership(client, data, txParams) {
|
|
298
|
-
|
|
303
|
+
logger$5("changeOwnership %o", data);
|
|
299
304
|
const receipt = await sendArkivTransaction(client, opsToTxData({ ownershipChanges: [data] }), txParams);
|
|
300
|
-
|
|
305
|
+
logger$5("Receipt from changeOwnership %o", receipt);
|
|
301
306
|
return {
|
|
302
307
|
txHash: receipt.transactionHash,
|
|
303
308
|
entityKey: data.entityKey
|
|
@@ -306,10 +311,11 @@ async function changeOwnership(client, data, txParams) {
|
|
|
306
311
|
|
|
307
312
|
//#endregion
|
|
308
313
|
//#region src/actions/wallet/createEntity.ts
|
|
314
|
+
const logger$4 = require_queryBuilder.getLogger("actions:wallet:create-entity");
|
|
309
315
|
async function createEntity(client, data, txParams) {
|
|
310
|
-
|
|
316
|
+
logger$4("createEntity %o", data);
|
|
311
317
|
const receipt = await sendArkivTransaction(client, opsToTxData({ creates: [data] }), txParams);
|
|
312
|
-
|
|
318
|
+
logger$4("Receipt from createEntity %o", receipt);
|
|
313
319
|
return {
|
|
314
320
|
txHash: receipt.transactionHash,
|
|
315
321
|
entityKey: receipt.logs[0].topics[1]
|
|
@@ -318,10 +324,11 @@ async function createEntity(client, data, txParams) {
|
|
|
318
324
|
|
|
319
325
|
//#endregion
|
|
320
326
|
//#region src/actions/wallet/deleteEntity.ts
|
|
327
|
+
const logger$3 = require_queryBuilder.getLogger("actions:wallet:delete-entity");
|
|
321
328
|
async function deleteEntity(client, data, txParams) {
|
|
322
|
-
|
|
329
|
+
logger$3("deleteEntity %o", data);
|
|
323
330
|
const receipt = await sendArkivTransaction(client, opsToTxData({ deletes: [data] }), txParams);
|
|
324
|
-
|
|
331
|
+
logger$3("Receipt from deleteEntity %o", receipt);
|
|
325
332
|
return {
|
|
326
333
|
txHash: receipt.transactionHash,
|
|
327
334
|
entityKey: data.entityKey
|
|
@@ -330,10 +337,11 @@ async function deleteEntity(client, data, txParams) {
|
|
|
330
337
|
|
|
331
338
|
//#endregion
|
|
332
339
|
//#region src/actions/wallet/extendEntity.ts
|
|
340
|
+
const logger$2 = require_queryBuilder.getLogger("actions:wallet:extend-entity");
|
|
333
341
|
async function extendEntity(client, data, txParams) {
|
|
334
|
-
|
|
342
|
+
logger$2("extendEntity %o", data);
|
|
335
343
|
const receipt = await sendArkivTransaction(client, opsToTxData({ extensions: [data] }), txParams);
|
|
336
|
-
|
|
344
|
+
logger$2("Receipt from extendEntity %o", receipt);
|
|
337
345
|
return {
|
|
338
346
|
txHash: receipt.transactionHash,
|
|
339
347
|
entityKey: receipt.logs[0].topics[1]
|
|
@@ -342,6 +350,7 @@ async function extendEntity(client, data, txParams) {
|
|
|
342
350
|
|
|
343
351
|
//#endregion
|
|
344
352
|
//#region src/actions/wallet/mutateEntities.ts
|
|
353
|
+
const logger$1 = require_queryBuilder.getLogger("actions:wallet:mutate-entities");
|
|
345
354
|
function parseReceipt(receipt, params) {
|
|
346
355
|
const createdEntities = [];
|
|
347
356
|
const updatedEntities = [];
|
|
@@ -379,7 +388,7 @@ async function mutateEntities(client, data, txParams) {
|
|
|
379
388
|
extensions: data.extensions ?? [],
|
|
380
389
|
ownershipChanges: data.ownershipChanges ?? []
|
|
381
390
|
}), txParams);
|
|
382
|
-
|
|
391
|
+
logger$1("Receipt from mutateEntities %o", receipt);
|
|
383
392
|
const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } = parseReceipt(receipt, data);
|
|
384
393
|
return {
|
|
385
394
|
txHash: receipt.transactionHash,
|
|
@@ -393,10 +402,11 @@ async function mutateEntities(client, data, txParams) {
|
|
|
393
402
|
|
|
394
403
|
//#endregion
|
|
395
404
|
//#region src/actions/wallet/updateEntity.ts
|
|
405
|
+
const logger = require_queryBuilder.getLogger("actions:wallet:update-entity");
|
|
396
406
|
async function updateEntity(client, data, txParams) {
|
|
397
|
-
|
|
407
|
+
logger("updateEntity %o", data);
|
|
398
408
|
const receipt = await sendArkivTransaction(client, opsToTxData({ updates: [data] }), txParams);
|
|
399
|
-
|
|
409
|
+
logger("Receipt from updateEntity %o", receipt);
|
|
400
410
|
return {
|
|
401
411
|
txHash: receipt.transactionHash,
|
|
402
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-
|
|
2
|
-
import { t as QueryBuilder } from "./queryBuilder-
|
|
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: [`
|
|
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-
|
|
2
|
-
import { t as QueryBuilder } from "./queryBuilder-
|
|
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: [`
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { a as entityFromRpcResult, s as NoEntityFoundError, t as QueryBuilder } from "./queryBuilder-
|
|
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
4
|
import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
|
|
@@ -6,12 +6,13 @@ import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicA
|
|
|
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
|
-
|
|
15
|
+
logger$9("Block timing %o", blockTiming);
|
|
15
16
|
return {
|
|
16
17
|
currentBlock: blockTiming.current_block,
|
|
17
18
|
currentBlockTime: blockTiming.current_block_time,
|
|
@@ -59,6 +60,7 @@ async function query(client, query$1) {
|
|
|
59
60
|
|
|
60
61
|
//#endregion
|
|
61
62
|
//#region src/actions/public/subscribeEntityEvents.ts
|
|
63
|
+
const logger$8 = getLogger("actions:public:subscribe-entity-events");
|
|
62
64
|
const arkivABI = parseAbi([
|
|
63
65
|
"event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
|
|
64
66
|
"event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
|
|
@@ -73,14 +75,14 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
|
|
|
73
75
|
fromBlock: fromBlock ?? 0n,
|
|
74
76
|
events: arkivABI,
|
|
75
77
|
onLogs: (logs) => {
|
|
76
|
-
|
|
78
|
+
logger$8("logs from subscribeEntityEvents %o", logs);
|
|
77
79
|
for (const log of logs) {
|
|
78
80
|
const event = decodeEventLog({
|
|
79
81
|
abi: arkivABI,
|
|
80
82
|
topics: log.topics,
|
|
81
83
|
data: log.data
|
|
82
84
|
});
|
|
83
|
-
|
|
85
|
+
logger$8("event from subscribeEntityEvents %o", event);
|
|
84
86
|
switch (event.eventName) {
|
|
85
87
|
case "ArkivEntityCreated":
|
|
86
88
|
onEntityCreated?.({
|
|
@@ -192,6 +194,7 @@ function createPublicClient(parameters) {
|
|
|
192
194
|
|
|
193
195
|
//#endregion
|
|
194
196
|
//#region src/utils/compression.ts
|
|
197
|
+
const logger$7 = getLogger("utils:compression");
|
|
195
198
|
const isNode = typeof process !== "undefined" && process.versions?.node != null;
|
|
196
199
|
let zlib = null;
|
|
197
200
|
let brotli = null;
|
|
@@ -217,14 +220,14 @@ async function getBrotli() {
|
|
|
217
220
|
return brotli;
|
|
218
221
|
}
|
|
219
222
|
async function compress(data) {
|
|
220
|
-
|
|
223
|
+
logger$7("Compressing data size %d", data.length);
|
|
221
224
|
if (isNode) {
|
|
222
225
|
const zlibModule = await getZlib();
|
|
223
226
|
if (zlibModule) try {
|
|
224
227
|
const buffer = Buffer.from(data);
|
|
225
228
|
const compressed = zlibModule.brotliCompressSync(buffer);
|
|
226
229
|
const result = new Uint8Array(compressed);
|
|
227
|
-
|
|
230
|
+
logger$7("Brotli compressed with zlib size %d", result.length);
|
|
228
231
|
return result;
|
|
229
232
|
} catch (error) {
|
|
230
233
|
console.warn("zlib compression failed, falling back to brotli-wasm", error);
|
|
@@ -236,12 +239,13 @@ async function compress(data) {
|
|
|
236
239
|
return data;
|
|
237
240
|
}
|
|
238
241
|
const brotliCompressed = brotliInstance.compress(data);
|
|
239
|
-
|
|
242
|
+
logger$7("Brotli compressed with wasm size %d", brotliCompressed.length);
|
|
240
243
|
return brotliCompressed;
|
|
241
244
|
}
|
|
242
245
|
|
|
243
246
|
//#endregion
|
|
244
247
|
//#region src/utils/arkivTransactions.ts
|
|
248
|
+
const logger$6 = getLogger("utils:arkiv-transactions");
|
|
245
249
|
function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }) {
|
|
246
250
|
function formatAttributes(attribute) {
|
|
247
251
|
return [toHex(attribute.key), toHex(attribute.value)];
|
|
@@ -266,13 +270,13 @@ function opsToTxData({ creates, updates, deletes, extensions, ownershipChanges }
|
|
|
266
270
|
(extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),
|
|
267
271
|
(ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner])
|
|
268
272
|
];
|
|
269
|
-
|
|
273
|
+
logger$6("txData to send as RLP %o length %d", payload, payload.length);
|
|
270
274
|
return toRlp(payload);
|
|
271
275
|
}
|
|
272
276
|
async function sendArkivTransaction(client, data, txParams) {
|
|
273
277
|
if (!client.account) throw new Error("Account required");
|
|
274
278
|
const walletClient = client;
|
|
275
|
-
|
|
279
|
+
logger$6("Sending transaction %o", {
|
|
276
280
|
account: client.account,
|
|
277
281
|
chain: client.chain,
|
|
278
282
|
to: ARKIV_ADDRESS,
|
|
@@ -290,16 +294,17 @@ async function sendArkivTransaction(client, data, txParams) {
|
|
|
290
294
|
...txParams
|
|
291
295
|
});
|
|
292
296
|
const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
|
|
293
|
-
|
|
297
|
+
logger$6("Tx receipt %o", receipt);
|
|
294
298
|
return receipt;
|
|
295
299
|
}
|
|
296
300
|
|
|
297
301
|
//#endregion
|
|
298
302
|
//#region src/actions/wallet/changeOwnership.ts
|
|
303
|
+
const logger$5 = getLogger("actions:wallet:change-ownership");
|
|
299
304
|
async function changeOwnership(client, data, txParams) {
|
|
300
|
-
|
|
305
|
+
logger$5("changeOwnership %o", data);
|
|
301
306
|
const receipt = await sendArkivTransaction(client, opsToTxData({ ownershipChanges: [data] }), txParams);
|
|
302
|
-
|
|
307
|
+
logger$5("Receipt from changeOwnership %o", receipt);
|
|
303
308
|
return {
|
|
304
309
|
txHash: receipt.transactionHash,
|
|
305
310
|
entityKey: data.entityKey
|
|
@@ -308,10 +313,11 @@ async function changeOwnership(client, data, txParams) {
|
|
|
308
313
|
|
|
309
314
|
//#endregion
|
|
310
315
|
//#region src/actions/wallet/createEntity.ts
|
|
316
|
+
const logger$4 = getLogger("actions:wallet:create-entity");
|
|
311
317
|
async function createEntity(client, data, txParams) {
|
|
312
|
-
|
|
318
|
+
logger$4("createEntity %o", data);
|
|
313
319
|
const receipt = await sendArkivTransaction(client, opsToTxData({ creates: [data] }), txParams);
|
|
314
|
-
|
|
320
|
+
logger$4("Receipt from createEntity %o", receipt);
|
|
315
321
|
return {
|
|
316
322
|
txHash: receipt.transactionHash,
|
|
317
323
|
entityKey: receipt.logs[0].topics[1]
|
|
@@ -320,10 +326,11 @@ async function createEntity(client, data, txParams) {
|
|
|
320
326
|
|
|
321
327
|
//#endregion
|
|
322
328
|
//#region src/actions/wallet/deleteEntity.ts
|
|
329
|
+
const logger$3 = getLogger("actions:wallet:delete-entity");
|
|
323
330
|
async function deleteEntity(client, data, txParams) {
|
|
324
|
-
|
|
331
|
+
logger$3("deleteEntity %o", data);
|
|
325
332
|
const receipt = await sendArkivTransaction(client, opsToTxData({ deletes: [data] }), txParams);
|
|
326
|
-
|
|
333
|
+
logger$3("Receipt from deleteEntity %o", receipt);
|
|
327
334
|
return {
|
|
328
335
|
txHash: receipt.transactionHash,
|
|
329
336
|
entityKey: data.entityKey
|
|
@@ -332,10 +339,11 @@ async function deleteEntity(client, data, txParams) {
|
|
|
332
339
|
|
|
333
340
|
//#endregion
|
|
334
341
|
//#region src/actions/wallet/extendEntity.ts
|
|
342
|
+
const logger$2 = getLogger("actions:wallet:extend-entity");
|
|
335
343
|
async function extendEntity(client, data, txParams) {
|
|
336
|
-
|
|
344
|
+
logger$2("extendEntity %o", data);
|
|
337
345
|
const receipt = await sendArkivTransaction(client, opsToTxData({ extensions: [data] }), txParams);
|
|
338
|
-
|
|
346
|
+
logger$2("Receipt from extendEntity %o", receipt);
|
|
339
347
|
return {
|
|
340
348
|
txHash: receipt.transactionHash,
|
|
341
349
|
entityKey: receipt.logs[0].topics[1]
|
|
@@ -344,6 +352,7 @@ async function extendEntity(client, data, txParams) {
|
|
|
344
352
|
|
|
345
353
|
//#endregion
|
|
346
354
|
//#region src/actions/wallet/mutateEntities.ts
|
|
355
|
+
const logger$1 = getLogger("actions:wallet:mutate-entities");
|
|
347
356
|
function parseReceipt(receipt, params) {
|
|
348
357
|
const createdEntities = [];
|
|
349
358
|
const updatedEntities = [];
|
|
@@ -381,7 +390,7 @@ async function mutateEntities(client, data, txParams) {
|
|
|
381
390
|
extensions: data.extensions ?? [],
|
|
382
391
|
ownershipChanges: data.ownershipChanges ?? []
|
|
383
392
|
}), txParams);
|
|
384
|
-
|
|
393
|
+
logger$1("Receipt from mutateEntities %o", receipt);
|
|
385
394
|
const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } = parseReceipt(receipt, data);
|
|
386
395
|
return {
|
|
387
396
|
txHash: receipt.transactionHash,
|
|
@@ -395,10 +404,11 @@ async function mutateEntities(client, data, txParams) {
|
|
|
395
404
|
|
|
396
405
|
//#endregion
|
|
397
406
|
//#region src/actions/wallet/updateEntity.ts
|
|
407
|
+
const logger = getLogger("actions:wallet:update-entity");
|
|
398
408
|
async function updateEntity(client, data, txParams) {
|
|
399
|
-
|
|
409
|
+
logger("updateEntity %o", data);
|
|
400
410
|
const receipt = await sendArkivTransaction(client, opsToTxData({ updates: [data] }), txParams);
|
|
401
|
-
|
|
411
|
+
logger("Receipt from updateEntity %o", receipt);
|
|
402
412
|
return {
|
|
403
413
|
txHash: receipt.transactionHash,
|
|
404
414
|
entityKey: receipt.logs[0].topics[1]
|