@carrot-protocol/boost-http-client 0.2.11 → 0.2.12-request-id-dev-9f67dd3
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 +5 -4
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/src/index.ts +17 -4
- package/src/types.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -73,7 +73,7 @@ class Client {
|
|
|
73
73
|
return this.provider.wallet.publicKey;
|
|
74
74
|
}
|
|
75
75
|
// sign and send tx to api for sending to network
|
|
76
|
-
async send(unsignedBase64Tx) {
|
|
76
|
+
async send(unsignedBase64Tx, userRequestId) {
|
|
77
77
|
// deserialize into tx obj
|
|
78
78
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
79
79
|
const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
@@ -84,6 +84,7 @@ class Client {
|
|
|
84
84
|
const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString("base64");
|
|
85
85
|
// create request obj
|
|
86
86
|
const sendRequest = {
|
|
87
|
+
userRequestId,
|
|
87
88
|
txns: [encodedAndSignedTx],
|
|
88
89
|
};
|
|
89
90
|
// send to api
|
|
@@ -247,7 +248,7 @@ class Client {
|
|
|
247
248
|
};
|
|
248
249
|
const body = await handleApiCall(() => this.http.post("leverage/deposit", JSON.stringify(req)));
|
|
249
250
|
const depositLeverageResponse = JSON.parse(body);
|
|
250
|
-
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
|
|
251
|
+
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx, depositLeverageResponse.userRequestId);
|
|
251
252
|
return txSig;
|
|
252
253
|
}
|
|
253
254
|
/**
|
|
@@ -263,7 +264,7 @@ class Client {
|
|
|
263
264
|
};
|
|
264
265
|
const body = await handleApiCall(() => this.http.post("leverage/adjust", JSON.stringify(req)));
|
|
265
266
|
const adjustLeverageResponse = JSON.parse(body);
|
|
266
|
-
const txSig = await this.send(adjustLeverageResponse.unsignedBase64Tx);
|
|
267
|
+
const txSig = await this.send(adjustLeverageResponse.unsignedBase64Tx, adjustLeverageResponse.userRequestId);
|
|
267
268
|
return txSig;
|
|
268
269
|
}
|
|
269
270
|
/**
|
|
@@ -281,7 +282,7 @@ class Client {
|
|
|
281
282
|
};
|
|
282
283
|
const body = await handleApiCall(() => this.http.post("leverage/withdraw", JSON.stringify(req)));
|
|
283
284
|
const withdrawLeverageResponse = JSON.parse(body);
|
|
284
|
-
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx);
|
|
285
|
+
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx, withdrawLeverageResponse.userRequestId);
|
|
285
286
|
return txSig;
|
|
286
287
|
}
|
|
287
288
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
2
|
export interface SendRequest {
|
|
3
|
+
userRequestId: string;
|
|
3
4
|
txns: string[];
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
@@ -16,6 +17,7 @@ export interface DepositLeverageRequest {
|
|
|
16
17
|
* Response for deposit leverage operation
|
|
17
18
|
*/
|
|
18
19
|
export interface DepositLeverageResponse {
|
|
20
|
+
userRequestId: string;
|
|
19
21
|
unsignedBase64Tx: string;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
@@ -30,6 +32,7 @@ export interface AdjustLeverageRequest {
|
|
|
30
32
|
* Response for adjust leverage operation
|
|
31
33
|
*/
|
|
32
34
|
export interface AdjustLeverageResponse {
|
|
35
|
+
userRequestId: string;
|
|
33
36
|
unsignedBase64Tx: string;
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
@@ -46,6 +49,7 @@ export interface WithdrawLeverageRequest {
|
|
|
46
49
|
* Response for withdraw leverage operation
|
|
47
50
|
*/
|
|
48
51
|
export interface WithdrawLeverageResponse {
|
|
52
|
+
userRequestId: string;
|
|
49
53
|
unsignedBase64Tx: string;
|
|
50
54
|
}
|
|
51
55
|
export interface GetGroupResponse {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -59,7 +59,10 @@ export class Client {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// sign and send tx to api for sending to network
|
|
62
|
-
private async send(
|
|
62
|
+
private async send(
|
|
63
|
+
unsignedBase64Tx: string,
|
|
64
|
+
userRequestId: string,
|
|
65
|
+
): Promise<string> {
|
|
63
66
|
// deserialize into tx obj
|
|
64
67
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
65
68
|
const tx = web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
@@ -75,6 +78,7 @@ export class Client {
|
|
|
75
78
|
|
|
76
79
|
// create request obj
|
|
77
80
|
const sendRequest: SendRequest = {
|
|
81
|
+
userRequestId,
|
|
78
82
|
txns: [encodedAndSignedTx],
|
|
79
83
|
};
|
|
80
84
|
|
|
@@ -289,7 +293,10 @@ export class Client {
|
|
|
289
293
|
|
|
290
294
|
const depositLeverageResponse: DepositLeverageResponse = JSON.parse(body);
|
|
291
295
|
|
|
292
|
-
const txSig = await this.send(
|
|
296
|
+
const txSig = await this.send(
|
|
297
|
+
depositLeverageResponse.unsignedBase64Tx,
|
|
298
|
+
depositLeverageResponse.userRequestId,
|
|
299
|
+
);
|
|
293
300
|
|
|
294
301
|
return txSig;
|
|
295
302
|
}
|
|
@@ -311,7 +318,10 @@ export class Client {
|
|
|
311
318
|
|
|
312
319
|
const adjustLeverageResponse: AdjustLeverageResponse = JSON.parse(body);
|
|
313
320
|
|
|
314
|
-
const txSig = await this.send(
|
|
321
|
+
const txSig = await this.send(
|
|
322
|
+
adjustLeverageResponse.unsignedBase64Tx,
|
|
323
|
+
adjustLeverageResponse.userRequestId,
|
|
324
|
+
);
|
|
315
325
|
|
|
316
326
|
return txSig;
|
|
317
327
|
}
|
|
@@ -340,7 +350,10 @@ export class Client {
|
|
|
340
350
|
|
|
341
351
|
const withdrawLeverageResponse: WithdrawLeverageResponse = JSON.parse(body);
|
|
342
352
|
|
|
343
|
-
const txSig = await this.send(
|
|
353
|
+
const txSig = await this.send(
|
|
354
|
+
withdrawLeverageResponse.unsignedBase64Tx,
|
|
355
|
+
withdrawLeverageResponse.userRequestId,
|
|
356
|
+
);
|
|
344
357
|
|
|
345
358
|
return txSig;
|
|
346
359
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { BN, web3 } from "@coral-xyz/anchor";
|
|
|
2
2
|
|
|
3
3
|
// Represents a request to send a transaction
|
|
4
4
|
export interface SendRequest {
|
|
5
|
+
userRequestId: string;
|
|
5
6
|
txns: string[];
|
|
6
7
|
}
|
|
7
8
|
|
|
@@ -20,6 +21,7 @@ export interface DepositLeverageRequest {
|
|
|
20
21
|
* Response for deposit leverage operation
|
|
21
22
|
*/
|
|
22
23
|
export interface DepositLeverageResponse {
|
|
24
|
+
userRequestId: string;
|
|
23
25
|
unsignedBase64Tx: string;
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -36,6 +38,7 @@ export interface AdjustLeverageRequest {
|
|
|
36
38
|
* Response for adjust leverage operation
|
|
37
39
|
*/
|
|
38
40
|
export interface AdjustLeverageResponse {
|
|
41
|
+
userRequestId: string;
|
|
39
42
|
unsignedBase64Tx: string;
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -54,6 +57,7 @@ export interface WithdrawLeverageRequest {
|
|
|
54
57
|
* Response for withdraw leverage operation
|
|
55
58
|
*/
|
|
56
59
|
export interface WithdrawLeverageResponse {
|
|
60
|
+
userRequestId: string;
|
|
57
61
|
unsignedBase64Tx: string;
|
|
58
62
|
}
|
|
59
63
|
|