@arkiv-network/sdk 0.5.0-dev.3 → 0.5.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +34 -14
- package/dist/index.d.cts +397 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +397 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -16
- package/dist/index.js.map +1 -1
- package/dist/{payload-D3fyOBWn.d.cts → payload-CJN8fTvX.d.cts} +1 -1
- package/dist/{payload-D3fyOBWn.d.cts.map → payload-CJN8fTvX.d.cts.map} +1 -1
- package/dist/{payload-BI2NXPDf.d.ts → payload-Da9gJMG5.d.ts} +1 -1
- package/dist/{payload-BI2NXPDf.d.ts.map → payload-Da9gJMG5.d.ts.map} +1 -1
- package/dist/query/index.cjs +1 -4
- package/dist/query/index.d.cts +3 -16
- package/dist/query/index.d.ts +3 -16
- package/dist/query/index.js +2 -2
- package/dist/query-C0dwQYxT.d.cts +320 -0
- package/dist/query-C0dwQYxT.d.cts.map +1 -0
- package/dist/query-DybEplzd.d.ts +320 -0
- package/dist/query-DybEplzd.d.ts.map +1 -0
- package/dist/{queryBuilder-DMzL_J5-.js → queryBuilder-BkWFLc3Y.js} +12 -3
- package/dist/queryBuilder-BkWFLc3Y.js.map +1 -0
- package/dist/{queryBuilder-B7063DYt.cjs → queryBuilder-BozfXlzA.cjs} +16 -1
- package/dist/queryBuilder-DfetMC5Z.d.cts +317 -0
- package/dist/queryBuilder-DfetMC5Z.d.cts.map +1 -0
- package/dist/queryBuilder-XIln1aIM.d.ts +317 -0
- package/dist/queryBuilder-XIln1aIM.d.ts.map +1 -0
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/actions/public/getEntity.ts +1 -1
- package/src/actions/public/query.ts +12 -1
- package/src/clients/decorators/arkivPublic.ts +5 -5
- package/src/clients/decorators/arkivWallet.ts +2 -2
- package/src/{query/errors.ts → errors.ts} +10 -0
- package/src/index.ts +2 -2
- package/src/query/index.ts +0 -1
- package/src/query/queryResult.test.ts +1 -1
- package/src/query/queryResult.ts +1 -1
- package/src/types/index.ts +1 -0
- package/src/types/rpcSchema.ts +1 -1
- package/src/utils/arkivTransactions.ts +31 -13
- package/dist/index-B801JxcV.d.ts +0 -1003
- package/dist/index-B801JxcV.d.ts.map +0 -1
- package/dist/index-DQGx5KZ6.d.cts +0 -1003
- package/dist/index-DQGx5KZ6.d.cts.map +0 -1
- package/dist/query/index.d.cts.map +0 -1
- package/dist/query/index.d.ts.map +0 -1
- package/dist/queryBuilder-DMzL_J5-.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,398 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { A as RpcIncludeData, C as CreateEntityReturnType, D as ArkivClient, E as GetBlockTimingReturnType, M as RpcQueryOptions, N as MimeType, O as ArkivRpcSchema, S as CreateEntityParameters, T as ChangeOwnershipReturnType, _ as UpdateEntityReturnType, a as Entity, b as DeleteEntityParameters, c as OnEntityDeletedEvent, d as OnEntityOwnerChangedEvent, f as OnEntityUpdatedEvent, g as UpdateEntityParameters, h as MutateEntitiesReturnType, i as QueryReturnType, j as RpcOrderByAttribute, k as RpcEntity, l as OnEntityExpiredEvent, m as MutateEntitiesParameters, n as QueryOptionsIncludeData, o as TxParams, p as Attribute, r as QueryOptionsOrderBy, s as OnEntityCreatedEvent, t as QueryOptions, u as OnEntityExpiresInExtendedEvent, v as ExtendEntityParameters, w as ChangeOwnershipParameters, x as DeleteEntityReturnType, y as ExtendEntityReturnType } from "./query-DybEplzd.js";
|
|
2
|
+
import { n as QueryBuilder } from "./queryBuilder-XIln1aIM.js";
|
|
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";
|
|
3
5
|
export * from "viem";
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
//#region src/clients/decorators/arkivPublic.d.ts
|
|
8
|
+
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"> & {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the entity with the given key.
|
|
11
|
+
*
|
|
12
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
13
|
+
*
|
|
14
|
+
* @param key - The entity key (hex string)
|
|
15
|
+
* @returns The entity with the given key. {@link Entity}
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
19
|
+
* import { kaolin } from 'arkiv/chains'
|
|
20
|
+
*
|
|
21
|
+
* const client = createPublicClient({
|
|
22
|
+
* chain: kaolin,
|
|
23
|
+
* transport: http(),
|
|
24
|
+
* })
|
|
25
|
+
* const entity = await client.getEntity("0x123")
|
|
26
|
+
* // {
|
|
27
|
+
* // key: "0x123",
|
|
28
|
+
* // value: "0x123",
|
|
29
|
+
* // }
|
|
30
|
+
*/
|
|
31
|
+
getEntity: (key: Hex) => Promise<Entity>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a QueryBuilder instance for building and executing queries.
|
|
34
|
+
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
35
|
+
*
|
|
36
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
37
|
+
*
|
|
38
|
+
* @returns A QueryBuilder instance for building and executing queries. {@link QueryBuilder}
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
42
|
+
* import { kaolin } from 'arkiv/chains'
|
|
43
|
+
*
|
|
44
|
+
* const client = createPublicClient({
|
|
45
|
+
* chain: kaolin,
|
|
46
|
+
* transport: http(),
|
|
47
|
+
* })
|
|
48
|
+
* const query = client.buildQuery()
|
|
49
|
+
* const entities = await query.where("key", "=", "value").ownedBy("0x123").fetch()
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
buildQuery: () => QueryBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a QueryResult instance for fetching the results of a raw query.
|
|
55
|
+
* If no query options are provided, all payload is included, but no metadata (like owner, expiredAt, etc.) and attributes.
|
|
56
|
+
* @param query - The raw query string
|
|
57
|
+
* @param queryOptions - The optional query options - {@link QueryOptions}
|
|
58
|
+
* @returns A QueryReturnType instance - {@link QueryReturnType}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
62
|
+
* import { kaolin } from 'arkiv/chains'
|
|
63
|
+
*
|
|
64
|
+
* const client = createPublicClient({
|
|
65
|
+
* chain: kaolin,
|
|
66
|
+
* transport: http(),
|
|
67
|
+
* })
|
|
68
|
+
* const queryResult = client.query('key = value && $owner = 0x123')
|
|
69
|
+
* // queryResult = { entities: [{ key: "0x123", value: "0x123" }], cursor: undefined, blockNumber: undefined }
|
|
70
|
+
* const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
|
|
71
|
+
* includeData: {
|
|
72
|
+
* attributes: false,
|
|
73
|
+
* payload: true,
|
|
74
|
+
* metadata: true,
|
|
75
|
+
* },
|
|
76
|
+
* orderBy: [{ name: "key", type: "string", desc: "asc" }],
|
|
77
|
+
* resultsPerPage: 10,
|
|
78
|
+
* cursor: undefined,
|
|
79
|
+
* atBlock: undefined,
|
|
80
|
+
* })
|
|
81
|
+
* // queryResultWithOptions = { entities: [{ key: "0x123", value: "0x123" }], cursor: "...", blockNumber: 32223n }
|
|
82
|
+
*/
|
|
83
|
+
query: (query: string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the number of entities in the DBChain.
|
|
86
|
+
* @returns The number of entities in the DBChain
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
90
|
+
* import { kaolin } from 'arkiv/chains'
|
|
91
|
+
*
|
|
92
|
+
* const client = createPublicClient({
|
|
93
|
+
* chain: kaolin,
|
|
94
|
+
* transport: http(),
|
|
95
|
+
* })
|
|
96
|
+
* const entityCount = await client.getEntityCount()
|
|
97
|
+
* // entityCount = 0
|
|
98
|
+
*/
|
|
99
|
+
getEntityCount: () => Promise<number>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the current block timing.
|
|
102
|
+
* @returns The current block timing. {@link GetBlockTimingReturnType}
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
106
|
+
* import { kaolin } from 'arkiv/chains'
|
|
107
|
+
*
|
|
108
|
+
* const client = createPublicClient({
|
|
109
|
+
* chain: kaolin,
|
|
110
|
+
* transport: http(),
|
|
111
|
+
* })
|
|
112
|
+
* const blockTiming = await client.getBlockTiming()
|
|
113
|
+
* // {
|
|
114
|
+
* // currentBlock: 10n, // block number
|
|
115
|
+
* // currentBlockTime: 1234567890, // block timestamp
|
|
116
|
+
* // blockDuration: 2, // in seconds
|
|
117
|
+
* // }
|
|
118
|
+
*/
|
|
119
|
+
getBlockTiming: () => Promise<{
|
|
120
|
+
currentBlock: bigint;
|
|
121
|
+
currentBlockTime: number;
|
|
122
|
+
blockDuration: number;
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* Subscribes to entity events.
|
|
126
|
+
* Takes an object with event handlers: {onError, onEntityCreated, onEntityUpdated, onEntityDeleted, onEntityExpiresInExtended}
|
|
127
|
+
* @param pollingInterval - The polling interval in milliseconds
|
|
128
|
+
* @param fromBlock - The block number to start from
|
|
129
|
+
* @returns A function to unsubscribe from the events
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
133
|
+
* import { kaolin } from 'arkiv/chains'
|
|
134
|
+
*
|
|
135
|
+
* const client = createPublicClient({
|
|
136
|
+
* chain: kaolin,
|
|
137
|
+
* transport: http(),
|
|
138
|
+
* })
|
|
139
|
+
* const unsubscribe = await client.subscribeEntityEvents({
|
|
140
|
+
* onError: (error) => console.error("subscribeEntityEvents error", error),
|
|
141
|
+
* })
|
|
142
|
+
* unsubscribe() // unsubscribe from the events
|
|
143
|
+
*/
|
|
144
|
+
subscribeEntityEvents: ({
|
|
145
|
+
onError,
|
|
146
|
+
onEntityCreated,
|
|
147
|
+
onEntityUpdated,
|
|
148
|
+
onEntityDeleted,
|
|
149
|
+
onEntityExpiresInExtended
|
|
150
|
+
}: {
|
|
151
|
+
onError?: (error: Error) => void;
|
|
152
|
+
onEntityCreated?: (event: OnEntityCreatedEvent) => void;
|
|
153
|
+
onEntityUpdated?: (event: OnEntityUpdatedEvent) => void;
|
|
154
|
+
onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
|
|
155
|
+
onEntityExpired?: (event: OnEntityExpiredEvent) => void;
|
|
156
|
+
onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
|
|
157
|
+
}, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
|
|
158
|
+
};
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/clients/createPublicClient.d.ts
|
|
161
|
+
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>>>;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
164
|
+
*
|
|
165
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
166
|
+
*
|
|
167
|
+
* 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).
|
|
168
|
+
*
|
|
169
|
+
* @param parameters - Configuration object for the public client (chain, transport, etc.)
|
|
170
|
+
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
174
|
+
* import { kaolin } from 'arkiv/chains'
|
|
175
|
+
*
|
|
176
|
+
* const client = createPublicClient({
|
|
177
|
+
* chain: kaolin,
|
|
178
|
+
* transport: http(),
|
|
179
|
+
* })
|
|
180
|
+
*/
|
|
181
|
+
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>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/clients/decorators/arkivWallet.d.ts
|
|
184
|
+
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" | "sendCalls" | "waitForCallsStatus" | "sendTransaction" | "sendRawTransaction" | "signMessage" | "signTransaction"> & {
|
|
185
|
+
/**
|
|
186
|
+
* Creates a new entity.
|
|
187
|
+
*
|
|
188
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/createEntity
|
|
189
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
190
|
+
*
|
|
191
|
+
* @param data - The entity creation parameters
|
|
192
|
+
* @param txParams - Optional transaction parameters
|
|
193
|
+
* @returns The created entity with transaction hash
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
197
|
+
* import { kaolin } from 'arkiv/chains'
|
|
198
|
+
*
|
|
199
|
+
* const client = createPublicClient({
|
|
200
|
+
* chain: kaolin,
|
|
201
|
+
* transport: http(),
|
|
202
|
+
* })
|
|
203
|
+
* const { entityKey, txHash } = await client.createEntity({
|
|
204
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
205
|
+
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
206
|
+
* expiresIn: 1000,
|
|
207
|
+
* })
|
|
208
|
+
* console.log("entityKey", entityKey)
|
|
209
|
+
* console.log("txHash", txHash)
|
|
210
|
+
* // {
|
|
211
|
+
* // entityKey: "0x123",
|
|
212
|
+
* // txHash: "0x123",
|
|
213
|
+
* // }
|
|
214
|
+
*/
|
|
215
|
+
createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
|
|
216
|
+
/**
|
|
217
|
+
* Updates the entity with the given key.
|
|
218
|
+
*
|
|
219
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/updateEntity
|
|
220
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
221
|
+
*
|
|
222
|
+
* @param data - The entity update parameters
|
|
223
|
+
* @param txParams - Optional transaction parameters
|
|
224
|
+
* @returns The updated entity with transaction hash
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
228
|
+
* import { kaolin } from 'arkiv/chains'
|
|
229
|
+
*
|
|
230
|
+
* const client = createWalletClient({
|
|
231
|
+
* chain: kaolin,
|
|
232
|
+
* transport: http(),
|
|
233
|
+
* })
|
|
234
|
+
*/
|
|
235
|
+
updateEntity: (data: UpdateEntityParameters, txParams?: TxParams) => Promise<UpdateEntityReturnType>;
|
|
236
|
+
/**
|
|
237
|
+
* Deletes the entity with the given key.
|
|
238
|
+
*
|
|
239
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/deleteEntity
|
|
240
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
241
|
+
*
|
|
242
|
+
* @param data - The entity deletion parameters
|
|
243
|
+
* @param txParams - Optional transaction parameters
|
|
244
|
+
* @returns The deleted entity with transaction hash
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
248
|
+
* import { kaolin } from 'arkiv/chains'
|
|
249
|
+
*
|
|
250
|
+
* const client = createWalletClient({
|
|
251
|
+
* chain: kaolin,
|
|
252
|
+
* transport: http(),
|
|
253
|
+
* })
|
|
254
|
+
* const { entityKey, txHash } = await client.deleteEntity({ entityKey: "0x123" })
|
|
255
|
+
* console.log("entityKey", entityKey)
|
|
256
|
+
* console.log("txHash", txHash)
|
|
257
|
+
* // {
|
|
258
|
+
* // entityKey: "0x123",
|
|
259
|
+
* // txHash: "0x123",
|
|
260
|
+
* // }
|
|
261
|
+
*/
|
|
262
|
+
deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
|
|
263
|
+
/**
|
|
264
|
+
* Extends the entity with the given key.
|
|
265
|
+
*
|
|
266
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
|
|
267
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
268
|
+
*
|
|
269
|
+
* @param data - The entity update parameters
|
|
270
|
+
* @param txParams - Optional transaction parameters
|
|
271
|
+
* @returns The updated entity with transaction hash
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
275
|
+
* import { kaolin } from 'arkiv/chains'
|
|
276
|
+
*
|
|
277
|
+
* const client = createWalletClient({
|
|
278
|
+
* chain: kaolin,
|
|
279
|
+
* transport: http(),
|
|
280
|
+
* })
|
|
281
|
+
* const { entityKey, txHash } = await client.extendEntity("0x123", {
|
|
282
|
+
* expiresIn: 1000,
|
|
283
|
+
* })
|
|
284
|
+
* console.log("entityKey", entityKey)
|
|
285
|
+
* console.log("txHash", txHash)
|
|
286
|
+
* // {
|
|
287
|
+
* // entityKey: "0x123",
|
|
288
|
+
* // txHash: "0x123",
|
|
289
|
+
* // }
|
|
290
|
+
*/
|
|
291
|
+
extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
|
|
292
|
+
/**
|
|
293
|
+
* Changes the ownership of the entity with the given address.
|
|
294
|
+
*
|
|
295
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/changeOwnership
|
|
296
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
297
|
+
*
|
|
298
|
+
* @param data - The ownership change parameters
|
|
299
|
+
* @param txParams - Optional transaction parameters
|
|
300
|
+
* @returns The entity with updated ownership and transaction hash
|
|
301
|
+
*/
|
|
302
|
+
changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>;
|
|
303
|
+
/**
|
|
304
|
+
* Mutates the entities with the given keys.
|
|
305
|
+
*
|
|
306
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
|
|
307
|
+
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
308
|
+
*
|
|
309
|
+
* @param data - The mutation parameters (creates, updates, deletes, extensions)
|
|
310
|
+
* @param txParams - Optional transaction parameters
|
|
311
|
+
* @returns The mutation result with transaction hash
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* import { createWalletClient, http } from 'arkiv'
|
|
315
|
+
* import { kaolin } from 'arkiv/chains'
|
|
316
|
+
*
|
|
317
|
+
* const client = createWalletClient({
|
|
318
|
+
* chain: kaolin,
|
|
319
|
+
* transport: http(),
|
|
320
|
+
* })
|
|
321
|
+
* const { entityKey, txHash } = await client.mutateEntities({
|
|
322
|
+
* creates: [{
|
|
323
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
324
|
+
* attriubutes: [{ key: "testKey", value: "testValue" }],
|
|
325
|
+
* expiresIn: 1000,
|
|
326
|
+
* }],
|
|
327
|
+
* updates: [{
|
|
328
|
+
* entityKey: "0x123",
|
|
329
|
+
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
330
|
+
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
331
|
+
* expiresIn: 1000,
|
|
332
|
+
* }],
|
|
333
|
+
* deletes: [{
|
|
334
|
+
* entityKey: "0x321",
|
|
335
|
+
* }],
|
|
336
|
+
* extensions: [{
|
|
337
|
+
* entityKey: "0x1234",
|
|
338
|
+
* expiresIn: 1000,
|
|
339
|
+
* }],
|
|
340
|
+
* })
|
|
341
|
+
* console.log("entityKey", entityKey)
|
|
342
|
+
* console.log("txHash", txHash)
|
|
343
|
+
* // {
|
|
344
|
+
* // entityKey: "0x123",
|
|
345
|
+
* // txHash: "0x123",
|
|
346
|
+
* // }
|
|
347
|
+
*/
|
|
348
|
+
mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
|
|
349
|
+
};
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/clients/createWalletClient.d.ts
|
|
352
|
+
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>>>;
|
|
353
|
+
/**
|
|
354
|
+
* Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/clients/chains).
|
|
355
|
+
*
|
|
356
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
357
|
+
*
|
|
358
|
+
* 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).
|
|
359
|
+
*
|
|
360
|
+
* @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
|
|
361
|
+
* @returns A Arkiv Wallet Client. {@link WalletArkivClient}
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* import { createPublicClient, http } from 'arkiv'
|
|
365
|
+
* import { kaolin } from 'arkiv/chains'
|
|
366
|
+
*
|
|
367
|
+
* const client = createPublicClient({
|
|
368
|
+
* chain: kaolin,
|
|
369
|
+
* transport: http(),
|
|
370
|
+
* })
|
|
371
|
+
*/
|
|
372
|
+
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>;
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/errors.d.ts
|
|
375
|
+
declare class EntityMutationError extends Error {
|
|
376
|
+
constructor(message: string);
|
|
377
|
+
}
|
|
378
|
+
declare class NoMoreResultsError extends Error {
|
|
379
|
+
constructor();
|
|
380
|
+
}
|
|
381
|
+
declare class NoCursorOrLimitError extends Error {
|
|
382
|
+
constructor();
|
|
383
|
+
}
|
|
384
|
+
declare class NoEntityFoundError extends Error {
|
|
385
|
+
constructor();
|
|
386
|
+
}
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/utils/chains.d.ts
|
|
389
|
+
/**
|
|
390
|
+
* Get a chain from its name
|
|
391
|
+
* @param name - The name of the chain, case insensitive
|
|
392
|
+
* @returns The chain
|
|
393
|
+
* @throws An error if the chain is not found
|
|
394
|
+
*/
|
|
395
|
+
declare function chainFromName(name: string): Chain;
|
|
396
|
+
//#endregion
|
|
397
|
+
export { type ArkivClient, ArkivRpcSchema, Attribute, ChangeOwnershipParameters, ChangeOwnershipReturnType, CreateEntityParameters, CreateEntityReturnType, DeleteEntityParameters, DeleteEntityReturnType, Entity, EntityMutationError, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, MimeType, MutateEntitiesParameters, MutateEntitiesReturnType, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, OnEntityCreatedEvent, OnEntityDeletedEvent, OnEntityExpiredEvent, OnEntityExpiresInExtendedEvent, OnEntityOwnerChangedEvent, OnEntityUpdatedEvent, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryOptionsIncludeData, QueryOptionsOrderBy, QueryReturnType, RpcEntity, RpcIncludeData, RpcOrderByAttribute, RpcQueryOptions, TxParams, UpdateEntityParameters, UpdateEntityReturnType, type WalletArkivActions, type WalletArkivClient, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
398
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/clients/decorators/arkivPublic.ts","../src/clients/createPublicClient.ts","../src/clients/decorators/arkivWallet.ts","../src/clients/createWalletClient.ts","../src/errors.ts","../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A,SAAA,GAAA,SAAA,EAAA,kBG9BA,SH8BA,GAAA,SAAA,GG9BwB,cH8BxB,CAAA,CAAA,UAAA,EG5BN,kBH4BM,CG5Ba,SH4Bb,EG5BwB,KH4BxB,EG5B+B,gBH4B/B,EG5BiD,SH4BjD,CAAA,CAAA,EG3BjB,iBH2BiB,CG3BC,SH2BD,EG3BY,KH2BZ,EG3BmB,YH2BnB,CG3BgC,gBH2BhC,CAAA,EG3BmD,SH2BnD,CAAA;;;cI7EP,mBAAA,SAA4B,KAAA;;;cAO5B,kBAAA,SAA2B,KAAA;;;cAO3B,oBAAA,SAA6B,KAAA;;AJE1C;AACoB,cIIP,kBAAA,SAA2B,KAAA,CJJpB;EAAY,WAAA,CAAA;;;;;;;;;;iBKLhB,aAAA,gBAA6B"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as chains_exports } from "./chains-BDsOtN2a.js";
|
|
2
|
-
import { a as entityFromRpcResult, l as
|
|
2
|
+
import { a as entityFromRpcResult, c as NoEntityFoundError, l as NoMoreResultsError, o as EntityMutationError, s as NoCursorOrLimitError, t as QueryBuilder, u as getLogger } from "./queryBuilder-BkWFLc3Y.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
|
-
import { bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
|
|
5
|
+
import { TransactionExecutionError, bytesToHex, createClient, decodeEventLog, hexToBytes, parseAbi, publicActions, toBytes, toHex, toRlp, walletActions } from "viem";
|
|
6
6
|
|
|
7
7
|
export * from "viem"
|
|
8
8
|
|
|
@@ -89,7 +89,11 @@ async function query(client, query$1, queryOptions) {
|
|
|
89
89
|
method: "arkiv_query",
|
|
90
90
|
params: [query$1, rpcQueryOptions]
|
|
91
91
|
});
|
|
92
|
-
return
|
|
92
|
+
return {
|
|
93
|
+
entities: await Promise.all(result.data.map((entity) => entityFromRpcResult(entity))),
|
|
94
|
+
cursor: result.cursor,
|
|
95
|
+
blockNumber: BigInt(result.blockNumber)
|
|
96
|
+
};
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
//#endregion
|
|
@@ -318,18 +322,30 @@ async function sendArkivTransaction(client, data, txParams) {
|
|
|
318
322
|
data,
|
|
319
323
|
...txParams
|
|
320
324
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
325
|
+
try {
|
|
326
|
+
const compressed = await compress(toBytes(data));
|
|
327
|
+
const txHash = await walletClient.sendTransaction({
|
|
328
|
+
account: client.account,
|
|
329
|
+
chain: client.chain,
|
|
330
|
+
to: ARKIV_ADDRESS,
|
|
331
|
+
value: 0n,
|
|
332
|
+
data: toHex(compressed),
|
|
333
|
+
...txParams
|
|
334
|
+
});
|
|
335
|
+
const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash });
|
|
336
|
+
logger$6("Tx receipt %o", receipt);
|
|
337
|
+
if (receipt.status === "reverted") {
|
|
338
|
+
logger$6("Reverted transaction %o", receipt);
|
|
339
|
+
throw new EntityMutationError(`Transaction ${receipt.transactionHash} reverted. Please make sure the data for entities doesn't contain invalid characters or invalid data types.`);
|
|
340
|
+
}
|
|
341
|
+
return receipt;
|
|
342
|
+
} catch (error) {
|
|
343
|
+
let message = "Transaction failed";
|
|
344
|
+
if (error instanceof TransactionExecutionError) message += `: ${error.details}`;
|
|
345
|
+
else if (error instanceof EntityMutationError) throw error;
|
|
346
|
+
logger$6("%s Detailed error stack: %o", message, error);
|
|
347
|
+
throw new EntityMutationError(message);
|
|
348
|
+
}
|
|
333
349
|
}
|
|
334
350
|
|
|
335
351
|
//#endregion
|
|
@@ -508,5 +524,5 @@ function chainFromName(name) {
|
|
|
508
524
|
}
|
|
509
525
|
|
|
510
526
|
//#endregion
|
|
511
|
-
export { chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
527
|
+
export { EntityMutationError, NoCursorOrLimitError, NoEntityFoundError, NoMoreResultsError, chainFromName, createPublicClient, createWalletClient, jsonToPayload, stringToPayload };
|
|
512
528
|
//# sourceMappingURL=index.js.map
|