web3-eth-accounts
Advanced tools
Comparing version 4.1.3-dev.88b7e2e.0 to 4.1.3-dev.89711ab.0
@@ -90,3 +90,3 @@ "use strict"; | ||
try { | ||
privateKeyUint8Array = (0, web3_utils_1.isUint8Array)(data) ? (data) : (0, web3_utils_1.bytesToUint8Array)(data); | ||
privateKeyUint8Array = (0, web3_utils_1.isUint8Array)(data) ? data : (0, web3_utils_1.bytesToUint8Array)(data); | ||
} | ||
@@ -356,3 +356,2 @@ catch (_a) { | ||
exports.recover = recover; | ||
; | ||
/** | ||
@@ -359,0 +358,0 @@ * Get the ethereum Address from a private key |
@@ -5,3 +5,3 @@ import { Numbers } from 'web3-types'; | ||
import type { AccessListEIP2930TxData, AccessListEIP2930ValuesArray, FeeMarketEIP1559TxData, FeeMarketEIP1559ValuesArray, JsonTx, TxData, TxOptions, TxValuesArray } from './types.js'; | ||
import { Capability } from './types.js'; | ||
import { Capability, ECDSASignature } from './types.js'; | ||
import { Address } from './address.js'; | ||
@@ -194,3 +194,3 @@ interface TransactionCache { | ||
protected _getSharedErrorPostfix(): string; | ||
private _ecsign; | ||
protected _ecsign(msgHash: Uint8Array, privateKey: Uint8Array, chainId?: bigint): ECDSASignature; | ||
static fromSerializedTx(serialized: Uint8Array, opts?: TxOptions): any; | ||
@@ -197,0 +197,0 @@ static fromTxData(txData: any, opts?: TxOptions): any; |
@@ -87,3 +87,3 @@ /* | ||
try { | ||
privateKeyUint8Array = isUint8Array(data) ? (data) : bytesToUint8Array(data); | ||
privateKeyUint8Array = isUint8Array(data) ? data : bytesToUint8Array(data); | ||
} | ||
@@ -347,3 +347,2 @@ catch (_a) { | ||
}; | ||
; | ||
/** | ||
@@ -350,0 +349,0 @@ * Get the ethereum Address from a private key |
@@ -5,3 +5,3 @@ import { Numbers } from 'web3-types'; | ||
import type { AccessListEIP2930TxData, AccessListEIP2930ValuesArray, FeeMarketEIP1559TxData, FeeMarketEIP1559ValuesArray, JsonTx, TxData, TxOptions, TxValuesArray } from './types.js'; | ||
import { Capability } from './types.js'; | ||
import { Capability, ECDSASignature } from './types.js'; | ||
import { Address } from './address.js'; | ||
@@ -194,3 +194,3 @@ interface TransactionCache { | ||
protected _getSharedErrorPostfix(): string; | ||
private _ecsign; | ||
protected _ecsign(msgHash: Uint8Array, privateKey: Uint8Array, chainId?: bigint): ECDSASignature; | ||
static fromSerializedTx(serialized: Uint8Array, opts?: TxOptions): any; | ||
@@ -197,0 +197,0 @@ static fromTxData(txData: any, opts?: TxOptions): any; |
{ | ||
"name": "web3-eth-accounts", | ||
"version": "4.1.3-dev.88b7e2e.0+88b7e2e", | ||
"version": "4.1.3-dev.89711ab.0+89711ab", | ||
"description": "Package for managing Ethereum accounts and signing", | ||
@@ -58,3 +58,3 @@ "main": "./lib/commonjs/index.js", | ||
"typescript": "^4.7.4", | ||
"web3-providers-ipc": "4.0.8-dev.88b7e2e.0+88b7e2e" | ||
"web3-providers-ipc": "4.0.8-dev.89711ab.0+89711ab" | ||
}, | ||
@@ -65,8 +65,8 @@ "dependencies": { | ||
"ethereum-cryptography": "^2.0.0", | ||
"web3-errors": "1.1.5-dev.88b7e2e.0+88b7e2e", | ||
"web3-types": "1.6.1-dev.88b7e2e.0+88b7e2e", | ||
"web3-utils": "4.2.4-dev.88b7e2e.0+88b7e2e", | ||
"web3-validator": "2.0.6-dev.88b7e2e.0+88b7e2e" | ||
"web3-errors": "1.2.1-dev.89711ab.0+89711ab", | ||
"web3-types": "1.7.1-dev.89711ab.0+89711ab", | ||
"web3-utils": "4.3.1-dev.89711ab.0+89711ab", | ||
"web3-validator": "2.0.7-dev.89711ab.0+89711ab" | ||
}, | ||
"gitHead": "88b7e2e22960898d69f7d35d1030edb37dc9d763" | ||
"gitHead": "89711ab7f6a63d910848807ee77f0a91497aa897" | ||
} |
@@ -20,25 +20,25 @@ /* | ||
* The web3 accounts package contains functions to generate Ethereum accounts and sign transactions & data. | ||
* | ||
* | ||
* For using accounts functions, first install Web3 package using `npm i web3` or `yarn add web3` based on your package manager usage. | ||
* After that, Accounts functions will be available as mentioned in following snippet. | ||
* After that, Accounts functions will be available as mentioned in following snippet. | ||
* ```ts | ||
* import {Web3} from 'web3'; | ||
* | ||
* | ||
* const web3 = new Web3(); | ||
* const account = web3.eth.accounts.create(); | ||
* const result = web3.eth.accounts.hashMessage("Test Message"); | ||
* | ||
* | ||
* ``` | ||
* | ||
* | ||
* For using individual package install `web3-eth-accounts` package using `npm i web3-eth-accounts` or `yarn add web3-eth-accounts` and only import required functions. | ||
* This is more efficient approach for building lightweight applications. | ||
* This is more efficient approach for building lightweight applications. | ||
* ```ts | ||
* import {create,hashMessage} from 'web3-eth-accounts'; | ||
* | ||
* | ||
* const account = create(); | ||
* const result = hashMessage("Test Message"); | ||
* | ||
* | ||
* ``` | ||
* @module Accounts | ||
* | ||
* | ||
*/ | ||
@@ -102,8 +102,7 @@ | ||
/** | ||
* Get the private key Uint8Array after the validation. | ||
* Note: This function is not exported through main web3 package, so for using it directly import from accounts package. | ||
* Note: This function is not exported through main web3 package, so for using it directly import from accounts package. | ||
* @param data - Private key | ||
* @param ignoreLength - Optional, ignore length check during validation | ||
* @param ignoreLength - Optional, ignore length check during validation | ||
* @returns The Uint8Array private key | ||
@@ -113,3 +112,3 @@ * | ||
* parseAndValidatePrivateKey("0x08c673022000ece7964ea4db2d9369c50442b2869cbd8fc21baaca59e18f642c") | ||
* | ||
* | ||
* > Uint8Array(32) [ | ||
@@ -121,3 +120,3 @@ * 186, 26, 143, 168, 235, 179, 90, 75, | ||
* ] | ||
* | ||
* | ||
* ``` | ||
@@ -134,3 +133,3 @@ */ | ||
try { | ||
privateKeyUint8Array = isUint8Array(data) ? (data ) : bytesToUint8Array(data); | ||
privateKeyUint8Array = isUint8Array(data) ? data : bytesToUint8Array(data); | ||
} catch { | ||
@@ -157,7 +156,7 @@ throw new InvalidPrivateKeyError(); | ||
* web3.eth.accounts.hashMessage("Hello world") | ||
* | ||
* | ||
* > "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede" | ||
* | ||
* | ||
* web3.eth.accounts.hashMessage(web3.utils.utf8ToHex("Hello world")) // Will be hex decoded in hashMessage | ||
* | ||
* | ||
* > "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede" | ||
@@ -237,3 +236,3 @@ * ``` | ||
* import {signTransaction, Transaction} from 'web3-eth-accounts'; | ||
* | ||
* | ||
* signTransaction(new Transaction({ | ||
@@ -248,3 +247,3 @@ * to: '0x118C2E5F57FD62C2B5b46a5ae9216F4FF4011a07', | ||
* '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318') | ||
* | ||
* | ||
* > { | ||
@@ -258,7 +257,7 @@ * messageHash: '0x28b7b75f7ba48d588a902c1ff4d5d13cc0ca9ac0aaa39562368146923fb853bf', | ||
* ``` | ||
* | ||
* | ||
* Signing an eip 1559 transaction | ||
* ```ts | ||
* import {signTransaction, Transaction} from 'web3-eth-accounts'; | ||
* | ||
* | ||
* signTransaction(new Transaction({ | ||
@@ -283,7 +282,7 @@ * to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', | ||
* ``` | ||
* | ||
* | ||
* Signing an eip 2930 transaction | ||
* ```ts | ||
* import {signTransaction, Transaction} from 'web3-eth-accounts'; | ||
* | ||
* | ||
* signTransaction(new Transaction ({ | ||
@@ -307,3 +306,3 @@ * chainId: 1, | ||
* }),"0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318") | ||
* | ||
* | ||
* > { | ||
@@ -380,7 +379,7 @@ * messageHash: '0xc55ea24bdb4c379550a7c9a6818ac39ca33e75bc78ddb862bd82c31cc1c7a073', | ||
* @returns The Ethereum address used to sign this data | ||
* | ||
* | ||
* ```ts | ||
* const data = 'Some data'; | ||
* const sigObj = web3.eth.accounts.sign(data, '0xbe6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728') | ||
* | ||
* | ||
* > { | ||
@@ -394,6 +393,6 @@ * message: 'Some data', | ||
* } | ||
* | ||
* | ||
* // now recover | ||
* web3.eth.accounts.recover(data, sigObj.v, sigObj.r, sigObj.s) | ||
* | ||
* | ||
* > 0xEB014f8c8B418Db6b45774c326A0E64C78914dC0 | ||
@@ -438,3 +437,3 @@ * ``` | ||
return address; | ||
};; | ||
}; | ||
@@ -450,3 +449,3 @@ /** | ||
* web3.eth.accounts.privateKeyToAddress("0xbe6383dad004f233317e46ddb46ad31b16064d14447a95cc1d8c8d4bc61c3728") | ||
* | ||
* | ||
* > "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0" | ||
@@ -480,3 +479,3 @@ * ``` | ||
* web3.eth.accounts.privateKeyToPublicKey("0x1e046a882bb38236b646c9f135cf90ad90a140810f439875f2a6dd8e50fa261f", true) | ||
* | ||
* | ||
* > "0x42beb65f179720abaa3ec9a70a539629cbbc5ec65bb57e7fc78977796837e537662dd17042e6449dc843c281067a4d6d8d1a1775a13c41901670d5de7ee6503a" // uncompressed public key | ||
@@ -504,3 +503,3 @@ * ``` | ||
* ```ts | ||
* | ||
* | ||
* web3.eth.accounts.encrypt( | ||
@@ -679,3 +678,3 @@ * '0x67f476289210e3bef3c1c75e4de993ff0a00663df00def84e73aa7411eac18a6', | ||
* web3.eth.accounts.privateKeyToAccount("0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709"); | ||
* | ||
* | ||
* > { | ||
@@ -761,4 +760,4 @@ * address: '0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01', | ||
* }, '123').then(console.log); | ||
* | ||
* | ||
* | ||
* | ||
* > { | ||
@@ -765,0 +764,0 @@ * address: '0xcdA9A91875fc35c8Ac1320E098e584495d66e47c', |
@@ -581,3 +581,7 @@ /* | ||
// eslint-disable-next-line class-methods-use-this | ||
private _ecsign(msgHash: Uint8Array, privateKey: Uint8Array, chainId?: bigint): ECDSASignature { | ||
protected _ecsign( | ||
msgHash: Uint8Array, | ||
privateKey: Uint8Array, | ||
chainId?: bigint, | ||
): ECDSASignature { | ||
const signature = secp256k1.sign(msgHash, privateKey); | ||
@@ -584,0 +588,0 @@ const signatureBytes = signature.toCompactRawBytes(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
1352636
29194