Comparing version 1.0.0 to 1.0.1
@@ -11,2 +11,3 @@ import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
import { signTransaction } from './utils/crypto'; | ||
import { utils } from 'ethers'; | ||
@@ -18,3 +19,3 @@ var FullNode = function () { | ||
this.apiUrl = options.apiUrl; | ||
xhr.defaults.baseURL = this.apiUrl; | ||
//xhr.defaults.baseURL = this.apiUrl; | ||
this.signer = null; | ||
@@ -114,3 +115,2 @@ } | ||
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(transaction, privateKey) { | ||
var txId; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
@@ -120,6 +120,5 @@ while (1) { | ||
case 0: | ||
txId = transaction.txID; | ||
return _context3.abrupt('return', signTransaction(privateKey, transaction)); | ||
case 2: | ||
case 1: | ||
case 'end': | ||
@@ -1512,3 +1511,150 @@ return _context3.stop(); | ||
}(); | ||
/** | ||
* 部署合约 | ||
* @param | ||
* {string} abi, | ||
* {string} bytecode, | ||
* {int} bandwidth_limit 字节数, | ||
* {int} cpu_limit 微秒, | ||
* {int} storage_limit 字节数 | ||
* {int} drop_limit 最大消耗的Drop (1trx = 1000000drop) | ||
* {int} call_value 本次调用网合约转账的Drop (1trx = 1000000drop) | ||
* {string hexString} owner_address 发起部署合约的账户地址 | ||
* @return {object transction} | ||
* */ | ||
FullNode.prototype.deployContract = function () { | ||
var _ref72 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee38(options) { | ||
var abi, bytecode, bandwidth_limit, cpu_limit, storage_limit, drop_limit, call_value, owner_address, _ref73, data; | ||
return _regeneratorRuntime.wrap(function _callee38$(_context38) { | ||
while (1) { | ||
switch (_context38.prev = _context38.next) { | ||
case 0: | ||
abi = options.abi, bytecode = options.bytecode, bandwidth_limit = options.bandwidth_limit, cpu_limit = options.cpu_limit, storage_limit = options.storage_limit, drop_limit = options.drop_limit, call_value = options.call_value, owner_address = options.owner_address; | ||
owner_address = address2HexString(owner_address); | ||
_context38.next = 4; | ||
return xhr.post(this.apiUrl + '/wallet/deploycontract', { | ||
abi: abi, | ||
bytecode: bytecode, | ||
bandwidth_limit: bandwidth_limit, | ||
cpu_limit: cpu_limit, | ||
storage_limit: storage_limit, | ||
drop_limit: drop_limit, | ||
call_value: call_value, | ||
owner_address: owner_address | ||
}); | ||
case 4: | ||
_ref73 = _context38.sent; | ||
data = _ref73.data; | ||
return _context38.abrupt('return', data); | ||
case 7: | ||
case 'end': | ||
return _context38.stop(); | ||
} | ||
} | ||
}, _callee38, this); | ||
})); | ||
function deployContract(_x46) { | ||
return _ref72.apply(this, arguments); | ||
} | ||
return deployContract; | ||
}(); | ||
FullNode.prototype.getContract = function () { | ||
var _ref74 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee39(contractAddress) { | ||
var _ref75, data; | ||
return _regeneratorRuntime.wrap(function _callee39$(_context39) { | ||
while (1) { | ||
switch (_context39.prev = _context39.next) { | ||
case 0: | ||
_context39.next = 2; | ||
return xhr.post(this.apiUrl + '/wallet/getcontract', { | ||
value: address2HexString(contractAddress) | ||
}); | ||
case 2: | ||
_ref75 = _context39.sent; | ||
data = _ref75.data; | ||
return _context39.abrupt('return', data); | ||
case 5: | ||
case 'end': | ||
return _context39.stop(); | ||
} | ||
} | ||
}, _callee39, this); | ||
})); | ||
function getContract(_x47) { | ||
return _ref74.apply(this, arguments); | ||
} | ||
return getContract; | ||
}(); | ||
FullNode.prototype.triggerSmartContract = function () { | ||
var _ref76 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee40(options) { | ||
var coder, contract_address, function_selector, parameter, bandwidth_limit, cpu_limit, storage_limit, drop_limit, call_value, owner_address, paramTypes, paramValues, _ref77, data; | ||
return _regeneratorRuntime.wrap(function _callee40$(_context40) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
coder = new utils.AbiCoder(); | ||
contract_address = options.contract_address, function_selector = options.function_selector, parameter = options.parameter, bandwidth_limit = options.bandwidth_limit, cpu_limit = options.cpu_limit, storage_limit = options.storage_limit, drop_limit = options.drop_limit, call_value = options.call_value, owner_address = options.owner_address; | ||
contract_address = address2HexString(contract_address); | ||
function_selector = function_selector.replace(/\s*/g, ''); | ||
paramTypes = parameter[0]; | ||
paramValues = parameter[1]; | ||
paramTypes.forEach(function (itemType, index) { | ||
if (itemType == 'address') { | ||
paramValues[index] = address2HexString(itemType).replace(/^(41)/, '0x'); | ||
} | ||
}); | ||
parameter = coder.encode(paramTypes, paramValues).replace(/^(0x)/, ''); | ||
owner_address = address2HexString(owner_address); | ||
_context40.next = 11; | ||
return xhr.post(this.apiUrl + '/wallet/triggersmartcontract', { | ||
contract_address: contract_address, | ||
function_selector: function_selector, | ||
parameter: parameter, | ||
bandwidth_limit: bandwidth_limit, | ||
cpu_limit: cpu_limit, | ||
storage_limit: storage_limit, | ||
drop_limit: drop_limit, | ||
call_value: call_value, | ||
owner_address: owner_address | ||
}); | ||
case 11: | ||
_ref77 = _context40.sent; | ||
data = _ref77.data; | ||
return _context40.abrupt('return', data); | ||
case 14: | ||
case 'end': | ||
return _context40.stop(); | ||
} | ||
} | ||
}, _callee40, this); | ||
})); | ||
function triggerSmartContract(_x48) { | ||
return _ref76.apply(this, arguments); | ||
} | ||
return triggerSmartContract; | ||
}(); | ||
return FullNode; | ||
@@ -1515,0 +1661,0 @@ }(); |
@@ -6,2 +6,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import SolidityNode from './solidityNode'; | ||
import { BigNumber } from 'bignumber.js'; | ||
@@ -29,5 +30,5 @@ var TronWeb = function () { | ||
TronWeb.getFullNode = function getFullNode(apiUrl) { | ||
TronWeb.prototype.getFullNode = function getFullNode(apiUrl) { | ||
if (!this.fullNode) { | ||
this.fullNode = new FullNode(apiUrl); | ||
this.fullNode = new FullNode({ apiUrl: apiUrl }); | ||
} | ||
@@ -37,5 +38,5 @@ return this.fullNode; | ||
TronWeb.getSolidityNode = function getSolidityNode(apiUrl) { | ||
TronWeb.prototype.getSolidityNode = function getSolidityNode(apiUrl) { | ||
if (!this.solidityNode) { | ||
this.solidityNode = new SolidityNode(apiUrl); | ||
this.solidityNode = new SolidityNode({ apiUrl: apiUrl }); | ||
} | ||
@@ -45,2 +46,19 @@ return this.solidityNode; | ||
TronWeb.prototype.setHttpProvider = function setHttpProvider(fullNodeUrl, solidityNodeUrl) { | ||
/*if(!fullNodeUrl||!solidityNodeUrl){ | ||
return { | ||
fullNode:{}, | ||
solidityNode:{} | ||
} | ||
}*/ | ||
return { | ||
fullNode: this.getFullNode(fullNodeUrl), | ||
solidityNode: this.getSolidityNode(solidityNodeUrl) | ||
}; | ||
}; | ||
TronWeb.prototype.toBigNumber = function toBigNumber(str) { | ||
return BigNumber(str); | ||
}; | ||
return TronWeb; | ||
@@ -47,0 +65,0 @@ }(); |
@@ -15,3 +15,3 @@ import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
this.apiUrl = options.apiUrl; | ||
xhr.defaults.baseURL = this.apiUrl; | ||
//xhr.defaults.baseURL = this.apiUrl; | ||
} | ||
@@ -18,0 +18,0 @@ /** |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var _ethers = require('ethers'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,3 +33,3 @@ | ||
this.apiUrl = options.apiUrl; | ||
_axios2.default.defaults.baseURL = this.apiUrl; | ||
//xhr.defaults.baseURL = this.apiUrl; | ||
this.signer = null; | ||
@@ -127,3 +129,2 @@ } | ||
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(transaction, privateKey) { | ||
var txId; | ||
return _regenerator2.default.wrap(function _callee3$(_context3) { | ||
@@ -133,6 +134,5 @@ while (1) { | ||
case 0: | ||
txId = transaction.txID; | ||
return _context3.abrupt('return', (0, _crypto.signTransaction)(privateKey, transaction)); | ||
case 2: | ||
case 1: | ||
case 'end': | ||
@@ -1525,3 +1525,150 @@ return _context3.stop(); | ||
}(); | ||
/** | ||
* 部署合约 | ||
* @param | ||
* {string} abi, | ||
* {string} bytecode, | ||
* {int} bandwidth_limit 字节数, | ||
* {int} cpu_limit 微秒, | ||
* {int} storage_limit 字节数 | ||
* {int} drop_limit 最大消耗的Drop (1trx = 1000000drop) | ||
* {int} call_value 本次调用网合约转账的Drop (1trx = 1000000drop) | ||
* {string hexString} owner_address 发起部署合约的账户地址 | ||
* @return {object transction} | ||
* */ | ||
FullNode.prototype.deployContract = function () { | ||
var _ref72 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee38(options) { | ||
var abi, bytecode, bandwidth_limit, cpu_limit, storage_limit, drop_limit, call_value, owner_address, _ref73, data; | ||
return _regenerator2.default.wrap(function _callee38$(_context38) { | ||
while (1) { | ||
switch (_context38.prev = _context38.next) { | ||
case 0: | ||
abi = options.abi, bytecode = options.bytecode, bandwidth_limit = options.bandwidth_limit, cpu_limit = options.cpu_limit, storage_limit = options.storage_limit, drop_limit = options.drop_limit, call_value = options.call_value, owner_address = options.owner_address; | ||
owner_address = (0, _help.address2HexString)(owner_address); | ||
_context38.next = 4; | ||
return _axios2.default.post(this.apiUrl + '/wallet/deploycontract', { | ||
abi: abi, | ||
bytecode: bytecode, | ||
bandwidth_limit: bandwidth_limit, | ||
cpu_limit: cpu_limit, | ||
storage_limit: storage_limit, | ||
drop_limit: drop_limit, | ||
call_value: call_value, | ||
owner_address: owner_address | ||
}); | ||
case 4: | ||
_ref73 = _context38.sent; | ||
data = _ref73.data; | ||
return _context38.abrupt('return', data); | ||
case 7: | ||
case 'end': | ||
return _context38.stop(); | ||
} | ||
} | ||
}, _callee38, this); | ||
})); | ||
function deployContract(_x46) { | ||
return _ref72.apply(this, arguments); | ||
} | ||
return deployContract; | ||
}(); | ||
FullNode.prototype.getContract = function () { | ||
var _ref74 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee39(contractAddress) { | ||
var _ref75, data; | ||
return _regenerator2.default.wrap(function _callee39$(_context39) { | ||
while (1) { | ||
switch (_context39.prev = _context39.next) { | ||
case 0: | ||
_context39.next = 2; | ||
return _axios2.default.post(this.apiUrl + '/wallet/getcontract', { | ||
value: (0, _help.address2HexString)(contractAddress) | ||
}); | ||
case 2: | ||
_ref75 = _context39.sent; | ||
data = _ref75.data; | ||
return _context39.abrupt('return', data); | ||
case 5: | ||
case 'end': | ||
return _context39.stop(); | ||
} | ||
} | ||
}, _callee39, this); | ||
})); | ||
function getContract(_x47) { | ||
return _ref74.apply(this, arguments); | ||
} | ||
return getContract; | ||
}(); | ||
FullNode.prototype.triggerSmartContract = function () { | ||
var _ref76 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee40(options) { | ||
var coder, contract_address, function_selector, parameter, bandwidth_limit, cpu_limit, storage_limit, drop_limit, call_value, owner_address, paramTypes, paramValues, _ref77, data; | ||
return _regenerator2.default.wrap(function _callee40$(_context40) { | ||
while (1) { | ||
switch (_context40.prev = _context40.next) { | ||
case 0: | ||
coder = new _ethers.utils.AbiCoder(); | ||
contract_address = options.contract_address, function_selector = options.function_selector, parameter = options.parameter, bandwidth_limit = options.bandwidth_limit, cpu_limit = options.cpu_limit, storage_limit = options.storage_limit, drop_limit = options.drop_limit, call_value = options.call_value, owner_address = options.owner_address; | ||
contract_address = (0, _help.address2HexString)(contract_address); | ||
function_selector = function_selector.replace(/\s*/g, ''); | ||
paramTypes = parameter[0]; | ||
paramValues = parameter[1]; | ||
paramTypes.forEach(function (itemType, index) { | ||
if (itemType == 'address') { | ||
paramValues[index] = (0, _help.address2HexString)(itemType).replace(/^(41)/, '0x'); | ||
} | ||
}); | ||
parameter = coder.encode(paramTypes, paramValues).replace(/^(0x)/, ''); | ||
owner_address = (0, _help.address2HexString)(owner_address); | ||
_context40.next = 11; | ||
return _axios2.default.post(this.apiUrl + '/wallet/triggersmartcontract', { | ||
contract_address: contract_address, | ||
function_selector: function_selector, | ||
parameter: parameter, | ||
bandwidth_limit: bandwidth_limit, | ||
cpu_limit: cpu_limit, | ||
storage_limit: storage_limit, | ||
drop_limit: drop_limit, | ||
call_value: call_value, | ||
owner_address: owner_address | ||
}); | ||
case 11: | ||
_ref77 = _context40.sent; | ||
data = _ref77.data; | ||
return _context40.abrupt('return', data); | ||
case 14: | ||
case 'end': | ||
return _context40.stop(); | ||
} | ||
} | ||
}, _callee40, this); | ||
})); | ||
function triggerSmartContract(_x48) { | ||
return _ref76.apply(this, arguments); | ||
} | ||
return triggerSmartContract; | ||
}(); | ||
return FullNode; | ||
@@ -1528,0 +1675,0 @@ }(); |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _bignumber = require('bignumber.js'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,5 +43,5 @@ | ||
TronWeb.getFullNode = function getFullNode(apiUrl) { | ||
TronWeb.prototype.getFullNode = function getFullNode(apiUrl) { | ||
if (!this.fullNode) { | ||
this.fullNode = new _fullNode2.default(apiUrl); | ||
this.fullNode = new _fullNode2.default({ apiUrl: apiUrl }); | ||
} | ||
@@ -49,5 +51,5 @@ return this.fullNode; | ||
TronWeb.getSolidityNode = function getSolidityNode(apiUrl) { | ||
TronWeb.prototype.getSolidityNode = function getSolidityNode(apiUrl) { | ||
if (!this.solidityNode) { | ||
this.solidityNode = new _solidityNode2.default(apiUrl); | ||
this.solidityNode = new _solidityNode2.default({ apiUrl: apiUrl }); | ||
} | ||
@@ -57,2 +59,19 @@ return this.solidityNode; | ||
TronWeb.prototype.setHttpProvider = function setHttpProvider(fullNodeUrl, solidityNodeUrl) { | ||
/*if(!fullNodeUrl||!solidityNodeUrl){ | ||
return { | ||
fullNode:{}, | ||
solidityNode:{} | ||
} | ||
}*/ | ||
return { | ||
fullNode: this.getFullNode(fullNodeUrl), | ||
solidityNode: this.getSolidityNode(solidityNodeUrl) | ||
}; | ||
}; | ||
TronWeb.prototype.toBigNumber = function toBigNumber(str) { | ||
return (0, _bignumber.BigNumber)(str); | ||
}; | ||
return TronWeb; | ||
@@ -59,0 +78,0 @@ }(); |
@@ -26,3 +26,3 @@ 'use strict'; | ||
this.apiUrl = options.apiUrl; | ||
_axios2.default.defaults.baseURL = this.apiUrl; | ||
//xhr.defaults.baseURL = this.apiUrl; | ||
} | ||
@@ -29,0 +29,0 @@ /** |
{ | ||
"name": "tronweb", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A jssdk that encapsulates the TRON HTTP request", | ||
@@ -18,2 +18,4 @@ "main": "lib/index.js", | ||
"axios": "^0.18.0", | ||
"bignumber.js": "^7.2.1", | ||
"ethers": "^3.0.26", | ||
"js-sha3": "^0.7.0" | ||
@@ -20,0 +22,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3415418
41336
4
1
+ Addedbignumber.js@^7.2.1
+ Addedethers@^3.0.26
+ Addedaes-js@3.0.0(transitive)
+ Addedbignumber.js@7.2.1(transitive)
+ Addedbn.js@4.12.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedelliptic@6.3.3(transitive)
+ Addedethers@3.0.29(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedinherits@2.0.12.0.4(transitive)
+ Addedjs-sha3@0.5.7(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedscrypt-js@2.0.3(transitive)
+ Addedsetimmediate@1.0.4(transitive)
+ Addeduuid@2.0.1(transitive)
+ Addedxmlhttprequest@1.8.0(transitive)