Comparing version 2.1.9 to 2.1.10
{ | ||
"name": "tronweb", | ||
"version": "2.1.9", | ||
"version": "2.1.10", | ||
"description": "JavaScript SDK that encapsulates the TRON Node HTTP API", | ||
@@ -5,0 +5,0 @@ "main": "dist/TronWeb.node.js", |
@@ -174,1 +174,4 @@ <p align="center"> | ||
``` | ||
#### Note: | ||
For testing TronWeb API functions, it would be best to setup a private network on your local machine using the <a href="https://developers.tron.network/docs/getting-started-1" target="_blank">TRON Docker Quickstart guide</a>. The Docker guide sets up a Full Node, Solidity Node, and Event Server on your machine. You can then deploy smart contracts on your network and interact with them via TronWeb. If you wish to test TronWeb with other users, it would be best to deploy your contracts/DApps on the Shasta test network and interact from there. |
@@ -160,5 +160,16 @@ import providers from 'lib/providers'; | ||
getEventResult(contractAddress = false, sinceTimestamp = 0, eventName = false, blockNumber = false, callback = false) { | ||
getEventResult(contractAddress = false, sinceTimestamp = 0, eventName = false, blockNumber = false, size = 20, page = 1, callback = false) { | ||
if(utils.isFunction(page)) { | ||
callback = page; | ||
page = 1; | ||
} | ||
if(utils.isFunction(size)) { | ||
callback = size; | ||
size = 20; | ||
} | ||
if(!callback) | ||
return this.injectPromise(this.getEventResult, contractAddress, sinceTimestamp, eventName, blockNumber); | ||
return this.injectPromise(this.getEventResult, contractAddress, sinceTimestamp, eventName, blockNumber, size, page); | ||
@@ -168,2 +179,7 @@ if(!this.eventServer) | ||
if(size > 200) { | ||
console.info('Defaulting to maximum accepted size: 200'); | ||
size = 200; | ||
} | ||
const routeParams = []; | ||
@@ -189,3 +205,3 @@ | ||
return this.eventServer.request(`event/contract/${routeParams.join('/')}?since=${sinceTimestamp}`).then((data = false) => { | ||
return this.eventServer.request(`event/contract/${routeParams.join('/')}?since=${sinceTimestamp}&size=${size}&page=${page}`).then((data = false) => { | ||
if(!data) | ||
@@ -192,0 +208,0 @@ return callback('Unknown error occurred'); |
@@ -662,27 +662,2 @@ import TronWeb from 'index'; | ||
callback(null, result); | ||
if (result.result) { | ||
const timeout = Date.now() + 6e4 // 1 minutes | ||
const isMined = async () => { | ||
let transaction = await this.tronWeb.trx.getTransactionInfo(signedTransaction.txID) | ||
if (Date.now() < timeout && (!utils.isObject(transaction) || !transaction.blockNumber)) { | ||
this.tronWeb.fullNode.request( | ||
'wallet/broadcasttransaction', | ||
signedTransaction, | ||
'post' | ||
).then(result => { | ||
}).catch(err => { | ||
}); | ||
setTimeout(isMined, 5e3) | ||
} else if (options.onConfirmation) { | ||
let err = null | ||
if (Date.now() >= timeout) { | ||
err = 'Broadcast timeout' | ||
transaction = null | ||
} | ||
options.onConfirmation(err, transaction); | ||
} | ||
} | ||
setTimeout(isMined, 5e3) | ||
} | ||
}).catch(err => callback(err)); | ||
@@ -689,0 +664,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
177
3593445
7123