@hashspan/core 0.7.0 → 0.9.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.
package/dist/index.d.cts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Attributes, Context, MeterProvider, TimeInput, TracerProvider } from "@opentelemetry/api";
2
2
  //#region src/types.d.ts
3
3
  /**
4
- * How wallet addresses are recorded. See
5
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0004-privacy-defaults.md.
4
+ * How wallet addresses are recorded: `raw` in lower case, `hashed` as a hash of the lower-cased address, `off` not at
5
+ * all. See
6
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0004-privacy-defaults.md.
6
7
  */
7
8
  type AddressMode = "raw" | "hashed" | "off";
8
9
  /**
9
10
  * How error messages are recorded on exception events and span status. See
10
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0006-error-privacy.md.
11
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0006-error-privacy.md.
11
12
  * - `off`: error type only
12
13
  * - `sanitized`: first line, addresses per address mode, other long hex data removed
13
14
  * - `raw`: full message and stack trace, as thrown
@@ -66,7 +67,7 @@ interface TxTrackerOptions {
66
67
  /**
67
68
  * Agent identity. A field set here always wins; fields left unset are taken from the Baggage entries
68
69
  * `gen_ai.agent.id` / `gen_ai.agent.name` unless `agentFromBaggage` is false
69
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0011-agent-identity-precedence.md).
70
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0011-agent-identity-precedence.md).
70
71
  */
71
72
  agent?: AgentIdentity | undefined;
72
73
  /**
@@ -80,13 +81,17 @@ interface TxTrackerOptions {
80
81
  * If it throws or returns something other than an attributes object, the tracker fails closed and records only
81
82
  * `blockchain.system`, `blockchain.chain.id`, `blockchain.operation.name`, `blockchain.tx.hash`,
82
83
  * `blockchain.tx.status`, `blockchain.tx.replacement.hash`, `blockchain.tx.replacement.reason`,
83
- * `blockchain.payment.protocol`, `blockchain.payment.status`, `blockchain.payment.verified`, `error.type` and
84
- * `exception.type`, and logs the failure via `diag`.
84
+ * `blockchain.payment.protocol`, `blockchain.payment.status`, `blockchain.payment.verified`,
85
+ * `blockchain.user_operation.hash`, `blockchain.user_operation.success`, `error.type` and `exception.type`, and logs
86
+ * the failure via `diag`.
85
87
  */
86
88
  redact?: ((attributes: Attributes) => Attributes) | undefined;
87
- /** How long a sent transaction can be linked from its confirmation. Default: 10 minutes. */
89
+ /** How long a sent transaction or user operation can be linked from its confirmation. Default: 10 minutes. */
88
90
  linkTtlMs?: number | undefined;
89
- /** Maximum number of sent transactions kept for linking. Default: 10 000. */
91
+ /**
92
+ * Maximum number of sent transactions kept for linking. Default: 10 000. User operations are kept separately, up to
93
+ * the same number.
94
+ */
90
95
  maxTrackedTransactions?: number | undefined;
91
96
  }
