@velocity-exchange/sdk 0.0.1 → 0.0.3
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/README.md +5 -6
- package/bunfig.toml +3 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/auctionSubscriber/types.d.ts +4 -2
- package/lib/browser/config.d.ts +3 -8
- package/lib/browser/config.js +14 -22
- package/lib/browser/constituentMap/constituentMap.d.ts +4 -2
- package/lib/browser/constituentMap/constituentMap.js +14 -10
- package/lib/browser/core/VelocityCore.d.ts +4 -0
- package/lib/browser/core/VelocityCore.js +3 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/browser/dlob/DLOBSubscriber.js +19 -10
- package/lib/browser/dlob/types.d.ts +3 -1
- package/lib/browser/idl/drift.d.ts +54 -1
- package/lib/browser/idl/drift.json +6046 -803
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/browser/orderSubscriber/types.d.ts +3 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/browser/priorityFee/types.d.ts +9 -5
- package/lib/browser/priorityFee/types.js +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/browser/swift/swiftOrderSubscriber.js +19 -11
- package/lib/browser/user.d.ts +3 -1
- package/lib/browser/user.js +93 -86
- package/lib/browser/userConfig.d.ts +4 -2
- package/lib/browser/userMap/referrerMap.d.ts +5 -3
- package/lib/browser/userMap/referrerMap.js +18 -14
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/browser/userMap/userMap.d.ts +3 -1
- package/lib/browser/userMap/userMap.js +24 -19
- package/lib/browser/userMap/userMapConfig.d.ts +4 -2
- package/lib/browser/userMap/userStatsMap.d.ts +5 -3
- package/lib/browser/userMap/userStatsMap.js +15 -11
- package/lib/browser/userStats.d.ts +3 -1
- package/lib/browser/userStats.js +21 -15
- package/lib/browser/userStatsConfig.d.ts +4 -2
- package/lib/browser/util/deprecatedAlias.d.ts +26 -0
- package/lib/browser/util/deprecatedAlias.js +10 -0
- package/lib/browser/velocityClient.js +5 -5
- package/lib/browser/velocityClientConfig.d.ts +7 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/auctionSubscriber/types.d.ts +4 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/config.d.ts +3 -8
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +14 -22
- package/lib/node/constituentMap/constituentMap.d.ts +4 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +14 -10
- package/lib/node/core/VelocityCore.d.ts +4 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +3 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +19 -10
- package/lib/node/dlob/types.d.ts +3 -1
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/idl/drift.d.ts +54 -1
- package/lib/node/idl/drift.d.ts.map +1 -1
- package/lib/node/idl/drift.json +6046 -803
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/node/orderSubscriber/types.d.ts +3 -1
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/node/priorityFee/types.d.ts +9 -5
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +19 -11
- package/lib/node/user.d.ts +3 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +93 -86
- package/lib/node/userConfig.d.ts +4 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts +5 -3
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +18 -14
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/node/userMap/userMap.d.ts +3 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +24 -19
- package/lib/node/userMap/userMapConfig.d.ts +4 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +5 -3
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +15 -11
- package/lib/node/userStats.d.ts +3 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +21 -15
- package/lib/node/userStatsConfig.d.ts +4 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- package/lib/node/util/deprecatedAlias.d.ts +27 -0
- package/lib/node/util/deprecatedAlias.d.ts.map +1 -0
- package/lib/node/util/deprecatedAlias.js +10 -0
- package/lib/node/velocityClient.js +5 -5
- package/lib/node/velocityClientConfig.d.ts +7 -4
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/auctionSubscriber/auctionSubscriber.ts +12 -6
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -6
- package/src/auctionSubscriber/types.ts +5 -2
- package/src/config.ts +35 -27
- package/src/constituentMap/constituentMap.ts +17 -9
- package/src/core/VelocityCore.ts +6 -0
- package/src/dlob/DLOBSubscriber.ts +21 -11
- package/src/dlob/types.ts +3 -1
- package/src/idl/drift.json +23940 -18697
- package/src/idl/drift.ts +54 -1
- package/src/orderSubscriber/OrderSubscriber.ts +17 -7
- package/src/orderSubscriber/types.ts +3 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +13 -9
- package/src/priorityFee/priorityFeeSubscriberMap.ts +23 -25
- package/src/priorityFee/types.ts +14 -9
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +10 -23
- package/src/swift/signedMsgUserAccountSubscriber.ts +22 -14
- package/src/swift/swiftOrderSubscriber.ts +24 -16
- package/src/user.ts +93 -82
- package/src/userConfig.ts +5 -2
- package/src/userMap/referrerMap.ts +19 -15
- package/src/userMap/revenueShareEscrowMap.ts +20 -16
- package/src/userMap/userMap.ts +20 -15
- package/src/userMap/userMapConfig.ts +6 -3
- package/src/userMap/userStatsMap.ts +19 -15
- package/src/userStats.ts +13 -7
- package/src/userStatsConfig.ts +5 -2
- package/src/util/deprecatedAlias.ts +25 -0
- package/src/velocityClient.ts +6 -6
- package/src/velocityClientConfig.ts +25 -42
|
@@ -10,12 +10,16 @@ const memcmp_1 = require("../memcmp");
|
|
|
10
10
|
const bs58_1 = __importDefault(require("bs58"));
|
|
11
11
|
const DEFAULT_PUBLIC_KEY = web3_js_1.PublicKey.default.toBase58();
|
|
12
12
|
class ReferrerMap {
|
|
13
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
+
get driftClient() {
|
|
15
|
+
return this.velocityClient;
|
|
16
|
+
}
|
|
13
17
|
/**
|
|
14
18
|
* Creates a new UserStatsMap instance.
|
|
15
19
|
*
|
|
16
|
-
* @param {VelocityClient}
|
|
20
|
+
* @param {VelocityClient} velocityClient - The VelocityClient instance.
|
|
17
21
|
*/
|
|
18
|
-
constructor(
|
|
22
|
+
constructor(velocityClient, parallelSync) {
|
|
19
23
|
/**
|
|
20
24
|
* map from authority pubkey to referrer pubkey.
|
|
21
25
|
*/
|
|
@@ -25,7 +29,7 @@ class ReferrerMap {
|
|
|
25
29
|
* Will be undefined if the referrer is not in the map yet.
|
|
26
30
|
*/
|
|
27
31
|
this.referrerReferrerInfoMap = new Map();
|
|
28
|
-
this.
|
|
32
|
+
this.velocityClient = velocityClient;
|
|
29
33
|
this.parallelSync = parallelSync !== undefined ? parallelSync : true;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
@@ -35,7 +39,7 @@ class ReferrerMap {
|
|
|
35
39
|
if (this.size() > 0) {
|
|
36
40
|
return;
|
|
37
41
|
}
|
|
38
|
-
await this.
|
|
42
|
+
await this.velocityClient.subscribe();
|
|
39
43
|
await this.sync();
|
|
40
44
|
}
|
|
41
45
|
has(authorityPublicKey) {
|
|
@@ -49,8 +53,8 @@ class ReferrerMap {
|
|
|
49
53
|
this.authorityReferrerMap.set(authority, referrer);
|
|
50
54
|
}
|
|
51
55
|
else if (referrer === undefined) {
|
|
52
|
-
const userStatsAccountPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.
|
|
53
|
-
const buffer = (await this.
|
|
56
|
+
const userStatsAccountPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.velocityClient.program.programId, new web3_js_1.PublicKey(authority));
|
|
57
|
+
const buffer = (await this.velocityClient.connection.getAccountInfo(userStatsAccountPublicKey, 'processed')).data;
|
|
54
58
|
const referrer = bs58_1.default.encode(buffer.subarray(40, 72));
|
|
55
59
|
this.addReferrer(authority, referrer);
|
|
56
60
|
}
|
|
@@ -81,8 +85,8 @@ class ReferrerMap {
|
|
|
81
85
|
}
|
|
82
86
|
const referrerKey = new web3_js_1.PublicKey(referrer);
|
|
83
87
|
const referrerInfo = {
|
|
84
|
-
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.
|
|
85
|
-
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.
|
|
88
|
+
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.velocityClient.program.programId, referrerKey, 0),
|
|
89
|
+
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.velocityClient.program.programId, referrerKey),
|
|
86
90
|
};
|
|
87
91
|
this.referrerReferrerInfoMap.set(referrer, referrerInfo);
|
|
88
92
|
return referrerInfo;
|
|
@@ -121,9 +125,9 @@ class ReferrerMap {
|
|
|
121
125
|
}
|
|
122
126
|
async syncAll() {
|
|
123
127
|
const rpcRequestArgs = [
|
|
124
|
-
this.
|
|
128
|
+
this.velocityClient.program.programId.toBase58(),
|
|
125
129
|
{
|
|
126
|
-
commitment: this.
|
|
130
|
+
commitment: this.velocityClient.opts.commitment,
|
|
127
131
|
filters: [(0, memcmp_1.getUserStatsFilter)()],
|
|
128
132
|
encoding: 'base64',
|
|
129
133
|
dataSlice: {
|
|
@@ -135,7 +139,7 @@ class ReferrerMap {
|
|
|
135
139
|
];
|
|
136
140
|
const rpcJSONResponse =
|
|
137
141
|
// @ts-ignore
|
|
138
|
-
await this.
|
|
142
|
+
await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
|
|
139
143
|
const rpcResponseAndContext = rpcJSONResponse.result;
|
|
140
144
|
for (const account of rpcResponseAndContext.value) {
|
|
141
145
|
// only add if it isn't already in the map
|
|
@@ -147,9 +151,9 @@ class ReferrerMap {
|
|
|
147
151
|
}
|
|
148
152
|
async syncReferrer(referrerFilter) {
|
|
149
153
|
const rpcRequestArgs = [
|
|
150
|
-
this.
|
|
154
|
+
this.velocityClient.program.programId.toBase58(),
|
|
151
155
|
{
|
|
152
|
-
commitment: this.
|
|
156
|
+
commitment: this.velocityClient.opts.commitment,
|
|
153
157
|
filters: [(0, memcmp_1.getUserStatsFilter)(), referrerFilter],
|
|
154
158
|
encoding: 'base64',
|
|
155
159
|
dataSlice: {
|
|
@@ -161,7 +165,7 @@ class ReferrerMap {
|
|
|
161
165
|
];
|
|
162
166
|
const rpcJSONResponse =
|
|
163
167
|
// @ts-ignore
|
|
164
|
-
await this.
|
|
168
|
+
await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
|
|
165
169
|
const rpcResponseAndContext = rpcJSONResponse.result;
|
|
166
170
|
const batchSize = 1000;
|
|
167
171
|
for (let i = 0; i < rpcResponseAndContext.value.length; i += batchSize) {
|
|
@@ -5,17 +5,19 @@ export declare class RevenueShareEscrowMap {
|
|
|
5
5
|
* map from authority pubkey to RevenueShareEscrow account data.
|
|
6
6
|
*/
|
|
7
7
|
private authorityEscrowMap;
|
|
8
|
-
private
|
|
8
|
+
private velocityClient;
|
|
9
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
10
|
+
private get driftClient();
|
|
9
11
|
private parallelSync;
|
|
10
12
|
private fetchPromise?;
|
|
11
13
|
private fetchPromiseResolver;
|
|
12
14
|
/**
|
|
13
15
|
* Creates a new RevenueShareEscrowMap instance.
|
|
14
16
|
*
|
|
15
|
-
* @param {VelocityClient}
|
|
17
|
+
* @param {VelocityClient} velocityClient - The VelocityClient instance.
|
|
16
18
|
* @param {boolean} parallelSync - Whether to sync accounts in parallel.
|
|
17
19
|
*/
|
|
18
|
-
constructor(
|
|
20
|
+
constructor(velocityClient: VelocityClient, parallelSync?: boolean);
|
|
19
21
|
/**
|
|
20
22
|
* Subscribe to all RevenueShareEscrow accounts.
|
|
21
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revenueShareEscrowMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/revenueShareEscrowMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,qBAAa,qBAAqB;IACjC;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAgD;IAC1E,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"revenueShareEscrowMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/revenueShareEscrowMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,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AM,GACvB,yBAAyB,EAAE;IAUjB,WAAW;CAGxB"}
|
|
@@ -5,18 +5,22 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
5
5
|
const pda_1 = require("../addresses/pda");
|
|
6
6
|
const memcmp_1 = require("../memcmp");
|
|
7
7
|
class RevenueShareEscrowMap {
|
|
8
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
9
|
+
get driftClient() {
|
|
10
|
+
return this.velocityClient;
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* Creates a new RevenueShareEscrowMap instance.
|
|
10
14
|
*
|
|
11
|
-
* @param {VelocityClient}
|
|
15
|
+
* @param {VelocityClient} velocityClient - The VelocityClient instance.
|
|
12
16
|
* @param {boolean} parallelSync - Whether to sync accounts in parallel.
|
|
13
17
|
*/
|
|
14
|
-
constructor(
|
|
18
|
+
constructor(velocityClient, parallelSync) {
|
|
15
19
|
/**
|
|
16
20
|
* map from authority pubkey to RevenueShareEscrow account data.
|
|
17
21
|
*/
|
|
18
22
|
this.authorityEscrowMap = new Map();
|
|
19
|
-
this.
|
|
23
|
+
this.velocityClient = velocityClient;
|
|
20
24
|
this.parallelSync = parallelSync !== undefined ? parallelSync : true;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -26,7 +30,7 @@ class RevenueShareEscrowMap {
|
|
|
26
30
|
if (this.size() > 0) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
await this.
|
|
33
|
+
await this.velocityClient.subscribe();
|
|
30
34
|
await this.sync();
|
|
31
35
|
}
|
|
32
36
|
has(authorityPublicKey) {
|
|
@@ -48,11 +52,11 @@ class RevenueShareEscrowMap {
|
|
|
48
52
|
return this.get(authorityPublicKey);
|
|
49
53
|
}
|
|
50
54
|
async addRevenueShareEscrow(authority) {
|
|
51
|
-
const escrowAccountPublicKey = (0, pda_1.getRevenueShareEscrowAccountPublicKey)(this.
|
|
55
|
+
const escrowAccountPublicKey = (0, pda_1.getRevenueShareEscrowAccountPublicKey)(this.velocityClient.program.programId, new web3_js_1.PublicKey(authority));
|
|
52
56
|
try {
|
|
53
|
-
const accountInfo = await this.
|
|
57
|
+
const accountInfo = await this.velocityClient.connection.getAccountInfo(escrowAccountPublicKey, 'processed');
|
|
54
58
|
if (accountInfo && accountInfo.data) {
|
|
55
|
-
const escrow = this.
|
|
59
|
+
const escrow = this.velocityClient.program.account.revenueShareEscrow.coder.accounts.decode('revenueShareEscrow', accountInfo.data);
|
|
56
60
|
this.authorityEscrowMap.set(authority, escrow);
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -88,16 +92,16 @@ class RevenueShareEscrowMap {
|
|
|
88
92
|
return this.fetchPromise;
|
|
89
93
|
}
|
|
90
94
|
for (const authority of this.authorityEscrowMap.keys()) {
|
|
91
|
-
const accountInfo = await this.
|
|
92
|
-
const escrowNew = this.
|
|
95
|
+
const accountInfo = await this.velocityClient.connection.getAccountInfo((0, pda_1.getRevenueShareEscrowAccountPublicKey)(this.velocityClient.program.programId, new web3_js_1.PublicKey(authority)), 'confirmed');
|
|
96
|
+
const escrowNew = this.velocityClient.program.account.revenueShareEscrow.coder.accounts.decode('revenueShareEscrow', accountInfo.data);
|
|
93
97
|
this.authorityEscrowMap.set(authority, escrowNew);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
async syncAll() {
|
|
97
101
|
const rpcRequestArgs = [
|
|
98
|
-
this.
|
|
102
|
+
this.velocityClient.program.programId.toBase58(),
|
|
99
103
|
{
|
|
100
|
-
commitment: this.
|
|
104
|
+
commitment: this.velocityClient.opts.commitment,
|
|
101
105
|
filters: [(0, memcmp_1.getRevenueShareEscrowFilter)()],
|
|
102
106
|
encoding: 'base64',
|
|
103
107
|
withContext: true,
|
|
@@ -105,7 +109,7 @@ class RevenueShareEscrowMap {
|
|
|
105
109
|
];
|
|
106
110
|
const rpcJSONResponse =
|
|
107
111
|
// @ts-ignore
|
|
108
|
-
await this.
|
|
112
|
+
await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
|
|
109
113
|
const rpcResponseAndContext = rpcJSONResponse.result;
|
|
110
114
|
const batchSize = 100;
|
|
111
115
|
for (let i = 0; i < rpcResponseAndContext.value.length; i += batchSize) {
|
|
@@ -115,7 +119,7 @@ class RevenueShareEscrowMap {
|
|
|
115
119
|
try {
|
|
116
120
|
// @ts-ignore
|
|
117
121
|
const buffer = Buffer.from(programAccount.account.data[0], programAccount.account.data[1]);
|
|
118
|
-
const escrow = this.
|
|
122
|
+
const escrow = this.velocityClient.program.account.revenueShareEscrow.coder.accounts.decode('revenueShareEscrow', buffer);
|
|
119
123
|
// Extract authority from the account data
|
|
120
124
|
const authorityKey = escrow.authority.toBase58();
|
|
121
125
|
this.authorityEscrowMap.set(authorityKey, escrow);
|
|
@@ -130,7 +134,7 @@ class RevenueShareEscrowMap {
|
|
|
130
134
|
try {
|
|
131
135
|
// @ts-ignore
|
|
132
136
|
const buffer = Buffer.from(programAccount.account.data[0], programAccount.account.data[1]);
|
|
133
|
-
const escrow = this.
|
|
137
|
+
const escrow = this.velocityClient.program.account.revenueShareEscrow.coder.accounts.decode('revenueShareEscrow', buffer);
|
|
134
138
|
// Extract authority from the account data
|
|
135
139
|
const authorityKey = escrow.authority.toBase58();
|
|
136
140
|
this.authorityEscrowMap.set(authorityKey, escrow);
|
|
@@ -29,7 +29,9 @@ export interface UserMapInterface {
|
|
|
29
29
|
}
|
|
30
30
|
export declare class UserMap implements UserMapInterface {
|
|
31
31
|
private userMap;
|
|
32
|
-
|
|
32
|
+
velocityClient: VelocityClient;
|
|
33
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
34
|
+
get driftClient(): VelocityClient;
|
|
33
35
|
eventEmitter: StrictEventEmitter<EventEmitter, UserEvents>;
|
|
34
36
|
private connection;
|
|
35
37
|
private commitment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMap.d.ts","sourceRoot":"","sources":["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"}
|
|
@@ -15,11 +15,15 @@ const grpcSubscription_1 = require("./grpcSubscription");
|
|
|
15
15
|
const events_1 = require("events");
|
|
16
16
|
const MAX_USER_ACCOUNT_SIZE_BYTES = 4376;
|
|
17
17
|
class UserMap {
|
|
18
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
19
|
+
get driftClient() {
|
|
20
|
+
return this.velocityClient;
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* Constructs a new UserMap instance.
|
|
20
24
|
*/
|
|
21
25
|
constructor(config) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
23
27
|
this.userMap = new Map();
|
|
24
28
|
this.stateAccountUpdateCallback = async (state) => {
|
|
25
29
|
if (!state.numberOfSubAccounts.eq(this.lastNumberOfSubAccounts)) {
|
|
@@ -28,29 +32,30 @@ class UserMap {
|
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
34
|
this.mostRecentSlot = 0;
|
|
31
|
-
|
|
35
|
+
// Type-system guarantees at least one of the two is supplied.
|
|
36
|
+
this.velocityClient = ((_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient);
|
|
32
37
|
if (config.connection) {
|
|
33
38
|
this.connection = config.connection;
|
|
34
39
|
}
|
|
35
40
|
else {
|
|
36
|
-
this.connection = this.
|
|
41
|
+
this.connection = this.velocityClient.connection;
|
|
37
42
|
}
|
|
38
43
|
this.commitment =
|
|
39
44
|
config.subscriptionConfig.type === 'websocket' ||
|
|
40
45
|
config.subscriptionConfig.type === 'polling'
|
|
41
|
-
? (
|
|
42
|
-
: this.
|
|
43
|
-
this.includeIdle = (
|
|
46
|
+
? (_b = config.subscriptionConfig.commitment) !== null && _b !== void 0 ? _b : this.velocityClient.opts.commitment
|
|
47
|
+
: this.velocityClient.opts.commitment;
|
|
48
|
+
this.includeIdle = (_c = config.includeIdle) !== null && _c !== void 0 ? _c : false;
|
|
44
49
|
this.filterByPoolId = config.filterByPoolId;
|
|
45
50
|
this.additionalFilters = config.additionalFilters;
|
|
46
51
|
this.disableSyncOnTotalAccountsChange =
|
|
47
|
-
(
|
|
52
|
+
(_d = config.disableSyncOnTotalAccountsChange) !== null && _d !== void 0 ? _d : false;
|
|
48
53
|
let decodeFn;
|
|
49
|
-
if ((
|
|
54
|
+
if ((_e = config.fastDecode) !== null && _e !== void 0 ? _e : true) {
|
|
50
55
|
decodeFn = (name, buffer) => (0, user_2.decodeUser)(buffer);
|
|
51
56
|
}
|
|
52
57
|
else {
|
|
53
|
-
decodeFn = this.
|
|
58
|
+
decodeFn = this.velocityClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.user.coder.accounts);
|
|
54
59
|
}
|
|
55
60
|
this.decode = decodeFn;
|
|
56
61
|
if (config.subscriptionConfig.type === 'polling') {
|
|
@@ -84,34 +89,34 @@ class UserMap {
|
|
|
84
89
|
decodeFn,
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
|
-
this.syncConfig = (
|
|
92
|
+
this.syncConfig = (_f = config.syncConfig) !== null && _f !== void 0 ? _f : {
|
|
88
93
|
type: 'default',
|
|
89
94
|
};
|
|
90
95
|
// Whether to throw an error if the userMap fails to sync. Defaults to false.
|
|
91
|
-
this.throwOnFailedSync = (
|
|
96
|
+
this.throwOnFailedSync = (_g = config.throwOnFailedSync) !== null && _g !== void 0 ? _g : false;
|
|
92
97
|
this.eventEmitter = new events_1.EventEmitter();
|
|
93
98
|
}
|
|
94
99
|
async subscribe() {
|
|
95
100
|
if (this.size() > 0) {
|
|
96
101
|
return;
|
|
97
102
|
}
|
|
98
|
-
await this.
|
|
103
|
+
await this.velocityClient.subscribe();
|
|
99
104
|
this.lastNumberOfSubAccounts =
|
|
100
|
-
this.
|
|
105
|
+
this.velocityClient.getStateAccount().numberOfSubAccounts;
|
|
101
106
|
if (!this.disableSyncOnTotalAccountsChange) {
|
|
102
|
-
this.
|
|
107
|
+
this.velocityClient.eventEmitter.on('stateAccountUpdate', this.stateAccountUpdateCallback);
|
|
103
108
|
}
|
|
104
109
|
await this.subscription.subscribe();
|
|
105
110
|
}
|
|
106
111
|
async addPubkey(userAccountPublicKey, userAccount, slot, accountSubscription) {
|
|
107
112
|
var _a;
|
|
108
113
|
const user = new user_1.User({
|
|
109
|
-
|
|
114
|
+
velocityClient: this.velocityClient,
|
|
110
115
|
userAccountPublicKey,
|
|
111
116
|
accountSubscription: accountSubscription !== null && accountSubscription !== void 0 ? accountSubscription : {
|
|
112
117
|
type: 'custom',
|
|
113
118
|
// OneShotUserAccountSubscriber used here so we don't load up the RPC with AccountSubscribes
|
|
114
|
-
userAccountSubscriber: new oneShotUserAccountSubscriber_1.OneShotUserAccountSubscriber(this.
|
|
119
|
+
userAccountSubscriber: new oneShotUserAccountSubscriber_1.OneShotUserAccountSubscriber(this.velocityClient.program, userAccountPublicKey, userAccount, slot, this.commitment),
|
|
115
120
|
},
|
|
116
121
|
});
|
|
117
122
|
await user.subscribe(userAccount);
|
|
@@ -292,7 +297,7 @@ class UserMap {
|
|
|
292
297
|
});
|
|
293
298
|
try {
|
|
294
299
|
const rpcRequestArgs = [
|
|
295
|
-
this.
|
|
300
|
+
this.velocityClient.program.programId.toBase58(),
|
|
296
301
|
{
|
|
297
302
|
commitment: this.commitment,
|
|
298
303
|
filters: this.getFilters(),
|
|
@@ -364,7 +369,7 @@ class UserMap {
|
|
|
364
369
|
this.syncPromiseResolver = resolve;
|
|
365
370
|
});
|
|
366
371
|
try {
|
|
367
|
-
const accountsPrefetch = await this.connection.getProgramAccounts(this.
|
|
372
|
+
const accountsPrefetch = await this.connection.getProgramAccounts(this.velocityClient.program.programId, {
|
|
368
373
|
dataSlice: { offset: 0, length: 0 },
|
|
369
374
|
filters: this.getFilters(),
|
|
370
375
|
});
|
|
@@ -454,7 +459,7 @@ class UserMap {
|
|
|
454
459
|
}
|
|
455
460
|
if (this.lastNumberOfSubAccounts) {
|
|
456
461
|
if (!this.disableSyncOnTotalAccountsChange) {
|
|
457
|
-
this.
|
|
462
|
+
this.velocityClient.eventEmitter.removeListener('stateAccountUpdate', this.stateAccountUpdateCallback);
|
|
458
463
|
}
|
|
459
464
|
this.lastNumberOfSubAccounts = undefined;
|
|
460
465
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Commitment, Connection, MemcmpFilter } from '@solana/web3.js';
|
|
2
2
|
import { VelocityClient } from '../velocityClient';
|
|
3
3
|
import { GrpcConfigs } from '../accounts/types';
|
|
4
|
+
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
4
5
|
export type UserAccountFilterCriteria = {
|
|
5
6
|
hasOpenOrders: boolean;
|
|
6
7
|
};
|
|
@@ -11,8 +12,7 @@ export type SyncConfig = {
|
|
|
11
12
|
chunkSize?: number;
|
|
12
13
|
concurrencyLimit?: number;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
driftClient: VelocityClient;
|
|
15
|
+
type UserMapConfigBase = {
|
|
16
16
|
connection?: Connection;
|
|
17
17
|
subscriptionConfig: {
|
|
18
18
|
type: 'polling';
|
|
@@ -38,4 +38,6 @@ export type UserMapConfig = {
|
|
|
38
38
|
filterByPoolId?: number;
|
|
39
39
|
additionalFilters?: MemcmpFilter[];
|
|
40
40
|
};
|
|
41
|
+
export type UserMapConfig = UserMapConfigBase & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
|
|
42
|
+
export {};
|
|
41
43
|
//# sourceMappingURL=userMapConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMapConfig.d.ts","sourceRoot":"","sources":["../../../src/userMap/userMapConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
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,CAAC;IAGxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAG5B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iBAAiB,CAAC,EAAE,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC5C,UAAU,CAAC,gBAAgB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -11,7 +11,9 @@ export declare class UserStatsMap {
|
|
|
11
11
|
* map from authority pubkey to UserStats
|
|
12
12
|
*/
|
|
13
13
|
private userStatsMap;
|
|
14
|
-
private
|
|
14
|
+
private velocityClient;
|
|
15
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
16
|
+
private get driftClient();
|
|
15
17
|
private bulkAccountLoader;
|
|
16
18
|
private decode;
|
|
17
19
|
private syncConfig;
|
|
@@ -20,10 +22,10 @@ export declare class UserStatsMap {
|
|
|
20
22
|
/**
|
|
21
23
|
* Creates a new UserStatsMap instance.
|
|
22
24
|
*
|
|
23
|
-
* @param {VelocityClient}
|
|
25
|
+
* @param {VelocityClient} velocityClient - The VelocityClient instance.
|
|
24
26
|
* @param {BulkAccountLoader} [bulkAccountLoader] - If not provided, a new BulkAccountLoader with polling disabled will be created.
|
|
25
27
|
*/
|
|
26
|
-
constructor(
|
|
28
|
+
constructor(velocityClient: VelocityClient, bulkAccountLoader?: BulkAccountLoader, syncConfig?: SyncConfig);
|
|
27
29
|
subscribe(authorities: PublicKey[]): Promise<void>;
|
|
28
30
|
/**
|
|
29
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStatsMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/userStatsMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACN,WAAW,EACX,gBAAgB,EAQhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,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E,iBAAiB,EACrC,UAAU,CAAC,EAAE,UAAU;IAuBX,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE;IAS/C;;;;;OAKG;IACU,WAAW,CACvB,SAAS,EAAE,SAAS,EACpB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,SAAS,CAAC,EAAE,OAAO;IAwBP,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO;IAO3D,qBAAqB,CACjC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,EACzB,OAAO,CAAC,EAAE,OAAO;IA0DX,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO;IAIxC,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS;IAIjD;;;;;OAKG;IACU,OAAO,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAW7D,MAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC;IAIrC,IAAI,IAAI,MAAM;IAIrB;;;;OAIG;IACU,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE;IAQ1C;;;;OAIG;YACW,WAAW;IASzB;;;OAGG;YACW,aAAa;IA8Gd,WAAW;CAMxB"}
|
|
@@ -7,32 +7,36 @@ const bulkAccountLoader_1 = require("../accounts/bulkAccountLoader");
|
|
|
7
7
|
const memcmp_1 = require("../memcmp");
|
|
8
8
|
const web3_js_1 = require("@solana/web3.js");
|
|
9
9
|
class UserStatsMap {
|
|
10
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
11
|
+
get driftClient() {
|
|
12
|
+
return this.velocityClient;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Creates a new UserStatsMap instance.
|
|
12
16
|
*
|
|
13
|
-
* @param {VelocityClient}
|
|
17
|
+
* @param {VelocityClient} velocityClient - The VelocityClient instance.
|
|
14
18
|
* @param {BulkAccountLoader} [bulkAccountLoader] - If not provided, a new BulkAccountLoader with polling disabled will be created.
|
|
15
19
|
*/
|
|
16
|
-
constructor(
|
|
20
|
+
constructor(velocityClient, bulkAccountLoader, syncConfig) {
|
|
17
21
|
/**
|
|
18
22
|
* map from authority pubkey to UserStats
|
|
19
23
|
*/
|
|
20
24
|
this.userStatsMap = new Map();
|
|
21
|
-
this.
|
|
25
|
+
this.velocityClient = velocityClient;
|
|
22
26
|
if (!bulkAccountLoader) {
|
|
23
|
-
bulkAccountLoader = new bulkAccountLoader_1.BulkAccountLoader(
|
|
27
|
+
bulkAccountLoader = new bulkAccountLoader_1.BulkAccountLoader(velocityClient.connection, velocityClient.opts.commitment, 0);
|
|
24
28
|
}
|
|
25
29
|
this.bulkAccountLoader = bulkAccountLoader;
|
|
26
30
|
this.syncConfig = syncConfig !== null && syncConfig !== void 0 ? syncConfig : {
|
|
27
31
|
type: 'default',
|
|
28
32
|
};
|
|
29
|
-
this.decode = this.
|
|
33
|
+
this.decode = this.velocityClient.program.account.userStats.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.userStats.coder.accounts);
|
|
30
34
|
}
|
|
31
35
|
async subscribe(authorities) {
|
|
32
36
|
if (this.size() > 0) {
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
|
-
await this.
|
|
39
|
+
await this.velocityClient.subscribe();
|
|
36
40
|
await this.sync(authorities);
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
@@ -43,8 +47,8 @@ class UserStatsMap {
|
|
|
43
47
|
*/
|
|
44
48
|
async addUserStat(authority, userStatsAccount, skipFetch) {
|
|
45
49
|
const userStat = new userStats_1.UserStats({
|
|
46
|
-
|
|
47
|
-
userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.
|
|
50
|
+
velocityClient: this.velocityClient,
|
|
51
|
+
userStatsAccountPublicKey: (0, pda_1.getUserStatsAccountPublicKey)(this.velocityClient.program.programId, authority),
|
|
48
52
|
accountSubscription: {
|
|
49
53
|
type: 'polling',
|
|
50
54
|
accountLoader: this.bulkAccountLoader,
|
|
@@ -182,7 +186,7 @@ class UserStatsMap {
|
|
|
182
186
|
try {
|
|
183
187
|
let accountsToLoad = authorities;
|
|
184
188
|
if (authorities.length === 0) {
|
|
185
|
-
const accountsPrefetch = await this.
|
|
189
|
+
const accountsPrefetch = await this.velocityClient.connection.getProgramAccounts(this.velocityClient.program.programId, {
|
|
186
190
|
dataSlice: { offset: 0, length: 0 },
|
|
187
191
|
filters: [(0, memcmp_1.getUserStatsFilter)()],
|
|
188
192
|
});
|
|
@@ -216,8 +220,8 @@ class UserStatsMap {
|
|
|
216
220
|
for (let i = 0; i < accountsToLoad.length; i += chunkSize) {
|
|
217
221
|
const chunk = accountsToLoad.slice(i, i + chunkSize);
|
|
218
222
|
tasks.push(async () => {
|
|
219
|
-
const accountInfos = await this.
|
|
220
|
-
commitment: this.
|
|
223
|
+
const accountInfos = await this.velocityClient.connection.getMultipleAccountsInfoAndContext(chunk, {
|
|
224
|
+
commitment: this.velocityClient.opts.commitment,
|
|
221
225
|
});
|
|
222
226
|
for (let j = 0; j < accountInfos.value.length; j += 1) {
|
|
223
227
|
const accountInfo = accountInfos.value[j];
|
package/lib/node/userStats.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
|
9
9
|
import { UserStatsConfig } from './userStatsConfig';
|
|
10
10
|
import { ReferrerInfo, UserStatsAccount } from './types';
|
|
11
11
|
export declare class UserStats {
|
|
12
|
-
|
|
12
|
+
velocityClient: VelocityClient;
|
|
13
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
+
get driftClient(): VelocityClient;
|
|
13
15
|
userStatsAccountPublicKey: PublicKey;
|
|
14
16
|
accountSubscriber: UserStatsAccountSubscriber;
|
|
15
17
|
isSubscribed: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStats.d.ts","sourceRoot":"","sources":["../../src/userStats.ts"],"names":[],"mappings":"AAAA;;;;G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gB,GAAG,MAAM;CAOlE"}
|
package/lib/node/userStats.js
CHANGED
|
@@ -7,26 +7,32 @@ const webSocketUserStatsAccountSubsriber_1 = require("./accounts/webSocketUserSt
|
|
|
7
7
|
const pda_1 = require("./addresses/pda");
|
|
8
8
|
const grpcUserStatsAccountSubscriber_1 = require("./accounts/grpcUserStatsAccountSubscriber");
|
|
9
9
|
class UserStats {
|
|
10
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
11
|
+
get driftClient() {
|
|
12
|
+
return this.velocityClient;
|
|
13
|
+
}
|
|
10
14
|
constructor(config) {
|
|
11
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12
|
-
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
16
|
+
// Type-system guarantees at least one of the two is supplied.
|
|
17
|
+
const velocityClient = ((_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient);
|
|
18
|
+
this.velocityClient = velocityClient;
|
|
13
19
|
this.userStatsAccountPublicKey = config.userStatsAccountPublicKey;
|
|
14
|
-
if (((
|
|
15
|
-
this.accountSubscriber = new pollingUserStatsAccountSubscriber_1.PollingUserStatsAccountSubscriber(
|
|
20
|
+
if (((_b = config.accountSubscription) === null || _b === void 0 ? void 0 : _b.type) === 'polling') {
|
|
21
|
+
this.accountSubscriber = new pollingUserStatsAccountSubscriber_1.PollingUserStatsAccountSubscriber(velocityClient.program, config.userStatsAccountPublicKey, config.accountSubscription.accountLoader);
|
|
16
22
|
}
|
|
17
|
-
else if (((
|
|
18
|
-
this.accountSubscriber = new grpcUserStatsAccountSubscriber_1.grpcUserStatsAccountSubscriber(config.accountSubscription.grpcConfigs,
|
|
19
|
-
resubTimeoutMs: (
|
|
20
|
-
logResubMessages: (
|
|
23
|
+
else if (((_c = config.accountSubscription) === null || _c === void 0 ? void 0 : _c.type) === 'grpc') {
|
|
24
|
+
this.accountSubscriber = new grpcUserStatsAccountSubscriber_1.grpcUserStatsAccountSubscriber(config.accountSubscription.grpcConfigs, velocityClient.program, config.userStatsAccountPublicKey, {
|
|
25
|
+
resubTimeoutMs: (_d = config.accountSubscription) === null || _d === void 0 ? void 0 : _d.resubTimeoutMs,
|
|
26
|
+
logResubMessages: (_e = config.accountSubscription) === null || _e === void 0 ? void 0 : _e.logResubMessages,
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
|
-
else if (((
|
|
24
|
-
this.accountSubscriber = new webSocketUserStatsAccountSubsriber_1.WebSocketUserStatsAccountSubscriber(
|
|
25
|
-
resubTimeoutMs: (
|
|
26
|
-
logResubMessages: (
|
|
29
|
+
else if (((_f = config.accountSubscription) === null || _f === void 0 ? void 0 : _f.type) === 'websocket') {
|
|
30
|
+
this.accountSubscriber = new webSocketUserStatsAccountSubsriber_1.WebSocketUserStatsAccountSubscriber(velocityClient.program, config.userStatsAccountPublicKey, {
|
|
31
|
+
resubTimeoutMs: (_g = config.accountSubscription) === null || _g === void 0 ? void 0 : _g.resubTimeoutMs,
|
|
32
|
+
logResubMessages: (_h = config.accountSubscription) === null || _h === void 0 ? void 0 : _h.logResubMessages,
|
|
27
33
|
}, config.accountSubscription.commitment);
|
|
28
34
|
}
|
|
29
|
-
else if (((
|
|
35
|
+
else if (((_j = config.accountSubscription) === null || _j === void 0 ? void 0 : _j.type) === 'custom') {
|
|
30
36
|
this.accountSubscriber =
|
|
31
37
|
config.accountSubscription.userStatsAccountSubscriber;
|
|
32
38
|
}
|
|
@@ -58,8 +64,8 @@ class UserStats {
|
|
|
58
64
|
}
|
|
59
65
|
else {
|
|
60
66
|
return {
|
|
61
|
-
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.
|
|
62
|
-
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.
|
|
67
|
+
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.velocityClient.program.programId, this.getAccount().referrer, 0),
|
|
68
|
+
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.velocityClient.program.programId, this.getAccount().referrer),
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -2,11 +2,12 @@ import { VelocityClient } from './velocityClient';
|
|
|
2
2
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
4
4
|
import { GrpcConfigs, UserStatsAccountSubscriber } from './accounts/types';
|
|
5
|
-
|
|
5
|
+
import { AtLeastOne } from './util/deprecatedAlias';
|
|
6
|
+
type UserStatsConfigBase = {
|
|
6
7
|
accountSubscription?: UserStatsSubscriptionConfig;
|
|
7
|
-
driftClient: VelocityClient;
|
|
8
8
|
userStatsAccountPublicKey: PublicKey;
|
|
9
9
|
};
|
|
10
|
+
export type UserStatsConfig = UserStatsConfigBase & AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
|
|
10
11
|
export type UserStatsSubscriptionConfig = {
|
|
11
12
|
type: 'websocket';
|
|
12
13
|
resubTimeoutMs?: number;
|
|
@@ -24,4 +25,5 @@ export type UserStatsSubscriptionConfig = {
|
|
|
24
25
|
logResubMessages?: boolean;
|
|
25
26
|
grpcConfigs: GrpcConfigs;
|
|
26
27
|
};
|
|
28
|
+
export {};
|
|
27
29
|
//# sourceMappingURL=userStatsConfig.d.ts.map
|