@pioneer-platform/eth-network 8.1.65 → 8.1.66
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 +32 -12
- package/package.json +1 -1
package/lib/index.js
CHANGED
@@ -162,8 +162,8 @@ module.exports = {
|
|
162
162
|
getSymbolFromContract: function (contract) {
|
163
163
|
return get_symbol_from_contract(contract);
|
164
164
|
},
|
165
|
-
getTransferData: function (toAddress, amount,
|
166
|
-
return get_token_transfer_data(toAddress, amount,
|
165
|
+
getTransferData: function (toAddress, amount, contract) {
|
166
|
+
return get_token_transfer_data(toAddress, amount, contract);
|
167
167
|
},
|
168
168
|
getPoolPositions: function (address) {
|
169
169
|
return get_pool_positions(address);
|
@@ -360,19 +360,39 @@ var check_airdrop_claim = function (address) {
|
|
360
360
|
});
|
361
361
|
};
|
362
362
|
//get_token_transfer_data
|
363
|
-
var get_token_transfer_data = function (toAddress, amount,
|
363
|
+
var get_token_transfer_data = function (toAddress, amount, contract) {
|
364
364
|
return __awaiter(this, void 0, void 0, function () {
|
365
|
-
var tag, value, tokenData, e_4;
|
365
|
+
var tag, minABI, newContract, decimals, value, tokenData, e_4;
|
366
366
|
return __generator(this, function (_a) {
|
367
367
|
switch (_a.label) {
|
368
368
|
case 0:
|
369
369
|
tag = TAG + " | get_token_transfer_data | ";
|
370
370
|
_a.label = 1;
|
371
371
|
case 1:
|
372
|
-
_a.trys.push([1,
|
373
|
-
|
374
|
-
|
375
|
-
|
372
|
+
_a.trys.push([1, 4, , 5]);
|
373
|
+
minABI = [
|
374
|
+
// balanceOf
|
375
|
+
{
|
376
|
+
"constant": true,
|
377
|
+
"inputs": [{ "name": "_owner", "type": "address" }],
|
378
|
+
"name": "balanceOf",
|
379
|
+
"outputs": [{ "name": "balance", "type": "uint256" }],
|
380
|
+
"type": "function"
|
381
|
+
},
|
382
|
+
// decimals
|
383
|
+
{
|
384
|
+
"constant": true,
|
385
|
+
"inputs": [],
|
386
|
+
"name": "decimals",
|
387
|
+
"outputs": [{ "name": "", "type": "uint8" }],
|
388
|
+
"type": "function"
|
389
|
+
}
|
390
|
+
];
|
391
|
+
newContract = new web3.eth.Contract(minABI, contract);
|
392
|
+
return [4 /*yield*/, newContract.methods.decimals().call()];
|
393
|
+
case 2:
|
394
|
+
decimals = _a.sent();
|
395
|
+
value = parseInt(amount / Math.pow(10, decimals));
|
376
396
|
return [4 /*yield*/, web3.eth.abi.encodeFunctionCall({
|
377
397
|
name: 'transfer',
|
378
398
|
type: 'function',
|
@@ -387,14 +407,14 @@ var get_token_transfer_data = function (toAddress, amount, prescision) {
|
|
387
407
|
}
|
388
408
|
]
|
389
409
|
}, [toAddress, value])];
|
390
|
-
case
|
410
|
+
case 3:
|
391
411
|
tokenData = _a.sent();
|
392
412
|
return [2 /*return*/, tokenData];
|
393
|
-
case
|
413
|
+
case 4:
|
394
414
|
e_4 = _a.sent();
|
395
415
|
console.error(tag, e_4);
|
396
|
-
return [3 /*break*/,
|
397
|
-
case
|
416
|
+
return [3 /*break*/, 5];
|
417
|
+
case 5: return [2 /*return*/];
|
398
418
|
}
|
399
419
|
});
|
400
420
|
});
|