Call status
The two methods that follow a batch sent with
Wallet.sendCalls (EIP-5792): one returns where the batch
stands, the other has the wallet show it to the user.
| Method | JSON-RPC | Returns | Description |
|---|---|---|---|
getCallsStatus |
wallet_getCallsStatus |
CallsStatus |
Where a batch stands, with its receipts once included. |
showCallsStatus |
wallet_showCallsStatus |
void |
Has the wallet show the user where a batch stands. |
Both take the id of the batch, the string that Wallet.sendCalls returned, and each
returns an Effect<…, Method.Error, Transport>.
getCallsStatus
Section titled “getCallsStatus”Returns where a batch stands, with its receipts once it is included.
import { Effect } from "effect";import { Wallet } from "@ethect/core/rpc";
const outcome = (id: string) => Wallet.getCallsStatus(id).pipe( Effect.map(({ status, receipts }) => { if (status < 200) return "pending"; if (status < 300) return `confirmed in ${receipts.length} transaction(s)`; return "failed"; }), );- JSON-RPC:
wallet_getCallsStatus - Parameters:
id(string). - Returns: a
CallsStatus.CallsStatus: thestatuscode, whether the batch ranatomic, and itsreceipts. - An id the wallet does not know fails with the reason
UnknownBundleId(code 5730). - An answer without a
status, or with a receipt that has no 32-bytetransactionHash, fails with aCodecErrorwhosevalueis the answer.
The status is a number. EIP-5792 defines these codes:
| Code | Meaning |
|---|---|
100 |
pending: the wallet received the batch, and it has not completed on chain |
200 |
confirmed: the batch was included without reverts |
400 |
failed off chain: the batch was not included, and the wallet will not retry |
500 |
reverted: the batch reverted completely |
600 |
partly reverted: some of the batch’s changes may be on chain |
A wallet that answers in the words of EIP-5792 v1 is read too: "PENDING" is 100 and
"CONFIRMED" is 200.
To wait for the outcome, repeat the call until the batch is no longer pending.
import { Effect, Schedule } from "effect";import { Wallet } from "@ethect/core/rpc";
const settled = (id: string) => Wallet.getCallsStatus(id).pipe( Effect.repeat({ until: ({ status }) => status >= 200, schedule: Schedule.spaced("1 second"), }), );showCallsStatus
Section titled “showCallsStatus”Has the wallet show the user where a batch stands.
import { Effect } from "effect";import { Wallet } from "@ethect/core/rpc";
const show = (id: string) => Wallet.showCallsStatus(id).pipe( Effect.catchReason("RpcError", "UnknownBundleId", () => Effect.void), );- JSON-RPC:
wallet_showCallsStatus - Parameters:
id(string). - Returns: nothing. Whatever the wallet answers is ignored, and the effect succeeds with
void. - By the EIP, an id the wallet does not know is an error here too.
Behavior
Section titled “Behavior”- Codes come in hundreds. A wallet may answer a more specific code, and it stays in the
hundred of its kind: test
status >= 200 && status < 300, notstatus === 200. - No receipts is an empty list.
receiptsis[]when the wallet leaves it out. Once there, the receipts are in the order the transactions were included. - Off-spec answers are read when they are unambiguous. An
idthat is not a string, a missingchainId, block numbers as JSON numbers, keys set toundefined: seeCallsStatusfor each. - A receipt is a subset. It has
logs,status,blockHash,blockNumber,gasUsedandtransactionHash, and its logs are only those of the batch’s own calls. - Statuses are names. The
statusof a receipt decodes from"0x1"and"0x0"to"success"and"reverted". Thestatusof the batch stays a number. - Atomic batches may share a receipt. When
atomicistrue, all the calls may be in one receipt.