@arkiv-network/sdk 0.7.0-dev.1 → 0.8.0-advanced.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/README.md +71 -16
- package/dist/actions/advanced/index.cjs +13 -0
- package/dist/actions/advanced/index.d.cts +8 -0
- package/dist/actions/advanced/index.d.ts +9 -0
- package/dist/actions/advanced/index.js +9 -0
- package/dist/advanced-8ZPTmmaN.js +598 -0
- package/dist/advanced-8ZPTmmaN.js.map +1 -0
- package/dist/advanced-fPImL6lW.cjs +656 -0
- package/dist/arkivTransactions-D74gERHG.d.cts +571 -0
- package/dist/arkivTransactions-D74gERHG.d.cts.map +1 -0
- package/dist/arkivTransactions-NtGD6uk5.d.ts +571 -0
- package/dist/arkivTransactions-NtGD6uk5.d.ts.map +1 -0
- package/dist/attr/index.cjs +35 -0
- package/dist/attr/index.d.cts +2 -0
- package/dist/attr/index.d.ts +3 -0
- package/dist/attr/index.js +4 -0
- package/dist/attributes-BhY5DwJp.js +809 -0
- package/dist/attributes-BhY5DwJp.js.map +1 -0
- package/dist/attributes-Df9IsCVs.cjs +1029 -0
- package/dist/chains/index.cjs +2 -3
- package/dist/chains/index.d.cts +22 -60
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +22 -60
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +2 -2
- package/dist/chains-BJrZs6sG.js +57 -0
- package/dist/chains-BJrZs6sG.js.map +1 -0
- package/dist/chains-BYRTTipa.cjs +73 -0
- package/dist/codec-Car3KkFF.d.ts +102 -0
- package/dist/codec-Car3KkFF.d.ts.map +1 -0
- package/dist/entity/index.cjs +20 -0
- package/dist/entity/index.d.cts +4 -0
- package/dist/entity/index.d.ts +5 -0
- package/dist/entity/index.js +7 -0
- package/dist/entity-B00Li04j.cjs +71 -0
- package/dist/entity-B7G8q_Eo.cjs +0 -0
- package/dist/entity-BYQR1uoe.js +67 -0
- package/dist/entity-BYQR1uoe.js.map +1 -0
- package/dist/entity-CD_qFF2M.js +0 -0
- package/dist/errors-BVbjKVMN.cjs +56 -0
- package/dist/errors-LTe7bOYS.js +33 -0
- package/dist/errors-LTe7bOYS.js.map +1 -0
- package/dist/expiry-BELY2Kpw.cjs +135 -0
- package/dist/expiry-BjpxZZQU.js +95 -0
- package/dist/expiry-BjpxZZQU.js.map +1 -0
- package/dist/expiry-DRV29F1r.d.cts +79 -0
- package/dist/expiry-DRV29F1r.d.cts.map +1 -0
- package/dist/expiry-nDbCgZX4.d.ts +79 -0
- package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
- package/dist/flags-5dTNRnow.d.ts +41 -0
- package/dist/flags-5dTNRnow.d.ts.map +1 -0
- package/dist/flags-CRjPpoh3.d.cts +41 -0
- package/dist/flags-CRjPpoh3.d.cts.map +1 -0
- package/dist/flags-DFBs2J94.js +33 -0
- package/dist/flags-DFBs2J94.js.map +1 -0
- package/dist/flags-kr276q6i.cjs +43 -0
- package/dist/index-B5j76711.d.ts +184 -0
- package/dist/index-B5j76711.d.ts.map +1 -0
- package/dist/index-BF7Mq9Is.d.cts +280 -0
- package/dist/index-BF7Mq9Is.d.cts.map +1 -0
- package/dist/index-CA4V7Pdh.d.cts +167 -0
- package/dist/index-CA4V7Pdh.d.cts.map +1 -0
- package/dist/index-CV5zCdpa.d.cts +417 -0
- package/dist/index-CV5zCdpa.d.cts.map +1 -0
- package/dist/index-DHDud2hC.d.ts +280 -0
- package/dist/index-DHDud2hC.d.ts.map +1 -0
- package/dist/index-DvYvrkdk.d.ts +320 -0
- package/dist/index-DvYvrkdk.d.ts.map +1 -0
- package/dist/index-EeUO0nnJ.d.cts +184 -0
- package/dist/index-EeUO0nnJ.d.cts.map +1 -0
- package/dist/index-fX_XyqLp.d.ts +167 -0
- package/dist/index-fX_XyqLp.d.ts.map +1 -0
- package/dist/index.cjs +411 -405
- package/dist/index.d.cts +360 -209
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +361 -209
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +342 -387
- package/dist/index.js.map +1 -1
- package/dist/key-D1Bh7MF0.js +70 -0
- package/dist/key-D1Bh7MF0.js.map +1 -0
- package/dist/key-WKhXnXuU.cjs +98 -0
- package/dist/logger-CVpvU8ik.js +153 -0
- package/dist/logger-CVpvU8ik.js.map +1 -0
- package/dist/logger-Cr15lPAQ.cjs +188 -0
- package/dist/payload-BNoud2KZ.d.cts +94 -0
- package/dist/payload-BNoud2KZ.d.cts.map +1 -0
- package/dist/payload-Bz6651ax.js +67 -0
- package/dist/payload-Bz6651ax.js.map +1 -0
- package/dist/payload-CcUj85ys.d.ts +94 -0
- package/dist/payload-CcUj85ys.d.ts.map +1 -0
- package/dist/payload-KC14SDlN.cjs +83 -0
- package/dist/query/index.cjs +26 -150
- package/dist/query/index.d.cts +5 -3
- package/dist/query/index.d.ts +6 -3
- package/dist/query/index.js +8 -138
- package/dist/queryBuilder-DM6AWCBa.js +820 -0
- package/dist/queryBuilder-DM6AWCBa.js.map +1 -0
- package/dist/queryBuilder-DbUMEZln.cjs +944 -0
- package/dist/selection-C4UhsMOO.d.ts +434 -0
- package/dist/selection-C4UhsMOO.d.ts.map +1 -0
- package/dist/selection-DPg0uyJf.d.cts +433 -0
- package/dist/selection-DPg0uyJf.d.cts.map +1 -0
- package/dist/types/index.cjs +3 -3
- package/dist/types/index.d.cts +7 -2
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.js +3 -3
- package/dist/types-Bu_ZwMbZ.js +0 -0
- package/dist/types-NRqymi6S.cjs +0 -0
- package/dist/utils/index.cjs +4 -17
- package/dist/utils/index.d.cts +3 -17
- package/dist/utils/index.d.ts +3 -17
- package/dist/utils/index.js +4 -18
- package/package.json +26 -5
- package/src/actions/advanced/advanced.test.ts +258 -0
- package/src/actions/advanced/buildMutation.ts +104 -0
- package/src/actions/advanced/getMutationResult.ts +112 -0
- package/src/actions/advanced/index.ts +21 -0
- package/src/actions/advanced/pingTransaction.ts +43 -0
- package/src/actions/advanced/sendMutation.ts +59 -0
- package/src/actions/public/getEntity.ts +27 -43
- package/src/actions/public/getEntityNonce.ts +30 -0
- package/src/actions/public/predictEntityKeys.test.ts +143 -0
- package/src/actions/public/predictEntityKeys.ts +138 -0
- package/src/actions/public/query.ts +35 -67
- package/src/actions/public/watchEntityEvents.test.ts +414 -0
- package/src/actions/public/watchEntityEvents.ts +225 -0
- package/src/actions/wallet/changeOwnership.ts +2 -2
- package/src/actions/wallet/createEntity.ts +99 -24
- package/src/actions/wallet/extendEntity.ts +37 -13
- package/src/actions/wallet/mutateEntities.test.ts +76 -0
- package/src/actions/wallet/mutateEntities.ts +16 -33
- package/src/actions/wallet/patchEntity.ts +90 -0
- package/src/attr/attributes.test.ts +120 -0
- package/src/attr/attributes.ts +190 -0
- package/src/attr/codec.test.ts +162 -0
- package/src/attr/codec.ts +220 -0
- package/src/attr/decimal.ts +86 -0
- package/src/attr/errors.ts +145 -0
- package/src/attr/index.ts +50 -0
- package/src/attr/names.ts +106 -0
- package/src/attr/types.ts +150 -0
- package/src/attr/values.test.ts +271 -0
- package/src/attr/values.ts +502 -0
- package/src/chains/cheesecake.ts +22 -0
- package/src/chains/index.ts +1 -2
- package/src/clients/createPublicClient.test.ts +3 -5
- package/src/clients/createPublicClient.ts +5 -4
- package/src/clients/createWalletClient.test.ts +2 -2
- package/src/clients/createWalletClient.ts +13 -7
- package/src/clients/decorators/arkivAdvanced.ts +144 -0
- package/src/clients/decorators/arkivPublic.ts +172 -139
- package/src/clients/decorators/arkivWallet.ts +101 -94
- package/src/entity/create.test.ts +184 -0
- package/src/entity/errors.ts +38 -0
- package/src/entity/events.ts +16 -0
- package/src/entity/expiry.test.ts +195 -0
- package/src/entity/expiry.ts +181 -0
- package/src/entity/flags.ts +65 -0
- package/src/entity/index.ts +15 -0
- package/src/entity/key.ts +68 -0
- package/src/entity/operations.ts +134 -0
- package/src/entity/params.ts +15 -0
- package/src/errors.ts +26 -49
- package/src/index.ts +19 -0
- package/src/query/engine.ts +68 -137
- package/src/query/errors.ts +151 -0
- package/src/query/expression.test.ts +286 -0
- package/src/query/expression.ts +493 -0
- package/src/query/index.ts +40 -4
- package/src/query/injection.test.ts +151 -0
- package/src/query/queryBuilder.test.ts +342 -637
- package/src/query/queryBuilder.ts +133 -359
- package/src/query/queryResult.ts +54 -51
- package/src/query/selection.test.ts +48 -98
- package/src/query/selection.ts +77 -65
- package/src/types/entity.test.ts +44 -155
- package/src/types/entity.ts +60 -52
- package/src/types/events.ts +59 -16
- package/src/types/index.ts +20 -17
- package/src/types/rpcSchema.ts +69 -37
- package/src/utils/arkivTransactions.test.ts +600 -155
- package/src/utils/arkivTransactions.ts +350 -219
- package/src/utils/chains.test.ts +21 -24
- package/src/utils/compression.ts +1 -1
- package/src/utils/entities.test.ts +62 -0
- package/src/utils/entities.ts +109 -37
- package/src/utils/expirationTime.ts +114 -10
- package/src/utils/logger.ts +2 -2
- package/src/utils/revert.test.ts +99 -0
- package/src/utils/revert.ts +145 -0
- package/dist/chains-BifaY04V.cjs +0 -108
- package/dist/chains-CrtkVbBh.js +0 -86
- package/dist/chains-CrtkVbBh.js.map +0 -1
- package/dist/consts-Bz0LZQZY.js +0 -7
- package/dist/consts-Bz0LZQZY.js.map +0 -1
- package/dist/consts-CxT1-RXU.cjs +0 -18
- package/dist/entity-BhSXaB23.cjs +0 -81
- package/dist/entity-CN41IOrq.d.cts +0 -401
- package/dist/entity-CN41IOrq.d.cts.map +0 -1
- package/dist/entity-DGfVyB-a.js +0 -71
- package/dist/entity-DGfVyB-a.js.map +0 -1
- package/dist/entity-NnEVlePN.d.ts +0 -401
- package/dist/entity-NnEVlePN.d.ts.map +0 -1
- package/dist/index-ClkpS6s_.d.ts +0 -481
- package/dist/index-ClkpS6s_.d.ts.map +0 -1
- package/dist/index-w4qop0Pe.d.cts +0 -481
- package/dist/index-w4qop0Pe.d.cts.map +0 -1
- package/dist/payload-BpNUPOnY.js +0 -13
- package/dist/payload-BpNUPOnY.js.map +0 -1
- package/dist/payload-C2KHOUoj.d.ts +0 -6
- package/dist/payload-C2KHOUoj.d.ts.map +0 -1
- package/dist/payload-CJN8fTvX.d.cts +0 -6
- package/dist/payload-CJN8fTvX.d.cts.map +0 -1
- package/dist/payload-D8YLKcJj.cjs +0 -23
- package/dist/query/index.js.map +0 -1
- package/dist/queryBuilder-BE_XhLLa.js +0 -735
- package/dist/queryBuilder-BE_XhLLa.js.map +0 -1
- package/dist/queryBuilder-J37buGCi.cjs +0 -865
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/src/actions/public/buildQuery.ts +0 -10
- package/src/actions/public/subscribeEntityEvents.ts +0 -93
- package/src/actions/wallet/updateEntity.ts +0 -59
- package/src/chains/braga.ts +0 -26
- package/src/chains/kaolin.ts +0 -29
- package/src/query/engine.test.ts +0 -571
- package/src/query/predicate.test.ts +0 -461
- package/src/query/predicate.ts +0 -144
- package/src/query/queryResult.test.ts +0 -270
- package/src/query/selectQueryBuilder.test.ts +0 -213
- package/src/types/attributes.ts +0 -28
- package/src/utils/validation.test.ts +0 -106
- package/src/utils/validation.ts +0 -80
- /package/dist/{types-Ci4BRClw.js → attr-DlmErkvR.cjs} +0 -0
- /package/dist/{types-a8gm_IaQ.cjs → attr-GcQKatub.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
1
|
+
import { F as RpcCreationFlags, I as RpcEntity, L as RpcQueryOptions, M as ArkivRpcSchema, N as RpcAttribute, P as RpcAttributeSchemaEntry, R as RpcSelect, c as EntityFields, i as SelectArg, j as ArkivClient, n as FullEntity, p as Expression, r as ProjectedEntity, s as Entity, t as EntitySelection } from "./selection-C4UhsMOO.js";
|
|
2
|
+
import { a as Bytes32Value, c as I32Value, d as TypeTag, f as U256Value, h as isArkivValue, i as BoolValue, l as KeyValue, m as UserTypeTag, n as AnyArkivValue, o as BytesValue, p as U64Value, r as ArkivValue, s as DecValue, t as AddrValue, u as StrValue } from "./codec-Car3KkFF.js";
|
|
3
|
+
import { a as ResolvedExpiry, i as Lifetime, n as Expiry, o as resolveExpiry, r as ExpiryContext, s as toBlocks, t as EncodedExpiry } from "./expiry-nDbCgZX4.js";
|
|
4
|
+
import { a as randomSalt, c as InvalidCreationFlagsError, d as NoRandomSourceError, f as Operation, i as predictEntityKey, l as InvalidExpiryError, n as OperationType, o as ENTITY_EVENTS_ABI, r as MAX_SALT, s as EntityEventName, t as MAX_EXPIRES_AT, u as InvalidSaltError } from "./index-fX_XyqLp.js";
|
|
5
|
+
import { A as PredictEntityKeysParameters, C as EntityEvent, D as OwnershipTransferredEvent, E as ExpiryExtendedEvent, M as PredictedEntityKey, N as GetBlockTimingReturnType, O as QueryOptions, S as EntityDeletedEvent, T as EntityPatchedEvent, _ as DeleteEntityReturnType, a as mutationNeedsBlockNumber, b as WatchEntityEventsParameters, c as TxParams, d as PatchEntityReturnType, f as MutateEntitiesParameters, g as DeleteEntityParameters, h as ExtendEntityReturnType, i as collectMutationEvents, j as PredictEntityKeysReturnType, k as QueryReturnType, l as MimeType, m as ExtendEntityParameters, n as MutationEvents, o as ChangeOwnershipParameters, p as MutateEntitiesReturnType, r as buildEntityOperations, s as ChangeOwnershipReturnType, t as EntityMutationOps, u as PatchEntityParameters, v as CreateEntityParameters, w as EntityEventContext, x as EntityCreatedEvent, y as CreateEntityReturnType } from "./arkivTransactions-NtGD6uk5.js";
|
|
6
|
+
import { A as i32, C as ValueInput, D as dec, E as bytes32, F as u64, M as str, N as toValue, O as decFromUnits, P as u256, S as U64_MAX, T as bool, _ as MAX_PAYLOAD_BYTES, a as InvalidAttributeNameError, b as MAX_STRING_BYTES, c as TooManyAttributesError, d as DECIMAL_SCALE, f as DECIMAL_UNIT, g as MAX_ATTRIBUTES, h as Attributes, i as ConflictingMutationError, j as key, k as decUnits, l as UnknownAttributeTypeError, m as AttributeSchema, n as isValidAttributeName, o as InvalidValueError, p as AttributeInputs, r as validateAttributeName, s as MissingValueError, t as MAX_NAME_BYTES, u as UntypedValueError, v as I32_MAX, w as addr, x as U256_MAX, y as I32_MIN } from "./index-DvYvrkdk.js";
|
|
7
|
+
import { i as encodeCreationFlags, n as ResolvedCreationFlags, r as decodeCreationFlags, t as CreationFlags } from "./flags-5dTNRnow.js";
|
|
8
|
+
import { a as pingTransaction, c as decodeMutationResult, d as BuildMutationReturnType, f as buildMutation, i as PingTransactionReturnType, l as getMutationResult, n as SendMutationReturnType, o as GetMutationResultReturnType, r as sendMutation, s as MutationResult, t as SendMutationOptions, u as BuildMutationOptions } from "./index-B5j76711.js";
|
|
9
|
+
import { t as SelectQueryBuilder } from "./index-DHDud2hC.js";
|
|
10
|
+
import { i as ExpirationTime, n as stringToPayload, r as DeadlineOptions, t as jsonToPayload } from "./payload-CcUj85ys.js";
|
|
11
|
+
import { Account, Address, Chain, Client, Hash, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, TransactionReceipt, Transport, WalletActions, WalletClientConfig } from "viem";
|
|
5
12
|
|
|
13
|
+
//#region src/clients/decorators/arkivAdvanced.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* The read-only half of the advanced path — checking on a transaction and decoding its result —
|
|
16
|
+
* which needs no account, so a Public Client carries it too.
|
|
17
|
+
*
|
|
18
|
+
* Every action here costs at most one RPC call, and says exactly which.
|
|
19
|
+
*/
|
|
20
|
+
type PublicAdvancedActions = {
|
|
21
|
+
/**
|
|
22
|
+
* Asks the chain — once — whether a transaction has landed. Exactly one
|
|
23
|
+
* `eth_getTransactionReceipt`, never a poll: an unmined transaction comes back as
|
|
24
|
+
* `{ status: "pending" }` and the schedule stays yours.
|
|
25
|
+
*
|
|
26
|
+
* @param txHash - The transaction hash returned by `sendMutation` (or any other send)
|
|
27
|
+
* @returns `{ status: "pending" }`, or `{ status: "success" | "reverted", blockNumber }`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const { status } = await client.advanced.pingTransaction(txHash)
|
|
31
|
+
* if (status === "pending") scheduleAnotherPing()
|
|
32
|
+
*/
|
|
33
|
+
pingTransaction: (txHash: Hash) => Promise<PingTransactionReturnType>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetches a transaction's receipt — once — and decodes what the mutation did: created keys and
|
|
36
|
+
* expiries, plus the keys of everything patched, deleted, extended or handed over. One
|
|
37
|
+
* `eth_getTransactionReceipt`; `{ status: "pending" }` if not mined yet. No revert diagnosis is
|
|
38
|
+
* run on a `reverted` result — that extra call is yours to spend or skip.
|
|
39
|
+
*
|
|
40
|
+
* @param txHash - The transaction hash
|
|
41
|
+
* @returns The decoded {@link MutationResult}, or `{ status: "pending" }`
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const result = await client.advanced.getMutationResult(txHash)
|
|
45
|
+
* if (result.status === "success") console.log(result.createdEntities)
|
|
46
|
+
*/
|
|
47
|
+
getMutationResult: (txHash: Hash) => Promise<GetMutationResultReturnType>;
|
|
48
|
+
/**
|
|
49
|
+
* Decodes a receipt you already hold into a {@link MutationResult}. **Zero RPC calls** — for
|
|
50
|
+
* receipts that reached you through your own `waitForTransactionReceipt`, a block watcher, or a
|
|
51
|
+
* webhook.
|
|
52
|
+
*
|
|
53
|
+
* @param receipt - The transaction receipt
|
|
54
|
+
* @returns The decoded {@link MutationResult}
|
|
55
|
+
*/
|
|
56
|
+
decodeMutationResult: (receipt: TransactionReceipt) => MutationResult;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The advanced path on a Wallet Client: build, send, ping and read results as separate steps, each
|
|
60
|
+
* costing the minimum number of RPC calls — down to one per transaction when you supply what the
|
|
61
|
+
* SDK would otherwise look up.
|
|
62
|
+
*
|
|
63
|
+
* The everyday actions (`createEntity`, `mutateEntities`, …) bundle send + wait + decode and are
|
|
64
|
+
* the right default. This namespace unbundles them for callers optimising their RPC budget.
|
|
65
|
+
*
|
|
66
|
+
* @example Minimal-call flow: one send, one ping, done.
|
|
67
|
+
* const { txHash } = await client.advanced.sendMutation(
|
|
68
|
+
* { creates: [{ payload, contentType: "application/json", expires }] },
|
|
69
|
+
* { currentBlock, txParams: { nonce, gas: 1_000_000n, maxFeePerGas, maxPriorityFeePerGas } },
|
|
70
|
+
* ) // exactly 1 RPC call: eth_sendRawTransaction
|
|
71
|
+
* // ... later, on your own schedule:
|
|
72
|
+
* const result = await client.advanced.getMutationResult(txHash) // 1 RPC call
|
|
73
|
+
* if (result.status === "success") console.log(result.createdEntities)
|
|
74
|
+
*/
|
|
75
|
+
type WalletAdvancedActions = PublicAdvancedActions & {
|
|
76
|
+
/**
|
|
77
|
+
* Encodes a mutation batch without sending anything: zero RPC calls with `currentBlock` supplied
|
|
78
|
+
* (or when no expiry is relative), at most one `eth_blockNumber` otherwise. Returns the
|
|
79
|
+
* operations for `writeContract`, and the `{ to, data }` calldata for offline signing.
|
|
80
|
+
*
|
|
81
|
+
* @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
|
|
82
|
+
* @param options - Optional `currentBlock` to avoid the `eth_blockNumber` lookup
|
|
83
|
+
*/
|
|
84
|
+
buildMutation: (data: EntityMutationOps, options?: BuildMutationOptions) => Promise<BuildMutationReturnType>;
|
|
85
|
+
/**
|
|
86
|
+
* Signs and sends a mutation batch, returning the hash as soon as the transaction is submitted —
|
|
87
|
+
* no waiting, no polling, no revert diagnosis. With `currentBlock` and full `txParams` (nonce,
|
|
88
|
+
* gas, fees) supplied this is exactly one `eth_sendRawTransaction`; each omitted piece adds only
|
|
89
|
+
* the lookup viem needs to fill it.
|
|
90
|
+
*
|
|
91
|
+
* @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
|
|
92
|
+
* @param options - Optional `currentBlock` and `txParams`
|
|
93
|
+
* @returns The transaction hash and the batch's per-kind operation counts
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const { txHash } = await client.advanced.sendMutation({
|
|
97
|
+
* creates: [{ payload, contentType: "application/json", expires: ExpirationTime.atBlock(1_200_000n) }],
|
|
98
|
+
* })
|
|
99
|
+
*/
|
|
100
|
+
sendMutation: (data: EntityMutationOps, options?: SendMutationOptions) => Promise<SendMutationReturnType>;
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
6
103
|
//#region src/clients/decorators/arkivPublic.d.ts
|
|
7
104
|
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"> & {
|
|
8
105
|
/**
|
|
@@ -11,23 +108,28 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
11
108
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/getEntity
|
|
12
109
|
*
|
|
13
110
|
* @param key - The entity key (hex string)
|
|
14
|
-
* @returns The entity with the given key. {@link
|
|
111
|
+
* @returns The entity with the given key, with every field populated. {@link FullEntity}
|
|
15
112
|
*
|
|
16
113
|
* @example
|
|
17
|
-
* import { createPublicClient
|
|
18
|
-
* import {
|
|
114
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
115
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
116
|
+
* import { http } from "viem"
|
|
19
117
|
*
|
|
20
118
|
* const client = createPublicClient({
|
|
21
|
-
* chain:
|
|
119
|
+
* chain: cheesecake,
|
|
22
120
|
* transport: http(),
|
|
23
121
|
* })
|
|
24
|
-
* const entity = await client.getEntity(
|
|
25
|
-
* // {
|
|
26
|
-
* // key: "
|
|
27
|
-
* //
|
|
122
|
+
* const entity = await client.getEntity(entityKey)
|
|
123
|
+
* // Entity {
|
|
124
|
+
* // key: "0x9f2c…",
|
|
125
|
+
* // owner: "0xabc…",
|
|
126
|
+
* // contentType: "application/json",
|
|
127
|
+
* // payload: Uint8Array, // entity.toJson() / entity.toText() decode it
|
|
128
|
+
* // attributes: { category: { type: "str", value: "docs" } },
|
|
129
|
+
* // expiresAt: 1_297_000n,
|
|
28
130
|
* // }
|
|
29
131
|
*/
|
|
30
|
-
getEntity: (key: Hex) => Promise<
|
|
132
|
+
getEntity: (key: Hex) => Promise<FullEntity>;
|
|
31
133
|
/**
|
|
32
134
|
* Returns a SelectQueryBuilder for building and executing queries — the recommended way to
|
|
33
135
|
* read entities. You declare up front which parts of an entity you want returned, so results
|
|
@@ -42,12 +144,13 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
42
144
|
* @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder}
|
|
43
145
|
*
|
|
44
146
|
* @example
|
|
45
|
-
* import { createPublicClient
|
|
46
|
-
* import {
|
|
47
|
-
* import { eq } from
|
|
147
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
148
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
149
|
+
* import { eq } from "@arkiv-network/sdk/query"
|
|
150
|
+
* import { http } from "viem"
|
|
48
151
|
*
|
|
49
152
|
* const client = createPublicClient({
|
|
50
|
-
* chain:
|
|
153
|
+
* chain: cheesecake,
|
|
51
154
|
* transport: http(),
|
|
52
155
|
* })
|
|
53
156
|
* // select everything
|
|
@@ -55,7 +158,7 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
55
158
|
* await client.select("*").where(eq("category", "docs")).fetch()
|
|
56
159
|
* // only the key
|
|
57
160
|
* await client.select({ key: true }).where(eq("category", "docs")).fetch()
|
|
58
|
-
* // select specific fields — result typed { owner: Hex; attributes:
|
|
161
|
+
* // select specific fields — result typed { owner: Hex; attributes: Attributes }
|
|
59
162
|
* await client.select({ owner: true, attributes: true }).fetch()
|
|
60
163
|
* // a single field — result typed { owner: Hex }
|
|
61
164
|
* await client.select({ owner: true }).fetch()
|
|
@@ -67,9 +170,11 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
67
170
|
* Pick the entity fields to return. Set the ones you want to `true` (at least one is required);
|
|
68
171
|
* the result is typed to exactly those fields, so reading anything else is a compile error.
|
|
69
172
|
*
|
|
70
|
-
* Available fields: `key`, `owner`, `creator`, `
|
|
71
|
-
* `
|
|
72
|
-
*
|
|
173
|
+
* Available fields: `key`, `owner`, `creator`, `createdAt`, `updatedAt`, `expiresAt`,
|
|
174
|
+
* `creationFlags`, `contentType`, `payload`, `attributeSchema` and `attributes`.
|
|
175
|
+
*
|
|
176
|
+
* `attributes` also takes a map of names, to fetch only those:
|
|
177
|
+
* `select({ key: true, attributes: { projectId: true } })`.
|
|
73
178
|
*
|
|
74
179
|
* Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/
|
|
75
180
|
* `const` variable widens to `boolean` and the result type can no longer be narrowed — annotate
|
|
@@ -77,7 +182,8 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
77
182
|
*
|
|
78
183
|
* @example
|
|
79
184
|
* client.select({ owner: true, attributes: true }) // entities typed { owner, attributes }
|
|
80
|
-
* client.select({ key: true, payload: true })
|
|
185
|
+
* client.select({ key: true, payload: true }) // includes payload → toText()/toJson() too
|
|
186
|
+
* client.select({ key: true, attributeSchema: true }) // what shape is the data?
|
|
81
187
|
*/
|
|
82
188
|
<const S extends EntitySelection>(selection: S): SelectQueryBuilder<ProjectedEntity<S>>;
|
|
83
189
|
/**
|
|
@@ -87,87 +193,124 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
87
193
|
(selection: SelectArg): SelectQueryBuilder<FullEntity>;
|
|
88
194
|
};
|
|
89
195
|
/**
|
|
90
|
-
*
|
|
91
|
-
* The QueryBuilder object follows the Builder pattern, allowing you to chain methods to build a query and then execute it.
|
|
92
|
-
*
|
|
93
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/public/query
|
|
196
|
+
* Runs one query and returns one page, with no builder in between.
|
|
94
197
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
198
|
+
* Use {@link select} for anything typed — this returns full {@link Entity} objects whatever the
|
|
199
|
+
* selection, and takes a raw string as an escape hatch for a query built elsewhere. A raw string
|
|
200
|
+
* goes to the node exactly as written, with none of the name, type or operator checks the
|
|
201
|
+
* expression combinators apply.
|
|
99
202
|
*
|
|
100
|
-
* @
|
|
203
|
+
* @param query - An {@link Expression}, or the raw query string.
|
|
204
|
+
* @param queryOptions - Selection, page size, cursor and block. {@link QueryOptions}
|
|
205
|
+
* @returns One page of entities. {@link QueryReturnType}
|
|
101
206
|
*
|
|
102
207
|
* @example
|
|
103
|
-
* import { createPublicClient
|
|
104
|
-
* import {
|
|
208
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
209
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
210
|
+
* import { and, eq, gte } from "@arkiv-network/sdk/query"
|
|
211
|
+
* import { i32 } from "@arkiv-network/sdk/attr"
|
|
212
|
+
* import { http } from "viem"
|
|
105
213
|
*
|
|
106
214
|
* const client = createPublicClient({
|
|
107
|
-
* chain:
|
|
215
|
+
* chain: cheesecake,
|
|
108
216
|
* transport: http(),
|
|
109
217
|
* })
|
|
110
|
-
* const
|
|
111
|
-
*
|
|
218
|
+
* const page = await client.query(and(eq("category", "docs"), gte("level", i32(10))), {
|
|
219
|
+
* select: { key: true, attributes: true },
|
|
220
|
+
* limit: 100,
|
|
221
|
+
* })
|
|
222
|
+
* // { entities: [Entity], cursor: "b64:…", blockNumber: 32223n }
|
|
112
223
|
*
|
|
224
|
+
* // The raw form, unchecked:
|
|
225
|
+
* await client.query("category = str('docs') AND level >= i32(10)")
|
|
113
226
|
*/
|
|
114
|
-
|
|
227
|
+
query: (query: Expression | string, queryOptions?: QueryOptions) => Promise<QueryReturnType>;
|
|
115
228
|
/**
|
|
116
|
-
* Returns
|
|
117
|
-
*
|
|
118
|
-
* @param query - The raw query string
|
|
119
|
-
* @param queryOptions - The optional query options - {@link QueryOptions}
|
|
120
|
-
* @returns A QueryReturnType instance - {@link QueryReturnType}
|
|
229
|
+
* Returns the total number of entities on the chain.
|
|
230
|
+
* @returns The number of entities currently stored
|
|
121
231
|
*
|
|
122
232
|
* @example
|
|
123
|
-
* import { createPublicClient
|
|
124
|
-
* import {
|
|
233
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
234
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
235
|
+
* import { http } from "viem"
|
|
125
236
|
*
|
|
126
237
|
* const client = createPublicClient({
|
|
127
|
-
* chain:
|
|
238
|
+
* chain: cheesecake,
|
|
128
239
|
* transport: http(),
|
|
129
240
|
* })
|
|
130
|
-
* const
|
|
131
|
-
* //
|
|
132
|
-
* const queryResultWithOptions = client.query('key = value && $owner = 0x123', {
|
|
133
|
-
* includeData: {
|
|
134
|
-
* attributes: false,
|
|
135
|
-
* payload: true,
|
|
136
|
-
* metadata: true,
|
|
137
|
-
* },
|
|
138
|
-
* resultsPerPage: 10,
|
|
139
|
-
* cursor: undefined,
|
|
140
|
-
* atBlock: undefined,
|
|
141
|
-
* })
|
|
142
|
-
* // queryResultWithOptions = { entities: [{ key: "0x123", value: "0x123" }], cursor: "...", blockNumber: 32223n }
|
|
241
|
+
* const entityCount = await client.getEntityCount()
|
|
242
|
+
* // entityCount = 0
|
|
143
243
|
*/
|
|
144
|
-
|
|
244
|
+
getEntityCount: () => Promise<number>;
|
|
145
245
|
/**
|
|
146
|
-
* Returns
|
|
147
|
-
*
|
|
246
|
+
* Returns how many entities an account has created — its entity-minting nonce.
|
|
247
|
+
*
|
|
248
|
+
* Not the account's transaction nonce: the engine keeps its own counter per creator and mixes it
|
|
249
|
+
* into every key it mints, which is why two identical creates from one account never collide.
|
|
250
|
+
*
|
|
251
|
+
* @param owner - The account whose nonce to read.
|
|
252
|
+
* @returns The nonce the account's next create will use.
|
|
148
253
|
*
|
|
149
254
|
* @example
|
|
150
|
-
* import { createPublicClient
|
|
151
|
-
* import {
|
|
255
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
256
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
257
|
+
* import { http } from "viem"
|
|
152
258
|
*
|
|
153
259
|
* const client = createPublicClient({
|
|
154
|
-
* chain:
|
|
260
|
+
* chain: cheesecake,
|
|
155
261
|
* transport: http(),
|
|
156
262
|
* })
|
|
157
|
-
* const
|
|
158
|
-
* //
|
|
263
|
+
* const nonce = await client.getEntityNonce("0xabc…")
|
|
264
|
+
* // 7n — the next entity this account creates is its eighth
|
|
159
265
|
*/
|
|
160
|
-
|
|
266
|
+
getEntityNonce: (owner: Address) => Promise<bigint>;
|
|
267
|
+
/**
|
|
268
|
+
* Works out the keys an account's next creates will be given, before sending them.
|
|
269
|
+
*
|
|
270
|
+
* The engine derives a key from the chain, the registry, the owner, the owner's nonce and a
|
|
271
|
+
* salt — everything but the nonce is known to the caller, and the nonce is read here. This is
|
|
272
|
+
* what lets a batch reference an entity it is about to mint.
|
|
273
|
+
*
|
|
274
|
+
* Each key arrives paired with the salt that mints it, because a create defaults to a *random*
|
|
275
|
+
* salt: a predicted key only holds if the create carries the salt it was predicted with. And the
|
|
276
|
+
* prediction holds only while nothing else from this owner is in flight — for a key you can rely
|
|
277
|
+
* on unconditionally, read it back from the create instead.
|
|
278
|
+
*
|
|
279
|
+
* A literal `count` comes back as a fixed-length tuple, so the pairs destructure into names.
|
|
280
|
+
*
|
|
281
|
+
* @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters}
|
|
282
|
+
* @returns One `{ key, salt }` pair per create, in batch order.
|
|
283
|
+
* {@link PredictEntityKeysReturnType}
|
|
284
|
+
*
|
|
285
|
+
* @example A batch whose second entity points at its first.
|
|
286
|
+
* import { key } from "@arkiv-network/sdk/attr"
|
|
287
|
+
*
|
|
288
|
+
* const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 })
|
|
289
|
+
* await wallet.mutateEntities({
|
|
290
|
+
* creates: [
|
|
291
|
+
* { payload, contentType, expires, salt: parent.salt },
|
|
292
|
+
* {
|
|
293
|
+
* payload,
|
|
294
|
+
* contentType,
|
|
295
|
+
* expires,
|
|
296
|
+
* salt: child.salt,
|
|
297
|
+
* attributes: { parent: key(parent.key) },
|
|
298
|
+
* },
|
|
299
|
+
* ],
|
|
300
|
+
* })
|
|
301
|
+
*/
|
|
302
|
+
predictEntityKeys: <const TCount extends number = number, const TSalts extends readonly bigint[] | undefined = undefined>(parameters: PredictEntityKeysParameters<TCount, TSalts>) => Promise<PredictEntityKeysReturnType<TCount, TSalts>>;
|
|
161
303
|
/**
|
|
162
304
|
* Returns the current block timing.
|
|
163
305
|
* @returns The current block timing. {@link GetBlockTimingReturnType}
|
|
164
306
|
*
|
|
165
307
|
* @example
|
|
166
|
-
* import { createPublicClient
|
|
167
|
-
* import {
|
|
308
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
309
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
310
|
+
* import { http } from "viem"
|
|
168
311
|
*
|
|
169
312
|
* const client = createPublicClient({
|
|
170
|
-
* chain:
|
|
313
|
+
* chain: cheesecake,
|
|
171
314
|
* transport: http(),
|
|
172
315
|
* })
|
|
173
316
|
* const blockTiming = await client.getBlockTiming()
|
|
@@ -183,39 +326,41 @@ type PublicArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
183
326
|
blockDuration: number;
|
|
184
327
|
}>;
|
|
185
328
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
329
|
+
* Watches entity events, calling the handlers you pass as they arrive.
|
|
330
|
+
*
|
|
331
|
+
* All five are decoded from logs — `onEntityCreated`, `onEntityPatched`, `onExpiryExtended`,
|
|
332
|
+
* `onOwnershipTransferred`, `onEntityDeleted` — and each carries the block, transaction and log
|
|
333
|
+
* index it came from, which is the order the operations were applied in. `onEvent` receives all
|
|
334
|
+
* of them, whatever their type.
|
|
335
|
+
*
|
|
336
|
+
* @param parameters - Handlers and options, all optional. {@link WatchEntityEventsParameters}
|
|
337
|
+
* @returns A function that stops the watcher.
|
|
191
338
|
*
|
|
192
339
|
* @example
|
|
193
|
-
* import { createPublicClient
|
|
194
|
-
* import {
|
|
340
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
341
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
342
|
+
* import { http } from "viem"
|
|
195
343
|
*
|
|
196
344
|
* const client = createPublicClient({
|
|
197
|
-
* chain:
|
|
345
|
+
* chain: cheesecake,
|
|
198
346
|
* transport: http(),
|
|
199
347
|
* })
|
|
200
|
-
* const
|
|
201
|
-
*
|
|
348
|
+
* const unwatch = client.watchEntityEvents({
|
|
349
|
+
* onEntityCreated: ({ entityKey, expiresAt }) => console.log(entityKey, "until", expiresAt),
|
|
350
|
+
* onError: (error) => console.error("watchEntityEvents error", error),
|
|
202
351
|
* })
|
|
203
|
-
*
|
|
352
|
+
* unwatch() // stop watching
|
|
204
353
|
*/
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
onEntityDeleted?: (event: OnEntityDeletedEvent) => void;
|
|
216
|
-
onEntityExpired?: (event: OnEntityExpiredEvent) => void;
|
|
217
|
-
onEntityExpiresInExtended?: (event: OnEntityExpiresInExtendedEvent) => void;
|
|
218
|
-
}, pollingInterval?: number, fromBlock?: bigint) => Promise<() => void>;
|
|
354
|
+
watchEntityEvents: (parameters: WatchEntityEventsParameters) => () => void;
|
|
355
|
+
/**
|
|
356
|
+
* The read-only half of the advanced path: check on a transaction and decode its result with at
|
|
357
|
+
* most one RPC call per action — so a process that holds nothing but a transaction hash can
|
|
358
|
+
* follow it without a wallet. {@link PublicAdvancedActions}
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* const { status } = await client.advanced.pingTransaction(txHash) // 1 eth_getTransactionReceipt
|
|
362
|
+
*/
|
|
363
|
+
advanced: PublicAdvancedActions;
|
|
219
364
|
};
|
|
220
365
|
//#endregion
|
|
221
366
|
//#region src/clients/createPublicClient.d.ts
|
|
@@ -225,17 +370,18 @@ type PublicArkivClient<transport extends Transport = Transport, chain extends Ch
|
|
|
225
370
|
*
|
|
226
371
|
* - Docs: https://docs.arkiv.network/ts-sdk/clients/public
|
|
227
372
|
*
|
|
228
|
-
* 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 [
|
|
373
|
+
* 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 [Cheesecake JSON-RPC API](https://rpc.cheesecake.db-chain.devnet.gobas.me) methods such as retrieving block numbers, transactions, reading from smart contracts, etc through [Public Actions](/docs/actions/public/introduction).
|
|
229
374
|
*
|
|
230
375
|
* @param parameters - Configuration object for the public client (chain, transport, etc.)
|
|
231
376
|
* @returns A Arkiv Public Client. {@link PublicArkivClient}
|
|
232
377
|
*
|
|
233
378
|
* @example
|
|
234
|
-
* import { createPublicClient
|
|
235
|
-
* import {
|
|
379
|
+
* import { createPublicClient } from "@arkiv-network/sdk"
|
|
380
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
381
|
+
* import { http } from "viem"
|
|
236
382
|
*
|
|
237
383
|
* const client = createPublicClient({
|
|
238
|
-
* chain:
|
|
384
|
+
* chain: cheesecake,
|
|
239
385
|
* transport: http(),
|
|
240
386
|
* })
|
|
241
387
|
*/
|
|
@@ -253,57 +399,64 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
253
399
|
* @param txParams - Optional transaction parameters
|
|
254
400
|
* @returns The created entity with transaction hash
|
|
255
401
|
*
|
|
256
|
-
* @throws {
|
|
257
|
-
*
|
|
258
|
-
* @throws {
|
|
259
|
-
*
|
|
402
|
+
* @throws {InvalidExpiryError} If the expiry exceeds a protocol bound or would leave the
|
|
403
|
+
* entity dead on arrival.
|
|
404
|
+
* @throws {InvalidValueError} If an attribute value does not fit the type it names.
|
|
405
|
+
* @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
|
|
260
406
|
*
|
|
261
407
|
* @example
|
|
262
|
-
* import {
|
|
263
|
-
* import {
|
|
408
|
+
* import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
|
|
409
|
+
* import { i32 } from "@arkiv-network/sdk/attr"
|
|
410
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
411
|
+
* import { http } from "viem"
|
|
264
412
|
*
|
|
265
|
-
* const client =
|
|
266
|
-
* chain:
|
|
413
|
+
* const client = createWalletClient({
|
|
414
|
+
* chain: cheesecake,
|
|
267
415
|
* transport: http(),
|
|
268
416
|
* })
|
|
269
|
-
* const { entityKey, txHash } = await client.createEntity({
|
|
270
|
-
* payload:
|
|
271
|
-
*
|
|
272
|
-
*
|
|
417
|
+
* const { entityKey, txHash, expiresAt } = await client.createEntity({
|
|
418
|
+
* payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
|
|
419
|
+
* contentType: "application/json",
|
|
420
|
+
* attributes: { testKey: "testValue", level: i32(3) },
|
|
421
|
+
* expires: ExpirationTime.fromDays(30),
|
|
273
422
|
* })
|
|
274
|
-
* console.log("entityKey", entityKey)
|
|
275
|
-
* console.log("txHash", txHash)
|
|
276
|
-
* // {
|
|
277
|
-
* // entityKey: "0x123",
|
|
278
|
-
* // txHash: "0x123",
|
|
279
|
-
* // }
|
|
280
423
|
*/
|
|
281
424
|
createEntity: (data: CreateEntityParameters, txParams?: TxParams) => Promise<CreateEntityReturnType>;
|
|
282
425
|
/**
|
|
283
|
-
*
|
|
426
|
+
* Applies a patch to the entity with the given key: sets some fields, unsets others, and leaves
|
|
427
|
+
* everything it does not name alone.
|
|
284
428
|
*
|
|
285
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/
|
|
429
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/patchEntity
|
|
286
430
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
287
431
|
*
|
|
288
|
-
* @param data - The entity
|
|
432
|
+
* @param data - The entity key and the mutations to apply
|
|
289
433
|
* @param txParams - Optional transaction parameters
|
|
290
|
-
* @returns The
|
|
434
|
+
* @returns The entity key and the transaction hash
|
|
291
435
|
*
|
|
292
|
-
* @throws {
|
|
293
|
-
*
|
|
294
|
-
* @throws {
|
|
295
|
-
*
|
|
436
|
+
* @throws {EmptyPatchError} If the patch has nothing to apply.
|
|
437
|
+
* @throws {ConflictingMutationError} If a name appears in both `set` and `unset`.
|
|
438
|
+
* @throws {InvalidValueError} If an attribute value does not fit the type it names.
|
|
439
|
+
* @throws {InvalidAttributeNameError} If a name violates the attribute-name grammar.
|
|
296
440
|
*
|
|
297
441
|
* @example
|
|
298
|
-
* import { createWalletClient,
|
|
299
|
-
* import {
|
|
442
|
+
* import { createWalletClient, jsonToPayload } from "@arkiv-network/sdk"
|
|
443
|
+
* import { i32 } from "@arkiv-network/sdk/attr"
|
|
444
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
445
|
+
* import { http } from "viem"
|
|
300
446
|
*
|
|
301
447
|
* const client = createWalletClient({
|
|
302
|
-
* chain:
|
|
448
|
+
* chain: cheesecake,
|
|
303
449
|
* transport: http(),
|
|
304
450
|
* })
|
|
451
|
+
* // Publish the entity: one attribute changes, one goes away, the payload is replaced.
|
|
452
|
+
* const { txHash } = await client.patchEntity({
|
|
453
|
+
* entityKey,
|
|
454
|
+
* set: { status: "published", revision: i32(2) },
|
|
455
|
+
* unset: ["draft"],
|
|
456
|
+
* payload: jsonToPayload({ title: "Hello" }),
|
|
457
|
+
* })
|
|
305
458
|
*/
|
|
306
|
-
|
|
459
|
+
patchEntity: (data: PatchEntityParameters, txParams?: TxParams) => Promise<PatchEntityReturnType>;
|
|
307
460
|
/**
|
|
308
461
|
* Deletes the entity with the given key.
|
|
309
462
|
*
|
|
@@ -315,52 +468,48 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
315
468
|
* @returns The deleted entity with transaction hash
|
|
316
469
|
*
|
|
317
470
|
* @example
|
|
318
|
-
* import { createWalletClient
|
|
319
|
-
* import {
|
|
471
|
+
* import { createWalletClient } from "@arkiv-network/sdk"
|
|
472
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
473
|
+
* import { http } from "viem"
|
|
320
474
|
*
|
|
321
475
|
* const client = createWalletClient({
|
|
322
|
-
* chain:
|
|
476
|
+
* chain: cheesecake,
|
|
323
477
|
* transport: http(),
|
|
324
478
|
* })
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* console.log("txHash", txHash)
|
|
328
|
-
* // {
|
|
329
|
-
* // entityKey: "0x123",
|
|
330
|
-
* // txHash: "0x123",
|
|
331
|
-
* // }
|
|
479
|
+
* // entityKey is the bytes32 key returned by createEntity.
|
|
480
|
+
* const { txHash } = await client.deleteEntity({ entityKey })
|
|
332
481
|
*/
|
|
333
482
|
deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>;
|
|
334
483
|
/**
|
|
335
|
-
*
|
|
484
|
+
* Sets a new expiry on the entity with the given key.
|
|
485
|
+
*
|
|
486
|
+
* The new lifetime is resolved the same way a create's is: a duration counts from now rather
|
|
487
|
+
* than adding to what the entity has left, and `atBlock` / `atDate` pin an absolute deadline.
|
|
488
|
+
* The engine rejects an extension that would not move the expiry later.
|
|
336
489
|
*
|
|
337
490
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/extendEntity
|
|
338
491
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
339
492
|
*
|
|
340
|
-
* @param data - The entity
|
|
493
|
+
* @param data - The entity key and its new lifetime
|
|
341
494
|
* @param txParams - Optional transaction parameters
|
|
342
|
-
* @returns The
|
|
495
|
+
* @returns The entity key, transaction hash, and the block it is now expected to expire at
|
|
343
496
|
*
|
|
344
|
-
* @throws {
|
|
345
|
-
*
|
|
497
|
+
* @throws {InvalidExpiryError} If the expiry is malformed, exceeds a protocol bound, or would
|
|
498
|
+
* leave the entity dead on arrival.
|
|
346
499
|
*
|
|
347
500
|
* @example
|
|
348
|
-
* import { createWalletClient,
|
|
349
|
-
* import {
|
|
501
|
+
* import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk"
|
|
502
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
503
|
+
* import { http } from "viem"
|
|
350
504
|
*
|
|
351
505
|
* const client = createWalletClient({
|
|
352
|
-
* chain:
|
|
506
|
+
* chain: cheesecake,
|
|
353
507
|
* transport: http(),
|
|
354
508
|
* })
|
|
355
|
-
* const {
|
|
356
|
-
*
|
|
509
|
+
* const { txHash, expiresAt } = await client.extendEntity({
|
|
510
|
+
* entityKey,
|
|
511
|
+
* expires: ExpirationTime.fromDays(30),
|
|
357
512
|
* })
|
|
358
|
-
* console.log("entityKey", entityKey)
|
|
359
|
-
* console.log("txHash", txHash)
|
|
360
|
-
* // {
|
|
361
|
-
* // entityKey: "0x123",
|
|
362
|
-
* // txHash: "0x123",
|
|
363
|
-
* // }
|
|
364
513
|
*/
|
|
365
514
|
extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>;
|
|
366
515
|
/**
|
|
@@ -380,100 +529,103 @@ type WalletArkivActions<transport extends Transport = Transport, chain extends C
|
|
|
380
529
|
* - Docs: https://docs.arkiv.network/ts-sdk/actions/wallet/mutateEntities
|
|
381
530
|
* - JSON-RPC Methods: [`eth_sendRawTransaction`](https://docs.arkiv.network/dev/json-rpc-api/#mutateEntities)
|
|
382
531
|
*
|
|
383
|
-
*
|
|
532
|
+
* Every operation lands in one transaction, so the whole batch applies or none of it does.
|
|
533
|
+
* At least one operation is required.
|
|
534
|
+
*
|
|
535
|
+
* @param data - The mutation parameters (creates, patches, deletes, extensions, ownershipChanges)
|
|
384
536
|
* @param txParams - Optional transaction parameters
|
|
385
537
|
* @returns The mutation result with transaction hash
|
|
386
538
|
*
|
|
387
|
-
* @throws {
|
|
388
|
-
*
|
|
389
|
-
* @throws {
|
|
390
|
-
* integer.
|
|
539
|
+
* @throws {InvalidExpiryError} If an expiry exceeds a protocol bound or would leave the entity
|
|
540
|
+
* dead on arrival.
|
|
541
|
+
* @throws {InvalidValueError} If an attribute value does not fit the type it names.
|
|
391
542
|
*
|
|
392
543
|
* @example
|
|
393
|
-
* import { createWalletClient,
|
|
394
|
-
* import {
|
|
544
|
+
* import { createWalletClient, ExpirationTime, jsonToPayload } from "@arkiv-network/sdk"
|
|
545
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
546
|
+
* import { http } from "viem"
|
|
395
547
|
*
|
|
396
548
|
* const client = createWalletClient({
|
|
397
|
-
* chain:
|
|
549
|
+
* chain: cheesecake,
|
|
398
550
|
* transport: http(),
|
|
399
551
|
* })
|
|
400
|
-
* const {
|
|
552
|
+
* const { txHash, createdEntities } = await client.mutateEntities({
|
|
401
553
|
* creates: [{
|
|
402
|
-
* payload:
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* updates: [{
|
|
407
|
-
* entityKey: "0x123",
|
|
408
|
-
* payload: toBytes(JSON.stringify({ entity: { entityType: "testType", entityId: "testId" } })),
|
|
409
|
-
* attributes: [{ key: "testKey", value: "testValue" }],
|
|
410
|
-
* expiresIn: 1000,
|
|
411
|
-
* }],
|
|
412
|
-
* deletes: [{
|
|
413
|
-
* entityKey: "0x321",
|
|
554
|
+
* payload: jsonToPayload({ entityType: "testType", entityId: "testId" }),
|
|
555
|
+
* contentType: "application/json",
|
|
556
|
+
* attributes: { testKey: "testValue" },
|
|
557
|
+
* expires: ExpirationTime.fromDays(30),
|
|
414
558
|
* }],
|
|
559
|
+
* patches: [{ entityKey: keyToRevise, set: { status: "archived" }, unset: ["draft"] }],
|
|
560
|
+
* deletes: [{ entityKey: staleKey }],
|
|
415
561
|
* extensions: [{
|
|
416
|
-
* entityKey:
|
|
417
|
-
*
|
|
562
|
+
* entityKey: keyToKeepAlive,
|
|
563
|
+
* expires: ExpirationTime.atBlock(1_200_000n),
|
|
418
564
|
* }],
|
|
565
|
+
* ownershipChanges: [{ entityKey: keyToHandOver, newOwner }],
|
|
419
566
|
* })
|
|
420
|
-
* console.log("entityKey", entityKey)
|
|
421
|
-
* console.log("txHash", txHash)
|
|
422
|
-
* // {
|
|
423
|
-
* // entityKey: "0x123",
|
|
424
|
-
* // txHash: "0x123",
|
|
425
|
-
* // }
|
|
426
567
|
*/
|
|
427
568
|
mutateEntities: (data: MutateEntitiesParameters, txParams?: TxParams) => Promise<MutateEntitiesReturnType>;
|
|
569
|
+
/**
|
|
570
|
+
* The advanced path: build, send, ping and read mutation results as separate steps, each
|
|
571
|
+
* costing the minimum number of RPC calls. Use it when you are optimising your RPC budget;
|
|
572
|
+
* the everyday actions above remain the right default. {@link WalletAdvancedActions}
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* const { txHash } = await client.advanced.sendMutation({ creates: [entity] }) // no waiting
|
|
576
|
+
* // ... later, one eth_getTransactionReceipt on your own schedule:
|
|
577
|
+
* const result = await client.advanced.getMutationResult(txHash)
|
|
578
|
+
* if (result.status === "success") console.log(result.createdEntities)
|
|
579
|
+
*/
|
|
580
|
+
advanced: WalletAdvancedActions;
|
|
428
581
|
};
|
|
429
582
|
//#endregion
|
|
430
583
|
//#region src/clients/createWalletClient.d.ts
|
|
431
584
|
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>>>;
|
|
432
585
|
/**
|
|
433
|
-
* Creates a
|
|
586
|
+
* Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured
|
|
587
|
+
* for a [Chain](https://viem.sh/docs/clients/chains) and an account.
|
|
434
588
|
*
|
|
435
|
-
* - Docs: https://docs.arkiv.network/ts-sdk/clients/
|
|
589
|
+
* - Docs: https://docs.arkiv.network/ts-sdk/clients/wallet
|
|
436
590
|
*
|
|
437
|
-
* A
|
|
591
|
+
* A Wallet Client signs and sends transactions, so it carries an `account` and exposes everything
|
|
592
|
+
* that mutates state — `createEntity`, `patchEntity`, `deleteEntity`, `extendEntity`,
|
|
593
|
+
* `changeOwnership` and `mutateEntities` — on top of the read actions a Public Client has.
|
|
438
594
|
*
|
|
439
595
|
* @param parameters - Configuration object for the wallet client (chain, transport, account, etc.)
|
|
440
596
|
* @returns A Arkiv Wallet Client. {@link WalletArkivClient}
|
|
441
597
|
*
|
|
442
598
|
* @example
|
|
443
|
-
* import {
|
|
444
|
-
* import {
|
|
599
|
+
* import { createWalletClient } from "@arkiv-network/sdk"
|
|
600
|
+
* import { cheesecake } from "@arkiv-network/sdk/chains"
|
|
601
|
+
* import { http } from "viem"
|
|
602
|
+
* import { privateKeyToAccount } from "viem/accounts"
|
|
445
603
|
*
|
|
446
|
-
* const client =
|
|
447
|
-
* chain:
|
|
604
|
+
* const client = createWalletClient({
|
|
605
|
+
* chain: cheesecake,
|
|
448
606
|
* transport: http(),
|
|
607
|
+
* account: privateKeyToAccount("0x..."),
|
|
449
608
|
* })
|
|
450
609
|
*/
|
|
451
610
|
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>;
|
|
452
611
|
//#endregion
|
|
453
612
|
//#region src/errors.d.ts
|
|
454
613
|
declare class EntityMutationError extends Error {
|
|
455
|
-
constructor(message: string
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
constructor(expiresIn: unknown);
|
|
459
|
-
}
|
|
460
|
-
declare class InvalidAttributeError extends Error {
|
|
461
|
-
constructor(key: string, value: number);
|
|
462
|
-
}
|
|
463
|
-
declare class InvalidAttributeKeyError extends Error {
|
|
464
|
-
constructor(key: string, reason: string);
|
|
465
|
-
}
|
|
466
|
-
declare class DuplicateAttributeError extends Error {
|
|
467
|
-
constructor(key: string);
|
|
614
|
+
constructor(message: string, options?: {
|
|
615
|
+
cause?: unknown;
|
|
616
|
+
});
|
|
468
617
|
}
|
|
469
618
|
declare class NoMoreResultsError extends Error {
|
|
470
619
|
constructor();
|
|
471
620
|
}
|
|
472
|
-
declare class NoCursorOrLimitError extends Error {
|
|
473
|
-
constructor();
|
|
474
|
-
}
|
|
475
621
|
declare class NoEntityFoundError extends Error {
|
|
476
|
-
|
|
622
|
+
/** The key that matched nothing, when the lookup was by key. */
|
|
623
|
+
readonly entityKey: string | undefined;
|
|
624
|
+
constructor(entityKey?: string);
|
|
625
|
+
}
|
|
626
|
+
declare class EmptyPatchError extends Error {
|
|
627
|
+
readonly entityKey: string;
|
|
628
|
+
constructor(entityKey: string);
|
|
477
629
|
}
|
|
478
630
|
declare class InvalidContentTypeError extends Error {
|
|
479
631
|
constructor(contentType: string);
|
|
@@ -488,5 +640,5 @@ declare class InvalidContentTypeError extends Error {
|
|
|
488
640
|
*/
|
|
489
641
|
declare function chainFromName(name: string): Chain;
|
|
490
642
|
//#endregion
|
|
491
|
-
export { type ArkivClient, ArkivRpcSchema,
|
|
643
|
+
export { AddrValue, AnyArkivValue, type ArkivClient, ArkivRpcSchema, ArkivValue, AttributeInputs, AttributeSchema, Attributes, BoolValue, BuildMutationOptions, BuildMutationReturnType, Bytes32Value, BytesValue, ChangeOwnershipParameters, ChangeOwnershipReturnType, ConflictingMutationError, CreateEntityParameters, CreateEntityReturnType, CreationFlags, DECIMAL_SCALE, DECIMAL_UNIT, type DeadlineOptions, DecValue, DeleteEntityParameters, DeleteEntityReturnType, ENTITY_EVENTS_ABI, EmptyPatchError, EncodedExpiry, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityEventName, EntityFields, EntityMutationError, type EntityMutationOps, EntityPatchedEvent, ExpirationTime, Expiry, ExpiryContext, ExpiryExtendedEvent, ExtendEntityParameters, ExtendEntityReturnType, GetBlockTimingReturnType, GetMutationResultReturnType, I32Value, I32_MAX, I32_MIN, InvalidAttributeNameError, InvalidContentTypeError, InvalidCreationFlagsError, InvalidExpiryError, InvalidSaltError, InvalidValueError, KeyValue, Lifetime, MAX_ATTRIBUTES, MAX_EXPIRES_AT, MAX_NAME_BYTES, MAX_PAYLOAD_BYTES, MAX_SALT, MAX_STRING_BYTES, MimeType, MissingValueError, MutateEntitiesParameters, MutateEntitiesReturnType, type MutationEvents, MutationResult, NoEntityFoundError, NoMoreResultsError, NoRandomSourceError, Operation, OperationType, OwnershipTransferredEvent, PatchEntityParameters, PatchEntityReturnType, PingTransactionReturnType, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, type PublicAdvancedActions, type PublicArkivActions, type PublicArkivClient, QueryOptions, QueryReturnType, ResolvedCreationFlags, ResolvedExpiry, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, SendMutationOptions, SendMutationReturnType, StrValue, TooManyAttributesError, TxParams, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, UserTypeTag, ValueInput, type WalletAdvancedActions, type WalletArkivActions, type WalletArkivClient, WatchEntityEventsParameters, addr, bool, buildEntityOperations, buildMutation, bytes32, chainFromName, collectMutationEvents, createPublicClient, createWalletClient, dec, decFromUnits, decUnits, decodeCreationFlags, decodeMutationResult, encodeCreationFlags, getMutationResult, i32, isArkivValue, isValidAttributeName, jsonToPayload, key, mutationNeedsBlockNumber, pingTransaction, predictEntityKey, randomSalt, resolveExpiry, sendMutation, str, stringToPayload, toBlocks, toValue, u256, u64, validateAttributeName };
|
|
492
644
|
//# sourceMappingURL=index.d.ts.map
|