@drift-labs/sdk 2.38.1-beta.3 → 2.38.1-beta.4

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 CHANGED
@@ -1 +1 @@
1
- 2.38.1-beta.3
1
+ 2.38.1-beta.4
@@ -37,7 +37,7 @@ class PollingUserAccountSubscriber {
37
37
  if (this.user && this.user.slot > slot) {
38
38
  return;
39
39
  }
40
- const account = this.program.account.user.coder.accounts.decodeUnchecked('User', buffer);
40
+ const account = this.program.account.user.coder.accounts.decode('User', buffer);
41
41
  this.user = { data: account, slot };
42
42
  this.eventEmitter.emit('userAccountUpdate', account);
43
43
  this.eventEmitter.emit('update');
@@ -57,7 +57,7 @@ class PollingUserAccountSubscriber {
57
57
  const { buffer, slot } = this.accountLoader.getBufferAndSlot(this.userAccountPublicKey);
58
58
  const currentSlot = (_b = (_a = this.user) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0;
59
59
  if (buffer && slot > currentSlot) {
60
- const account = this.program.account.user.coder.accounts.decodeUnchecked('User', buffer);
60
+ const account = this.program.account.user.coder.accounts.decode('User', buffer);
61
61
  this.user = { data: account, slot };
62
62
  }
63
63
  }
@@ -78,7 +78,7 @@ class WebSocketAccountSubscriber {
78
78
  return this.decodeBufferFn(buffer);
79
79
  }
80
80
  else {
81
- return this.program.account[this.accountName].coder.accounts.decodeUnchecked((0, utils_1.capitalize)(this.accountName), buffer);
81
+ return this.program.account[this.accountName].coder.accounts.decode((0, utils_1.capitalize)(this.accountName), buffer);
82
82
  }
83
83
  }
84
84
  unsubscribe() {
@@ -76,7 +76,9 @@ class DriftClient {
76
76
  this.connection = config.connection;
77
77
  this.wallet = config.wallet;
78
78
  this.opts = config.opts || anchor_1.AnchorProvider.defaultOptions();
79
- this.provider = new anchor_1.AnchorProvider(config.connection, config.wallet, this.opts);
79
+ this.provider = new anchor_1.AnchorProvider(config.connection,
80
+ // @ts-ignore
81
+ config.wallet, this.opts);
80
82
  this.program = new anchor_1.Program(drift_json_1.default, (_a = config.programID) !== null && _a !== void 0 ? _a : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
81
83
  this.authority = (_b = config.authority) !== null && _b !== void 0 ? _b : this.wallet.publicKey;
82
84
  this.activeSubAccountId = (_c = config.activeSubAccountId) !== null && _c !== void 0 ? _c : 0;
@@ -292,7 +294,9 @@ class DriftClient {
292
294
  * @param includeDelegates
293
295
  */
294
296
  async updateWallet(newWallet, subAccountIds, activeSubAccountId, includeDelegates, authoritySubaccountMap) {
295
- const newProvider = new anchor_1.AnchorProvider(this.connection, newWallet, this.opts);
297
+ const newProvider = new anchor_1.AnchorProvider(this.connection,
298
+ // @ts-ignore
299
+ newWallet, this.opts);
296
300
  const newProgram = new anchor_1.Program(drift_json_1.default, this.program.programId, newProvider);
297
301
  this.skipLoadUsers = false;
298
302
  // Update provider for txSender with new wallet details
@@ -1374,6 +1378,7 @@ class DriftClient {
1374
1378
  ]);
1375
1379
  const { txSig, slot } = await this.txSender.sendRawTransaction(signedVersionedMarketOrderTx.serialize(), this.opts);
1376
1380
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
1381
+ // @ts-ignore
1377
1382
  return { txSig, signedFillTx: signedVersionedFillTx };
1378
1383
  }
1379
1384
  else {
@@ -16,7 +16,9 @@ const main = async () => {
16
16
  const rpcAddress = process.env.RPC_ADDRESS; // can use: https://api.devnet.solana.com for devnet; https://api.mainnet-beta.solana.com for mainnet;
17
17
  const connection = new web3_js_1.Connection(rpcAddress);
18
18
  // Set up the Provider
19
- const provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
19
+ const provider = new anchor_1.AnchorProvider(connection,
20
+ // @ts-ignore
21
+ wallet, anchor_1.AnchorProvider.defaultOptions());
20
22
  // Set up the Drift Clearing House
21
23
  const driftPublicKey = new web3_js_1.PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
22
24
  const bulkAccountLoader = new __2.BulkAccountLoader(connection, 'confirmed', 1000);
@@ -23,7 +23,9 @@ const main = async () => {
23
23
  const rpcAddress = process.env.RPC_ADDRESS; // can use: https://api.devnet.solana.com for devnet; https://api.mainnet-beta.solana.com for mainnet;
24
24
  const connection = new web3_js_1.Connection(rpcAddress);
25
25
  // Set up the Provider
26
- const provider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
26
+ const provider = new anchor_1.AnchorProvider(connection,
27
+ // @ts-ignore
28
+ wallet, anchor_1.AnchorProvider.defaultOptions());
27
29
  // Check SOL Balance
28
30
  const lamportsBalance = await connection.getBalance(wallet.publicKey);
29
31
  console.log('SOL balance:', lamportsBalance / 10 ** 9);
@@ -76,7 +76,7 @@ class OrderSubscriber {
76
76
  tryUpdateUserAccount(key, buffer, slot) {
77
77
  const slotAndUserAccount = this.usersAccounts.get(key);
78
78
  if (!slotAndUserAccount || slotAndUserAccount.slot < slot) {
79
- const userAccount = this.driftClient.program.account.user.coder.accounts.decodeUnchecked('User', buffer);
79
+ const userAccount = this.driftClient.program.account.user.coder.accounts.decode('User', buffer);
80
80
  const newOrders = userAccount.orders.filter((order) => {
81
81
  var _a;
82
82
  return order.slot.toNumber() > ((_a = slotAndUserAccount === null || slotAndUserAccount === void 0 ? void 0 : slotAndUserAccount.slot) !== null && _a !== void 0 ? _a : 0) &&
@@ -37,6 +37,7 @@ class TokenFaucet {
37
37
  this.connection = connection;
38
38
  this.wallet = wallet;
39
39
  this.opts = opts || anchor_1.AnchorProvider.defaultOptions();
40
+ // @ts-ignore
40
41
  const provider = new anchor_1.AnchorProvider(connection, wallet, this.opts);
41
42
  this.provider = provider;
42
43
  this.program = new anchor_1.Program(token_faucet_json_1.default, programId, provider);
@@ -165,7 +165,7 @@ class UserMap {
165
165
  }
166
166
  for (const [key, buffer] of programAccountBufferMap.entries()) {
167
167
  if (!this.has(key)) {
168
- const userAccount = this.driftClient.program.account.user.coder.accounts.decodeUnchecked('User', buffer);
168
+ const userAccount = this.driftClient.program.account.user.coder.accounts.decode('User', buffer);
169
169
  await this.addPubkey(new web3_js_1.PublicKey(key), userAccount);
170
170
  }
171
171
  }
@@ -175,7 +175,7 @@ class UserMap {
175
175
  this.userMap.delete(key);
176
176
  }
177
177
  else {
178
- const userAccount = this.driftClient.program.account.user.coder.accounts.decodeUnchecked('User', programAccountBufferMap.get(key));
178
+ const userAccount = this.driftClient.program.account.user.coder.accounts.decode('User', programAccountBufferMap.get(key));
179
179
  user.accountSubscriber.updateData(userAccount, slot);
180
180
  }
181
181
  }
@@ -141,7 +141,7 @@ class UserStatsMap {
141
141
  }
142
142
  for (const key of programAccountMap.keys()) {
143
143
  if (!this.has(key)) {
144
- const userStatsAccount = this.driftClient.program.account.userStats.coder.accounts.decodeUnchecked('UserStats', programAccountMap.get(key).data);
144
+ const userStatsAccount = this.driftClient.program.account.userStats.coder.accounts.decode('UserStats', programAccountMap.get(key).data);
145
145
  await this.addUserStat(new web3_js_1.PublicKey(key), userStatsAccount);
146
146
  }
147
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.38.1-beta.3",
3
+ "version": "2.38.1-beta.4",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@coral-xyz/anchor": "0.26.0",
37
+ "@coral-xyz/anchor": "0.28.1-beta.2",
38
38
  "@ellipsis-labs/phoenix-sdk": "^1.4.2",
39
39
  "@project-serum/serum": "^0.13.38",
40
40
  "@pythnetwork/client": "2.5.3",
@@ -71,11 +71,10 @@ export class PollingUserAccountSubscriber implements UserAccountSubscriber {
71
71
  return;
72
72
  }
73
73
 
74
- const account =
75
- this.program.account.user.coder.accounts.decodeUnchecked(
76
- 'User',
77
- buffer
78
- );
74
+ const account = this.program.account.user.coder.accounts.decode(
75
+ 'User',
76
+ buffer
77
+ );
79
78
  this.user = { data: account, slot };
80
79
  this.eventEmitter.emit('userAccountUpdate', account);
81
80
  this.eventEmitter.emit('update');
@@ -100,7 +99,7 @@ export class PollingUserAccountSubscriber implements UserAccountSubscriber {
100
99
  );
101
100
  const currentSlot = this.user?.slot ?? 0;
102
101
  if (buffer && slot > currentSlot) {
103
- const account = this.program.account.user.coder.accounts.decodeUnchecked(
102
+ const account = this.program.account.user.coder.accounts.decode(
104
103
  'User',
105
104
  buffer
106
105
  );
@@ -112,9 +112,10 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
112
112
  if (this.decodeBufferFn) {
113
113
  return this.decodeBufferFn(buffer);
114
114
  } else {
115
- return this.program.account[
116
- this.accountName
117
- ].coder.accounts.decodeUnchecked(capitalize(this.accountName), buffer);
115
+ return this.program.account[this.accountName].coder.accounts.decode(
116
+ capitalize(this.accountName),
117
+ buffer
118
+ );
118
119
  }
119
120
  }
120
121
 
@@ -174,6 +174,7 @@ export class DriftClient {
174
174
  this.opts = config.opts || AnchorProvider.defaultOptions();
175
175
  this.provider = new AnchorProvider(
176
176
  config.connection,
177
+ // @ts-ignore
177
178
  config.wallet,
178
179
  this.opts
179
180
  );
@@ -512,6 +513,7 @@ export class DriftClient {
512
513
  ): Promise<boolean> {
513
514
  const newProvider = new AnchorProvider(
514
515
  this.connection,
516
+ // @ts-ignore
515
517
  newWallet,
516
518
  this.opts
517
519
  );
@@ -2473,6 +2475,7 @@ export class DriftClient {
2473
2475
  );
2474
2476
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
2475
2477
 
2478
+ // @ts-ignore
2476
2479
  return { txSig, signedFillTx: signedVersionedFillTx };
2477
2480
  } else {
2478
2481
  const marketOrderTx = wrapInTx(
@@ -28,6 +28,7 @@ const main = async () => {
28
28
  // Set up the Provider
29
29
  const provider = new AnchorProvider(
30
30
  connection,
31
+ // @ts-ignore
31
32
  wallet,
32
33
  AnchorProvider.defaultOptions()
33
34
  );
@@ -51,6 +51,7 @@ const main = async () => {
51
51
  // Set up the Provider
52
52
  const provider = new AnchorProvider(
53
53
  connection,
54
+ // @ts-ignore
54
55
  wallet,
55
56
  AnchorProvider.defaultOptions()
56
57
  );
@@ -106,7 +106,7 @@ export class OrderSubscriber {
106
106
  const slotAndUserAccount = this.usersAccounts.get(key);
107
107
  if (!slotAndUserAccount || slotAndUserAccount.slot < slot) {
108
108
  const userAccount =
109
- this.driftClient.program.account.user.coder.accounts.decodeUnchecked(
109
+ this.driftClient.program.account.user.coder.accounts.decode(
110
110
  'User',
111
111
  buffer
112
112
  ) as UserAccount;
@@ -38,6 +38,7 @@ export class TokenFaucet {
38
38
  this.connection = connection;
39
39
  this.wallet = wallet;
40
40
  this.opts = opts || AnchorProvider.defaultOptions();
41
+ // @ts-ignore
41
42
  const provider = new AnchorProvider(connection, wallet, this.opts);
42
43
  this.provider = provider;
43
44
  this.program = new Program(tokenFaucet as Idl, programId, provider);
@@ -235,7 +235,7 @@ export class UserMap implements UserMapInterface {
235
235
  for (const [key, buffer] of programAccountBufferMap.entries()) {
236
236
  if (!this.has(key)) {
237
237
  const userAccount =
238
- this.driftClient.program.account.user.coder.accounts.decodeUnchecked(
238
+ this.driftClient.program.account.user.coder.accounts.decode(
239
239
  'User',
240
240
  buffer
241
241
  );
@@ -249,7 +249,7 @@ export class UserMap implements UserMapInterface {
249
249
  this.userMap.delete(key);
250
250
  } else {
251
251
  const userAccount =
252
- this.driftClient.program.account.user.coder.accounts.decodeUnchecked(
252
+ this.driftClient.program.account.user.coder.accounts.decode(
253
253
  'User',
254
254
  programAccountBufferMap.get(key)
255
255
  );
@@ -197,7 +197,7 @@ export class UserStatsMap {
197
197
  for (const key of programAccountMap.keys()) {
198
198
  if (!this.has(key)) {
199
199
  const userStatsAccount =
200
- this.driftClient.program.account.userStats.coder.accounts.decodeUnchecked(
200
+ this.driftClient.program.account.userStats.coder.accounts.decode(
201
201
  'UserStats',
202
202
  programAccountMap.get(key).data
203
203
  );