@carrot-protocol/boost-http-client 0.2.7-actions1-dev-ccd7ce6 → 0.2.7-actions1-dev-4c5f4e1
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 +10 -16
- package/dist/types.d.ts +1 -7
- package/package.json +1 -1
- package/src/index.ts +10 -20
- package/src/types.ts +1 -8
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ class Client {
|
|
|
109
109
|
if (!user) {
|
|
110
110
|
user = this.address();
|
|
111
111
|
}
|
|
112
|
-
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&
|
|
112
|
+
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&getClendAccountSummary=${request.getClendAccountSummary}`));
|
|
113
113
|
const jsonRawResponse = JSON.parse(body);
|
|
114
114
|
// get tokens still in user wallet
|
|
115
115
|
const wallet = {
|
|
@@ -161,35 +161,29 @@ class Client {
|
|
|
161
161
|
};
|
|
162
162
|
// get tx summary for each account
|
|
163
163
|
const summary = [];
|
|
164
|
-
for (const
|
|
164
|
+
for (const s of jsonRawResponse.summary) {
|
|
165
165
|
const txSummary = {
|
|
166
|
-
txSig:
|
|
167
|
-
time:
|
|
168
|
-
clendAccount: new anchor_1.web3.PublicKey(
|
|
169
|
-
clendAccountAuthority: new anchor_1.web3.PublicKey(
|
|
170
|
-
clendGroup: new anchor_1.web3.PublicKey(
|
|
171
|
-
action:
|
|
166
|
+
txSig: s.txSig,
|
|
167
|
+
time: s.time,
|
|
168
|
+
clendAccount: new anchor_1.web3.PublicKey(s.clendAccount),
|
|
169
|
+
clendAccountAuthority: new anchor_1.web3.PublicKey(s.clendAccountAuthority),
|
|
170
|
+
clendGroup: new anchor_1.web3.PublicKey(s.clendGroup),
|
|
171
|
+
action: s.action,
|
|
172
172
|
events: [],
|
|
173
173
|
};
|
|
174
174
|
// get events for each summary
|
|
175
|
-
for (const event of
|
|
175
|
+
for (const event of s.events) {
|
|
176
176
|
let closeBalance = null;
|
|
177
177
|
if (event.closeBalance !== null) {
|
|
178
178
|
closeBalance = Boolean(event.closeBalance);
|
|
179
179
|
}
|
|
180
180
|
// parse amount
|
|
181
181
|
const clendAccountEvent = {
|
|
182
|
-
txSig: event.txSig,
|
|
183
182
|
eventIndex: event.eventIndex,
|
|
184
|
-
time: event.time,
|
|
185
183
|
eventName: event.eventName,
|
|
186
|
-
clendAccount: new anchor_1.web3.PublicKey(event.clendAccount),
|
|
187
|
-
signer: event.signer ? new anchor_1.web3.PublicKey(event.signer) : null,
|
|
188
|
-
clendAccountAuthority: new anchor_1.web3.PublicKey(event.clendAccountAuthority),
|
|
189
|
-
clendGroup: new anchor_1.web3.PublicKey(event.clendGroup),
|
|
190
184
|
bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
|
|
191
185
|
mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
|
|
192
|
-
amount: event.amount ? new anchor_1.BN(event.amount) : null,
|
|
186
|
+
amount: event.amount ? new anchor_1.BN(event.amount, "hex") : null,
|
|
193
187
|
closeBalance,
|
|
194
188
|
};
|
|
195
189
|
txSummary.events.push(clendAccountEvent);
|
package/dist/types.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface GetGroupResponse {
|
|
|
53
53
|
}
|
|
54
54
|
export interface GetUserRequest {
|
|
55
55
|
user?: web3.PublicKey;
|
|
56
|
-
|
|
56
|
+
getClendAccountSummary?: boolean;
|
|
57
57
|
}
|
|
58
58
|
export interface GetUserResponse {
|
|
59
59
|
wallet: UserWallet;
|
|
@@ -132,14 +132,8 @@ export interface ClendAccountTxSummary {
|
|
|
132
132
|
events: ClendAccountEvent[];
|
|
133
133
|
}
|
|
134
134
|
export interface ClendAccountEvent {
|
|
135
|
-
txSig: string;
|
|
136
135
|
eventIndex: number;
|
|
137
|
-
time: Date;
|
|
138
136
|
eventName: string;
|
|
139
|
-
clendAccount: web3.PublicKey;
|
|
140
|
-
signer: web3.PublicKey | null;
|
|
141
|
-
clendAccountAuthority: web3.PublicKey;
|
|
142
|
-
clendGroup: web3.PublicKey;
|
|
143
137
|
bank: web3.PublicKey | null;
|
|
144
138
|
mint: web3.PublicKey | null;
|
|
145
139
|
amount: BN | null;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -107,7 +107,7 @@ export class Client {
|
|
|
107
107
|
|
|
108
108
|
const body = await handleApiCall(() =>
|
|
109
109
|
this.http.get(
|
|
110
|
-
`/user?user=${user.toString()}&
|
|
110
|
+
`/user?user=${user.toString()}&getClendAccountSummary=${request.getClendAccountSummary}`,
|
|
111
111
|
),
|
|
112
112
|
);
|
|
113
113
|
|
|
@@ -177,21 +177,19 @@ export class Client {
|
|
|
177
177
|
|
|
178
178
|
// get tx summary for each account
|
|
179
179
|
const summary: ClendAccountTxSummary[] = [];
|
|
180
|
-
for (const
|
|
180
|
+
for (const s of jsonRawResponse.summary) {
|
|
181
181
|
const txSummary: ClendAccountTxSummary = {
|
|
182
|
-
txSig:
|
|
183
|
-
time:
|
|
184
|
-
clendAccount: new web3.PublicKey(
|
|
185
|
-
clendAccountAuthority: new web3.PublicKey(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
clendGroup: new web3.PublicKey(summary.clendGroup),
|
|
189
|
-
action: summary.action,
|
|
182
|
+
txSig: s.txSig,
|
|
183
|
+
time: s.time,
|
|
184
|
+
clendAccount: new web3.PublicKey(s.clendAccount),
|
|
185
|
+
clendAccountAuthority: new web3.PublicKey(s.clendAccountAuthority),
|
|
186
|
+
clendGroup: new web3.PublicKey(s.clendGroup),
|
|
187
|
+
action: s.action,
|
|
190
188
|
events: [],
|
|
191
189
|
};
|
|
192
190
|
|
|
193
191
|
// get events for each summary
|
|
194
|
-
for (const event of
|
|
192
|
+
for (const event of s.events) {
|
|
195
193
|
let closeBalance: boolean | null = null;
|
|
196
194
|
if (event.closeBalance !== null) {
|
|
197
195
|
closeBalance = Boolean(event.closeBalance);
|
|
@@ -199,19 +197,11 @@ export class Client {
|
|
|
199
197
|
|
|
200
198
|
// parse amount
|
|
201
199
|
const clendAccountEvent: ClendAccountEvent = {
|
|
202
|
-
txSig: event.txSig,
|
|
203
200
|
eventIndex: event.eventIndex,
|
|
204
|
-
time: event.time,
|
|
205
201
|
eventName: event.eventName,
|
|
206
|
-
clendAccount: new web3.PublicKey(event.clendAccount),
|
|
207
|
-
signer: event.signer ? new web3.PublicKey(event.signer) : null,
|
|
208
|
-
clendAccountAuthority: new web3.PublicKey(
|
|
209
|
-
event.clendAccountAuthority,
|
|
210
|
-
),
|
|
211
|
-
clendGroup: new web3.PublicKey(event.clendGroup),
|
|
212
202
|
bank: event.bank ? new web3.PublicKey(event.bank) : null,
|
|
213
203
|
mint: event.mint ? new web3.PublicKey(event.mint) : null,
|
|
214
|
-
amount: event.amount ? new BN(event.amount) : null,
|
|
204
|
+
amount: event.amount ? new BN(event.amount, "hex") : null,
|
|
215
205
|
closeBalance,
|
|
216
206
|
};
|
|
217
207
|
txSummary.events.push(clendAccountEvent);
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import Decimal from "decimal.js";
|
|
3
2
|
|
|
4
3
|
// Represents a request to send a transaction
|
|
5
4
|
export interface SendRequest {
|
|
@@ -64,7 +63,7 @@ export interface GetGroupResponse {
|
|
|
64
63
|
|
|
65
64
|
export interface GetUserRequest {
|
|
66
65
|
user?: web3.PublicKey;
|
|
67
|
-
|
|
66
|
+
getClendAccountSummary?: boolean;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
export interface GetUserResponse {
|
|
@@ -151,14 +150,8 @@ export interface ClendAccountTxSummary {
|
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
export interface ClendAccountEvent {
|
|
154
|
-
txSig: string;
|
|
155
153
|
eventIndex: number;
|
|
156
|
-
time: Date;
|
|
157
154
|
eventName: string;
|
|
158
|
-
clendAccount: web3.PublicKey;
|
|
159
|
-
signer: web3.PublicKey | null;
|
|
160
|
-
clendAccountAuthority: web3.PublicKey;
|
|
161
|
-
clendGroup: web3.PublicKey;
|
|
162
155
|
bank: web3.PublicKey | null;
|
|
163
156
|
mint: web3.PublicKey | null;
|
|
164
157
|
amount: BN | null;
|