92
97
  interface SendInput {
@@ -106,25 +111,37 @@ interface SendInput {
106
111
  functionSelector?: string | undefined;
107
112
  /** Decoded call arguments; recorded only with the `recordFunctionArguments` tracker option. */
108
113
  functionArguments?: readonly unknown[] | undefined;
114
+ /**
115
+ * The EIP-7702 authorization list of a type 4 transaction. Its length is recorded as
116
+ * `blockchain.tx.authorization.count`; for each well-formed entry (at most 64), its delegated address per the
117
+ * address mode and its chain id. Signatures and nonces are never recorded.
118
+ */
119
+ authorizations?: readonly AuthorizationInput[] | undefined;
109
120
  /**
110
121
  * When the send started, for adapters that record it after the fact
111
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0009-telemetry-off-the-call-path.md).
122
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0009-telemetry-off-the-call-path.md).
112
123
  * Omit it otherwise: with an explicit start time, the SDK measures the span by the wall clock, so pass the end time
113
124
  * to the handle too.
114
125
  */
115
126
  startTime?: TimeInput | undefined;
116
127
  }
128
+ /** One EIP-7702 authorization: the contract the account delegates to, and the chain it is valid on (0: every chain). */
129
+ interface AuthorizationInput {
130
+ /** The delegated contract address; `0x000...0` clears a delegation. */
131
+ address: string;
132
+ chainId: number;
133
+ }
117
134
  /**
118
135
  * Ends a send span. Only the first call counts; methods never throw.
119
136
  * Produced by the tracker only; methods may be added in minor releases
120
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0014-core-api-boundary.md).
137
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
121
138
  */
122
139
  interface SendHandle {
123
140
  /**
124
141
  * The parent context with the send span set. Run the call that sends the transaction in it, e.g.
125
142
  * `await context.with(send.context, () => sendSomehow())`, so that spans of wallet, RPC or HTTP instrumentation
126
143
  * nest under the send span
127
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0015-send-span-as-active-context.md).
144
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0015-send-span-as-active-context.md).
128
145
  * Run only that call in it: a confirm span started in it becomes a child of the send span.
129
146
  */
130
147
  readonly context: Context;
@@ -187,7 +204,7 @@ interface ReceiptLike {
187
204
  /**
188
205
  * Hash of the mined transaction. When it differs from the awaited hash, the awaited transaction was replaced: its
189
206
  * confirm span ends as `replaced` and the receipt is recorded for this hash
190
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0008-replaced-transactions.md).
207
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0008-replaced-transactions.md).
191
208
  */
192
209
  transactionHash?: string | undefined;
193
210
  /** Replacement reason reported by the library, when {@link transactionHash} differs from the awaited hash. */
@@ -197,7 +214,7 @@ interface ReceiptLike {
197
214
  * One wait for a transaction's receipt, joined to the transaction's shared confirm span. Only the first call counts;
198
215
  * methods never throw.
199
216
  * Produced by the tracker only; methods may be added in minor releases
200
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0014-core-api-boundary.md).
217
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
201
218
  */
202
219
  interface ConfirmHandle {
203
220
  /** Ends the shared confirm span with the receipt, for every handle of the transaction. */
@@ -221,7 +238,7 @@ interface ConfirmHandle {
221
238
  }
222
239
  /**
223
240
  * A payment the agent authorizes and another party settles on chain, e.g. an x402 facilitator
224
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0013-x402-payments.md).
241
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0013-x402-payments.md).
225
242
  * Values often come from a remote server: addresses, amounts and identifiers that are malformed are not recorded.
226
243
  */
227
244
  interface PaymentInput {
@@ -255,7 +272,7 @@ interface PaymentSettlement {
255
272
  status: PaymentStatus;
256
273
  /** Hash of the settling transaction; with it, a confirm span for this hash links to the payment span. */
257
274
  hash?: string | undefined;
258
- /** Address that paid, when the settlement reports it; recorded instead of the input's. */
275
+ /** Address that paid, when the settlement reports it; recorded only when the payment's input had no payer. */
259
276
  payer?: string | undefined;
260
277
  /**
261
278
  * Amount settled, when the settlement reports it, recorded as `blockchain.payment.settled_amount`; also as
@@ -273,7 +290,7 @@ interface PaymentSettlement {
273
290
  /**
274
291
  * Ends a payment span. Only the first call counts; methods never throw.
275
292
  * Produced by the tracker only; methods may be added in minor releases
276
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0014-core-api-boundary.md).
293
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
277
294
  */
278
295
  interface PaymentHandle {
279
296
  /** Ends the payment span with its settlement. */
@@ -296,6 +313,202 @@ interface PaymentHandle {
296
313
  */
297
314
  link(hash: string): void;
298
315
  }
316
+ /**
317
+ * A user operation of an ERC-4337 smart account, handed to a bundler
318
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0021-user-operations.md). It has no
319
+ * transaction of its own: the bundler includes it in a bundle transaction that the bundler sends.
320
+ */
321
+ interface UserOperationInput {
322
+ /** EIP-155 chain id. */
323
+ chainId: number;
324
+ /** Address of the smart account, recorded as `blockchain.user_operation.sender` per the address mode. */
325
+ sender?: string | undefined;
326
+ /** Address of the EntryPoint contract, recorded as `blockchain.user_operation.entry_point` per the address mode. */
327
+ entryPoint?: string | undefined;
328
+ /** Number of calls the operation makes, recorded as `blockchain.user_operation.call_count`. */
329
+ callCount?: number | undefined;
330
+ /** When the send started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
331
+ startTime?: TimeInput | undefined;
332
+ }
333
+ /** What handing a user operation to a bundler produced. */
334
+ interface UserOperationResult {
335
+ /** Hash of the user operation, `0x`-prefixed 32 bytes, as the bundler returned it. */
336
+ userOpHash: string;
337
+ }
338
+ /**
339
+ * Ends the send span of a user operation. Only the first call counts; methods never throw.
340
+ * Produced by the tracker only; methods may be added in minor releases
341
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
342
+ */
343
+ interface UserOperationSendHandle {
344
+ /**
345
+ * The parent context with the send span set. Run the call that hands the operation to the bundler in it, as for
346
+ * {@link SendHandle.context}.
347
+ */
348
+ readonly context: Context;
349
+ /** Ends the send span successfully once the user operation hash is known. */
350
+ end(result: UserOperationResult, options?: EndOptions): void;
351
+ /** Ends the send span with an error (preparing, signing or handing the operation to the bundler failed). */
352
+ fail(error: unknown, options?: FailOptions): void;
353
+ }
354
+ interface UserOperationConfirmInput {
355
+ /** EIP-155 chain id; with `userOpHash`, it identifies the user operation and its confirm span. */
356
+ chainId: number;
357
+ /** Hash of the user operation awaited, `0x`-prefixed. */
358
+ userOpHash: string;
359
+ /** When the wait started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
360
+ startTime?: TimeInput | undefined;
361
+ }
362
+ /**
363
+ * Library-agnostic view of a user operation receipt (ERC-4337 `eth_getUserOperationReceipt`, or the EntryPoint's
364
+ * `UserOperationEvent`). Every field is optional, since some SDKs report less; values usually come from a bundler,
365
+ * and malformed ones are not recorded.
366
+ */
367
+ interface UserOperationReceiptLike {
368
+ /**
369
+ * Whether the operation's calls succeeded. `false` ends the confirm span with an error status and `error.type`
370
+ * `reverted`; the bundle transaction itself can still have succeeded.
371
+ */
372
+ success?: boolean | undefined;
373
+ /** What the operation paid, in wei (`actualGasCost`), recorded as `blockchain.user_operation.gas.cost`. */
374
+ actualGasCost?: bigint | string | undefined;
375
+ /** Gas the operation used (`actualGasUsed`), recorded as `blockchain.user_operation.gas.used`. */
376
+ actualGasUsed?: bigint | number | string | undefined;
377
+ /** Address of the smart account. */
378
+ sender?: string | undefined;
379
+ /**
380
+ * The operation's nonce, recorded as a decimal string: it holds a 192-bit key and a 64-bit sequence number. Bundlers
381
+ * return it as a hex string, which some libraries pass on unchanged.
382
+ */
383
+ nonce?: bigint | string | undefined;
384
+ /** Address of the paymaster that paid for the operation; the zero address means none. */
385
+ paymaster?: string | undefined;
386
+ /** Address of the EntryPoint contract. */
387
+ entryPoint?: string | undefined;
388
+ /** Decoded revert reason, recorded as `blockchain.tx.revert.reason` with addresses per the address mode. */
389
+ revertReason?: string | undefined;
390
+ /** Hash of the bundle transaction that included the operation, recorded as `blockchain.tx.hash`. */
391
+ transactionHash?: string | undefined;
392
+ /** Block of the bundle transaction. */
393
+ blockNumber?: bigint | number | undefined;
394
+ }
395
+ /**
396
+ * One wait for a user operation's receipt, joined to the operation's shared confirm span, as for transactions
397
+ * ({@link ConfirmHandle}). Only the first call counts; methods never throw.
398
+ * Produced by the tracker only; methods may be added in minor releases
399
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
400
+ */
401
+ interface UserOperationConfirmHandle {
402
+ /** Ends the shared confirm span with the receipt, for every handle of the user operation. */
403
+ end(receipt: UserOperationReceiptLike, options?: EndOptions): void;
404
+ /**
405
+ * Withdraws this handle because waiting for the receipt timed out. The confirm span ends as `timeout` only if no
406
+ * other handle of the user operation is still waiting.
407
+ */
408
+ timeout(options?: EndOptions): void;
409
+ /**
410
+ * Withdraws this handle because the operation failed or its receipt could not be retrieved. The confirm span ends
411
+ * as a failure only if no other handle is still waiting. Called without an error, as
412
+ * `fail(undefined, { errorType })`, it records no exception event: for an SDK that reports a failed operation
413
+ * without an error.
414
+ */
415
+ fail(error: unknown, options?: FailOptions): void;
416
+ }
417
+ /**
418
+ * A batch of calls handed to a wallet with EIP-5792 `wallet_sendCalls`
419
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0022-call-batches.md). The wallet decides
420
+ * how the calls reach the chain: in one transaction, several, or a user operation.
421
+ */
422
+ interface CallBatchInput {
423
+ /** EIP-155 chain id. */
424
+ chainId: number;
425
+ /** Address of the account the calls are sent from, recorded as `blockchain.call_batch.sender` per the address mode. */
426
+ sender?: string | undefined;
427
+ /** Number of calls in the batch, recorded as `blockchain.call_batch.call_count`. */
428
+ callCount?: number | undefined;
429
+ /** When the send started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
430
+ startTime?: TimeInput | undefined;
431
+ }
432
+ /** What handing a call batch to a wallet produced. */
433
+ interface CallBatchResult {
434
+ /**
435
+ * The batch id the wallet returned, which identifies the batch with the chain id: `0x`-prefixed hex of at most 8194
436
+ * characters. Any other id is not recorded.
437
+ */
438
+ id: string;
439
+ /**
440
+ * Hashes of transactions the account itself sent for the batch, when the adapter knows them (viem's fallback to
441
+ * `eth_sendTransaction`). Each is recorded as sent by the batch's send span, so its confirm span links to it.
442
+ */
443
+ transactionHashes?: readonly string[] | undefined;
444
+ }
445
+ /**
446
+ * Ends the send span of a call batch. Only the first call counts; methods never throw.
447
+ * Produced by the tracker only; methods may be added in minor releases
448
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
449
+ */
450
+ interface CallBatchSendHandle {
451
+ /**
452
+ * The parent context with the send span set. Run the call that hands the batch to the wallet in it, as for
453
+ * {@link SendHandle.context}.
454
+ */
455
+ readonly context: Context;
456
+ /** Ends the send span successfully once the batch id is known. */
457
+ end(result: CallBatchResult, options?: EndOptions): void;
458
+ /** Ends the send span with an error (the wallet rejected the batch, or sending it failed). */
459
+ fail(error: unknown, options?: FailOptions): void;
460
+ }
461
+ interface CallBatchConfirmInput {
462
+ /** EIP-155 chain id; with `id`, it identifies the batch and its confirm span. */
463
+ chainId: number;
464
+ /** The batch id awaited, as the wallet returned it. */
465
+ id: string;
466
+ /** When the wait started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
467
+ startTime?: TimeInput | undefined;
468
+ }
469
+ /**
470
+ * Library-agnostic view of an EIP-5792 call batch status (`wallet_getCallsStatus`). Every field is optional; values
471
+ * come from a wallet, and malformed ones are not recorded.
472
+ */
473
+ interface CallBatchStatusLike {
474
+ /**
475
+ * The EIP-5792 status code, recorded as `blockchain.call_batch.status_code`. 200 ends the confirm span as
476
+ * `success`, 500 as `reverted` and 600 as `partially_reverted` (`blockchain.call_batch.status`); 400 (failed without
477
+ * inclusion) with `error.type` `failed`; 100 (still pending) without an outcome; any other code, or none, with
478
+ * `error.type` `_OTHER`.
479
+ */
480
+ statusCode?: number | undefined;
481
+ /** Whether the wallet ran the calls atomically. */
482
+ atomic?: boolean | undefined;
483
+ /**
484
+ * Receipts of the transactions that carried the batch; only their hashes (validated, de-duplicated, at most 64) and
485
+ * the highest block number are recorded.
486
+ */
487
+ receipts?: readonly {
488
+ transactionHash?: string | undefined;
489
+ blockNumber?: bigint | number | undefined;
490
+ }[] | undefined;
491
+ }
492
+ /**
493
+ * One wait for a call batch's status, joined to the batch's shared confirm span, as for transactions
494
+ * ({@link ConfirmHandle}). Only the first call counts; methods never throw.
495
+ * Produced by the tracker only; methods may be added in minor releases
496
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
497
+ */
498
+ interface CallBatchConfirmHandle {
499
+ /** Ends the shared confirm span with the status, for every handle of the batch. */
500
+ end(status: CallBatchStatusLike, options?: EndOptions): void;
501
+ /**
502
+ * Withdraws this handle because waiting for the status timed out. The confirm span ends as `timeout` only if no
503
+ * other handle of the batch is still waiting.
504
+ */
505
+ timeout(options?: EndOptions): void;
506
+ /**
507
+ * Withdraws this handle because the status could not be retrieved. The confirm span ends as a failure only if no
508
+ * other handle is still waiting.
509
+ */
510
+ fail(error: unknown, options?: FailOptions): void;
511
+ }
299
512
  //#endregion
300
513
  //#region src/agent.d.ts
301
514
  export declare const ATTR_GEN_AI_AGENT_ID: "gen_ai.agent.id";
@@ -305,7 +518,7 @@ export declare const ATTR_GEN_AI_AGENT_NAME: "gen_ai.agent.name";
305
518
  /**
306
519
  * Attribute keys emitted by hashspan.
307
520
  *
308
- * Stability: development. See https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/semconv.md for
521
+ * Stability: development. See https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/semconv.md for
309
522
  * definitions and value types. These names are a public contract: changes follow the deprecation policy in AGENTS.md.
310
523
  */
311
524
  export declare const ATTR_BLOCKCHAIN_SYSTEM: "blockchain.system";
@@ -316,6 +529,12 @@ export declare const ATTR_BLOCKCHAIN_TX_FROM: "blockchain.tx.from";
316
529
  export declare const ATTR_BLOCKCHAIN_TX_TO: "blockchain.tx.to";
317
530
  export declare const ATTR_BLOCKCHAIN_TX_VALUE: "blockchain.tx.value";
318
531
  export declare const ATTR_BLOCKCHAIN_TX_NONCE: "blockchain.tx.nonce";
532
+ /** Number of EIP-7702 authorizations a type 4 transaction carries. */
533
+ export declare const ATTR_BLOCKCHAIN_TX_AUTHORIZATION_COUNT: "blockchain.tx.authorization.count";
534
+ /** Delegated contract address of each well-formed EIP-7702 authorization, per the address mode; at most 64. */
535
+ export declare const ATTR_BLOCKCHAIN_TX_AUTHORIZATION_ADDRESSES: "blockchain.tx.authorization.addresses";
536
+ /** Chain id of each well-formed EIP-7702 authorization, aligned with the addresses; 0 means every chain. */
537
+ export declare const ATTR_BLOCKCHAIN_TX_AUTHORIZATION_CHAIN_IDS: "blockchain.tx.authorization.chain_ids";
319
538
  export declare const ATTR_BLOCKCHAIN_TX_STATUS: "blockchain.tx.status";
320
539
  export declare const ATTR_BLOCKCHAIN_TX_GAS_USED: "blockchain.tx.gas.used";
321
540
  export declare const ATTR_BLOCKCHAIN_TX_EFFECTIVE_GAS_PRICE: "blockchain.tx.effective_gas_price";
@@ -329,12 +548,12 @@ export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_NAME: "blockchain.contrac
329
548
  export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_SELECTOR: "blockchain.contract.function.selector";
330
549
  /**
331
550
  * Opt-in: decoded call arguments as a JSON array. See
332
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0004-privacy-defaults.md.
551
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0004-privacy-defaults.md.
333
552
  */
334
553
  export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_ARGUMENTS: "blockchain.contract.function.arguments";
335
554
  /**
336
555
  * Payments settled on chain by a party other than the agent, e.g. an x402 facilitator. See
337
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0013-x402-payments.md.
556
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0013-x402-payments.md.
338
557
  */
339
558
  export declare const ATTR_BLOCKCHAIN_PAYMENT_PROTOCOL: "blockchain.payment.protocol";
340
559
  export declare const ATTR_BLOCKCHAIN_PAYMENT_PAYER: "blockchain.payment.payer";
@@ -347,12 +566,52 @@ export declare const ATTR_BLOCKCHAIN_PAYMENT_SETTLED_AMOUNT: "blockchain.payment
347
566
  /**
348
567
  * Whether the settlement transaction's receipt carries the payment, as checked by the adapter; absent when no check
349
568
  * was possible. See
350
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0017-x402-payment-verification.md.
569
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0017-x402-payment-verification.md.
351
570
  */
352
571
  export declare const ATTR_BLOCKCHAIN_PAYMENT_VERIFIED: "blockchain.payment.verified";
353
572
  /** x402's own payment fields. */
354
573
  export declare const ATTR_X402_SCHEME: "x402.scheme";
355
574
  export declare const ATTR_X402_RESOURCE: "x402.resource";
575
+ /**
576
+ * User operations of ERC-4337 smart accounts. See
577
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0021-user-operations.md.
578
+ */
579
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_HASH: "blockchain.user_operation.hash";
580
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_SENDER: "blockchain.user_operation.sender";
581
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_ENTRY_POINT: "blockchain.user_operation.entry_point";
582
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_CALL_COUNT: "blockchain.user_operation.call_count";
583
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_NONCE: "blockchain.user_operation.nonce";
584
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_SUCCESS: "blockchain.user_operation.success";
585
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_GAS_USED: "blockchain.user_operation.gas.used";
586
+ /** What the operation itself paid, in wei; the bundle transaction's fee covers every operation in the bundle. */
587
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_GAS_COST: "blockchain.user_operation.gas.cost";
588
+ export declare const ATTR_BLOCKCHAIN_USER_OPERATION_PAYMASTER: "blockchain.user_operation.paymaster";
589
+ /**
590
+ * The batch id the wallet returned, truncated after 256 characters. See
591
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0022-call-batches.md.
592
+ */
593
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_ID: "blockchain.call_batch.id";
594
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_SENDER: "blockchain.call_batch.sender";
595
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_CALL_COUNT: "blockchain.call_batch.call_count";
596
+ /** The outcome of a batch from chain data: `success`, `reverted` or `partially_reverted`. */
597
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_STATUS: "blockchain.call_batch.status";
598
+ /** The EIP-5792 status code of the batch as the wallet reported it, e.g. 200 confirmed or 500 reverted; spans only. */
599
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_STATUS_CODE: "blockchain.call_batch.status_code";
600
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_ATOMIC: "blockchain.call_batch.atomic";
601
+ /** Hashes of the transactions whose receipts the wallet reported for the batch. */
602
+ export declare const ATTR_BLOCKCHAIN_CALL_BATCH_TRANSACTION_HASHES: "blockchain.call_batch.transaction_hashes";
603
+ /**
604
+ * Metrics only: what a send, confirmation or fee sample is about. Recorded as `user_operation` on samples of user
605
+ * operations and `call_batch` on those of call batches, and absent on those of transactions.
606
+ */
607
+ export declare const ATTR_BLOCKCHAIN_OPERATION_SUBJECT: "blockchain.operation.subject";
608
+ /** Values for {@link ATTR_BLOCKCHAIN_OPERATION_SUBJECT}. */
609
+ export declare const BLOCKCHAIN_OPERATION_SUBJECT_VALUE_USER_OPERATION: "user_operation";
610
+ export declare const BLOCKCHAIN_OPERATION_SUBJECT_VALUE_CALL_BATCH: "call_batch";
611
+ /** Values for {@link ATTR_BLOCKCHAIN_CALL_BATCH_STATUS}. */
612
+ export declare const BLOCKCHAIN_CALL_BATCH_STATUS_VALUE_SUCCESS: "success";
613
+ export declare const BLOCKCHAIN_CALL_BATCH_STATUS_VALUE_REVERTED: "reverted";
614
+ export declare const BLOCKCHAIN_CALL_BATCH_STATUS_VALUE_PARTIALLY_REVERTED: "partially_reverted";
356
615
  /** Values for {@link ATTR_BLOCKCHAIN_SYSTEM}. */
357
616
  export declare const BLOCKCHAIN_SYSTEM_VALUE_EVM: "evm";
358
617
  /** Values for {@link ATTR_BLOCKCHAIN_OPERATION_NAME}. */
@@ -371,7 +630,7 @@ export declare const BLOCKCHAIN_TX_STATUS_VALUE_REVERTED: "reverted";
371
630
  /**
372
631
  * @deprecated No longer recorded: a confirm span that gave up waiting records `error.type` `timeout` and no
373
632
  * `blockchain.tx.status`. The constant is removed in 1.0. See
374
- * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0016-timeout-is-an-observer-outcome.md.
633
+ * https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0016-timeout-is-an-observer-outcome.md.
375
634
  */
376
635
  export declare const BLOCKCHAIN_TX_STATUS_VALUE_TIMEOUT: "timeout";
377
636
  export declare const BLOCKCHAIN_TX_STATUS_VALUE_REPLACED: "replaced";
@@ -385,23 +644,32 @@ export declare const ATTR_ERROR_TYPE: "error.type";
385
644
  export declare const ERROR_TYPE_VALUE_OTHER: "_OTHER";
386
645
  //#endregion
387
646
  //#region src/metrics.d.ts
388
- /** Duration of a send: from the start of the sending call until the hash is known or the call failed. */
647
+ /**
648
+ * Duration of a send of a transaction or user operation: from the start of the sending call until the hash is known or
649
+ * the call failed.
650
+ */
389
651
  export declare const METRIC_BLOCKCHAIN_CLIENT_SEND_DURATION: "blockchain.client.send.duration";
390
- /** Duration of a confirmation: from the start of the wait until the receipt, a timeout or a failure. */
652
+ /**
653
+ * Duration of a confirmation of a transaction or user operation: from the start of the wait until the receipt, a
654
+ * timeout or a failure.
655
+ */
391
656
  export declare const METRIC_BLOCKCHAIN_CLIENT_CONFIRMATION_DURATION: "blockchain.client.confirmation.duration";
392
- /** Total fee of a mined transaction (execution fee plus L1 data fee), in the chain's smallest unit (wei). */
657
+ /**
658
+ * Total fee of a mined transaction (execution fee plus L1 data fee), or the cost of a user operation, in the chain's
659
+ * smallest unit (wei).
660
+ */
393
661
  export declare const METRIC_BLOCKCHAIN_CLIENT_FEE: "blockchain.client.fee";
394
662
  //#endregion
395
663
  //#region src/tracker.d.ts
396
664
  /**
397
- * Records transactions and payments as spans. Obtain one from {@link createTxTracker}: it is not meant to be
665
+ * Records transactions, payments and user operations as spans. Obtain one from {@link createTxTracker}: it is not meant to be
398
666
  * implemented, and members may be added to it and to its handles in minor releases
399
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0014-core-api-boundary.md).
667
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0014-core-api-boundary.md).
400
668
  */
401
669
  interface TxTracker {
402
670
  /**
403
671
  * Starts a `send` span as a child of `parent` (default: the active context).
404
- * Call `end(hash)` once the transaction hash is known, or `fail(error)`.
672
+ * Call `end({ hash })` once the transaction hash is known, or `fail(error)`.
405
673
  */
406
674
  startSend(input: SendInput, parent?: Context): SendHandle;
407
675
  /**
@@ -414,15 +682,41 @@ interface TxTracker {
414
682
  /**
415
683
  * Starts a `payment` span as a child of `parent` (default: the active context), for a payment that another party
416
684
  * settles on chain
417
- * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/adr/0013-x402-payments.md). Call
685
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0013-x402-payments.md). Call
418
686
  * `end(settlement)` with the settlement, or `fail(error)`. A settlement with a hash links the transaction's confirm
419
687
  * span to this span, as a send span would.
420
688
  */
421
689
  startPayment(input: PaymentInput, parent?: Context): PaymentHandle;
690
+ /**
691
+ * Starts a `send` span for a user operation of a smart account as a child of `parent` (default: the active context)
692
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0021-user-operations.md). Call
693
+ * `end({ userOpHash })` once the bundler returned the operation's hash, or `fail(error)`.
694
+ */
695
+ startUserOperationSend(input: UserOperationInput, parent?: Context): UserOperationSendHandle;
696
+ /**
697
+ * Joins the `confirm` span of a user operation, starting it for the first caller; linked to its `send` span when
698
+ * known. As for {@link TxTracker.startConfirm}, calls for the same chain id and user operation hash share one span,
699
+ * apart from those of transactions. Returns a no-op handle for an operation that recently got a receipt. Every
700
+ * returned handle must be ended.
701
+ */
702
+ startUserOperationConfirm(input: UserOperationConfirmInput, parent?: Context): UserOperationConfirmHandle;
703
+ /**
704
+ * Starts a `send` span for an EIP-5792 call batch as a child of `parent` (default: the active context)
705
+ * (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/adr/0022-call-batches.md). Call
706
+ * `end({ id })` once the wallet returned the batch id, or `fail(error)`.
707
+ */
708
+ startCallBatchSend(input: CallBatchInput, parent?: Context): CallBatchSendHandle;
709
+ /**
710
+ * Joins the `confirm` span of a call batch, starting it for the first caller; linked to its `send` span when
711
+ * known. As for {@link TxTracker.startConfirm}, calls for the same chain id and batch id share one span, apart from
712
+ * those of transactions and user operations. Returns a no-op handle for a batch that recently got its status. Every
713
+ * returned handle must be ended.
714
+ */
715
+ startCallBatchConfirm(input: CallBatchConfirmInput, parent?: Context): CallBatchConfirmHandle;
422
716
  }
423
717
  /**
424
718
  * Creates a tracker that records transactions as `send` and `confirm` spans, and payments as `payment` spans, with
425
- * `@opentelemetry/api` (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.7.0/docs/semconv.md). It makes
719
+ * `@opentelemetry/api` (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.9.0/docs/semconv.md). It makes
426
720
  * no network calls; the caller passes hashes and receipts. Its methods and handles never throw: failures are logged
427
721
  * via `diag`, and a method that fails returns a handle that records nothing.
428
722
  */
@@ -431,4 +725,4 @@ export declare function createTxTracker(options?: TxTrackerOptions): TxTracker;
431
725
  //#region src/version.d.ts
432
726
  export declare const VERSION: string;
433
727
  //#endregion
434
- export type { AddressMode, AddressOptions, AgentIdentity, ConfirmHandle, ConfirmInput, EndOptions, ErrorMessageMode, FailOptions, PaymentHandle, PaymentInput, PaymentResourceMode, PaymentSettlement, PaymentStatus, ReceiptLike, ReplacementReason, SendHandle, SendInput, SendResult, TxTracker, TxTrackerOptions, X402PaymentDetails };
728
+ export type { AddressMode, AddressOptions, AgentIdentity, AuthorizationInput, CallBatchConfirmHandle, CallBatchConfirmInput, CallBatchInput, CallBatchResult, CallBatchSendHandle, CallBatchStatusLike, ConfirmHandle, ConfirmInput, EndOptions, ErrorMessageMode, FailOptions, PaymentHandle, PaymentInput, PaymentResourceMode, PaymentSettlement, PaymentStatus, ReceiptLike, ReplacementReason, SendHandle, SendInput, SendResult, TxTracker, TxTrackerOptions, UserOperationConfirmHandle, UserOperationConfirmInput, UserOperationInput, UserOperationReceiptLike, UserOperationResult, UserOperationSendHandle, X402PaymentDetails };