@hashspan/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -12
- package/dist/index.cjs +264 -20
- package/dist/index.d.cts +217 -17
- package/dist/index.d.mts +217 -17
- package/dist/index.mjs +252 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { Attributes, Context, 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.4.0/docs/adr/0004-privacy-defaults.md.
|
|
6
|
+
*/
|
|
4
7
|
type AddressMode = "raw" | "hashed" | "off";
|
|
5
8
|
/**
|
|
6
|
-
* How error messages are recorded on exception events and span status. See
|
|
9
|
+
* How error messages are recorded on exception events and span status. See
|
|
10
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0006-error-privacy.md.
|
|
7
11
|
* - `off`: error type only
|
|
8
12
|
* - `sanitized`: first line, addresses per address mode, other long hex data removed
|
|
9
13
|
* - `raw`: full message and stack trace, as thrown
|
|
10
14
|
*/
|
|
11
15
|
type ErrorMessageMode = "off" | "sanitized" | "raw";
|
|
16
|
+
/**
|
|
17
|
+
* How much of a paid resource's URL `x402.resource` records. Paths often carry user or account identifiers, so only
|
|
18
|
+
* the origin is recorded by default (ADR 0004).
|
|
19
|
+
* - `origin`: scheme, host and port only, e.g. `https://api.example.com`; a resource that is not a URL is not recorded
|
|
20
|
+
* - `path`: the URL without its query string, fragment and user info
|
|
21
|
+
* - `off`: nothing
|
|
22
|
+
*/
|
|
23
|
+
type PaymentResourceMode = "origin" | "path" | "off";
|
|
12
24
|
interface AddressOptions {
|
|
25
|
+
/** How addresses are recorded; `hash` applies to `hashed` mode only. */
|
|
13
26
|
mode: AddressMode;
|
|
14
27
|
/**
|
|
15
28
|
* Custom hash for `hashed` mode; receives the lower-cased address.
|
|
@@ -17,9 +30,14 @@ interface AddressOptions {
|
|
|
17
30
|
*/
|
|
18
31
|
hash?: ((address: string) => string) | undefined;
|
|
19
32
|
}
|
|
20
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Static agent identity, recorded on every span of the tracker. A field set here wins over the same Baggage entry;
|
|
35
|
+
* see {@link TxTrackerOptions.agent}. Unlike Baggage, it is never propagated to other services.
|
|
36
|
+
*/
|
|
21
37
|
interface AgentIdentity {
|
|
38
|
+
/** Recorded as `gen_ai.agent.id`. */
|
|
22
39
|
id?: string | undefined;
|
|
40
|
+
/** Recorded as `gen_ai.agent.name`. */
|
|
23
41
|
name?: string | undefined;
|
|
24
42
|
}
|
|
25
43
|
interface TxTrackerOptions {
|
|
@@ -32,6 +50,8 @@ interface TxTrackerOptions {
|
|
|
32
50
|
* attributes.
|
|
33
51
|
*/
|
|
34
52
|
errorMessages?: ErrorMessageMode | undefined;
|
|
53
|
+
/** How much of a paid resource's URL `x402.resource` records. Default: `origin`. */
|
|
54
|
+
paymentResource?: PaymentResourceMode | undefined;
|
|
35
55
|
/**
|
|
36
56
|
* Record decoded contract call arguments ({@link SendInput.functionArguments}) as
|
|
37
57
|
* `blockchain.contract.function.arguments`. Default: false. Arguments can carry amounts, counterparties and free
|
|
@@ -40,7 +60,8 @@ interface TxTrackerOptions {
|
|
|
40
60
|
recordFunctionArguments?: boolean | undefined;
|
|
41
61
|
/**
|
|
42
62
|
* Agent identity. A field set here always wins; fields left unset are taken from the Baggage entries
|
|
43
|
-
* `gen_ai.agent.id` / `gen_ai.agent.name` unless `agentFromBaggage` is false
|
|
63
|
+
* `gen_ai.agent.id` / `gen_ai.agent.name` unless `agentFromBaggage` is false
|
|
64
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0011-agent-identity-precedence.md).
|
|
44
65
|
*/
|
|
45
66
|
agent?: AgentIdentity | undefined;
|
|
46
67
|
/**
|
|
@@ -50,8 +71,12 @@ interface TxTrackerOptions {
|
|
|
50
71
|
*/
|
|
51
72
|
agentFromBaggage?: boolean | undefined;
|
|
52
73
|
/**
|
|
53
|
-
* Runs last on every attribute set and returns the attributes to record.
|
|
54
|
-
* If it throws
|
|
74
|
+
* Runs last on every attribute set, including exception event attributes, and returns the attributes to record.
|
|
75
|
+
* If it throws or returns something other than an attributes object, the tracker fails closed and records only
|
|
76
|
+
* `blockchain.system`, `blockchain.chain.id`, `blockchain.operation.name`, `blockchain.tx.hash`,
|
|
77
|
+
* `blockchain.tx.status`, `blockchain.tx.replacement.hash`, `blockchain.tx.replacement.reason`,
|
|
78
|
+
* `blockchain.payment.protocol`, `blockchain.payment.status`, `error.type` and `exception.type`, and logs the
|
|
79
|
+
* failure via `diag`.
|
|
55
80
|
*/
|
|
56
81
|
redact?: ((attributes: Attributes) => Attributes) | undefined;
|
|
57
82
|
/** How long a sent transaction can be linked from its confirmation. Default: 10 minutes. */
|
|
@@ -62,30 +87,77 @@ interface TxTrackerOptions {
|
|
|
62
87
|
interface SendInput {
|
|
63
88
|
/** EIP-155 chain id. */
|
|
64
89
|
chainId: number;
|
|
90
|
+
/** Sender address, recorded as `blockchain.tx.from` per the address mode. */
|
|
65
91
|
from?: string | undefined;
|
|
92
|
+
/** Recipient or contract address, recorded as `blockchain.tx.to` per the address mode. */
|
|
66
93
|
to?: string | undefined;
|
|
67
94
|
/** Value in wei. */
|
|
68
95
|
value?: bigint | undefined;
|
|
96
|
+
/** Sender nonce, when known before the send; omit it when the library or wallet fills it in. */
|
|
69
97
|
nonce?: number | undefined;
|
|
98
|
+
/** Name of the called contract function, when an ABI is known, e.g. `transfer`. */
|
|
70
99
|
functionName?: string | undefined;
|
|
71
100
|
/** 4-byte function selector, e.g. `0xa9059cbb`. */
|
|
72
101
|
functionSelector?: string | undefined;
|
|
73
102
|
/** Decoded call arguments; recorded only with the `recordFunctionArguments` tracker option. */
|
|
74
103
|
functionArguments?: readonly unknown[] | undefined;
|
|
75
104
|
/**
|
|
76
|
-
* When the send started, for adapters that record it after the fact
|
|
77
|
-
*
|
|
105
|
+
* When the send started, for adapters that record it after the fact
|
|
106
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0009-telemetry-off-the-call-path.md).
|
|
107
|
+
* Omit it otherwise: with an explicit start time, the SDK measures the span by the wall clock, so pass the end time
|
|
108
|
+
* to the handle too.
|
|
78
109
|
*/
|
|
79
110
|
startTime?: TimeInput | undefined;
|
|
80
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Ends a send span. Only the first call counts; methods never throw.
|
|
114
|
+
* Produced by the tracker only; methods may be added in minor releases
|
|
115
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0014-core-api-boundary.md).
|
|
116
|
+
*/
|
|
81
117
|
interface SendHandle {
|
|
82
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* The parent context with the send span set. Run the call that sends the transaction in it, e.g.
|
|
120
|
+
* `await context.with(send.context, () => sendSomehow())`, so that spans of wallet, RPC or HTTP instrumentation
|
|
121
|
+
* nest under the send span
|
|
122
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0015-send-span-as-active-context.md).
|
|
123
|
+
* Run only that call in it: a confirm span started in it becomes a child of the send span.
|
|
124
|
+
*/
|
|
125
|
+
readonly context: Context;
|
|
126
|
+
/** Ends the send span successfully once the transaction hash is known. */
|
|
127
|
+
end(result: SendResult, options?: EndOptions): void;
|
|
128
|
+
/** @deprecated Use `end({ hash }, { endTime })`; removed in 1.0. */
|
|
83
129
|
end(hash: string, endTime?: TimeInput): void;
|
|
84
|
-
/** Ends the send span with an error (signing, simulation or broadcast failure)
|
|
85
|
-
fail(error: unknown,
|
|
130
|
+
/** Ends the send span with an error (signing, simulation or broadcast failure). */
|
|
131
|
+
fail(error: unknown, options?: FailOptions): void;
|
|
132
|
+
/** @deprecated Use `fail(error, { endTime, errorType })`; removed in 1.0. */
|
|
133
|
+
fail(error: unknown, endTime: TimeInput | undefined, options?: FailOptions): void;
|
|
134
|
+
}
|
|
135
|
+
/** What a send produced. */
|
|
136
|
+
interface SendResult {
|
|
137
|
+
/** Hash of the sent transaction, `0x`-prefixed. */
|
|
138
|
+
hash: string;
|
|
139
|
+
}
|
|
140
|
+
/** Options of every handle method. */
|
|
141
|
+
interface EndOptions {
|
|
142
|
+
/**
|
|
143
|
+
* When the span ends, for adapters that record it after the fact; defaults to now. See
|
|
144
|
+
* {@link SendInput.startTime}.
|
|
145
|
+
*/
|
|
146
|
+
endTime?: TimeInput | undefined;
|
|
147
|
+
}
|
|
148
|
+
interface FailOptions extends EndOptions {
|
|
149
|
+
/**
|
|
150
|
+
* `error.type` to record instead of the error's class name, for adapters whose library reports a stable,
|
|
151
|
+
* machine-readable error code (for example a wallet API's error type). Recorded only if it matches
|
|
152
|
+
* `/^[A-Za-z0-9_.-]{1,64}$/`, so that the attribute keeps a bounded set of values; otherwise the class name is
|
|
153
|
+
* recorded. `exception.type` is always the class name.
|
|
154
|
+
*/
|
|
155
|
+
errorType?: string | undefined;
|
|
86
156
|
}
|
|
87
157
|
interface ConfirmInput {
|
|
158
|
+
/** EIP-155 chain id; with `hash`, it identifies the transaction and its confirm span. */
|
|
88
159
|
chainId: number;
|
|
160
|
+
/** Hash of the transaction awaited, `0x`-prefixed. */
|
|
89
161
|
hash: string;
|
|
90
162
|
/** When the wait started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
|
|
91
163
|
startTime?: TimeInput | undefined;
|
|
@@ -94,6 +166,7 @@ interface ConfirmInput {
|
|
|
94
166
|
type ReplacementReason = "repriced" | "cancelled" | "replaced";
|
|
95
167
|
/** Library-agnostic view of a transaction receipt. Adapters normalise their client's receipt into this. */
|
|
96
168
|
interface ReceiptLike {
|
|
169
|
+
/** `reverted` ends the confirm span with an error status and `error.type` `reverted`. */
|
|
97
170
|
status: "success" | "reverted";
|
|
98
171
|
blockNumber: bigint | number;
|
|
99
172
|
gasUsed: bigint | number;
|
|
@@ -101,29 +174,109 @@ interface ReceiptLike {
|
|
|
101
174
|
effectiveGasPrice?: bigint | undefined;
|
|
102
175
|
/** L1 data fee in wei on OP-stack chains. */
|
|
103
176
|
l1Fee?: bigint | null | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Decoded revert reason, recorded as `blockchain.tx.revert.reason` with addresses per the address mode, e.g.
|
|
179
|
+
* `Error(string)`'s message, `Panic(0x11)` or `InsufficientBalance(1, 2)`.
|
|
180
|
+
*/
|
|
104
181
|
revertReason?: string | undefined;
|
|
105
182
|
/**
|
|
106
|
-
* Hash of the mined transaction. When it differs from the awaited hash, the awaited transaction was replaced:
|
|
107
|
-
*
|
|
183
|
+
* Hash of the mined transaction. When it differs from the awaited hash, the awaited transaction was replaced: its
|
|
184
|
+
* confirm span ends as `replaced` and the receipt is recorded for this hash
|
|
185
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0008-replaced-transactions.md).
|
|
108
186
|
*/
|
|
109
187
|
transactionHash?: string | undefined;
|
|
110
188
|
/** Replacement reason reported by the library, when {@link transactionHash} differs from the awaited hash. */
|
|
111
189
|
replacementReason?: ReplacementReason | undefined;
|
|
112
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* One wait for a transaction's receipt, joined to the transaction's shared confirm span. Only the first call counts;
|
|
193
|
+
* methods never throw.
|
|
194
|
+
* Produced by the tracker only; methods may be added in minor releases
|
|
195
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0014-core-api-boundary.md).
|
|
196
|
+
*/
|
|
113
197
|
interface ConfirmHandle {
|
|
114
198
|
/** Ends the shared confirm span with the receipt, for every handle of the transaction. */
|
|
199
|
+
end(receipt: ReceiptLike, options?: EndOptions): void;
|
|
200
|
+
/** @deprecated Use `end(receipt, { endTime })`; removed in 1.0. */
|
|
115
201
|
end(receipt: ReceiptLike, endTime?: TimeInput): void;
|
|
116
202
|
/**
|
|
117
203
|
* Withdraws this handle because waiting for the receipt timed out. The confirm span ends as `timeout` only if
|
|
118
204
|
* no other handle of the transaction is still waiting.
|
|
119
205
|
*/
|
|
206
|
+
timeout(options?: EndOptions): void;
|
|
207
|
+
/** @deprecated Use `timeout({ endTime })`; removed in 1.0. */
|
|
120
208
|
timeout(endTime?: TimeInput): void;
|
|
121
209
|
/**
|
|
122
210
|
* Withdraws this handle because retrieving the receipt failed. The confirm span ends as a failure only if no
|
|
123
211
|
* other handle of the transaction is still waiting.
|
|
124
212
|
*/
|
|
213
|
+
fail(error: unknown, options?: EndOptions): void;
|
|
214
|
+
/** @deprecated Use `fail(error, { endTime })`; removed in 1.0. */
|
|
125
215
|
fail(error: unknown, endTime?: TimeInput): void;
|
|
126
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* A payment the agent authorizes and another party settles on chain, e.g. an x402 facilitator
|
|
219
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0013-x402-payments.md).
|
|
220
|
+
* Values often come from a remote server: addresses, amounts and identifiers that are malformed are not recorded.
|
|
221
|
+
*/
|
|
222
|
+
interface PaymentInput {
|
|
223
|
+
/** EIP-155 chain id of the network the payment settles on. */
|
|
224
|
+
chainId: number;
|
|
225
|
+
/** Payment protocol, e.g. `x402`; recorded only if it is a short identifier. */
|
|
226
|
+
protocol: string;
|
|
227
|
+
/** Address that pays, recorded per the address mode. */
|
|
228
|
+
payer?: string | undefined;
|
|
229
|
+
/** Address that is paid, recorded per the address mode. */
|
|
230
|
+
recipient?: string | undefined;
|
|
231
|
+
/** Contract address of the token paid with, recorded per the address mode. */
|
|
232
|
+
asset?: string | undefined;
|
|
233
|
+
/** Amount in the asset's smallest unit. */
|
|
234
|
+
amount?: bigint | string | undefined;
|
|
235
|
+
/** Fields of x402 payments. */
|
|
236
|
+
x402?: X402PaymentDetails | undefined;
|
|
237
|
+
/** When the payment started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
|
|
238
|
+
startTime?: TimeInput | undefined;
|
|
239
|
+
}
|
|
240
|
+
interface X402PaymentDetails {
|
|
241
|
+
/** Payment scheme, e.g. `exact`; recorded only if it is a short identifier. */
|
|
242
|
+
scheme?: string | undefined;
|
|
243
|
+
/** URL or name of the resource paid for. Its query string, fragment and user info are never recorded. */
|
|
244
|
+
resource?: string | undefined;
|
|
245
|
+
}
|
|
246
|
+
/** How a payment's settlement ended: `pending` means the transaction is known but its receipt was not seen. */
|
|
247
|
+
type PaymentStatus = "settled" | "pending" | "failed";
|
|
248
|
+
/** The settlement of a payment, as reported by the party that settled it. */
|
|
249
|
+
interface PaymentSettlement {
|
|
250
|
+
status: PaymentStatus;
|
|
251
|
+
/** Hash of the settling transaction; with it, a confirm span for this hash links to the payment span. */
|
|
252
|
+
hash?: string | undefined;
|
|
253
|
+
/** Address that paid, when the settlement reports it; recorded instead of the input's. */
|
|
254
|
+
payer?: string | undefined;
|
|
255
|
+
/** Amount settled, when the settlement reports it; recorded instead of the input's. */
|
|
256
|
+
amount?: bigint | string | undefined;
|
|
257
|
+
/** Why a `failed` settlement failed, recorded as `error.type` if it is a short identifier, else `_OTHER`. */
|
|
258
|
+
errorReason?: string | undefined;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Ends a payment span. Only the first call counts; methods never throw.
|
|
262
|
+
* Produced by the tracker only; methods may be added in minor releases
|
|
263
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0014-core-api-boundary.md).
|
|
264
|
+
*/
|
|
265
|
+
interface PaymentHandle {
|
|
266
|
+
/** Ends the payment span with its settlement. */
|
|
267
|
+
end(settlement: PaymentSettlement, options?: EndOptions): void;
|
|
268
|
+
/**
|
|
269
|
+
* Ends the payment span with an error when the payment could not be made, e.g. signing it failed. Called without
|
|
270
|
+
* an error, as `fail(undefined, { errorType })`, it records no exception event: for outcomes that are not
|
|
271
|
+
* exceptions, such as a response without a settlement (`no_settlement`).
|
|
272
|
+
*/
|
|
273
|
+
fail(error: unknown, options?: FailOptions): void;
|
|
274
|
+
/**
|
|
275
|
+
* Ends the payment span with `error.type` `timeout` and no `blockchain.payment.status`, when its outcome was never
|
|
276
|
+
* learned, e.g. no response arrived before the authorization expired.
|
|
277
|
+
*/
|
|
278
|
+
timeout(options?: EndOptions): void;
|
|
279
|
+
}
|
|
127
280
|
//#endregion
|
|
128
281
|
//#region src/agent.d.ts
|
|
129
282
|
export declare const ATTR_GEN_AI_AGENT_ID: "gen_ai.agent.id";
|
|
@@ -133,8 +286,8 @@ export declare const ATTR_GEN_AI_AGENT_NAME: "gen_ai.agent.name";
|
|
|
133
286
|
/**
|
|
134
287
|
* Attribute keys emitted by hashspan.
|
|
135
288
|
*
|
|
136
|
-
* Stability: development. See docs/semconv.md for
|
|
137
|
-
* These names are a public contract: changes follow the deprecation policy in AGENTS.md.
|
|
289
|
+
* Stability: development. See https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/semconv.md for
|
|
290
|
+
* definitions and value types. These names are a public contract: changes follow the deprecation policy in AGENTS.md.
|
|
138
291
|
*/
|
|
139
292
|
export declare const ATTR_BLOCKCHAIN_SYSTEM: "blockchain.system";
|
|
140
293
|
export declare const ATTR_BLOCKCHAIN_CHAIN_ID: "blockchain.chain.id";
|
|
@@ -155,16 +308,44 @@ export declare const ATTR_BLOCKCHAIN_TX_REPLACEMENT_REASON: "blockchain.tx.repla
|
|
|
155
308
|
export declare const ATTR_BLOCKCHAIN_BLOCK_NUMBER: "blockchain.block.number";
|
|
156
309
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_NAME: "blockchain.contract.function.name";
|
|
157
310
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_SELECTOR: "blockchain.contract.function.selector";
|
|
158
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Opt-in: decoded call arguments as a JSON array. See
|
|
313
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0004-privacy-defaults.md.
|
|
314
|
+
*/
|
|
159
315
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_ARGUMENTS: "blockchain.contract.function.arguments";
|
|
316
|
+
/**
|
|
317
|
+
* Payments settled on chain by a party other than the agent, e.g. an x402 facilitator. See
|
|
318
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0013-x402-payments.md.
|
|
319
|
+
*/
|
|
320
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_PROTOCOL: "blockchain.payment.protocol";
|
|
321
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_PAYER: "blockchain.payment.payer";
|
|
322
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_RECIPIENT: "blockchain.payment.recipient";
|
|
323
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_ASSET: "blockchain.payment.asset";
|
|
324
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_AMOUNT: "blockchain.payment.amount";
|
|
325
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_STATUS: "blockchain.payment.status";
|
|
326
|
+
/** x402's own payment fields. */
|
|
327
|
+
export declare const ATTR_X402_SCHEME: "x402.scheme";
|
|
328
|
+
export declare const ATTR_X402_RESOURCE: "x402.resource";
|
|
160
329
|
/** Values for {@link ATTR_BLOCKCHAIN_SYSTEM}. */
|
|
161
330
|
export declare const BLOCKCHAIN_SYSTEM_VALUE_EVM: "evm";
|
|
162
331
|
/** Values for {@link ATTR_BLOCKCHAIN_OPERATION_NAME}. */
|
|
163
332
|
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_SEND: "send";
|
|
164
333
|
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_CONFIRM: "confirm";
|
|
334
|
+
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_PAYMENT: "payment";
|
|
335
|
+
/** Values for {@link ATTR_BLOCKCHAIN_PAYMENT_PROTOCOL}. */
|
|
336
|
+
export declare const BLOCKCHAIN_PAYMENT_PROTOCOL_VALUE_X402: "x402";
|
|
337
|
+
/** Values for {@link ATTR_BLOCKCHAIN_PAYMENT_STATUS}. */
|
|
338
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_SETTLED: "settled";
|
|
339
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_PENDING: "pending";
|
|
340
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_FAILED: "failed";
|
|
165
341
|
/** Values for {@link ATTR_BLOCKCHAIN_TX_STATUS}. */
|
|
166
342
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_SUCCESS: "success";
|
|
167
343
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_REVERTED: "reverted";
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated A confirm span that gave up waiting records `error.type` `timeout`; this value of
|
|
346
|
+
* `blockchain.tx.status` stops being recorded in a later minor release and the constant is removed in 1.0. See
|
|
347
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0016-timeout-is-an-observer-outcome.md.
|
|
348
|
+
*/
|
|
168
349
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_TIMEOUT: "timeout";
|
|
169
350
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_REPLACED: "replaced";
|
|
170
351
|
/** Values for {@link ATTR_BLOCKCHAIN_TX_REPLACEMENT_REASON}, as reported by the instrumented library. */
|
|
@@ -177,6 +358,11 @@ export declare const ATTR_ERROR_TYPE: "error.type";
|
|
|
177
358
|
export declare const ERROR_TYPE_VALUE_OTHER: "_OTHER";
|
|
178
359
|
//#endregion
|
|
179
360
|
//#region src/tracker.d.ts
|
|
361
|
+
/**
|
|
362
|
+
* Records transactions and payments as spans. Obtain one from {@link createTxTracker}: it is not meant to be
|
|
363
|
+
* implemented, and members may be added to it and to its handles in minor releases
|
|
364
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0014-core-api-boundary.md).
|
|
365
|
+
*/
|
|
180
366
|
interface TxTracker {
|
|
181
367
|
/**
|
|
182
368
|
* Starts a `send` span as a child of `parent` (default: the active context).
|
|
@@ -190,10 +376,24 @@ interface TxTracker {
|
|
|
190
376
|
* transaction that recently got a receipt. Every returned handle must be ended.
|
|
191
377
|
*/
|
|
192
378
|
startConfirm(input: ConfirmInput, parent?: Context): ConfirmHandle;
|
|
379
|
+
/**
|
|
380
|
+
* Starts a `payment` span as a child of `parent` (default: the active context), for a payment that another party
|
|
381
|
+
* settles on chain
|
|
382
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/adr/0013-x402-payments.md). Call
|
|
383
|
+
* `end(settlement)` with the settlement, or `fail(error)`. A settlement with a hash links the transaction's confirm
|
|
384
|
+
* span to this span, as a send span would.
|
|
385
|
+
*/
|
|
386
|
+
startPayment(input: PaymentInput, parent?: Context): PaymentHandle;
|
|
193
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Creates a tracker that records transactions as `send` and `confirm` spans, and payments as `payment` spans, with
|
|
390
|
+
* `@opentelemetry/api` (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.4.0/docs/semconv.md). It makes
|
|
391
|
+
* no network calls; the caller passes hashes and receipts. Its methods and handles never throw: failures are logged
|
|
392
|
+
* via `diag`, and a method that fails returns a handle that records nothing.
|
|
393
|
+
*/
|
|
194
394
|
export declare function createTxTracker(options?: TxTrackerOptions): TxTracker;
|
|
195
395
|
//#endregion
|
|
196
396
|
//#region src/version.d.ts
|
|
197
397
|
export declare const VERSION: string;
|
|
198
398
|
//#endregion
|
|
199
|
-
export type { AddressMode, AddressOptions, AgentIdentity, ConfirmHandle, ConfirmInput, ErrorMessageMode, ReceiptLike, ReplacementReason, SendHandle, SendInput, TxTracker, TxTrackerOptions };
|
|
399
|
+
export type { AddressMode, AddressOptions, AgentIdentity, ConfirmHandle, ConfirmInput, EndOptions, ErrorMessageMode, FailOptions, PaymentHandle, PaymentInput, PaymentResourceMode, PaymentSettlement, PaymentStatus, ReceiptLike, ReplacementReason, SendHandle, SendInput, SendResult, TxTracker, TxTrackerOptions, X402PaymentDetails };
|