@arkiv-network/sdk 0.5.0-dev.1 → 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.d.cts +33 -33
- 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 +30 -8
- package/dist/index.d.cts +3 -392
- package/dist/index.d.ts +3 -392
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{payload-Da9gJMG5.d.ts → payload-BI2NXPDf.d.ts} +1 -1
- package/dist/{payload-Da9gJMG5.d.ts.map → payload-BI2NXPDf.d.ts.map} +1 -1
- package/dist/{payload-CJN8fTvX.d.cts → payload-D3fyOBWn.d.cts} +1 -1
- package/dist/{payload-CJN8fTvX.d.cts.map → payload-D3fyOBWn.d.cts.map} +1 -1
- 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-Cy7vf54g.js → queryBuilder-DNUwJvf0.js} +4 -9
- package/dist/queryBuilder-DNUwJvf0.js.map +1 -0
- package/dist/{queryBuilder-DS2Q9bgk.cjs → queryBuilder-KrdIUVZv.cjs} +2 -13
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +8 -5
- package/src/actions/public/query.ts +49 -2
- package/src/actions/public/subscribeEntityEvents.ts +2 -2
- package/src/clients/createPublicClient.ts +1 -1
- package/src/clients/createWalletClient.ts +2 -2
- package/src/clients/decorators/arkivPublic.ts +26 -11
- package/src/clients/decorators/arkivWallet.ts +21 -15
- package/src/index.ts +6 -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/compression.ts +1 -1
- package/dist/entity-BNSCqNpu.d.cts +0 -254
- package/dist/entity-BNSCqNpu.d.cts.map +0 -1
- package/dist/entity-D7fzI0Hc.d.ts +0 -254
- package/dist/entity-D7fzI0Hc.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/queryBuilder-BGz98Y1C.d.ts +0 -314
- package/dist/queryBuilder-BGz98Y1C.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-Cy7vf54g.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,393 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as stringToPayload, t as jsonToPayload } from "./payload-Da9gJMG5.js";
|
|
4
|
-
import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem";
|
|
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, X as ArkivClient, Y as QueryOptionsOrderBy, Z as ArkivRpcSchema, _ as OnEntityExpiredEvent, a as PublicArkivClient, b as OnEntityUpdatedEvent, et as RpcOrderByAttribute, g as OnEntityDeletedEvent, h as OnEntityCreatedEvent, i as WalletArkivActions, j as CreateEntityReturnType, k as DeleteEntityReturnType, m as TxParams, n as WalletArkivClient, nt as MimeType, o as createPublicClient, p as Entity, q as QueryOptions, r as createWalletClient, s as PublicArkivActions, t as chainFromName, tt as RpcQueryOptions, v as OnEntityExpiresInExtendedEvent, w as UpdateEntityParameters, x as Attribute, y as OnEntityOwnerChangedEvent } from "./index-B801JxcV.js";
|
|
2
|
+
import { n as stringToPayload, t as jsonToPayload } from "./payload-BI2NXPDf.js";
|
|
5
3
|
export * from "viem";
|
|
6
|
-
|
|
7
|
-
//#region src/types/events.d.ts
|
|
8
|
-
type OnEntityCreatedEvent = {
|
|
9
|
-
entityKey: Hex;
|
|
10
|
-
owner: Hex;
|
|
11
|
-
expirationBlock: number;
|
|
12
|
-
cost: bigint;
|
|
13
|
-
};
|
|
14
|
-
type OnEntityUpdatedEvent = {
|
|
15
|
-
entityKey: Hex;
|
|
16
|
-
owner: Hex;
|
|
17
|
-
oldExpirationBlock: number;
|
|
18
|
-
newExpirationBlock: number;
|
|
19
|
-
cost: bigint;
|
|
20
|
-
};
|
|
21
|
-
type OnEntityDeletedEvent = {
|
|
22
|
-
entityKey: Hex;
|
|
23
|
-
owner: Hex;
|
|
24
|
-
};
|
|
25
|
-
type OnEntityExpiredEvent = {
|
|
26
|
-
entityKey: Hex;
|
|
27
|
-
owner: Hex;
|
|
28
|
-
};
|
|
29
|
-
type OnEntityExpiresInExtendedEvent = {
|
|
30
|
-
entityKey: Hex;
|
|
31
|
-
owner: Hex;
|
|
32
|
-
oldExpirationBlock: number;
|
|
33
|
-
newExpirationBlock: number;
|
|
34
|
-
cost: bigint;
|
|
35
|
-
};
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/clients/decorators/arkivPublic.d.ts
|
|
38
|
-
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"> & {
|
|
39
|
-
/**
|
|
40
|
-
* Returns the entity with the given key.
|
|
41
|
-
*
|
|
42
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
43
|
-
*
|
|
44
|
-
* @param args - {entityKey}
|
|
45
|
-
* @returns The entity with the given key. {@link Entity}
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
49
|
-
* import { kaolin } from 'arkiv/chains'
|
|
50
|
-
*
|
|
51
|
-
* const client = createPublicClient({
|
|
52
|
-
* chain: kaolin,
|
|
53
|
-
* transport: http(),
|
|
54
|
-
* })
|
|
55
|
-
* const entity = await client.getEntity("0x123")
|
|
56
|
-
* // {
|
|
57
|
-
* // key: "0x123",
|
|
58
|
-
* // value: "0x123",
|
|
59
|
-
* // }
|
|
60
|
-
*/
|
|
61
|
-
getEntity: (key: Hex) => Promise<Entity>;
|
|
62
|
-
/**
|
|
63
|
-
* Returns a QueryBuilder instance for building and executing queries.
|
|
64
|
-
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
65
|
-
*
|
|
66
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
67
|
-
*
|
|
68
|
-
* @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
72
|
-
* import { kaolin } from 'arkiv/chains'
|
|
73
|
-
*
|
|
74
|
-
* const client = createPublicClient({
|
|
75
|
-
* chain: kaolin,
|
|
76
|
-
* transport: http(),
|
|
77
|
-
* })
|
|
78
|
-
* const query = client.buildQuery()
|
|
79
|
-
* const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
buildQuery: () => QueryBuilder;
|
|
83
|
-
/**
|
|
84
|
-
* Returns a QueryResult instance for fetching the results of a raw query.
|
|
85
|
-
* @returns A QueryResult instance for fetching the results of a raw query. {@link QueryResult}
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
89
|
-
* import { kaolin } from 'arkiv/chains'
|
|
90
|
-
*
|
|
91
|
-
* const client = createPublicClient({
|
|
92
|
-
* chain: kaolin,
|
|
93
|
-
* transport: http(),
|
|
94
|
-
* })
|
|
95
|
-
* const queryResult = client.query('key = value && $owner = 0x123')
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
query: (query: string) => Promise<Entity[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Returns the number of entities in the DBChain.
|
|
101
|
-
* @returns The number of entities in the DBChain. {@link number}
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
105
|
-
* import { kaolin } from 'arkiv/chains'
|
|
106
|
-
*
|
|
107
|
-
* const client = createPublicClient({
|
|
108
|
-
* chain: kaolin,
|
|
109
|
-
* transport: http(),
|
|
110
|
-
* })
|
|
111
|
-
* const entityCount = await client.getEntityCount()
|
|
112
|
-
* // entityCount = 0
|
|
113
|
-
*/
|
|
114
|
-
getEntityCount: () => Promise<number>;
|
|
115
|
-
/**
|
|
116
|
-
* Returns the current block timing.
|
|
117
|
-
* @returns The current block timing. {@link GetBlockTimingReturnType}
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
121
|
-
* import { kaolin } from 'arkiv/chains'
|
|
122
|
-
*
|
|
123
|
-
* const client = createPublicClient({
|
|
124
|
-
* chain: kaolin,
|
|
125
|
-
* transport: http(),
|
|
126
|
-
* })
|
|
127
|
-
* const blockTiming = await client.getBlockTiming()
|
|
128
|
-
* // {
|
|
129
|
-
* // currentBlock: 10n, // block number
|
|
130
|
-
* // currentBlockTime: 1234567890, // block timestamp
|
|
131
|
-
* // blockDuration: 2, // in seconds
|
|
132
|
-
* // }
|
|
133
|
-
*/
|
|
134
|
-
getBlockTiming: () => Promise<{
|
|
135
|
-
currentBlock: bigint;
|
|
136
|
-
currentBlockTime: number;
|
|
137
|
-
blockDuration: number;
|
|
138
|
-
}>;
|
|
139
|
-
/**
|
|
140
|
-
* Subscribes to entity events.
|
|
141
|
-
* @param events to watch - {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
|
|
142
|
-
* @param pollingInterval - The polling interval in milliseconds. {@link number}
|
|
143
|
-
* @param fromBlock - The block number to start from. {@link bigint}
|
|
144
|
-
* @returns A function to unsubscribe from the events. {() => void}
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
148
|
-
* import { kaolin } from 'arkiv/chains'
|
|
149
|
-
*
|
|
150
|
-
* const client = createPublicClient({
|
|
151
|
-
* chain: kaolin,
|
|
152
|
-
* transport: http(),
|
|
153
|
-
* })
|
|
154
|
-
* const unsubscribe = await client.subscribeEntityEvents({
|
|
155
|
-
* onError: (error) => console.error("subscribeEntityEvents error", error),
|
|
156
|
-
* })
|
|
157
|
-
* unsubscribe() // unsubscribe from the events
|
|
158
|
-
*/
|
|
159
|
-
subscribeEntityEvents: ({
|
|
160
|
-
onError,
|
|
161
|
-
onEntityCreated,
|
|
162
|
-
onEntityUpdated,
|
|
163
|
-
onEntityDeleted,
|
|
164
|
-
onEntityExpiresInExtended
|
|
165
|
-
}: {
|
|
166
|
-
onError?: (error: Error) => void;
|
|
167
|
-
onEntityCreated?: (event: OnEntityCreatedEvent) => void;
|
|
168
|
-
onEntityUpdated?: (event: OnEntityUpdatedEvent) => void;
|
|
169
|
-
onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
|
|
170
|
-
onEntityExpired?: (event: OnEntityExpiredEvent) => void;
|
|
171
|
-
onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
|
|
172
|
-
}, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
|
|
173
|
-
};
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/clients/createPublicClient.d.ts
|
|
176
|
-
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>>>;
|
|
177
|
-
/**
|
|
178
|
-
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
179
|
-
*
|
|
180
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
181
|
-
*
|
|
182
|
-
* 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).
|
|
183
|
-
*
|
|
184
|
-
* @param config - {@link PublicClientConfig}
|
|
185
|
-
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
189
|
-
* import { kaolin } from 'arkiv/chains'
|
|
190
|
-
*
|
|
191
|
-
* const client = createPublicClient({
|
|
192
|
-
* chain: kaolin,
|
|
193
|
-
* transport: http(),
|
|
194
|
-
* })
|
|
195
|
-
*/
|
|
196
|
-
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>;
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/clients/decorators/arkivWallet.d.ts
|
|
199
|
-
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"> & {
|
|
200
|
-
/**
|
|
201
|
-
* Returns the entity with the given key.
|
|
202
|
-
*
|
|
203
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
204
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
205
|
-
*
|
|
206
|
-
* @param args - {entityKey}
|
|
207
|
-
* @returns The entity with the given key. {@link Entity}
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
211
|
-
* import { kaolin } from 'arkiv/chains'
|
|
212
|
-
*
|
|
213
|
-
* const client = createPublicClient({
|
|
214
|
-
* chain: kaolin,
|
|
215
|
-
* transport: http(),
|
|
216
|
-
* })
|
|
217
|
-
* const { entityKey, txHash } = await client.createEntity({
|
|
218
|
-
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
219
|
-
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
220
|
-
* expiresIn: 1000,
|
|
221
|
-
* })
|
|
222
|
-
* console.log("entityKey", entityKey)
|
|
223
|
-
* console.log("txHash", txHash)
|
|
224
|
-
* // {
|
|
225
|
-
* // entityKey: "0x123",
|
|
226
|
-
* // txHash: "0x123",
|
|
227
|
-
* // }
|
|
228
|
-
*/
|
|
229
|
-
createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
|
|
230
|
-
/**
|
|
231
|
-
* Updates the entity with the given key.
|
|
232
|
-
*
|
|
233
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
|
|
234
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
235
|
-
*
|
|
236
|
-
* @param args - {entityKey, data}
|
|
237
|
-
* @returns The entity with the given key. {@link Entity}
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* import { createWalletClient, http } from 'arkiv'
|
|
241
|
-
* import { kaolin } from 'arkiv/chains'
|
|
242
|
-
*
|
|
243
|
-
* const client = createWalletClient({
|
|
244
|
-
* chain: kaolin,
|
|
245
|
-
* transport: http(),
|
|
246
|
-
* })
|
|
247
|
-
*/
|
|
248
|
-
updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
|
|
249
|
-
/**
|
|
250
|
-
* Deletes the entity with the given key.
|
|
251
|
-
*
|
|
252
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
|
|
253
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
254
|
-
*
|
|
255
|
-
* @param args - {entityKey}
|
|
256
|
-
* @returns The entity with the given key. {@link Entity}
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* import { createWalletClient, http } from 'arkiv'
|
|
260
|
-
* import { kaolin } from 'arkiv/chains'
|
|
261
|
-
*
|
|
262
|
-
* const client = createWalletClient({
|
|
263
|
-
* chain: kaolin,
|
|
264
|
-
* transport: http(),
|
|
265
|
-
* })
|
|
266
|
-
* const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
|
|
267
|
-
* console.log("entityKey", entityKey)
|
|
268
|
-
* console.log("txHash", txHash)
|
|
269
|
-
* // {
|
|
270
|
-
* // entityKey: "0x123",
|
|
271
|
-
* // txHash: "0x123",
|
|
272
|
-
* // }
|
|
273
|
-
*/
|
|
274
|
-
deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
|
|
275
|
-
/**
|
|
276
|
-
* Extends the entity with the given key.
|
|
277
|
-
*
|
|
278
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
|
|
279
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
280
|
-
*
|
|
281
|
-
* @param args - {entityKey, data}
|
|
282
|
-
* @returns The entity with the given key. {@link Entity}
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* import { createWalletClient, http } from 'arkiv'
|
|
286
|
-
* import { kaolin } from 'arkiv/chains'
|
|
287
|
-
*
|
|
288
|
-
* const client = createWalletClient({
|
|
289
|
-
* chain: kaolin,
|
|
290
|
-
* transport: http(),
|
|
291
|
-
* })
|
|
292
|
-
* const { entityKey, txHash } = await client.extendEntity("0x123", {
|
|
293
|
-
* expiresIn: 1000,
|
|
294
|
-
* })
|
|
295
|
-
* console.log("entityKey", entityKey)
|
|
296
|
-
* console.log("txHash", txHash)
|
|
297
|
-
* // {
|
|
298
|
-
* // entityKey: "0x123",
|
|
299
|
-
* // txHash: "0x123",
|
|
300
|
-
* // }
|
|
301
|
-
*/
|
|
302
|
-
extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
|
|
303
|
-
/**
|
|
304
|
-
* Changes the ownership of the entity with the given address.
|
|
305
|
-
*
|
|
306
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
|
|
307
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
308
|
-
*
|
|
309
|
-
* @param args - {entityKey, newOwner}
|
|
310
|
-
* @returns The entity with the given address. {@link Entity}
|
|
311
|
-
*/
|
|
312
|
-
changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>;
|
|
313
|
-
/**
|
|
314
|
-
* Mutates the entities with the given keys.
|
|
315
|
-
*
|
|
316
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
|
|
317
|
-
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
318
|
-
*
|
|
319
|
-
* @param args - {data}
|
|
320
|
-
* @returns The entity with the given key. {@link Entity}
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* import { createWalletClient, http } from 'arkiv'
|
|
324
|
-
* import { kaolin } from 'arkiv/chains'
|
|
325
|
-
*
|
|
326
|
-
* const client = createWalletClient({
|
|
327
|
-
* chain: kaolin,
|
|
328
|
-
* transport: http(),
|
|
329
|
-
* })
|
|
330
|
-
* const { entityKey, txHash } = await client.mutateEntities({
|
|
331
|
-
* creates: [{
|
|
332
|
-
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
333
|
-
* attriubutes: [{ key: "testKey", value: "testValue" }],
|
|
334
|
-
* expiresIn: 1000,
|
|
335
|
-
* }],
|
|
336
|
-
* updates: [{
|
|
337
|
-
* entityKey: "0x123",
|
|
338
|
-
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
339
|
-
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
340
|
-
* expiresIn: 1000,
|
|
341
|
-
* }],
|
|
342
|
-
* deletes: [{
|
|
343
|
-
* entityKey: "0x321",
|
|
344
|
-
* }],
|
|
345
|
-
* extensions: [{
|
|
346
|
-
* entityKey: "0x1234",
|
|
347
|
-
* expiresIn: 1000,
|
|
348
|
-
* }],
|
|
349
|
-
* })
|
|
350
|
-
* console.log("entityKey", entityKey)
|
|
351
|
-
* console.log("txHash", txHash)
|
|
352
|
-
* // {
|
|
353
|
-
* // entityKey: "0x123",
|
|
354
|
-
* // txHash: "0x123",
|
|
355
|
-
* // }
|
|
356
|
-
*/
|
|
357
|
-
mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
|
|
358
|
-
};
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/clients/createWalletClient.d.ts
|
|
361
|
-
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>>>;
|
|
362
|
-
/**
|
|
363
|
-
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
364
|
-
*
|
|
365
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
366
|
-
*
|
|
367
|
-
* 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).
|
|
368
|
-
*
|
|
369
|
-
* @param config - {@link PublicClientConfig}
|
|
370
|
-
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* import { createPublicClient, http } from 'arkiv'
|
|
374
|
-
* import { kaolin } from 'arkiv/chains'
|
|
375
|
-
*
|
|
376
|
-
* const client = createPublicClient({
|
|
377
|
-
* chain: kaolin,
|
|
378
|
-
* transport: http(),
|
|
379
|
-
* })
|
|
380
|
-
*/
|
|
381
|
-
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>;
|
|
382
|
-
//#endregion
|
|
383
|
-
//#region src/utils/chains.d.ts
|
|
384
|
-
/**
|
|
385
|
-
* Get a chain from its name
|
|
386
|
-
* @param name - The name of the chain, case insensitive
|
|
387
|
-
* @returns The chain
|
|
388
|
-
* @throws An error if the chain is not found
|
|
389
|
-
*/
|
|
390
|
-
declare function chainFromName(name: string): Chain;
|
|
391
|
-
//#endregion
|
|
392
|
-
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, type PublicArkivClient, RpcEntity, RpcIncludeData, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
393
|
-
//# sourceMappingURL=index.d.ts.map
|
|
4
|
+
export { ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, PublicArkivActions, PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, WalletArkivActions, WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as chains_exports } from "./chains-BDsOtN2a.js";
|
|
2
|
-
import { a as entityFromRpcResult,
|
|
2
|
+
import { a as entityFromRpcResult, l as getLogger, s as NoEntityFoundError, t as QueryBuilder } from "./queryBuilder-DNUwJvf0.js";
|
|
3
3
|
import { i as BLOCK_TIME, n as stringToPayload, r as ARKIV_ADDRESS, t as jsonToPayload } from "./payload-DKBYYjeA.js";
|
|
4
4
|
import "./types-H-TSmRpm.js";
|
|
5
5
|
import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
|
|
@@ -62,10 +62,32 @@ async function getEntityCount(client) {
|
|
|
62
62
|
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/actions/public/query.ts
|
|
65
|
-
async function query(client, query$1) {
|
|
65
|
+
async function query(client, query$1, queryOptions) {
|
|
66
|
+
const rpcQueryOptions = {
|
|
67
|
+
includeData: {
|
|
68
|
+
key: true,
|
|
69
|
+
payload: queryOptions?.includeData?.payload ?? true,
|
|
70
|
+
attributes: queryOptions?.includeData?.attributes ?? false,
|
|
71
|
+
contentType: queryOptions?.includeData?.metadata ?? false,
|
|
72
|
+
expiration: queryOptions?.includeData?.metadata ?? false,
|
|
73
|
+
owner: queryOptions?.includeData?.metadata ?? false,
|
|
74
|
+
createdAtBlock: queryOptions?.includeData?.metadata ?? false,
|
|
75
|
+
lastModifiedAtBlock: queryOptions?.includeData?.metadata ?? false,
|
|
76
|
+
transactionIndexInBlock: queryOptions?.includeData?.metadata ?? false,
|
|
77
|
+
operationIndexInTransaction: queryOptions?.includeData?.metadata ?? false
|
|
78
|
+
},
|
|
79
|
+
...queryOptions?.atBlock !== void 0 && { atBlock: Number(queryOptions.atBlock) },
|
|
80
|
+
...queryOptions?.orderBy && { orderBy: queryOptions?.orderBy.map((order) => ({
|
|
81
|
+
name: order.name,
|
|
82
|
+
type: order.type,
|
|
83
|
+
desc: order.desc === "desc"
|
|
84
|
+
})) },
|
|
85
|
+
...queryOptions?.resultsPerPage !== void 0 && { resultsPerPage: queryOptions.resultsPerPage },
|
|
86
|
+
...queryOptions?.cursor !== void 0 && { cursor: queryOptions?.cursor }
|
|
87
|
+
};
|
|
66
88
|
const result = await client.request({
|
|
67
89
|
method: "arkiv_query",
|
|
68
|
-
params: [query$1]
|
|
90
|
+
params: [query$1, rpcQueryOptions]
|
|
69
91
|
});
|
|
70
92
|
return await Promise.all(result.data.map((entity) => entityFromRpcResult(entity)));
|
|
71
93
|
}
|
|
@@ -159,7 +181,7 @@ async function subscribeEntityEvents(client, { onError, onEntityCreated, onEntit
|
|
|
159
181
|
function publicArkivActions(client) {
|
|
160
182
|
return {
|
|
161
183
|
getEntity: (key) => getEntity(client, key),
|
|
162
|
-
query: (rawQuery) => query(client, rawQuery),
|
|
184
|
+
query: (rawQuery, queryOptions) => query(client, rawQuery, queryOptions),
|
|
163
185
|
buildQuery: () => new QueryBuilder(client),
|
|
164
186
|
getBlockTiming: () => getBlockTiming(client),
|
|
165
187
|
getEntityCount: () => getEntityCount(client),
|
|
@@ -183,7 +205,7 @@ function publicArkivActions(client) {
|
|
|
183
205
|
*
|
|
184
206
|
* 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).
|
|
185
207
|
*
|
|
186
|
-
* @param
|
|
208
|
+
* @param parameters - Configuration object for the public client (chain, transport, etc.)
|
|
187
209
|
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
188
210
|
*
|
|
189
211
|
* @example
|
|
@@ -224,7 +246,7 @@ async function getBrotli() {
|
|
|
224
246
|
if (brotli) return brotli;
|
|
225
247
|
try {
|
|
226
248
|
const brotliModule = await import("brotli-wasm");
|
|
227
|
-
brotli = brotliModule.default
|
|
249
|
+
brotli = brotliModule.default ? await brotliModule.default : brotliModule;
|
|
228
250
|
} catch (error) {
|
|
229
251
|
console.error("Error importing brotli-wasm", error);
|
|
230
252
|
return null;
|
|
@@ -449,8 +471,8 @@ function walletArkivActions(client) {
|
|
|
449
471
|
*
|
|
450
472
|
* 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).
|
|
451
473
|
*
|
|
452
|
-
* @param
|
|
453
|
-
* @returns A Arkiv
|
|
474
|
+
* @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
|
|
475
|
+
* @returns A Arkiv Wallet Client. {@link WalletArkivClient}
|
|
454
476
|
*
|
|
455
477
|
* @example
|
|
456
478
|
* import { createPublicClient, http } from 'arkiv'
|