@openocean.finance/openocean-sdk 1.7.7 → 1.7.9

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.
@@ -193,7 +193,7 @@ var Swap = /** @class */ (function () {
193
193
  };
194
194
  Swap.prototype.sendSolanaTransaction = function () {
195
195
  return __awaiter(this, void 0, void 0, function () {
196
- var res, transaction, signed, result, bytes, _a, msg, data, bytes, serializedTransaction, blockhashWithExpiryBlockHeight, blockhashInfo, lastValidBlockHeight, transactionResponse, e_1;
196
+ var res, transaction, signed, result, bytes, _a, msg, data, bytes, serializedTransaction, transactionResponse, e_1;
197
197
  var _b, _c;
198
198
  return __generator(this, function (_d) {
199
199
  switch (_d.label) {
@@ -201,7 +201,7 @@ var Swap = /** @class */ (function () {
201
201
  res = this.res;
202
202
  _d.label = 1;
203
203
  case 1:
204
- _d.trys.push([1, 13, , 14]);
204
+ _d.trys.push([1, 9, , 10]);
205
205
  transaction = '';
206
206
  if (res.dexId == 6 || res.dexId == 7) {
207
207
  transaction = web3_js_1.VersionedTransaction.deserialize(Buffer.from(res.transaction, 'hex'));
@@ -244,30 +244,12 @@ var Swap = /** @class */ (function () {
244
244
  verifySignatures: false,
245
245
  requireAllSignatures: false
246
246
  });
247
- blockhashWithExpiryBlockHeight = void 0;
248
- if (!res.lastValidBlockHeight) return [3 /*break*/, 8];
249
- blockhashWithExpiryBlockHeight = {
250
- blockhash: transaction.message.recentBlockhash,
251
- lastValidBlockHeight: res.lastValidBlockHeight,
252
- };
253
- return [3 /*break*/, 11];
254
- case 8: return [4 /*yield*/, this.wallet.connection.getRecentBlockhash()];
255
- case 9:
256
- blockhashInfo = _d.sent();
257
- return [4 /*yield*/, this.wallet.connection.getBlockHeight()];
258
- case 10:
259
- lastValidBlockHeight = _d.sent();
260
- blockhashWithExpiryBlockHeight = {
261
- blockhash: transaction._message ? transaction._message.recentBlockhash : blockhashInfo.blockhash,
262
- lastValidBlockHeight: lastValidBlockHeight + 400,
263
- };
264
- _d.label = 11;
265
- case 11: return [4 /*yield*/, (0, solanaTransactionSender_1.transactionSenderAndConfirmationWaiter)({
266
- connection: this.wallet.connection,
267
- serializedTransaction: serializedTransaction,
268
- blockhashWithExpiryBlockHeight: blockhashWithExpiryBlockHeight
269
- })];
270
- case 12:
247
+ return [4 /*yield*/, (0, solanaTransactionSender_1.transactionSenderAndConfirmationWaiter)({
248
+ connection: this.wallet.connection,
249
+ serializedTransaction: serializedTransaction,
250
+ // blockhashWithExpiryBlockHeight
251
+ })];
252
+ case 8:
271
253
  transactionResponse = _d.sent();
272
254
  if (transactionResponse && transactionResponse.response) {
273
255
  if ((_b = transactionResponse.response.meta) === null || _b === void 0 ? void 0 : _b.err) {
@@ -280,12 +262,12 @@ var Swap = /** @class */ (function () {
280
262
  else {
281
263
  this.errorCallback('Transaction not confirmed.');
282
264
  }
283
- return [3 /*break*/, 14];
284
- case 13:
265
+ return [3 /*break*/, 10];
266
+ case 9:
285
267
  e_1 = _d.sent();
286
268
  this.errorCallback(e_1.message);
287
- return [3 /*break*/, 14];
288
- case 14: return [2 /*return*/];
269
+ return [3 /*break*/, 10];
270
+ case 10: return [2 /*return*/];
289
271
  }
290
272
  });
291
273
  });
@@ -4,5 +4,5 @@ type TransactionSenderAndConfirmationWaiterArgs = {
4
4
  serializedTransaction: Buffer;
5
5
  blockhashWithExpiryBlockHeight?: BlockhashWithExpiryBlockHeight | any;
6
6
  };
7
- export declare function transactionSenderAndConfirmationWaiter({ connection, serializedTransaction, blockhashWithExpiryBlockHeight, }: TransactionSenderAndConfirmationWaiterArgs): Promise<any>;
7
+ export declare function transactionSenderAndConfirmationWaiter({ connection, serializedTransaction, }: TransactionSenderAndConfirmationWaiterArgs): Promise<any>;
8
8
  export {};
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -53,19 +42,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
42
  exports.transactionSenderAndConfirmationWaiter = transactionSenderAndConfirmationWaiter;
54
43
  var web3_js_1 = require("@solana/web3.js");
55
44
  var promise_retry_1 = __importDefault(require("promise-retry"));
56
- var wait = function (time) {
45
+ var sleep = function (time) {
57
46
  return new Promise(function (resolve) { return setTimeout(resolve, time); });
58
47
  };
59
48
  function transactionSenderAndConfirmationWaiter(_a) {
60
49
  return __awaiter(this, arguments, void 0, function (_b) {
61
- var txid, controller, abortSignal, abortableResender, races, lastValidBlockHeight, e_1, response;
50
+ var txid, controller, abortSignal, abortableResender, times_1, races, e_1, response;
62
51
  var _this = this;
63
- var connection = _b.connection, serializedTransaction = _b.serializedTransaction, blockhashWithExpiryBlockHeight = _b.blockhashWithExpiryBlockHeight;
52
+ var connection = _b.connection, serializedTransaction = _b.serializedTransaction;
64
53
  return __generator(this, function (_c) {
65
54
  switch (_c.label) {
66
55
  case 0: return [4 /*yield*/, connection.sendRawTransaction(serializedTransaction, {
67
56
  skipPreflight: true,
68
- // preflightCommitment: "confirmed",
69
57
  })];
70
58
  case 1:
71
59
  txid = _c.sent();
@@ -78,7 +66,7 @@ function transactionSenderAndConfirmationWaiter(_a) {
78
66
  switch (_a.label) {
79
67
  case 0:
80
68
  if (!true) return [3 /*break*/, 6];
81
- return [4 /*yield*/, wait(5000)];
69
+ return [4 /*yield*/, sleep(6000)];
82
70
  case 1:
83
71
  _a.sent();
84
72
  if (abortSignal.aborted)
@@ -88,7 +76,6 @@ function transactionSenderAndConfirmationWaiter(_a) {
88
76
  _a.trys.push([2, 4, , 5]);
89
77
  return [4 /*yield*/, connection.sendRawTransaction(serializedTransaction, {
90
78
  skipPreflight: true,
91
- // preflightCommitment: "confirmed",
92
79
  })];
93
80
  case 3:
94
81
  id = _a.sent();
@@ -108,6 +95,7 @@ function transactionSenderAndConfirmationWaiter(_a) {
108
95
  case 2:
109
96
  _c.trys.push([2, 4, 5, 6]);
110
97
  abortableResender();
98
+ times_1 = 0;
111
99
  races = [
112
100
  new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
113
101
  var tx;
@@ -116,7 +104,10 @@ function transactionSenderAndConfirmationWaiter(_a) {
116
104
  switch (_b.label) {
117
105
  case 0:
118
106
  if (!!abortSignal.aborted) return [3 /*break*/, 3];
119
- return [4 /*yield*/, wait(4000)];
107
+ times_1++;
108
+ if (times_1 > 8)
109
+ resolve('');
110
+ return [4 /*yield*/, sleep(3000)];
120
111
  case 1:
121
112
  _b.sent();
122
113
  return [4 /*yield*/, connection.getSignatureStatus(txid, {
@@ -133,24 +124,16 @@ function transactionSenderAndConfirmationWaiter(_a) {
133
124
  });
134
125
  }); }),
135
126
  ];
136
- if (blockhashWithExpiryBlockHeight && blockhashWithExpiryBlockHeight.lastValidBlockHeight) {
137
- lastValidBlockHeight = blockhashWithExpiryBlockHeight.lastValidBlockHeight - 150;
138
- races.push(connection.confirmTransaction(__assign(__assign({}, blockhashWithExpiryBlockHeight), { lastValidBlockHeight: lastValidBlockHeight, signature: txid, abortSignal: abortSignal }), "confirmed"));
139
- }
140
- // this would throw TransactionExpiredBlockheightExceededError
141
127
  return [4 /*yield*/, Promise.race(races)];
142
128
  case 3:
143
- // this would throw TransactionExpiredBlockheightExceededError
144
129
  _c.sent();
145
130
  return [3 /*break*/, 6];
146
131
  case 4:
147
132
  e_1 = _c.sent();
148
133
  if (e_1 instanceof web3_js_1.TransactionExpiredBlockheightExceededError) {
149
- // we consume this error and getTransaction would return null
150
134
  return [2 /*return*/, null];
151
135
  }
152
136
  else {
153
- // invalid state from web3.js
154
137
  throw e_1;
155
138
  }
156
139
  return [3 /*break*/, 6];
@@ -175,8 +158,8 @@ function transactionSenderAndConfirmationWaiter(_a) {
175
158
  }
176
159
  });
177
160
  }); }, {
178
- retries: 5,
179
- minTimeout: 1e3,
161
+ retries: 2,
162
+ minTimeout: 3000,
180
163
  });
181
164
  return [2 /*return*/, { response: response, txid: txid }];
182
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/openocean-sdk",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Openocean sdk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@ethersproject/bignumber": "^5.1.1",
29
29
  "@looksrare/sdk": "^0.12.1",
30
- "@openocean.finance/wallet": "^1.10.6",
30
+ "@openocean.finance/wallet": "^1.10.8",
31
31
  "@terra-money/terra.js": "^3.1.10",
32
32
  "@uniswap/v2-core": "^1.0.1",
33
33
  "@walletconnect/ethereum-provider": "2.17.1",
@@ -45,7 +45,6 @@
45
45
  "jsbi": "^4.3.0",
46
46
  "json-loader": "^0.5.7",
47
47
  "near-api-js": "^0.44.2",
48
- "nifty-protocol": "^1.0.62",
49
48
  "node-polyfill-webpack-plugin": "^1.1.4",
50
49
  "ontology-ts-sdk": "^1.1.16",
51
50
  "path-browserify": "^1.0.1",