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