UNPKG

@arkiv-network/sdk

Version:

TypeScript client library for Arkiv's blockchains interactions

579 lines (577 loc) • 34.7 kB
import { a as predictEntityKey, c as ResolvedCreationFlags, d as InvalidCreationFlagsError, f as InvalidExpiryError, h as MAX_LIFETIME, i as SaltInput, l as ENTITY_EVENTS_ABI, m as NoRandomSourceError, n as MAX_SALT, o as randomSalt, p as InvalidSaltError, r as NO_SALT, s as CreationFlags, t as MAX_EXPIRES_AT, u as EntityEventName } from "./index-CL3rAR9T.js"; import { n as Lifetime, t as Expiry } from "./expiry-S2PUL8Hg.js"; import { A as FullRow, At as PredictedEntityKey, B as Selection, C as OwnershipTransferredEvent, E as QueryRow, F as ResultOf, Ft as RpcAttributeSchemaEntry, H as SelectionOf, I as Row, It as RpcCreationFlags, J as Entity, L as SYSTEM_FIELDS, Lt as RpcEntity, M as NonEmptySelection, Mt as ArkivClient, N as PartialRow, Nt as ArkivRpcSchema, O as DynamicSelection, Ot as PredictEntityKeysParameters, Pt as RpcAttribute, Q as SortDirection, R as SelectArg, Rt as RpcQueryOptions, S as ExpiryExtendedEvent, T as QueryReturnType, U as SystemField, Y as EntityFields, Z as OrderTerm, _ as EntityCreatedEvent, a as ExecuteBatchReturnType, b as EntityEventContext, c as PatchEntityReturnType, d as DeleteEntityParameters, dt as SchemaRef, f as DeleteEntityReturnType, g as WatchEntityEventsParameters, h as CreateEntityReturnType, i as ExecuteBatchParameters, j as KnownSystemFields, jt as GetBlockTimingReturnType, k as FullEntity, kt as PredictEntityKeysReturnType, l as ExtendEntityParameters, m as CreateEntityParameters, n as ChangeOwnershipReturnType, nt as AttributeRef, o as PatchEntityChanges, p as CreateEntityOptions, r as TxParams, s as PatchEntityParameters, st as Expression, t as ChangeOwnershipParameters, u as ExtendEntityReturnType, v as EntityDeletedEvent, w as QueryOptions, x as EntityPatchedEvent, y as EntityEvent, z as Selected, zt as RpcSelect } from "./changeOwnership-CV-auKHv.js"; import { $ as u64, A as describeColumns, B as U64_MAX, C as IndexedColumnName, D as SCHEMA_ATTRIBUTE, E as PatchEntityValues, F as I32_MIN, G as dec, H as addr, I as MAX_BYTES_LENGTH, J as i32, K as decFromUnits, L as MAX_STRING_BYTES, M as lookupColumn, N as BareOf, O as Schema, P as I32_MAX, Q as u256, R as TagOf, S as CreateEntityValues, T as OptionalColumnName, U as bool, V as ValueInput, W as bytes, X as str, Y as key, Z as toValue, _ as Attributes, _t as U64Value, a as EntityTooLargeError, at as ArkivValue, b as Columns, c as MissingValueError, ct as DecValue, d as TooManyAttributesError, dt as IndexableTypeTag, et as AnyColumn, f as UnknownAttributeTypeError, ft as IndexableValue, g as AttributeSchema, gt as U256Value, h as DECIMAL_UNIT, ht as TypeTag, i as ConflictingMutationError, it as AddrValue, j as isSchema, k as defineSchema, l as SchemaDefinitionError, lt as I32Value, m as DECIMAL_SCALE, mt as StrValue, n as isValidAttributeName, nt as ValueArgument, o as InvalidAttributeNameError, ot as BoolValue, p as UntypedValueError, pt as KeyValue, q as decUnits, r as validateAttributeName, rt as isColumn, s as InvalidValueError, st as BytesValue, t as MAX_NAME_BYTES, tt as Column, u as SchemaMismatchError, ut as INDEXED_FLAG, v as MAX_ENTITY_BYTES, vt as ValueOf, w as MAX_ATTRIBUTES, x as ColumnsOf, y as ColumnInput, yt as isArkivValue, z as U256_MAX } from "./index-DaMIgZgJ.js"; import { d as QueryResult, f as CountQueryBuilder, l as FromOptions, p as QueryBuilderBase, u as SelectQueryBuilder } from "./index-CBvzb16i.js"; import { n as ExpirationTime, t as DeadlineOptions } from "./expirationTime-C9rz8--Q.js"; import { Account, Address, Chain, Client, Hex, ParseAccount, Prettify, PublicActions, PublicClientConfig, RpcSchema, Transport, WalletActions, WalletClientConfig } from "viem"; //#region src/clients/decorators/arkivPublic.d.ts 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"> & { /** * Returns the entity with the given key. * * Given a schema, it is read through it: the result is a flat row of every entity field and * every column, each typed as the schema declares and checked against it. * * - JSON-RPC Methods: `arkiv_getEntity` * * @param key - The entity key (hex string) * @param schema - Optionally, the schema to read the entity through. * @returns The entity with the given key, with every field populated — a {@link FullEntity}, or * a {@link FullRow} through a schema. * * @throws {InvalidValueError} If the key is not 32 bytes. * @throws {NoEntityFoundError} If no live entity has that key — it never existed, or it was * deleted or has expired. * @throws {SchemaMismatchError} If, given a schema, the entity does not fit it. * @throws {SchemaDefinitionError} If the schema given was not built with `defineSchema`. * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const entity = await client.getEntity(entityKey) * // { * // $key: "0x9f2c…", * // $owner: "0xabc…", * // $expiresAt: 1_297_000n, * // $attributes: { category: { type: "str", value: "docs" } }, * // ... * // } * * const post = await client.getEntity(entityKey, Posts) * // { $key: "0x9f2c…", $owner: "0xabc…", ..., category: { type: "str", value: "docs" }, ... } */ getEntity: { (key: Hex): Promise<FullEntity>; <S extends Schema>(key: Hex, schema: S): Promise<FullRow<S>>; }; /** * Returns a SelectQueryBuilder for building and executing queries — the recommended way to * read entities. You declare up front which parts of an entity you want returned, so results * always contain exactly the data you asked for. * * The selection names entity fields and attributes side by side, and each result is a flat row. * Chain `.from(schema)` to read through a schema: the selection keeps its meaning, but each * attribute comes back typed and checked as the schema declares, and `where` may only filter on * the schema's indexed columns. * * - JSON-RPC Methods: `arkiv_query` * * @param selection - What to include in the results. Omit it (or pass `"*"`) to select everything, * or pass an object to select specific parts (at least one field is required). Every part is * opt-in, including the `$key`. The selection is flat — each field maps to a field of the result. * {@link SelectArg} * @returns A SelectQueryBuilder instance for building and executing queries. {@link SelectQueryBuilder} * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { and, eq, gt } from "@arkiv-network/sdk/query" * import { dec } from "@arkiv-network/sdk/schema" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * // through a schema — rows typed { $key: Hex; author: AddrValue; title: StrValue } * await client * .select({ $key: true, author: true, title: true }) * .from(Posts) * .where(and(eq("category", "docs"), gt("score", dec("4.0")))) * .fetch() * // every field and column * await client.select().from(Posts).where(eq("category", "docs")).fetch() * * // the same selection without a schema — rows typed * // { $key: Hex; author: ArkivValue | undefined; title: ArkivValue | undefined } * await client.select({ $key: true, author: true, title: true }).where(eq("category", "docs")).fetch() */ select: { /** * Select every field — and every column through a schema, or the `$attributes` map without * one. Pass nothing or `"*"`. The `$attributeSchema` is not included: select it by name. */ (selection?: "*"): SelectQueryBuilder<"*">; /** * Pick the fields to return. Set the ones you want to `true` (at least one is required); the * result is typed to exactly those fields, so reading anything else is a compile error. * * Entity fields start with `$`: `$key`, `$owner`, `$creator`, `$createdAt`, `$updatedAt`, * `$expiresAt` and `$creationFlags`. `$attributes` reads every attribute as a map, and * `$attributeSchema` their names, types and indexing without the values — a cheap way to find * out what entities hold before fetching values that may be too large for one response. Any * other name is an attribute, read as a field * of its own: untyped without a schema, and through one typed and checked as the column it * must be. An attribute name cannot start with `$`, so the two never collide. * * Pass the selection inline so its fields stay literal `true`. A selection stored in a `let`/ * `const` variable widens to `boolean`, and one typed {@link SelectArg} is only known at * runtime: which fields come back is then decided at runtime, so every field of the result is * optional — a {@link PartialRow}. Annotate a stored selection `as const` to keep it narrow. * * @example * client.select({ $key: true, title: true }) // { $key: Hex; title: ArkivValue | undefined } * client.select({ $key: true, title: true }).from(Posts) // { $key: Hex; title: StrValue } * client.select({ $owner: true, $attributes: true }) // { $owner: Hex; $attributes: Attributes } * client.select({ $key: true, $attributeSchema: true }) // what do they hold? no values */ <const S extends SelectArg>(selection: S & NonEmptySelection<S> & KnownSystemFields<S>): SelectQueryBuilder<SelectionOf<S>>; }; /** * Returns a CountQueryBuilder: counts the entities a query matches, without fetching any of them. * * It filters exactly as {@link select} does — `.from(schema)`, `.where(...)`, `.ownedBy(...)` and * `.createdBy(...)` — and `.fetch()` resolves to a `bigint`. To show the total next to a page of * rows, use `select(...).withCount()` instead. * * - JSON-RPC Methods: `arkiv_query`, with the `count` projection * * @example * const total = await client.count().from(Posts).ownedBy(account.address).fetch() * const news = await client.count().from(Posts).where(eq("category", "news")).fetch() */ count: () => CountQueryBuilder; /** * Runs one query and returns one page, with no builder in between. * * The selection means what it does in {@link PublicArkivActions.select}, and the results are the * same flat rows a query without a schema returns, typed from the selection. Use `select()` to * read through a schema. This also takes a raw string as an escape hatch for a query built * elsewhere. A raw string * goes to the node exactly as written, with none of the name, type or operator checks the * expression combinators apply. * * @param query - An {@link Expression}, or the raw query string. * @param queryOptions - Selection, sort, page size, offset and count. {@link QueryOptions} * @returns One page of entities. {@link QueryReturnType} * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { and, desc, eq, gte } from "@arkiv-network/sdk/query" * import { i32 } from "@arkiv-network/sdk/schema" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const page = await client.query(and(eq("category", "docs"), gte("level", i32(10))), { * select: { $key: true, title: true }, * orderBy: desc("level", "i32"), * limit: 100, * }) * // { entities: [{ $key: Hex; title: ArkivValue | undefined }], blockNumber: 32223n, count: undefined } * * // The raw form, unchecked: * await client.query("category = str('docs') AND level >= i32(10)") */ query: <const S extends SelectArg = "*", const K extends OrderTerm = OrderTerm>(query: Expression | string, queryOptions?: QueryOptions<S, K>) => Promise<QueryReturnType<QueryRow<S>>>; /** * Returns how many entities an account has created — its entity-minting nonce. * * Not the account's transaction nonce: the engine keeps its own counter per creator and mixes it * into every key it mints, which is why two identical creates from one account never collide. * * @param owner - The account whose nonce to read. * @returns The nonce the account's next create will use. * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const nonce = await client.getEntityNonce("0xabc…") * // 7n — the next entity this account creates is its eighth */ getEntityNonce: (owner: Address) => Promise<bigint>; /** * Works out the keys an account's next creates will be given, before sending them. * * The engine derives a key from the chain, the registry, the owner, the owner's nonce and a * salt — everything but the nonce is known to the caller, and the nonce is read here. This is * what lets a batch reference an entity it is about to mint. * * Each key arrives paired with the salt that mints it, because a create defaults to a *random* * salt: a predicted key only holds if the create carries the salt it was predicted with. And the * prediction holds only while nothing else from this owner is in flight — for a key you can rely * on unconditionally, read it back from the create instead. * * A literal `count` comes back as a fixed-length tuple, so the pairs destructure into names. * * @param parameters - Owner, and either a count or the salts. {@link PredictEntityKeysParameters} * @returns One `{ key, salt }` pair per create, in batch order. * {@link PredictEntityKeysReturnType} * * @example A batch whose second entity points at its first. * import { defineSchema, key, str } from "@arkiv-network/sdk/schema" * * const Nodes = defineSchema("nodes", { name: str(), parent: key().indexed().optional() }) * * const [parent, child] = await client.predictEntityKeys({ owner: account.address, count: 2 }) * await wallet.executeBatch({ * creates: [ * { schema: Nodes, values: { name: "root" }, expiration, salt: parent.salt }, * { * schema: Nodes, * values: { name: "leaf", parent: key(parent.key) }, * expiration, * salt: child.salt, * }, * ], * }) */ predictEntityKeys: <const TCount extends number = number, const TSalts extends readonly SaltInput[] | undefined = undefined>(parameters: PredictEntityKeysParameters<TCount, TSalts>) => Promise<PredictEntityKeysReturnType<TCount, TSalts>>; /** * Returns the current block timing. * @returns The current block timing. {@link GetBlockTimingReturnType} * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const blockTiming = await client.getBlockTiming() * // { * // currentBlock: 10n, // block number * // currentBlockTime: 1234567890, // block timestamp * // blockDuration: 2, // in seconds * // } */ getBlockTiming: () => Promise<GetBlockTimingReturnType>; /** * Watches entity events, calling the handlers you pass as they arrive. * * All five are decoded from logs — `onEntityCreated`, `onEntityPatched`, `onExpiryExtended`, * `onOwnershipTransferred`, `onEntityDeleted` — and each carries the block, transaction and log * index it came from, which is the order the operations were applied in. `onEvent` receives all * of them, whatever their type. * * @param parameters - Handlers and options, all optional. {@link WatchEntityEventsParameters} * @returns A function that stops the watcher. * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const unwatch = client.watchEntityEvents({ * onEntityCreated: ({ entityKey, expiresAt }) => console.log(entityKey, "until", expiresAt), * onError: (error) => console.error("watchEntityEvents error", error), * }) * unwatch() // stop watching */ watchEntityEvents: (parameters: WatchEntityEventsParameters) => () => void; }; //#endregion //#region src/clients/createPublicClient.d.ts type PublicArkivClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema> = Prettify<Client<transport, chain, accountOrAddress, rpcSchema, PublicArkivActions<transport, chain>>>; /** * Creates a Public Client with a given [Transport](https://viem.sh/docs/clients/intro) configured for a [Chain](https://viem.sh/docs/chains/introduction). * * A Public Client is an interface to the "public" [Ethereum JSON-RPC API](https://ethereum.org/en/developers/docs/apis/json-rpc/) * and the Arkiv JSON-RPC API — retrieving block numbers and transactions, reading from * contracts, and querying entities — through {@link PublicArkivActions}. * * @param parameters - Configuration object for the public client (chain, transport, etc.) * @returns An Arkiv Public Client. {@link PublicArkivClient} * * @example * import { createPublicClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * * const client = createPublicClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) */ declare function createPublicClient<transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = ArkivRpcSchema>(parameters: PublicClientConfig<transport, chain, accountOrAddress, rpcSchema>): PublicArkivClient<transport, chain, ParseAccount<accountOrAddress>, rpcSchema>; //#endregion //#region src/clients/decorators/arkivWallet.d.ts type WalletArkivActions<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = Pick<PublicActions<transport, chain, account>, "waitForTransactionReceipt" | "call" | "simulateContract" | "readContract" | "getBlockNumber"> & Pick<WalletActions<chain, account>, "addChain" | "sendCalls" | "waitForCallsStatus" | "sendTransaction" | "sendRawTransaction" | "signMessage" | "signTransaction" | "writeContract"> & { /** * Creates a new entity through a schema: each column becomes an attribute, written with the * type and indexed flag the schema declares. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * @param schema - The schema the entity is written through, built with `defineSchema`. * @param values - The entity's values, keyed by column. Required columns must be given; * defaulted ones left out are written with their default. {@link CreateEntityValues} * @param options - The entity's lifetime, plus its flags and salt. {@link CreateEntityOptions} * @param txParams - Optional transaction parameters * @returns The new entity's key, the transaction hash, and the block it expires at, as the * engine recorded it. {@link CreateEntityReturnType} * * @throws {InvalidExpiryError} If the expiry exceeds a protocol bound or would leave the * entity dead on arrival. * @throws {SchemaMismatchError} If the values do not fit the schema. * @throws {InvalidValueError} If a value does not fit its type. * @throws {EntityTooLargeError} If the `bytes` values add up to more than `MAX_ENTITY_BYTES`. * @throws {EntityMutationError} If the transaction fails or reverts. * * @example * import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk" * import { addr, bytes, dec, defineSchema, str } from "@arkiv-network/sdk/schema" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * import { privateKeyToAccount } from "viem/accounts" * * const Posts = defineSchema("posts", { * author: addr().indexed(), * category: str().indexed(), * score: dec().indexed(), * title: str(), * body: bytes(), * thumbnail: bytes().optional(), * mimeType: str().default("text/markdown"), * }) * * const client = createWalletClient({ * account: privateKeyToAccount("0x..."), * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const { entityKey, txHash, expiresAt } = await client.createEntity( * Posts, * { * author: addr(client.account.address), * category: "docs", * score: dec("4.1"), * title: "Cells, not entities", * body: new TextEncoder().encode("# Hello"), * }, * { expiration: ExpirationTime.fromDays(30) }, * ) */ createEntity: <S extends Schema>(schema: S, values: CreateEntityValues<S>, options: CreateEntityOptions, txParams?: TxParams) => Promise<CreateEntityReturnType>; /** * Patches the entity with the given key through a schema: sets some columns, unsets optional * ones, and leaves everything it does not name alone. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * @param schema - The schema the changes are typed by. * @param entityKey - The entity to patch. * @param changes - The columns to set and the optional columns to unset. {@link PatchEntityChanges} * @param txParams - Optional transaction parameters * @returns The patched entity's key and the transaction hash. {@link PatchEntityReturnType} * * @throws {EmptyPatchError} If the patch has nothing to apply. * @throws {ConflictingMutationError} If a name appears in both `set` and `unset`. * @throws {SchemaMismatchError} If the changes do not fit the schema. * @throws {InvalidValueError} If a value does not fit its type. * @throws {EntityTooLargeError} If the `bytes` values in `set` add up to more than * `MAX_ENTITY_BYTES`. * @throws {EntityMutationError} If the transaction fails or reverts. * * @example * // Posts is the schema from the createEntity example. * // One column changes, an optional one goes away. * const { txHash } = await client.patchEntity(Posts, entityKey, { * set: { score: dec("4.5") }, * unset: ["thumbnail"], * }) */ patchEntity: <S extends Schema>(schema: S, entityKey: Hex, changes: PatchEntityChanges<S>, txParams?: TxParams) => Promise<PatchEntityReturnType>; /** * Deletes the entity with the given key. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * @param data - The entity deletion parameters * @param txParams - Optional transaction parameters * @returns The deleted entity's key and the transaction hash. {@link DeleteEntityReturnType} * * @example * import { createWalletClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * import { privateKeyToAccount } from "viem/accounts" * * const client = createWalletClient({ * account: privateKeyToAccount("0x..."), * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * // entityKey is the bytes32 key returned by createEntity. * const { txHash } = await client.deleteEntity({ entityKey }) */ deleteEntity: (data: DeleteEntityParameters, txParams?: TxParams) => Promise<DeleteEntityReturnType>; /** * Sets a new expiry on the entity with the given key. * * The new lifetime is resolved the same way a create's is: a duration counts from now rather * than adding to what the entity has left, and `atBlock` / `atDate` pin an absolute deadline. * The engine rejects an extension that would move the expiry earlier; one that resolves to the * current expiry changes nothing. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * @param data - The entity key and its new lifetime * @param txParams - Optional transaction parameters * @returns The entity's key, the transaction hash, and the block it now expires at, as the * engine recorded it. {@link ExtendEntityReturnType} * * @throws {InvalidExpiryError} If the expiry is malformed, exceeds a protocol bound, or would * leave the entity dead on arrival. * * @example * import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * import { privateKeyToAccount } from "viem/accounts" * * const client = createWalletClient({ * account: privateKeyToAccount("0x..."), * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * const { txHash, expiresAt } = await client.extendEntity({ * entityKey, * expiration: ExpirationTime.fromDays(30), * }) */ extendEntity: (data: ExtendEntityParameters, txParams?: TxParams) => Promise<ExtendEntityReturnType>; /** * Hands the entity with the given key to a new owner. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * @param data - The ownership change parameters * @param txParams - Optional transaction parameters * @returns The entity's key and the transaction hash. {@link ChangeOwnershipReturnType} */ changeOwnership: (data: ChangeOwnershipParameters, txParams?: TxParams) => Promise<ChangeOwnershipReturnType>; /** * Applies a batch of entity operations — creates, patches, deletes, extensions and ownership * transfers — in one transaction. * * - JSON-RPC Methods: `eth_sendRawTransaction` * * Every operation lands in one transaction, so the whole batch applies or none of it does. * At least one operation is required. Each create and patch names its own schema and is typed * by it, so one batch can write entities of several schemas. * * @param data - The batch parameters (creates, patches, deletes, extensions, ownershipChanges) * @param txParams - Optional transaction parameters * @returns The transaction hash, plus the keys touched by each kind of operation. * {@link ExecuteBatchReturnType} * * @throws {Error} If the batch has no operations. * @throws {InvalidExpiryError} If an expiry exceeds a protocol bound or would leave the entity * dead on arrival. * @throws {SchemaMismatchError} If a create's or patch's values do not fit its schema. * @throws {InvalidValueError} If a value does not fit its type. * @throws {EmptyPatchError} If a patch has nothing to apply. * @throws {ConflictingMutationError} If a patch names a column in both `set` and `unset`. * @throws {EntityTooLargeError} If the `bytes` values of one create or patch add up to more * than `MAX_ENTITY_BYTES`. * @throws {EntityMutationError} If the transaction fails or reverts. * * @example * import { createWalletClient, ExpirationTime } from "@arkiv-network/sdk" * import { dec } from "@arkiv-network/sdk/schema" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * import { privateKeyToAccount } from "viem/accounts" * * const client = createWalletClient({ * account: privateKeyToAccount("0x..."), * chain: rabdi({ accessKey: "..." }), * transport: http(), * }) * // Posts is the schema from the createEntity example. * const { txHash, createdEntities } = await client.executeBatch({ * creates: [{ * schema: Posts, * values: { author, category: "docs", score: dec("4.1"), title: "Hi", body: new Uint8Array() }, * expiration: ExpirationTime.fromDays(30), * }], * patches: [{ schema: Posts, entityKey: keyToRevise, set: { category: "archive" } }], * deletes: [{ entityKey: staleKey }], * extensions: [{ * entityKey: keyToKeepAlive, * expiration: ExpirationTime.atBlock(1_200_000n), * }], * ownershipChanges: [{ entityKey: keyToHandOver, newOwner }], * }) */ executeBatch: <const TCreates extends readonly Schema[] = [], const TPatches extends readonly Schema[] = []>(data: ExecuteBatchParameters<TCreates, TPatches>, txParams?: TxParams) => Promise<ExecuteBatchReturnType>; }; //#endregion //#region src/clients/createWalletClient.d.ts 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>>>; /** * Creates a Wallet Client with a given [Transport](https://viem.sh/docs/clients/intro) configured * for a [Chain](https://viem.sh/docs/chains/introduction) and an account. * * A Wallet Client signs and sends transactions, so it carries an `account` and exposes everything * that mutates state — `createEntity`, `patchEntity`, `deleteEntity`, `extendEntity`, * `changeOwnership` and `executeBatch` — alongside the viem actions those need, such as * `getBlockNumber`, `readContract` and `waitForTransactionReceipt`. It does not have the Arkiv * read actions (`getEntity`, `query`, `select`, `watchEntityEvents`, `predictEntityKeys`); read * through a Public Client from `createPublicClient` for those. * * @param parameters - Configuration object for the wallet client (chain, transport, account, etc.) * @returns An Arkiv Wallet Client. {@link WalletArkivClient} * * @example * import { createWalletClient } from "@arkiv-network/sdk" * import { rabdi } from "@arkiv-network/sdk/chains" * import { http } from "viem" * import { privateKeyToAccount } from "viem/accounts" * * const client = createWalletClient({ * chain: rabdi({ accessKey: "..." }), * transport: http(), * account: privateKeyToAccount("0x..."), * }) */ 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>; //#endregion //#region src/errors.d.ts declare class EntityMutationError extends Error { readonly txHash: Hex | undefined; constructor(message: string, options?: { cause?: unknown; txHash?: Hex | undefined; }); } declare class NoEntityFoundError extends Error { /** The key that matched nothing, when the lookup was by key. */ readonly entityKey: string | undefined; constructor(entityKey?: string); } declare class EmptyPatchError extends Error { readonly entityKey: string; constructor(entityKey: string); } declare class MissingAccessKeyError extends Error { /** The chain that was asked for without a key. */ readonly chain: string; constructor(chain: string); } //#endregion export { AddrValue, AnyColumn, type ArkivClient, ArkivRpcSchema, ArkivValue, type AttributeRef, AttributeSchema, Attributes, BareOf, BoolValue, BytesValue, ChangeOwnershipParameters, ChangeOwnershipReturnType, Column, ColumnInput, Columns, ColumnsOf, ConflictingMutationError, CountQueryBuilder, CreateEntityOptions, CreateEntityParameters, CreateEntityReturnType, CreateEntityValues, CreationFlags, DECIMAL_SCALE, DECIMAL_UNIT, type DeadlineOptions, DecValue, DeleteEntityParameters, DeleteEntityReturnType, type DynamicSelection, ENTITY_EVENTS_ABI, EmptyPatchError, Entity, EntityCreatedEvent, EntityDeletedEvent, EntityEvent, EntityEventContext, EntityEventName, EntityFields, EntityMutationError, EntityPatchedEvent, EntityTooLargeError, ExecuteBatchParameters, ExecuteBatchReturnType, ExpirationTime, Expiry, ExpiryExtendedEvent, type Expression, ExtendEntityParameters, ExtendEntityReturnType, type FromOptions, type FullEntity, type FullRow, GetBlockTimingReturnType, I32Value, I32_MAX, I32_MIN, INDEXED_FLAG, IndexableTypeTag, IndexableValue, IndexedColumnName, InvalidAttributeNameError, InvalidCreationFlagsError, InvalidExpiryError, InvalidSaltError, InvalidValueError, KeyValue, type KnownSystemFields, Lifetime, MAX_ATTRIBUTES, MAX_BYTES_LENGTH, MAX_ENTITY_BYTES, MAX_EXPIRES_AT, MAX_LIFETIME, MAX_NAME_BYTES, MAX_SALT, MAX_STRING_BYTES, MissingAccessKeyError, MissingValueError, NO_SALT, NoEntityFoundError, NoRandomSourceError, type NonEmptySelection, OptionalColumnName, type OrderTerm, OwnershipTransferredEvent, type PartialRow, PatchEntityChanges, PatchEntityParameters, PatchEntityReturnType, PatchEntityValues, PredictEntityKeysParameters, PredictEntityKeysReturnType, PredictedEntityKey, type PublicArkivActions, type PublicArkivClient, type QueryBuilderBase, QueryOptions, type QueryResult, QueryReturnType, QueryRow, ResolvedCreationFlags, type ResultOf, type Row, RpcAttribute, RpcAttributeSchemaEntry, RpcCreationFlags, RpcEntity, RpcQueryOptions, RpcSelect, SCHEMA_ATTRIBUTE, SYSTEM_FIELDS, SaltInput, Schema, SchemaDefinitionError, SchemaMismatchError, type SchemaRef, type SelectArg, SelectQueryBuilder, type Selected, type Selection, type SelectionOf, type SortDirection, StrValue, type SystemField, TagOf, TooManyAttributesError, TxParams, TypeTag, U256Value, U256_MAX, U64Value, U64_MAX, UnknownAttributeTypeError, UntypedValueError, ValueArgument, ValueInput, ValueOf, type WalletArkivActions, type WalletArkivClient, WatchEntityEventsParameters, addr, bool, bytes, createPublicClient, createWalletClient, dec, decFromUnits, decUnits, defineSchema, describeColumns, i32, isArkivValue, isColumn, isSchema, isValidAttributeName, key, lookupColumn, predictEntityKey, randomSalt, str, toValue, u256, u64, validateAttributeName }; //# sourceMappingURL=index.d.ts.map