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