Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "tronweb", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "JavaScript SDK that encapsulates the TRON Node HTTP API", | ||
@@ -5,0 +5,0 @@ "main": "dist/TronWeb.node.js", |
@@ -983,3 +983,3 @@ import TronWeb from 'index'; | ||
exchange_id: parseInt(exchangeID), | ||
token_id: this.tronWeb.fromAscii(tokenName), | ||
token_id: this.tronWeb.fromUtf8(tokenName), | ||
quant:parseInt(tokenAmount) | ||
@@ -1001,2 +1001,42 @@ }, 'post').then(transaction => { | ||
/** | ||
* Withdraws tokens from a bancor style exchange. | ||
*/ | ||
withdrawExchangeTRX(exchangeID = false, trxAmount = 0, ownerAddress = this.tronWeb.defaultAddress.hex, callback = false) { | ||
if(utils.isFunction(ownerAddress)) { | ||
callback = ownerAddress; | ||
ownerAddress = this.tronWeb.defaultAddress.hex; | ||
} | ||
if(!callback) | ||
return this.injectPromise(this.withdrawExchangeTokens, exchangeID, trxAmount, ownerAddress); | ||
if(!this.tronWeb.isAddress(ownerAddress)) | ||
return callback('Invalid ownerAddress provided'); | ||
if(!utils.isInteger(exchangeID) || exchangeID < 0) | ||
return callback('Invalid exchangeID provided'); | ||
if(!utils.isInteger(trxAmount) || trxAmount < 1) | ||
return callback('Invalid trxAmount provided'); | ||
this.tronWeb.fullNode.request('wallet/exchangewithdraw', { | ||
owner_address: this.tronWeb.address.toHex(ownerAddress), | ||
exchange_id: parseInt(exchangeID), | ||
token_id: "5f", | ||
quant:parseInt(trxAmount) | ||
}, 'post').then(transaction => { | ||
if(transaction.Error) | ||
return callback(transaction.Error); | ||
if(transaction.result && transaction.result.message) { | ||
return callback( | ||
this.tronWeb.toUtf8(transaction.result.message) | ||
); | ||
} | ||
callback(null, transaction); | ||
}).catch(err => callback(err)); | ||
} | ||
/** | ||
* Trade tokens on a bancor style exchange. | ||
@@ -1003,0 +1043,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
3594488
7129