@capxul/cli 4.20.0-beta.3 → 4.20.0-beta.30

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 (44) hide show
  1. package/README.md +1156 -21
  2. package/dist/browser/GeistVF.woff +0 -0
  3. package/dist/browser/signer.js +85954 -0
  4. package/dist/browser/signer.js.map +1 -0
  5. package/dist/entry-Cp3LiVYn.mjs +46472 -0
  6. package/dist/entry-Cp3LiVYn.mjs.map +1 -0
  7. package/dist/fast-Dvf2EM7j.mjs +57 -0
  8. package/dist/fast-Dvf2EM7j.mjs.map +1 -0
  9. package/dist/{lib-BOge5QZP.mjs → lib-5nM6ORJd.mjs} +5 -4
  10. package/dist/{lib-BOge5QZP.mjs.map → lib-5nM6ORJd.mjs.map} +1 -1
  11. package/dist/{lib-DH_xJGSE.mjs → lib-BJgR4mWJ.mjs} +6 -5
  12. package/dist/{lib-DH_xJGSE.mjs.map → lib-BJgR4mWJ.mjs.map} +1 -1
  13. package/dist/lib-BlUleR2B.mjs +3 -0
  14. package/dist/{lib-C8ENT9j6.mjs → lib-BspI667y.mjs} +7 -6
  15. package/dist/{lib-C8ENT9j6.mjs.map → lib-BspI667y.mjs.map} +1 -1
  16. package/dist/{lib-C4fpnzyy.mjs → lib-Buegx0dz.mjs} +6 -5
  17. package/dist/{lib-C4fpnzyy.mjs.map → lib-Buegx0dz.mjs.map} +1 -1
  18. package/dist/{lib-DVGoRCJN.mjs → lib-CJw8te9L.mjs} +38 -38
  19. package/dist/{lib-DVGoRCJN.mjs.map → lib-CJw8te9L.mjs.map} +1 -1
  20. package/dist/lib-C_-etuHZ.mjs +3 -0
  21. package/dist/lib-CoGPQsbr.mjs +655 -0
  22. package/dist/lib-CoGPQsbr.mjs.map +1 -0
  23. package/dist/lib-Dd_fsz7h.mjs +3 -0
  24. package/dist/lib-DnmstTkB.mjs +578 -0
  25. package/dist/lib-DnmstTkB.mjs.map +1 -0
  26. package/dist/lib-IlYdzOHo.mjs +3 -0
  27. package/dist/main.mjs +22 -51062
  28. package/dist/main.mjs.map +1 -1
  29. package/dist/organizations-Dkb73lVO.mjs +37607 -0
  30. package/dist/organizations-Dkb73lVO.mjs.map +1 -0
  31. package/dist/permission-approvals-C3cUSQeT.mjs +139 -0
  32. package/dist/permission-approvals-C3cUSQeT.mjs.map +1 -0
  33. package/dist/record-U7Yu4KQP.mjs +1295 -0
  34. package/dist/record-U7Yu4KQP.mjs.map +1 -0
  35. package/dist/{secp256k1-Cc9JhcTQ.mjs → secp256k1-D8L212-Z.mjs} +5 -298
  36. package/dist/secp256k1-D8L212-Z.mjs.map +1 -0
  37. package/dist/sha2-CR2DnMEk.mjs +298 -0
  38. package/dist/sha2-CR2DnMEk.mjs.map +1 -0
  39. package/dist/utils-DmKXBQjM.mjs +130 -0
  40. package/dist/utils-DmKXBQjM.mjs.map +1 -0
  41. package/dist/where-view-DuGbrSLp.mjs +1420 -0
  42. package/dist/where-view-DuGbrSLp.mjs.map +1 -0
  43. package/package.json +18 -10
  44. package/dist/secp256k1-Cc9JhcTQ.mjs.map +0 -1
