flash-sdk 2.46.5 → 2.46.6

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.
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -36,7 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getCpiEventsFromTransaction = exports.getAndValidateEvent = void 0;
39
+ exports.getCpiEventsFromTransaction = void 0;
40
+ exports.getAndValidateEvent = getAndValidateEvent;
40
41
  var anchor_1 = require("@coral-xyz/anchor");
41
42
  var perpetuals_1 = require("../idl/perpetuals");
42
43
  var bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
@@ -55,7 +56,6 @@ function getAndValidateEvent(previousProgram, currentProgram, eventAuthority, ev
55
56
  }
56
57
  return event;
57
58
  }
58
- exports.getAndValidateEvent = getAndValidateEvent;
59
59
  var getCpiEventsFromTransaction = function (response) { return __awaiter(void 0, void 0, void 0, function () {
60
60
  var instructions, innerInstructions, accounts, eventCoder, events, _loop_1, _i, innerInstructions_1, packet;
61
61
  var _a, _b;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -39,7 +39,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.checkedDecimalDiv = exports.checkedDecimalMul = exports.checkedDecimalCeilMul = exports.checkedCeilDiv = exports.scaleToExponent = exports.checkIfAccountExists = exports.nativeToUiDecimals = exports.validateNumberString = exports.uiDecimalsToNative = exports.toUiDecimalsOldSDK = exports.getUnixTs = void 0;
42
+ exports.checkedDecimalDiv = exports.checkedDecimalMul = exports.checkedDecimalCeilMul = exports.checkedCeilDiv = exports.scaleToExponent = exports.validateNumberString = exports.uiDecimalsToNative = exports.getUnixTs = void 0;
43
+ exports.toUiDecimalsOldSDK = toUiDecimalsOldSDK;
44
+ exports.nativeToUiDecimals = nativeToUiDecimals;
45
+ exports.checkIfAccountExists = checkIfAccountExists;
43
46
  var bn_js_1 = __importDefault(require("bn.js"));
44
47
  var constants_1 = require("../constants");
45
48
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
@@ -89,7 +92,6 @@ function toUiDecimalsOldSDK(nativeAmount, decimals, precision, commaSeperated) {
89
92
  return r;
90
93
  }
91
94
  }
92
- exports.toUiDecimalsOldSDK = toUiDecimalsOldSDK;
93
95
  var uiDecimalsToNative = function (amountUi, decimals) {
94
96
  var valueBigNumber = (new bignumber_js_1.default(amountUi)).multipliedBy(new bignumber_js_1.default(Math.pow(10, decimals)));
95
97
  return new bn_js_1.default(valueBigNumber.toFixed(0, bignumber_js_1.default.ROUND_DOWN));
@@ -137,7 +139,6 @@ function nativeToUiDecimals(nativeAmount, decimals, precision, commaSeperated) {
137
139
  return r;
138
140
  }
139
141
  }
140
- exports.nativeToUiDecimals = nativeToUiDecimals;
141
142
  function checkIfAccountExists(account, connection) {
142
143
  return __awaiter(this, void 0, void 0, function () {
143
144
  var bal;
@@ -157,7 +158,6 @@ function checkIfAccountExists(account, connection) {
157
158
  });
158
159
  });
159
160
  }
160
- exports.checkIfAccountExists = checkIfAccountExists;
161
161
  var scaleToExponent = function (arg, exponent, target_exponent) {
162
162
  if (target_exponent.eq(exponent)) {
163
163
  return arg;
package/dist/utils/rpc.js CHANGED
@@ -24,8 +24,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
24
24
  });
25
25
  };
26
26
  var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
28
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
29
  function verb(n) { return function (v) { return step([n, v]); }; }
30
30
  function step(op) {
31
31
  if (f) throw new TypeError("Generator is already executing.");
@@ -63,28 +63,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
63
63
  return (mod && mod.__esModule) ? mod : { "default": mod };
64
64
  };
