@miradorlabs/parallax-web 1.0.6 → 1.0.8
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.ts +93 -83
- package/dist/index.esm.js +594 -3048
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +594 -3047
- package/dist/index.umd.js.map +1 -1
- package/example/README.md +257 -0
- package/example/app.js +411 -0
- package/example/index.html +469 -0
- package/example/package-lock.json +1877 -0
- package/example/package.json +33 -0
- package/example/proxy-server.js +86 -0
- package/example/rollup.config.js +16 -0
- package/index.ts +0 -10
- package/package.json +3 -2
- package/src/grpc/index.ts +2 -2
- package/src/parallax/ParallaxService.ts +62 -180
- package/src/parallax/index.ts +169 -156
- package/PARALLAX_SERVICE_USAGE.md +0 -306
- package/SETUP.md +0 -220
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreateTraceRequest, CreateTraceResponse
|
|
2
|
-
export {
|
|
1
|
+
import { CreateTraceRequest, CreateTraceResponse } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
|
2
|
+
export { CreateTraceRequest, CreateTraceResponse } from 'mirador-gateway-parallax-web/proto/gateway/parallax/v1/parallax_gateway_pb';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
declare class ParallaxClient {
|
|
@@ -39,97 +39,96 @@ declare class ParallaxClient {
|
|
|
39
39
|
*/
|
|
40
40
|
createTrace(params: CreateTraceRequest): Promise<CreateTraceResponse>;
|
|
41
41
|
/**
|
|
42
|
-
* Create a
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Start a new span within a trace
|
|
61
|
-
* @param params Parameters to start a new span
|
|
42
|
+
* Create a new trace builder
|
|
43
|
+
*
|
|
44
|
+
* Example usage:
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const response = await client.trace("swap_execution")
|
|
47
|
+
* .addAttribute("user", "0xabc...")
|
|
48
|
+
* .addAttribute("slippage_bps", 25)
|
|
49
|
+
* .addTag("dex")
|
|
50
|
+
* .addTag("swap")
|
|
51
|
+
* .addEvent("wallet_connected", { wallet: "MetaMask" })
|
|
52
|
+
* .addEvent("quote_received")
|
|
53
|
+
* .submit("0x123...", "ethereum");
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param name The name of the trace
|
|
57
|
+
* @param includeClientMeta Optional flag to automatically include client metadata
|
|
58
|
+
* @returns A ParallaxTrace builder instance
|
|
62
59
|
*/
|
|
63
|
-
|
|
60
|
+
trace(name: string, includeClientMeta?: boolean): ParallaxTrace;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Builder class for constructing traces with method chaining
|
|
64
|
+
* Automatically handles web-specific features like client metadata
|
|
65
|
+
*/
|
|
66
|
+
declare class ParallaxTrace {
|
|
67
|
+
private name;
|
|
68
|
+
private attributes;
|
|
69
|
+
private tags;
|
|
70
|
+
private events;
|
|
71
|
+
private txHashHint?;
|
|
72
|
+
private client;
|
|
73
|
+
private includeClientMeta;
|
|
74
|
+
constructor(client: ParallaxClient, name: string, includeClientMeta?: boolean);
|
|
64
75
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @
|
|
76
|
+
* Add an attribute to the trace
|
|
77
|
+
* @param key Attribute key
|
|
78
|
+
* @param value Attribute value (will be converted to string)
|
|
79
|
+
* @returns This trace builder for chaining
|
|
68
80
|
*/
|
|
69
|
-
|
|
70
|
-
traceId: string;
|
|
71
|
-
spanId: string;
|
|
72
|
-
status?: {
|
|
73
|
-
success: boolean;
|
|
74
|
-
errorMessage: string;
|
|
75
|
-
};
|
|
76
|
-
}): FinishSpanRequest;
|
|
81
|
+
addAttribute(key: string, value: string | number | boolean): this;
|
|
77
82
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
83
|
+
* Add multiple attributes to the trace
|
|
84
|
+
* @param attributes Object containing key-value pairs
|
|
85
|
+
* @returns This trace builder for chaining
|
|
80
86
|
*/
|
|
81
|
-
|
|
87
|
+
addAttributes(attributes: {
|
|
88
|
+
[key: string]: string | number | boolean;
|
|
89
|
+
}): this;
|
|
82
90
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
85
|
-
* @returns
|
|
91
|
+
* Add a tag to the trace
|
|
92
|
+
* @param tag Tag to add
|
|
93
|
+
* @returns This trace builder for chaining
|
|
86
94
|
*/
|
|
87
|
-
|
|
88
|
-
traceId: string;
|
|
89
|
-
spanId: string;
|
|
90
|
-
eventName: string;
|
|
91
|
-
attr?: {
|
|
92
|
-
[key: string]: string;
|
|
93
|
-
};
|
|
94
|
-
}): AddSpanEventRequest;
|
|
95
|
+
addTag(tag: string): this;
|
|
95
96
|
/**
|
|
96
|
-
* Add
|
|
97
|
-
* @param
|
|
97
|
+
* Add multiple tags to the trace
|
|
98
|
+
* @param tags Array of tags to add
|
|
99
|
+
* @returns This trace builder for chaining
|
|
98
100
|
*/
|
|
99
|
-
|
|
101
|
+
addTags(tags: string[]): this;
|
|
100
102
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
103
|
+
* Add an event to the trace
|
|
104
|
+
* @param eventName Name of the event
|
|
105
|
+
* @param details Optional details (can be a JSON string or object that will be stringified)
|
|
106
|
+
* @param timestamp Optional timestamp (defaults to current time)
|
|
107
|
+
* @returns This trace builder for chaining
|
|
104
108
|
*/
|
|
105
|
-
|
|
106
|
-
traceId: string;
|
|
107
|
-
spanId: string;
|
|
108
|
-
errorMessage: string;
|
|
109
|
-
errorType?: string;
|
|
110
|
-
stackTrace?: string;
|
|
111
|
-
}): AddSpanErrorRequest;
|
|
109
|
+
addEvent(eventName: string, details?: string | object, timestamp?: Date): this;
|
|
112
110
|
/**
|
|
113
|
-
*
|
|
114
|
-
* @param
|
|
111
|
+
* Set or update the transaction hash hint
|
|
112
|
+
* @param txHash Transaction hash
|
|
113
|
+
* @param chainId Chain ID (e.g., "ethereum", "polygon")
|
|
114
|
+
* @param details Optional details about the transaction
|
|
115
|
+
* @param timestamp Optional timestamp (defaults to current time)
|
|
116
|
+
* @returns This trace builder for chaining
|
|
115
117
|
*/
|
|
116
|
-
|
|
118
|
+
setTxHash(txHash: string, chainId: string, details?: string, timestamp?: Date): this;
|
|
117
119
|
/**
|
|
118
|
-
*
|
|
119
|
-
* @
|
|
120
|
-
* @returns AddSpanHintRequest
|
|
120
|
+
* Submit the trace without a transaction hash hint (if not already set via setTxHash)
|
|
121
|
+
* @returns Response from the create trace operation
|
|
121
122
|
*/
|
|
122
|
-
|
|
123
|
-
traceId: string;
|
|
124
|
-
parentSpanId: string;
|
|
125
|
-
txHash?: string;
|
|
126
|
-
chainId?: number;
|
|
127
|
-
}): AddSpanHintRequest;
|
|
123
|
+
submit(): Promise<CreateTraceResponse>;
|
|
128
124
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @param
|
|
125
|
+
* Submit the trace with a transaction hash hint (overrides any previously set via setTxHash)
|
|
126
|
+
* @param txHash Transaction hash
|
|
127
|
+
* @param chainId Chain ID (e.g., "ethereum", "polygon")
|
|
128
|
+
* @param details Optional details about the transaction
|
|
129
|
+
* @returns Response from the create trace operation
|
|
131
130
|
*/
|
|
132
|
-
|
|
131
|
+
submit(txHash: string, chainId: string, details?: string): Promise<CreateTraceResponse>;
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
interface Metadata {
|
|
@@ -161,8 +160,6 @@ declare class GrpcWebRpc implements Rpc {
|
|
|
161
160
|
|
|
162
161
|
interface TransactionInfo {
|
|
163
162
|
traceId: string;
|
|
164
|
-
rootSpanId: string;
|
|
165
|
-
spanId: string | null;
|
|
166
163
|
timestamp: string;
|
|
167
164
|
txHash: string | null;
|
|
168
165
|
from?: string;
|
|
@@ -195,8 +192,7 @@ declare class ParallaxService {
|
|
|
195
192
|
* Start a new transaction trace
|
|
196
193
|
* Called when user initiates a transaction
|
|
197
194
|
*
|
|
198
|
-
*
|
|
199
|
-
* to call startSpan separately. The rootSpanId from the response is the parent span.
|
|
195
|
+
* Uses the builder pattern to create a trace with events
|
|
200
196
|
*
|
|
201
197
|
* @param txData - Transaction data
|
|
202
198
|
* @param name - Name for the trace (e.g., 'SendingTrace', 'SwappingTrace')
|
|
@@ -216,34 +212,48 @@ declare class ParallaxService {
|
|
|
216
212
|
* Associate a transaction hash with an existing trace
|
|
217
213
|
* Called when the transaction hash is available after signing/sending
|
|
218
214
|
*
|
|
215
|
+
* NOTE: This method is deprecated as the new API does not support adding hints to existing traces.
|
|
216
|
+
* Transaction hashes should be provided at trace creation time via the builder's submit(txHash, chainId) method.
|
|
217
|
+
*
|
|
219
218
|
* @param txId - Transaction identifier returned from startTransactionTrace
|
|
220
219
|
* @param txHash - Blockchain transaction hash
|
|
221
220
|
* @param chainId - Chain ID
|
|
221
|
+
* @deprecated Use submit(txHash, chainId) when creating the trace instead
|
|
222
222
|
*/
|
|
223
223
|
associateTransactionHash(txId: string, txHash: string, chainId: number): Promise<void>;
|
|
224
224
|
/**
|
|
225
225
|
* Add an event to a transaction trace
|
|
226
226
|
*
|
|
227
|
+
* NOTE: This method is deprecated as the new API does not support adding events to existing traces.
|
|
228
|
+
* Events should be added to the trace builder before calling submit().
|
|
229
|
+
*
|
|
227
230
|
* @param txId - Transaction identifier
|
|
228
231
|
* @param eventName - Event name
|
|
229
232
|
* @param attributes - Event attributes
|
|
233
|
+
* @deprecated Use the trace builder's addEvent() method before calling submit() instead
|
|
230
234
|
*/
|
|
231
235
|
addTransactionEvent(txId: string, eventName: string, attributes?: Record<string, any>): Promise<void>;
|
|
232
236
|
/**
|
|
233
237
|
* Add an error to a transaction trace
|
|
234
|
-
*
|
|
238
|
+
*
|
|
239
|
+
* NOTE: This method is deprecated as the new API does not support adding errors to existing traces.
|
|
240
|
+
* Errors should be added as events to the trace builder before calling submit().
|
|
235
241
|
*
|
|
236
242
|
* @param txId - Transaction identifier
|
|
237
243
|
* @param error - Error object or message
|
|
238
244
|
* @param errorType - Type/category of error (e.g., 'TransactionError', 'NetworkError', 'UserRejection')
|
|
245
|
+
* @deprecated Use the trace builder's addEvent() method to add error events before calling submit() instead
|
|
239
246
|
*/
|
|
240
247
|
addTransactionError(txId: string, error: Error | string, errorType?: string): Promise<void>;
|
|
241
248
|
/**
|
|
242
249
|
* Finish a transaction trace
|
|
243
|
-
*
|
|
250
|
+
*
|
|
251
|
+
* NOTE: This method is deprecated as the new API does not support span lifecycle management.
|
|
252
|
+
* Traces are completed when submit() is called on the builder.
|
|
244
253
|
*
|
|
245
254
|
* @param txId - Transaction identifier
|
|
246
255
|
* @param options - Finish options (success, error message)
|
|
256
|
+
* @deprecated Traces are automatically completed when submit() is called
|
|
247
257
|
*/
|
|
248
258
|
finishTransactionTrace(txId: string, options?: FinishOptions): Promise<void>;
|
|
249
259
|
/**
|
|
@@ -270,4 +280,4 @@ declare class ParallaxService {
|
|
|
270
280
|
}
|
|
271
281
|
declare const parallaxService: ParallaxService;
|
|
272
282
|
|
|
273
|
-
export { GrpcWebRpc, ParallaxClient, ParallaxService, parallaxService };
|
|
283
|
+
export { GrpcWebRpc, ParallaxClient, ParallaxService, ParallaxTrace, parallaxService };
|