@carrot-protocol/http-client 0.2.79 → 0.2.80
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 +1 -1
- package/dist/index.js +12 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class Client {
|
|
|
11
11
|
index(): Promise<void>;
|
|
12
12
|
getVault(vault: anchor.web3.PublicKey, useCache: boolean): Promise<Vault>;
|
|
13
13
|
getVaultPerformance(vault: anchor.web3.PublicKey, useCache: boolean): Promise<VaultPerformance>;
|
|
14
|
-
getUser(vault: anchor.web3.PublicKey): Promise<UserResponse>;
|
|
14
|
+
getUser(vault: anchor.web3.PublicKey, user?: anchor.web3.PublicKey): Promise<UserResponse>;
|
|
15
15
|
getHistoricalVaultApy(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultApyResponse>;
|
|
16
16
|
getUserPerformance(vault: anchor.web3.PublicKey, wallets: anchor.web3.PublicKey[]): Promise<UserPerformanceResponse>;
|
|
17
17
|
getHistoricalVaultNav(vault: anchor.web3.PublicKey, interval: VaultHistoricalInterval): Promise<HistoricalVaultNavResponse>;
|
package/dist/index.js
CHANGED
|
@@ -139,10 +139,18 @@ class Client {
|
|
|
139
139
|
return body;
|
|
140
140
|
}
|
|
141
141
|
// Retrieves user-specific data for a given vault
|
|
142
|
-
async getUser(vault) {
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
async getUser(vault, user) {
|
|
143
|
+
// if user is not provided, use the provider's public key
|
|
144
|
+
let userString = "";
|
|
145
|
+
if (user) {
|
|
146
|
+
userString = user.toString();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// error if provider is undefined
|
|
150
|
+
requireProvider(this.provider);
|
|
151
|
+
userString = this.provider.publicKey.toString();
|
|
152
|
+
}
|
|
153
|
+
const url = new URL(`${this.baseUrl}/user?vault=${vault.toString()}&user=${userString}`);
|
|
146
154
|
const response = await (0, cross_fetch_1.default)(url, {
|
|
147
155
|
method: "GET",
|
|
148
156
|
headers: this.headers,
|