Comparing version 2.1.17 to 2.1.19
const HttpProvider = TronWeb.providers.HttpProvider; | ||
const fullNode = new HttpProvider('https://api.trongrid.io:8090'); | ||
const solidityNode = new HttpProvider('https://api.trongrid.io:8091'); | ||
const fullNode = new HttpProvider('https://api.trongrid.io'); | ||
const solidityNode = new HttpProvider('https://api.trongrid.io'); | ||
const eventServer = 'https://api.trongrid.io/'; | ||
@@ -6,0 +6,0 @@ const privateKey = 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0'; |
const TronWeb = require('../../dist/TronWeb.node.js'); | ||
const fullNode = 'http://127.0.0.1:8090'; | ||
const solidityNode = 'http://127.0.0.1:8091'; | ||
const eventServer = 'http://127.0.0.1:8092/'; | ||
const fullNode = 'http://127.0.0.1:9090'; | ||
const solidityNode = 'http://127.0.0.1:9090'; | ||
const eventServer = 'http://127.0.0.1:9090/'; | ||
const privateKey = 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0'; | ||
@@ -7,0 +7,0 @@ |
{ | ||
"name": "tronweb", | ||
"version": "2.1.17", | ||
"version": "2.1.19", | ||
"description": "JavaScript SDK that encapsulates the TRON Node HTTP API", | ||
@@ -5,0 +5,0 @@ "main": "dist/TronWeb.node.js", |
@@ -77,3 +77,3 @@ <h1 align="center"> | ||
* You can also set up your own private network, but you need to solve cross-domain CORS. The following example in Node reads from a full node listening on 16667 and a solidity node listening on 16668, and exposes the ports 8090 and 8091 with the needed headers. | ||
* You can also set up your own private network, but you need to solve cross-domain CORS. The following example in Node reads from a full node listening on 16667 and a solidity node listening on 16668, and exposes the ports 9090 and 9090 with the needed headers. | ||
@@ -97,3 +97,3 @@ ```javascript | ||
})); | ||
fullnode.listen(8090); | ||
fullnode.listen(9090); | ||
@@ -107,3 +107,3 @@ var soliditynode = express(); | ||
})); | ||
soliditynode.listen(8091); | ||
soliditynode.listen(9090); | ||
``` | ||
@@ -110,0 +110,0 @@ |
@@ -180,7 +180,2 @@ import providers from 'lib/providers'; | ||
if(size > 200) { | ||
console.info('Defaulting to maximum accepted size: 200'); | ||
size = 200; | ||
} | ||
const routeParams = []; | ||
@@ -193,3 +188,17 @@ | ||
return callback('Usage of event name filtering requires a contract address'); | ||
if (!utils.isInteger(sinceTimestamp)) | ||
return callback('Invalid sinceTimestamp provided'); | ||
if (!utils.isInteger(size)) | ||
return callback('Invalid size provided'); | ||
if(size > 200) { | ||
console.warn('Defaulting to maximum accepted size: 200'); | ||
size = 200; | ||
} | ||
if (!utils.isInteger(page)) | ||
return callback('Invalid page provided'); | ||
if(blockNumber && !eventName) | ||
@@ -196,0 +205,0 @@ return callback('Usage of block number filtering requires an event name'); |
@@ -523,3 +523,4 @@ import TronWeb from 'index'; | ||
frozenAmount = 0, | ||
frozenDuration = 0 | ||
frozenDuration = 0, | ||
voteScore | ||
} = options; | ||
@@ -569,2 +570,5 @@ | ||
if(utils.isNotNullOrUndefined(voteScore) && (!utils.isInteger(voteScore) || voteScore < 0)) | ||
return callback('voteScore must be a positive integer'); | ||
this.tronWeb.fullNode.request('wallet/createassetissue', { | ||
@@ -579,2 +583,3 @@ owner_address: this.tronWeb.address.toHex(issuerAddress), | ||
num: parseInt(tokenRatio), | ||
vote_score: parseInt(voteScore), | ||
start_time: parseInt(saleStart), | ||
@@ -949,8 +954,14 @@ end_time: parseInt(saleEnd), | ||
*/ | ||
updateSetting(ownerAddress = this.tronWeb.defaultAddress.hex, | ||
contractAddress = false, | ||
userFeePercentage = false, | ||
callback = false) { | ||
updateSetting(contractAddress = false, | ||
userFeePercentage = false, | ||
ownerAddress = this.tronWeb.defaultAddress.hex, | ||
callback = false) { | ||
if(utils.isFunction(ownerAddress)) { | ||
callback = ownerAddress; | ||
ownerAddress = this.tronWeb.defaultAddress.hex; | ||
} | ||
if(!callback) | ||
return this.injectPromise(this.updateSetting, ownerAddress, contractAddress, userFeePercentage); | ||
return this.injectPromise(this.updateSetting, contractAddress, userFeePercentage, ownerAddress); | ||
@@ -967,4 +978,4 @@ if(!this.tronWeb.isAddress(ownerAddress)) | ||
this.tronWeb.fullNode.request('wallet/updatesetting', { | ||
owner_address: ownerAddress, | ||
contract_address: contractAddress, | ||
owner_address: this.tronWeb.address.toHex(ownerAddress), | ||
contract_address: this.tronWeb.address.toHex(contractAddress), | ||
consume_user_resource_percent: userFeePercentage | ||
@@ -977,8 +988,14 @@ }, 'post').then(transaction => transactionResultManager(transaction, callback)).catch(err => callback(err)); | ||
*/ | ||
updateEnergyLimit(ownerAddress = this.tronWeb.defaultAddress.hex, | ||
contractAddress = false, | ||
originEnergyLimit = false, | ||
callback = false) { | ||
updateEnergyLimit(contractAddress = false, | ||
originEnergyLimit = false, | ||
ownerAddress = this.tronWeb.defaultAddress.hex, | ||
callback = false) { | ||
if(utils.isFunction(ownerAddress)) { | ||
callback = ownerAddress; | ||
ownerAddress = this.tronWeb.defaultAddress.hex; | ||
} | ||
if(!callback) | ||
return this.injectPromise(this.updateEnergyLimit, ownerAddress, contractAddress, originEnergyLimit); | ||
return this.injectPromise(this.updateEnergyLimit, contractAddress, originEnergyLimit, ownerAddress); | ||
@@ -995,4 +1012,4 @@ if(!this.tronWeb.isAddress(ownerAddress)) | ||
this.tronWeb.fullNode.request('wallet/updateenergylimit', { | ||
owner_address: ownerAddress, | ||
contract_address: contractAddress, | ||
owner_address: this.tronWeb.address.toHex(ownerAddress), | ||
contract_address: this.tronWeb.address.toHex(contractAddress), | ||
origin_energy_limit: originEnergyLimit | ||
@@ -999,0 +1016,0 @@ }, 'post').then(transaction => transactionResultManager(transaction, callback)).catch(err => callback(err)); |
@@ -1055,2 +1055,37 @@ import TronWeb from 'index'; | ||
getTokenListByName(tokenID = false, callback = false) { | ||
if(!callback) | ||
return this.injectPromise(this.getTokenListByName, tokenID); | ||
if(!utils.isString(tokenID) || !tokenID.length) | ||
return callback('Invalid token ID provided'); | ||
this.tronWeb.fullNode.request('wallet/getassetissuelistbyname', { | ||
value: this.tronWeb.fromUtf8(tokenID) | ||
}, 'post').then(token => { | ||
if(!token.name) | ||
return callback('Token does not exist'); | ||
callback(null, this.parseToken(token)); | ||
}).catch(err => callback(err)); | ||
} | ||
getTokenByID(tokenID = false, callback = false) { | ||
if(!callback) | ||
return this.injectPromise(this.getTokenByID, tokenID); | ||
if(!utils.isString(tokenID) || !tokenID.length) | ||
return callback('Invalid token ID provided'); | ||
this.tronWeb.fullNode.request('wallet/getassetissuebyid', { | ||
value: this.tronWeb.fromUtf8(tokenID) | ||
}, 'post').then(token => { | ||
if(!token.name) | ||
return callback('Token does not exist'); | ||
callback(null, this.parseToken(token)); | ||
}).catch(err => callback(err)); | ||
} | ||
}; |
@@ -59,2 +59,4 @@ import * as accounts from './accounts'; | ||
isInteger(number) { | ||
if (number === null) | ||
return false | ||
return Number.isInteger( | ||
@@ -139,2 +141,6 @@ Number(number) | ||
return res; | ||
}, | ||
isNotNullOrUndefined(val) { | ||
return val !== null && typeof val !== 'undefined'; | ||
} | ||
@@ -141,0 +147,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7191
3315739