@pioneer-platform/mayachain-client 0.8.0 → 0.8.2
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/CHANGELOG.md +12 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +24 -15
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pioneer-platform/mayachain-client
|
|
2
2
|
|
|
3
|
+
## 0.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: add static file serving for /coins/ directory
|
|
8
|
+
|
|
9
|
+
## 0.8.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: add static file serving for /coins/ directory
|
|
14
|
+
|
|
3
15
|
## 0.8.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare let network: any;
|
|
|
7
7
|
declare const createMemo: any, parseMemo: any;
|
|
8
8
|
declare const axios: any;
|
|
9
9
|
declare let Web3: any;
|
|
10
|
-
declare let service: string | undefined;
|
|
11
10
|
declare let web3: any;
|
|
11
|
+
declare function getWeb3(): any;
|
|
12
12
|
declare let networkSupport: any[];
|
|
13
13
|
declare let assetSupport: any[];
|
|
14
14
|
declare function nodeRequest(path: any): Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -46,11 +46,19 @@ var _a = require("@pioneer-platform/pioneer-caip"), caipToNetworkId = _a.caipToN
|
|
|
46
46
|
var network = require("@pioneer-platform/maya-network");
|
|
47
47
|
var _b = require('@pioneer-platform/pioneer-coins'), createMemo = _b.createMemo, parseMemo = _b.parseMemo;
|
|
48
48
|
var axios = require('axios');
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
// Lazy-load web3 to avoid Bun initialization issues
|
|
50
|
+
var Web3;
|
|
51
|
+
var web3;
|
|
52
|
+
function getWeb3() {
|
|
53
|
+
if (!web3) {
|
|
54
|
+
Web3 = require('web3');
|
|
55
|
+
var service = process.env['PARITY_ARCHIVE_NODE'];
|
|
56
|
+
if (!service)
|
|
57
|
+
throw Error("Missing PARITY_ARCHIVE_NODE in .env");
|
|
58
|
+
web3 = new Web3(service);
|
|
59
|
+
}
|
|
60
|
+
return web3;
|
|
61
|
+
}
|
|
54
62
|
var networkSupport = [
|
|
55
63
|
ChainToNetworkId["BTC"],
|
|
56
64
|
ChainToNetworkId["MAYA"],
|
|
@@ -107,7 +115,7 @@ module.exports = {
|
|
|
107
115
|
};
|
|
108
116
|
var get_quote = function (quote) {
|
|
109
117
|
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
-
var tag, output, pools, BaseDecimal, asset, DECIMALS, BASE_UNIT, sellAmountInBaseUnits, quoteFromNode, URL_1, amountOutEstimated, memoInput, memo, type, chain, tx, inbounds, inbound, tokenAddress, depositAbi, routerContract, quoteSellAmountInEther, numberBN, numberHex, data, gasLimit, block, baseFeePerGas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, feeData, e_1;
|
|
118
|
+
var tag, output, pools, BaseDecimal, asset, DECIMALS, BASE_UNIT, sellAmountInBaseUnits, quoteFromNode, URL_1, amountOutEstimated, memoInput, memo, type, chain, tx, inbounds, inbound, tokenAddress, depositAbi, web3Instance, routerContract, quoteSellAmountInEther, numberBN, numberHex, data, gasLimit, block, baseFeePerGas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, feeData, e_1;
|
|
111
119
|
return __generator(this, function (_a) {
|
|
112
120
|
switch (_a.label) {
|
|
113
121
|
case 0:
|
|
@@ -234,17 +242,18 @@ var get_quote = function (quote) {
|
|
|
234
242
|
"type": "function"
|
|
235
243
|
}
|
|
236
244
|
];
|
|
237
|
-
|
|
245
|
+
web3Instance = getWeb3();
|
|
246
|
+
routerContract = new web3Instance.eth.Contract(depositAbi, inbound.router);
|
|
238
247
|
log.info("routerContract: ", routerContract);
|
|
239
|
-
quoteSellAmountInEther =
|
|
240
|
-
numberBN =
|
|
248
|
+
quoteSellAmountInEther = web3Instance.utils.toWei(quote.sellAmount, 'ether');
|
|
249
|
+
numberBN = web3Instance.utils.toBN(quoteSellAmountInEther);
|
|
241
250
|
numberHex = '0x' + numberBN.toString(16);
|
|
242
251
|
console.log("numberHex: ", numberHex);
|
|
243
252
|
data = routerContract.methods
|
|
244
253
|
.deposit(inbound.address, '0x0000000000000000000000000000000000000000', // 0 = ETH
|
|
245
254
|
numberHex, memo)
|
|
246
255
|
.encodeABI();
|
|
247
|
-
return [4 /*yield*/,
|
|
256
|
+
return [4 /*yield*/, web3Instance.eth.estimateGas({
|
|
248
257
|
from: quote.senderAddress,
|
|
249
258
|
to: inbound.router,
|
|
250
259
|
value: 0,
|
|
@@ -255,15 +264,15 @@ var get_quote = function (quote) {
|
|
|
255
264
|
gasLimit = gasLimit + gasLimit * 0.2;
|
|
256
265
|
gasLimit = parseInt(gasLimit);
|
|
257
266
|
log.info(tag, 'gasLimit: ', gasLimit);
|
|
258
|
-
return [4 /*yield*/,
|
|
267
|
+
return [4 /*yield*/, web3Instance.eth.getBlock("latest")];
|
|
259
268
|
case 6:
|
|
260
269
|
block = _a.sent();
|
|
261
270
|
baseFeePerGas = block.baseFeePerGas;
|
|
262
|
-
return [4 /*yield*/,
|
|
271
|
+
return [4 /*yield*/, web3Instance.eth.getGasPrice()];
|
|
263
272
|
case 7:
|
|
264
273
|
gasPrice = _a.sent();
|
|
265
|
-
maxPriorityFeePerGas = baseFeePerGas ?
|
|
266
|
-
maxFeePerGas = baseFeePerGas ?
|
|
274
|
+
maxPriorityFeePerGas = baseFeePerGas ? web3Instance.utils.toBN(baseFeePerGas).div(web3Instance.utils.toBN(2)).toString() : '0';
|
|
275
|
+
maxFeePerGas = baseFeePerGas ? web3Instance.utils.toBN(baseFeePerGas).mul(web3Instance.utils.toBN(2)).toString() : gasPrice;
|
|
267
276
|
feeData = {
|
|
268
277
|
gasPrice: gasPrice, // Legacy networks
|
|
269
278
|
baseFeePerGas: baseFeePerGas, // EIP-1559 networks
|
|
@@ -288,7 +297,7 @@ var get_quote = function (quote) {
|
|
|
288
297
|
from: quote.senderAddress,
|
|
289
298
|
data: data,
|
|
290
299
|
value: numberHex,
|
|
291
|
-
"gasLimit":
|
|
300
|
+
"gasLimit": web3Instance.utils.toHex(gasLimit),
|
|
292
301
|
"maxPriorityFeePerGas": maxPriorityFeePerGas,
|
|
293
302
|
"maxFeePerGas": maxFeePerGas,
|
|
294
303
|
"nonce": null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/mayachain-client",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"@pioneer-platform/pioneer-caip": "^9.10.0",
|
|
10
10
|
"@pioneer-platform/pioneer-coins": "^9.11.0",
|
|
11
11
|
"axios": "^1.6.0",
|
|
12
|
-
"dotenv": "^
|
|
12
|
+
"dotenv": "^17.2.3",
|
|
13
13
|
"rango-sdk": "^0.1.45",
|
|
14
14
|
"uuidv4": "^6.2.13",
|
|
15
|
-
"web3": "
|
|
15
|
+
"web3": "4.14.0"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"npm": "pnpm i",
|