@t3foundry/tasra-sdk 0.3.1 → 0.4.0

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.
Files changed (255) hide show
  1. package/CHANGELOG.md +1067 -28
  2. package/README.md +15 -0
  3. package/dist/app/approvals.d.ts +66 -4
  4. package/dist/app/approvals.js +153 -16
  5. package/dist/app/authorization.d.ts +1 -1
  6. package/dist/app/authorization.js +1 -1
  7. package/dist/app/browser.d.ts +63 -0
  8. package/dist/app/browser.js +242 -0
  9. package/dist/app/client.d.ts +114 -13
  10. package/dist/app/client.js +302 -76
  11. package/dist/app/identity.js +21 -9
  12. package/dist/app/index.d.ts +28 -3
  13. package/dist/app/index.js +16 -1
  14. package/dist/app/memory-store.d.ts +7 -0
  15. package/dist/app/memory-store.js +55 -0
  16. package/dist/app/node.d.ts +34 -6
  17. package/dist/app/node.js +387 -64
  18. package/dist/app/paid-allowance.d.ts +325 -0
  19. package/dist/app/paid-allowance.js +1290 -0
  20. package/dist/app/paid-approval.d.ts +122 -0
  21. package/dist/app/paid-approval.js +379 -0
  22. package/dist/app/paid-journal.d.ts +51 -0
  23. package/dist/app/paid-journal.js +117 -0
  24. package/dist/app/paid-keys.d.ts +12 -0
  25. package/dist/app/paid-keys.js +20 -0
  26. package/dist/app/paid-operation.d.ts +821 -0
  27. package/dist/app/paid-operation.js +1720 -0
  28. package/dist/app/paid-reservation.d.ts +157 -0
  29. package/dist/app/paid-reservation.js +323 -0
  30. package/dist/app/paid-session.d.ts +147 -0
  31. package/dist/app/paid-session.js +578 -0
  32. package/dist/app/payer-queue.d.ts +11 -0
  33. package/dist/app/payer-queue.js +27 -0
  34. package/dist/app/policy-bootstrap.d.ts +342 -0
  35. package/dist/app/policy-bootstrap.js +365 -0
  36. package/dist/app/policy-operation.d.ts +47 -0
  37. package/dist/app/policy-operation.js +101 -0
  38. package/dist/app/ready-slot.d.ts +12 -0
  39. package/dist/app/ready-slot.js +5 -2
  40. package/dist/app/rotation-lock.d.ts +38 -0
  41. package/dist/app/rotation-lock.js +42 -0
  42. package/dist/app/session-decrypt.d.ts +135 -0
  43. package/dist/app/session-decrypt.js +335 -0
  44. package/dist/app/session-grants.d.ts +349 -0
  45. package/dist/app/session-grants.js +811 -0
  46. package/dist/app/signing-intents.d.ts +78 -0
  47. package/dist/app/signing-intents.js +95 -0
  48. package/dist/app/store-commit.d.ts +63 -0
  49. package/dist/app/store-commit.js +126 -0
  50. package/dist/app/store-errors.d.ts +8 -0
  51. package/dist/app/store-errors.js +11 -0
  52. package/dist/app/tasra-client.d.ts +2 -0
  53. package/dist/app/tasra-client.js +1 -1
  54. package/dist/app/wallet.js +4 -1
  55. package/dist/auth/holderProof.d.ts +3 -0
  56. package/dist/auth/holderProof.js +8 -7
  57. package/dist/auth/verifier.d.ts +4 -2
  58. package/dist/auth/verifier.js +5 -2
  59. package/dist/chain/abis/index.d.ts +6178 -4101
  60. package/dist/chain/abis/index.js +3 -0
  61. package/dist/chain/abis/keyRegistry.d.ts +256 -0
  62. package/dist/chain/abis/keyRegistry.js +333 -0
  63. package/dist/chain/abis/prepaidFaultOracle.d.ts +321 -0
  64. package/dist/chain/abis/prepaidFaultOracle.js +413 -0
  65. package/dist/chain/abis/settlement.d.ts +2203 -703
  66. package/dist/chain/abis/settlement.js +2685 -764
  67. package/dist/chain/allowance.d.ts +358 -0
  68. package/dist/chain/allowance.js +800 -0
  69. package/dist/chain/billing.d.ts +85 -0
  70. package/dist/chain/billing.js +197 -0
  71. package/dist/chain/chainId.d.ts +13 -0
  72. package/dist/chain/chainId.js +26 -0
  73. package/dist/chain/client.d.ts +15 -1
  74. package/dist/chain/client.js +57 -1
  75. package/dist/chain/commitmentRecovery.d.ts +51 -0
  76. package/dist/chain/commitmentRecovery.js +38 -0
  77. package/dist/chain/committeeClient.d.ts +17 -10
  78. package/dist/chain/committeeClient.js +64 -16
  79. package/dist/chain/committeeDraw.d.ts +12 -0
  80. package/dist/chain/committeeDraw.js +56 -0
  81. package/dist/chain/custodyHealth.d.ts +212 -0
  82. package/dist/chain/custodyHealth.js +365 -0
  83. package/dist/chain/deployments.js +2 -0
  84. package/dist/chain/events.js +2 -0
  85. package/dist/chain/headFollower.d.ts +77 -0
  86. package/dist/chain/headFollower.js +219 -0
  87. package/dist/chain/headPrefetch.d.ts +23 -0
  88. package/dist/chain/headPrefetch.js +67 -0
  89. package/dist/chain/index.d.ts +50 -8
  90. package/dist/chain/index.js +28 -3
  91. package/dist/chain/keeperExecution.d.ts +44 -0
  92. package/dist/chain/keeperExecution.js +127 -0
  93. package/dist/chain/keeperRecovery.d.ts +78 -0
  94. package/dist/chain/keeperRecovery.js +91 -0
  95. package/dist/chain/node.d.ts +24 -1
  96. package/dist/chain/node.js +88 -43
  97. package/dist/chain/offchain.d.ts +2 -0
  98. package/dist/chain/paidAgentTransport.d.ts +38 -0
  99. package/dist/chain/paidAgentTransport.js +1 -0
  100. package/dist/chain/paidEpoch.d.ts +66 -0
  101. package/dist/chain/paidEpoch.js +139 -0
  102. package/dist/chain/paidPacing.d.ts +81 -0
  103. package/dist/chain/paidPacing.js +136 -0
  104. package/dist/chain/pinnedReads.d.ts +49 -0
  105. package/dist/chain/pinnedReads.js +218 -0
  106. package/dist/chain/prepaid.d.ts +383 -0
  107. package/dist/chain/prepaid.js +1046 -0
  108. package/dist/chain/prepaidEscape.d.ts +274 -0
  109. package/dist/chain/prepaidEscape.js +432 -0
  110. package/dist/chain/prepaidFault.d.ts +94 -0
  111. package/dist/chain/prepaidFault.js +148 -0
  112. package/dist/chain/receipt.d.ts +24 -0
  113. package/dist/chain/receipt.js +82 -0
  114. package/dist/chain/registeredAgent.d.ts +68 -3
  115. package/dist/chain/registeredAgent.js +143 -42
  116. package/dist/chain/registeredOperation.d.ts +10 -1
  117. package/dist/chain/registeredOperation.js +18 -3
  118. package/dist/chain/registeredPaidAgent.d.ts +254 -0
  119. package/dist/chain/registeredPaidAgent.js +889 -0
  120. package/dist/chain/registeredRelay.d.ts +31 -1
  121. package/dist/chain/registeredRelay.js +164 -43
  122. package/dist/chain/relayVoucher.d.ts +64 -0
  123. package/dist/chain/relayVoucher.js +69 -0
  124. package/dist/chain/reservation.d.ts +239 -0
  125. package/dist/chain/reservation.js +746 -0
  126. package/dist/chain/reshareRoster.d.ts +64 -0
  127. package/dist/chain/reshareRoster.js +85 -0
  128. package/dist/chain/revertReason.d.ts +8 -0
  129. package/dist/chain/revertReason.js +2 -1
  130. package/dist/chain/rotationLock.d.ts +130 -0
  131. package/dist/chain/rotationLock.js +168 -0
  132. package/dist/chain/serviceRequestPolicy.d.ts +47 -0
  133. package/dist/chain/serviceRequestPolicy.js +86 -0
  134. package/dist/chain/services.d.ts +7 -0
  135. package/dist/chain/services.js +44 -4
  136. package/dist/chain/slotClient.js +11 -2
  137. package/dist/chain/slotHandoff.d.ts +81 -0
  138. package/dist/chain/slotHandoff.js +166 -0
  139. package/dist/chain/slotSeed.d.ts +47 -5
  140. package/dist/chain/slotSeed.js +173 -42
  141. package/dist/chain/verifierSnapshot.d.ts +36 -0
  142. package/dist/chain/verifierSnapshot.js +197 -0
  143. package/dist/chain/write.d.ts +111 -21
  144. package/dist/chain/write.js +378 -146
  145. package/dist/committee/blsSharing.d.ts +53 -0
  146. package/dist/committee/blsSharing.js +90 -0
  147. package/dist/committee/client.d.ts +62 -23
  148. package/dist/committee/client.js +288 -72
  149. package/dist/committee/dual-operation.d.ts +165 -0
  150. package/dist/committee/dual-operation.js +229 -0
  151. package/dist/committee/dual-sign.d.ts +26 -1
  152. package/dist/committee/dual-sign.js +85 -7
  153. package/dist/committee/ecdsa.d.ts +38 -0
  154. package/dist/committee/ecdsa.js +87 -15
  155. package/dist/committee/evidence.d.ts +30 -0
  156. package/dist/committee/evidence.js +65 -0
  157. package/dist/committee/execution.d.ts +414 -0
  158. package/dist/committee/execution.js +446 -0
  159. package/dist/committee/extraction.js +33 -26
  160. package/dist/committee/index.d.ts +30 -7
  161. package/dist/committee/index.js +18 -6
  162. package/dist/committee/keeperExecution.d.ts +37 -0
  163. package/dist/committee/keeperExecution.js +141 -0
  164. package/dist/committee/oauth.d.ts +14 -4
  165. package/dist/committee/oauth.js +17 -5
  166. package/dist/committee/payment.d.ts +369 -0
  167. package/dist/committee/payment.js +339 -0
  168. package/dist/committee/recovery.d.ts +136 -0
  169. package/dist/committee/recovery.js +204 -0
  170. package/dist/committee/recoveryJson.d.ts +2 -0
  171. package/dist/committee/recoveryJson.js +87 -0
  172. package/dist/committee/request.d.ts +63 -27
  173. package/dist/committee/request.js +77 -66
  174. package/dist/committee/session-grant.d.ts +320 -0
  175. package/dist/committee/session-grant.js +397 -0
  176. package/dist/committee/status-refresh.d.ts +257 -0
  177. package/dist/committee/status-refresh.js +619 -0
  178. package/dist/committee/token.d.ts +163 -15
  179. package/dist/committee/token.js +247 -10
  180. package/dist/crypto/bn254.d.ts +70 -0
  181. package/dist/crypto/bn254.js +222 -0
  182. package/dist/crypto/ibe.d.ts +32 -0
  183. package/dist/crypto/ibe.js +56 -8
  184. package/dist/crypto/index.d.ts +1 -1
  185. package/dist/crypto/index.js +1 -1
  186. package/dist/crypto/kem.d.ts +31 -0
  187. package/dist/crypto/kem.js +113 -7
  188. package/dist/crypto/recipient.d.ts +75 -0
  189. package/dist/crypto/recipient.js +107 -0
  190. package/dist/decryption/client.d.ts +10 -16
  191. package/dist/decryption/client.js +8 -76
  192. package/dist/decryption/index.d.ts +2 -0
  193. package/dist/decryption/index.js +2 -0
  194. package/dist/decryption/sealed.d.ts +72 -0
  195. package/dist/decryption/sealed.js +147 -0
  196. package/dist/decryption/session.d.ts +115 -0
  197. package/dist/decryption/session.js +358 -0
  198. package/dist/errors.d.ts +406 -1
  199. package/dist/errors.js +400 -5
  200. package/dist/index.d.ts +9 -2
  201. package/dist/index.js +6 -1
  202. package/dist/internal/bounded.d.ts +66 -0
  203. package/dist/internal/bounded.js +126 -0
  204. package/dist/internal/network.d.ts +4 -0
  205. package/dist/internal/network.js +40 -0
  206. package/dist/internal/retryAfter.d.ts +8 -0
  207. package/dist/internal/retryAfter.js +28 -0
  208. package/dist/internal/sleep.d.ts +6 -0
  209. package/dist/internal/sleep.js +15 -0
  210. package/dist/internal/typedData.d.ts +13 -0
  211. package/dist/internal/typedData.js +77 -0
  212. package/dist/internal/viemErrors.d.ts +26 -0
  213. package/dist/internal/viemErrors.js +49 -0
  214. package/dist/oid4vp/binding.d.ts +27 -1
  215. package/dist/oid4vp/binding.js +36 -1
  216. package/dist/oid4vp/jose.d.ts +4 -2
  217. package/dist/oid4vp/jose.js +39 -7
  218. package/dist/oid4vp/request-object.d.ts +61 -4
  219. package/dist/oid4vp/request-object.js +140 -5
  220. package/dist/oid4vp/verifier-agent.d.ts +18 -8
  221. package/dist/oid4vp/verifier-agent.js +48 -6
  222. package/dist/oid4vp/wallet.d.ts +2 -4
  223. package/dist/oid4vp/wallet.js +1 -0
  224. package/dist/retry.d.ts +78 -0
  225. package/dist/retry.js +137 -0
  226. package/dist/signing/frost.d.ts +1 -1
  227. package/dist/verifier-agent/index.d.ts +41 -5
  228. package/dist/verifier-agent/index.js +124 -9
  229. package/dist/verifier-agent/payment.d.ts +7 -0
  230. package/dist/verifier-agent/payment.js +17 -0
  231. package/docs/api.md +8 -2
  232. package/docs/application-api.md +25 -2
  233. package/docs/chain.md +155 -9
  234. package/docs/consumer-migrations.md +61 -0
  235. package/docs/encrypted-notes.md +3 -2
  236. package/docs/encryption.md +4 -2
  237. package/docs/errors.md +14 -1
  238. package/docs/flows.md +2 -2
  239. package/docs/funding.md +902 -0
  240. package/docs/native-approvals.md +63 -0
  241. package/docs/reference/README.md +9 -8
  242. package/docs/reference/app-browser.md +232 -0
  243. package/docs/reference/app-node.md +38 -8
  244. package/docs/reference/app.md +4621 -805
  245. package/docs/reference/chain-node.md +74 -16
  246. package/docs/reference/chain.md +6740 -1592
  247. package/docs/reference/committee.md +5630 -987
  248. package/docs/reference/main.md +1439 -140
  249. package/docs/reference/oid4vp.md +297 -144
  250. package/docs/reference/verifier-agent.md +77 -35
  251. package/docs/signing.md +6 -0
  252. package/examples/encrypted-notes.ts +21 -6
  253. package/examples/getting-started.ts +2 -7
  254. package/examples/live-config.ts +24 -17
  255. package/package.json +17 -5