65
65
  Object.defineProperty(exports, "__esModule", { value: true });
66
- exports.TransactionFailError = exports.createComputeBudgetIx = exports.confirmTransactionV3 = exports.sendTransactionV3 = exports.confirmTransactionV2 = exports.sendTransactionV2 = exports.confirmTransaction = exports.sendTransaction = void 0;
66
+ exports.TransactionFailError = exports.createComputeBudgetIx = void 0;
67
+ exports.sendTransaction = sendTransaction;
68
+ exports.confirmTransaction = confirmTransaction;
69
+ exports.sendTransactionV2 = sendTransactionV2;
70
+ exports.confirmTransactionV2 = confirmTransactionV2;
71
+ exports.sendTransactionV3 = sendTransactionV3;
72
+ exports.confirmTransactionV3 = confirmTransactionV3;
67
73
  var nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewallet"));
68
74
  var bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
69
75
  var web3_js_1 = require("@solana/web3.js");
70
- function sendTransaction(provider, ixs, opts) {
71
- var _a, _b, _c, _d;
72
- if (opts === void 0) { opts = {}; }
73
- return __awaiter(this, void 0, void 0, function () {
74
- var connection, latestBlockhash, _e, payer, message, vtx, signature;
76
+ function sendTransaction(provider_1, ixs_1) {
77
+ return __awaiter(this, arguments, void 0, function (provider, ixs, opts) {
78
+ var connection, latestBlockhash, _a, payer, message, vtx, signature;
79
+ var _b, _c, _d, _e;
80
+ if (opts === void 0) { opts = {}; }
75
81
  return __generator(this, function (_f) {
76
82
  switch (_f.label) {
77
83
  case 0:
78
84
  connection = provider.connection;
79
- if (!((_a = opts.latestBlockhash) !== null && _a !== void 0)) return [3, 1];
80
- _e = _a;
85
+ if (!((_b = opts.latestBlockhash) !== null && _b !== void 0)) return [3, 1];
86
+ _a = _b;
81
87
  return [3, 3];
82
- case 1: return [4, connection.getLatestBlockhash((_c = (_b = opts.preflightCommitment) !== null && _b !== void 0 ? _b : provider.opts.preflightCommitment) !== null && _c !== void 0 ? _c : 'finalized')];
88
+ case 1: return [4, connection.getLatestBlockhash((_d = (_c = opts.preflightCommitment) !== null && _c !== void 0 ? _c : provider.opts.preflightCommitment) !== null && _d !== void 0 ? _d : 'finalized')];
83
89
  case 2:
84
- _e = (_f.sent());
90
+ _a = (_f.sent());
85
91
  _f.label = 3;
86
92
  case 3:
87
- latestBlockhash = _e;
93
+ latestBlockhash = _a;
88
94
  payer = provider.wallet;
89
95
  if (opts.prioritizationFee) {
90
96
  ixs = __spreadArray(__spreadArray([], ixs, true), [(0, exports.createComputeBudgetIx)(opts.prioritizationFee)], false);
@@ -96,7 +102,7 @@ function sendTransaction(provider, ixs, opts) {
96
102
  addressLookupTableAccounts: opts.alts,
97
103
  });
98
104
  vtx = new web3_js_1.VersionedTransaction(message);
99
- if ((_d = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _d === void 0 ? void 0 : _d.length) {
105
+ if ((_e = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _e === void 0 ? void 0 : _e.length) {
100
106
  vtx.sign(__spreadArray([], opts === null || opts === void 0 ? void 0 : opts.additionalSigners, true));
101
107
  }
102
108
  if (!(typeof payer.signTransaction === 'function' &&
@@ -118,26 +124,25 @@ function sendTransaction(provider, ixs, opts) {
118
124
  });
119
125
  });
120
126
  }
121
- exports.sendTransaction = sendTransaction;
122
- function confirmTransaction(provider, signature, opts) {
123
- var _a, _b, _c, _d;
124
- if (opts === void 0) { opts = {}; }
125
- return __awaiter(this, void 0, void 0, function () {
126
- var connection, latestBlockhash, _e, txConfirmationCommitment, status;
127
+ function confirmTransaction(provider_1, signature_1) {
128
+ return __awaiter(this, arguments, void 0, function (provider, signature, opts) {
129
+ var connection, latestBlockhash, _a, txConfirmationCommitment, status;
130
+ var _b, _c, _d, _e;
131
+ if (opts === void 0) { opts = {}; }
127
132
  return __generator(this, function (_f) {
128
133
  switch (_f.label) {
129
134
  case 0:
130
135
  connection = provider.connection;
131
- if (!((_a = opts.latestBlockhash) !== null && _a !== void 0)) return [3, 1];
132
- _e = _a;
136
+ if (!((_b = opts.latestBlockhash) !== null && _b !== void 0)) return [3, 1];
137
+ _a = _b;
133
138
  return [3, 3];
134
- case 1: return [4, connection.getLatestBlockhash((_c = (_b = opts.preflightCommitment) !== null && _b !== void 0 ? _b : provider.opts.preflightCommitment) !== null && _c !== void 0 ? _c : 'finalized')];
139
+ case 1: return [4, connection.getLatestBlockhash((_d = (_c = opts.preflightCommitment) !== null && _c !== void 0 ? _c : provider.opts.preflightCommitment) !== null && _d !== void 0 ? _d : 'finalized')];
135
140
  case 2:
136
- _e = (_f.sent());
141
+ _a = (_f.sent());
137
142
  _f.label = 3;
138
143
  case 3:
139
- latestBlockhash = _e;
140
- txConfirmationCommitment = (_d = opts.txConfirmationCommitment) !== null && _d !== void 0 ? _d : 'processed';
144
+ latestBlockhash = _a;
145
+ txConfirmationCommitment = (_e = opts.txConfirmationCommitment) !== null && _e !== void 0 ? _e : 'processed';
141
146
  if (!(latestBlockhash.blockhash != null &&
142
147
  latestBlockhash.lastValidBlockHeight != null)) return [3, 5];
143
148
  return [4, connection.confirmTransaction({
@@ -165,25 +170,24 @@ function confirmTransaction(provider, signature, opts) {
165
170
  });
166
171
  });
167
172
  }
168
- exports.confirmTransaction = confirmTransaction;
169
- function sendTransactionV2(provider, ixs, opts) {
170
- var _a, _b, _c, _d;
171
- if (opts === void 0) { opts = {}; }
172
- return __awaiter(this, void 0, void 0, function () {
173
- var connection, latestBlockhash, _e, payer, message, vtx, signature;
173
+ function sendTransactionV2(provider_1, ixs_1) {
174
+ return __awaiter(this, arguments, void 0, function (provider, ixs, opts) {
175
+ var connection, latestBlockhash, _a, payer, message, vtx, signature;
176
+ var _b, _c, _d, _e;
177
+ if (opts === void 0) { opts = {}; }
174
178
  return __generator(this, function (_f) {
175
179
  switch (_f.label) {
176
180
  case 0:
177
181
  connection = provider.connection;
178
- if (!((_a = opts.latestBlockhash) !== null && _a !== void 0)) return [3, 1];
179
- _e = _a;
182
+ if (!((_b = opts.latestBlockhash) !== null && _b !== void 0)) return [3, 1];
183
+ _a = _b;
180
184
  return [3, 3];
181
- case 1: return [4, connection.getLatestBlockhash((_c = (_b = opts.preflightCommitment) !== null && _b !== void 0 ? _b : provider.opts.preflightCommitment) !== null && _c !== void 0 ? _c : 'finalized')];
185
+ case 1: return [4, connection.getLatestBlockhash((_d = (_c = opts.preflightCommitment) !== null && _c !== void 0 ? _c : provider.opts.preflightCommitment) !== null && _d !== void 0 ? _d : 'finalized')];
182
186
  case 2:
183
- _e = (_f.sent());
187
+ _a = (_f.sent());
184
188
  _f.label = 3;
185
189
  case 3:
186
- latestBlockhash = _e;
190
+ latestBlockhash = _a;
187
191
  payer = provider.wallet;
188
192
  if (opts.prioritizationFee) {
189
193
  ixs = __spreadArray(__spreadArray([], ixs, true), [(0, exports.createComputeBudgetIx)(opts.prioritizationFee)], false);
@@ -195,7 +199,7 @@ function sendTransactionV2(provider, ixs, opts) {
195
199
  addressLookupTableAccounts: opts.alts,
196
200
  });
197
201
  vtx = new web3_js_1.VersionedTransaction(message);
198
- if ((_d = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _d === void 0 ? void 0 : _d.length) {
202
+ if ((_e = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _e === void 0 ? void 0 : _e.length) {
199
203
  vtx.sign(__spreadArray([], opts === null || opts === void 0 ? void 0 : opts.additionalSigners, true));
200
204
  }
201
205
  if (!(typeof payer.signTransaction === 'function' &&
@@ -217,12 +221,11 @@ function sendTransactionV2(provider, ixs, opts) {
217
221
  });
218
222
  });
219
223
  }
220
- exports.sendTransactionV2 = sendTransactionV2;
221
224
  var sleep = function (ms) { return new Promise(function (r) { return setTimeout(r, ms); }); };
222
- function confirmTransactionV2(provider, versionedTransaction, signature, opts) {
223
- if (opts === void 0) { opts = {}; }
224
- return __awaiter(this, void 0, void 0, function () {
225
+ function confirmTransactionV2(provider_1, versionedTransaction_1, signature_1) {
226
+ return __awaiter(this, arguments, void 0, function (provider, versionedTransaction, signature, opts) {
225
227
  var connection, status, done, blockhashResponse, lastValidBlockHeight, blockheight, signatureStatuses, result, x;
228
+ if (opts === void 0) { opts = {}; }
226
229
  return __generator(this, function (_a) {
227
230
  switch (_a.label) {
228
231
  case 0:
@@ -279,25 +282,24 @@ function confirmTransactionV2(provider, versionedTransaction, signature, opts) {
279
282
  });
280
283
  });
281
284
  }
282
- exports.confirmTransactionV2 = confirmTransactionV2;
283
- function sendTransactionV3(provider, ixs, opts) {
284
- var _a, _b, _c, _d;
285
- if (opts === void 0) { opts = {}; }
286
- return __awaiter(this, void 0, void 0, function () {
287
- var connection, latestBlockhash, _e, payer, message, vtx, tx, signature;
285
+ function sendTransactionV3(provider_1, ixs_1) {
286
+ return __awaiter(this, arguments, void 0, function (provider, ixs, opts) {
287
+ var connection, latestBlockhash, _a, payer, message, vtx, tx, signature;
288
+ var _b, _c, _d, _e;
289
+ if (opts === void 0) { opts = {}; }
288
290
  return __generator(this, function (_f) {
289
291
  switch (_f.label) {
290
292
  case 0:
291
293
  connection = provider.connection;
292
- if (!((_a = opts.latestBlockhash) !== null && _a !== void 0)) return [3, 1];
293
- _e = _a;
294
+ if (!((_b = opts.latestBlockhash) !== null && _b !== void 0)) return [3, 1];
295
+ _a = _b;
294
296
  return [3, 3];
295
- case 1: return [4, connection.getLatestBlockhash((_c = (_b = opts.preflightCommitment) !== null && _b !== void 0 ? _b : provider.opts.preflightCommitment) !== null && _c !== void 0 ? _c : 'finalized')];
297
+ case 1: return [4, connection.getLatestBlockhash((_d = (_c = opts.preflightCommitment) !== null && _c !== void 0 ? _c : provider.opts.preflightCommitment) !== null && _d !== void 0 ? _d : 'finalized')];
296
298
  case 2:
297
- _e = (_f.sent());
299
+ _a = (_f.sent());
298
300
  _f.label = 3;
299
301
  case 3:
300
- latestBlockhash = _e;
302
+ latestBlockhash = _a;
301
303
  payer = provider.wallet;
302
304
  message = web3_js_1.MessageV0.compile({
303
305
  payerKey: provider.wallet.publicKey,
@@ -306,7 +308,7 @@ function sendTransactionV3(provider, ixs, opts) {
306
308
  addressLookupTableAccounts: opts.alts,
307
309
  });
308
310
  vtx = new web3_js_1.VersionedTransaction(message);
309
- if ((_d = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _d === void 0 ? void 0 : _d.length) {
311
+ if ((_e = opts === null || opts === void 0 ? void 0 : opts.additionalSigners) === null || _e === void 0 ? void 0 : _e.length) {
310
312
  vtx.sign(__spreadArray([], opts === null || opts === void 0 ? void 0 : opts.additionalSigners, true));
311
313
  }
312
314
  if (!(typeof payer.signTransaction === 'function' &&
@@ -332,11 +334,10 @@ function sendTransactionV3(provider, ixs, opts) {
332
334
  });
333
335
  });
334
336
  }
335
- exports.sendTransactionV3 = sendTransactionV3;
336
- function confirmTransactionV3(provider, versionedTransaction, signature, opts) {
337
- if (opts === void 0) { opts = {}; }
338
- return __awaiter(this, void 0, void 0, function () {
337
+ function confirmTransactionV3(provider_1, versionedTransaction_1, signature_1) {
338
+ return __awaiter(this, arguments, void 0, function (provider, versionedTransaction, signature, opts) {
339
339
  var connection, status, blockhashResponse, lastValidBlockHeight, blockheight, signatureStatuses, result, x;
340
+ if (opts === void 0) { opts = {}; }
340
341
  return __generator(this, function (_a) {
341
342
  switch (_a.label) {
342
343
  case 0:
@@ -399,7 +400,6 @@ function confirmTransactionV3(provider, versionedTransaction, signature, opts) {
399
400
  });
400
401
  });
401
402
  }
402
- exports.confirmTransactionV3 = confirmTransactionV3;
403
403
  var createComputeBudgetIx = function (microLamports) {
404
404
  var computeBudgetIx = web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
405
405
  microLamports: microLamports,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flash-sdk",
3
- "version": "2.46.5",
3
+ "version": "2.46.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -21,11 +21,11 @@
21
21
  "doc": "yarn typedoc --out docs src"
22
22
  },
23
23
  "dependencies": {
24
- "@coral-xyz/anchor": "^0.27.0",
24
+ "@coral-xyz/anchor": "=0.27.0",
25
25
  "@pythnetwork/client": "^2.19.0",
26
26
  "@pythnetwork/price-service-client": "^1.8.2",
27
- "@solana/spl-token": "^0.3.6",
28
- "@solana/web3.js": "=1.95.8",
27
+ "@solana/spl-token": "^0.4.13",
28
+ "@solana/web3.js": "=1.98.2",
29
29
  "@types/node": "^20.0.0",
30
30
  "bignumber.js": "^9.1.2",
31
31
  "bs58": "^5.0.0",
@@ -38,11 +38,14 @@
38
38
  "ts-node": "^10.9.1",
39
39
  "tweetnacl": "^1.0.3"
40
40
  },
41
+ "resolutions": {
42
+ "@solana/web3.js": "1.98.2"
43
+ },
41
44
  "devDependencies": {
42
45
  "@types/bn.js": "^5.1.1",
43
46
  "prettier": "^2.8.1",
44
47
  "ts-node": "^10.9.1",
45
48
  "typedoc": "^0.25.13",
46
- "typescript": "^4.9.4"
49
+ "typescript": "^5.3.3"
47
50
  }
48
51
  }