Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eth-sdk/key

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eth-sdk/key - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

3

build/Key.d.ts

@@ -6,2 +6,3 @@ import { IQuery, WithQuery, queryProviders } from '@eth-sdk/query';

private static DEFAULT_HD_PATH;
private nonce;
static createRandom(query?: IQuery): Key;

@@ -35,4 +36,4 @@ static createLocalKeyFromMnemonic(mnemonic: string, query?: IQuery, options?: Key.IFromMnemonicOptionsSingle): Key;

nonce?: TQuantity;
gas?: TQuantity;
gasPrice?: TQuantity;
gasLimit?: TQuantity;
to: string;

@@ -39,0 +40,0 @@ value?: TQuantity;

@@ -20,2 +20,3 @@ "use strict";

const ethereumjs_tx_1 = require("ethereumjs-tx");
const ethereumjs_common_1 = __importDefault(require("ethereumjs-common"));
class Key extends query_1.WithQuery {

@@ -25,2 +26,3 @@ constructor(privateKey = null, query = null) {

this.privateKey = privateKey;
this.nonce = null;
this.type = null;

@@ -87,19 +89,40 @@ if (privateKey) {

const { to, value, data, } = options;
let { nonce, gasPrice, gasLimit, } = options;
let { nonce, gasPrice, gas, } = options;
if (!nonce) {
nonce = yield this.query.eth.getTransactionCount(yield this.address, 'pending');
if (this.nonce !== null && this.nonce >= nonce) {
nonce = this.nonce + 1;
}
this.nonce = nonce;
}
else {
this.nonce = utils_1.toNumber(nonce);
}
if (!gasPrice) {
gasPrice = yield this.query.eth.gasPrice;
}
if (!gasLimit) {
gasLimit = 21000;
if (!gas) {
gas = 21000;
}
const chainId = yield this.query.net.version;
let common = null;
try {
common = new ethereumjs_common_1.default(chainId);
}
catch (err) {
common = ethereumjs_common_1.default.forCustomChain(1, {
chainId,
networkId: chainId,
comment: 'Custom chain',
}, 'petersburg');
}
const transaction = new ethereumjs_tx_1.Transaction({
to,
nonce: utils_1.toHex(nonce, '0x00', true),
gasLimit: utils_1.toHex(gas, '0x00', true),
gasPrice: utils_1.toHex(gasPrice, '0x00', true),
gasLimit: utils_1.toHex(gasLimit, '0x00', true),
value: utils_1.toHex(value, '0x00', true),
data: utils_1.toHex(data, '0x'),
}, {
common,
});

@@ -137,3 +160,3 @@ transaction.sign(utils_1.toBuffer(this.privateKey));

([options] = params);
const { from, to, data, value, nonce, gas: gasLimit, gasPrice, } = options;
const { from, to, data, value, nonce, gas, gasPrice, } = options;
if (from === (yield this.address)) {

@@ -145,3 +168,3 @@ const raw = yield this.signTransaction({

value,
gasLimit,
gas,
gasPrice,

@@ -148,0 +171,0 @@ });

{
"name": "@eth-sdk/key",
"version": "0.1.1",
"version": "0.1.2",
"description": "Eth sdk key",

@@ -30,7 +30,8 @@ "author": {

"dependencies": {
"@eth-sdk/query": "^0.1.1",
"@eth-sdk/utils": "^0.1.1",
"@eth-sdk/query": "^0.1.2",
"@eth-sdk/utils": "^0.1.2",
"@types/hdkey": "^0.7.1",
"@types/node": "^12.0.0",
"bip39": "^3.0.2",
"ethereumjs-common": "^1.3.2",
"ethereumjs-tx": "^2.1.1",

@@ -37,0 +38,0 @@ "hdkey": "^1.1.1"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc