@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
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { j as ArkivClient } from "./selection-DPg0uyJf.cjs";
|
|
2
|
+
import { f as Operation } from "./index-CA4V7Pdh.cjs";
|
|
3
|
+
import { c as TxParams, t as EntityMutationOps } from "./arkivTransactions-D74gERHG.cjs";
|
|
4
|
+
import { Address, Hash, Hex, TransactionReceipt } from "viem";
|
|
5
|
+
|
|
6
|
+
//#region src/actions/advanced/buildMutation.d.ts
|
|
7
|
+
/** Options for the advanced-path builders ({@link buildMutation}, {@link sendMutation}). */
|
|
8
|
+
type BuildMutationOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* The chain head to resolve relative expiries against.
|
|
11
|
+
*
|
|
12
|
+
* Pass a block number you already hold — from a previous call, `getBlockTiming()`, or your own
|
|
13
|
+
* tracking — and the build spends no RPC call at all. Without it, one `eth_blockNumber` is made,
|
|
14
|
+
* and only when the batch actually needs the head (a relative lifetime or a `Date` deadline);
|
|
15
|
+
* purely absolute `atBlock(n)` expiries never trigger it.
|
|
16
|
+
*
|
|
17
|
+
* Supplying it also buys back a check: absolute expiries are validated against it, so an
|
|
18
|
+
* `atBlock(n)` already in the past throws {@link InvalidExpiryError} locally instead of
|
|
19
|
+
* reverting on-chain. When the head is neither supplied nor fetched, that dead-on-arrival
|
|
20
|
+
* check is skipped — the one local validation of the everyday path this path trades away.
|
|
21
|
+
*/
|
|
22
|
+
currentBlock?: bigint;
|
|
23
|
+
};
|
|
24
|
+
/** What {@link buildMutation} hands back: the batch in every form a sender might want. */
|
|
25
|
+
type BuildMutationReturnType = {
|
|
26
|
+
/** The encoded batch, in engine order, for `writeContract`-style sends. */
|
|
27
|
+
operations: Operation[];
|
|
28
|
+
/** The Arkiv engine address the transaction must be sent to. */
|
|
29
|
+
to: Address;
|
|
30
|
+
/**
|
|
31
|
+
* The full `execute(operations)` calldata. Sign a transaction carrying it offline (with your own
|
|
32
|
+
* nonce, gas and fees) and the whole mutation costs exactly one `eth_sendRawTransaction`.
|
|
33
|
+
*/
|
|
34
|
+
data: Hex;
|
|
35
|
+
/**
|
|
36
|
+
* How many operations of each kind went into the batch — which is how many events of each kind a
|
|
37
|
+
* successful transaction emits, in batch order, for cross-checking a decoded result.
|
|
38
|
+
*/
|
|
39
|
+
expected: {
|
|
40
|
+
creates: number;
|
|
41
|
+
patches: number;
|
|
42
|
+
deletes: number;
|
|
43
|
+
extensions: number;
|
|
44
|
+
ownershipChanges: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Encodes a mutation batch without sending anything.
|
|
49
|
+
*
|
|
50
|
+
* This is the first step of the advanced path: it performs only local validation and encoding, so
|
|
51
|
+
* it costs **zero RPC calls** when `options.currentBlock` is provided (or no expiry is relative),
|
|
52
|
+
* and at most one `eth_blockNumber` otherwise. Send the result however you like: pass `operations`
|
|
53
|
+
* to `writeContract`, or sign `{ to, data }` offline and push it with `eth_sendRawTransaction`.
|
|
54
|
+
*
|
|
55
|
+
* One check rides on knowing the head: an absolute `atBlock(n)` already in the past is rejected
|
|
56
|
+
* locally only when the head is supplied or was fetched anyway. With neither, a dead-on-arrival
|
|
57
|
+
* expiry encodes cleanly and the engine reverts it on-chain — see
|
|
58
|
+
* {@link BuildMutationOptions.currentBlock}.
|
|
59
|
+
*
|
|
60
|
+
* @throws {InvalidExpiryError} If an expiry exceeds a protocol bound.
|
|
61
|
+
* @throws {InvalidValueError} If an attribute value does not fit the type it names.
|
|
62
|
+
* @throws {EmptyPatchError} If a patch has nothing to apply.
|
|
63
|
+
*/
|
|
64
|
+
declare function buildMutation(client: ArkivClient, data: EntityMutationOps, options?: BuildMutationOptions): Promise<BuildMutationReturnType>;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/actions/advanced/getMutationResult.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* A mined mutation, decoded from its receipt alone.
|
|
69
|
+
*
|
|
70
|
+
* Everything here comes out of the events the batch emitted, so no request context is needed to
|
|
71
|
+
* read it — a process that holds nothing but the transaction hash gets the full picture. Arrays
|
|
72
|
+
* are in batch order, which is the order the operations were applied in.
|
|
73
|
+
*/
|
|
74
|
+
type MutationResult = {
|
|
75
|
+
/** `success` means the whole batch applied; `reverted` means none of it did (arrays are empty). */
|
|
76
|
+
status: "success" | "reverted";
|
|
77
|
+
/** The transaction hash. */
|
|
78
|
+
txHash: Hash;
|
|
79
|
+
/** The block the transaction landed in. */
|
|
80
|
+
blockNumber: bigint;
|
|
81
|
+
/** The keys the engine minted for the created entities, in batch order. */
|
|
82
|
+
createdEntities: Hex[];
|
|
83
|
+
/** The block each created entity expires at, as the engine recorded it, in the same order. */
|
|
84
|
+
createdExpiries: bigint[];
|
|
85
|
+
/** The keys of the patched entities. */
|
|
86
|
+
patchedEntities: Hex[];
|
|
87
|
+
/** The keys of the deleted entities. */
|
|
88
|
+
deletedEntities: Hex[];
|
|
89
|
+
/** The keys of the extended entities. */
|
|
90
|
+
extendedEntities: Hex[];
|
|
91
|
+
/** The block each extended entity now expires at, in the same order. */
|
|
92
|
+
extendedExpiries: bigint[];
|
|
93
|
+
/** The keys of the entities handed to a new owner. */
|
|
94
|
+
ownershipChanges: Hex[];
|
|
95
|
+
/** The raw receipt, so nothing the chain said is lost. */
|
|
96
|
+
receipt: TransactionReceipt;
|
|
97
|
+
};
|
|
98
|
+
/** Return type for {@link getMutationResult}: the decoded result, or still pending. */
|
|
99
|
+
type GetMutationResultReturnType = MutationResult | {
|
|
100
|
+
status: "pending";
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Decodes a receipt you already hold into a {@link MutationResult}. **Zero RPC calls.**
|
|
104
|
+
*
|
|
105
|
+
* The pure tail of the advanced path: if a receipt reached you some other way — your own
|
|
106
|
+
* `waitForTransactionReceipt`, a webhook, a block watcher — this turns it into entity keys and
|
|
107
|
+
* expiries without touching the network. Lenient by design: it reports what the events say,
|
|
108
|
+
* without counting them against a request it never saw.
|
|
109
|
+
*/
|
|
110
|
+
declare function decodeMutationResult(receipt: TransactionReceipt): MutationResult;
|
|
111
|
+
/**
|
|
112
|
+
* Fetches a transaction's receipt — once — and decodes what the mutation did.
|
|
113
|
+
*
|
|
114
|
+
* Exactly one `eth_getTransactionReceipt`, like `pingTransaction`, but the answer carries the
|
|
115
|
+
* decoded entity events as well: created keys, recorded expiries, and the keys of everything
|
|
116
|
+
* patched, deleted, extended or handed over. A transaction that is not mined yet comes back as
|
|
117
|
+
* `{ status: "pending" }` — check `status` before reading the rest.
|
|
118
|
+
*
|
|
119
|
+
* No revert diagnosis is run: a `reverted` result reports the fact and the raw receipt, and
|
|
120
|
+
* spending a `simulateContract` on the why is your call, not the SDK's.
|
|
121
|
+
*/
|
|
122
|
+
declare function getMutationResult(client: ArkivClient, txHash: Hash): Promise<GetMutationResultReturnType>;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/actions/advanced/pingTransaction.d.ts
|
|
125
|
+
/** Return type for {@link pingTransaction}. */
|
|
126
|
+
type PingTransactionReturnType = {
|
|
127
|
+
/** Not mined yet (or unknown to this node). Ping again later. */
|
|
128
|
+
status: "pending";
|
|
129
|
+
blockNumber?: undefined;
|
|
130
|
+
} | {
|
|
131
|
+
/** Mined. `success` means the whole batch applied; `reverted` means none of it did. */
|
|
132
|
+
status: "success" | "reverted";
|
|
133
|
+
/** The block the transaction landed in. */
|
|
134
|
+
blockNumber: bigint;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Asks the chain — once — whether a transaction has landed.
|
|
138
|
+
*
|
|
139
|
+
* Exactly one `eth_getTransactionReceipt`, never a poll: a transaction that is not mined yet comes
|
|
140
|
+
* back as `{ status: "pending" }` rather than being waited on. This is the "ping" of the advanced
|
|
141
|
+
* path — you own the schedule, the SDK owns nothing.
|
|
142
|
+
*
|
|
143
|
+
* When it reports `success` and you need the created keys or recorded expiries, spend the next
|
|
144
|
+
* call on `getMutationResult` — or none at all, if you predicted the keys up front with
|
|
145
|
+
* `predictEntityKeys`.
|
|
146
|
+
*/
|
|
147
|
+
declare function pingTransaction(client: ArkivClient, txHash: Hash): Promise<PingTransactionReturnType>;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/actions/advanced/sendMutation.d.ts
|
|
150
|
+
/** Options for {@link sendMutation}. */
|
|
151
|
+
type SendMutationOptions = BuildMutationOptions & {
|
|
152
|
+
/**
|
|
153
|
+
* Transaction parameters. Supply `nonce`, `gas` and the fee fields and viem has nothing left to
|
|
154
|
+
* look up — the send collapses to a single `eth_sendRawTransaction`.
|
|
155
|
+
*/
|
|
156
|
+
txParams?: TxParams;
|
|
157
|
+
};
|
|
158
|
+
/** Return type for {@link sendMutation}. */
|
|
159
|
+
type SendMutationReturnType = {
|
|
160
|
+
/** The transaction hash. Poll it with `pingTransaction` / fetch it with `getMutationResult`. */
|
|
161
|
+
txHash: Hash;
|
|
162
|
+
/** The per-kind operation counts of the batch that was sent, for cross-checking the result. */
|
|
163
|
+
expected: BuildMutationReturnType["expected"];
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Signs and sends a mutation batch, returning as soon as the transaction is submitted.
|
|
167
|
+
*
|
|
168
|
+
* The fire-and-forget half of the advanced path. Unlike `mutateEntities`, this does **not** wait
|
|
169
|
+
* for a receipt, does not poll, and runs no revert diagnosis — it spends only what submitting
|
|
170
|
+
* costs. With `options.currentBlock` and full `txParams` (nonce, gas, fees) that is exactly one
|
|
171
|
+
* RPC call; each omitted piece adds only the lookup viem needs to fill it.
|
|
172
|
+
*
|
|
173
|
+
* Follow up separately, on your own schedule:
|
|
174
|
+
* - `pingTransaction(txHash)` — one `eth_getTransactionReceipt`, tells you pending/success/reverted.
|
|
175
|
+
* - `getMutationResult(txHash)` — the same single call, plus the decoded entity keys and expiries.
|
|
176
|
+
*
|
|
177
|
+
* @throws {EntityMutationError} If the node rejects the submission (the batch never made it into
|
|
178
|
+
* the mempool) — in engine terms when the rejection decodes, with the node's message otherwise.
|
|
179
|
+
* Anything after that — inclusion, success — is yours to check.
|
|
180
|
+
*/
|
|
181
|
+
declare function sendMutation(client: ArkivClient, data: EntityMutationOps, options?: SendMutationOptions): Promise<SendMutationReturnType>;
|
|
182
|
+
//#endregion
|
|
183
|
+
export { pingTransaction as a, decodeMutationResult as c, BuildMutationReturnType as d, buildMutation as f, PingTransactionReturnType as i, getMutationResult as l, SendMutationReturnType as n, GetMutationResultReturnType as o, sendMutation as r, MutationResult as s, SendMutationOptions as t, BuildMutationOptions as u };
|
|
184
|
+
//# sourceMappingURL=index-EeUO0nnJ.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-EeUO0nnJ.d.cts","names":[],"sources":["../src/actions/advanced/buildMutation.ts","../src/actions/advanced/getMutationResult.ts","../src/actions/advanced/pingTransaction.ts","../src/actions/advanced/sendMutation.ts"],"sourcesContent":[],"mappings":";;;;;;;KAeY,oBAAA;EAAA;AAkBZ;;;;;AAwCA;;;;;;;;;;AC1DY,KDkBA,uBAAA,GClBc;EAIhB;EAIS,UAAA,EDYL,SCZK,EAAA;EAIA;EAEA,EAAA,EDQb,OCRa;EAEC;;;;EAUR,IAAA,EDCJ,GCDI;EAUI;AA4BhB;;;EAGW,QAAA,EAAA;IAAR,OAAA,EAAA,MAAA;IAAO,OAAA,EAAA,MAAA;;;;EC1EE,CAAA;AAwBZ,CAAA;;;;;;;;;AClBA;AASA;AAuBA;;;;;;;iBH2BsB,aAAA,SACZ,mBACF,6BACG,uBACR,QAAQ;;;;;;;AA9DX;AAkBA;;AAIM,KCtBM,cAAA,GDsBN;EAKE;EAAG,MAAA,EAAA,SAAA,GAAA,UAAA;EA+BW;EACZ,MAAA,ECvDA,IDuDA;EACF;EACG,WAAA,EAAA,MAAA;EACA;EAAR,eAAA,ECtDgB,GDsDhB,EAAA;EAAO;;;mBClDS;EAZP;EAIF,eAAA,EAUS,GAVT,EAAA;EAIS;EAIA,gBAAA,EAIC,GAJD,EAAA;EAEA;EAEC,gBAAA,EAAA,MAAA,EAAA;EAIA;EAET,gBAAA,EAFS,GAET,EAAA;EAAkB;EAIjB,OAAA,EAJD,kBAIC;AAUZ,CAAA;AA4BA;AACU,KAvCE,2BAAA,GAA8B,cAuChC,GAAA;EACA,MAAA,EAAA,SAAA;CACC;;;;;;AC1EX;AAwBA;;AAEU,iBDiBM,oBAAA,CCjBN,OAAA,EDiBoC,kBCjBpC,CAAA,EDiByD,cCjBzD;;;;;;;ACpBV;AASA;AAuBA;;;AAGW,iBF8BW,iBAAA,CE9BX,MAAA,EF+BD,WE/BC,EAAA,MAAA,EFgCD,IEhCC,CAAA,EFiCR,OEjCQ,CFiCA,2BEjCA,CAAA;;;;KDzCC,yBAAA;;;EFOA,WAAA,CAAA,EAAA,SAAoB;AAkBhC,CAAA,GAAY;EAEE;EAER,MAAA,EAAA,SAAA,GAAA,UAAA;EAKE;EAAG,WAAA,EAAA,MAAA;AA+BX,CAAA;;;;;;;;;;AC1DA;;AAQmB,iBCSG,eAAA,CDTH,MAAA,ECUT,WDVS,EAAA,MAAA,ECWT,IDXS,CAAA,ECYhB,ODZgB,CCYR,yBDZQ,CAAA;;;;ADRP,KGDA,mBAAA,GAAsB,oBHCF,GAAA;EAkBpB;;;;EASD,QAAA,CAAA,EGvBE,QHuBF;AA+BX,CAAA;;AAEQ,KGpDI,sBAAA,GHoDJ;EACG;EACA,MAAA,EGpDD,IHoDC;EAAR;EAAO,QAAA,EGlDE,uBHkDF,CAAA,UAAA,CAAA;;;;AC9DV;;;;;;;;;AA0BA;AAUA;AA4BA;;;AAGW,iBEpCW,YAAA,CFoCX,MAAA,EEnCD,WFmCC,EAAA,IAAA,EElCH,iBFkCG,EAAA,OAAA,CAAA,EEjCA,mBFiCA,CAAA,EEhCR,OFgCQ,CEhCA,sBFgCA,CAAA"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
|
|
3
|
+
//#region src/entity/operations.d.ts
|
|
4
|
+
|
|
5
|
+
/** One entry of the `execute` batch: the operation tag and its ABI-encoded payload. */
|
|
6
|
+
type Operation = {
|
|
7
|
+
operation: number;
|
|
8
|
+
operationData: Hex;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/entity/errors.d.ts
|
|
12
|
+
/** An expiry could not be expressed, or would be rejected by the engine. */
|
|
13
|
+
declare class InvalidExpiryError extends Error {
|
|
14
|
+
constructor(reason: string);
|
|
15
|
+
}
|
|
16
|
+
/** A `creationFlags` byte could not be built or read. */
|
|
17
|
+
declare class InvalidCreationFlagsError extends Error {
|
|
18
|
+
constructor(reason: string);
|
|
19
|
+
}
|
|
20
|
+
/** A key salt was outside the `uint128` the wire carries. */
|
|
21
|
+
declare class InvalidSaltError extends Error {
|
|
22
|
+
constructor(salt: bigint);
|
|
23
|
+
}
|
|
24
|
+
/** No cryptographic randomness was available to generate a salt. */
|
|
25
|
+
declare class NoRandomSourceError extends Error {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/entity/events.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* The events the engine emits: one per applied operation, in application order, so an off-chain
|
|
32
|
+
* replica can replay a transaction operation by operation.
|
|
33
|
+
*/
|
|
34
|
+
declare const ENTITY_EVENTS_ABI: readonly [{
|
|
35
|
+
readonly name: "EntityCreated";
|
|
36
|
+
readonly type: "event";
|
|
37
|
+
readonly inputs: readonly [{
|
|
38
|
+
readonly type: "bytes32";
|
|
39
|
+
readonly name: "entityKey";
|
|
40
|
+
readonly indexed: true;
|
|
41
|
+
}, {
|
|
42
|
+
readonly type: "address";
|
|
43
|
+
readonly name: "owner";
|
|
44
|
+
readonly indexed: true;
|
|
45
|
+
}, {
|
|
46
|
+
readonly type: "uint64";
|
|
47
|
+
readonly name: "expiresAt";
|
|
48
|
+
}, {
|
|
49
|
+
readonly type: "uint8";
|
|
50
|
+
readonly name: "creationFlags";
|
|
51
|
+
}];
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "EntityPatched";
|
|
54
|
+
readonly type: "event";
|
|
55
|
+
readonly inputs: readonly [{
|
|
56
|
+
readonly type: "bytes32";
|
|
57
|
+
readonly name: "entityKey";
|
|
58
|
+
readonly indexed: true;
|
|
59
|
+
}, {
|
|
60
|
+
readonly type: "address";
|
|
61
|
+
readonly name: "owner";
|
|
62
|
+
readonly indexed: true;
|
|
63
|
+
}];
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "ExpiryExtended";
|
|
66
|
+
readonly type: "event";
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly type: "bytes32";
|
|
69
|
+
readonly name: "entityKey";
|
|
70
|
+
readonly indexed: true;
|
|
71
|
+
}, {
|
|
72
|
+
readonly type: "address";
|
|
73
|
+
readonly name: "owner";
|
|
74
|
+
readonly indexed: true;
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "uint64";
|
|
77
|
+
readonly name: "expiresAt";
|
|
78
|
+
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "OwnershipTransferred";
|
|
81
|
+
readonly type: "event";
|
|
82
|
+
readonly inputs: readonly [{
|
|
83
|
+
readonly type: "bytes32";
|
|
84
|
+
readonly name: "entityKey";
|
|
85
|
+
readonly indexed: true;
|
|
86
|
+
}, {
|
|
87
|
+
readonly type: "address";
|
|
88
|
+
readonly name: "previousOwner";
|
|
89
|
+
readonly indexed: true;
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "address";
|
|
92
|
+
readonly name: "newOwner";
|
|
93
|
+
readonly indexed: true;
|
|
94
|
+
}];
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "EntityDeleted";
|
|
97
|
+
readonly type: "event";
|
|
98
|
+
readonly inputs: readonly [{
|
|
99
|
+
readonly type: "bytes32";
|
|
100
|
+
readonly name: "entityKey";
|
|
101
|
+
readonly indexed: true;
|
|
102
|
+
}, {
|
|
103
|
+
readonly type: "address";
|
|
104
|
+
readonly name: "owner";
|
|
105
|
+
readonly indexed: true;
|
|
106
|
+
}];
|
|
107
|
+
}];
|
|
108
|
+
/** The name of each event in {@link ENTITY_EVENTS_ABI}. */
|
|
109
|
+
type EntityEventName = (typeof ENTITY_EVENTS_ABI)[number]["name"];
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/entity/key.d.ts
|
|
112
|
+
/** The widest salt the `uint128` wire field carries. */
|
|
113
|
+
declare const MAX_SALT: bigint;
|
|
114
|
+
/**
|
|
115
|
+
* A cryptographically random 128-bit salt — what {@link CreateEntityParameters.salt} defaults to.
|
|
116
|
+
*
|
|
117
|
+
* The salt exists for unpredictability, not uniqueness: the per-owner nonce already guarantees
|
|
118
|
+
* distinct keys. Random bits mean only the creator can predict the key of an entity they are about
|
|
119
|
+
* to create, so nobody else can reference or squat it in advance.
|
|
120
|
+
*
|
|
121
|
+
* @throws {NoRandomSourceError} If the runtime has no `crypto.getRandomValues`.
|
|
122
|
+
*/
|
|
123
|
+
declare function randomSalt(): bigint;
|
|
124
|
+
/**
|
|
125
|
+
* The key an entity will be created with, derived exactly as the engine derives it:
|
|
126
|
+
* `keccak256(domain ++ owner ++ nonce ++ salt)`.
|
|
127
|
+
*
|
|
128
|
+
* Deriving it client-side is what lets a batch compose: predict the key of a create, then have a
|
|
129
|
+
* later operation in the same transaction reference it, or store it as a `key` attribute on a
|
|
130
|
+
* sibling entity.
|
|
131
|
+
*/
|
|
132
|
+
declare function predictEntityKey({
|
|
133
|
+
owner,
|
|
134
|
+
nonce,
|
|
135
|
+
salt,
|
|
136
|
+
chainId
|
|
137
|
+
}: {
|
|
138
|
+
/** The account creating the entity. */
|
|
139
|
+
owner: Address;
|
|
140
|
+
/**
|
|
141
|
+
* The owner's entity-nonce at creation time. Each create in a batch consumes one, so the *n*th
|
|
142
|
+
* create in a batch uses `nonce + n`.
|
|
143
|
+
*/
|
|
144
|
+
nonce: bigint;
|
|
145
|
+
/** The salt the create will carry. */
|
|
146
|
+
salt: bigint;
|
|
147
|
+
/** The chain the entity is being created on — half of the derivation domain. */
|
|
148
|
+
chainId: number;
|
|
149
|
+
}): Hex;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/entity/params.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* Max uint64 value
|
|
154
|
+
*/
|
|
155
|
+
declare const MAX_EXPIRES_AT: bigint;
|
|
156
|
+
/** The operation tags of the `execute` ABI's tagged union. */
|
|
157
|
+
declare const OperationType: {
|
|
158
|
+
readonly Create: 1;
|
|
159
|
+
readonly Patch: 2;
|
|
160
|
+
readonly ExtendExpiry: 3;
|
|
161
|
+
readonly TransferOwnership: 4;
|
|
162
|
+
readonly Delete: 5;
|
|
163
|
+
};
|
|
164
|
+
type OperationType = (typeof OperationType)[keyof typeof OperationType];
|
|
165
|
+
//#endregion
|
|
166
|
+
export { randomSalt as a, InvalidCreationFlagsError as c, NoRandomSourceError as d, Operation as f, predictEntityKey as i, InvalidExpiryError as l, OperationType as n, ENTITY_EVENTS_ABI as o, MAX_SALT as r, EntityEventName as s, MAX_EXPIRES_AT as t, InvalidSaltError as u };
|
|
167
|
+
//# sourceMappingURL=index-fX_XyqLp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-fX_XyqLp.d.ts","names":[],"sources":["../src/entity/operations.ts","../src/entity/errors.ts","../src/entity/events.ts","../src/entity/key.ts","../src/entity/params.ts"],"sourcesContent":[],"mappings":";;;;;KAgDY,SAAA;;iBAEK;;;;;cCjDJ,kBAAA,SAA2B,KAAA;;AD+CxC;;cCvCa,yBAAA,SAAkC,KAAA;;AAR/C;AAQA;AAQa,cAAA,gBAAA,SAAyB,KAAA,CAAK;EAW9B,WAAA,CAAA,IAAA,EAAA,MAAoB;;;cAApB,mBAAA,SAA4B,KAAA;ECtB5B,WAAA,CAAA;AASb;;;;;;AFiCA;cE1Ca;;;EDLA,SAAA,MAAA,EAAA,SAAmB,CAAA;IAQnB,SAAA,IAAA,EAAA,SAA0B;IAQ1B,SAAA,IAAA,EAAiB,WAAA;IAWjB,SAAA,OAAA,EAAoB,IAAA;;;;ICtBpB,SAAA,OAMX,EAAA,IAAA;EAGU,CAAA,EAAA;;;;ICVC,SAA0B,IAAA,EAAA,OAAA;IAWvB,SAAU,IAAA,EAAA,eAAA;EA2BV,CAAA,CAAA;CACd,EAAA;EACA,SAAA,IAAA,EAAA,eAAA;EACA,SAAA,IAAA,EAAA,OAAA;EACA,SAAA,MAAA,EAAA,SAAA,CAAA;IAGO,SAAA,IAAA,EAAA,SAAA;IAUL,SAAA,IAAA,EAAA,WAAA;IAAG,SAAA,OAAA,EAAA,IAAA;;;;ICzDM,SAAA,OAA+B,EAAA,IAAA;EAG/B,CAAA,CAAA;AAQb,CAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KFCY,eAAA,WAA0B;;;;cCVzB;AH2Cb;;;;AC/CA;AAQA;AAQA;AAWA;;iBEZgB,UAAA,CAAA;ADDhB;;;;ACVA;AAWA;AA2BA;;AAEE,iBAFc,gBAAA,CAEd;EAAA,KAAA;EAAA,KAAA;EAAA,IAAA;EAAA;CAAA,EAAA;EACA;EACA,KAAA,EAGO,OAHP;EAGO;;;;;;EC/CI,IAAA,EAAA,MAAA;EAGA;EAQD,OAAA,EAAA,MAAA;ID8CR;;;;;;AHZQ,cI7CC,cJ+CO,EAAA,MAAA;;cI5CP;;EHLA,SAAA,KAAA,EAAA,CAAA;EAQA,SAAA,YAAA,EAAA,CAAA;EAQA,SAAA,iBAAiB,EAAA,CAAA;EAWjB,SAAA,MAAA,EAAA,CAAA;;KGdD,aAAA,WAAwB,4BAA4B"}
|