@carrot-protocol/boost-http-client 0.1.4 → 0.1.5-bundle1-dev-131458e

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 CHANGED
@@ -70,9 +70,9 @@ class Client {
70
70
  return this.provider.wallet.publicKey;
71
71
  }
72
72
  // sign and send tx to api for sending to network
73
- async send(base64Tx) {
73
+ async send(unsignedBase64Tx, ...signedBase64Txns) {
74
74
  // deserialize into tx obj
75
- const txBytes = Buffer.from(base64Tx, "base64");
75
+ const txBytes = Buffer.from(unsignedBase64Tx, "base64");
76
76
  const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
77
77
  // sign tx
78
78
  const signedTx = await this.provider.wallet.signTransaction(tx);
@@ -81,7 +81,7 @@ class Client {
81
81
  const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString("base64");
82
82
  // create request obj
83
83
  const sendRequest = {
84
- tx: encodedAndSignedTx,
84
+ txns: [encodedAndSignedTx, ...signedBase64Txns],
85
85
  };
86
86
  // send to api
87
87
  await handleApiCall(() => this.http.post(`send`, sendRequest));
@@ -132,7 +132,7 @@ class Client {
132
132
  async depositLeverage(params) {
133
133
  const body = await handleApiCall(() => this.http.post("leverage/deposit", JSON.stringify(params)));
134
134
  const depositLeverageResponse = JSON.parse(body);
135
- const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
135
+ const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx, depositLeverageResponse.signedSetBorrowRateBase64Tx);
136
136
  return txSig;
137
137
  }
138
138
  /**
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { web3 } from "@coral-xyz/anchor";
2
2
  import Decimal from "decimal.js";
3
3
  export interface SendRequest {
4
- tx: string;
4
+ txns: string[];
5
5
  }
6
6
  export interface CreateObligationRequest {
7
7
  owner: web3.PublicKey;
@@ -24,6 +24,7 @@ export interface DepositLeverageRequest {
24
24
  */
25
25
  export interface DepositLeverageResponse {
26
26
  unsignedBase64Tx: string;
27
+ signedSetBorrowRateBase64Tx: string;
27
28
  }
28
29
  /**
29
30
  * Request to modify the leverage of an existing position
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.1.4",
3
+ "version": "0.1.5-bundle1-dev-131458e",
4
4
  "description": "HTTP client for Carrot Boost API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -48,9 +48,12 @@ export class Client {
48
48
  }
49
49
 
50
50
  // sign and send tx to api for sending to network
51
- private async send(base64Tx: string): Promise<string> {
51
+ private async send(
52
+ unsignedBase64Tx: string,
53
+ ...signedBase64Txns: string[]
54
+ ): Promise<string> {
52
55
  // deserialize into tx obj
53
- const txBytes = Buffer.from(base64Tx, "base64");
56
+ const txBytes = Buffer.from(unsignedBase64Tx, "base64");
54
57
  const tx = web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
55
58
 
56
59
  // sign tx
@@ -64,7 +67,7 @@ export class Client {
64
67
 
65
68
  // create request obj
66
69
  const sendRequest: SendRequest = {
67
- tx: encodedAndSignedTx,
70
+ txns: [encodedAndSignedTx, ...signedBase64Txns],
68
71
  };
69
72
 
70
73
  // send to api
@@ -140,7 +143,10 @@ export class Client {
140
143
 
141
144
  const depositLeverageResponse: DepositLeverageResponse = JSON.parse(body);
142
145
 
143
- const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
146
+ const txSig = await this.send(
147
+ depositLeverageResponse.unsignedBase64Tx,
148
+ depositLeverageResponse.signedSetBorrowRateBase64Tx,
149
+ );
144
150
 
145
151
  return txSig;
146
152
  }
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@ import Decimal from "decimal.js";
3
3
 
4
4
  // Represents a request to send a transaction
5
5
  export interface SendRequest {
6
- tx: string;
6
+ txns: string[];
7
7
  }
8
8
 
9
9
  export interface CreateObligationRequest {
@@ -30,6 +30,7 @@ export interface DepositLeverageRequest {
30
30
  */
31
31
  export interface DepositLeverageResponse {
32
32
  unsignedBase64Tx: string;
33
+ signedSetBorrowRateBase64Tx: string;
33
34
  }
34
35
 
35
36
  /**