@carrot-protocol/boost-http-client 0.2.15-group-refactor1-dev-57892a5 → 0.2.15-group-refactor1-dev-ef145c2
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 +2 -2
- package/dist/index.js +3 -8
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
- package/src/index.ts +7 -9
- package/src/types.ts +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorProvider, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import { GetBankResponse, GetUserResponse, GetGroupResponse
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./utils";
|
|
5
5
|
export * as Common from "@carrot-protocol/clend-common";
|
|
@@ -27,7 +27,7 @@ export declare class Client {
|
|
|
27
27
|
* @param user wallet public key
|
|
28
28
|
* @returns User details
|
|
29
29
|
*/
|
|
30
|
-
getUser(
|
|
30
|
+
getUser(group: web3.PublicKey, user: web3.PublicKey, getClendAccountSummary: boolean): Promise<GetUserResponse>;
|
|
31
31
|
/**
|
|
32
32
|
* Get market details
|
|
33
33
|
* @param groupAddress group public key
|
package/dist/index.js
CHANGED
|
@@ -104,13 +104,8 @@ class Client {
|
|
|
104
104
|
* @param user wallet public key
|
|
105
105
|
* @returns User details
|
|
106
106
|
*/
|
|
107
|
-
async getUser(
|
|
108
|
-
|
|
109
|
-
let user = request.user;
|
|
110
|
-
if (!user) {
|
|
111
|
-
user = this.address();
|
|
112
|
-
}
|
|
113
|
-
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&getClendAccountSummary=${request.getClendAccountSummary}`));
|
|
107
|
+
async getUser(group, user, getClendAccountSummary) {
|
|
108
|
+
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&group=${group.toString()}&getClendAccountSummary=${getClendAccountSummary}`));
|
|
114
109
|
const jsonRawResponse = JSON.parse(body);
|
|
115
110
|
// parse balances
|
|
116
111
|
const walletBalances = [];
|
|
@@ -127,7 +122,7 @@ class Client {
|
|
|
127
122
|
};
|
|
128
123
|
// get tx summary for each account and group them
|
|
129
124
|
const summaryByAccount = new Map();
|
|
130
|
-
if (
|
|
125
|
+
if (getClendAccountSummary && jsonRawResponse.summary) {
|
|
131
126
|
for (const s of jsonRawResponse.summary) {
|
|
132
127
|
const accountAddress = new anchor_1.web3.PublicKey(s.clendAccount).toBase58();
|
|
133
128
|
if (!summaryByAccount.has(accountAddress)) {
|
package/dist/types.d.ts
CHANGED
|
@@ -65,8 +65,9 @@ export interface GetGroupResponse {
|
|
|
65
65
|
banks: Bank[];
|
|
66
66
|
}
|
|
67
67
|
export interface GetUserRequest {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
group: web3.PublicKey;
|
|
69
|
+
user: web3.PublicKey;
|
|
70
|
+
getClendAccountSummary: boolean;
|
|
70
71
|
}
|
|
71
72
|
export interface GetUserResponse {
|
|
72
73
|
wallet: UserWallet;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -104,16 +104,14 @@ export class Client {
|
|
|
104
104
|
* @param user wallet public key
|
|
105
105
|
* @returns User details
|
|
106
106
|
*/
|
|
107
|
-
async getUser(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
107
|
+
async getUser(
|
|
108
|
+
group: web3.PublicKey,
|
|
109
|
+
user: web3.PublicKey,
|
|
110
|
+
getClendAccountSummary: boolean,
|
|
111
|
+
): Promise<GetUserResponse> {
|
|
114
112
|
const body = await handleApiCall(() =>
|
|
115
113
|
this.http.get(
|
|
116
|
-
`/user?user=${user.toString()}&
|
|
114
|
+
`/user?user=${user.toString()}&group=${group.toString()}&getClendAccountSummary=${getClendAccountSummary}`,
|
|
117
115
|
),
|
|
118
116
|
);
|
|
119
117
|
|
|
@@ -136,7 +134,7 @@ export class Client {
|
|
|
136
134
|
|
|
137
135
|
// get tx summary for each account and group them
|
|
138
136
|
const summaryByAccount = new Map<string, ClendAccountTxSummary[]>();
|
|
139
|
-
if (
|
|
137
|
+
if (getClendAccountSummary && jsonRawResponse.summary) {
|
|
140
138
|
for (const s of jsonRawResponse.summary) {
|
|
141
139
|
const accountAddress = new web3.PublicKey(s.clendAccount).toBase58();
|
|
142
140
|
if (!summaryByAccount.has(accountAddress)) {
|
package/src/types.ts
CHANGED
|
@@ -75,8 +75,9 @@ export interface GetGroupResponse {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface GetUserRequest {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
group: web3.PublicKey;
|
|
79
|
+
user: web3.PublicKey;
|
|
80
|
+
getClendAccountSummary: boolean;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export interface GetUserResponse {
|