@drift-labs/sdk 2.100.0-beta.13 → 2.100.0-beta.14
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/VERSION +1 -1
- package/lib/browser/driftClient.js +42 -39
- package/lib/node/driftClient.js +42 -39
- package/package.json +1 -1
- package/src/driftClient.ts +5 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.100.0-beta.
|
|
1
|
+
2.100.0-beta.14
|
|
@@ -82,7 +82,7 @@ class DriftClient {
|
|
|
82
82
|
this._isSubscribed = val;
|
|
83
83
|
}
|
|
84
84
|
constructor(config) {
|
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
|
|
86
86
|
this.users = new Map();
|
|
87
87
|
this._isSubscribed = false;
|
|
88
88
|
this.perpMarketLastSlotCache = new Map();
|
|
@@ -93,24 +93,27 @@ class DriftClient {
|
|
|
93
93
|
this.wallet = config.wallet;
|
|
94
94
|
this.opts = config.opts || {
|
|
95
95
|
...config_1.DEFAULT_CONFIRMATION_OPTS,
|
|
96
|
-
commitment: (_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment,
|
|
97
|
-
preflightCommitment: (_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
98
96
|
};
|
|
97
|
+
if ((_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment) {
|
|
98
|
+
// At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
99
|
+
this.opts.commitment = config.connection.commitment;
|
|
100
|
+
this.opts.preflightCommitment = config.connection.commitment;
|
|
101
|
+
}
|
|
99
102
|
this.provider = new anchor_1.AnchorProvider(config.connection,
|
|
100
103
|
// @ts-ignore
|
|
101
104
|
config.wallet, this.opts);
|
|
102
|
-
this.program = new anchor_1.Program(drift_json_1.default, (
|
|
103
|
-
this.swiftID = (
|
|
104
|
-
this.authority = (
|
|
105
|
-
this.activeSubAccountId = (
|
|
106
|
-
this.skipLoadUsers = (
|
|
107
|
-
this.txVersion = (
|
|
105
|
+
this.program = new anchor_1.Program(drift_json_1.default, (_b = config.programID) !== null && _b !== void 0 ? _b : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
|
|
106
|
+
this.swiftID = (_c = config.swiftID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.SWIFT_ID);
|
|
107
|
+
this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
|
|
108
|
+
this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
|
|
109
|
+
this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
|
|
110
|
+
this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 'legacy';
|
|
108
111
|
this.txParams = {
|
|
109
|
-
computeUnits: (
|
|
110
|
-
computeUnitsPrice: (
|
|
112
|
+
computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
|
|
113
|
+
computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
|
|
111
114
|
};
|
|
112
115
|
this.txHandler =
|
|
113
|
-
(
|
|
116
|
+
(_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
|
|
114
117
|
connection: this.connection,
|
|
115
118
|
// @ts-ignore
|
|
116
119
|
wallet: this.provider.wallet,
|
|
@@ -136,8 +139,8 @@ class DriftClient {
|
|
|
136
139
|
: config.subAccountIds
|
|
137
140
|
? new Map([[this.authority.toString(), config.subAccountIds]])
|
|
138
141
|
: new Map();
|
|
139
|
-
this.includeDelegates = (
|
|
140
|
-
if (((
|
|
142
|
+
this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
|
|
143
|
+
if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
|
|
141
144
|
this.userAccountSubscriptionConfig = {
|
|
142
145
|
type: 'polling',
|
|
143
146
|
accountLoader: config.accountSubscription.accountLoader,
|
|
@@ -147,32 +150,32 @@ class DriftClient {
|
|
|
147
150
|
accountLoader: config.accountSubscription.accountLoader,
|
|
148
151
|
};
|
|
149
152
|
}
|
|
150
|
-
else if (((
|
|
153
|
+
else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
|
|
151
154
|
this.userAccountSubscriptionConfig = {
|
|
152
155
|
type: 'grpc',
|
|
153
|
-
resubTimeoutMs: (
|
|
154
|
-
logResubMessages: (
|
|
155
|
-
grpcConfigs: (
|
|
156
|
+
resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
|
|
157
|
+
logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
|
|
158
|
+
grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
|
|
156
159
|
};
|
|
157
160
|
this.userStatsAccountSubscriptionConfig = {
|
|
158
161
|
type: 'grpc',
|
|
159
|
-
grpcConfigs: (
|
|
160
|
-
resubTimeoutMs: (
|
|
161
|
-
logResubMessages: (
|
|
162
|
+
grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
|
|
163
|
+
resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
|
|
164
|
+
logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
else {
|
|
165
168
|
this.userAccountSubscriptionConfig = {
|
|
166
169
|
type: 'websocket',
|
|
167
|
-
resubTimeoutMs: (
|
|
168
|
-
logResubMessages: (
|
|
169
|
-
commitment: (
|
|
170
|
+
resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
|
|
171
|
+
logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
|
|
172
|
+
commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
|
|
170
173
|
};
|
|
171
174
|
this.userStatsAccountSubscriptionConfig = {
|
|
172
175
|
type: 'websocket',
|
|
173
|
-
resubTimeoutMs: (
|
|
174
|
-
logResubMessages: (
|
|
175
|
-
commitment: (
|
|
176
|
+
resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
|
|
177
|
+
logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
|
|
178
|
+
commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
|
|
176
179
|
};
|
|
177
180
|
}
|
|
178
181
|
if (config.userStats) {
|
|
@@ -190,20 +193,20 @@ class DriftClient {
|
|
|
190
193
|
const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
|
|
191
194
|
config.spotMarketIndexes === undefined &&
|
|
192
195
|
config.oracleInfos === undefined;
|
|
193
|
-
if (((
|
|
194
|
-
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (
|
|
196
|
+
if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
|
|
197
|
+
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
|
|
195
198
|
}
|
|
196
|
-
else if (((
|
|
197
|
-
this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (
|
|
198
|
-
resubTimeoutMs: (
|
|
199
|
-
logResubMessages: (
|
|
199
|
+
else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
|
|
200
|
+
this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
201
|
+
resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
|
|
202
|
+
logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
|
|
200
203
|
});
|
|
201
204
|
}
|
|
202
205
|
else {
|
|
203
|
-
this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (
|
|
204
|
-
resubTimeoutMs: (
|
|
205
|
-
logResubMessages: (
|
|
206
|
-
}, (
|
|
206
|
+
this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
207
|
+
resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
|
|
208
|
+
logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
|
|
209
|
+
}, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
|
|
207
210
|
}
|
|
208
211
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
209
212
|
this.metricsEventEmitter = new events_1.EventEmitter();
|
|
@@ -211,14 +214,14 @@ class DriftClient {
|
|
|
211
214
|
this.enableMetricsEvents = true;
|
|
212
215
|
}
|
|
213
216
|
this.txSender =
|
|
214
|
-
(
|
|
217
|
+
(_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
|
|
215
218
|
connection: this.connection,
|
|
216
219
|
wallet: this.wallet,
|
|
217
220
|
opts: this.opts,
|
|
218
221
|
txHandler: this.txHandler,
|
|
219
222
|
});
|
|
220
223
|
this.sbOnDemandProgramdId =
|
|
221
|
-
config_1.configs[(
|
|
224
|
+
config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
|
|
222
225
|
}
|
|
223
226
|
getUserMapKey(subAccountId, authority) {
|
|
224
227
|
return `${subAccountId}_${authority.toString()}`;
|
package/lib/node/driftClient.js
CHANGED
|
@@ -82,7 +82,7 @@ class DriftClient {
|
|
|
82
82
|
this._isSubscribed = val;
|
|
83
83
|
}
|
|
84
84
|
constructor(config) {
|
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
|
|
86
86
|
this.users = new Map();
|
|
87
87
|
this._isSubscribed = false;
|
|
88
88
|
this.perpMarketLastSlotCache = new Map();
|
|
@@ -93,24 +93,27 @@ class DriftClient {
|
|
|
93
93
|
this.wallet = config.wallet;
|
|
94
94
|
this.opts = config.opts || {
|
|
95
95
|
...config_1.DEFAULT_CONFIRMATION_OPTS,
|
|
96
|
-
commitment: (_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment,
|
|
97
|
-
preflightCommitment: (_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
98
96
|
};
|
|
97
|
+
if ((_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment) {
|
|
98
|
+
// At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
99
|
+
this.opts.commitment = config.connection.commitment;
|
|
100
|
+
this.opts.preflightCommitment = config.connection.commitment;
|
|
101
|
+
}
|
|
99
102
|
this.provider = new anchor_1.AnchorProvider(config.connection,
|
|
100
103
|
// @ts-ignore
|
|
101
104
|
config.wallet, this.opts);
|
|
102
|
-
this.program = new anchor_1.Program(drift_json_1.default, (
|
|
103
|
-
this.swiftID = (
|
|
104
|
-
this.authority = (
|
|
105
|
-
this.activeSubAccountId = (
|
|
106
|
-
this.skipLoadUsers = (
|
|
107
|
-
this.txVersion = (
|
|
105
|
+
this.program = new anchor_1.Program(drift_json_1.default, (_b = config.programID) !== null && _b !== void 0 ? _b : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
|
|
106
|
+
this.swiftID = (_c = config.swiftID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.SWIFT_ID);
|
|
107
|
+
this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
|
|
108
|
+
this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
|
|
109
|
+
this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
|
|
110
|
+
this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 'legacy';
|
|
108
111
|
this.txParams = {
|
|
109
|
-
computeUnits: (
|
|
110
|
-
computeUnitsPrice: (
|
|
112
|
+
computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
|
|
113
|
+
computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
|
|
111
114
|
};
|
|
112
115
|
this.txHandler =
|
|
113
|
-
(
|
|
116
|
+
(_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
|
|
114
117
|
connection: this.connection,
|
|
115
118
|
// @ts-ignore
|
|
116
119
|
wallet: this.provider.wallet,
|
|
@@ -136,8 +139,8 @@ class DriftClient {
|
|
|
136
139
|
: config.subAccountIds
|
|
137
140
|
? new Map([[this.authority.toString(), config.subAccountIds]])
|
|
138
141
|
: new Map();
|
|
139
|
-
this.includeDelegates = (
|
|
140
|
-
if (((
|
|
142
|
+
this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
|
|
143
|
+
if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
|
|
141
144
|
this.userAccountSubscriptionConfig = {
|
|
142
145
|
type: 'polling',
|
|
143
146
|
accountLoader: config.accountSubscription.accountLoader,
|
|
@@ -147,32 +150,32 @@ class DriftClient {
|
|
|
147
150
|
accountLoader: config.accountSubscription.accountLoader,
|
|
148
151
|
};
|
|
149
152
|
}
|
|
150
|
-
else if (((
|
|
153
|
+
else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
|
|
151
154
|
this.userAccountSubscriptionConfig = {
|
|
152
155
|
type: 'grpc',
|
|
153
|
-
resubTimeoutMs: (
|
|
154
|
-
logResubMessages: (
|
|
155
|
-
grpcConfigs: (
|
|
156
|
+
resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
|
|
157
|
+
logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
|
|
158
|
+
grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
|
|
156
159
|
};
|
|
157
160
|
this.userStatsAccountSubscriptionConfig = {
|
|
158
161
|
type: 'grpc',
|
|
159
|
-
grpcConfigs: (
|
|
160
|
-
resubTimeoutMs: (
|
|
161
|
-
logResubMessages: (
|
|
162
|
+
grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
|
|
163
|
+
resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
|
|
164
|
+
logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
else {
|
|
165
168
|
this.userAccountSubscriptionConfig = {
|
|
166
169
|
type: 'websocket',
|
|
167
|
-
resubTimeoutMs: (
|
|
168
|
-
logResubMessages: (
|
|
169
|
-
commitment: (
|
|
170
|
+
resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
|
|
171
|
+
logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
|
|
172
|
+
commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
|
|
170
173
|
};
|
|
171
174
|
this.userStatsAccountSubscriptionConfig = {
|
|
172
175
|
type: 'websocket',
|
|
173
|
-
resubTimeoutMs: (
|
|
174
|
-
logResubMessages: (
|
|
175
|
-
commitment: (
|
|
176
|
+
resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
|
|
177
|
+
logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
|
|
178
|
+
commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
|
|
176
179
|
};
|
|
177
180
|
}
|
|
178
181
|
if (config.userStats) {
|
|
@@ -190,20 +193,20 @@ class DriftClient {
|
|
|
190
193
|
const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
|
|
191
194
|
config.spotMarketIndexes === undefined &&
|
|
192
195
|
config.oracleInfos === undefined;
|
|
193
|
-
if (((
|
|
194
|
-
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (
|
|
196
|
+
if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
|
|
197
|
+
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
|
|
195
198
|
}
|
|
196
|
-
else if (((
|
|
197
|
-
this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (
|
|
198
|
-
resubTimeoutMs: (
|
|
199
|
-
logResubMessages: (
|
|
199
|
+
else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
|
|
200
|
+
this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
201
|
+
resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
|
|
202
|
+
logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
|
|
200
203
|
});
|
|
201
204
|
}
|
|
202
205
|
else {
|
|
203
|
-
this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (
|
|
204
|
-
resubTimeoutMs: (
|
|
205
|
-
logResubMessages: (
|
|
206
|
-
}, (
|
|
206
|
+
this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
207
|
+
resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
|
|
208
|
+
logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
|
|
209
|
+
}, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
|
|
207
210
|
}
|
|
208
211
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
209
212
|
this.metricsEventEmitter = new events_1.EventEmitter();
|
|
@@ -211,14 +214,14 @@ class DriftClient {
|
|
|
211
214
|
this.enableMetricsEvents = true;
|
|
212
215
|
}
|
|
213
216
|
this.txSender =
|
|
214
|
-
(
|
|
217
|
+
(_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
|
|
215
218
|
connection: this.connection,
|
|
216
219
|
wallet: this.wallet,
|
|
217
220
|
opts: this.opts,
|
|
218
221
|
txHandler: this.txHandler,
|
|
219
222
|
});
|
|
220
223
|
this.sbOnDemandProgramdId =
|
|
221
|
-
config_1.configs[(
|
|
224
|
+
config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
|
|
222
225
|
}
|
|
223
226
|
getUserMapKey(subAccountId, authority) {
|
|
224
227
|
return `${subAccountId}_${authority.toString()}`;
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -243,9 +243,12 @@ export class DriftClient {
|
|
|
243
243
|
this.wallet = config.wallet;
|
|
244
244
|
this.opts = config.opts || {
|
|
245
245
|
...DEFAULT_CONFIRMATION_OPTS,
|
|
246
|
-
commitment: config?.connection?.commitment,
|
|
247
|
-
preflightCommitment: config?.connection?.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
248
246
|
};
|
|
247
|
+
if (config?.connection?.commitment) {
|
|
248
|
+
// At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
|
|
249
|
+
this.opts.commitment = config.connection.commitment;
|
|
250
|
+
this.opts.preflightCommitment = config.connection.commitment;
|
|
251
|
+
}
|
|
249
252
|
this.provider = new AnchorProvider(
|
|
250
253
|
config.connection,
|
|
251
254
|
// @ts-ignore
|