@pioneer-platform/mayachain-client 0.0.30 → 0.0.32

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.
Files changed (2) hide show
  1. package/lib/index.js +23 -17
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -123,14 +123,14 @@ function quoteFromPool(sellAmount, assetPoolAmount, runePoolAmount, maxSlippage)
123
123
  }
124
124
  var get_quote = function (quote) {
125
125
  return __awaiter(this, void 0, void 0, function () {
126
- var tag, output, pools, poolIn, poolOut, BaseDecimal_1, asset, DECIMALS, BASE_UNIT, sellAmountInBaseUnits, quoteFromNode, URL_1, amountOutMin, inboundAddress, amountOutEstimated, memoInput, memo, type, chain, tx, inbounds, inbound, tokenAddress, depositAbi, routerContract, quoteSellAmountInEther, numberHex, data, gasLimit, block, baseFeePerGas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, feeData, nonce, e_1;
126
+ var tag, output, pools, poolIn, poolOut, BaseDecimal_1, asset, DECIMALS, BASE_UNIT, sellAmountInBaseUnits, quoteFromNode, URL_1, amountOutMin, inboundAddress, amountOutEstimated, memoInput, memo, type, chain, tx, inbounds, inbound, tokenAddress, depositAbi, routerContract, quoteSellAmountInEther, numberBN, numberHex, data, gasLimit, block, baseFeePerGas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, feeData, e_1;
127
127
  return __generator(this, function (_a) {
128
128
  switch (_a.label) {
129
129
  case 0:
130
130
  tag = TAG + " | get_quote | ";
131
131
  _a.label = 1;
132
132
  case 1:
133
- _a.trys.push([1, 11, , 12]);
133
+ _a.trys.push([1, 10, , 11]);
134
134
  output = {};
135
135
  if (!quote.sellAsset)
136
136
  throw new Error("missing sellAsset");
@@ -226,7 +226,7 @@ var get_quote = function (quote) {
226
226
  type = 'transfer';
227
227
  }
228
228
  tx = void 0;
229
- if (!(chain === "ETH")) return [3 /*break*/, 9];
229
+ if (!(chain === "ETH")) return [3 /*break*/, 8];
230
230
  type = 'EVM';
231
231
  return [4 /*yield*/, nodeRequest('/inbound_addresses')];
232
232
  case 4:
@@ -255,7 +255,8 @@ var get_quote = function (quote) {
255
255
  routerContract = new web3.eth.Contract(depositAbi, inbound.router);
256
256
  log.info("routerContract: ", routerContract);
257
257
  quoteSellAmountInEther = web3.utils.toWei(quote.sellAmount, 'ether');
258
- numberHex = web3.utils.toBN(quoteSellAmountInEther);
258
+ numberBN = web3.utils.toBN(quoteSellAmountInEther);
259
+ numberHex = '0x' + numberBN.toString(16);
259
260
  console.log("numberHex: ", numberHex);
260
261
  data = routerContract.methods
261
262
  .deposit(inbound.address, '0x0000000000000000000000000000000000000000', // 0 = ETH
@@ -286,10 +287,15 @@ var get_quote = function (quote) {
286
287
  maxFeePerGas: maxFeePerGas // EIP-1559 calculation
287
288
  };
288
289
  console.log("feeData: ", feeData);
289
- return [4 /*yield*/, web3.eth.getTransactionCount(quote.senderAddress, 'latest')];
290
- case 8:
291
- nonce = _a.sent();
292
- console.log("nonce: ", nonce);
290
+ // Calculate a 20% buffer and add it to the gasLimit
291
+ // const buffer = gasLimit.mul(20).div(100); // 20% buffer
292
+ // gasLimit = gasLimit.add(buffer);
293
+ // //if gas limit is < 21000 then set to 21000
294
+ // if (gasLimit.lt(ethers.BigNumber.from('36000'))) {
295
+ // gasLimit = ethers.BigNumber.from('36000');
296
+ // }
297
+ // const nonce = await web3.eth.getTransactionCount(quote.senderAddress, 'latest'); // 'latest' can be replaced with the desired block number
298
+ // console.log("nonce: ",nonce)
293
299
  tx = {
294
300
  type: type,
295
301
  chain: ChainToNetworkId[quote.sellAsset.split(".")[0]],
@@ -297,15 +303,15 @@ var get_quote = function (quote) {
297
303
  to: inbound.router,
298
304
  from: quote.senderAddress,
299
305
  data: data,
300
- value: quoteSellAmountInEther,
301
- "gasLimit": gasLimit,
306
+ value: numberHex,
307
+ "gasLimit": Web3.utils.toHex(gasLimit),
302
308
  "maxPriorityFeePerGas": maxPriorityFeePerGas,
303
309
  "maxFeePerGas": maxFeePerGas,
304
- "nonce": nonce
310
+ "nonce": null
305
311
  }
306
312
  };
307
- return [3 /*break*/, 10];
308
- case 9:
313
+ return [3 /*break*/, 9];
314
+ case 8:
309
315
  tx = {
310
316
  type: type,
311
317
  chain: ChainToNetworkId[quote.sellAsset.split(".")[0]],
@@ -317,17 +323,17 @@ var get_quote = function (quote) {
317
323
  memo: quoteFromNode.memo || memo
318
324
  }
319
325
  };
320
- _a.label = 10;
321
- case 10:
326
+ _a.label = 9;
327
+ case 9:
322
328
  output.txs = [
323
329
  tx
324
330
  ];
325
331
  return [2 /*return*/, output];
326
- case 11:
332
+ case 10:
327
333
  e_1 = _a.sent();
328
334
  console.error(tag, "e: ", e_1);
329
335
  throw e_1;
330
- case 12: return [2 /*return*/];
336
+ case 11: return [2 /*return*/];
331
337
  }
332
338
  });
333
339
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/mayachain-client",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "dependencies": {