@arkiv-network/sdk 0.8.0-advanced.2 → 0.8.0-dev.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 +0 -42
- package/dist/attr/index.cjs +33 -34
- package/dist/attr/index.d.cts +1 -1
- package/dist/attr/index.d.ts +1 -2
- package/dist/attr/index.js +1 -2
- package/dist/{attributes-Df9IsCVs.cjs → attr-BXTkpnoc.cjs} +13 -3
- package/dist/{attributes-BhY5DwJp.js → attr-tmyREHtw.js} +14 -4
- package/dist/attr-tmyREHtw.js.map +1 -0
- package/dist/chains/index.cjs +1 -1
- package/dist/chains/index.d.cts +3 -0
- package/dist/chains/index.d.cts.map +1 -1
- package/dist/chains/index.d.ts +3 -0
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/{chains-BYRTTipa.cjs → chains-BfNQliHU.cjs} +3 -0
- package/dist/{chains-BJrZs6sG.js → chains-Du8tql7I.js} +4 -1
- package/dist/chains-Du8tql7I.js.map +1 -0
- package/dist/{arkivTransactions-NtGD6uk5.d.ts → changeOwnership-B0ar96ub.d.ts} +74 -123
- package/dist/changeOwnership-B0ar96ub.d.ts.map +1 -0
- package/dist/{arkivTransactions-D74gERHG.d.cts → changeOwnership-BofkLnXJ.d.cts} +74 -123
- package/dist/changeOwnership-BofkLnXJ.d.cts.map +1 -0
- package/dist/entity/index.cjs +9 -9
- package/dist/entity/index.d.cts +3 -3
- package/dist/entity/index.d.ts +4 -5
- package/dist/entity/index.js +5 -6
- package/dist/{entity-BYQR1uoe.js → entity-BIp_df9u.js} +1 -1
- package/dist/{entity-BYQR1uoe.js.map → entity-BIp_df9u.js.map} +1 -1
- package/dist/{key-D1Bh7MF0.js → entity-CniBgBSd.js} +31 -19
- package/dist/entity-CniBgBSd.js.map +1 -0
- package/dist/{key-WKhXnXuU.cjs → entity-DJ0Gml9c.cjs} +37 -19
- package/dist/{errors-LTe7bOYS.js → errors-D2E1GRjw.js} +2 -2
- package/dist/errors-D2E1GRjw.js.map +1 -0
- package/dist/{errors-BVbjKVMN.cjs → errors-DhV00966.cjs} +1 -1
- package/dist/{expiry-nDbCgZX4.d.ts → expiry-BxOlvVWC.d.ts} +1 -1
- package/dist/{expiry-nDbCgZX4.d.ts.map → expiry-BxOlvVWC.d.ts.map} +1 -1
- package/dist/{expiry-BELY2Kpw.cjs → expiry-CG9GhVXv.cjs} +1 -1
- package/dist/{expiry-BjpxZZQU.js → expiry-Cgdb_dbq.js} +2 -2
- package/dist/expiry-Cgdb_dbq.js.map +1 -0
- package/dist/expiry-DRV29F1r.d.cts.map +1 -1
- package/dist/{flags-CRjPpoh3.d.cts → flags-0Vl5rrHq.d.cts} +1 -1
- package/dist/{flags-CRjPpoh3.d.cts.map → flags-0Vl5rrHq.d.cts.map} +1 -1
- package/dist/{flags-kr276q6i.cjs → flags-DCD26uhe.cjs} +1 -1
- package/dist/{flags-DFBs2J94.js → flags-DUT2gHEU.js} +2 -2
- package/dist/{flags-DFBs2J94.js.map → flags-DUT2gHEU.js.map} +1 -1
- package/dist/{flags-5dTNRnow.d.ts → flags-wmcMoAnN.d.ts} +1 -1
- package/dist/{flags-5dTNRnow.d.ts.map → flags-wmcMoAnN.d.ts.map} +1 -1
- package/dist/{index-fX_XyqLp.d.ts → index-BGp2plHs.d.cts} +15 -13
- package/dist/index-BGp2plHs.d.cts.map +1 -0
- package/dist/{index-DHDud2hC.d.ts → index-BKB875Um.d.ts} +5 -7
- package/dist/{index-DHDud2hC.d.ts.map → index-BKB875Um.d.ts.map} +1 -1
- package/dist/{index-DvYvrkdk.d.ts → index-CIcHPx2j.d.cts} +110 -6
- package/dist/index-CIcHPx2j.d.cts.map +1 -0
- package/dist/{index-CV5zCdpa.d.cts → index-Cd2aaWme.d.ts} +13 -6
- package/dist/index-Cd2aaWme.d.ts.map +1 -0
- package/dist/{index-CA4V7Pdh.d.cts → index-ezMZ2-JH.d.ts} +15 -13
- package/dist/index-ezMZ2-JH.d.ts.map +1 -0
- package/dist/{index-BF7Mq9Is.d.cts → index-rINthNuU.d.cts} +5 -7
- package/dist/{index-BF7Mq9Is.d.cts.map → index-rINthNuU.d.cts.map} +1 -1
- package/dist/index.cjs +433 -139
- package/dist/index.d.cts +58 -164
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +59 -166
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +376 -75
- package/dist/index.js.map +1 -1
- package/dist/{payload-CcUj85ys.d.ts → payload-CGvVPZQX.d.ts} +61 -2
- package/dist/payload-CGvVPZQX.d.ts.map +1 -0
- package/dist/{payload-Bz6651ax.js → payload-DE7wMztL.js} +28 -3
- package/dist/payload-DE7wMztL.js.map +1 -0
- package/dist/{payload-BNoud2KZ.d.cts → payload-Dfu30njp.d.cts} +60 -1
- package/dist/payload-Dfu30njp.d.cts.map +1 -0
- package/dist/{payload-KC14SDlN.cjs → payload-DqFweqiO.cjs} +27 -2
- package/dist/query/index.cjs +5 -7
- package/dist/query/index.d.cts +4 -4
- package/dist/query/index.d.ts +4 -5
- package/dist/query/index.js +5 -7
- package/dist/{queryBuilder-DM6AWCBa.js → queryBuilder-wvA8sn--.js} +169 -23
- package/dist/queryBuilder-wvA8sn--.js.map +1 -0
- package/dist/{queryBuilder-DbUMEZln.cjs → queryBuilder-zHGhDmaG.cjs} +215 -33
- package/dist/{selection-DPg0uyJf.d.cts → selection-Bv8_o-7i.d.cts} +76 -68
- package/dist/selection-Bv8_o-7i.d.cts.map +1 -0
- package/dist/{selection-C4UhsMOO.d.ts → selection-ox7zdtVm.d.ts} +76 -69
- package/dist/selection-ox7zdtVm.d.ts.map +1 -0
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +6 -6
- package/dist/types/index.d.ts +7 -8
- package/dist/types/index.js +2 -2
- package/dist/utils/index.cjs +3 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -3
- package/package.json +1 -5
- package/src/actions/public/getEntity.ts +1 -0
- package/src/actions/public/predictEntityKeys.test.ts +17 -1
- package/src/actions/public/predictEntityKeys.ts +28 -14
- package/src/actions/public/query.ts +1 -5
- package/src/actions/wallet/createEntity.ts +7 -6
- package/src/actions/wallet/{mutateEntities.test.ts → executeBatch.test.ts} +7 -7
- package/src/actions/wallet/{mutateEntities.ts → executeBatch.ts} +26 -11
- package/src/actions/wallet/extendEntity.ts +1 -0
- package/src/actions/wallet/patchEntity.ts +3 -3
- package/src/attr/attributes.ts +8 -2
- package/src/attr/errors.ts +2 -2
- package/src/attr/types.ts +3 -3
- package/src/attr/values.ts +5 -1
- package/src/chains/localhost.ts +3 -0
- package/src/clients/createPublicClient.test.ts +1 -1
- package/src/clients/createPublicClient.ts +5 -5
- package/src/clients/createWalletClient.test.ts +2 -2
- package/src/clients/createWalletClient.ts +3 -5
- package/src/clients/decorators/arkivPublic.ts +13 -24
- package/src/clients/decorators/arkivWallet.ts +40 -47
- package/src/entity/create.test.ts +20 -1
- package/src/entity/errors.ts +4 -3
- package/src/entity/expiry.ts +1 -0
- package/src/entity/index.ts +2 -2
- package/src/entity/key.ts +23 -3
- package/src/entity/operations.ts +1 -0
- package/src/index.ts +0 -13
- package/src/query/engine.ts +0 -11
- package/src/query/errors.ts +1 -1
- package/src/query/expression.ts +14 -7
- package/src/query/queryBuilder.test.ts +1 -21
- package/src/query/queryBuilder.ts +3 -10
- package/src/types/index.ts +4 -4
- package/src/types/rpcSchema.ts +1 -0
- package/src/types/txParams.ts +8 -0
- package/src/utils/arkivTransactions.test.ts +7 -1
- package/src/utils/arkivTransactions.ts +114 -254
- package/src/utils/expirationTime.ts +39 -0
- package/src/utils/payload.ts +25 -0
- package/dist/actions/advanced/index.cjs +0 -13
- package/dist/actions/advanced/index.d.cts +0 -8
- package/dist/actions/advanced/index.d.ts +0 -9
- package/dist/actions/advanced/index.js +0 -9
- package/dist/advanced-8ZPTmmaN.js +0 -598
- package/dist/advanced-8ZPTmmaN.js.map +0 -1
- package/dist/advanced-fPImL6lW.cjs +0 -656
- package/dist/arkivTransactions-D74gERHG.d.cts.map +0 -1
- package/dist/arkivTransactions-NtGD6uk5.d.ts.map +0 -1
- package/dist/attributes-BhY5DwJp.js.map +0 -1
- package/dist/chains-BJrZs6sG.js.map +0 -1
- package/dist/codec-Car3KkFF.d.ts +0 -102
- package/dist/codec-Car3KkFF.d.ts.map +0 -1
- package/dist/entity-B7G8q_Eo.cjs +0 -0
- package/dist/entity-CD_qFF2M.js +0 -0
- package/dist/errors-LTe7bOYS.js.map +0 -1
- package/dist/expiry-BjpxZZQU.js.map +0 -1
- package/dist/index-B5j76711.d.ts +0 -184
- package/dist/index-B5j76711.d.ts.map +0 -1
- package/dist/index-CA4V7Pdh.d.cts.map +0 -1
- package/dist/index-CV5zCdpa.d.cts.map +0 -1
- package/dist/index-DvYvrkdk.d.ts.map +0 -1
- package/dist/index-EeUO0nnJ.d.cts +0 -184
- package/dist/index-EeUO0nnJ.d.cts.map +0 -1
- package/dist/index-fX_XyqLp.d.ts.map +0 -1
- package/dist/key-D1Bh7MF0.js.map +0 -1
- package/dist/logger-CVpvU8ik.js +0 -153
- package/dist/logger-CVpvU8ik.js.map +0 -1
- package/dist/logger-Cr15lPAQ.cjs +0 -188
- package/dist/payload-BNoud2KZ.d.cts.map +0 -1
- package/dist/payload-Bz6651ax.js.map +0 -1
- package/dist/payload-CcUj85ys.d.ts.map +0 -1
- package/dist/queryBuilder-DM6AWCBa.js.map +0 -1
- package/dist/selection-C4UhsMOO.d.ts.map +0 -1
- package/dist/selection-DPg0uyJf.d.cts.map +0 -1
- package/dist/types-Bu_ZwMbZ.js +0 -0
- package/dist/types-NRqymi6S.cjs +0 -0
- package/src/actions/advanced/advanced.test.ts +0 -258
- package/src/actions/advanced/buildMutation.ts +0 -104
- package/src/actions/advanced/getMutationResult.ts +0 -112
- package/src/actions/advanced/index.ts +0 -21
- package/src/actions/advanced/pingTransaction.ts +0 -43
- package/src/actions/advanced/sendMutation.ts +0 -59
- package/src/clients/decorators/arkivAdvanced.ts +0 -144
- /package/dist/{entity-B00Li04j.cjs → entity-B0t6sN7F.cjs} +0 -0
- /package/dist/{attr-DlmErkvR.cjs → types-Bx1EKe0v.js} +0 -0
- /package/dist/{attr-GcQKatub.js → types-CKPddlfS.cjs} +0 -0
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The advanced path: send, ping and read results as separate, single-RPC-call steps.
|
|
3
|
-
*
|
|
4
|
-
* The everyday actions (`createEntity`, `mutateEntities`, …) bundle send + wait + decode into one
|
|
5
|
-
* call, which is convenient and spends several RPC requests. These actions unbundle that so a
|
|
6
|
-
* caller can hit the theoretical minimum:
|
|
7
|
-
*
|
|
8
|
-
* 1. {@link buildMutation} — encode locally (0 RPC calls with `currentBlock` supplied)
|
|
9
|
-
* 2. {@link sendMutation} — submit and return the hash (1 call with full `txParams`)
|
|
10
|
-
* 3. {@link pingTransaction} — one `eth_getTransactionReceipt`, on your schedule
|
|
11
|
-
* 4. {@link getMutationResult} / {@link decodeMutationResult} — the same single call (or none)
|
|
12
|
-
* turned into entity keys and expiries
|
|
13
|
-
*/
|
|
14
|
-
export type { BuildMutationOptions, BuildMutationReturnType } from "./buildMutation"
|
|
15
|
-
export { buildMutation } from "./buildMutation"
|
|
16
|
-
export type { GetMutationResultReturnType, MutationResult } from "./getMutationResult"
|
|
17
|
-
export { decodeMutationResult, getMutationResult } from "./getMutationResult"
|
|
18
|
-
export type { PingTransactionReturnType } from "./pingTransaction"
|
|
19
|
-
export { pingTransaction } from "./pingTransaction"
|
|
20
|
-
export type { SendMutationOptions, SendMutationReturnType } from "./sendMutation"
|
|
21
|
-
export { sendMutation } from "./sendMutation"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Hash } from "viem"
|
|
2
|
-
import type { ArkivClient } from "../../clients/baseClient"
|
|
3
|
-
import { getLogger } from "../../utils/logger"
|
|
4
|
-
import { fetchReceipt } from "./getMutationResult"
|
|
5
|
-
|
|
6
|
-
const logger = getLogger("actions:advanced:ping-transaction")
|
|
7
|
-
|
|
8
|
-
/** Return type for {@link pingTransaction}. */
|
|
9
|
-
export type PingTransactionReturnType =
|
|
10
|
-
| {
|
|
11
|
-
/** Not mined yet (or unknown to this node). Ping again later. */
|
|
12
|
-
status: "pending"
|
|
13
|
-
blockNumber?: undefined
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
/** Mined. `success` means the whole batch applied; `reverted` means none of it did. */
|
|
17
|
-
status: "success" | "reverted"
|
|
18
|
-
/** The block the transaction landed in. */
|
|
19
|
-
blockNumber: bigint
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Asks the chain — once — whether a transaction has landed.
|
|
24
|
-
*
|
|
25
|
-
* Exactly one `eth_getTransactionReceipt`, never a poll: a transaction that is not mined yet comes
|
|
26
|
-
* back as `{ status: "pending" }` rather than being waited on. This is the "ping" of the advanced
|
|
27
|
-
* path — you own the schedule, the SDK owns nothing.
|
|
28
|
-
*
|
|
29
|
-
* When it reports `success` and you need the created keys or recorded expiries, spend the next
|
|
30
|
-
* call on `getMutationResult` — or none at all, if you predicted the keys up front with
|
|
31
|
-
* `predictEntityKeys`.
|
|
32
|
-
*/
|
|
33
|
-
export async function pingTransaction(
|
|
34
|
-
client: ArkivClient,
|
|
35
|
-
txHash: Hash,
|
|
36
|
-
): Promise<PingTransactionReturnType> {
|
|
37
|
-
const receipt = await fetchReceipt(client, txHash)
|
|
38
|
-
if (receipt === undefined) {
|
|
39
|
-
logger("Tx %s still pending", txHash)
|
|
40
|
-
return { status: "pending" }
|
|
41
|
-
}
|
|
42
|
-
return { status: receipt.status, blockNumber: receipt.blockNumber }
|
|
43
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { Hash } from "viem"
|
|
2
|
-
import type { ArkivClient } from "../../clients/baseClient"
|
|
3
|
-
import type { TxParams } from "../../types"
|
|
4
|
-
import { type EntityMutationOps, submitMutation } from "../../utils/arkivTransactions"
|
|
5
|
-
import { getLogger } from "../../utils/logger"
|
|
6
|
-
import {
|
|
7
|
-
type BuildMutationOptions,
|
|
8
|
-
type BuildMutationReturnType,
|
|
9
|
-
buildMutation,
|
|
10
|
-
} from "./buildMutation"
|
|
11
|
-
|
|
12
|
-
const logger = getLogger("actions:advanced:send-mutation")
|
|
13
|
-
|
|
14
|
-
/** Options for {@link sendMutation}. */
|
|
15
|
-
export type SendMutationOptions = BuildMutationOptions & {
|
|
16
|
-
/**
|
|
17
|
-
* Transaction parameters. Supply `nonce`, `gas` and the fee fields and viem has nothing left to
|
|
18
|
-
* look up — the send collapses to a single `eth_sendRawTransaction`.
|
|
19
|
-
*/
|
|
20
|
-
txParams?: TxParams
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Return type for {@link sendMutation}. */
|
|
24
|
-
export type SendMutationReturnType = {
|
|
25
|
-
/** The transaction hash. Poll it with `pingTransaction` / fetch it with `getMutationResult`. */
|
|
26
|
-
txHash: Hash
|
|
27
|
-
/** The per-kind operation counts of the batch that was sent, for cross-checking the result. */
|
|
28
|
-
expected: BuildMutationReturnType["expected"]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Signs and sends a mutation batch, returning as soon as the transaction is submitted.
|
|
33
|
-
*
|
|
34
|
-
* The fire-and-forget half of the advanced path. Unlike `mutateEntities`, this does **not** wait
|
|
35
|
-
* for a receipt, does not poll, and runs no revert diagnosis — it spends only what submitting
|
|
36
|
-
* costs. With `options.currentBlock` and full `txParams` (nonce, gas, fees) that is exactly one
|
|
37
|
-
* RPC call; each omitted piece adds only the lookup viem needs to fill it.
|
|
38
|
-
*
|
|
39
|
-
* Follow up separately, on your own schedule:
|
|
40
|
-
* - `pingTransaction(txHash)` — one `eth_getTransactionReceipt`, tells you pending/success/reverted.
|
|
41
|
-
* - `getMutationResult(txHash)` — the same single call, plus the decoded entity keys and expiries.
|
|
42
|
-
*
|
|
43
|
-
* @throws {EntityMutationError} If the node rejects the submission (the batch never made it into
|
|
44
|
-
* the mempool) — in engine terms when the rejection decodes, with the node's message otherwise.
|
|
45
|
-
* Anything after that — inclusion, success — is yours to check.
|
|
46
|
-
*/
|
|
47
|
-
export async function sendMutation(
|
|
48
|
-
client: ArkivClient,
|
|
49
|
-
data: EntityMutationOps,
|
|
50
|
-
options: SendMutationOptions = {},
|
|
51
|
-
): Promise<SendMutationReturnType> {
|
|
52
|
-
const { operations, expected } = await buildMutation(client, data, options)
|
|
53
|
-
|
|
54
|
-
logger("Sending execute with %d operations (no wait)", operations.length)
|
|
55
|
-
|
|
56
|
-
const txHash = await submitMutation(client, operations, options.txParams)
|
|
57
|
-
|
|
58
|
-
return { txHash, expected }
|
|
59
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import type { Account, Chain, Client, Hash, TransactionReceipt, Transport } from "viem"
|
|
2
|
-
import type {
|
|
3
|
-
BuildMutationOptions,
|
|
4
|
-
BuildMutationReturnType,
|
|
5
|
-
} from "../../actions/advanced/buildMutation"
|
|
6
|
-
import { buildMutation } from "../../actions/advanced/buildMutation"
|
|
7
|
-
import type {
|
|
8
|
-
GetMutationResultReturnType,
|
|
9
|
-
MutationResult,
|
|
10
|
-
} from "../../actions/advanced/getMutationResult"
|
|
11
|
-
import { decodeMutationResult, getMutationResult } from "../../actions/advanced/getMutationResult"
|
|
12
|
-
import type { PingTransactionReturnType } from "../../actions/advanced/pingTransaction"
|
|
13
|
-
import { pingTransaction } from "../../actions/advanced/pingTransaction"
|
|
14
|
-
import type {
|
|
15
|
-
SendMutationOptions,
|
|
16
|
-
SendMutationReturnType,
|
|
17
|
-
} from "../../actions/advanced/sendMutation"
|
|
18
|
-
import { sendMutation } from "../../actions/advanced/sendMutation"
|
|
19
|
-
import type { EntityMutationOps } from "../../utils/arkivTransactions"
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The read-only half of the advanced path — checking on a transaction and decoding its result —
|
|
23
|
-
* which needs no account, so a Public Client carries it too.
|
|
24
|
-
*
|
|
25
|
-
* Every action here costs at most one RPC call, and says exactly which.
|
|
26
|
-
*/
|
|
27
|
-
export type PublicAdvancedActions = {
|
|
28
|
-
/**
|
|
29
|
-
* Asks the chain — once — whether a transaction has landed. Exactly one
|
|
30
|
-
* `eth_getTransactionReceipt`, never a poll: an unmined transaction comes back as
|
|
31
|
-
* `{ status: "pending" }` and the schedule stays yours.
|
|
32
|
-
*
|
|
33
|
-
* @param txHash - The transaction hash returned by `sendMutation` (or any other send)
|
|
34
|
-
* @returns `{ status: "pending" }`, or `{ status: "success" | "reverted", blockNumber }`
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const { status } = await client.advanced.pingTransaction(txHash)
|
|
38
|
-
* if (status === "pending") scheduleAnotherPing()
|
|
39
|
-
*/
|
|
40
|
-
pingTransaction: (txHash: Hash) => Promise<PingTransactionReturnType>
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Fetches a transaction's receipt — once — and decodes what the mutation did: created keys and
|
|
44
|
-
* expiries, plus the keys of everything patched, deleted, extended or handed over. One
|
|
45
|
-
* `eth_getTransactionReceipt`; `{ status: "pending" }` if not mined yet. No revert diagnosis is
|
|
46
|
-
* run on a `reverted` result — that extra call is yours to spend or skip.
|
|
47
|
-
*
|
|
48
|
-
* @param txHash - The transaction hash
|
|
49
|
-
* @returns The decoded {@link MutationResult}, or `{ status: "pending" }`
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* const result = await client.advanced.getMutationResult(txHash)
|
|
53
|
-
* if (result.status === "success") console.log(result.createdEntities)
|
|
54
|
-
*/
|
|
55
|
-
getMutationResult: (txHash: Hash) => Promise<GetMutationResultReturnType>
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Decodes a receipt you already hold into a {@link MutationResult}. **Zero RPC calls** — for
|
|
59
|
-
* receipts that reached you through your own `waitForTransactionReceipt`, a block watcher, or a
|
|
60
|
-
* webhook.
|
|
61
|
-
*
|
|
62
|
-
* @param receipt - The transaction receipt
|
|
63
|
-
* @returns The decoded {@link MutationResult}
|
|
64
|
-
*/
|
|
65
|
-
decodeMutationResult: (receipt: TransactionReceipt) => MutationResult
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The advanced path on a Wallet Client: build, send, ping and read results as separate steps, each
|
|
70
|
-
* costing the minimum number of RPC calls — down to one per transaction when you supply what the
|
|
71
|
-
* SDK would otherwise look up.
|
|
72
|
-
*
|
|
73
|
-
* The everyday actions (`createEntity`, `mutateEntities`, …) bundle send + wait + decode and are
|
|
74
|
-
* the right default. This namespace unbundles them for callers optimising their RPC budget.
|
|
75
|
-
*
|
|
76
|
-
* @example Minimal-call flow: one send, one ping, done.
|
|
77
|
-
* const { txHash } = await client.advanced.sendMutation(
|
|
78
|
-
* { creates: [{ payload, contentType: "application/json", expires }] },
|
|
79
|
-
* { currentBlock, txParams: { nonce, gas: 1_000_000n, maxFeePerGas, maxPriorityFeePerGas } },
|
|
80
|
-
* ) // exactly 1 RPC call: eth_sendRawTransaction
|
|
81
|
-
* // ... later, on your own schedule:
|
|
82
|
-
* const result = await client.advanced.getMutationResult(txHash) // 1 RPC call
|
|
83
|
-
* if (result.status === "success") console.log(result.createdEntities)
|
|
84
|
-
*/
|
|
85
|
-
export type WalletAdvancedActions = PublicAdvancedActions & {
|
|
86
|
-
/**
|
|
87
|
-
* Encodes a mutation batch without sending anything: zero RPC calls with `currentBlock` supplied
|
|
88
|
-
* (or when no expiry is relative), at most one `eth_blockNumber` otherwise. Returns the
|
|
89
|
-
* operations for `writeContract`, and the `{ to, data }` calldata for offline signing.
|
|
90
|
-
*
|
|
91
|
-
* @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
|
|
92
|
-
* @param options - Optional `currentBlock` to avoid the `eth_blockNumber` lookup
|
|
93
|
-
*/
|
|
94
|
-
buildMutation: (
|
|
95
|
-
data: EntityMutationOps,
|
|
96
|
-
options?: BuildMutationOptions,
|
|
97
|
-
) => Promise<BuildMutationReturnType>
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Signs and sends a mutation batch, returning the hash as soon as the transaction is submitted —
|
|
101
|
-
* no waiting, no polling, no revert diagnosis. With `currentBlock` and full `txParams` (nonce,
|
|
102
|
-
* gas, fees) supplied this is exactly one `eth_sendRawTransaction`; each omitted piece adds only
|
|
103
|
-
* the lookup viem needs to fill it.
|
|
104
|
-
*
|
|
105
|
-
* @param data - The batch (creates, patches, deletes, extensions, ownershipChanges)
|
|
106
|
-
* @param options - Optional `currentBlock` and `txParams`
|
|
107
|
-
* @returns The transaction hash and the batch's per-kind operation counts
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* const { txHash } = await client.advanced.sendMutation({
|
|
111
|
-
* creates: [{ payload, contentType: "application/json", expires: ExpirationTime.atBlock(1_200_000n) }],
|
|
112
|
-
* })
|
|
113
|
-
*/
|
|
114
|
-
sendMutation: (
|
|
115
|
-
data: EntityMutationOps,
|
|
116
|
-
options?: SendMutationOptions,
|
|
117
|
-
) => Promise<SendMutationReturnType>
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function publicAdvancedActions<
|
|
121
|
-
transport extends Transport = Transport,
|
|
122
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
123
|
-
account extends Account | undefined = Account | undefined,
|
|
124
|
-
>(client: Client<transport, chain, account>): PublicAdvancedActions {
|
|
125
|
-
return {
|
|
126
|
-
pingTransaction: (txHash: Hash) => pingTransaction(client, txHash),
|
|
127
|
-
getMutationResult: (txHash: Hash) => getMutationResult(client, txHash),
|
|
128
|
-
decodeMutationResult: (receipt: TransactionReceipt) => decodeMutationResult(receipt),
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export function walletAdvancedActions<
|
|
133
|
-
transport extends Transport = Transport,
|
|
134
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
135
|
-
account extends Account | undefined = Account | undefined,
|
|
136
|
-
>(client: Client<transport, chain, account>): WalletAdvancedActions {
|
|
137
|
-
return {
|
|
138
|
-
...publicAdvancedActions(client),
|
|
139
|
-
buildMutation: (data: EntityMutationOps, options?: BuildMutationOptions) =>
|
|
140
|
-
buildMutation(client, data, options),
|
|
141
|
-
sendMutation: (data: EntityMutationOps, options?: SendMutationOptions) =>
|
|
142
|
-
sendMutation(client, data, options),
|
|
143
|
-
}
|
|
144
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|