@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
|
@@ -0,0 +1,1003 @@
|
|
|
1
|
+
import { Account, Address, Chain, Client, Hash, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
|
|
2
|
+
|
|
3
|
+
//#region src/types/mimeTypes.d.ts
|
|
4
|
+
type MimeType = "text/plain" | "text/html" | "text/css" | "text/csv" | "text/xml" | "text/javascript" | "application/json" | "application/xml" | "application/pdf" | "application/zip" | "application/gzip" | "application/octet-stream" | "application/javascript" | "application/x-www-form-urlencoded" | "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "video/mp4" | "video/webm" | "video/ogg" | "multipart/form-data";
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/types/rpcSchema.d.ts
|
|
7
|
+
type RpcEntity = {
|
|
8
|
+
key: Hex;
|
|
9
|
+
contentType: MimeType;
|
|
10
|
+
value: string;
|
|
11
|
+
expiresAt: string;
|
|
12
|
+
createdAtBlock: string;
|
|
13
|
+
lastModifiedAtBlock: string;
|
|
14
|
+
transactionIndexInBlock: string;
|
|
15
|
+
operationIndexInTransaction: string;
|
|
16
|
+
owner: Hex;
|
|
17
|
+
stringAttributes?: [{
|
|
18
|
+
key: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}];
|
|
21
|
+
numericAttributes?: [{
|
|
22
|
+
key: string;
|
|
23
|
+
value: number;
|
|
24
|
+
}];
|
|
25
|
+
};
|
|
26
|
+
type RpcOrderByAttribute = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: "string" | "numeric";
|
|
29
|
+
desc: boolean;
|
|
30
|
+
};
|
|
31
|
+
type RpcQueryOptions = {
|
|
32
|
+
atBlock?: number;
|
|
33
|
+
includeData?: RpcIncludeData;
|
|
34
|
+
orderBy?: RpcOrderByAttribute[];
|
|
35
|
+
resultsPerPage?: number;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
};
|
|
38
|
+
type RpcIncludeData = {
|
|
39
|
+
key?: boolean;
|
|
40
|
+
attributes?: boolean;
|
|
41
|
+
payload?: boolean;
|
|
42
|
+
contentType?: boolean;
|
|
43
|
+
expiration?: boolean;
|
|
44
|
+
owner?: boolean;
|
|
45
|
+
createdAtBlock?: boolean;
|
|
46
|
+
lastModifiedAtBlock?: boolean;
|
|
47
|
+
transactionIndexInBlock?: boolean;
|
|
48
|
+
operationIndexInTransaction?: boolean;
|
|
49
|
+
};
|
|
50
|
+
type ArkivRpcSchema = [{
|
|
51
|
+
Method: "arkiv_query";
|
|
52
|
+
Parameters?: [query: string, queryOptions?: RpcQueryOptions];
|
|
53
|
+
ReturnType: {
|
|
54
|
+
data: RpcEntity[];
|
|
55
|
+
blockNumber: bigint;
|
|
56
|
+
cursor: string;
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
Method: "arkiv_getBlockTiming";
|
|
60
|
+
Parameters?: [];
|
|
61
|
+
ReturnType: {
|
|
62
|
+
current_block: bigint;
|
|
63
|
+
current_block_time: number;
|
|
64
|
+
duration: number;
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
Method: "arkiv_getEntityCount";
|
|
68
|
+
Parameters?: [];
|
|
69
|
+
ReturnType: number;
|
|
70
|
+
}];
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/clients/baseClient.d.ts
|
|
73
|
+
type ArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Client<transport, chain, accountOrAddress, rpcSchema>;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/actions/public/query.d.ts
|
|
76
|
+
type QueryOptionsIncludeData = {
|
|
77
|
+
attributes?: boolean;
|
|
78
|
+
payload?: boolean;
|
|
79
|
+
metadata?: boolean;
|
|
80
|
+
};
|
|
81
|
+
type QueryOptionsOrderBy = {
|
|
82
|
+
name: string;
|
|
83
|
+
type: "string" | "numeric";
|
|
84
|
+
desc: "asc" | "desc";
|
|
85
|
+
};
|
|
86
|
+
type QueryOptions = {
|
|
87
|
+
includeData?: QueryOptionsIncludeData;
|
|
88
|
+
atBlock?: bigint;
|
|
89
|
+
orderBy?: QueryOptionsOrderBy[];
|
|
90
|
+
resultsPerPage?: number | undefined;
|
|
91
|
+
cursor?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/query/predicate.d.ts
|
|
95
|
+
type PredicateType = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "not";
|
|
96
|
+
type PredicateContainerType = "or" | "and";
|
|
97
|
+
type Predicate = {
|
|
98
|
+
type: PredicateType;
|
|
99
|
+
key: string;
|
|
100
|
+
value: string | number;
|
|
101
|
+
} | {
|
|
102
|
+
type: PredicateContainerType;
|
|
103
|
+
predicates: Predicate[];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Creates an OR predicate
|
|
107
|
+
* @param predicates - The predicates to combine
|
|
108
|
+
* @returns The OR predicate
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const predicates = [eq("name", "John"), eq("age", 30)]
|
|
112
|
+
* const result = or(predicates)
|
|
113
|
+
* // result = { type: "or", predicates: [eq("name", "John"), eq("age", 30)] }
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
declare function or(predicates: Predicate[]): Predicate;
|
|
117
|
+
/**
|
|
118
|
+
* Creates an AND predicate
|
|
119
|
+
* @param predicates - The predicates to combine
|
|
120
|
+
* @returns The AND predicate
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const predicates = [eq("name", "John"), eq("age", 30)]
|
|
124
|
+
* const result = and(predicates)
|
|
125
|
+
* // result = { type: "and", predicates: [eq("name", "John"), eq("age", 30)] }
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
declare function and(predicates: Predicate[]): Predicate;
|
|
129
|
+
/**
|
|
130
|
+
* Creates an equality predicate
|
|
131
|
+
* @param key - The key to compare
|
|
132
|
+
* @param value - The value to compare
|
|
133
|
+
* @returns The equality predicate
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* const predicate = eq("name", "John")
|
|
137
|
+
* // result = { type: "eq", key: "name", value: "John" }
|
|
138
|
+
*/
|
|
139
|
+
declare function eq(key: string, value: string | number): Predicate;
|
|
140
|
+
/**
|
|
141
|
+
* Creates a not equal predicate
|
|
142
|
+
* @param key - The key to compare
|
|
143
|
+
* @param value - The value to compare
|
|
144
|
+
* @returns The not equal predicate
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* const predicate = neq("name", "John")
|
|
148
|
+
* // result = { type: "neq", key: "name", value: "John" }
|
|
149
|
+
*/
|
|
150
|
+
declare function neq(key: string, value: string | number): Predicate;
|
|
151
|
+
/**
|
|
152
|
+
* Creates a greater than predicate
|
|
153
|
+
* @param key - The key to compare
|
|
154
|
+
* @param value - The value to compare
|
|
155
|
+
* @returns The greater than predicate
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* const predicate = gt("name", "John")
|
|
159
|
+
* // result = { type: "gt", key: "name", value: "John" }
|
|
160
|
+
*/
|
|
161
|
+
declare function gt(key: string, value: string | number): Predicate;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a greater than or equal predicate
|
|
164
|
+
* @param key - The key to compare
|
|
165
|
+
* @param value - The value to compare
|
|
166
|
+
* @returns The greater than or equal predicate
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* const predicate = gte("name", "John")
|
|
170
|
+
* // result = { type: "gte", key: "name", value: "John" }
|
|
171
|
+
*/
|
|
172
|
+
declare function gte(key: string, value: string | number): Predicate;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a less than predicate
|
|
175
|
+
* @param key - The key to compare
|
|
176
|
+
* @param value - The value to compare
|
|
177
|
+
* @returns The less than predicate
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* const predicate = lt("name", "John")
|
|
181
|
+
* // result = { type: "lt", key: "name", value: "John" }
|
|
182
|
+
*/
|
|
183
|
+
declare function lt(key: string, value: string | number): Predicate;
|
|
184
|
+
/**
|
|
185
|
+
* Creates a less than or equal predicate
|
|
186
|
+
* @param key - The key to compare
|
|
187
|
+
* @param value - The value to compare
|
|
188
|
+
* @returns The less than or equal predicate
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* const predicate = lte("name", "John")
|
|
192
|
+
* // result = { type: "lte", key: "name", value: "John" }
|
|
193
|
+
*/
|
|
194
|
+
declare function lte(key: string, value: string | number): Predicate;
|
|
195
|
+
/**
|
|
196
|
+
* Creates a not predicate
|
|
197
|
+
* @param key - The key to compare
|
|
198
|
+
* @returns The not predicate
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* const predicate = not("name")
|
|
202
|
+
* // result = { type: "not", key: "name", value: "" }
|
|
203
|
+
*/
|
|
204
|
+
declare function not(key: string): Predicate;
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/actions/public/getBlockTiming.d.ts
|
|
207
|
+
type GetBlockTimingReturnType = {
|
|
208
|
+
currentBlock: bigint;
|
|
209
|
+
currentBlockTime: number;
|
|
210
|
+
blockDuration: number;
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/actions/wallet/changeOwnership.d.ts
|
|
214
|
+
/**
|
|
215
|
+
* Parameters for the deleteEntity function.
|
|
216
|
+
* - entityKey: The key of the entity to delete.
|
|
217
|
+
*/
|
|
218
|
+
type ChangeOwnershipParameters = {
|
|
219
|
+
entityKey: Hex;
|
|
220
|
+
newOwner: Hex;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Return type for the deleteEntity function.
|
|
224
|
+
* - entityKey: The key of the entity.
|
|
225
|
+
* - txHash: The transaction hash.
|
|
226
|
+
*/
|
|
227
|
+
type ChangeOwnershipReturnType = {
|
|
228
|
+
entityKey: Hex;
|
|
229
|
+
txHash: string;
|
|
230
|
+
};
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/actions/wallet/createEntity.d.ts
|
|
233
|
+
/**
|
|
234
|
+
* Parameters for the createEntity function.
|
|
235
|
+
* - payload: The payload of the entity.
|
|
236
|
+
* - attributes: The attributes of the entity.
|
|
237
|
+
* - contentType: The content type of the entity.
|
|
238
|
+
* - expiresIn: The expires in of the entity in seconds.
|
|
239
|
+
*/
|
|
240
|
+
type CreateEntityParameters = {
|
|
241
|
+
payload: Uint8Array;
|
|
242
|
+
attributes: Attribute[];
|
|
243
|
+
contentType: MimeType;
|
|
244
|
+
expiresIn: number;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Return type for the createEntity function.
|
|
248
|
+
* - entityKey: The key of the entity.
|
|
249
|
+
* - txHash: The transaction hash.
|
|
250
|
+
*/
|
|
251
|
+
type CreateEntityReturnType = {
|
|
252
|
+
entityKey: Hex;
|
|
253
|
+
txHash: Hash;
|
|
254
|
+
};
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/actions/wallet/deleteEntity.d.ts
|
|
257
|
+
/**
|
|
258
|
+
* Parameters for the deleteEntity function.
|
|
259
|
+
* - entityKey: The key of the entity to delete.
|
|
260
|
+
*/
|
|
261
|
+
type DeleteEntityParameters = {
|
|
262
|
+
entityKey: Hex;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Return type for the deleteEntity function.
|
|
266
|
+
* - entityKey: The key of the entity.
|
|
267
|
+
* - txHash: The transaction hash.
|
|
268
|
+
*/
|
|
269
|
+
type DeleteEntityReturnType = {
|
|
270
|
+
entityKey: Hex;
|
|
271
|
+
txHash: Hash;
|
|
272
|
+
};
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/actions/wallet/extendEntity.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* Parameters for the extendEntity function.
|
|
277
|
+
* - entityKey: The key of the entity to extend.
|
|
278
|
+
* - expiresIn: The expires in of the entity in seconds.
|
|
279
|
+
*/
|
|
280
|
+
type ExtendEntityParameters = {
|
|
281
|
+
entityKey: Hex;
|
|
282
|
+
expiresIn: number;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Return type for the extendEntity function.
|
|
286
|
+
* - entityKey: The key of the entity.
|
|
287
|
+
* - txHash: The transaction hash.
|
|
288
|
+
*/
|
|
289
|
+
type ExtendEntityReturnType = {
|
|
290
|
+
entityKey: Hex;
|
|
291
|
+
txHash: Hash;
|
|
292
|
+
};
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/actions/wallet/updateEntity.d.ts
|
|
295
|
+
/**
|
|
296
|
+
* Parameters for the updateEntity function.
|
|
297
|
+
* - entityKey: The key of the entity to update.
|
|
298
|
+
* - payload: The payload of the entity.
|
|
299
|
+
* - attributes: The attributes of the entity.
|
|
300
|
+
* - contentType: The content type of the entity.
|
|
301
|
+
* - expiresIn: The expires in of the entity in seconds.
|
|
302
|
+
*/
|
|
303
|
+
type UpdateEntityParameters = {
|
|
304
|
+
entityKey: Hex;
|
|
305
|
+
payload: Uint8Array;
|
|
306
|
+
attributes: Attribute[];
|
|
307
|
+
contentType: MimeType;
|
|
308
|
+
expiresIn: number;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Return type for the updateEntity function.
|
|
312
|
+
* - entityKey: The key of the entity.
|
|
313
|
+
* - txHash: The transaction hash.
|
|
314
|
+
*/
|
|
315
|
+
type UpdateEntityReturnType = {
|
|
316
|
+
entityKey: Hex;
|
|
317
|
+
txHash: Hash;
|
|
318
|
+
};
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/actions/wallet/mutateEntities.d.ts
|
|
321
|
+
/**
|
|
322
|
+
* Parameters for the mutateEntities function.
|
|
323
|
+
* - creates: The creates to perform.
|
|
324
|
+
* - updates: The updates to perform.
|
|
325
|
+
* - deletes: The deletes to perform.
|
|
326
|
+
* - extensions: The extensions to perform.
|
|
327
|
+
*/
|
|
328
|
+
type MutateEntitiesParameters = {
|
|
329
|
+
creates?: CreateEntityParameters[];
|
|
330
|
+
updates?: UpdateEntityParameters[];
|
|
331
|
+
deletes?: DeleteEntityParameters[];
|
|
332
|
+
extensions?: ExtendEntityParameters[];
|
|
333
|
+
ownershipChanges?: ChangeOwnershipParameters[];
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Return type for the mutateEntities function.
|
|
337
|
+
* - txHash: The transaction hash.
|
|
338
|
+
* - createdEntities: The keys of the created entities.
|
|
339
|
+
* - updatedEntities: The keys of the updated entities.
|
|
340
|
+
* - deletedEntities: The keys of the deleted entities.
|
|
341
|
+
* - extendedEntities: The keys of the extended entities.
|
|
342
|
+
* - ownershipChanges: The keys of the ownership changes.
|
|
343
|
+
*/
|
|
344
|
+
type MutateEntitiesReturnType = {
|
|
345
|
+
txHash: Hash;
|
|
346
|
+
createdEntities: Hex[];
|
|
347
|
+
updatedEntities: Hex[];
|
|
348
|
+
deletedEntities: Hex[];
|
|
349
|
+
extendedEntities: Hex[];
|
|
350
|
+
ownershipChanges: Hex[];
|
|
351
|
+
};
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/types/attributes.d.ts
|
|
354
|
+
type Attribute = {
|
|
355
|
+
key: string;
|
|
356
|
+
value: string | number;
|
|
357
|
+
};
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/types/events.d.ts
|
|
360
|
+
type OnEntityCreatedEvent = {
|
|
361
|
+
entityKey: Hex;
|
|
362
|
+
owner: Hex;
|
|
363
|
+
expirationBlock: number;
|
|
364
|
+
cost: bigint;
|
|
365
|
+
};
|
|
366
|
+
type OnEntityUpdatedEvent = {
|
|
367
|
+
entityKey: Hex;
|
|
368
|
+
owner: Hex;
|
|
369
|
+
oldExpirationBlock: number;
|
|
370
|
+
newExpirationBlock: number;
|
|
371
|
+
cost: bigint;
|
|
372
|
+
};
|
|
373
|
+
type OnEntityDeletedEvent = {
|
|
374
|
+
entityKey: Hex;
|
|
375
|
+
owner: Hex;
|
|
376
|
+
};
|
|
377
|
+
type OnEntityExpiredEvent = {
|
|
378
|
+
entityKey: Hex;
|
|
379
|
+
owner: Hex;
|
|
380
|
+
};
|
|
381
|
+
type OnEntityExpiresInExtendedEvent = {
|
|
382
|
+
entityKey: Hex;
|
|
383
|
+
owner: Hex;
|
|
384
|
+
oldExpirationBlock: number;
|
|
385
|
+
newExpirationBlock: number;
|
|
386
|
+
cost: bigint;
|
|
387
|
+
};
|
|
388
|
+
type OnEntityOwnerChangedEvent = {
|
|
389
|
+
entityKey: Hex;
|
|
390
|
+
oldOwner: Hex;
|
|
391
|
+
newOwner: Hex;
|
|
392
|
+
};
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/types/txParams.d.ts
|
|
395
|
+
type TxParams = {
|
|
396
|
+
gas?: bigint;
|
|
397
|
+
nonce?: number;
|
|
398
|
+
gasPrice?: bigint;
|
|
399
|
+
maxFeePerGas?: never;
|
|
400
|
+
maxPriorityFeePerGas?: never;
|
|
401
|
+
} | {
|
|
402
|
+
gas?: bigint;
|
|
403
|
+
nonce?: number;
|
|
404
|
+
maxFeePerGas?: bigint;
|
|
405
|
+
maxPriorityFeePerGas?: bigint;
|
|
406
|
+
gasPrice?: never;
|
|
407
|
+
};
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/types/entity.d.ts
|
|
410
|
+
declare class Entity {
|
|
411
|
+
key: Hex;
|
|
412
|
+
contentType: MimeType | undefined;
|
|
413
|
+
owner: Hex | undefined;
|
|
414
|
+
expiresAtBlock: bigint | undefined;
|
|
415
|
+
createdAtBlock: bigint | undefined;
|
|
416
|
+
lastModifiedAtBlock: bigint | undefined;
|
|
417
|
+
transactionIndexInBlock: bigint | undefined;
|
|
418
|
+
operationIndexInTransaction: bigint | undefined;
|
|
419
|
+
payload: Uint8Array | undefined;
|
|
420
|
+
attributes: Attribute[];
|
|
421
|
+
constructor(key: Hex, contentType: MimeType | undefined, owner: Hex | undefined, expiresAtBlock: bigint | undefined, createdAtBlock: bigint | undefined, lastModifiedAtBlock: bigint | undefined, transactionIndexInBlock: bigint | undefined, operationIndexInTransaction: bigint | undefined, payload: Uint8Array | undefined, attributes: Attribute[]);
|
|
422
|
+
toText(): string;
|
|
423
|
+
toJson(): any;
|
|
424
|
+
}
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/query/queryResult.d.ts
|
|
427
|
+
declare class QueryResult {
|
|
428
|
+
entities: Entity[];
|
|
429
|
+
private _endOfIteration;
|
|
430
|
+
private _cursor;
|
|
431
|
+
private _limit;
|
|
432
|
+
private _validAtBlock;
|
|
433
|
+
private _queryBuilder;
|
|
434
|
+
get queryBuilder(): QueryBuilder;
|
|
435
|
+
get cursor(): string | undefined;
|
|
436
|
+
constructor(entities: Entity[], queryBuilder: QueryBuilder, cursor: string | undefined, limit: number | undefined, validAtBlock: bigint | undefined);
|
|
437
|
+
next(): Promise<void>;
|
|
438
|
+
hasNextPage(): boolean;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/query/queryBuilder.d.ts
|
|
442
|
+
type OrderByAttribute = {
|
|
443
|
+
name: string;
|
|
444
|
+
type: "string" | "number";
|
|
445
|
+
order: "asc" | "desc";
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Helper function to create an ascending order by attribute
|
|
449
|
+
* @param attributeName - The name of the attribute to order by
|
|
450
|
+
* @param attributeType - The type of the attribute to order by (string or number)
|
|
451
|
+
* @returns Input for orderBy method
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* const ascAttribute = asc("name", "string")
|
|
455
|
+
*/
|
|
456
|
+
declare function asc(attributeName: string, attributeType: "string" | "number"): OrderByAttribute;
|
|
457
|
+
/**
|
|
458
|
+
* Helper function to create a descending order by attribute
|
|
459
|
+
* @param attributeName - The name of the attribute to order by
|
|
460
|
+
* @param attributeType - The type of the attribute to order by (string or number)
|
|
461
|
+
* @returns Input for orderBy method
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* const descAttribute = desc("name", "string")
|
|
465
|
+
*/
|
|
466
|
+
declare function desc(attributeName: string, attributeType: "string" | "number"): OrderByAttribute;
|
|
467
|
+
/**
|
|
468
|
+
* QueryBuilder is a helper class to build queries to the Arkiv DBChains.
|
|
469
|
+
* It can be used to fetch entities from the Arkiv DBChains. It follows the Builder pattern allowing chaining of methods.
|
|
470
|
+
* @param client - The Arkiv client
|
|
471
|
+
* @returns The QueryBuilder instance {@link QueryBuilder}
|
|
472
|
+
*/
|
|
473
|
+
declare class QueryBuilder {
|
|
474
|
+
private _client;
|
|
475
|
+
private _ownedBy;
|
|
476
|
+
private _orderBy;
|
|
477
|
+
private _validAtBlock;
|
|
478
|
+
private _withAttributes;
|
|
479
|
+
private _withMetadata;
|
|
480
|
+
private _withPayload;
|
|
481
|
+
private _limit;
|
|
482
|
+
private _cursor;
|
|
483
|
+
private _predicates;
|
|
484
|
+
constructor(client: ArkivClient);
|
|
485
|
+
/**
|
|
486
|
+
* Sets the ownedBy filter
|
|
487
|
+
* @param ownedBy - The address of the owner
|
|
488
|
+
* @returns The QueryBuilder instance
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* const builder = new QueryBuilder(client)
|
|
492
|
+
* builder.ownedBy("0x1234567890123456789012345678901234567890")
|
|
493
|
+
*/
|
|
494
|
+
ownedBy(ownedBy: Hex): this;
|
|
495
|
+
/**
|
|
496
|
+
* Sets the orderBy for the query.
|
|
497
|
+
* It can be called multiple times to order by multiple attributes.
|
|
498
|
+
* The order of the attributes is important. The first attribute is the primary order by attribute.
|
|
499
|
+
* You can use the helper functions asc() and desc() as input for this method.
|
|
500
|
+
* @param attributeName - The name of the attribute to order by
|
|
501
|
+
* @param attributeType - The type of the attribute to order by (string or number)
|
|
502
|
+
* @param order - The order to set the order by (asc or desc)
|
|
503
|
+
* @returns The QueryBuilder instance
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* const builder = client.buildQuery()
|
|
507
|
+
* builder.orderBy("name", "string", "desc")
|
|
508
|
+
* builder.orderBy(asc("name", "string"))
|
|
509
|
+
* builder.orderBy(desc("name", "string"))
|
|
510
|
+
*/
|
|
511
|
+
orderBy(attributeName: string, attributeType: "string" | "number", order?: "asc" | "desc"): this;
|
|
512
|
+
/**
|
|
513
|
+
* Sets the orderBy for the query.
|
|
514
|
+
* This method takes the OrderByAttribute object as an argument and is mainly
|
|
515
|
+
* used to use the helper functions asc() and desc() to create the OrderByAttribute instances.
|
|
516
|
+
* @param orderByAttribute - The OrderByAttribute instance to set
|
|
517
|
+
* @returns The QueryBuilder instance
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* const builder = new QueryBuilder(client)
|
|
521
|
+
* builder.orderBy(asc("name", "string"))
|
|
522
|
+
* builder.orderBy(desc("name", "string"))
|
|
523
|
+
*/
|
|
524
|
+
orderBy(orderByAttribute: OrderByAttribute): this;
|
|
525
|
+
/**
|
|
526
|
+
* Sets the withAttributes flag which will return the attributes for the entities if true
|
|
527
|
+
* @param withAttributes - The boolean value to set
|
|
528
|
+
* @returns The QueryBuilder instance
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* const builder = new QueryBuilder(client)
|
|
532
|
+
* builder.withAttributes(true)
|
|
533
|
+
*/
|
|
534
|
+
withAttributes(withAttributes?: boolean): this;
|
|
535
|
+
/**
|
|
536
|
+
* Sets the withMetadata flag which will return the metadata (like owner, expiredAt, etc.) for the entities if true
|
|
537
|
+
* @param withMetadata - The boolean value to set
|
|
538
|
+
* @returns The QueryBuilder instance
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* const builder = new QueryBuilder(client)
|
|
542
|
+
* builder.withMetadata(true)
|
|
543
|
+
*/
|
|
544
|
+
withMetadata(withMetadata?: boolean): this;
|
|
545
|
+
/**
|
|
546
|
+
* Sets the withPayload flag which will return the payload for the entities if true
|
|
547
|
+
* @param withPayload - The boolean value to set
|
|
548
|
+
* @returns The QueryBuilder instance
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* const builder = new QueryBuilder(client)
|
|
552
|
+
* builder.withPayload(true)
|
|
553
|
+
*/
|
|
554
|
+
withPayload(withPayload?: boolean): this;
|
|
555
|
+
/**
|
|
556
|
+
* Sets the limit for the query
|
|
557
|
+
* @param limit - The number of entities to return
|
|
558
|
+
* @returns The QueryBuilder instance
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* const builder = new QueryBuilder(client)
|
|
562
|
+
* builder.limit(10)
|
|
563
|
+
*/
|
|
564
|
+
limit(limit: number): this;
|
|
565
|
+
/**
|
|
566
|
+
* Sets the cursor for the query - it is advances setting which rather shouldn't be used manually but it is provided from query result if limit is used (pagination).
|
|
567
|
+
* @param cursor - The cursor to set which tells to RPC Query server where to start or continue the query.
|
|
568
|
+
* @returns The QueryBuilder instance
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* const builder = new QueryBuilder(client)
|
|
572
|
+
* builder.offset(10)
|
|
573
|
+
*/
|
|
574
|
+
cursor(cursor: string): this;
|
|
575
|
+
/**
|
|
576
|
+
* Sets the validAtBlock for the query which tells at which block height the state we are intested.
|
|
577
|
+
* If not set, the latest block is used.
|
|
578
|
+
* @param validAtBlock - The block number to set
|
|
579
|
+
* @returns The QueryBuilder instance
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* const builder = new QueryBuilder(client)
|
|
583
|
+
* builder.validAtBlock(10000)
|
|
584
|
+
*/
|
|
585
|
+
validAtBlock(validAtBlock: bigint): this;
|
|
586
|
+
/**
|
|
587
|
+
* Sets the predicates for the query limiting the results. It can be a single predicate or an array of predicates combined with 'and'.
|
|
588
|
+
* Predicates can be nested using 'or' and 'and' predicates.
|
|
589
|
+
* @param predicates - The predicates to set
|
|
590
|
+
* @returns The QueryBuilder instance
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* const builder = new QueryBuilder(client)
|
|
594
|
+
* builder.where(eq("name", "John"))
|
|
595
|
+
* builder.where([eq("name", "John"), eq("age", 30)])
|
|
596
|
+
* builder.where([eq("name", "John"), or([eq("age", 30), eq("age", 31)])])
|
|
597
|
+
* builder.where([eq("name", "John"), and([eq("age", 30), eq("age", 31)])])
|
|
598
|
+
* builder.where([eq("name", "John"), or([eq("age", 30), and([eq("age", 31), eq("age", 32)])])])
|
|
599
|
+
* builder.where([eq("name", "John"), and([eq("age", 30), or([eq("age", 31), eq("age", 32)])])])
|
|
600
|
+
* builder.where([eq("name", "John"), and([eq("age", 30), or([eq("age", 31), and([eq("age", 32), eq("age", 33)])])])])
|
|
601
|
+
*/
|
|
602
|
+
where(predicates: Predicate[] | Predicate): this;
|
|
603
|
+
/**
|
|
604
|
+
* Fetches the entities from the query. Re
|
|
605
|
+
* It will return a QueryResult instance which can be used to fetch the next and previous pages.
|
|
606
|
+
* @returns The QueryResult instance {@link QueryResult}
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* const builder = new QueryBuilder(client)
|
|
610
|
+
* const result = await builder.where(eq("name", "John")).fetch()
|
|
611
|
+
* // result = { entities: [Entity, Entity, Entity], next: async () => QueryResult, previous: async () => QueryResult }
|
|
612
|
+
*/
|
|
613
|
+
fetch(): Promise<QueryResult>;
|
|
614
|
+
/**
|
|
615
|
+
* Counts the entities from the query.
|
|
616
|
+
* @returns The number of entities
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* const builder = new QueryBuilder(client)
|
|
620
|
+
* const result = await builder.where(eq("name", "John")).count()
|
|
621
|
+
* // result = 10
|
|
622
|
+
*/
|
|
623
|
+
count(): Promise<number>;
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/clients/decorators/arkivPublic.d.ts
|
|
627
|
+
type PublicArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "getBalance" | "getBlock" | "getBlockNumber" | "getChainId" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "waitForTransactionReceipt" | "watchEvent"> & {
|
|
628
|
+
/**
|
|
629
|
+
* Returns the entity with the given key.
|
|
630
|
+
*
|
|
631
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
632
|
+
*
|
|
633
|
+
* @param key - The entity key (hex string)
|
|
634
|
+
* @returns The entity with the given key. {@link Entity}
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
638
|
+
* import { kaolin } from 'arkiv/chains'
|
|
639
|
+
*
|
|
640
|
+
* const client = createPublicClient({
|
|
641
|
+
* chain: kaolin,
|
|
642
|
+
* transport: http(),
|
|
643
|
+
* })
|
|
644
|
+
* const entity = await client.getEntity("0x123")
|
|
645
|
+
* // {
|
|
646
|
+
* // key: "0x123",
|
|
647
|
+
* // value: "0x123",
|
|
648
|
+
* // }
|
|
649
|
+
*/
|
|
650
|
+
getEntity: (key: Hex) => Promise<Entity>;
|
|
651
|
+
/**
|
|
652
|
+
* Returns a QueryBuilder instance for building and executing queries.
|
|
653
|
+
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
654
|
+
*
|
|
655
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
656
|
+
*
|
|
657
|
+
* @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
661
|
+
* import { kaolin } from 'arkiv/chains'
|
|
662
|
+
*
|
|
663
|
+
* const client = createPublicClient({
|
|
664
|
+
* chain: kaolin,
|
|
665
|
+
* transport: http(),
|
|
666
|
+
* })
|
|
667
|
+
* const query = client.buildQuery()
|
|
668
|
+
* const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
|
|
669
|
+
*
|
|
670
|
+
*/
|
|
671
|
+
buildQuery: () => QueryBuilder;
|
|
672
|
+
/**
|
|
673
|
+
* Returns a QueryResult instance for fetching the results of a raw query.
|
|
674
|
+
* If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
|
|
675
|
+
* @param query - The raw query string
|
|
676
|
+
* @param queryOptions - The optional query options - {@link QueryOptions}
|
|
677
|
+
* @returns An array of entities matching the query. {@link Entity}
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
681
|
+
* import { kaolin } from 'arkiv/chains'
|
|
682
|
+
*
|
|
683
|
+
* const client = createPublicClient({
|
|
684
|
+
* chain: kaolin,
|
|
685
|
+
* transport: http(),
|
|
686
|
+
* })
|
|
687
|
+
* const queryResult = client.query('key = value && $owner = 0x123')
|
|
688
|
+
* // queryResult = [{ key: "0x123", value: "0x123" }]
|
|
689
|
+
* const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
|
|
690
|
+
* includeData: {
|
|
691
|
+
* attributes: false,
|
|
692
|
+
* payload: true,
|
|
693
|
+
* metadata: true,
|
|
694
|
+
* },
|
|
695
|
+
* orderBy: [{ name: "key", type: "string", desc: "asc" }],
|
|
696
|
+
* resultsPerPage: 10,
|
|
697
|
+
* cursor: undefined,
|
|
698
|
+
* atBlock: undefined,
|
|
699
|
+
* })
|
|
700
|
+
* // queryResultWithOptions = [{ key: "0x123", value: "0x123" }]
|
|
701
|
+
*/
|
|
702
|
+
query: (query: string, queryOptions?: QueryOptions) => Promise<Entity[]>;
|
|
703
|
+
/**
|
|
704
|
+
* Returns the number of entities in the DBChain.
|
|
705
|
+
* @returns The number of entities in the DBChain
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
709
|
+
* import { kaolin } from 'arkiv/chains'
|
|
710
|
+
*
|
|
711
|
+
* const client = createPublicClient({
|
|
712
|
+
* chain: kaolin,
|
|
713
|
+
* transport: http(),
|
|
714
|
+
* })
|
|
715
|
+
* const entityCount = await client.getEntityCount()
|
|
716
|
+
* // entityCount = 0
|
|
717
|
+
*/
|
|
718
|
+
getEntityCount: () => Promise<number>;
|
|
719
|
+
/**
|
|
720
|
+
* Returns the current block timing.
|
|
721
|
+
* @returns The current block timing. {@link GetBlockTimingReturnType}
|
|
722
|
+
*
|
|
723
|
+
* @example
|
|
724
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
725
|
+
* import { kaolin } from 'arkiv/chains'
|
|
726
|
+
*
|
|
727
|
+
* const client = createPublicClient({
|
|
728
|
+
* chain: kaolin,
|
|
729
|
+
* transport: http(),
|
|
730
|
+
* })
|
|
731
|
+
* const blockTiming = await client.getBlockTiming()
|
|
732
|
+
* // {
|
|
733
|
+
* // currentBlock: 10n, // block number
|
|
734
|
+
* // currentBlockTime: 1234567890, // block timestamp
|
|
735
|
+
* // blockDuration: 2, // in seconds
|
|
736
|
+
* // }
|
|
737
|
+
*/
|
|
738
|
+
getBlockTiming: () => Promise<{
|
|
739
|
+
currentBlock: bigint;
|
|
740
|
+
currentBlockTime: number;
|
|
741
|
+
blockDuration: number;
|
|
742
|
+
}>;
|
|
743
|
+
/**
|
|
744
|
+
* Subscribes to entity events.
|
|
745
|
+
* Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
|
|
746
|
+
* @param pollingInterval - The polling interval in milliseconds
|
|
747
|
+
* @param fromBlock - The block number to start from
|
|
748
|
+
* @returns A function to unsubscribe from the events
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
752
|
+
* import { kaolin } from 'arkiv/chains'
|
|
753
|
+
*
|
|
754
|
+
* const client = createPublicClient({
|
|
755
|
+
* chain: kaolin,
|
|
756
|
+
* transport: http(),
|
|
757
|
+
* })
|
|
758
|
+
* const unsubscribe = await client.subscribeEntityEvents({
|
|
759
|
+
* onError: (error) => console.error("subscribeEntityEvents error", error),
|
|
760
|
+
* })
|
|
761
|
+
* unsubscribe() // unsubscribe from the events
|
|
762
|
+
*/
|
|
763
|
+
subscribeEntityEvents: ({
|
|
764
|
+
onError,
|
|
765
|
+
onEntityCreated,
|
|
766
|
+
onEntityUpdated,
|
|
767
|
+
onEntityDeleted,
|
|
768
|
+
onEntityExpiresInExtended
|
|
769
|
+
}: {
|
|
770
|
+
onError?: (error: Error) => void;
|
|
771
|
+
onEntityCreated?: (event: OnEntityCreatedEvent) => void;
|
|
772
|
+
onEntityUpdated?: (event: OnEntityUpdatedEvent) => void;
|
|
773
|
+
onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
|
|
774
|
+
onEntityExpired?: (event: OnEntityExpiredEvent) => void;
|
|
775
|
+
onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
|
|
776
|
+
}, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
|
|
777
|
+
};
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/clients/createPublicClient.d.ts
|
|
780
|
+
type PublicArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Prettify<Client<transport, chain, accountOrAddress, rpcSchema, PublicArkivActions<transport, chain>>>;
|
|
781
|
+
/**
|
|
782
|
+
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
783
|
+
*
|
|
784
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
785
|
+
*
|
|
786
|
+
* 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).
|
|
787
|
+
*
|
|
788
|
+
* @param parameters - Configuration object for the public client (chain, transport, etc.)
|
|
789
|
+
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
793
|
+
* import { kaolin } from 'arkiv/chains'
|
|
794
|
+
*
|
|
795
|
+
* const client = createPublicClient({
|
|
796
|
+
* chain: kaolin,
|
|
797
|
+
* transport: http(),
|
|
798
|
+
* })
|
|
799
|
+
*/
|
|
800
|
+
declare function createPublicClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema>(parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>): PublicArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>;
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/clients/decorators/arkivWallet.d.ts
|
|
803
|
+
type WalletArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "waitForTransactionReceipt"> & Pick<WalletActions<chain, account>, "addChain" | "sendTransaction" | "sendTransactionSync" | "sendRawTransaction" | "sendRawTransactionSync" | "signMessage" | "signTransaction"> & {
|
|
804
|
+
/**
|
|
805
|
+
* Creates a new entity.
|
|
806
|
+
*
|
|
807
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/createEntity
|
|
808
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
809
|
+
*
|
|
810
|
+
* @param data - The entity creation parameters
|
|
811
|
+
* @param txParams - Optional transaction parameters
|
|
812
|
+
* @returns The created entity with transaction hash
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
816
|
+
* import { kaolin } from 'arkiv/chains'
|
|
817
|
+
*
|
|
818
|
+
* const client = createPublicClient({
|
|
819
|
+
* chain: kaolin,
|
|
820
|
+
* transport: http(),
|
|
821
|
+
* })
|
|
822
|
+
* const { entityKey, txHash } = await client.createEntity({
|
|
823
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
824
|
+
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
825
|
+
* expiresIn: 1000,
|
|
826
|
+
* })
|
|
827
|
+
* console.log("entityKey", entityKey)
|
|
828
|
+
* console.log("txHash", txHash)
|
|
829
|
+
* // {
|
|
830
|
+
* // entityKey: "0x123",
|
|
831
|
+
* // txHash: "0x123",
|
|
832
|
+
* // }
|
|
833
|
+
*/
|
|
834
|
+
createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
|
|
835
|
+
/**
|
|
836
|
+
* Updates the entity with the given key.
|
|
837
|
+
*
|
|
838
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
|
|
839
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
840
|
+
*
|
|
841
|
+
* @param data - The entity update parameters
|
|
842
|
+
* @param txParams - Optional transaction parameters
|
|
843
|
+
* @returns The updated entity with transaction hash
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
847
|
+
* import { kaolin } from 'arkiv/chains'
|
|
848
|
+
*
|
|
849
|
+
* const client = createWalletClient({
|
|
850
|
+
* chain: kaolin,
|
|
851
|
+
* transport: http(),
|
|
852
|
+
* })
|
|
853
|
+
*/
|
|
854
|
+
updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
|
|
855
|
+
/**
|
|
856
|
+
* Deletes the entity with the given key.
|
|
857
|
+
*
|
|
858
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
|
|
859
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
860
|
+
*
|
|
861
|
+
* @param data - The entity deletion parameters
|
|
862
|
+
* @param txParams - Optional transaction parameters
|
|
863
|
+
* @returns The deleted entity with transaction hash
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
867
|
+
* import { kaolin } from 'arkiv/chains'
|
|
868
|
+
*
|
|
869
|
+
* const client = createWalletClient({
|
|
870
|
+
* chain: kaolin,
|
|
871
|
+
* transport: http(),
|
|
872
|
+
* })
|
|
873
|
+
* const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
|
|
874
|
+
* console.log("entityKey", entityKey)
|
|
875
|
+
* console.log("txHash", txHash)
|
|
876
|
+
* // {
|
|
877
|
+
* // entityKey: "0x123",
|
|
878
|
+
* // txHash: "0x123",
|
|
879
|
+
* // }
|
|
880
|
+
*/
|
|
881
|
+
deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
|
|
882
|
+
/**
|
|
883
|
+
* Extends the entity with the given key.
|
|
884
|
+
*
|
|
885
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
|
|
886
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
887
|
+
*
|
|
888
|
+
* @param data - The entity update parameters
|
|
889
|
+
* @param txParams - Optional transaction parameters
|
|
890
|
+
* @returns The updated entity with transaction hash
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
894
|
+
* import { kaolin } from 'arkiv/chains'
|
|
895
|
+
*
|
|
896
|
+
* const client = createWalletClient({
|
|
897
|
+
* chain: kaolin,
|
|
898
|
+
* transport: http(),
|
|
899
|
+
* })
|
|
900
|
+
* const { entityKey, txHash } = await client.extendEntity("0x123", {
|
|
901
|
+
* expiresIn: 1000,
|
|
902
|
+
* })
|
|
903
|
+
* console.log("entityKey", entityKey)
|
|
904
|
+
* console.log("txHash", txHash)
|
|
905
|
+
* // {
|
|
906
|
+
* // entityKey: "0x123",
|
|
907
|
+
* // txHash: "0x123",
|
|
908
|
+
* // }
|
|
909
|
+
*/
|
|
910
|
+
extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
|
|
911
|
+
/**
|
|
912
|
+
* Changes the ownership of the entity with the given address.
|
|
913
|
+
*
|
|
914
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
|
|
915
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
916
|
+
*
|
|
917
|
+
* @param data - The ownership change parameters
|
|
918
|
+
* @param txParams - Optional transaction parameters
|
|
919
|
+
* @returns The entity with updated ownership and transaction hash
|
|
920
|
+
*/
|
|
921
|
+
changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>;
|
|
922
|
+
/**
|
|
923
|
+
* Mutates the entities with the given keys.
|
|
924
|
+
*
|
|
925
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
|
|
926
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
927
|
+
*
|
|
928
|
+
* @param data - The mutation parameters (creates, updates, deletes, extensions)
|
|
929
|
+
* @param txParams - Optional transaction parameters
|
|
930
|
+
* @returns The mutation result with transaction hash
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
934
|
+
* import { kaolin } from 'arkiv/chains'
|
|
935
|
+
*
|
|
936
|
+
* const client = createWalletClient({
|
|
937
|
+
* chain: kaolin,
|
|
938
|
+
* transport: http(),
|
|
939
|
+
* })
|
|
940
|
+
* const { entityKey, txHash } = await client.mutateEntities({
|
|
941
|
+
* creates: [{
|
|
942
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
943
|
+
* attriubutes: [{ key: "testKey", value: "testValue" }],
|
|
944
|
+
* expiresIn: 1000,
|
|
945
|
+
* }],
|
|
946
|
+
* updates: [{
|
|
947
|
+
* entityKey: "0x123",
|
|
948
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
949
|
+
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
950
|
+
* expiresIn: 1000,
|
|
951
|
+
* }],
|
|
952
|
+
* deletes: [{
|
|
953
|
+
* entityKey: "0x321",
|
|
954
|
+
* }],
|
|
955
|
+
* extensions: [{
|
|
956
|
+
* entityKey: "0x1234",
|
|
957
|
+
* expiresIn: 1000,
|
|
958
|
+
* }],
|
|
959
|
+
* })
|
|
960
|
+
* console.log("entityKey", entityKey)
|
|
961
|
+
* console.log("txHash", txHash)
|
|
962
|
+
* // {
|
|
963
|
+
* // entityKey: "0x123",
|
|
964
|
+
* // txHash: "0x123",
|
|
965
|
+
* // }
|
|
966
|
+
*/
|
|
967
|
+
mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
|
|
968
|
+
};
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region src/clients/createWalletClient.d.ts
|
|
971
|
+
type WalletArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Prettify<Client<transport, chain, account, rpcSchema, WalletArkivActions<transport, chain, account>>>;
|
|
972
|
+
/**
|
|
973
|
+
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
974
|
+
*
|
|
975
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
976
|
+
*
|
|
977
|
+
* 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).
|
|
978
|
+
*
|
|
979
|
+
* @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
|
|
980
|
+
* @returns A Arkiv Wallet Client. {@link WalletArkivClient}
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
984
|
+
* import { kaolin } from 'arkiv/chains'
|
|
985
|
+
*
|
|
986
|
+
* const client = createPublicClient({
|
|
987
|
+
* chain: kaolin,
|
|
988
|
+
* transport: http(),
|
|
989
|
+
* })
|
|
990
|
+
*/
|
|
991
|
+
declare function createWalletClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema>(parameters: WalletClientConfig<transport, chain, accountOrAddress, rpcSchema>): WalletArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>;
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region src/utils/chains.d.ts
|
|
994
|
+
/**
|
|
995
|
+
* Get a chain from its name
|
|
996
|
+
* @param name - The name of the chain, case insensitive
|
|
997
|
+
* @returns The chain
|
|
998
|
+
* @throws An error if the chain is not found
|
|
999
|
+
*/
|
|
1000
|
+
declare function chainFromName(name: string): Chain;
|
|
1001
|
+
//#endregion
|
|
1002
|
+
export { RpcIncludeData as $, CreateEntityParameters as A, gt as B, MutateEntitiesReturnType as C, ExtendEntityReturnType as D, ExtendEntityParameters as E, Predicate as F, not as G, lt as H, PredicateContainerType as I, QueryOptionsIncludeData as J, or as K, PredicateType as L, ChangeOwnershipParameters as M, ChangeOwnershipReturnType as N, DeleteEntityParameters as O, GetBlockTimingReturnType as P, RpcEntity as Q, and as R, MutateEntitiesParameters as S, UpdateEntityReturnType as T, lte as U, gte as V, neq as W, ArkivClient as X, QueryOptionsOrderBy as Y, ArkivRpcSchema as Z, OnEntityExpiredEvent as _, PublicArkivClient as a, OnEntityUpdatedEvent as b, OrderByAttribute as c, desc as d, RpcOrderByAttribute as et, QueryResult as f, OnEntityDeletedEvent as g, OnEntityCreatedEvent as h, WalletArkivActions as i, CreateEntityReturnType as j, DeleteEntityReturnType as k, QueryBuilder as l, TxParams as m, WalletArkivClient as n, MimeType as nt, createPublicClient as o, Entity as p, QueryOptions as q, createWalletClient as r, PublicArkivActions as s, chainFromName as t, RpcQueryOptions as tt, asc as u, OnEntityExpiresInExtendedEvent as v, UpdateEntityParameters as w, Attribute as x, OnEntityOwnerChangedEvent as y, eq as z };
|
|
1003
|
+
//# sourceMappingURL=index-DQGx5KZ6.d.cts.map
|