@hashlock-tech/sdk 0.1.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.js ADDED
@@ -0,0 +1,507 @@
1
+ // src/errors.ts
2
+ var HashLockError = class extends Error {
3
+ constructor(message, code, details) {
4
+ super(message);
5
+ this.code = code;
6
+ this.details = details;
7
+ this.name = "HashLockError";
8
+ }
9
+ code;
10
+ details;
11
+ };
12
+ var GraphQLError = class extends HashLockError {
13
+ constructor(message, errors) {
14
+ super(message, "GRAPHQL_ERROR", errors);
15
+ this.errors = errors;
16
+ this.name = "GraphQLError";
17
+ }
18
+ errors;
19
+ };
20
+ var NetworkError = class extends HashLockError {
21
+ constructor(message, cause) {
22
+ super(message, "NETWORK_ERROR", cause);
23
+ this.cause = cause;
24
+ this.name = "NetworkError";
25
+ }
26
+ cause;
27
+ };
28
+ var AuthError = class extends HashLockError {
29
+ constructor(message = "Authentication required \u2014 set accessToken in config or call setAccessToken()") {
30
+ super(message, "AUTH_ERROR");
31
+ this.name = "AuthError";
32
+ }
33
+ };
34
+
35
+ // src/client.ts
36
+ var DEFAULT_TIMEOUT = 3e4;
37
+ var DEFAULT_RETRIES = 3;
38
+ var RETRY_DELAY_BASE = 1e3;
39
+ var GraphQLClient = class {
40
+ endpoint;
41
+ accessToken;
42
+ timeout;
43
+ retries;
44
+ fetchFn;
45
+ constructor(config) {
46
+ this.endpoint = config.endpoint;
47
+ this.accessToken = config.accessToken;
48
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
49
+ this.retries = config.retries ?? DEFAULT_RETRIES;
50
+ this.fetchFn = config.fetch ?? globalThis.fetch;
51
+ if (!this.fetchFn) {
52
+ throw new Error("fetch is not available \u2014 pass a custom fetch implementation or use Node.js >= 18");
53
+ }
54
+ }
55
+ setAccessToken(token) {
56
+ this.accessToken = token;
57
+ }
58
+ /**
59
+ * Execute a GraphQL query with automatic retries on transient failures.
60
+ * Retries on: network errors, 5xx status codes.
61
+ * Does NOT retry on: 4xx errors, GraphQL validation errors.
62
+ */
63
+ async query(query, variables) {
64
+ return this.execute(query, variables, true);
65
+ }
66
+ /**
67
+ * Execute a GraphQL mutation.
68
+ * Only retries on network errors (not on 5xx — mutations are not idempotent).
69
+ */
70
+ async mutate(query, variables) {
71
+ return this.execute(query, variables, false);
72
+ }
73
+ async execute(query, variables, retryOn5xx) {
74
+ let lastError;
75
+ for (let attempt = 0; attempt <= this.retries; attempt++) {
76
+ try {
77
+ const controller = new AbortController();
78
+ const timer = setTimeout(() => controller.abort(), this.timeout);
79
+ const headers = {
80
+ "Content-Type": "application/json",
81
+ "Accept": "application/json"
82
+ };
83
+ if (this.accessToken) {
84
+ headers["Authorization"] = `Bearer ${this.accessToken}`;
85
+ }
86
+ const response = await this.fetchFn(this.endpoint, {
87
+ method: "POST",
88
+ headers,
89
+ body: JSON.stringify({ query, variables }),
90
+ signal: controller.signal
91
+ });
92
+ clearTimeout(timer);
93
+ if (response.status === 401 || response.status === 403) {
94
+ throw new AuthError(`HTTP ${response.status}: ${response.statusText}`);
95
+ }
96
+ if (response.status >= 500) {
97
+ const msg = `Server error: HTTP ${response.status}`;
98
+ if (retryOn5xx && attempt < this.retries) {
99
+ lastError = new NetworkError(msg);
100
+ await this.delay(attempt);
101
+ continue;
102
+ }
103
+ throw new NetworkError(msg);
104
+ }
105
+ const json = await response.json();
106
+ if (json.errors?.length) {
107
+ throw new GraphQLError(
108
+ json.errors[0].message,
109
+ json.errors
110
+ );
111
+ }
112
+ if (!json.data) {
113
+ throw new GraphQLError("No data returned", [{ message: "Empty response" }]);
114
+ }
115
+ return json.data;
116
+ } catch (err) {
117
+ if (err instanceof AuthError || err instanceof GraphQLError) {
118
+ throw err;
119
+ }
120
+ const isAbort = err instanceof DOMException && err.name === "AbortError";
121
+ const isNetwork = err instanceof TypeError;
122
+ if ((isAbort || isNetwork) && attempt < this.retries) {
123
+ lastError = err instanceof Error ? err : new Error(String(err));
124
+ await this.delay(attempt);
125
+ continue;
126
+ }
127
+ if (err instanceof NetworkError) throw err;
128
+ throw new NetworkError(
129
+ isAbort ? "Request timed out" : `Network error: ${err instanceof Error ? err.message : err}`,
130
+ err instanceof Error ? err : void 0
131
+ );
132
+ }
133
+ }
134
+ throw lastError ?? new NetworkError("Request failed after all retries");
135
+ }
136
+ delay(attempt) {
137
+ const ms = RETRY_DELAY_BASE * Math.pow(2, attempt);
138
+ return new Promise((resolve) => setTimeout(resolve, ms));
139
+ }
140
+ };
141
+
142
+ // src/hashlock.ts
143
+ var MAINNET_ENDPOINT = "http://142.93.106.129/graphql";
144
+ var HashLock = class {
145
+ client;
146
+ constructor(config) {
147
+ this.client = new GraphQLClient(config);
148
+ }
149
+ /** Update the access token (e.g., after login or token refresh) */
150
+ setAccessToken(token) {
151
+ this.client.setAccessToken(token);
152
+ }
153
+ // ─── RFQ ─────────────────────────────────────────────────
154
+ /**
155
+ * Create a Request for Quote (RFQ).
156
+ * Broadcasts to market makers who can respond with prices.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const rfq = await hl.createRFQ({
161
+ * baseToken: 'ETH',
162
+ * quoteToken: 'USDT',
163
+ * side: 'SELL',
164
+ * amount: '10.0',
165
+ * expiresIn: 300, // 5 minutes
166
+ * });
167
+ * console.log(`RFQ created: ${rfq.id}`);
168
+ * ```
169
+ */
170
+ async createRFQ(input) {
171
+ const { createRFQ } = await this.client.mutate(`
172
+ mutation CreateRFQ($baseToken: String!, $quoteToken: String!, $side: Side!, $amount: String!, $expiresIn: Int, $isBlind: Boolean) {
173
+ createRFQ(baseToken: $baseToken, quoteToken: $quoteToken, side: $side, amount: $amount, expiresIn: $expiresIn, isBlind: $isBlind) {
174
+ id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount
175
+ }
176
+ }
177
+ `, input);
178
+ return createRFQ;
179
+ }
180
+ /**
181
+ * Get a single RFQ by ID.
182
+ */
183
+ async getRFQ(id) {
184
+ const { rfq } = await this.client.query(`
185
+ query GetRFQ($id: ID!) {
186
+ rfq(id: $id) {
187
+ id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount
188
+ quotes { id rfqId marketMakerId price amount status createdAt }
189
+ }
190
+ }
191
+ `, { id });
192
+ return rfq;
193
+ }
194
+ /**
195
+ * List RFQs with optional status filter and pagination.
196
+ */
197
+ async listRFQs(params) {
198
+ const { rfqs } = await this.client.query(`
199
+ query ListRFQs($status: RFQStatus, $page: Int, $pageSize: Int) {
200
+ rfqs(status: $status, page: $page, pageSize: $pageSize) {
201
+ rfqs { id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount }
202
+ total page pageSize
203
+ }
204
+ }
205
+ `, params);
206
+ return rfqs;
207
+ }
208
+ /**
209
+ * Cancel an active RFQ.
210
+ */
211
+ async cancelRFQ(id) {
212
+ const { cancelRFQ } = await this.client.mutate(`
213
+ mutation CancelRFQ($id: ID!) {
214
+ cancelRFQ(id: $id) {
215
+ id status
216
+ }
217
+ }
218
+ `, { id });
219
+ return cancelRFQ;
220
+ }
221
+ // ─── Quotes ──────────────────────────────────────────────
222
+ /**
223
+ * Submit a price quote in response to an RFQ.
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * const quote = await hl.submitQuote({
228
+ * rfqId: 'rfq-uuid',
229
+ * price: '3450.00',
230
+ * amount: '10.0',
231
+ * });
232
+ * ```
233
+ */
234
+ async submitQuote(input) {
235
+ const { submitQuote } = await this.client.mutate(`
236
+ mutation SubmitQuote($rfqId: ID!, $price: String!, $amount: String!, $expiresIn: Int) {
237
+ submitQuote(rfqId: $rfqId, price: $price, amount: $amount, expiresIn: $expiresIn) {
238
+ id rfqId marketMakerId price amount status createdAt expiresAt
239
+ }
240
+ }
241
+ `, input);
242
+ return submitQuote;
243
+ }
244
+ /**
245
+ * Accept a quote — creates a trade from the RFQ flow.
246
+ */
247
+ async acceptQuote(quoteId) {
248
+ const { acceptQuote } = await this.client.mutate(`
249
+ mutation AcceptQuote($quoteId: ID!) {
250
+ acceptQuote(quoteId: $quoteId) {
251
+ id rfqId status trade { id status }
252
+ }
253
+ }
254
+ `, { quoteId });
255
+ return acceptQuote;
256
+ }
257
+ /**
258
+ * Get all quotes for an RFQ.
259
+ */
260
+ async getQuotes(rfqId) {
261
+ const { quotes } = await this.client.query(`
262
+ query GetQuotes($rfqId: ID!) {
263
+ quotes(rfqId: $rfqId) {
264
+ id rfqId marketMakerId price amount status createdAt expiresAt
265
+ deliveryDelayHours collateralBtcSats isCollateralBacked
266
+ }
267
+ }
268
+ `, { rfqId });
269
+ return quotes;
270
+ }
271
+ // ─── Trades ──────────────────────────────────────────────
272
+ /**
273
+ * Get a single trade by ID.
274
+ */
275
+ async getTrade(id) {
276
+ const { trade } = await this.client.query(`
277
+ query GetTrade($id: ID!) {
278
+ trade(id: $id) {
279
+ id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt
280
+ }
281
+ }
282
+ `, { id });
283
+ return trade;
284
+ }
285
+ /**
286
+ * List trades with optional status filter.
287
+ */
288
+ async listTrades(params) {
289
+ const { trades } = await this.client.query(`
290
+ query ListTrades($status: TradeStatus, $page: Int, $pageSize: Int) {
291
+ trades(status: $status, page: $page, pageSize: $pageSize) {
292
+ trades { id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt }
293
+ total
294
+ }
295
+ }
296
+ `, params);
297
+ return trades;
298
+ }
299
+ /**
300
+ * Create a direct trade from 1-on-1 chat (skips RFQ flow).
301
+ */
302
+ async confirmDirectTrade(input) {
303
+ const { confirmDirectTrade } = await this.client.mutate(`
304
+ mutation ConfirmDirectTrade($counterpartyId: ID!, $baseToken: String!, $quoteToken: String!, $side: Side!, $baseAmount: String!, $price: String!, $chainId: String!, $broadcastRfqId: ID, $conversationId: ID) {
305
+ confirmDirectTrade(counterpartyId: $counterpartyId, baseToken: $baseToken, quoteToken: $quoteToken, side: $side, baseAmount: $baseAmount, price: $price, chainId: $chainId, broadcastRfqId: $broadcastRfqId, conversationId: $conversationId) {
306
+ id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt
307
+ }
308
+ }
309
+ `, input);
310
+ return confirmDirectTrade;
311
+ }
312
+ /**
313
+ * Accept a proposed trade.
314
+ */
315
+ async acceptTrade(tradeId) {
316
+ const { acceptTrade } = await this.client.mutate(`
317
+ mutation AcceptTrade($tradeId: ID!) {
318
+ acceptTrade(tradeId: $tradeId) { id status }
319
+ }
320
+ `, { tradeId });
321
+ return acceptTrade;
322
+ }
323
+ /**
324
+ * Cancel a trade.
325
+ */
326
+ async cancelTrade(tradeId) {
327
+ const { cancelTrade } = await this.client.mutate(`
328
+ mutation CancelTrade($tradeId: ID!) {
329
+ cancelTrade(tradeId: $tradeId) { id status }
330
+ }
331
+ `, { tradeId });
332
+ return cancelTrade;
333
+ }
334
+ /**
335
+ * Confirm settlement wallets for a trade.
336
+ */
337
+ async confirmSettlementWallets(input) {
338
+ const { confirmSettlementWallets } = await this.client.mutate(`
339
+ mutation ConfirmWallets($tradeId: ID!, $sendWalletId: ID!, $receiveWalletId: ID!) {
340
+ confirmSettlementWallets(tradeId: $tradeId, sendWalletId: $sendWalletId, receiveWalletId: $receiveWalletId) {
341
+ id status
342
+ }
343
+ }
344
+ `, input);
345
+ return confirmSettlementWallets;
346
+ }
347
+ // ─── HTLC — EVM (ETH / ERC-20) ──────────────────────────
348
+ /**
349
+ * Record an on-chain HTLC funding transaction.
350
+ * Called after the user sends an ETH/ERC20 lock tx on-chain.
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * // After sending ETH lock tx on-chain via ethers/viem:
355
+ * const result = await hl.fundHTLC({
356
+ * tradeId: 'trade-uuid',
357
+ * txHash: '0xabc...',
358
+ * role: 'INITIATOR',
359
+ * timelock: Math.floor(Date.now() / 1000) + 3600,
360
+ * hashlock: '0x...',
361
+ * });
362
+ * ```
363
+ */
364
+ async fundHTLC(input) {
365
+ const { fundHTLC } = await this.client.mutate(`
366
+ mutation FundHTLC($tradeId: ID!, $txHash: String!, $role: HTLCRole!, $timelock: Int, $hashlock: String, $chainType: String, $senderPubKey: String, $receiverPubKey: String, $redeemScript: String, $refundTxHex: String, $preimage: String) {
367
+ fundHTLC(tradeId: $tradeId, txHash: $txHash, role: $role, timelock: $timelock, hashlock: $hashlock, chainType: $chainType, senderPubKey: $senderPubKey, receiverPubKey: $receiverPubKey, redeemScript: $redeemScript, refundTxHex: $refundTxHex, preimage: $preimage) {
368
+ tradeId txHash status
369
+ }
370
+ }
371
+ `, input);
372
+ return fundHTLC;
373
+ }
374
+ /**
375
+ * Record an on-chain HTLC claim (preimage reveal).
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * const result = await hl.claimHTLC({
380
+ * tradeId: 'trade-uuid',
381
+ * txHash: '0xdef...',
382
+ * preimage: '0x...',
383
+ * });
384
+ * ```
385
+ */
386
+ async claimHTLC(input) {
387
+ const { claimHTLC } = await this.client.mutate(`
388
+ mutation ClaimHTLC($tradeId: ID!, $txHash: String!, $preimage: String!, $chainType: String) {
389
+ claimHTLC(tradeId: $tradeId, txHash: $txHash, preimage: $preimage, chainType: $chainType) {
390
+ tradeId status
391
+ }
392
+ }
393
+ `, input);
394
+ return claimHTLC;
395
+ }
396
+ /**
397
+ * Record an on-chain HTLC refund (after timelock expiry).
398
+ *
399
+ * @example
400
+ * ```ts
401
+ * const result = await hl.refundHTLC({
402
+ * tradeId: 'trade-uuid',
403
+ * txHash: '0x...',
404
+ * });
405
+ * ```
406
+ */
407
+ async refundHTLC(input) {
408
+ const { refundHTLC } = await this.client.mutate(`
409
+ mutation RefundHTLC($tradeId: ID!, $txHash: String!, $chainType: String) {
410
+ refundHTLC(tradeId: $tradeId, txHash: $txHash, chainType: $chainType) {
411
+ tradeId status
412
+ }
413
+ }
414
+ `, input);
415
+ return refundHTLC;
416
+ }
417
+ /**
418
+ * Get HTLC status for a trade (both initiator and counterparty HTLCs).
419
+ */
420
+ async getHTLCStatus(tradeId) {
421
+ const { htlcStatus } = await this.client.query(`
422
+ query HTLCStatus($tradeId: ID!) {
423
+ htlcStatus(tradeId: $tradeId) {
424
+ tradeId status
425
+ initiatorHTLC { id tradeId role status contractAddress hashlock timelock amount txHash chainType }
426
+ counterpartyHTLC { id tradeId role status contractAddress hashlock timelock amount txHash chainType }
427
+ }
428
+ }
429
+ `, { tradeId });
430
+ return htlcStatus;
431
+ }
432
+ /**
433
+ * Get all HTLCs for a trade.
434
+ */
435
+ async getHTLCs(tradeId) {
436
+ const { htlcs } = await this.client.query(`
437
+ query GetHTLCs($tradeId: ID!) {
438
+ htlcs(tradeId: $tradeId) {
439
+ id tradeId role status contractAddress hashlock timelock amount txHash chainType preimage
440
+ }
441
+ }
442
+ `, { tradeId });
443
+ return htlcs;
444
+ }
445
+ // ─── HTLC — Bitcoin ──────────────────────────────────────
446
+ /**
447
+ * Prepare a Bitcoin HTLC. Returns P2WSH address and redeem script.
448
+ * The client funds this address, then calls fundHTLC with the txHash.
449
+ *
450
+ * @example
451
+ * ```ts
452
+ * const btcHtlc = await hl.prepareBitcoinHTLC({
453
+ * tradeId: 'trade-uuid',
454
+ * role: 'INITIATOR',
455
+ * senderPubKey: '02abc...',
456
+ * receiverPubKey: '03def...',
457
+ * timelock: Math.floor(Date.now() / 1000) + 7200,
458
+ * amountSats: '100000', // 0.001 BTC
459
+ * });
460
+ * console.log(`Fund this address: ${btcHtlc.htlcAddress}`);
461
+ * ```
462
+ */
463
+ async prepareBitcoinHTLC(input) {
464
+ const { prepareBitcoinHTLC } = await this.client.mutate(`
465
+ mutation PrepareBTCHTLC($tradeId: ID!, $role: HTLCRole!, $senderPubKey: String!, $receiverPubKey: String!, $timelock: Int!, $amountSats: String!) {
466
+ prepareBitcoinHTLC(tradeId: $tradeId, role: $role, senderPubKey: $senderPubKey, receiverPubKey: $receiverPubKey, timelock: $timelock, amountSats: $amountSats) {
467
+ tradeId htlcId htlcAddress redeemScript hashlock preimageHash timelock amountSats estimatedClaimFee estimatedRefundFee refundPsbt
468
+ }
469
+ }
470
+ `, input);
471
+ return prepareBitcoinHTLC;
472
+ }
473
+ /**
474
+ * Build an unsigned claim PSBT for a Bitcoin HTLC.
475
+ * The client signs with their wallet, then broadcasts via broadcastBitcoinTx.
476
+ */
477
+ async buildBitcoinClaimPSBT(input) {
478
+ const { buildBitcoinClaimPSBT } = await this.client.mutate(`
479
+ mutation BuildClaim($tradeId: ID!, $htlcId: ID!, $preimage: String!, $destinationPubKey: String!, $feeRate: Int) {
480
+ buildBitcoinClaimPSBT(tradeId: $tradeId, htlcId: $htlcId, preimage: $preimage, destinationPubKey: $destinationPubKey, feeRate: $feeRate) {
481
+ tradeId htlcId psbtBase64 fee utxoTxid utxoVout
482
+ }
483
+ }
484
+ `, input);
485
+ return buildBitcoinClaimPSBT;
486
+ }
487
+ /**
488
+ * Broadcast a signed Bitcoin transaction.
489
+ */
490
+ async broadcastBitcoinTx(input) {
491
+ const { broadcastBitcoinTx } = await this.client.mutate(`
492
+ mutation BroadcastBTC($tradeId: ID!, $txHex: String!) {
493
+ broadcastBitcoinTx(tradeId: $tradeId, txHex: $txHex) { txid success }
494
+ }
495
+ `, input);
496
+ return broadcastBitcoinTx;
497
+ }
498
+ };
499
+ export {
500
+ AuthError,
501
+ GraphQLError,
502
+ HashLock,
503
+ HashLockError,
504
+ MAINNET_ENDPOINT,
505
+ NetworkError
506
+ };
507
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/hashlock.ts"],"sourcesContent":["/**\n * Base error class for all HashLock SDK errors.\n */\nexport class HashLockError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly details?: unknown,\n ) {\n super(message);\n this.name = 'HashLockError';\n }\n}\n\n/**\n * GraphQL returned errors in the response.\n */\nexport class GraphQLError extends HashLockError {\n constructor(\n message: string,\n public readonly errors: Array<{ message: string; path?: string[] }>,\n ) {\n super(message, 'GRAPHQL_ERROR', errors);\n this.name = 'GraphQLError';\n }\n}\n\n/**\n * Network-level error (timeout, DNS failure, etc.).\n */\nexport class NetworkError extends HashLockError {\n constructor(message: string, public readonly cause?: Error) {\n super(message, 'NETWORK_ERROR', cause);\n this.name = 'NetworkError';\n }\n}\n\n/**\n * Authentication error — token missing or expired.\n */\nexport class AuthError extends HashLockError {\n constructor(message: string = 'Authentication required — set accessToken in config or call setAccessToken()') {\n super(message, 'AUTH_ERROR');\n this.name = 'AuthError';\n }\n}\n","import type { HashLockConfig } from './types.js';\nimport { GraphQLError, NetworkError, AuthError } from './errors.js';\n\nconst DEFAULT_TIMEOUT = 30_000;\nconst DEFAULT_RETRIES = 3;\nconst RETRY_DELAY_BASE = 1000;\n\ninterface GQLResponse<T> {\n data?: T;\n errors?: Array<{ message: string; path?: string[] }>;\n}\n\n/**\n * Low-level GraphQL client with retry logic, timeout, and error normalization.\n * Used internally by all SDK methods — not exported to consumers.\n */\nexport class GraphQLClient {\n private endpoint: string;\n private accessToken: string | undefined;\n private timeout: number;\n private retries: number;\n private fetchFn: typeof fetch;\n\n constructor(config: HashLockConfig) {\n this.endpoint = config.endpoint;\n this.accessToken = config.accessToken;\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n this.retries = config.retries ?? DEFAULT_RETRIES;\n this.fetchFn = config.fetch ?? globalThis.fetch;\n\n if (!this.fetchFn) {\n throw new Error('fetch is not available — pass a custom fetch implementation or use Node.js >= 18');\n }\n }\n\n setAccessToken(token: string): void {\n this.accessToken = token;\n }\n\n /**\n * Execute a GraphQL query with automatic retries on transient failures.\n * Retries on: network errors, 5xx status codes.\n * Does NOT retry on: 4xx errors, GraphQL validation errors.\n */\n async query<T>(\n query: string,\n variables?: Record<string, unknown> | object,\n ): Promise<T> {\n return this.execute<T>(query, variables, true);\n }\n\n /**\n * Execute a GraphQL mutation.\n * Only retries on network errors (not on 5xx — mutations are not idempotent).\n */\n async mutate<T>(\n query: string,\n variables?: Record<string, unknown> | object,\n ): Promise<T> {\n return this.execute<T>(query, variables, false);\n }\n\n private async execute<T>(\n query: string,\n variables: Record<string, unknown> | undefined,\n retryOn5xx: boolean,\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.retries; attempt++) {\n try {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'Accept': 'application/json',\n };\n\n if (this.accessToken) {\n headers['Authorization'] = `Bearer ${this.accessToken}`;\n }\n\n const response = await this.fetchFn(this.endpoint, {\n method: 'POST',\n headers,\n body: JSON.stringify({ query, variables }),\n signal: controller.signal,\n });\n\n clearTimeout(timer);\n\n // Auth errors — don't retry\n if (response.status === 401 || response.status === 403) {\n throw new AuthError(`HTTP ${response.status}: ${response.statusText}`);\n }\n\n // Server errors — retry only for queries\n if (response.status >= 500) {\n const msg = `Server error: HTTP ${response.status}`;\n if (retryOn5xx && attempt < this.retries) {\n lastError = new NetworkError(msg);\n await this.delay(attempt);\n continue;\n }\n throw new NetworkError(msg);\n }\n\n const json = (await response.json()) as GQLResponse<T>;\n\n // GraphQL errors\n if (json.errors?.length) {\n throw new GraphQLError(\n json.errors[0].message,\n json.errors,\n );\n }\n\n if (!json.data) {\n throw new GraphQLError('No data returned', [{ message: 'Empty response' }]);\n }\n\n return json.data;\n } catch (err) {\n if (err instanceof AuthError || err instanceof GraphQLError) {\n throw err;\n }\n\n // Network/timeout errors — retry\n const isAbort = err instanceof DOMException && err.name === 'AbortError';\n const isNetwork = err instanceof TypeError; // fetch network failure\n\n if ((isAbort || isNetwork) && attempt < this.retries) {\n lastError = err instanceof Error ? err : new Error(String(err));\n await this.delay(attempt);\n continue;\n }\n\n if (err instanceof NetworkError) throw err;\n\n throw new NetworkError(\n isAbort ? 'Request timed out' : `Network error: ${err instanceof Error ? err.message : err}`,\n err instanceof Error ? err : undefined,\n );\n }\n }\n\n throw lastError ?? new NetworkError('Request failed after all retries');\n }\n\n private delay(attempt: number): Promise<void> {\n const ms = RETRY_DELAY_BASE * Math.pow(2, attempt);\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","import { GraphQLClient } from './client.js';\nimport type {\n HashLockConfig,\n RFQ,\n Quote,\n Trade,\n HTLC,\n HTLCStatusResult,\n FundHTLCResult,\n FundHTLCInput,\n ClaimHTLCInput,\n RefundHTLCInput,\n CreateRFQInput,\n SubmitQuoteInput,\n ConfirmDirectTradeInput,\n ConfirmSettlementWalletsInput,\n PrepareBitcoinHTLCInput,\n BitcoinHTLCPrepareResult,\n BuildBitcoinClaimPSBTInput,\n BitcoinClaimPSBTResult,\n BroadcastBitcoinTxInput,\n BitcoinBroadcastResult,\n TradeStatus,\n RFQStatus,\n} from './types.js';\n\n/** Mainnet endpoint */\nexport const MAINNET_ENDPOINT = 'http://142.93.106.129/graphql';\n\n/**\n * HashLock SDK — TypeScript client for HashLock OTC trading platform.\n *\n * @example\n * ```ts\n * import { HashLock } from '@hashlock/sdk';\n *\n * const hl = new HashLock({\n * endpoint: 'http://142.93.106.129/graphql',\n * accessToken: 'your-jwt-token',\n * });\n *\n * const rfq = await hl.createRFQ({\n * baseToken: 'ETH',\n * quoteToken: 'USDT',\n * side: 'SELL',\n * amount: '1.0',\n * });\n * ```\n */\nexport class HashLock {\n private client: GraphQLClient;\n\n constructor(config: HashLockConfig) {\n this.client = new GraphQLClient(config);\n }\n\n /** Update the access token (e.g., after login or token refresh) */\n setAccessToken(token: string): void {\n this.client.setAccessToken(token);\n }\n\n // ─── RFQ ─────────────────────────────────────────────────\n\n /**\n * Create a Request for Quote (RFQ).\n * Broadcasts to market makers who can respond with prices.\n *\n * @example\n * ```ts\n * const rfq = await hl.createRFQ({\n * baseToken: 'ETH',\n * quoteToken: 'USDT',\n * side: 'SELL',\n * amount: '10.0',\n * expiresIn: 300, // 5 minutes\n * });\n * console.log(`RFQ created: ${rfq.id}`);\n * ```\n */\n async createRFQ(input: CreateRFQInput): Promise<RFQ> {\n const { createRFQ } = await this.client.mutate<{ createRFQ: RFQ }>(`\n mutation CreateRFQ($baseToken: String!, $quoteToken: String!, $side: Side!, $amount: String!, $expiresIn: Int, $isBlind: Boolean) {\n createRFQ(baseToken: $baseToken, quoteToken: $quoteToken, side: $side, amount: $amount, expiresIn: $expiresIn, isBlind: $isBlind) {\n id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount\n }\n }\n `, input);\n return createRFQ;\n }\n\n /**\n * Get a single RFQ by ID.\n */\n async getRFQ(id: string): Promise<RFQ | null> {\n const { rfq } = await this.client.query<{ rfq: RFQ | null }>(`\n query GetRFQ($id: ID!) {\n rfq(id: $id) {\n id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount\n quotes { id rfqId marketMakerId price amount status createdAt }\n }\n }\n `, { id });\n return rfq;\n }\n\n /**\n * List RFQs with optional status filter and pagination.\n */\n async listRFQs(params?: { status?: RFQStatus; page?: number; pageSize?: number }) {\n const { rfqs } = await this.client.query<{ rfqs: { rfqs: RFQ[]; total: number; page: number; pageSize: number } }>(`\n query ListRFQs($status: RFQStatus, $page: Int, $pageSize: Int) {\n rfqs(status: $status, page: $page, pageSize: $pageSize) {\n rfqs { id userId baseToken quoteToken side amount isBlind status expiresAt createdAt quotesCount }\n total page pageSize\n }\n }\n `, params);\n return rfqs;\n }\n\n /**\n * Cancel an active RFQ.\n */\n async cancelRFQ(id: string): Promise<RFQ> {\n const { cancelRFQ } = await this.client.mutate<{ cancelRFQ: RFQ }>(`\n mutation CancelRFQ($id: ID!) {\n cancelRFQ(id: $id) {\n id status\n }\n }\n `, { id });\n return cancelRFQ;\n }\n\n // ─── Quotes ──────────────────────────────────────────────\n\n /**\n * Submit a price quote in response to an RFQ.\n *\n * @example\n * ```ts\n * const quote = await hl.submitQuote({\n * rfqId: 'rfq-uuid',\n * price: '3450.00',\n * amount: '10.0',\n * });\n * ```\n */\n async submitQuote(input: SubmitQuoteInput): Promise<Quote> {\n const { submitQuote } = await this.client.mutate<{ submitQuote: Quote }>(`\n mutation SubmitQuote($rfqId: ID!, $price: String!, $amount: String!, $expiresIn: Int) {\n submitQuote(rfqId: $rfqId, price: $price, amount: $amount, expiresIn: $expiresIn) {\n id rfqId marketMakerId price amount status createdAt expiresAt\n }\n }\n `, input);\n return submitQuote;\n }\n\n /**\n * Accept a quote — creates a trade from the RFQ flow.\n */\n async acceptQuote(quoteId: string): Promise<Quote> {\n const { acceptQuote } = await this.client.mutate<{ acceptQuote: Quote }>(`\n mutation AcceptQuote($quoteId: ID!) {\n acceptQuote(quoteId: $quoteId) {\n id rfqId status trade { id status }\n }\n }\n `, { quoteId });\n return acceptQuote;\n }\n\n /**\n * Get all quotes for an RFQ.\n */\n async getQuotes(rfqId: string): Promise<Quote[]> {\n const { quotes } = await this.client.query<{ quotes: Quote[] }>(`\n query GetQuotes($rfqId: ID!) {\n quotes(rfqId: $rfqId) {\n id rfqId marketMakerId price amount status createdAt expiresAt\n deliveryDelayHours collateralBtcSats isCollateralBacked\n }\n }\n `, { rfqId });\n return quotes;\n }\n\n // ─── Trades ──────────────────────────────────────────────\n\n /**\n * Get a single trade by ID.\n */\n async getTrade(id: string): Promise<Trade | null> {\n const { trade } = await this.client.query<{ trade: Trade | null }>(`\n query GetTrade($id: ID!) {\n trade(id: $id) {\n id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt\n }\n }\n `, { id });\n return trade;\n }\n\n /**\n * List trades with optional status filter.\n */\n async listTrades(params?: { status?: TradeStatus; page?: number; pageSize?: number }) {\n const { trades } = await this.client.query<{ trades: { trades: Trade[]; total: number } }>(`\n query ListTrades($status: TradeStatus, $page: Int, $pageSize: Int) {\n trades(status: $status, page: $page, pageSize: $pageSize) {\n trades { id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt }\n total\n }\n }\n `, params);\n return trades;\n }\n\n /**\n * Create a direct trade from 1-on-1 chat (skips RFQ flow).\n */\n async confirmDirectTrade(input: ConfirmDirectTradeInput): Promise<Trade> {\n const { confirmDirectTrade } = await this.client.mutate<{ confirmDirectTrade: Trade }>(`\n mutation ConfirmDirectTrade($counterpartyId: ID!, $baseToken: String!, $quoteToken: String!, $side: Side!, $baseAmount: String!, $price: String!, $chainId: String!, $broadcastRfqId: ID, $conversationId: ID) {\n confirmDirectTrade(counterpartyId: $counterpartyId, baseToken: $baseToken, quoteToken: $quoteToken, side: $side, baseAmount: $baseAmount, price: $price, chainId: $chainId, broadcastRfqId: $broadcastRfqId, conversationId: $conversationId) {\n id initiatorId counterpartyId baseToken quoteToken side baseAmount quoteAmount price status createdAt\n }\n }\n `, input);\n return confirmDirectTrade;\n }\n\n /**\n * Accept a proposed trade.\n */\n async acceptTrade(tradeId: string): Promise<Trade> {\n const { acceptTrade } = await this.client.mutate<{ acceptTrade: Trade }>(`\n mutation AcceptTrade($tradeId: ID!) {\n acceptTrade(tradeId: $tradeId) { id status }\n }\n `, { tradeId });\n return acceptTrade;\n }\n\n /**\n * Cancel a trade.\n */\n async cancelTrade(tradeId: string): Promise<Trade> {\n const { cancelTrade } = await this.client.mutate<{ cancelTrade: Trade }>(`\n mutation CancelTrade($tradeId: ID!) {\n cancelTrade(tradeId: $tradeId) { id status }\n }\n `, { tradeId });\n return cancelTrade;\n }\n\n /**\n * Confirm settlement wallets for a trade.\n */\n async confirmSettlementWallets(input: ConfirmSettlementWalletsInput): Promise<Trade> {\n const { confirmSettlementWallets } = await this.client.mutate<{ confirmSettlementWallets: Trade }>(`\n mutation ConfirmWallets($tradeId: ID!, $sendWalletId: ID!, $receiveWalletId: ID!) {\n confirmSettlementWallets(tradeId: $tradeId, sendWalletId: $sendWalletId, receiveWalletId: $receiveWalletId) {\n id status\n }\n }\n `, input);\n return confirmSettlementWallets;\n }\n\n // ─── HTLC — EVM (ETH / ERC-20) ──────────────────────────\n\n /**\n * Record an on-chain HTLC funding transaction.\n * Called after the user sends an ETH/ERC20 lock tx on-chain.\n *\n * @example\n * ```ts\n * // After sending ETH lock tx on-chain via ethers/viem:\n * const result = await hl.fundHTLC({\n * tradeId: 'trade-uuid',\n * txHash: '0xabc...',\n * role: 'INITIATOR',\n * timelock: Math.floor(Date.now() / 1000) + 3600,\n * hashlock: '0x...',\n * });\n * ```\n */\n async fundHTLC(input: FundHTLCInput): Promise<FundHTLCResult> {\n const { fundHTLC } = await this.client.mutate<{ fundHTLC: FundHTLCResult }>(`\n mutation FundHTLC($tradeId: ID!, $txHash: String!, $role: HTLCRole!, $timelock: Int, $hashlock: String, $chainType: String, $senderPubKey: String, $receiverPubKey: String, $redeemScript: String, $refundTxHex: String, $preimage: String) {\n fundHTLC(tradeId: $tradeId, txHash: $txHash, role: $role, timelock: $timelock, hashlock: $hashlock, chainType: $chainType, senderPubKey: $senderPubKey, receiverPubKey: $receiverPubKey, redeemScript: $redeemScript, refundTxHex: $refundTxHex, preimage: $preimage) {\n tradeId txHash status\n }\n }\n `, input);\n return fundHTLC;\n }\n\n /**\n * Record an on-chain HTLC claim (preimage reveal).\n *\n * @example\n * ```ts\n * const result = await hl.claimHTLC({\n * tradeId: 'trade-uuid',\n * txHash: '0xdef...',\n * preimage: '0x...',\n * });\n * ```\n */\n async claimHTLC(input: ClaimHTLCInput): Promise<HTLCStatusResult> {\n const { claimHTLC } = await this.client.mutate<{ claimHTLC: HTLCStatusResult }>(`\n mutation ClaimHTLC($tradeId: ID!, $txHash: String!, $preimage: String!, $chainType: String) {\n claimHTLC(tradeId: $tradeId, txHash: $txHash, preimage: $preimage, chainType: $chainType) {\n tradeId status\n }\n }\n `, input);\n return claimHTLC;\n }\n\n /**\n * Record an on-chain HTLC refund (after timelock expiry).\n *\n * @example\n * ```ts\n * const result = await hl.refundHTLC({\n * tradeId: 'trade-uuid',\n * txHash: '0x...',\n * });\n * ```\n */\n async refundHTLC(input: RefundHTLCInput): Promise<HTLCStatusResult> {\n const { refundHTLC } = await this.client.mutate<{ refundHTLC: HTLCStatusResult }>(`\n mutation RefundHTLC($tradeId: ID!, $txHash: String!, $chainType: String) {\n refundHTLC(tradeId: $tradeId, txHash: $txHash, chainType: $chainType) {\n tradeId status\n }\n }\n `, input);\n return refundHTLC;\n }\n\n /**\n * Get HTLC status for a trade (both initiator and counterparty HTLCs).\n */\n async getHTLCStatus(tradeId: string): Promise<HTLCStatusResult | null> {\n const { htlcStatus } = await this.client.query<{ htlcStatus: HTLCStatusResult | null }>(`\n query HTLCStatus($tradeId: ID!) {\n htlcStatus(tradeId: $tradeId) {\n tradeId status\n initiatorHTLC { id tradeId role status contractAddress hashlock timelock amount txHash chainType }\n counterpartyHTLC { id tradeId role status contractAddress hashlock timelock amount txHash chainType }\n }\n }\n `, { tradeId });\n return htlcStatus;\n }\n\n /**\n * Get all HTLCs for a trade.\n */\n async getHTLCs(tradeId: string): Promise<HTLC[]> {\n const { htlcs } = await this.client.query<{ htlcs: HTLC[] }>(`\n query GetHTLCs($tradeId: ID!) {\n htlcs(tradeId: $tradeId) {\n id tradeId role status contractAddress hashlock timelock amount txHash chainType preimage\n }\n }\n `, { tradeId });\n return htlcs;\n }\n\n // ─── HTLC — Bitcoin ──────────────────────────────────────\n\n /**\n * Prepare a Bitcoin HTLC. Returns P2WSH address and redeem script.\n * The client funds this address, then calls fundHTLC with the txHash.\n *\n * @example\n * ```ts\n * const btcHtlc = await hl.prepareBitcoinHTLC({\n * tradeId: 'trade-uuid',\n * role: 'INITIATOR',\n * senderPubKey: '02abc...',\n * receiverPubKey: '03def...',\n * timelock: Math.floor(Date.now() / 1000) + 7200,\n * amountSats: '100000', // 0.001 BTC\n * });\n * console.log(`Fund this address: ${btcHtlc.htlcAddress}`);\n * ```\n */\n async prepareBitcoinHTLC(input: PrepareBitcoinHTLCInput): Promise<BitcoinHTLCPrepareResult> {\n const { prepareBitcoinHTLC } = await this.client.mutate<{ prepareBitcoinHTLC: BitcoinHTLCPrepareResult }>(`\n mutation PrepareBTCHTLC($tradeId: ID!, $role: HTLCRole!, $senderPubKey: String!, $receiverPubKey: String!, $timelock: Int!, $amountSats: String!) {\n prepareBitcoinHTLC(tradeId: $tradeId, role: $role, senderPubKey: $senderPubKey, receiverPubKey: $receiverPubKey, timelock: $timelock, amountSats: $amountSats) {\n tradeId htlcId htlcAddress redeemScript hashlock preimageHash timelock amountSats estimatedClaimFee estimatedRefundFee refundPsbt\n }\n }\n `, input);\n return prepareBitcoinHTLC;\n }\n\n /**\n * Build an unsigned claim PSBT for a Bitcoin HTLC.\n * The client signs with their wallet, then broadcasts via broadcastBitcoinTx.\n */\n async buildBitcoinClaimPSBT(input: BuildBitcoinClaimPSBTInput): Promise<BitcoinClaimPSBTResult> {\n const { buildBitcoinClaimPSBT } = await this.client.mutate<{ buildBitcoinClaimPSBT: BitcoinClaimPSBTResult }>(`\n mutation BuildClaim($tradeId: ID!, $htlcId: ID!, $preimage: String!, $destinationPubKey: String!, $feeRate: Int) {\n buildBitcoinClaimPSBT(tradeId: $tradeId, htlcId: $htlcId, preimage: $preimage, destinationPubKey: $destinationPubKey, feeRate: $feeRate) {\n tradeId htlcId psbtBase64 fee utxoTxid utxoVout\n }\n }\n `, input);\n return buildBitcoinClaimPSBT;\n }\n\n /**\n * Broadcast a signed Bitcoin transaction.\n */\n async broadcastBitcoinTx(input: BroadcastBitcoinTxInput): Promise<BitcoinBroadcastResult> {\n const { broadcastBitcoinTx } = await this.client.mutate<{ broadcastBitcoinTx: BitcoinBroadcastResult }>(`\n mutation BroadcastBTC($tradeId: ID!, $txHex: String!) {\n broadcastBitcoinTx(tradeId: $tradeId, txHex: $txHex) { txid success }\n }\n `, input);\n return broadcastBitcoinTx;\n }\n}\n"],"mappings":";AAGO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACgB,MACA,SAChB;AACA,UAAM,OAAO;AAHG;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AAAA,EALkB;AAAA,EACA;AAKpB;AAKO,IAAM,eAAN,cAA2B,cAAc;AAAA,EAC9C,YACE,SACgB,QAChB;AACA,UAAM,SAAS,iBAAiB,MAAM;AAFtB;AAGhB,SAAK,OAAO;AAAA,EACd;AAAA,EAJkB;AAKpB;AAKO,IA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 {
2
+ "name": "@hashlock-tech/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for HashLock OTC — HTLC atomic settlement, RFQ trading, and Bitcoin cross-chain swaps",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsup",
29
+ "dev": "tsup --watch",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "lint": "tsc --noEmit",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "devDependencies": {
36
+ "tsup": "^8.0.0",
37
+ "typescript": "^5.4.0",
38
+ "vitest": "^2.0.0"
39
+ },
40
+ "keywords": [
41
+ "hashlock",
42
+ "htlc",
43
+ "otc",
44
+ "atomic-swap",
45
+ "ethereum",
46
+ "bitcoin",
47
+ "settlement"
48
+ ],
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/Hashlock-Tech/hashlock-sdk"
52
+ },
53
+ "engines": {
54
+ "node": ">=18"
55
+ }
56
+ }