Skip to content

Commit f64f390

Browse files
authored
Merge pull request #111 from tronprotocol/develop
Develop
2 parents 97b5529 + 947146e commit f64f390

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ In order to contribute you can
168168

169169
## Recent History
170170

171+
__3.1.0__
172+
- Update `elliptic` to the latest version 6.5.3
173+
- Update `ethers` to the latest version 5.0.8
174+
- Fix `loadAbi()`
175+
171176
__3.0.0__
172177
- Support sidechain for SunNetwork
173178
- Set feeLimit default value as 20 TRX

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tronweb",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "JavaScript SDK that encapsulates the TRON HTTP API",
55
"main": "dist/TronWeb.node.js",
66
"scripts": {
@@ -25,8 +25,8 @@
2525
"axios": "^0.19.0",
2626
"babel-runtime": "^6.26.0",
2727
"bignumber.js": "^7.2.1",
28-
"elliptic": "^6.4.1",
29-
"ethers": "^4.0.7",
28+
"elliptic": "^6.5.3",
29+
"ethers": "^5.0.8",
3030
"eventemitter3": "^3.1.0",
3131
"injectpromise": "^1.0.0",
3232
"lodash": "^4.17.14",

src/lib/contract/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default class Contract {
202202
this.bytecode = contract.bytecode;
203203
this.deployed = true;
204204

205-
this.loadAbi(contract.abi ? contract.abi.entrys : []);
205+
this.loadAbi(contract.abi ? contract.abi.entrys ? contract.abi.entrys : [] : []);
206206

207207
return callback(null, this);
208208
} catch (ex) {

src/lib/trx.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,22 +710,25 @@ export default class Trx {
710710

711711
static signString(message, privateKey, useTronHeader = true) {
712712
message = message.replace(/^0x/, '');
713-
const signingKey = new SigningKey(privateKey);
713+
const value ={
714+
toHexString: function() {
715+
return '0x' + privateKey
716+
},
717+
value: privateKey
718+
}
719+
const signingKey = new SigningKey(value);
714720
const messageBytes = [
715721
...toUtf8Bytes(useTronHeader ? TRX_MESSAGE_HEADER : ETH_MESSAGE_HEADER),
716722
...utils.code.hexStr2byteArray(message)
717723
];
718-
719724
const messageDigest = keccak256(messageBytes);
720725
const signature = signingKey.signDigest(messageDigest);
721-
722726
const signatureHex = [
723727
'0x',
724728
signature.r.substring(2),
725729
signature.s.substring(2),
726730
Number(signature.v).toString(16)
727731
].join('');
728-
729732
return signatureHex
730733
}
731734

test/lib/transactionBuilder.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ describe('TronWeb.transactionBuilder', function () {
11591159
const tx = await tronWeb.transactionBuilder.createSmartContract(options)
11601160
assert.equal(tx.raw_data.contract[0].parameter.value.new_contract.consume_user_resource_percent, 100);
11611161
assert.equal(tx.raw_data.contract[0].parameter.value.new_contract.origin_energy_limit, 1e7);
1162-
assert.equal(tx.raw_data.fee_limit, 1e9);
1162+
assert.equal(tx.raw_data.fee_limit, 2e7);
11631163
assert.equal(tx.raw_data.contract[0].Permission_id || 0, options.permissionId || 0);
11641164
}
11651165
});

test/utils/abi.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ describe('TronWeb.utils.abi', function () {
5656
const types = ['string', 'string', 'uint8', 'bytes32', 'uint256'];
5757
const output =
5858
'00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000012dc03b7993bad736ad595eb9e3ba51877ac17ecc31d2355f8f270125b9427ece700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011506920446179204e30306220546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035049450000000000000000000000000000000000000000000000000000000000';
59-
6059
assert.throws(() => {
6160
tronWeb.utils.abi.decodeParams(types, output)
62-
}, 'hex string must have 0x prefix');
61+
}, 'invalid arrayify value');
6362
});
6463

6564
it('should throw if the output format is wrong', function () {
@@ -70,7 +69,7 @@ describe('TronWeb.utils.abi', function () {
7069

7170
assert.throws(() => {
7271
tronWeb.utils.abi.decodeParams(types, output)
73-
}, 'dynamic bytes count too large');
72+
}, 'overflow');
7473
});
7574

7675
it('should throw if the output is invalid', function () {

0 commit comments

Comments
 (0)