@carrot-protocol/http-client 0.2.9-http-get-vault-dev-551e417 → 0.2.9-http-get-vault-dev-c935fbf

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 CHANGED
@@ -1,32 +1,32 @@
1
- import { web3, BN, AnchorProvider } from "@coral-xyz/anchor";
1
+ import * as anchor from "@coral-xyz/anchor";
2
2
  import { Vault, VaultPerformance } from "@carrot-protocol/common";
3
3
  export declare class Client {
4
4
  readonly baseUrl: string;
5
- readonly provider: AnchorProvider;
5
+ readonly provider: anchor.AnchorProvider;
6
6
  private headers;
7
- constructor(baseUrl: string, provider: AnchorProvider);
7
+ constructor(baseUrl: string, provider: anchor.AnchorProvider);
8
8
  index(): Promise<void>;
9
- getVault(vault: web3.PublicKey): Promise<Vault>;
10
- getVaultPerformance(vault: web3.PublicKey): Promise<VaultPerformance>;
11
- getUser(vault: web3.PublicKey): Promise<UserResponse>;
12
- issue(vault: web3.PublicKey, assetMint: web3.PublicKey, amount: BN): Promise<string>;
13
- redeem(vault: web3.PublicKey, assetMint: web3.PublicKey, amount: BN): Promise<string>;
9
+ getVault(vault: anchor.web3.PublicKey): Promise<Vault>;
10
+ getVaultPerformance(vault: anchor.web3.PublicKey): Promise<VaultPerformance>;
11
+ getUser(vault: anchor.web3.PublicKey): Promise<UserResponse>;
12
+ issue(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
13
+ redeem(vault: anchor.web3.PublicKey, assetMint: anchor.web3.PublicKey, amount: anchor.BN): Promise<string>;
14
14
  private send;
15
15
  }
16
16
  export interface SendRequest {
17
17
  tx: string;
18
18
  }
19
19
  export interface RedeemRequest {
20
- vault: web3.PublicKey;
21
- assetMint: web3.PublicKey;
22
- amount: BN;
23
- user: web3.PublicKey;
20
+ vault: anchor.web3.PublicKey;
21
+ assetMint: anchor.web3.PublicKey;
22
+ amount: anchor.BN;
23
+ user: anchor.web3.PublicKey;
24
24
  }
25
25
  export interface IssueRequest {
26
- vault: web3.PublicKey;
27
- assetMint: web3.PublicKey;
28
- amount: BN;
29
- user: web3.PublicKey;
26
+ vault: anchor.web3.PublicKey;
27
+ assetMint: anchor.web3.PublicKey;
28
+ amount: anchor.BN;
29
+ user: anchor.web3.PublicKey;
30
30
  }
31
31
  export interface RedeemResponse {
32
32
  tx: string;
@@ -35,15 +35,15 @@ export interface IssueResponse {
35
35
  tx: string;
36
36
  }
37
37
  export interface UserResponse {
38
- solAmount: BN;
38
+ solAmount: anchor.BN;
39
39
  solAmountUi: number;
40
- sharesAmount: BN;
40
+ sharesAmount: anchor.BN;
41
41
  sharesAmountUi: number;
42
42
  assets: UserAssetBalance[];
43
43
  }
44
44
  export interface UserAssetBalance {
45
- mint: web3.PublicKey;
46
- amount: BN;
45
+ mint: anchor.web3.PublicKey;
46
+ amount: anchor.BN;
47
47
  amountUi: number;
48
48
  }
49
- export declare function prepareUnsignedTx(connection: web3.Connection, payer: web3.PublicKey, ixns: web3.TransactionInstruction[], lutAddr?: web3.PublicKey, additionalSigner?: AnchorProvider): Promise<string>;
49
+ export declare function prepareUnsignedTx(connection: anchor.web3.Connection, payer: anchor.web3.PublicKey, ixns: anchor.web3.TransactionInstruction[], lutAddr?: anchor.web3.PublicKey, additionalSigner?: anchor.AnchorProvider): Promise<string>;
package/dist/index.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -6,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.Client = void 0;
7
30
  exports.prepareUnsignedTx = prepareUnsignedTx;
8
31
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
9
- const anchor_1 = require("@coral-xyz/anchor");
32
+ const anchor = __importStar(require("@coral-xyz/anchor"));
10
33
  const bs58_1 = require("bs58");
11
34
  class Client {
12
35
  constructor(baseUrl, provider) {
@@ -28,35 +51,34 @@ class Client {
28
51
  });
29
52
  checkResponse(response);
30
53
  const rawBody = await response.json();
31
- console.log("GET_VAULT_RAW:", rawBody);
32
54
  let body = JSON.parse(JSON.stringify(rawBody));
33
- body.address = new anchor_1.web3.PublicKey(body.address);
34
- body.authority = new anchor_1.web3.PublicKey(body.authority);
35
- body.shares = new anchor_1.web3.PublicKey(body.shares);
36
- body.sharesSupply = new anchor_1.BN(body.sharesSupply, "hex");
55
+ body.address = new anchor.web3.PublicKey(body.address);
56
+ body.authority = new anchor.web3.PublicKey(body.authority);
57
+ body.shares = new anchor.web3.PublicKey(body.shares);
58
+ body.sharesSupply = new anchor.BN(body.sharesSupply);
37
59
  body.assets = body.assets.map((asset) => ({
38
60
  ...asset,
39
61
  assetId: Number(asset.assetId),
40
62
  balanceUsd: Number(asset.balanceUsd),
41
- mint: new anchor_1.web3.PublicKey(asset.mint),
42
- ata: new anchor_1.web3.PublicKey(asset.ata),
43
- oracle: new anchor_1.web3.PublicKey(asset.oracle),
44
- ataAmount: new anchor_1.BN(asset.ataAmount, "hex"),
63
+ mint: new anchor.web3.PublicKey(asset.mint),
64
+ ata: new anchor.web3.PublicKey(asset.ata),
65
+ oracle: new anchor.web3.PublicKey(asset.oracle),
66
+ ataAmount: new anchor.BN(asset.ataAmount, "hex"),
45
67
  }));
46
68
  body.strategies = body.strategies.map((strategy) => ({
47
- address: new anchor_1.web3.PublicKey(strategy.address),
69
+ address: new anchor.web3.PublicKey(strategy.address),
48
70
  record: {
49
71
  strategyId: Number(strategy.record.strategyId),
50
72
  assetId: Number(strategy.record.assetId),
51
- balance: new anchor_1.BN(strategy.record.balance, "hex"),
73
+ balance: new anchor.BN(strategy.record.balance, "hex"),
52
74
  balanceUsd: Number(strategy.record.balanceUsd),
53
- netEarnings: new anchor_1.BN(strategy.record.netEarnings, "hex"),
75
+ netEarnings: new anchor.BN(strategy.record.netEarnings, "hex"),
54
76
  },
55
77
  metadata: {
56
78
  ...strategy.metadata,
57
79
  strategyId: Number(strategy.metadata.strategyId),
58
- assetMint: new anchor_1.web3.PublicKey(strategy.metadata.assetMint),
59
- vault: new anchor_1.web3.PublicKey(strategy.metadata.vault),
80
+ assetMint: new anchor.web3.PublicKey(strategy.metadata.assetMint),
81
+ vault: new anchor.web3.PublicKey(strategy.metadata.vault),
60
82
  },
61
83
  strategyType: strategy.strategyType,
62
84
  }));
@@ -75,9 +97,9 @@ class Client {
75
97
  for (let strats of body.strategyAPY) {
76
98
  strats.apy = Number(strats.apy);
77
99
  strats.balanceUsd = Number(strats.balanceUsd);
78
- strats.strategy = new anchor_1.web3.PublicKey(strats.strategy);
100
+ strats.strategy = new anchor.web3.PublicKey(strats.strategy);
79
101
  strats.vaultWeight = Number(strats.vaultWeight);
80
- strats.assetMint = new anchor_1.web3.PublicKey(strats.assetMint);
102
+ strats.assetMint = new anchor.web3.PublicKey(strats.assetMint);
81
103
  }
82
104
  return body;
83
105
  }
@@ -89,12 +111,12 @@ class Client {
89
111
  });
90
112
  checkResponse(response);
91
113
  const body = JSON.parse(JSON.stringify(await response.json()));
92
- body.solAmount = new anchor_1.BN(body.solAmount, "hex");
93
- body.sharesAmount = new anchor_1.BN(body.sharesAmount, "hex");
114
+ body.solAmount = new anchor.BN(body.solAmount, "hex");
115
+ body.sharesAmount = new anchor.BN(body.sharesAmount, "hex");
94
116
  body.assets = body.assets.map((asset) => ({
95
117
  ...asset,
96
- mint: new anchor_1.web3.PublicKey(asset.mint),
97
- amount: new anchor_1.BN(asset.amount, "hex"),
118
+ mint: new anchor.web3.PublicKey(asset.mint),
119
+ amount: new anchor.BN(asset.amount, "hex"),
98
120
  }));
99
121
  return body;
100
122
  }
@@ -138,7 +160,7 @@ class Client {
138
160
  }
139
161
  async send(base64Tx) {
140
162
  const txBytes = Buffer.from(base64Tx, "base64");
141
- const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
163
+ const tx = anchor.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
142
164
  const signedTx = await this.provider.wallet.signTransaction(tx);
143
165
  const txSig = signedTx.signatures[0];
144
166
  const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString("base64");
@@ -168,12 +190,12 @@ async function prepareUnsignedTx(connection, payer, ixns, lutAddr, additionalSig
168
190
  const recentBh = await connection.getLatestBlockhash({
169
191
  commitment: "confirmed",
170
192
  });
171
- const msg = new anchor_1.web3.TransactionMessage({
193
+ const msg = new anchor.web3.TransactionMessage({
172
194
  payerKey: payer,
173
195
  recentBlockhash: recentBh.blockhash,
174
196
  instructions: ixns,
175
197
  }).compileToV0Message(lutAccounts);
176
- const tx = new anchor_1.web3.VersionedTransaction(msg);
198
+ const tx = new anchor.web3.VersionedTransaction(msg);
177
199
  let base64Tx = Buffer.from(tx.serialize()).toString("base64");
178
200
  if (additionalSigner) {
179
201
  const signedTx = await additionalSigner.wallet.signTransaction(tx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/http-client",
3
- "version": "0.2.9-http-get-vault-dev-551e417",
3
+ "version": "0.2.9-http-get-vault-dev-c935fbf",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",