@@ -0,0 +1,1420 @@
1
+ import { A as isHex, C as numberToHex, N as BaseError, O as trim, S as bytesToHex, T as toHex, _ as hexToBigInt, a as isAddress, b as toBytes, d as formatGwei$1, f as toRlp, h as concatHex, k as size, l as InvalidAddressError, p as createCursor, r as slice, t as isRecord, v as hexToNumber, y as hexToBytes } from "./record-U7Yu4KQP.mjs";
2
+ import { t as sha256$2 } from "./sha2-CR2DnMEk.mjs";
3
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/chain/defineChain.js
4
+ function defineChain(chain) {
5
+ const chainInstance = {
6
+ formatters: void 0,
7
+ fees: void 0,
8
+ serializers: void 0,
9
+ ...chain
10
+ };
11
+ function extend(base) {
12
+ return (fnOrExtended) => {
13
+ const properties = typeof fnOrExtended === "function" ? fnOrExtended(base) : fnOrExtended;
14
+ const combined = {
15
+ ...base,
16
+ ...properties
17
+ };
18
+ return Object.assign(combined, { extend: extend(combined) });
19
+ };
20
+ }
21
+ return Object.assign(chainInstance, { extend: extend(chainInstance) });
22
+ }
23
+ //#endregion
24
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/formatters/formatter.js
25
+ function defineFormatter(type, format) {
26
+ return ({ exclude, format: overrides }) => {
27
+ return {
28
+ exclude,
29
+ format: (args, action) => {
30
+ const formatted = format(args, action);
31
+ if (exclude) for (const key of exclude) delete formatted[key];
32
+ return {
33
+ ...formatted,
34
+ ...overrides(args, action)
35
+ };
36
+ },
37
+ type
38
+ };
39
+ };
40
+ }
41
+ //#endregion
42
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/formatters/transaction.js
43
+ const transactionType = {
44
+ "0x0": "legacy",
45
+ "0x1": "eip2930",
46
+ "0x2": "eip1559",
47
+ "0x3": "eip4844",
48
+ "0x4": "eip7702"
49
+ };
50
+ function formatTransaction(transaction, _) {
51
+ const transaction_ = {
52
+ ...transaction,
53
+ blockHash: transaction.blockHash ? transaction.blockHash : null,
54
+ blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
55
+ ...transaction.blockTimestamp != null && { blockTimestamp: BigInt(transaction.blockTimestamp) },
56
+ chainId: transaction.chainId ? hexToNumber(transaction.chainId) : void 0,
57
+ gas: transaction.gas ? BigInt(transaction.gas) : void 0,
58
+ gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
59
+ maxFeePerBlobGas: transaction.maxFeePerBlobGas ? BigInt(transaction.maxFeePerBlobGas) : void 0,
60
+ maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
61
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas ? BigInt(transaction.maxPriorityFeePerGas) : void 0,
62
+ nonce: transaction.nonce ? hexToNumber(transaction.nonce) : void 0,
63
+ to: transaction.to ? transaction.to : null,
64
+ transactionIndex: transaction.transactionIndex ? Number(transaction.transactionIndex) : null,
65
+ type: transaction.type ? transactionType[transaction.type] : void 0,
66
+ typeHex: transaction.type ? transaction.type : void 0,
67
+ value: transaction.value ? BigInt(transaction.value) : void 0,
68
+ v: transaction.v ? BigInt(transaction.v) : void 0
69
+ };
70
+ if (transaction.authorizationList) transaction_.authorizationList = formatAuthorizationList(transaction.authorizationList);
71
+ transaction_.yParity = (() => {
72
+ if (transaction.yParity) return Number(transaction.yParity);
73
+ if (typeof transaction_.v === "bigint") {
74
+ if (transaction_.v === 0n || transaction_.v === 27n) return 0;
75
+ if (transaction_.v === 1n || transaction_.v === 28n) return 1;
76
+ if (transaction_.v >= 35n) return transaction_.v % 2n === 0n ? 1 : 0;
77
+ }
78
+ })();
79
+ if (transaction_.type === "legacy") {
80
+ delete transaction_.accessList;
81
+ delete transaction_.maxFeePerBlobGas;
82
+ delete transaction_.maxFeePerGas;
83
+ delete transaction_.maxPriorityFeePerGas;
84
+ delete transaction_.yParity;
85
+ }
86
+ if (transaction_.type === "eip2930") {
87
+ delete transaction_.maxFeePerBlobGas;
88
+ delete transaction_.maxFeePerGas;
89
+ delete transaction_.maxPriorityFeePerGas;
90
+ }
91
+ if (transaction_.type === "eip1559") delete transaction_.maxFeePerBlobGas;
92
+ return transaction_;
93
+ }
94
+ const defineTransaction = /*#__PURE__*/ defineFormatter("transaction", formatTransaction);
95
+ function formatAuthorizationList(authorizationList) {
96
+ return authorizationList.map((authorization) => ({
97
+ address: authorization.address,
98
+ chainId: Number(authorization.chainId),
99
+ nonce: Number(authorization.nonce),
100
+ r: authorization.r,
101
+ s: authorization.s,
102
+ yParity: Number(authorization.yParity)
103
+ }));
104
+ }
105
+ //#endregion
106
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/formatters/block.js
107
+ function formatBlock(block, _) {
108
+ const transactions = (block.transactions ?? []).map((transaction) => {
109
+ if (typeof transaction === "string") return transaction;
110
+ return formatTransaction(transaction);
111
+ });
112
+ return {
113
+ ...block,
114
+ baseFeePerGas: block.baseFeePerGas ? BigInt(block.baseFeePerGas) : null,
115
+ blobGasUsed: block.blobGasUsed ? BigInt(block.blobGasUsed) : void 0,
116
+ difficulty: block.difficulty ? BigInt(block.difficulty) : void 0,
117
+ excessBlobGas: block.excessBlobGas ? BigInt(block.excessBlobGas) : void 0,
118
+ gasLimit: block.gasLimit ? BigInt(block.gasLimit) : void 0,
119
+ gasUsed: block.gasUsed ? BigInt(block.gasUsed) : void 0,
120
+ hash: block.hash ? block.hash : null,
121
+ logsBloom: block.logsBloom ? block.logsBloom : null,
122
+ nonce: block.nonce ? block.nonce : null,
123
+ number: block.number ? BigInt(block.number) : null,
124
+ size: block.size ? BigInt(block.size) : void 0,
125
+ timestamp: block.timestamp ? BigInt(block.timestamp) : void 0,
126
+ transactions,
127
+ totalDifficulty: block.totalDifficulty ? BigInt(block.totalDifficulty) : null
128
+ };
129
+ }
130
+ const defineBlock = /*#__PURE__*/ defineFormatter("block", formatBlock);
131
+ //#endregion
132
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/formatters/log.js
133
+ function formatLog(log, { args, eventName } = {}) {
134
+ return {
135
+ ...log,
136
+ blockHash: log.blockHash ? log.blockHash : null,
137
+ blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
138
+ blockTimestamp: log.blockTimestamp ? BigInt(log.blockTimestamp) : log.blockTimestamp === null ? null : void 0,
139
+ logIndex: log.logIndex ? Number(log.logIndex) : null,
140
+ transactionHash: log.transactionHash ? log.transactionHash : null,
141
+ transactionIndex: log.transactionIndex ? Number(log.transactionIndex) : null,
142
+ ...eventName ? {
143
+ args,
144
+ eventName
145
+ } : {}
146
+ };
147
+ }
148
+ //#endregion
149
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/formatters/transactionReceipt.js
150
+ const receiptStatuses = {
151
+ "0x0": "reverted",
152
+ "0x1": "success"
153
+ };
154
+ function formatTransactionReceipt(transactionReceipt, _) {
155
+ const receipt = {
156
+ ...transactionReceipt,
157
+ blockNumber: transactionReceipt.blockNumber ? BigInt(transactionReceipt.blockNumber) : null,
158
+ contractAddress: transactionReceipt.contractAddress ? transactionReceipt.contractAddress : null,
159
+ cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
160
+ effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
161
+ gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
162
+ logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
163
+ to: transactionReceipt.to ? transactionReceipt.to : null,
164
+ transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
165
+ status: transactionReceipt.status ? receiptStatuses[transactionReceipt.status] : null,
166
+ type: transactionReceipt.type ? transactionType[transactionReceipt.type] || transactionReceipt.type : null
167
+ };
168
+ if (transactionReceipt.blobGasPrice) receipt.blobGasPrice = BigInt(transactionReceipt.blobGasPrice);
169
+ if (transactionReceipt.blobGasUsed) receipt.blobGasUsed = BigInt(transactionReceipt.blobGasUsed);
170
+ return receipt;
171
+ }
172
+ const defineTransactionReceipt = /*#__PURE__*/ defineFormatter("transactionReceipt", formatTransactionReceipt);
173
+ 2n ** (8n - 1n) - 1n;
174
+ 2n ** (16n - 1n) - 1n;
175
+ 2n ** (24n - 1n) - 1n;
176
+ 2n ** (32n - 1n) - 1n;
177
+ 2n ** (40n - 1n) - 1n;
178
+ 2n ** (48n - 1n) - 1n;
179
+ 2n ** (56n - 1n) - 1n;
180
+ 2n ** (64n - 1n) - 1n;
181
+ 2n ** (72n - 1n) - 1n;
182
+ 2n ** (80n - 1n) - 1n;
183
+ 2n ** (88n - 1n) - 1n;
184
+ 2n ** (96n - 1n) - 1n;
185
+ 2n ** (104n - 1n) - 1n;
186
+ 2n ** (112n - 1n) - 1n;
187
+ 2n ** (120n - 1n) - 1n;
188
+ 2n ** (128n - 1n) - 1n;
189
+ 2n ** (136n - 1n) - 1n;
190
+ 2n ** (144n - 1n) - 1n;
191
+ 2n ** (152n - 1n) - 1n;
192
+ 2n ** (160n - 1n) - 1n;
193
+ 2n ** (168n - 1n) - 1n;
194
+ 2n ** (176n - 1n) - 1n;
195
+ 2n ** (184n - 1n) - 1n;
196
+ 2n ** (192n - 1n) - 1n;
197
+ 2n ** (200n - 1n) - 1n;
198
+ 2n ** (208n - 1n) - 1n;
199
+ 2n ** (216n - 1n) - 1n;
200
+ 2n ** (224n - 1n) - 1n;
201
+ 2n ** (232n - 1n) - 1n;
202
+ 2n ** (240n - 1n) - 1n;
203
+ 2n ** (248n - 1n) - 1n;
204
+ 2n ** (256n - 1n) - 1n;
205
+ -(2n ** (8n - 1n));
206
+ -(2n ** (16n - 1n));
207
+ -(2n ** (24n - 1n));
208
+ -(2n ** (32n - 1n));
209
+ -(2n ** (40n - 1n));
210
+ -(2n ** (48n - 1n));
211
+ -(2n ** (56n - 1n));
212
+ -(2n ** (64n - 1n));
213
+ -(2n ** (72n - 1n));
214
+ -(2n ** (80n - 1n));
215
+ -(2n ** (88n - 1n));
216
+ -(2n ** (96n - 1n));
217
+ -(2n ** (104n - 1n));
218
+ -(2n ** (112n - 1n));
219
+ -(2n ** (120n - 1n));
220
+ -(2n ** (128n - 1n));
221
+ -(2n ** (136n - 1n));
222
+ -(2n ** (144n - 1n));
223
+ -(2n ** (152n - 1n));
224
+ -(2n ** (160n - 1n));
225
+ -(2n ** (168n - 1n));
226
+ -(2n ** (176n - 1n));
227
+ -(2n ** (184n - 1n));
228
+ -(2n ** (192n - 1n));
229
+ -(2n ** (200n - 1n));
230
+ -(2n ** (208n - 1n));
231
+ -(2n ** (216n - 1n));
232
+ -(2n ** (224n - 1n));
233
+ -(2n ** (232n - 1n));
234
+ -(2n ** (240n - 1n));
235
+ -(2n ** (248n - 1n));
236
+ -(2n ** (256n - 1n));
237
+ const maxUint256 = 2n ** 256n - 1n;
238
+ //#endregion
239
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/unit/formatGwei.js
240
+ /**
241
+ * Converts numerical wei to a string representation of gwei.
242
+ *
243
+ * - Docs: https://viem.sh/docs/utilities/formatGwei
244
+ *
245
+ * @example
246
+ * import { formatGwei } from 'viem'
247
+ *
248
+ * formatGwei(1000000000n)
249
+ * // '1'
250
+ */
251
+ function formatGwei(wei, unit = "wei") {
252
+ return formatGwei$1(wei, unit);
253
+ }
254
+ //#endregion
255
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/transaction.js
256
+ function prettyPrint(args) {
257
+ const entries = Object.entries(args).map(([key, value]) => {
258
+ if (value === void 0 || value === false) return null;
259
+ return [key, value];
260
+ }).filter(Boolean);
261
+ const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
262
+ return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
263
+ }
264
+ var InvalidLegacyVError = class extends BaseError {
265
+ constructor({ v }) {
266
+ super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, { name: "InvalidLegacyVError" });
267
+ }
268
+ };
269
+ var InvalidSerializableTransactionError = class extends BaseError {
270
+ constructor({ transaction }) {
271
+ super("Cannot infer a transaction type from provided transaction.", {
272
+ metaMessages: [
273
+ "Provided Transaction:",
274
+ "{",
275
+ prettyPrint(transaction),
276
+ "}",
277
+ "",
278
+ "To infer the type, either provide:",
279
+ "- a `type` to the Transaction, or",
280
+ "- an EIP-1559 Transaction with `maxFeePerGas`, or",
281
+ "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
282
+ "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
283
+ "- an EIP-7702 Transaction with `authorizationList`, or",
284
+ "- a Legacy Transaction with `gasPrice`"
285
+ ],
286
+ name: "InvalidSerializableTransactionError"
287
+ });
288
+ }
289
+ };
290
+ var InvalidStorageKeySizeError = class extends BaseError {
291
+ constructor({ storageKey }) {
292
+ super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
293
+ }
294
+ };
295
+ //#endregion
296
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/authorization/serializeAuthorizationList.js
297
+ function serializeAuthorizationList(authorizationList) {
298
+ if (!authorizationList || authorizationList.length === 0) return [];
299
+ const serializedAuthorizationList = [];
300
+ for (const authorization of authorizationList) {
301
+ const { chainId, nonce, ...signature } = authorization;
302
+ const contractAddress = authorization.address;
303
+ serializedAuthorizationList.push([
304
+ chainId ? toHex(chainId) : "0x",
305
+ contractAddress,
306
+ nonce ? toHex(nonce) : "0x",
307
+ ...toYParitySignatureArray({}, signature)
308
+ ]);
309
+ }
310
+ return serializedAuthorizationList;
311
+ }
312
+ //#endregion
313
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/blobsToCommitments.js
314
+ /**
315
+ * Compute commitments from a list of blobs.
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * import { blobsToCommitments, toBlobs } from 'viem'
320
+ * import { kzg } from './kzg'
321
+ *
322
+ * const blobs = toBlobs({ data: '0x1234' })
323
+ * const commitments = blobsToCommitments({ blobs, kzg })
324
+ * ```
325
+ */
326
+ function blobsToCommitments(parameters) {
327
+ const { kzg } = parameters;
328
+ const to = parameters.to ?? (typeof parameters.blobs[0] === "string" ? "hex" : "bytes");
329
+ const blobs = typeof parameters.blobs[0] === "string" ? parameters.blobs.map((x) => hexToBytes(x)) : parameters.blobs;
330
+ const commitments = [];
331
+ for (const blob of blobs) commitments.push(Uint8Array.from(kzg.blobToKzgCommitment(blob)));
332
+ return to === "bytes" ? commitments : commitments.map((x) => bytesToHex(x));
333
+ }
334
+ //#endregion
335
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/blobsToProofs.js
336
+ /**
337
+ * Compute the proofs for a list of blobs and their commitments.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * import {
342
+ * blobsToCommitments,
343
+ * toBlobs
344
+ * } from 'viem'
345
+ * import { kzg } from './kzg'
346
+ *
347
+ * const blobs = toBlobs({ data: '0x1234' })
348
+ * const commitments = blobsToCommitments({ blobs, kzg })
349
+ * const proofs = blobsToProofs({ blobs, commitments, kzg })
350
+ * ```
351
+ */
352
+ function blobsToProofs(parameters) {
353
+ const { kzg } = parameters;
354
+ const to = parameters.to ?? (typeof parameters.blobs[0] === "string" ? "hex" : "bytes");
355
+ const blobs = typeof parameters.blobs[0] === "string" ? parameters.blobs.map((x) => hexToBytes(x)) : parameters.blobs;
356
+ const commitments = typeof parameters.commitments[0] === "string" ? parameters.commitments.map((x) => hexToBytes(x)) : parameters.commitments;
357
+ const proofs = [];
358
+ for (let i = 0; i < blobs.length; i++) {
359
+ const blob = blobs[i];
360
+ const commitment = commitments[i];
361
+ proofs.push(Uint8Array.from(kzg.computeBlobKzgProof(blob, commitment)));
362
+ }
363
+ return to === "bytes" ? proofs : proofs.map((x) => bytesToHex(x));
364
+ }
365
+ //#endregion
366
+ //#region ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
367
+ /**
368
+ * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
369
+ *
370
+ * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
371
+ * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
372
+ *
373
+ * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
374
+ * @module
375
+ * @deprecated
376
+ */
377
+ /** @deprecated Use import from `noble/hashes/sha2` module */
378
+ const sha256$1 = sha256$2;
379
+ //#endregion
380
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/hash/sha256.js
381
+ function sha256(value, to_) {
382
+ const to = to_ || "hex";
383
+ const bytes = sha256$1(isHex(value, { strict: false }) ? toBytes(value) : value);
384
+ if (to === "bytes") return bytes;
385
+ return toHex(bytes);
386
+ }
387
+ //#endregion
388
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/commitmentToVersionedHash.js
389
+ /**
390
+ * Transform a commitment to it's versioned hash.
391
+ *
392
+ * @example
393
+ * ```ts
394
+ * import {
395
+ * blobsToCommitments,
396
+ * commitmentToVersionedHash,
397
+ * toBlobs
398
+ * } from 'viem'
399
+ * import { kzg } from './kzg'
400
+ *
401
+ * const blobs = toBlobs({ data: '0x1234' })
402
+ * const [commitment] = blobsToCommitments({ blobs, kzg })
403
+ * const versionedHash = commitmentToVersionedHash({ commitment })
404
+ * ```
405
+ */
406
+ function commitmentToVersionedHash(parameters) {
407
+ const { commitment, version = 1 } = parameters;
408
+ const to = parameters.to ?? (typeof commitment === "string" ? "hex" : "bytes");
409
+ const versionedHash = sha256(commitment, "bytes");
410
+ versionedHash.set([version], 0);
411
+ return to === "bytes" ? versionedHash : bytesToHex(versionedHash);
412
+ }
413
+ //#endregion
414
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/commitmentsToVersionedHashes.js
415
+ /**
416
+ * Transform a list of commitments to their versioned hashes.
417
+ *
418
+ * @example
419
+ * ```ts
420
+ * import {
421
+ * blobsToCommitments,
422
+ * commitmentsToVersionedHashes,
423
+ * toBlobs
424
+ * } from 'viem'
425
+ * import { kzg } from './kzg'
426
+ *
427
+ * const blobs = toBlobs({ data: '0x1234' })
428
+ * const commitments = blobsToCommitments({ blobs, kzg })
429
+ * const versionedHashes = commitmentsToVersionedHashes({ commitments })
430
+ * ```
431
+ */
432
+ function commitmentsToVersionedHashes(parameters) {
433
+ const { commitments, version } = parameters;
434
+ const to = parameters.to ?? (typeof commitments[0] === "string" ? "hex" : "bytes");
435
+ const hashes = [];
436
+ for (const commitment of commitments) hashes.push(commitmentToVersionedHash({
437
+ commitment,
438
+ to,
439
+ version
440
+ }));
441
+ return hashes;
442
+ }
443
+ //#endregion
444
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/constants/blob.js
445
+ /** Blob limit per transaction. */
446
+ const blobsPerTransaction = 6;
447
+ /** The number of field elements in a blob. */
448
+ const fieldElementsPerBlob = 4096;
449
+ /** The number of bytes in a blob. */
450
+ const bytesPerBlob = 32 * fieldElementsPerBlob;
451
+ /** Blob bytes limit per transaction. */
452
+ const maxBytesPerTransaction = bytesPerBlob * blobsPerTransaction - 1 - 1 * fieldElementsPerBlob * blobsPerTransaction;
453
+ //#endregion
454
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/blob.js
455
+ var BlobSizeTooLargeError = class extends BaseError {
456
+ constructor({ maxSize, size }) {
457
+ super("Blob size is too large.", {
458
+ metaMessages: [`Max: ${maxSize} bytes`, `Given: ${size} bytes`],
459
+ name: "BlobSizeTooLargeError"
460
+ });
461
+ }
462
+ };
463
+ var EmptyBlobError = class extends BaseError {
464
+ constructor() {
465
+ super("Blob data must not be empty.", { name: "EmptyBlobError" });
466
+ }
467
+ };
468
+ var InvalidVersionedHashSizeError = class extends BaseError {
469
+ constructor({ hash, size }) {
470
+ super(`Versioned hash "${hash}" size is invalid.`, {
471
+ metaMessages: ["Expected: 32", `Received: ${size}`],
472
+ name: "InvalidVersionedHashSizeError"
473
+ });
474
+ }
475
+ };
476
+ var InvalidVersionedHashVersionError = class extends BaseError {
477
+ constructor({ hash, version }) {
478
+ super(`Versioned hash "${hash}" version is invalid.`, {
479
+ metaMessages: [`Expected: 1`, `Received: ${version}`],
480
+ name: "InvalidVersionedHashVersionError"
481
+ });
482
+ }
483
+ };
484
+ //#endregion
485
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/toBlobs.js
486
+ /**
487
+ * Transforms arbitrary data to blobs.
488
+ *
489
+ * @example
490
+ * ```ts
491
+ * import { toBlobs, stringToHex } from 'viem'
492
+ *
493
+ * const blobs = toBlobs({ data: stringToHex('hello world') })
494
+ * ```
495
+ */
496
+ function toBlobs(parameters) {
497
+ const to = parameters.to ?? (typeof parameters.data === "string" ? "hex" : "bytes");
498
+ const data = typeof parameters.data === "string" ? hexToBytes(parameters.data) : parameters.data;
499
+ const size_ = size(data);
500
+ if (!size_) throw new EmptyBlobError();
501
+ if (size_ > 761855) throw new BlobSizeTooLargeError({
502
+ maxSize: maxBytesPerTransaction,
503
+ size: size_
504
+ });
505
+ const blobs = [];
506
+ let active = true;
507
+ let position = 0;
508
+ while (active) {
509
+ const blob = createCursor(new Uint8Array(bytesPerBlob));
510
+ let size = 0;
511
+ while (size < fieldElementsPerBlob) {
512
+ const bytes = data.slice(position, position + 31);
513
+ blob.pushByte(0);
514
+ blob.pushBytes(bytes);
515
+ if (bytes.length < 31) {
516
+ blob.pushByte(128);
517
+ active = false;
518
+ break;
519
+ }
520
+ size++;
521
+ position += 31;
522
+ }
523
+ blobs.push(blob);
524
+ }
525
+ return to === "bytes" ? blobs.map((x) => x.bytes) : blobs.map((x) => bytesToHex(x.bytes));
526
+ }
527
+ //#endregion
528
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/blob/toBlobSidecars.js
529
+ /**
530
+ * Transforms arbitrary data (or blobs, commitments, & proofs) into a sidecar array.
531
+ *
532
+ * @example
533
+ * ```ts
534
+ * import { toBlobSidecars, stringToHex } from 'viem'
535
+ *
536
+ * const sidecars = toBlobSidecars({ data: stringToHex('hello world') })
537
+ * ```
538
+ *
539
+ * @example
540
+ * ```ts
541
+ * import {
542
+ * blobsToCommitments,
543
+ * toBlobs,
544
+ * blobsToProofs,
545
+ * toBlobSidecars,
546
+ * stringToHex
547
+ * } from 'viem'
548
+ *
549
+ * const blobs = toBlobs({ data: stringToHex('hello world') })
550
+ * const commitments = blobsToCommitments({ blobs, kzg })
551
+ * const proofs = blobsToProofs({ blobs, commitments, kzg })
552
+ *
553
+ * const sidecars = toBlobSidecars({ blobs, commitments, proofs })
554
+ * ```
555
+ */
556
+ function toBlobSidecars(parameters) {
557
+ const { data, kzg, to } = parameters;
558
+ const blobs = parameters.blobs ?? toBlobs({
559
+ data,
560
+ to
561
+ });
562
+ const commitments = parameters.commitments ?? blobsToCommitments({
563
+ blobs,
564
+ kzg,
565
+ to
566
+ });
567
+ const proofs = parameters.proofs ?? blobsToProofs({
568
+ blobs,
569
+ commitments,
570
+ kzg,
571
+ to
572
+ });
573
+ const sidecars = [];
574
+ for (let i = 0; i < blobs.length; i++) sidecars.push({
575
+ blob: blobs[i],
576
+ commitment: commitments[i],
577
+ proof: proofs[i]
578
+ });
579
+ return sidecars;
580
+ }
581
+ //#endregion
582
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/chain.js
583
+ var InvalidChainIdError = class extends BaseError {
584
+ constructor({ chainId }) {
585
+ super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
586
+ }
587
+ };
588
+ //#endregion
589
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/errors/node.js
590
+ var ExecutionRevertedError = class extends BaseError {
591
+ constructor({ cause, message } = {}) {
592
+ const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
593
+ super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
594
+ cause,
595
+ name: "ExecutionRevertedError"
596
+ });
597
+ }
598
+ };
599
+ Object.defineProperty(ExecutionRevertedError, "code", {
600
+ enumerable: true,
601
+ configurable: true,
602
+ writable: true,
603
+ value: 3
604
+ });
605
+ Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
606
+ enumerable: true,
607
+ configurable: true,
608
+ writable: true,
609
+ value: /execution reverted|gas required exceeds allowance/
610
+ });
611
+ var FeeCapTooHighError = class extends BaseError {
612
+ constructor({ cause, maxFeePerGas } = {}) {
613
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
614
+ cause,
615
+ name: "FeeCapTooHighError"
616
+ });
617
+ }
618
+ };
619
+ Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
620
+ enumerable: true,
621
+ configurable: true,
622
+ writable: true,
623
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
624
+ });
625
+ var FeeCapTooLowError = class extends BaseError {
626
+ constructor({ cause, maxFeePerGas } = {}) {
627
+ super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
628
+ cause,
629
+ name: "FeeCapTooLowError"
630
+ });
631
+ }
632
+ };
633
+ Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
634
+ enumerable: true,
635
+ configurable: true,
636
+ writable: true,
637
+ value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
638
+ });
639
+ var NonceTooHighError = class extends BaseError {
640
+ constructor({ cause, nonce } = {}) {
641
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, {
642
+ cause,
643
+ name: "NonceTooHighError"
644
+ });
645
+ }
646
+ };
647
+ Object.defineProperty(NonceTooHighError, "nodeMessage", {
648
+ enumerable: true,
649
+ configurable: true,
650
+ writable: true,
651
+ value: /nonce too high/
652
+ });
653
+ var NonceTooLowError = class extends BaseError {
654
+ constructor({ cause, nonce } = {}) {
655
+ super([`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`, "Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"), {
656
+ cause,
657
+ name: "NonceTooLowError"
658
+ });
659
+ }
660
+ };
661
+ Object.defineProperty(NonceTooLowError, "nodeMessage", {
662
+ enumerable: true,
663
+ configurable: true,
664
+ writable: true,
665
+ value: /nonce too low|transaction already imported|already known/
666
+ });
667
+ var NonceMaxValueError = class extends BaseError {
668
+ constructor({ cause, nonce } = {}) {
669
+ super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, {
670
+ cause,
671
+ name: "NonceMaxValueError"
672
+ });
673
+ }
674
+ };
675
+ Object.defineProperty(NonceMaxValueError, "nodeMessage", {
676
+ enumerable: true,
677
+ configurable: true,
678
+ writable: true,
679
+ value: /nonce has max value/
680
+ });
681
+ var InsufficientFundsError = class extends BaseError {
682
+ constructor({ cause } = {}) {
683
+ super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"), {
684
+ cause,
685
+ metaMessages: [
686
+ "This error could arise when the account does not have enough funds to:",
687
+ " - pay for the total gas fee,",
688
+ " - pay for the value to send.",
689
+ " ",
690
+ "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
691
+ " - `gas` is the amount of gas needed for transaction to execute,",
692
+ " - `gas fee` is the gas fee,",
693
+ " - `value` is the amount of ether to send to the recipient."
694
+ ],
695
+ name: "InsufficientFundsError"
696
+ });
697
+ }
698
+ };
699
+ Object.defineProperty(InsufficientFundsError, "nodeMessage", {
700
+ enumerable: true,
701
+ configurable: true,
702
+ writable: true,
703
+ value: /insufficient funds|exceeds transaction sender account balance/
704
+ });
705
+ var IntrinsicGasTooHighError = class extends BaseError {
706
+ constructor({ cause, gas } = {}) {
707
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
708
+ cause,
709
+ name: "IntrinsicGasTooHighError"
710
+ });
711
+ }
712
+ };
713
+ Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
714
+ enumerable: true,
715
+ configurable: true,
716
+ writable: true,
717
+ value: /intrinsic gas too high|gas limit reached/
718
+ });
719
+ var IntrinsicGasTooLowError = class extends BaseError {
720
+ constructor({ cause, gas } = {}) {
721
+ super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
722
+ cause,
723
+ name: "IntrinsicGasTooLowError"
724
+ });
725
+ }
726
+ };
727
+ Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
728
+ enumerable: true,
729
+ configurable: true,
730
+ writable: true,
731
+ value: /intrinsic gas too low/
732
+ });
733
+ var TransactionTypeNotSupportedError = class extends BaseError {
734
+ constructor({ cause }) {
735
+ super("The transaction type is not supported for this chain.", {
736
+ cause,
737
+ name: "TransactionTypeNotSupportedError"
738
+ });
739
+ }
740
+ };
741
+ Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
742
+ enumerable: true,
743
+ configurable: true,
744
+ writable: true,
745
+ value: /transaction type not valid/
746
+ });
747
+ var TipAboveFeeCapError = class extends BaseError {
748
+ constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
749
+ super([`The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`].join("\n"), {
750
+ cause,
751
+ name: "TipAboveFeeCapError"
752
+ });
753
+ }
754
+ };
755
+ Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
756
+ enumerable: true,
757
+ configurable: true,
758
+ writable: true,
759
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
760
+ });
761
+ //#endregion
762
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/transaction/assertTransaction.js
763
+ function assertTransactionEIP7702(transaction) {
764
+ const { authorizationList } = transaction;
765
+ if (authorizationList) for (const authorization of authorizationList) {
766
+ const { chainId } = authorization;
767
+ const address = authorization.address;
768
+ if (!isAddress(address)) throw new InvalidAddressError({ address });
769
+ if (chainId < 0) throw new InvalidChainIdError({ chainId });
770
+ }
771
+ assertTransactionEIP1559(transaction);
772
+ }
773
+ function assertTransactionEIP4844(transaction) {
774
+ const { blobVersionedHashes } = transaction;
775
+ if (blobVersionedHashes) {
776
+ if (blobVersionedHashes.length === 0) throw new EmptyBlobError();
777
+ for (const hash of blobVersionedHashes) {
778
+ const size_ = size(hash);
779
+ const version = hexToNumber(slice(hash, 0, 1));
780
+ if (size_ !== 32) throw new InvalidVersionedHashSizeError({
781
+ hash,
782
+ size: size_
783
+ });
784
+ if (version !== 1) throw new InvalidVersionedHashVersionError({
785
+ hash,
786
+ version
787
+ });
788
+ }
789
+ }
790
+ assertTransactionEIP1559(transaction);
791
+ }
792
+ function assertTransactionEIP1559(transaction) {
793
+ const { chainId, maxPriorityFeePerGas, maxFeePerGas, to } = transaction;
794
+ if (chainId <= 0) throw new InvalidChainIdError({ chainId });
795
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to });
796
+ if (maxFeePerGas && maxFeePerGas > maxUint256) throw new FeeCapTooHighError({ maxFeePerGas });
797
+ if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas) throw new TipAboveFeeCapError({
798
+ maxFeePerGas,
799
+ maxPriorityFeePerGas
800
+ });
801
+ }
802
+ function assertTransactionEIP2930(transaction) {
803
+ const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
804
+ if (chainId <= 0) throw new InvalidChainIdError({ chainId });
805
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to });
806
+ if (maxPriorityFeePerGas || maxFeePerGas) throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
807
+ if (gasPrice && gasPrice > maxUint256) throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
808
+ }
809
+ function assertTransactionLegacy(transaction) {
810
+ const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
811
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to });
812
+ if (typeof chainId !== "undefined" && chainId <= 0) throw new InvalidChainIdError({ chainId });
813
+ if (maxPriorityFeePerGas || maxFeePerGas) throw new BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
814
+ if (gasPrice && gasPrice > maxUint256) throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
815
+ }
816
+ //#endregion
817
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/transaction/getTransactionType.js
818
+ function getTransactionType(transaction) {
819
+ if (transaction.type) return transaction.type;
820
+ if (typeof transaction.authorizationList !== "undefined") return "eip7702";
821
+ if (typeof transaction.blobs !== "undefined" || typeof transaction.blobVersionedHashes !== "undefined" || typeof transaction.maxFeePerBlobGas !== "undefined" || typeof transaction.sidecars !== "undefined") return "eip4844";
822
+ if (typeof transaction.maxFeePerGas !== "undefined" || typeof transaction.maxPriorityFeePerGas !== "undefined") return "eip1559";
823
+ if (typeof transaction.gasPrice !== "undefined") {
824
+ if (typeof transaction.accessList !== "undefined") return "eip2930";
825
+ return "legacy";
826
+ }
827
+ throw new InvalidSerializableTransactionError({ transaction });
828
+ }
829
+ //#endregion
830
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/transaction/serializeAccessList.js
831
+ function serializeAccessList(accessList) {
832
+ if (!accessList || accessList.length === 0) return [];
833
+ const serializedAccessList = [];
834
+ for (let i = 0; i < accessList.length; i++) {
835
+ const { address, storageKeys } = accessList[i];
836
+ for (let j = 0; j < storageKeys.length; j++) if (storageKeys[j].length - 2 !== 64) throw new InvalidStorageKeySizeError({ storageKey: storageKeys[j] });
837
+ if (!isAddress(address, { strict: false })) throw new InvalidAddressError({ address });
838
+ serializedAccessList.push([address, storageKeys]);
839
+ }
840
+ return serializedAccessList;
841
+ }
842
+ //#endregion
843
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/transaction/serializeTransaction.js
844
+ function serializeTransaction$1(transaction, signature) {
845
+ const type = getTransactionType(transaction);
846
+ if (type === "eip1559") return serializeTransactionEIP1559(transaction, signature);
847
+ if (type === "eip2930") return serializeTransactionEIP2930(transaction, signature);
848
+ if (type === "eip4844") return serializeTransactionEIP4844(transaction, signature);
849
+ if (type === "eip7702") return serializeTransactionEIP7702(transaction, signature);
850
+ return serializeTransactionLegacy(transaction, signature);
851
+ }
852
+ function serializeTransactionEIP7702(transaction, signature) {
853
+ const { authorizationList, chainId, gas, nonce, to, value, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
854
+ assertTransactionEIP7702(transaction);
855
+ const serializedAccessList = serializeAccessList(accessList);
856
+ const serializedAuthorizationList = serializeAuthorizationList(authorizationList);
857
+ return concatHex(["0x04", toRlp([
858
+ numberToHex(chainId),
859
+ nonce ? numberToHex(nonce) : "0x",
860
+ maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : "0x",
861
+ maxFeePerGas ? numberToHex(maxFeePerGas) : "0x",
862
+ gas ? numberToHex(gas) : "0x",
863
+ to ?? "0x",
864
+ value ? numberToHex(value) : "0x",
865
+ data ?? "0x",
866
+ serializedAccessList,
867
+ serializedAuthorizationList,
868
+ ...toYParitySignatureArray(transaction, signature)
869
+ ])]);
870
+ }
871
+ function serializeTransactionEIP4844(transaction, signature) {
872
+ const { chainId, gas, nonce, to, value, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
873
+ assertTransactionEIP4844(transaction);
874
+ let blobVersionedHashes = transaction.blobVersionedHashes;
875
+ let sidecars = transaction.sidecars;
876
+ if (transaction.blobs && (typeof blobVersionedHashes === "undefined" || typeof sidecars === "undefined")) {
877
+ const blobs = typeof transaction.blobs[0] === "string" ? transaction.blobs : transaction.blobs.map((x) => bytesToHex(x));
878
+ const kzg = transaction.kzg;
879
+ const commitments = blobsToCommitments({
880
+ blobs,
881
+ kzg
882
+ });
883
+ if (typeof blobVersionedHashes === "undefined") blobVersionedHashes = commitmentsToVersionedHashes({ commitments });
884
+ if (typeof sidecars === "undefined") sidecars = toBlobSidecars({
885
+ blobs,
886
+ commitments,
887
+ proofs: blobsToProofs({
888
+ blobs,
889
+ commitments,
890
+ kzg
891
+ })
892
+ });
893
+ }
894
+ const serializedAccessList = serializeAccessList(accessList);
895
+ const serializedTransaction = [
896
+ numberToHex(chainId),
897
+ nonce ? numberToHex(nonce) : "0x",
898
+ maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : "0x",
899
+ maxFeePerGas ? numberToHex(maxFeePerGas) : "0x",
900
+ gas ? numberToHex(gas) : "0x",
901
+ to ?? "0x",
902
+ value ? numberToHex(value) : "0x",
903
+ data ?? "0x",
904
+ serializedAccessList,
905
+ maxFeePerBlobGas ? numberToHex(maxFeePerBlobGas) : "0x",
906
+ blobVersionedHashes ?? [],
907
+ ...toYParitySignatureArray(transaction, signature)
908
+ ];
909
+ const blobs = [];
910
+ const commitments = [];
911
+ const proofs = [];
912
+ if (sidecars) for (let i = 0; i < sidecars.length; i++) {
913
+ const { blob, commitment, proof } = sidecars[i];
914
+ blobs.push(blob);
915
+ commitments.push(commitment);
916
+ proofs.push(proof);
917
+ }
918
+ return concatHex(["0x03", sidecars ? toRlp([
919
+ serializedTransaction,
920
+ blobs,
921
+ commitments,
922
+ proofs
923
+ ]) : toRlp(serializedTransaction)]);
924
+ }
925
+ function serializeTransactionEIP1559(transaction, signature) {
926
+ const { chainId, gas, nonce, to, value, maxFeePerGas, maxPriorityFeePerGas, accessList, data } = transaction;
927
+ assertTransactionEIP1559(transaction);
928
+ const serializedAccessList = serializeAccessList(accessList);
929
+ const serializedTransaction = [
930
+ numberToHex(chainId),
931
+ nonce ? numberToHex(nonce) : "0x",
932
+ maxPriorityFeePerGas ? numberToHex(maxPriorityFeePerGas) : "0x",
933
+ maxFeePerGas ? numberToHex(maxFeePerGas) : "0x",
934
+ gas ? numberToHex(gas) : "0x",
935
+ to ?? "0x",
936
+ value ? numberToHex(value) : "0x",
937
+ data ?? "0x",
938
+ serializedAccessList,
939
+ ...toYParitySignatureArray(transaction, signature)
940
+ ];
941
+ return concatHex(["0x02", toRlp(serializedTransaction)]);
942
+ }
943
+ function serializeTransactionEIP2930(transaction, signature) {
944
+ const { chainId, gas, data, nonce, to, value, accessList, gasPrice } = transaction;
945
+ assertTransactionEIP2930(transaction);
946
+ const serializedAccessList = serializeAccessList(accessList);
947
+ const serializedTransaction = [
948
+ numberToHex(chainId),
949
+ nonce ? numberToHex(nonce) : "0x",
950
+ gasPrice ? numberToHex(gasPrice) : "0x",
951
+ gas ? numberToHex(gas) : "0x",
952
+ to ?? "0x",
953
+ value ? numberToHex(value) : "0x",
954
+ data ?? "0x",
955
+ serializedAccessList,
956
+ ...toYParitySignatureArray(transaction, signature)
957
+ ];
958
+ return concatHex(["0x01", toRlp(serializedTransaction)]);
959
+ }
960
+ function serializeTransactionLegacy(transaction, signature) {
961
+ const { chainId = 0, gas, data, nonce, to, value, gasPrice } = transaction;
962
+ assertTransactionLegacy(transaction);
963
+ let serializedTransaction = [
964
+ nonce ? numberToHex(nonce) : "0x",
965
+ gasPrice ? numberToHex(gasPrice) : "0x",
966
+ gas ? numberToHex(gas) : "0x",
967
+ to ?? "0x",
968
+ value ? numberToHex(value) : "0x",
969
+ data ?? "0x"
970
+ ];
971
+ if (signature) {
972
+ const v = (() => {
973
+ if (signature.v >= 35n) {
974
+ if ((signature.v - 35n) / 2n > 0) return signature.v;
975
+ return 27n + (signature.v === 35n ? 0n : 1n);
976
+ }
977
+ if (chainId > 0) return BigInt(chainId * 2) + BigInt(35n + signature.v - 27n);
978
+ const v = 27n + (signature.v === 27n ? 0n : 1n);
979
+ if (signature.v !== v) throw new InvalidLegacyVError({ v: signature.v });
980
+ return v;
981
+ })();
982
+ const r = trim(signature.r);
983
+ const s = trim(signature.s);
984
+ serializedTransaction = [
985
+ ...serializedTransaction,
986
+ numberToHex(v),
987
+ r === "0x00" ? "0x" : r,
988
+ s === "0x00" ? "0x" : s
989
+ ];
990
+ } else if (chainId > 0) serializedTransaction = [
991
+ ...serializedTransaction,
992
+ numberToHex(chainId),
993
+ "0x",
994
+ "0x"
995
+ ];
996
+ return toRlp(serializedTransaction);
997
+ }
998
+ function toYParitySignatureArray(transaction, signature_) {
999
+ const signature = signature_ ?? transaction;
1000
+ const { v, yParity } = signature;
1001
+ if (typeof signature.r === "undefined") return [];
1002
+ if (typeof signature.s === "undefined") return [];
1003
+ if (typeof v === "undefined" && typeof yParity === "undefined") return [];
1004
+ const r = trim(signature.r);
1005
+ const s = trim(signature.s);
1006
+ return [
1007
+ (() => {
1008
+ if (typeof yParity === "number") return yParity ? numberToHex(1) : "0x";
1009
+ if (v === 0n) return "0x";
1010
+ if (v === 1n) return numberToHex(1);
1011
+ return v === 27n ? "0x" : numberToHex(1);
1012
+ })(),
1013
+ r === "0x00" ? "0x" : r,
1014
+ s === "0x00" ? "0x" : s
1015
+ ];
1016
+ }
1017
+ //#endregion
1018
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/op-stack/contracts.js
1019
+ /**
1020
+ * Predeploy contracts for OP Stack.
1021
+ * @see https://github.com/ethereum-optimism/optimism/blob/develop/specs/predeploys.md
1022
+ */
1023
+ const contracts = {
1024
+ gasPriceOracle: { address: "0x420000000000000000000000000000000000000F" },
1025
+ l1Block: { address: "0x4200000000000000000000000000000000000015" },
1026
+ l2CrossDomainMessenger: { address: "0x4200000000000000000000000000000000000007" },
1027
+ l2Erc721Bridge: { address: "0x4200000000000000000000000000000000000014" },
1028
+ l2StandardBridge: { address: "0x4200000000000000000000000000000000000010" },
1029
+ l2ToL1MessagePasser: { address: "0x4200000000000000000000000000000000000016" }
1030
+ };
1031
+ //#endregion
1032
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/op-stack/formatters.js
1033
+ const formatters = {
1034
+ block: /*#__PURE__*/ defineBlock({ format(args) {
1035
+ return {
1036
+ transactions: args.transactions?.map((transaction) => {
1037
+ if (typeof transaction === "string") return transaction;
1038
+ const formatted = formatTransaction(transaction);
1039
+ if (formatted.typeHex === "0x7e") {
1040
+ formatted.isSystemTx = transaction.isSystemTx;
1041
+ formatted.mint = transaction.mint ? hexToBigInt(transaction.mint) : void 0;
1042
+ formatted.sourceHash = transaction.sourceHash;
1043
+ formatted.type = "deposit";
1044
+ }
1045
+ return formatted;
1046
+ }),
1047
+ stateRoot: args.stateRoot
1048
+ };
1049
+ } }),
1050
+ transaction: /*#__PURE__*/ defineTransaction({ format(args) {
1051
+ const transaction = {};
1052
+ if (args.type === "0x7e") {
1053
+ transaction.isSystemTx = args.isSystemTx;
1054
+ transaction.mint = args.mint ? hexToBigInt(args.mint) : void 0;
1055
+ transaction.sourceHash = args.sourceHash;
1056
+ transaction.type = "deposit";
1057
+ }
1058
+ return transaction;
1059
+ } }),
1060
+ transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({ format(args) {
1061
+ return {
1062
+ ...args.depositNonce ? { depositNonce: hexToBigInt(args.depositNonce) } : {},
1063
+ ...args.depositReceiptVersion ? { depositReceiptVersion: hexToNumber(args.depositReceiptVersion) } : {},
1064
+ l1GasPrice: args.l1GasPrice ? hexToBigInt(args.l1GasPrice) : null,
1065
+ l1GasUsed: args.l1GasUsed ? hexToBigInt(args.l1GasUsed) : null,
1066
+ l1Fee: args.l1Fee ? hexToBigInt(args.l1Fee) : null,
1067
+ l1FeeScalar: args.l1FeeScalar ? Number(args.l1FeeScalar) : null
1068
+ };
1069
+ } })
1070
+ };
1071
+ //#endregion
1072
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/op-stack/serializers.js
1073
+ function serializeTransaction(transaction, signature) {
1074
+ if (isDeposit(transaction)) return serializeTransactionDeposit(transaction);
1075
+ return serializeTransaction$1(transaction, signature);
1076
+ }
1077
+ const serializers = { transaction: serializeTransaction };
1078
+ function serializeTransactionDeposit(transaction) {
1079
+ assertTransactionDeposit(transaction);
1080
+ const { sourceHash, data, from, gas, isSystemTx, mint, to, value } = transaction;
1081
+ const serializedTransaction = [
1082
+ sourceHash,
1083
+ from,
1084
+ to ?? "0x",
1085
+ mint ? toHex(mint) : "0x",
1086
+ value ? toHex(value) : "0x",
1087
+ gas ? toHex(gas) : "0x",
1088
+ isSystemTx ? "0x1" : "0x",
1089
+ data ?? "0x"
1090
+ ];
1091
+ return concatHex(["0x7e", toRlp(serializedTransaction)]);
1092
+ }
1093
+ function isDeposit(transaction) {
1094
+ if (transaction.type === "deposit") return true;
1095
+ if (typeof transaction.sourceHash !== "undefined") return true;
1096
+ return false;
1097
+ }
1098
+ function assertTransactionDeposit(transaction) {
1099
+ const { from, to } = transaction;
1100
+ if (from && !isAddress(from)) throw new InvalidAddressError({ address: from });
1101
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to });
1102
+ }
1103
+ //#endregion
1104
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/op-stack/chainConfig.js
1105
+ const chainConfig = {
1106
+ blockTime: 2e3,
1107
+ contracts,
1108
+ formatters,
1109
+ serializers
1110
+ };
1111
+ //#endregion
1112
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/chains/definitions/base.js
1113
+ const sourceId$1 = 1;
1114
+ const base = /*#__PURE__*/ defineChain({
1115
+ ...chainConfig,
1116
+ id: 8453,
1117
+ name: "Base",
1118
+ nativeCurrency: {
1119
+ name: "Ether",
1120
+ symbol: "ETH",
1121
+ decimals: 18
1122
+ },
1123
+ rpcUrls: { default: { http: ["https://mainnet.base.org"] } },
1124
+ blockExplorers: { default: {
1125
+ name: "Basescan",
1126
+ url: "https://basescan.org",
1127
+ apiUrl: "https://api.basescan.org/api"
1128
+ } },
1129
+ contracts: {
1130
+ ...chainConfig.contracts,
1131
+ disputeGameFactory: { [sourceId$1]: { address: "0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e" } },
1132
+ l2OutputOracle: { [sourceId$1]: { address: "0x56315b90c40730925ec5485cf004d835058518A0" } },
1133
+ multicall3: {
1134
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
1135
+ blockCreated: 5022
1136
+ },
1137
+ portal: { [sourceId$1]: {
1138
+ address: "0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",
1139
+ blockCreated: 17482143
1140
+ } },
1141
+ l1StandardBridge: { [sourceId$1]: {
1142
+ address: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
1143
+ blockCreated: 17482143
1144
+ } }
1145
+ },
1146
+ sourceId: sourceId$1
1147
+ });
1148
+ ({ ...base });
1149
+ //#endregion
1150
+ //#region ../../node_modules/.pnpm/viem@2.55.18_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/chains/definitions/baseSepolia.js
1151
+ const sourceId = 11155111;
1152
+ const baseSepolia = /*#__PURE__*/ defineChain({
1153
+ ...chainConfig,
1154
+ id: 84532,
1155
+ network: "base-sepolia",
1156
+ name: "Base Sepolia",
1157
+ nativeCurrency: {
1158
+ name: "Sepolia Ether",
1159
+ symbol: "ETH",
1160
+ decimals: 18
1161
+ },
1162
+ rpcUrls: { default: { http: ["https://sepolia.base.org"] } },
1163
+ blockExplorers: { default: {
1164
+ name: "Basescan",
1165
+ url: "https://sepolia.basescan.org",
1166
+ apiUrl: "https://api-sepolia.basescan.org/api"
1167
+ } },
1168
+ contracts: {
1169
+ ...chainConfig.contracts,
1170
+ disputeGameFactory: { [sourceId]: { address: "0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1" } },
1171
+ l2OutputOracle: { [sourceId]: { address: "0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254" } },
1172
+ portal: { [sourceId]: {
1173
+ address: "0x49f53e41452c74589e85ca1677426ba426459e85",
1174
+ blockCreated: 4446677
1175
+ } },
1176
+ l1StandardBridge: { [sourceId]: {
1177
+ address: "0xfd0Bf71F60660E2f608ed56e1659C450eB113120",
1178
+ blockCreated: 4446677
1179
+ } },
1180
+ multicall3: {
1181
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
1182
+ blockCreated: 1059647
1183
+ }
1184
+ },
1185
+ testnet: true,
1186
+ sourceId
1187
+ });
1188
+ ({ ...baseSepolia });
1189
+ //#endregion
1190
+ //#region ../../packages/protocol/src/evm/networks.ts
1191
+ const CHAINS = [base, baseSepolia];
1192
+ /** The network for a chain Capxul runs on, or null for any other chain. */
1193
+ function networkForChain(chainId) {
1194
+ const chain = CHAINS.find((candidate) => candidate.id === chainId);
1195
+ return chain === void 0 ? null : {
1196
+ chainId,
1197
+ name: chain.name,
1198
+ explorerUrl: chain.blockExplorers.default.url
1199
+ };
1200
+ }
1201
+ //#endregion
1202
+ //#region src/runtime/where.ts
1203
+ /** The bundled staging deployment's bootstrap origin. */
1204
+ const STAGING_ORIGIN = "https://api.staging.capxul.com";
1205
+ /** The standing local DevNet's bootstrap (Convex site) origin. */
1206
+ const DEVNET_ORIGIN = "http://127.0.0.1:3211";
1207
+ /** Environments `use env` and `--env` accept. Production is not wired yet. */
1208
+ const ENVIRONMENT_NAMES = [
1209
+ "staging",
1210
+ "devnet",
1211
+ "production"
1212
+ ];
1213
+ const EMPTY_WHERE = { version: 1 };
1214
+ const nonEmpty = (value) => typeof value === "string" && value !== "" ? value : void 0;
1215
+ const parseOrganization = (value) => {
1216
+ if (value === null) return null;
1217
+ if (!isRecord(value)) return void 0;
1218
+ const [id, handle, name] = [
1219
+ nonEmpty(value.id),
1220
+ nonEmpty(value.handle),
1221
+ nonEmpty(value.name)
1222
+ ];
1223
+ return id === void 0 || handle === void 0 || name === void 0 ? void 0 : {
1224
+ id,
1225
+ handle,
1226
+ name,
1227
+ safe: nonEmpty(value.safe) ?? null
1228
+ };
1229
+ };
1230
+ const parseOrigin = (value) => {
1231
+ if (!isRecord(value)) return {};
1232
+ const fields = {
1233
+ email: nonEmpty(value.email),
1234
+ authUserId: nonEmpty(value.authUserId),
1235
+ pending: nonEmpty(value.pending),
1236
+ safe: nonEmpty(value.safe),
1237
+ chainId: Number.isSafeInteger(value.chainId) ? Number(value.chainId) : void 0,
1238
+ org: parseOrganization(value.org)
1239
+ };
1240
+ return Object.fromEntries(Object.entries(fields).filter(([, field]) => field !== void 0));
1241
+ };
1242
+ /** Read `context.json` content. Damaged or foreign content reads as empty: it is a cache. */
1243
+ const parseWhere = (content) => {
1244
+ if (content === null) return EMPTY_WHERE;
1245
+ try {
1246
+ const value = JSON.parse(content);
1247
+ if (!isRecord(value) || value.version !== 1) return EMPTY_WHERE;
1248
+ const origins = isRecord(value.origins) ? value.origins : {};
1249
+ const env = nonEmpty(value.env);
1250
+ return {
1251
+ version: 1,
1252
+ ...env === void 0 ? {} : { env },
1253
+ origins: Object.fromEntries(Object.entries(origins).map(([origin, saved]) => [origin, parseOrigin(saved)]))
1254
+ };
1255
+ } catch {
1256
+ return EMPTY_WHERE;
1257
+ }
1258
+ };
1259
+ /** The CLI home folder, from the same variables the runtime configuration reads. */
1260
+ const cliHome = (env, join) => env.CAPXUL_CLI_HOME ?? (env.XDG_CONFIG_HOME === void 0 ? env.HOME === void 0 ? void 0 : join(env.HOME, ".config", "capxul", "cli") : join(env.XDG_CONFIG_HOME, "capxul", "cli"));
1261
+ /** Every value of a `--name value` or `--name=value` flag, before any `--`. */
1262
+ const flagValues = (args, name) => {
1263
+ const end = args.indexOf("--");
1264
+ const flags = end < 0 ? args : args.slice(0, end);
1265
+ return flags.flatMap((arg, index) => arg.startsWith(`--${name}=`) ? [arg.slice(name.length + 3)] : arg === `--${name}` && flags[index + 1] !== void 0 ? [flags[index + 1]] : []);
1266
+ };
1267
+ /** The last value of one flag, as the parser reads it. */
1268
+ const flagValue = (args, name) => flagValues(args, name).at(-1);
1269
+ /**
1270
+ * The `--org` and `--env` a person typed, for a suggested command line: every
1271
+ * command takes them, and without them the suggestion acts somewhere else or
1272
+ * refuses (`org payroll run`). A value that is not plain is not echoed.
1273
+ */
1274
+ const scopeArgs = (args) => ["org", "env"].flatMap((name) => {
1275
+ const value = flagValue(args, name);
1276
+ return value !== void 0 && /^[\w.@:+-]{1,64}$/u.test(value) ? [`--${name}`, value] : [];
1277
+ });
1278
+ const isLoopback = (hostname) => hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
1279
+ /** What an origin points at: bundled staging, the local DevNet, another loopback backend, or custom. */
1280
+ const environmentOf = (origin) => {
1281
+ if (origin === "https://api.staging.capxul.com") return "staging";
1282
+ if (origin === "http://127.0.0.1:3211") return "devnet";
1283
+ return URL.canParse(origin) && isLoopback(new URL(origin).hostname) ? "local" : "custom";
1284
+ };
1285
+ /**
1286
+ * Select the deployment: `--env`, then `CAPXUL_ENV`, then `CAPXUL_BOOTSTRAP_URL`,
1287
+ * then the environment `use env` saved, then staging.
1288
+ */
1289
+ const chooseEnvironment = (input) => {
1290
+ const named = (name, source) => {
1291
+ if (name === "staging") return {
1292
+ origin: STAGING_ORIGIN,
1293
+ source
1294
+ };
1295
+ if (name === "devnet") return {
1296
+ origin: DEVNET_ORIGIN,
1297
+ source
1298
+ };
1299
+ if (name === "production") return { refusal: "Production is not available in this CLI yet. Use staging or devnet." };
1300
+ return { refusal: `Unknown environment "${name}". Use one of: staging, devnet.` };
1301
+ };
1302
+ if (input.flag !== void 0) return named(input.flag, "flag");
1303
+ if (input.variable !== void 0 && input.variable !== "") return named(input.variable, "env");
1304
+ if (input.bootstrapUrl !== void 0 && input.bootstrapUrl !== "") return {
1305
+ origin: input.bootstrapUrl,
1306
+ source: "env"
1307
+ };
1308
+ if (input.saved !== void 0) return named(input.saved, "saved");
1309
+ return {
1310
+ origin: STAGING_ORIGIN,
1311
+ source: "default"
1312
+ };
1313
+ };
1314
+ /** The network's name, from the chain Capxul data names. */
1315
+ const networkName = (chainId) => chainId === null || chainId === void 0 ? null : networkForChain(chainId)?.name ?? `Chain ${chainId}`;
1316
+ /** The Organization `--org`, else `CAPXUL_ORG`, names for one command. */
1317
+ const explicitOrganization = (flag, variable) => flag !== void 0 ? {
1318
+ value: flag,
1319
+ source: "flag"
1320
+ } : variable === void 0 || variable === "" ? void 0 : {
1321
+ value: variable,
1322
+ source: "env"
1323
+ };
1324
+ /** Who you act as: `--org` or `CAPXUL_ORG`, else the saved Organization, else yourself. */
1325
+ const actorOf = (saved, explicit) => {
1326
+ if (explicit === void 0) {
1327
+ const org = saved.org;
1328
+ if (org === null || org === void 0) return { actingAs: {
1329
+ kind: "personal",
1330
+ source: org === null ? "saved" : "default"
1331
+ } };
1332
+ return {
1333
+ known: org,
1334
+ actingAs: {
1335
+ kind: "organization",
1336
+ ...org,
1337
+ source: "saved"
1338
+ }
1339
+ };
1340
+ }
1341
+ const wanted = explicit.value.replace(/^@/u, "").toLowerCase();
1342
+ const known = saved.org?.handle.toLowerCase() === wanted || saved.org?.id === explicit.value ? saved.org : void 0;
1343
+ return {
1344
+ known,
1345
+ actingAs: {
1346
+ kind: "organization",
1347
+ handle: known?.handle ?? explicit.value,
1348
+ name: known?.name ?? null,
1349
+ id: known?.id ?? null,
1350
+ source: explicit.source
1351
+ }
1352
+ };
1353
+ };
1354
+ /** Combine the selected deployment, an explicit Organization, and what this machine saved. */
1355
+ const describeWhere = (input) => {
1356
+ const saved = input.saved.origins?.[input.origin] ?? {};
1357
+ const user = saved.email === void 0 ? null : { email: saved.email };
1358
+ const { known, actingAs: actor } = actorOf(saved, input.explicitOrg);
1359
+ const actingAs = actor.kind === "personal" ? actor : {
1360
+ kind: actor.kind,
1361
+ handle: actor.handle,
1362
+ name: actor.name,
1363
+ id: actor.id,
1364
+ source: actor.source
1365
+ };
1366
+ const chainId = saved.chainId ?? null;
1367
+ return {
1368
+ user,
1369
+ actingAs,
1370
+ safe: actingAs.kind === "personal" ? saved.safe ?? null : known?.safe ?? null,
1371
+ env: {
1372
+ name: environmentOf(input.origin),
1373
+ origin: input.origin,
1374
+ source: input.envSource,
1375
+ network: networkName(chainId),
1376
+ chainId
1377
+ }
1378
+ };
1379
+ };
1380
+ //#endregion
1381
+ //#region src/runtime/where-view.ts
1382
+ const shortAddress = (address) => /^0x[0-9a-fA-F]{40}$/u.test(address) ? `${address.slice(0, 6)}…${address.slice(-4)}` : address;
1383
+ /** Saved names come from other clients: keep terminal control characters out of them. */
1384
+ const printable = (value) => value.replace(/[\p{Cc}\p{Cf}]/gu, "?");
1385
+ const actorLabel = (where) => where.actingAs.kind === "personal" ? "Personal" : printable(where.actingAs.name ?? where.actingAs.handle);
1386
+ const PLAIN = {
1387
+ highlight: (text) => text,
1388
+ dim: (text) => text,
1389
+ bad: (text) => text,
1390
+ good: (text) => text
1391
+ };
1392
+ const COLOR = {
1393
+ highlight: (text) => `\u001b[33m${text}\u001b[39m`,
1394
+ dim: (text) => `\u001b[2m${text}\u001b[22m`,
1395
+ bad: (text) => `\u001b[31m${text}\u001b[39m`,
1396
+ good: (text) => `\u001b[32m${text}\u001b[39m`
1397
+ };
1398
+ const styleFor = (tty, env) => tty && (env.NO_COLOR === void 0 || env.NO_COLOR === "") ? COLOR : PLAIN;
1399
+ /** `▸ Acme Ltd · staging · Base Sepolia`. Production is the normal case: no label. */
1400
+ const headerLine = (where, style) => [
1401
+ `▸ ${actorLabel(where)}`,
1402
+ ...where.env.name === "production" ? [] : [style.highlight(where.env.name)],
1403
+ ...where.env.network === null ? [] : [where.env.network]
1404
+ ].join(" · ");
1405
+ /** The `whoami` table. Values are padded before styling so columns stay aligned. */
1406
+ const whoamiLines = (where, style) => {
1407
+ const row = (label, value, note, styled = value) => `${label.padEnd(11)}${note === void 0 || note === "default" ? styled : `${styled}${" ".repeat(Math.max(2, 23 - value.length))}${style.dim(note)}`}`;
1408
+ const acting = where.actingAs.kind === "personal" ? "yourself" : `${printable(where.actingAs.name ?? where.actingAs.handle)} (org)`;
1409
+ const network = where.env.network === null ? "" : ` · ${where.env.network}`;
1410
+ return [
1411
+ row("user", where.user === null ? "not signed in · capxul auth login" : printable(where.user.email)),
1412
+ row("acting as", acting, where.actingAs.source),
1413
+ ...where.safe === null ? [] : [row("safe", shortAddress(where.safe))],
1414
+ row("env", `${where.env.name}${network}`, where.env.source, `${style.highlight(where.env.name)}${network}`)
1415
+ ];
1416
+ };
1417
+ //#endregion
1418
+ export { scopeArgs as _, DEVNET_ORIGIN as a, chooseEnvironment as c, environmentOf as d, explicitOrganization as f, parseWhere as g, networkName as h, whoamiLines as i, cliHome as l, flagValues as m, headerLine as n, ENVIRONMENT_NAMES as o, flagValue as p, styleFor as r, STAGING_ORIGIN as s, PLAIN as t, describeWhere as u };
1419
+
1420
+ //# sourceMappingURL=where-view-DuGbrSLp.mjs.map