@pioneer-platform/eth-network 8.1.65 → 8.1.67
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/lib/index.js +37 -14
- package/lib/types/client-types.js +1 -1
- package/package.json +3 -1
package/lib/index.js
CHANGED
@@ -72,6 +72,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
72
|
var TAG = " | eth-network | ";
|
73
73
|
var Web3 = require('web3');
|
74
74
|
var ethers_1 = require("ethers");
|
75
|
+
// @ts-ignore
|
76
|
+
var BigNumber = require('bignumber.js');
|
75
77
|
//
|
76
78
|
var Axios = require('axios');
|
77
79
|
var https = require('https');
|
@@ -162,8 +164,8 @@ module.exports = {
|
|
162
164
|
getSymbolFromContract: function (contract) {
|
163
165
|
return get_symbol_from_contract(contract);
|
164
166
|
},
|
165
|
-
getTransferData: function (toAddress, amount,
|
166
|
-
return get_token_transfer_data(toAddress, amount,
|
167
|
+
getTransferData: function (toAddress, amount, contract) {
|
168
|
+
return get_token_transfer_data(toAddress, amount, contract);
|
167
169
|
},
|
168
170
|
getPoolPositions: function (address) {
|
169
171
|
return get_pool_positions(address);
|
@@ -360,19 +362,40 @@ var check_airdrop_claim = function (address) {
|
|
360
362
|
});
|
361
363
|
};
|
362
364
|
//get_token_transfer_data
|
363
|
-
var get_token_transfer_data = function (toAddress, amount,
|
365
|
+
var get_token_transfer_data = function (toAddress, amount, contract) {
|
364
366
|
return __awaiter(this, void 0, void 0, function () {
|
365
|
-
var tag, value, tokenData, e_4;
|
367
|
+
var tag, minABI, newContract, decimals, value, tokenData, e_4;
|
366
368
|
return __generator(this, function (_a) {
|
367
369
|
switch (_a.label) {
|
368
370
|
case 0:
|
369
371
|
tag = TAG + " | get_token_transfer_data | ";
|
370
372
|
_a.label = 1;
|
371
373
|
case 1:
|
372
|
-
_a.trys.push([1,
|
373
|
-
|
374
|
-
|
375
|
-
|
374
|
+
_a.trys.push([1, 4, , 5]);
|
375
|
+
minABI = [
|
376
|
+
// balanceOf
|
377
|
+
{
|
378
|
+
"constant": true,
|
379
|
+
"inputs": [{ "name": "_owner", "type": "address" }],
|
380
|
+
"name": "balanceOf",
|
381
|
+
"outputs": [{ "name": "balance", "type": "uint256" }],
|
382
|
+
"type": "function"
|
383
|
+
},
|
384
|
+
// decimals
|
385
|
+
{
|
386
|
+
"constant": true,
|
387
|
+
"inputs": [],
|
388
|
+
"name": "decimals",
|
389
|
+
"outputs": [{ "name": "", "type": "uint8" }],
|
390
|
+
"type": "function"
|
391
|
+
}
|
392
|
+
];
|
393
|
+
newContract = new web3.eth.Contract(minABI, contract);
|
394
|
+
return [4 /*yield*/, newContract.methods.decimals().call()];
|
395
|
+
case 2:
|
396
|
+
decimals = _a.sent();
|
397
|
+
value = new BigNumber(amount).times(new BigNumber(10).pow(decimals)).toFixed();
|
398
|
+
log.info(tag, "value: ", value);
|
376
399
|
return [4 /*yield*/, web3.eth.abi.encodeFunctionCall({
|
377
400
|
name: 'transfer',
|
378
401
|
type: 'function',
|
@@ -387,14 +410,14 @@ var get_token_transfer_data = function (toAddress, amount, prescision) {
|
|
387
410
|
}
|
388
411
|
]
|
389
412
|
}, [toAddress, value])];
|
390
|
-
case
|
413
|
+
case 3:
|
391
414
|
tokenData = _a.sent();
|
392
415
|
return [2 /*return*/, tokenData];
|
393
|
-
case
|
416
|
+
case 4:
|
394
417
|
e_4 = _a.sent();
|
395
418
|
console.error(tag, e_4);
|
396
|
-
return [3 /*break*/,
|
397
|
-
case
|
419
|
+
return [3 /*break*/, 5];
|
420
|
+
case 5: return [2 /*return*/];
|
398
421
|
}
|
399
422
|
});
|
400
423
|
});
|
@@ -818,7 +841,7 @@ var estimate_fee = function (sourceAsset, params) {
|
|
818
841
|
return [4 /*yield*/, get_fees(entry)];
|
819
842
|
case 3:
|
820
843
|
fees = (_b.sent()).fees;
|
821
|
-
minimumWeiCost =
|
844
|
+
minimumWeiCost = BigNumber.from(fees.average);
|
822
845
|
minimumWeiCost = minimumWeiCost.mul(estimateGas.toNumber());
|
823
846
|
return [2 /*return*/, minimumWeiCost];
|
824
847
|
case 4:
|
@@ -842,7 +865,7 @@ var get_gas_limit = function (_a) {
|
|
842
865
|
case 1:
|
843
866
|
_b.trys.push([1, 6, , 7]);
|
844
867
|
log.debug(tag, "input: ", { asset: asset, recipient: recipient, amount: amount, memo: memo });
|
845
|
-
txAmount =
|
868
|
+
txAmount = BigNumber.from(amount === null || amount === void 0 ? void 0 : amount.amount().toFixed());
|
846
869
|
assetAddress = void 0;
|
847
870
|
if (asset && (0, xchain_util_1.assetToString)(asset) !== (0, xchain_util_1.assetToString)(xchain_util_1.AssetETH)) {
|
848
871
|
assetAddress = (0, utils_1.getTokenAddress)(asset);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pioneer-platform/eth-network",
|
3
|
-
"version": "8.1.
|
3
|
+
"version": "8.1.67",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"types": "./lib/index.d.ts",
|
6
6
|
"scripts": {
|
@@ -19,6 +19,8 @@
|
|
19
19
|
"@pioneer-platform/loggerdog": "^8.1.29",
|
20
20
|
"@xchainjs/xchain-util": "^0.2.6",
|
21
21
|
"axios": "^0.21.4",
|
22
|
+
"bignumber.js": "^9.1.1",
|
23
|
+
"decimal.js": "^10.4.3",
|
22
24
|
"dotenv": "^8.2.0",
|
23
25
|
"ethers": "^5.1.0",
|
24
26
|
"request-promise": "^4.2.6",
|