web3-eth-accounts
Advanced tools
Comparing version 1.0.0-beta.11 to 1.0.0-beta.12
{ | ||
"name": "web3-eth-accounts", | ||
"version": "1.0.0-beta.11", | ||
"version": "1.0.0-beta.12", | ||
"description": "Web3 module to generate Ethereum accounts and sign data and transactions.", | ||
@@ -14,5 +14,7 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-eth-accounts", | ||
"uuid": "2.0.1", | ||
"web3-core-helpers": "^1.0.0-beta.11", | ||
"web3-utils": "^1.0.0-beta.11" | ||
"web3-core": "^1.0.0-beta.12", | ||
"web3-core-helpers": "^1.0.0-beta.12", | ||
"web3-core-method": "^1.0.0-beta.12", | ||
"web3-utils": "^1.0.0-beta.12" | ||
} | ||
} |
@@ -32,8 +32,5 @@ # web3-eth-accounts | ||
// in node.js | ||
var Eth = require('web3-eth'); | ||
var Web3EthAccounts = require('web3-eth-accounts'); | ||
var eth = new Eth('ws://localhost:8546'); | ||
var account = new Web3EthAccounts(eth); | ||
var account = new Web3EthAccounts('ws://localhost:8546'); | ||
account.create(); | ||
@@ -40,0 +37,0 @@ > { |
@@ -26,2 +26,4 @@ /* | ||
var _ = require("underscore"); | ||
var core = require('web3-core'); | ||
var Method = require('web3-core-method'); | ||
var Promise = require('bluebird'); | ||
@@ -41,7 +43,45 @@ var Account = require("eth-lib/src/account"); | ||
var Accounts = function Accounts(eth) { | ||
var Accounts = function Accounts() { | ||
var _this = this; | ||
if (eth) { | ||
this.eth = (eth.eth) ? eth.eth : eth; | ||
} | ||
// sets _requestmanager | ||
core.packageInit(this, arguments); | ||
// remove unecessary core functions | ||
delete this.BatchRequest; | ||
delete this.extend; | ||
var _ethereumCall = [ | ||
new Method({ | ||
name: 'getId', | ||
call: 'net_version', | ||
params: 0, | ||
outputFormatter: utils.hexToNumber | ||
}), | ||
new Method({ | ||
name: 'getGasPrice', | ||
call: 'eth_gasPrice', | ||
params: 0 | ||
}), | ||
new Method({ | ||
name: 'getTransactionCount', | ||
call: 'eth_getTransactionCount', | ||
params: 2, | ||
inputFormatter: [function (address) { | ||
if (utils.isAddress(address)) { | ||
return address; | ||
} else { | ||
throw new Error('Address '+ address +' is not a valid address to get the "transactionCount".'); | ||
} | ||
}, function () { return 'latest'; }] | ||
}) | ||
]; | ||
// attach methods to this._ethereumCall | ||
this._ethereumCall = {}; | ||
_.each(_ethereumCall, function (method) { | ||
method.attachToObject(_this._ethereumCall); | ||
method.setRequestManager(_this._requestManager); | ||
}); | ||
this.wallet = new Wallet(this); | ||
@@ -119,11 +159,8 @@ }; | ||
if (!_this || !_this.eth || !_this.eth.net) { | ||
return Promise.reject(new Error('The Eth package is set bound. Please set using "accounts.eth = eth", or provide "nonce", "chainId" and "gasPrice" in the transaction yourself.')); | ||
} | ||
// Otherwise, get the missing info from the Ethereum Node | ||
return Promise.all([ | ||
isNot(tx.chainId) ? _this.eth.net.getId() : tx.chainId, | ||
isNot(tx.gasPrice) ? _this.eth.getGasPrice() : tx.gasPrice, | ||
isNot(tx.nonce) ? _this.eth.getTransactionCount(_this.privateKeyToAccount(privateKey).address) : tx.nonce | ||
isNot(tx.chainId) ? _this._ethereumCall.getId() : tx.chainId, | ||
isNot(tx.gasPrice) ? _this._ethereumCall.getGasPrice() : tx.gasPrice, | ||
isNot(tx.nonce) ? _this._ethereumCall.getTransactionCount(_this.privateKeyToAccount(privateKey).address) : tx.nonce | ||
]).then(function (args) { | ||
@@ -130,0 +167,0 @@ if (isNot(args[0]) || isNot(args[1]) || isNot(args[2])) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15059
346
9
50
+ Addedweb3-core@^1.0.0-beta.12
+ Added@ethersproject/address@5.7.0(transitive)
+ Added@ethersproject/bignumber@5.7.0(transitive)
+ Added@ethersproject/bytes@5.7.0(transitive)
+ Added@ethersproject/constants@5.7.0(transitive)
+ Added@ethersproject/keccak256@5.7.0(transitive)
+ Added@ethersproject/logger@5.7.0(transitive)
+ Added@ethersproject/properties@5.7.0(transitive)
+ Added@ethersproject/rlp@5.7.0(transitive)
+ Added@ethersproject/signing-key@5.7.0(transitive)
+ Added@ethersproject/transactions@5.7.0(transitive)
+ Added@types/bn.js@5.1.6(transitive)
+ Added@types/node@12.20.55(transitive)
+ Addedabortcontroller-polyfill@1.7.6(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addedbufferutil@4.0.8(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcross-fetch@4.0.0(transitive)
+ Addedd@1.0.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedelliptic@6.5.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedeventemitter3@4.0.4(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-https@1.0.0(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedjs-sha3@0.8.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addednode-gyp-build@4.8.2(transitive)
+ Addedoboe@2.1.5(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtype@2.7.3(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedutf-8-validate@5.0.10(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedweb3-core@1.10.4(transitive)
+ Addedweb3-core-method@1.10.4(transitive)
+ Addedweb3-core-promievent@1.10.4(transitive)
+ Addedweb3-core-requestmanager@1.10.4(transitive)
+ Addedweb3-core-subscriptions@1.10.4(transitive)
+ Addedweb3-providers-http@1.10.4(transitive)
+ Addedweb3-providers-ipc@1.10.4(transitive)
+ Addedweb3-providers-ws@1.10.4(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwebsocket@1.0.35(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
+ Addedyaeti@0.0.6(transitive)
Updatedweb3-utils@^1.0.0-beta.12