@tatumio/tron 2.2.8 → 2.2.9
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tatumio/tron",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.9",
|
4
4
|
"type": "commonjs",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "./src/index.js",
|
7
7
|
"types": "./src/index.d.ts",
|
8
8
|
"dependencies": {
|
9
|
-
"@tatumio/shared-testing-common": "2.2.
|
10
|
-
"@tatumio/api-client": "2.2.
|
9
|
+
"@tatumio/shared-testing-common": "2.2.9",
|
10
|
+
"@tatumio/api-client": "2.2.9",
|
11
11
|
"axios": "^0.26.0",
|
12
12
|
"form-data": "^4.0.0",
|
13
|
-
"@tatumio/shared-blockchain-evm-based": "2.2.
|
14
|
-
"@tatumio/shared-abstract-sdk": "2.2.
|
13
|
+
"@tatumio/shared-blockchain-evm-based": "2.2.9",
|
14
|
+
"@tatumio/shared-abstract-sdk": "2.2.9",
|
15
15
|
"bignumber.js": "^9.0.2",
|
16
|
-
"@tatumio/shared-core": "2.2.
|
16
|
+
"@tatumio/shared-core": "2.2.9",
|
17
17
|
"lodash": "^4.17.21",
|
18
|
-
"@tatumio/shared-blockchain-abstract": "2.2.
|
18
|
+
"@tatumio/shared-blockchain-abstract": "2.2.9",
|
19
19
|
"ethereumjs-wallet": "^1.0.2",
|
20
20
|
"bip39": "^3.0.2",
|
21
21
|
"web3": "^1.7.4",
|
@@ -8,19 +8,18 @@ const shared_blockchain_evm_based_1 = require("@tatumio/shared-blockchain-evm-ba
|
|
8
8
|
const prepareSignedTransaction = (body, tronWeb, provider) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
9
9
|
const { to, tokenAddress, amount, feeLimit } = body;
|
10
10
|
const client = tronWeb.getClient(provider);
|
11
|
-
|
12
|
-
client.
|
13
|
-
const contractInstance = yield client.contract().at(destinationContractAddress);
|
14
|
-
const decimals = yield contractInstance.decimals().call();
|
11
|
+
client.setAddress(tokenAddress);
|
12
|
+
const contractInstance = yield client.contract(shared_blockchain_evm_based_1.Trc20Token.abi, tokenAddress);
|
15
13
|
const from = body.signatureId
|
16
14
|
? body.from
|
17
15
|
: client.address.fromHex(client.address.fromPrivateKey(body.fromPrivateKey));
|
18
16
|
const balance = (yield contractInstance.balanceOf(from).call()).toString();
|
17
|
+
const decimals = yield contractInstance.decimals().call({ _isConstant: true });
|
19
18
|
const valueToSend = new bignumber_js_1.default(amount).multipliedBy(new bignumber_js_1.default(10).pow(decimals));
|
20
19
|
if (valueToSend.isGreaterThan(new bignumber_js_1.default(balance || 0))) {
|
21
20
|
throw new Error('Insufficient TRC20 balance');
|
22
21
|
}
|
23
|
-
const tokenAddressHex = client.address.toHex(
|
22
|
+
const tokenAddressHex = client.address.toHex(tokenAddress);
|
24
23
|
const methodName = 'transfer(address,uint256)';
|
25
24
|
const params = [
|
26
25
|
{ type: 'address', value: client.address.toHex(to) },
|
@@ -45,16 +44,6 @@ const prepareSignedTransaction = (body, tronWeb, provider) => tslib_1.__awaiter(
|
|
45
44
|
return JSON.stringify(yield client.trx.sign(transaction, body.fromPrivateKey));
|
46
45
|
}
|
47
46
|
});
|
48
|
-
/*
|
49
|
-
We need to hardcode some proxy contracts for some tokens, because they are not automatically resolved to the destination contract.
|
50
|
-
*/
|
51
|
-
const getProxyTokenAddress = (tokenAddress) => {
|
52
|
-
const proxyContract = {
|
53
|
-
// BUSD https://tronscan.org/#/token20/TMz2SWatiAtZVVcH2ebpsbVtYwUPT9EdjH
|
54
|
-
TMz2SWatiAtZVVcH2ebpsbVtYwUPT9EdjH: 'TTtQQxmhZTnpKhdVVJpANpX12vRjc16TxZ',
|
55
|
-
};
|
56
|
-
return proxyContract[tokenAddress] || tokenAddress;
|
57
|
-
};
|
58
47
|
const prepareCreateSignedTransaction = (body, tronWeb, provider) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
59
48
|
const { name, decimals, recipient, symbol, totalSupply } = body;
|
60
49
|
const client = tronWeb.getClient(provider);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tron.trc20.js","sourceRoot":"","sources":["../../../../../../../packages/blockchain/tron/src/lib/services/tron.trc20.ts"],"names":[],"mappings":";;;;AAAA,oDAM4B;AAC5B,wEAAoC;AAEpC,sFAAiE;AAMjE,MAAM,wBAAwB,GAAG,CAAO,IAAuB,EAAE,OAAiB,EAAE,QAAiB,EAAE,EAAE;IACvG,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAEnD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAE1C,MAAM,
|
1
|
+
{"version":3,"file":"tron.trc20.js","sourceRoot":"","sources":["../../../../../../../packages/blockchain/tron/src/lib/services/tron.trc20.ts"],"names":[],"mappings":";;;;AAAA,oDAM4B;AAC5B,wEAAoC;AAEpC,sFAAiE;AAMjE,MAAM,wBAAwB,GAAG,CAAO,IAAuB,EAAE,OAAiB,EAAE,QAAiB,EAAE,EAAE;IACvG,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;IAEnD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAE1C,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;IAC/B,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,wCAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAE5E,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW;QAC3B,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAA;IAE9E,MAAM,OAAO,GAAI,CAAC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