@hashspan/core 0.3.0 → 0.5.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 +30 -13
- package/dist/index.cjs +256 -21
- package/dist/index.d.cts +214 -18
- package/dist/index.d.mts +214 -18
- package/dist/index.mjs +243 -22
- package/package.json +1 -1
package/dist/index.d.cts
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.5.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.5.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.5.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,29 +87,65 @@ 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.5.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.5.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.5.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;
|
|
86
139
|
}
|
|
87
|
-
|
|
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 {
|
|
88
149
|
/**
|
|
89
150
|
* `error.type` to record instead of the error's class name, for adapters whose library reports a stable,
|
|
90
151
|
* machine-readable error code (for example a wallet API's error type). Recorded only if it matches
|
|
@@ -94,7 +155,9 @@ interface FailOptions {
|
|
|
94
155
|
errorType?: string | undefined;
|
|
95
156
|
}
|
|
96
157
|
interface ConfirmInput {
|
|
158
|
+
/** EIP-155 chain id; with `hash`, it identifies the transaction and its confirm span. */
|
|
97
159
|
chainId: number;
|
|
160
|
+
/** Hash of the transaction awaited, `0x`-prefixed. */
|
|
98
161
|
hash: string;
|
|
99
162
|
/** When the wait started, for adapters that record it after the fact; see {@link SendInput.startTime}. */
|
|
100
163
|
startTime?: TimeInput | undefined;
|
|
@@ -103,6 +166,7 @@ interface ConfirmInput {
|
|
|
103
166
|
type ReplacementReason = "repriced" | "cancelled" | "replaced";
|
|
104
167
|
/** Library-agnostic view of a transaction receipt. Adapters normalise their client's receipt into this. */
|
|
105
168
|
interface ReceiptLike {
|
|
169
|
+
/** `reverted` ends the confirm span with an error status and `error.type` `reverted`. */
|
|
106
170
|
status: "success" | "reverted";
|
|
107
171
|
blockNumber: bigint | number;
|
|
108
172
|
gasUsed: bigint | number;
|
|
@@ -110,29 +174,112 @@ interface ReceiptLike {
|
|
|
110
174
|
effectiveGasPrice?: bigint | undefined;
|
|
111
175
|
/** L1 data fee in wei on OP-stack chains. */
|
|
112
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
|
+
*/
|
|
113
181
|
revertReason?: string | undefined;
|
|
114
182
|
/**
|
|
115
|
-
* Hash of the mined transaction. When it differs from the awaited hash, the awaited transaction was replaced:
|
|
116
|
-
*
|
|
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.5.0/docs/adr/0008-replaced-transactions.md).
|
|
117
186
|
*/
|
|
118
187
|
transactionHash?: string | undefined;
|
|
119
188
|
/** Replacement reason reported by the library, when {@link transactionHash} differs from the awaited hash. */
|
|
120
189
|
replacementReason?: ReplacementReason | undefined;
|
|
121
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.5.0/docs/adr/0014-core-api-boundary.md).
|
|
196
|
+
*/
|
|
122
197
|
interface ConfirmHandle {
|
|
123
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. */
|
|
124
201
|
end(receipt: ReceiptLike, endTime?: TimeInput): void;
|
|
125
202
|
/**
|
|
126
203
|
* Withdraws this handle because waiting for the receipt timed out. The confirm span ends as `timeout` only if
|
|
127
204
|
* no other handle of the transaction is still waiting.
|
|
128
205
|
*/
|
|
206
|
+
timeout(options?: EndOptions): void;
|
|
207
|
+
/** @deprecated Use `timeout({ endTime })`; removed in 1.0. */
|
|
129
208
|
timeout(endTime?: TimeInput): void;
|
|
130
209
|
/**
|
|
131
210
|
* Withdraws this handle because retrieving the receipt failed. The confirm span ends as a failure only if no
|
|
132
211
|
* other handle of the transaction is still waiting.
|
|
133
212
|
*/
|
|
213
|
+
fail(error: unknown, options?: EndOptions): void;
|
|
214
|
+
/** @deprecated Use `fail(error, { endTime })`; removed in 1.0. */
|
|
134
215
|
fail(error: unknown, endTime?: TimeInput): void;
|
|
135
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.5.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
|
+
/**
|
|
256
|
+
* Amount settled, when the settlement reports it, recorded as `blockchain.payment.settled_amount`; also as
|
|
257
|
+
* `blockchain.payment.amount` when the input had none.
|
|
258
|
+
*/
|
|
259
|
+
amount?: bigint | string | undefined;
|
|
260
|
+
/** Why a `failed` settlement failed, recorded as `error.type` if it is a short identifier, else `_OTHER`. */
|
|
261
|
+
errorReason?: string | undefined;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Ends a payment span. Only the first call counts; methods never throw.
|
|
265
|
+
* Produced by the tracker only; methods may be added in minor releases
|
|
266
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0014-core-api-boundary.md).
|
|
267
|
+
*/
|
|
268
|
+
interface PaymentHandle {
|
|
269
|
+
/** Ends the payment span with its settlement. */
|
|
270
|
+
end(settlement: PaymentSettlement, options?: EndOptions): void;
|
|
271
|
+
/**
|
|
272
|
+
* Ends the payment span with an error when the payment could not be made, e.g. signing it failed. Called without
|
|
273
|
+
* an error, as `fail(undefined, { errorType })`, it records no exception event: for outcomes that are not
|
|
274
|
+
* exceptions, such as a response without a settlement (`no_settlement`).
|
|
275
|
+
*/
|
|
276
|
+
fail(error: unknown, options?: FailOptions): void;
|
|
277
|
+
/**
|
|
278
|
+
* Ends the payment span with `error.type` `timeout` and no `blockchain.payment.status`, when its outcome was never
|
|
279
|
+
* learned, e.g. no response arrived before the authorization expired.
|
|
280
|
+
*/
|
|
281
|
+
timeout(options?: EndOptions): void;
|
|
282
|
+
}
|
|
136
283
|
//#endregion
|
|
137
284
|
//#region src/agent.d.ts
|
|
138
285
|
export declare const ATTR_GEN_AI_AGENT_ID: "gen_ai.agent.id";
|
|
@@ -142,8 +289,8 @@ export declare const ATTR_GEN_AI_AGENT_NAME: "gen_ai.agent.name";
|
|
|
142
289
|
/**
|
|
143
290
|
* Attribute keys emitted by hashspan.
|
|
144
291
|
*
|
|
145
|
-
* Stability: development. See docs/semconv.md for
|
|
146
|
-
* These names are a public contract: changes follow the deprecation policy in AGENTS.md.
|
|
292
|
+
* Stability: development. See https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/semconv.md for
|
|
293
|
+
* definitions and value types. These names are a public contract: changes follow the deprecation policy in AGENTS.md.
|
|
147
294
|
*/
|
|
148
295
|
export declare const ATTR_BLOCKCHAIN_SYSTEM: "blockchain.system";
|
|
149
296
|
export declare const ATTR_BLOCKCHAIN_CHAIN_ID: "blockchain.chain.id";
|
|
@@ -164,16 +311,46 @@ export declare const ATTR_BLOCKCHAIN_TX_REPLACEMENT_REASON: "blockchain.tx.repla
|
|
|
164
311
|
export declare const ATTR_BLOCKCHAIN_BLOCK_NUMBER: "blockchain.block.number";
|
|
165
312
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_NAME: "blockchain.contract.function.name";
|
|
166
313
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_SELECTOR: "blockchain.contract.function.selector";
|
|
167
|
-
/**
|
|
314
|
+
/**
|
|
315
|
+
* Opt-in: decoded call arguments as a JSON array. See
|
|
316
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0004-privacy-defaults.md.
|
|
317
|
+
*/
|
|
168
318
|
export declare const ATTR_BLOCKCHAIN_CONTRACT_FUNCTION_ARGUMENTS: "blockchain.contract.function.arguments";
|
|
319
|
+
/**
|
|
320
|
+
* Payments settled on chain by a party other than the agent, e.g. an x402 facilitator. See
|
|
321
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0013-x402-payments.md.
|
|
322
|
+
*/
|
|
323
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_PROTOCOL: "blockchain.payment.protocol";
|
|
324
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_PAYER: "blockchain.payment.payer";
|
|
325
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_RECIPIENT: "blockchain.payment.recipient";
|
|
326
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_ASSET: "blockchain.payment.asset";
|
|
327
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_AMOUNT: "blockchain.payment.amount";
|
|
328
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_STATUS: "blockchain.payment.status";
|
|
329
|
+
/** The amount the settling party reports it settled, e.g. less than the authorized maximum with x402 `upto`. */
|
|
330
|
+
export declare const ATTR_BLOCKCHAIN_PAYMENT_SETTLED_AMOUNT: "blockchain.payment.settled_amount";
|
|
331
|
+
/** x402's own payment fields. */
|
|
332
|
+
export declare const ATTR_X402_SCHEME: "x402.scheme";
|
|
333
|
+
export declare const ATTR_X402_RESOURCE: "x402.resource";
|
|
169
334
|
/** Values for {@link ATTR_BLOCKCHAIN_SYSTEM}. */
|
|
170
335
|
export declare const BLOCKCHAIN_SYSTEM_VALUE_EVM: "evm";
|
|
171
336
|
/** Values for {@link ATTR_BLOCKCHAIN_OPERATION_NAME}. */
|
|
172
337
|
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_SEND: "send";
|
|
173
338
|
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_CONFIRM: "confirm";
|
|
339
|
+
export declare const BLOCKCHAIN_OPERATION_NAME_VALUE_PAYMENT: "payment";
|
|
340
|
+
/** Values for {@link ATTR_BLOCKCHAIN_PAYMENT_PROTOCOL}. */
|
|
341
|
+
export declare const BLOCKCHAIN_PAYMENT_PROTOCOL_VALUE_X402: "x402";
|
|
342
|
+
/** Values for {@link ATTR_BLOCKCHAIN_PAYMENT_STATUS}. */
|
|
343
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_SETTLED: "settled";
|
|
344
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_PENDING: "pending";
|
|
345
|
+
export declare const BLOCKCHAIN_PAYMENT_STATUS_VALUE_FAILED: "failed";
|
|
174
346
|
/** Values for {@link ATTR_BLOCKCHAIN_TX_STATUS}. */
|
|
175
347
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_SUCCESS: "success";
|
|
176
348
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_REVERTED: "reverted";
|
|
349
|
+
/**
|
|
350
|
+
* @deprecated No longer recorded: a confirm span that gave up waiting records `error.type` `timeout` and no
|
|
351
|
+
* `blockchain.tx.status`. The constant is removed in 1.0. See
|
|
352
|
+
* https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0016-timeout-is-an-observer-outcome.md.
|
|
353
|
+
*/
|
|
177
354
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_TIMEOUT: "timeout";
|
|
178
355
|
export declare const BLOCKCHAIN_TX_STATUS_VALUE_REPLACED: "replaced";
|
|
179
356
|
/** Values for {@link ATTR_BLOCKCHAIN_TX_REPLACEMENT_REASON}, as reported by the instrumented library. */
|
|
@@ -186,6 +363,11 @@ export declare const ATTR_ERROR_TYPE: "error.type";
|
|
|
186
363
|
export declare const ERROR_TYPE_VALUE_OTHER: "_OTHER";
|
|
187
364
|
//#endregion
|
|
188
365
|
//#region src/tracker.d.ts
|
|
366
|
+
/**
|
|
367
|
+
* Records transactions and payments as spans. Obtain one from {@link createTxTracker}: it is not meant to be
|
|
368
|
+
* implemented, and members may be added to it and to its handles in minor releases
|
|
369
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0014-core-api-boundary.md).
|
|
370
|
+
*/
|
|
189
371
|
interface TxTracker {
|
|
190
372
|
/**
|
|
191
373
|
* Starts a `send` span as a child of `parent` (default: the active context).
|
|
@@ -199,10 +381,24 @@ interface TxTracker {
|
|
|
199
381
|
* transaction that recently got a receipt. Every returned handle must be ended.
|
|
200
382
|
*/
|
|
201
383
|
startConfirm(input: ConfirmInput, parent?: Context): ConfirmHandle;
|
|
384
|
+
/**
|
|
385
|
+
* Starts a `payment` span as a child of `parent` (default: the active context), for a payment that another party
|
|
386
|
+
* settles on chain
|
|
387
|
+
* (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/adr/0013-x402-payments.md). Call
|
|
388
|
+
* `end(settlement)` with the settlement, or `fail(error)`. A settlement with a hash links the transaction's confirm
|
|
389
|
+
* span to this span, as a send span would.
|
|
390
|
+
*/
|
|
391
|
+
startPayment(input: PaymentInput, parent?: Context): PaymentHandle;
|
|
202
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Creates a tracker that records transactions as `send` and `confirm` spans, and payments as `payment` spans, with
|
|
395
|
+
* `@opentelemetry/api` (https://github.com/selimaytac/hashspan/blob/@hashspan/core@0.5.0/docs/semconv.md). It makes
|
|
396
|
+
* no network calls; the caller passes hashes and receipts. Its methods and handles never throw: failures are logged
|
|
397
|
+
* via `diag`, and a method that fails returns a handle that records nothing.
|
|
398
|
+
*/
|
|
203
399
|
export declare function createTxTracker(options?: TxTrackerOptions): TxTracker;
|
|
204
400
|
//#endregion
|
|
205
401
|
//#region src/version.d.ts
|
|
206
402
|
export declare const VERSION: string;
|
|
207
403
|
//#endregion
|
|
208
|
-
export type { AddressMode, AddressOptions, AgentIdentity, ConfirmHandle, ConfirmInput, ErrorMessageMode, FailOptions, ReceiptLike, ReplacementReason, SendHandle, SendInput, TxTracker, TxTrackerOptions };
|
|
404
|
+
export type { AddressMode, AddressOptions, AgentIdentity, ConfirmHandle, ConfirmInput, EndOptions, ErrorMessageMode, FailOptions, PaymentHandle, PaymentInput, PaymentResourceMode, PaymentSettlement, PaymentStatus, ReceiptLike, ReplacementReason, SendHandle, SendInput, SendResult, TxTracker, TxTrackerOptions, X402PaymentDetails };
|