@@ -0,0 +1,432 @@
1
+ // Payer-side client for the Settlement prepaid timeout escape.
2
+ //
3
+ // A prepaid reservation is normally completed by the accountant set's signed reconcile (or full
4
+ // payout). If nobody reconciles it within the governed escape delay, anyone may call
5
+ // `Settlement.escapePrepaid(slotId, requestIds)`: the full reserved cost of each named request
6
+ // returns to the SAME slot's balance, nothing is paid to any operator, and the request gets the
7
+ // permanent settled mark that reconcile also writes, so whichever is mined first is final.
8
+ //
9
+ // This module reads when each request becomes escapable, refuses locally unless every named
10
+ // request is open, chunks to the contract's 64-request bound, simulates each call, journals it
11
+ // before its single broadcast (never a blind resend), and confirms it from the emitted events.
12
+ // `reconcileEscape` settles an uncertain broadcast by reading chain state. The governance setter
13
+ // for the delay is deliberately not part of this client.
14
+ import { decodeErrorResult, decodeEventLog, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, keccak256, parseTransaction, recoverTransactionAddress, toHex } from 'viem';
15
+ import { settlementAbi } from './abis/settlement.js';
16
+ import { PrepaidEscapeError, PrepaidEscapeUncertainError, TasraError } from '../errors.js';
17
+ import { revertData, revertError } from './revertReason.js';
18
+ import { untilAborted } from './reservation.js';
19
+ import { chainIdOf } from './chainId.js';
20
+ import { pollTransactionReceipt } from './receipt.js';
21
+ import { isViemError } from '../internal/viemErrors.js';
22
+ /** Most requests one `escapePrepaid` transaction may name (the contract's `MAX_ESCAPE_PER_CALL`). */
23
+ export const MAX_ESCAPE_PER_CALL = 64;
24
+ /** Most requests one client call accepts; they are sent as sequential transactions of at most 64. */
25
+ export const MAX_ESCAPE_REQUESTS = 1024;
26
+ const HEX32 = /^0x[0-9a-f]{64}$/i;
27
+ const ADDRESS = /^0x[0-9a-f]{40}$/i;
28
+ const ZERO32 = /^0x0{64}$/i;
29
+ const ZERO_ADDRESS = /^0x0{40}$/i;
30
+ const MAX_AGE = 30n;
31
+ const FUTURE_SKEW = 2n;
32
+ const MAX_DATE_SECONDS = 8640000000000n;
33
+ const READ_FANOUT = 8;
34
+ const JOURNAL_LABEL = keccak256(toHex('tasra-sdk/prepaid-escape-journal'));
35
+ const PRE_ESCAPE_VERSIONS = new Set(['1', '2']);
36
+ const nowSecs = () => BigInt(Math.floor(Date.now() / 1000));
37
+ const same = (a, b) => a.toLowerCase() === b.toLowerCase();
38
+ function date(seconds) {
39
+ if (seconds <= 0n || seconds > MAX_DATE_SECONDS)
40
+ throw new TasraError('prepaid escape time is outside the date range');
41
+ return new Date(Number(seconds) * 1000);
42
+ }
43
+ function validateDeployment(d) {
44
+ if (!Number.isSafeInteger(d.chainId) || d.chainId <= 0 || typeof d.settlement !== 'string'
45
+ || !ADDRESS.test(d.settlement) || ZERO_ADDRESS.test(d.settlement))
46
+ throw new TasraError('Invalid prepaid escape deployment');
47
+ }
48
+ function requestList(slotId, requestIds) {
49
+ if (typeof slotId !== 'string' || !HEX32.test(slotId) || ZERO32.test(slotId))
50
+ throw new TasraError('Invalid prepaid escape slot');
51
+ if (!Array.isArray(requestIds) || requestIds.length > MAX_ESCAPE_REQUESTS)
52
+ throw new TasraError(`Supply at most ${MAX_ESCAPE_REQUESTS} prepaid request IDs`);
53
+ if (requestIds.length === 0)
54
+ throw new PrepaidEscapeError({ code: 'empty_request', local: true });
55
+ const ids = requestIds.map(id => {
56
+ if (typeof id !== 'string' || !HEX32.test(id) || ZERO32.test(id))
57
+ throw new TasraError('Invalid prepaid request ID');
58
+ return id.toLowerCase();
59
+ });
60
+ if (new Set(ids).size !== ids.length)
61
+ throw new TasraError('Duplicate prepaid request ID');
62
+ return { slot: slotId.toLowerCase(), ids };
63
+ }
64
+ /**
65
+ * Local journal key of one escape call: keccak256 of a fixed label, chain ID, Settlement, slot and
66
+ * the exact ordered request list. Not a wire or on-chain format.
67
+ * @param deployment Approved chain and Settlement.
68
+ * @param slotId Slot identifier.
69
+ * @param requestIds Exact ordered requests of the call.
70
+ */
71
+ export function prepaidEscapeId(deployment, slotId, requestIds) {
72
+ return keccak256(encodeAbiParameters([{ type: 'bytes32' }, { type: 'uint256' }, { type: 'address' }, { type: 'bytes32' }, { type: 'bytes32[]' }], [JOURNAL_LABEL, BigInt(deployment.chainId), deployment.settlement, slotId, [...requestIds]]));
73
+ }
74
+ function fresh(at) {
75
+ const t = nowSecs();
76
+ if (t - at.blockTimestamp > MAX_AGE || at.blockTimestamp - t > FUTURE_SKEW)
77
+ throw new TasraError('prepaid escape observation is stale or future-dated');
78
+ }
79
+ async function observeHead(client, d, depth = 0n) {
80
+ if (await chainIdOf(client) !== d.chainId)
81
+ throw new TasraError('prepaid escape RPC chain mismatch');
82
+ const head = await client.getBlock({ blockTag: 'latest' });
83
+ if (head.number === null || head.hash === null || !HEX32.test(head.hash) || head.timestamp < 0n)
84
+ throw new TasraError('prepaid escape canonical head unavailable');
85
+ fresh({ blockNumber: head.number, blockHash: head.hash, blockTimestamp: head.timestamp });
86
+ if (depth === 0n)
87
+ return { blockNumber: head.number, blockHash: head.hash, blockTimestamp: head.timestamp };
88
+ if (head.number < depth)
89
+ throw new TasraError('prepaid escape chain is shorter than the confirmation depth');
90
+ const block = await client.getBlock({ blockNumber: head.number - depth });
91
+ if (block.number === null || block.hash === null || !HEX32.test(block.hash))
92
+ throw new TasraError('prepaid escape observation block unavailable');
93
+ return { blockNumber: block.number, blockHash: block.hash, blockTimestamp: block.timestamp };
94
+ }
95
+ async function readAt(client, settlement, at, functionName, args = []) {
96
+ const abi = settlementAbi;
97
+ const data = encodeFunctionData({ abi, functionName, args });
98
+ const result = await client.call({ to: settlement, data, blockHash: at.blockHash, requireCanonical: true, batch: false });
99
+ if (result.data === undefined || result.data === '0x')
100
+ throw new TasraError(`empty Settlement ${functionName} response`);
101
+ return decodeFunctionResult({ abi, functionName, data: result.data });
102
+ }
103
+ async function recheck(client, at) {
104
+ const canonical = await client.getBlock({ blockNumber: at.blockNumber });
105
+ if (canonical.hash === null || !same(canonical.hash, at.blockHash))
106
+ throw new TasraError('prepaid escape observation reorganized during reads');
107
+ }
108
+ /** A Settlement that positively reads a version before the escape has no escape getters. */
109
+ async function escapeDelayAt(client, d, at) {
110
+ let delay;
111
+ try {
112
+ delay = await readAt(client, d.settlement, at, 'prepaidEscapeDelay');
113
+ }
114
+ catch (cause) {
115
+ const version = await readAt(client, d.settlement, at, 'version').catch(() => undefined);
116
+ if (typeof version === 'string' && PRE_ESCAPE_VERSIONS.has(version)) {
117
+ throw new PrepaidEscapeError({ code: 'escape_unsupported', local: true, cause,
118
+ message: `Settlement version ${version} has no prepaid timeout escape; nothing was sent` });
119
+ }
120
+ throw cause;
121
+ }
122
+ if (typeof delay !== 'bigint' || delay < 0n)
123
+ throw new TasraError('invalid prepaidEscapeDelay response');
124
+ return delay;
125
+ }
126
+ async function observe(client, d, slot, ids) {
127
+ const at = await observeHead(client, d);
128
+ const delay = await escapeDelayAt(client, d, at);
129
+ const requests = [];
130
+ // Bounded RPC fan-out; an unreadable request fails the whole observation.
131
+ for (let offset = 0; offset < ids.length; offset += READ_FANOUT) {
132
+ requests.push(...await Promise.all(ids.slice(offset, offset + READ_FANOUT).map(async (requestId) => {
133
+ const [opens, cost, settled, escapedAt] = await Promise.all(['prepaidEscapableAt', 'prepaidCost', 'prepaidSettled', 'prepaidEscapedAt']
134
+ .map(name => readAt(client, d.settlement, at, name, [slot, requestId])));
135
+ if (typeof opens !== 'bigint' || typeof cost !== 'bigint' || typeof settled !== 'boolean' || typeof escapedAt !== 'bigint')
136
+ throw new TasraError('invalid prepaid escape response');
137
+ return classify(requestId, delay, opens, cost, settled, escapedAt, at.blockTimestamp);
138
+ })));
139
+ }
140
+ await recheck(client, at);
141
+ fresh(at);
142
+ return { ...at, escapeDelaySeconds: delay, slotId: slot, requests };
143
+ }
144
+ function classify(requestId, delay, opens, cost, settled, escapedAt, timestamp) {
145
+ const inconsistent = () => new TasraError(`inconsistent prepaid escape state for request ${requestId}`);
146
+ if (cost === 0n) {
147
+ if (settled || escapedAt !== 0n || opens !== 0n)
148
+ throw inconsistent();
149
+ return { requestId, status: 'notReserved' };
150
+ }
151
+ if (settled) {
152
+ if (opens !== 0n)
153
+ throw inconsistent();
154
+ return escapedAt === 0n ? { requestId, status: 'settled' } : { requestId, status: 'settled', escapedAt: date(escapedAt) };
155
+ }
156
+ if (escapedAt !== 0n)
157
+ throw inconsistent();
158
+ if (delay === 0n) {
159
+ if (opens !== 0n)
160
+ throw inconsistent();
161
+ return { requestId, status: 'disabled' };
162
+ }
163
+ if (opens === 0n)
164
+ throw inconsistent();
165
+ // The contract reverts while block.timestamp < opensAt.
166
+ return { requestId, status: timestamp >= opens ? 'open' : 'notOpen', opensAt: date(opens) };
167
+ }
168
+ /** The contract's own first refusal for these states, in its order: disabled first, then per request. */
169
+ function refuseUnlessOpen(observed) {
170
+ if (observed.escapeDelaySeconds === 0n)
171
+ throw new PrepaidEscapeError({ code: 'escape_disabled', local: true });
172
+ for (const state of observed.requests) {
173
+ if (state.status === 'open')
174
+ continue;
175
+ if (state.status === 'notOpen')
176
+ throw new PrepaidEscapeError({ code: 'escape_not_open', local: true, requestId: state.requestId, opensAt: state.opensAt });
177
+ throw new PrepaidEscapeError({ code: 'reservation_unavailable', local: true, requestId: state.requestId,
178
+ message: state.status === 'settled'
179
+ ? `prepaid request ${state.requestId} is already complete${state.escapedAt ? ' (escaped)' : ''}; nothing was sent`
180
+ : `prepaid request ${state.requestId} is not reserved; nothing was sent` });
181
+ }
182
+ }
183
+ /**
184
+ * Map a Settlement escape revert anywhere in an error's cause chain to a typed
185
+ * {@link PrepaidEscapeError} (`local: false`); `undefined` for any other failure.
186
+ * @param error RPC or viem error from a simulation, gas estimate or relayed call.
187
+ */
188
+ export function decodePrepaidEscapeRevert(error) {
189
+ const data = revertData(error);
190
+ if (!data)
191
+ return undefined;
192
+ let decoded;
193
+ try {
194
+ decoded = decodeErrorResult({ abi: settlementAbi, data });
195
+ }
196
+ catch {
197
+ return undefined;
198
+ }
199
+ const args = decoded.args ?? [];
200
+ switch (decoded.errorName) {
201
+ case 'EscapeDisabled': return new PrepaidEscapeError({ code: 'escape_disabled', local: false, cause: error });
202
+ case 'EscapeNotOpen': {
203
+ // Never throw while naming a revert: an out-of-range time is reported without opensAt.
204
+ const at = args[1];
205
+ return new PrepaidEscapeError({ code: 'escape_not_open', local: false, requestId: args[0],
206
+ ...(at > 0n && at <= MAX_DATE_SECONDS ? { opensAt: date(at) } : {}), cause: error });
207
+ }
208
+ case 'ReservationUnavailable': return new PrepaidEscapeError({ code: 'reservation_unavailable', local: false, requestId: args[0], cause: error });
209
+ case 'InvalidEscapeDelay': return new PrepaidEscapeError({ code: 'invalid_escape_delay', local: false, delaySeconds: args[0], cause: error });
210
+ case 'TooManyCovered': return new PrepaidEscapeError({ code: 'too_many_requests', local: false, cause: error });
211
+ case 'EmptyBundle': return new PrepaidEscapeError({ code: 'empty_request', local: false, cause: error });
212
+ default: return undefined;
213
+ }
214
+ }
215
+ /**
216
+ * Decode `PrepaidEscaped` and `PrepaidBatchEscaped` from logs emitted by one Settlement. Logs from
217
+ * any other address, and other events, are skipped; a removed (reorganized) log is refused.
218
+ * @param logs Receipt logs or a bounded `eth_getLogs` window.
219
+ * @param settlement Approved Settlement proxy.
220
+ */
221
+ export function decodePrepaidEscapeLogs(logs, settlement) {
222
+ const events = { escaped: [], batches: [] };
223
+ for (const log of logs) {
224
+ if (!same(log.address, settlement))
225
+ continue;
226
+ let decoded;
227
+ try {
228
+ decoded = decodeEventLog({ abi: settlementAbi, data: log.data, topics: log.topics, strict: true });
229
+ }
230
+ catch {
231
+ continue;
232
+ }
233
+ if (decoded.eventName !== 'PrepaidEscaped' && decoded.eventName !== 'PrepaidBatchEscaped')
234
+ continue;
235
+ if (log.removed)
236
+ throw new TasraError('prepaid escape log was removed by a reorganization');
237
+ const a = decoded.args;
238
+ if (decoded.eventName === 'PrepaidEscaped')
239
+ events.escaped.push({ slotId: a.slotId, requestId: a.requestId, refunded: a.refunded });
240
+ else
241
+ events.batches.push({ slotId: a.slotId, caller: a.caller, refunded: a.refunded, requestCount: a.requestCount });
242
+ }
243
+ return events;
244
+ }
245
+ /** Exactly one batch for this slot and caller, and one `PrepaidEscaped` per request in order. */
246
+ function verifyEvents(logs, d, slot, ids, caller) {
247
+ const { escaped, batches } = decodePrepaidEscapeLogs(logs, d.settlement);
248
+ const refunds = escaped.map(e => ({ requestId: e.requestId.toLowerCase(), refunded: e.refunded, slot: e.slotId }));
249
+ const total = refunds.reduce((sum, r) => sum + r.refunded, 0n);
250
+ const [batch] = batches;
251
+ if (batches.length !== 1 || !batch || !same(batch.slotId, slot) || !same(batch.caller, caller) || batch.requestCount !== BigInt(ids.length)
252
+ || batch.refunded !== total || refunds.length !== ids.length
253
+ || refunds.some((r, i) => !same(r.slot, slot) || r.requestId !== ids[i] || r.refunded <= 0n))
254
+ throw new TasraError('escape events differ from the submitted call');
255
+ return { refunded: total, refunds: refunds.map(({ requestId, refunded }) => ({ requestId, refunded })) };
256
+ }
257
+ function validateRecord(d, original) {
258
+ const record = structuredClone(original), tx = record?.transaction;
259
+ if (!record || record.schema !== 1 || !tx)
260
+ throw new TasraError('invalid prepaid escape record');
261
+ const { slot, ids } = requestList(record.slotId, record.requestIds);
262
+ if (ids.length > MAX_ESCAPE_PER_CALL || !same(record.escapeId, prepaidEscapeId(d, slot, ids))
263
+ || tx.chainId !== d.chainId || typeof tx.from !== 'string' || !ADDRESS.test(tx.from) || ZERO_ADDRESS.test(tx.from) || !same(tx.to, d.settlement)
264
+ || !same(tx.data, encodeFunctionData({ abi: settlementAbi, functionName: 'escapePrepaid', args: [slot, ids] })) || tx.value !== '0'
265
+ || !Number.isSafeInteger(tx.nonce) || tx.nonce < 0 || typeof tx.gas !== 'string' || !/^[1-9][0-9]{0,19}$/.test(tx.gas) || BigInt(tx.gas) >= 1n << 64n
266
+ || typeof tx.gasPrice !== 'string' || !/^[1-9][0-9]{0,38}$/.test(tx.gasPrice) || BigInt(tx.gasPrice) >= 1n << 128n)
267
+ throw new TasraError('invalid prepaid escape record');
268
+ return { ...record, slotId: slot, requestIds: ids };
269
+ }
270
+ function sameTransaction(tx, record) {
271
+ return tx.to !== null && same(tx.to, record.to) && same(tx.from, record.from) && same(tx.input, record.data) && tx.value === 0n
272
+ && tx.nonce === record.nonce && tx.type === 'legacy' && tx.gas === BigInt(record.gas) && tx.gasPrice === BigInt(record.gasPrice)
273
+ && (tx.chainId === undefined || tx.chainId === record.chainId);
274
+ }
275
+ const notFound = (error, name) => isViemError(error, name);
276
+ async function escapeCall(client, d, slot, ids, signer, payer, payerChain, opts) {
277
+ const escapeId = prepaidEscapeId(d, slot, ids), signal = opts.signal;
278
+ const data = encodeFunctionData({ abi: settlementAbi, functionName: 'escapePrepaid', args: [slot, ids] });
279
+ signal?.throwIfAborted();
280
+ // The contract's own checks at the current head; a refusal is named and nothing is sent.
281
+ try {
282
+ await client.call({ account: payer, to: d.settlement, data, batch: false });
283
+ }
284
+ catch (error) {
285
+ throw decodePrepaidEscapeRevert(error) ?? revertError(error, 'prepaid escape simulation refused');
286
+ }
287
+ const [gasPrice, gas, nonce] = await Promise.all([
288
+ client.getGasPrice(), client.estimateGas({ account: payer, to: d.settlement, data, value: 0n }),
289
+ client.getTransactionCount({ address: payer.address, blockTag: 'pending' }),
290
+ ]);
291
+ if (gas <= 0n || gas > opts.maxGas || gasPrice <= 0n || gasPrice > opts.maxGasPrice)
292
+ throw new TasraError('prepaid escape exceeds the native gas budget');
293
+ const record = { schema: 1, escapeId, slotId: slot, requestIds: [...ids],
294
+ transaction: { chainId: d.chainId, from: payer.address, to: d.settlement, data, value: '0', nonce, gas: gas.toString(), gasPrice: gasPrice.toString() } };
295
+ // A local signer signs before the journal, so the exact hash is durable before any broadcast.
296
+ let raw, transactionHash;
297
+ if (payer.type === 'local') {
298
+ raw = await signer.signTransaction({ account: payer, chain: payerChain, to: d.settlement, data, value: 0n, nonce, gas, gasPrice, type: 'legacy' });
299
+ const signed = parseTransaction(raw), sender = await recoverTransactionAddress({ serializedTransaction: raw });
300
+ if (signed.type !== 'legacy' || signed.chainId !== d.chainId || !same(sender, payer.address) || !signed.to || !same(signed.to, d.settlement)
301
+ || !signed.data || !same(signed.data, data) || (signed.value ?? 0n) !== 0n || signed.nonce !== nonce || signed.gas !== gas
302
+ || signed.gasPrice !== gasPrice)
303
+ throw new TasraError('signed transaction differs from the prepared escape');
304
+ transactionHash = keccak256(raw);
305
+ }
306
+ signal?.throwIfAborted();
307
+ await opts.persist({ phase: 'prepared', record: structuredClone(record), ...(transactionHash ? { transactionHash } : {}) });
308
+ try {
309
+ // Exactly one RPC submission; viem's generic send may otherwise retry or switch method.
310
+ if (raw !== undefined) {
311
+ const returned = await signer.request({ method: 'eth_sendRawTransaction', params: [raw] }, { retryCount: 0 });
312
+ if (transactionHash === undefined || typeof returned !== 'string' || !same(returned, transactionHash))
313
+ throw new TasraError('RPC returned another signed transaction hash');
314
+ }
315
+ else {
316
+ transactionHash = await signer.request({ method: 'eth_sendTransaction', params: [{ from: payer.address, to: d.settlement, data, value: '0x0',
317
+ nonce: toHex(nonce), gas: toHex(gas), gasPrice: toHex(gasPrice), type: '0x0', chainId: toHex(d.chainId) }] }, { retryCount: 0 });
318
+ }
319
+ if (typeof transactionHash !== 'string' || !HEX32.test(transactionHash) || ZERO32.test(transactionHash))
320
+ throw new TasraError('invalid prepaid escape transaction hash');
321
+ const sent = transactionHash;
322
+ await opts.persist({ phase: 'submitted', escapeId, transactionHash: sent });
323
+ const mined = await untilAborted(pollTransactionReceipt(client, sent, { confirmations: opts.confirmations, timeoutMs: opts.receiptTimeout, signal }), signal);
324
+ if (!same(mined.transactionHash, sent) || mined.status !== 'success')
325
+ throw new TasraError('prepaid escape transaction reverted or was replaced');
326
+ const transaction = await untilAborted(client.getTransaction({ hash: sent }), signal);
327
+ if (!sameTransaction(transaction, record.transaction) || transaction.blockHash === null || !same(transaction.blockHash, mined.blockHash))
328
+ throw new TasraError('mined transaction differs from the prepared escape');
329
+ const { refunded, refunds } = verifyEvents(mined.logs, d, slot, ids, payer.address);
330
+ const minedBlock = await untilAborted(client.getBlock({ blockNumber: mined.blockNumber }), signal);
331
+ if (minedBlock.hash === null || !same(minedBlock.hash, mined.blockHash))
332
+ throw new TasraError('prepaid escape receipt reorganized');
333
+ await opts.persist({ phase: 'confirmed', escapeId, transactionHash: sent, blockHash: mined.blockHash, refunded: refunded.toString() });
334
+ return { escapeId, requestIds: [...ids], transactionHash: sent, blockNumber: mined.blockNumber, blockHash: mined.blockHash, refunded, refunds };
335
+ }
336
+ catch (cause) {
337
+ throw new PrepaidEscapeUncertainError({ escapeId, requestIds: ids, ...(transactionHash ? { transactionHash } : {}), cause });
338
+ }
339
+ }
340
+ async function escape(client, d, original) {
341
+ // Snapshot caller-owned inputs before the first await.
342
+ const args = { ...original }, { slot, ids } = requestList(args.slotId, args.requestIds);
343
+ const signer = args.signer, payer = { ...signer?.account }, payerChain = { ...signer?.chain };
344
+ const confirmations = args.confirmations ?? 1, receiptTimeout = args.receiptTimeoutMs ?? 60_000;
345
+ if (typeof args.maxGas !== 'bigint' || typeof args.maxGasPrice !== 'bigint' || args.maxGas <= 0n || args.maxGas >= 1n << 64n
346
+ || args.maxGasPrice <= 0n || args.maxGasPrice >= 1n << 128n || typeof args.persist !== 'function')
347
+ throw new TasraError('Invalid prepaid escape gas budget or journal');
348
+ if (!Number.isSafeInteger(confirmations) || confirmations < 1 || confirmations > 64
349
+ || !Number.isSafeInteger(receiptTimeout) || receiptTimeout < 1 || receiptTimeout > 120_000)
350
+ throw new TasraError('Invalid prepaid escape confirmations or timeout');
351
+ if (payer.type !== 'local' && payer.type !== 'json-rpc')
352
+ throw new TasraError('prepaid escape requires an EOA gas payer');
353
+ if (payerChain.id !== d.chainId || await chainIdOf(signer) !== d.chainId)
354
+ throw new TasraError('prepaid escape signer chain mismatch');
355
+ args.signal?.throwIfAborted();
356
+ refuseUnlessOpen(await observe(client, d, slot, ids));
357
+ const calls = [];
358
+ for (let offset = 0; offset < ids.length; offset += MAX_ESCAPE_PER_CALL) {
359
+ calls.push(await escapeCall(client, d, slot, ids.slice(offset, offset + MAX_ESCAPE_PER_CALL), signer, payer, payerChain, { maxGas: args.maxGas, maxGasPrice: args.maxGasPrice, persist: args.persist, confirmations, receiptTimeout, signal: args.signal }));
360
+ }
361
+ return { slotId: slot, refunded: calls.reduce((sum, c) => sum + c.refunded, 0n), calls };
362
+ }
363
+ async function reconcile(client, d, original) {
364
+ const record = validateRecord(d, original.record), hash = original.transactionHash, confirmations = original.confirmations ?? 1;
365
+ if (hash !== undefined && (typeof hash !== 'string' || !HEX32.test(hash) || ZERO32.test(hash)))
366
+ throw new TasraError('Invalid prepaid escape transaction hash');
367
+ if (!Number.isSafeInteger(confirmations) || confirmations < 1 || confirmations > 64)
368
+ throw new TasraError('Invalid prepaid escape confirmations');
369
+ const at = await observeHead(client, d, BigInt(confirmations - 1));
370
+ const [receipt, transaction] = hash === undefined ? [null, null] : await Promise.all([
371
+ client.getTransactionReceipt({ hash }).catch((e) => { if (notFound(e, 'TransactionReceiptNotFoundError'))
372
+ return null; throw e; }),
373
+ client.getTransaction({ hash }).catch((e) => { if (notFound(e, 'TransactionNotFoundError'))
374
+ return null; throw e; }),
375
+ ]);
376
+ const [requests, nonce] = await Promise.all([
377
+ Promise.all(record.requestIds.map(async (requestId) => {
378
+ const [settled, escapedAt] = await Promise.all([readAt(client, d.settlement, at, 'prepaidSettled', [record.slotId, requestId]),
379
+ readAt(client, d.settlement, at, 'prepaidEscapedAt', [record.slotId, requestId])]);
380
+ if (typeof settled !== 'boolean' || typeof escapedAt !== 'bigint' || (escapedAt !== 0n && !settled))
381
+ throw new TasraError('invalid prepaid escape state');
382
+ return escapedAt === 0n ? { requestId, settled } : { requestId, settled, escapedAt: date(escapedAt) };
383
+ })),
384
+ client.getTransactionCount({ address: record.transaction.from, blockNumber: at.blockNumber }),
385
+ ]);
386
+ const base = { escapeId: record.escapeId, blockNumber: at.blockNumber, blockHash: at.blockHash, requests, ...(hash ? { transactionHash: hash } : {}) };
387
+ let result;
388
+ if (receipt && receipt.blockNumber <= at.blockNumber) {
389
+ if (!transaction || !same(receipt.transactionHash, hash) || !sameTransaction(transaction, record.transaction)
390
+ || transaction.blockHash === null || !same(transaction.blockHash, receipt.blockHash))
391
+ throw new TasraError('candidate transaction differs from the prepared escape');
392
+ const minedBlock = await client.getBlock({ blockNumber: receipt.blockNumber });
393
+ if (minedBlock.hash === null || !same(minedBlock.hash, receipt.blockHash))
394
+ throw new TasraError('prepaid escape receipt reorganized');
395
+ if (receipt.status === 'success') {
396
+ const { refunded } = verifyEvents(receipt.logs, d, record.slotId, record.requestIds, record.transaction.from);
397
+ if (requests.some(r => r.escapedAt === undefined))
398
+ throw new TasraError('mined escape is not reflected in prepaidEscapedAt');
399
+ result = { ...base, state: 'escaped', refunded };
400
+ }
401
+ else
402
+ result = { ...base, state: 'reverted' };
403
+ }
404
+ else if (requests.every(r => r.settled))
405
+ result = { ...base, state: 'completed' };
406
+ // The nonce is spent at the observed depth, yet some request is still open: whatever spent it
407
+ // did not escape this call (a successful escape completes every request atomically).
408
+ else if (nonce > record.transaction.nonce)
409
+ result = { ...base, state: 'not-escaped' };
410
+ else
411
+ result = { ...base, state: 'uncertain' };
412
+ await recheck(client, at);
413
+ return result;
414
+ }
415
+ /**
416
+ * Bind the payer-side prepaid timeout-escape client to one approved deployment.
417
+ * Exposes no governance action: the escape delay is set only by the Settlement owner (timelock).
418
+ * @param client Trusted bounded public RPC client with canonical EIP-1898 reads; use retryCount: 0.
419
+ * @param deployment Independently approved chain ID and Settlement proxy.
420
+ */
421
+ export function createPrepaidEscapeClient(client, deployment) {
422
+ const d = { chainId: deployment.chainId, settlement: deployment.settlement };
423
+ validateDeployment(d);
424
+ return Object.freeze({
425
+ escapableAt: async (args) => {
426
+ const { slot, ids } = requestList(args?.slotId, args?.requestIds);
427
+ return observe(client, d, slot, ids);
428
+ },
429
+ escapePrepaid: (args) => escape(client, d, args),
430
+ reconcileEscape: (args) => reconcile(client, d, args),
431
+ });
432
+ }
@@ -0,0 +1,94 @@
1
+ import { type Account, type Address, type Chain, type Hex, type PublicClient, type Transport, type WalletClient } from 'viem';
2
+ /** Fault kinds in the oracle's enum order. */
3
+ export declare const PREPAID_FAULT_KINDS: readonly ["WrongPayout", "KeeperUndercredit", "KeeperOvercredit", "VerifierUndercredit", "VerifierOvercredit"];
4
+ /** A prepaid payout fault kind. */
5
+ export type PrepaidFaultKind = (typeof PREPAID_FAULT_KINDS)[number];
6
+ /** The verdict the accountant set threshold-signs and the oracle executes. */
7
+ export interface PrepaidFaultVerdict {
8
+ /** Slot of the settled request. */
9
+ slotId: Hex;
10
+ /** Settled prepaid request. */
11
+ requestId: Hex;
12
+ /** Mined batch that settled it. */
13
+ batchId: Hex;
14
+ /** Commitment to the adjudicated evidence. */
15
+ evidenceHash: Hex;
16
+ /** Operator to slash. */
17
+ offender: Address;
18
+ /** Under-credited worker paid the bounty; zero for every other kind. */
19
+ beneficiary: Address;
20
+ /** Fault kind. */
21
+ kind: PrepaidFaultKind;
22
+ /** Beacon epoch the verdict was signed at; must be current when executed. */
23
+ epoch: bigint;
24
+ /** Unix deadline, at most 120 s after execution time. */
25
+ deadline: bigint;
26
+ }
27
+ /** Accountant claim intake byte limit (the witness's own bundle maximum). */
28
+ export declare const MAX_PREPAID_FAULT_BUNDLE_BYTES: number;
29
+ /**
30
+ * Calldata for `PrepaidFaultOracle.contest`, after the oracle's local preconditions
31
+ * (nonzero subject, beneficiary rule, a deadline within 120 s). Chain-dependent checks
32
+ * (current epoch, settled request and batch, signature) stay with the oracle.
33
+ * @param verdict Threshold-signed verdict.
34
+ * @param signature BN254 threshold signature over the verdict digest.
35
+ * @param nowSecs Current time in Unix seconds (default: now).
36
+ */
37
+ export declare function encodePrepaidFaultContest(verdict: PrepaidFaultVerdict, signature: Hex, nowSecs?: bigint): Hex;
38
+ /**
39
+ * Whether the oracle already punished this offender for this batch (one resolution per
40
+ * offender and batch, whatever the kind or evidence).
41
+ * @param client Trusted RPC client.
42
+ * @param oracle Independently approved PrepaidFaultOracle.
43
+ * @param subject Slot, batch and offender.
44
+ */
45
+ export declare function readPrepaidFaultResolution(client: PublicClient, oracle: Address, subject: {
46
+ slotId: Hex;
47
+ batchId: Hex;
48
+ offender: Address;
49
+ }): Promise<{
50
+ resolutionId: Hex;
51
+ resolved: boolean;
52
+ }>;
53
+ /**
54
+ * Relay a threshold-signed verdict to the oracle. The call is simulated first, so an oracle
55
+ * refusal (WrongEpoch, AlreadyResolved, BadSignature, ...) is named and nothing is sent; the
56
+ * transaction is then sent once and its hash returned. Reconcile an unknown outcome with
57
+ * {@link readPrepaidFaultResolution}; never resend blindly.
58
+ * @param client Trusted RPC client.
59
+ * @param wallet Account- and chain-bound sender (any account: contest is permissionless).
60
+ * @param oracle Independently approved PrepaidFaultOracle.
61
+ * @param verdict Threshold-signed verdict.
62
+ * @param signature BN254 threshold signature over the verdict digest.
63
+ */
64
+ export declare function contestPrepaidFault(client: PublicClient, wallet: WalletClient<Transport, Chain, Account>, oracle: Address, verdict: PrepaidFaultVerdict, signature: Hex): Promise<Hex>;
65
+ /** Options for the accountant fault endpoints. */
66
+ export interface PrepaidFaultHttpOptions {
67
+ /** Fetch implementation (default global fetch). */
68
+ fetch?: typeof fetch;
69
+ /** Cancellation. */
70
+ signal?: AbortSignal;
71
+ /** Per-request deadline in ms (default 30000). */
72
+ timeoutMs?: number;
73
+ /** Permit plain HTTP to a loopback accountant (local development only). */
74
+ allowLocalHttp?: boolean;
75
+ }
76
+ /**
77
+ * Hand a proof bundle to an accountant's fault witness (`POST /v1/prepaid-fault/claim`).
78
+ * Resolves on HTTP 202 (authenticated and durably stored). Any other status throws a
79
+ * TasraHttpError with the service's `Retry-After`: 400 malformed, 403 nothing authenticated,
80
+ * 413 too large are final; 408, 429 and 503 may be sent again later. Never re-sent here.
81
+ * @param base Approved accountant origin.
82
+ * @param bundle Proof bundle (`version` 1, `slot`, `batch_id`, `reconcile_block`, signed records).
83
+ * @param options Fetch, cancellation, deadline and local HTTP allowance.
84
+ */
85
+ export declare function submitPrepaidFaultClaim(base: string, bundle: Record<string, unknown>, options?: PrepaidFaultHttpOptions): Promise<{
86
+ status: 202;
87
+ }>;
88
+ /**
89
+ * Read an accountant fault witness's adjudication health (`GET /v1/prepaid-fault/status`).
90
+ * The body is returned as parsed JSON, bounded to 64 KiB; it is a monitoring view, not evidence.
91
+ * @param base Approved accountant origin.
92
+ * @param options Fetch, cancellation, deadline and local HTTP allowance.
93
+ */
94
+ export declare function readPrepaidFaultStatus(base: string, options?: PrepaidFaultHttpOptions): Promise<Record<string, unknown>>;