Socket
Socket
Sign inDemoInstall

@ethereumjs/util

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/util - npm Package Compare versions

Comparing version 8.0.3 to 8.0.4

dist/ssz.d.ts

4

dist/account.d.ts

@@ -123,5 +123,7 @@ /// <reference types="node" />

/**
* Converts a slim account RLP to a normal account RLP
* Converts a slim account (per snap protocol spec) to the RLP encoded version of the account
* @param body Array of 4 Buffer-like items to represent the account
* @returns RLP encoded version of the account
*/
export declare function accountBodyToRLP(body: AccountBodyBuffer, couldBeSlim?: boolean): Buffer;
//# sourceMappingURL=account.d.ts.map

@@ -311,3 +311,5 @@ "use strict";

/**
* Converts a slim account RLP to a normal account RLP
* Converts a slim account (per snap protocol spec) to the RLP encoded version of the account
* @param body Array of 4 Buffer-like items to represent the account
* @returns RLP encoded version of the account
*/

@@ -314,0 +316,0 @@ function accountBodyToRLP(body, couldBeSlim = true) {

@@ -12,4 +12,32 @@ "use strict";

exports.AsyncEventEmitter = void 0;
const async_1 = require("async");
const events_1 = require("events");
async function runInSeries(context, tasks, data) {
let error;
for await (const task of tasks) {
try {
if (task.length < 2) {
//sync
task.call(context, data);
}
else {
await new Promise((resolve, reject) => {
task.call(context, data, (error) => {
if (error) {
reject(error);
}
else {
resolve();
}
});
});
}
}
catch (e) {
error = e;
}
}
if (error) {
throw error;
}
}
class AsyncEventEmitter extends events_1.EventEmitter {

@@ -35,17 +63,3 @@ emit(event, ...args) {

listeners = Array.isArray(listeners) ? listeners : [listeners];
(0, async_1.eachSeries)(listeners.slice(), function (fn, next) {
let err;
// Support synchronous functions
if (fn.length < 2) {
try {
fn.call(self, data);
}
catch (e) {
err = e;
}
return next(err);
}
// Async
fn.call(self, data, next);
}, callback);
runInSeries(self, listeners.slice(), data).then(callback).catch(callback);
return self.listenerCount(event) > 0;

@@ -52,0 +66,0 @@ }

@@ -13,2 +13,4 @@ /// <reference types="node" />

* The max integer that the evm can handle (2^256-1) as a bigint
* 2^256-1 equals to 340282366920938463463374607431768211455
* We use literal value instead of calculated value for compatibility issue.
*/

@@ -50,2 +52,3 @@ export declare const MAX_INTEGER_BIGINT: bigint;

export declare const RLP_EMPTY_STRING: Buffer;
export declare const MAX_WITHDRAWALS_PER_PAYLOAD = 16;
//# sourceMappingURL=constants.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RLP_EMPTY_STRING = exports.KECCAK256_RLP = exports.KECCAK256_RLP_S = exports.KECCAK256_RLP_ARRAY = exports.KECCAK256_RLP_ARRAY_S = exports.KECCAK256_NULL = exports.KECCAK256_NULL_S = exports.TWO_POW256 = exports.SECP256K1_ORDER_DIV_2 = exports.SECP256K1_ORDER = exports.MAX_INTEGER_BIGINT = exports.MAX_INTEGER = exports.MAX_UINT64 = void 0;
exports.MAX_WITHDRAWALS_PER_PAYLOAD = exports.RLP_EMPTY_STRING = exports.KECCAK256_RLP = exports.KECCAK256_RLP_S = exports.KECCAK256_RLP_ARRAY = exports.KECCAK256_RLP_ARRAY_S = exports.KECCAK256_NULL = exports.KECCAK256_NULL_S = exports.TWO_POW256 = exports.SECP256K1_ORDER_DIV_2 = exports.SECP256K1_ORDER = exports.MAX_INTEGER_BIGINT = exports.MAX_INTEGER = exports.MAX_UINT64 = void 0;
const buffer_1 = require("buffer");

@@ -16,4 +16,6 @@ const secp256k1_1 = require("ethereum-cryptography/secp256k1");

* The max integer that the evm can handle (2^256-1) as a bigint
* 2^256-1 equals to 340282366920938463463374607431768211455
* We use literal value instead of calculated value for compatibility issue.
*/
exports.MAX_INTEGER_BIGINT = BigInt(2) ** BigInt(256) - BigInt(1);
exports.MAX_INTEGER_BIGINT = BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935');
exports.SECP256K1_ORDER = secp256k1_1.CURVE.n;

@@ -53,2 +55,3 @@ exports.SECP256K1_ORDER_DIV_2 = secp256k1_1.CURVE.n / BigInt(2);

exports.RLP_EMPTY_STRING = buffer_1.Buffer.from([0x80]);
exports.MAX_WITHDRAWALS_PER_PAYLOAD = 16;
//# sourceMappingURL=constants.js.map

@@ -6,2 +6,6 @@ /**

/**
* Units helpers
*/
export * from './units';
/**
* Account class and helper functions

@@ -27,2 +31,6 @@ */

/**
* SSZ containers
*/
export * as ssz from './ssz';
/**
* Helpful TypeScript types

@@ -29,0 +37,0 @@ */

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.toAscii = exports.stripHexPrefix = exports.padToEven = exports.isHexString = exports.isHexPrefixed = exports.getKeys = exports.getBinarySize = exports.fromUtf8 = exports.fromAscii = exports.arrayContainsArray = void 0;
exports.toAscii = exports.stripHexPrefix = exports.padToEven = exports.isHexString = exports.isHexPrefixed = exports.getKeys = exports.getBinarySize = exports.fromUtf8 = exports.fromAscii = exports.arrayContainsArray = exports.ssz = void 0;
/**

@@ -24,2 +24,6 @@ * Constants

/**
* Units helpers
*/
__exportStar(require("./units"), exports);
/**
* Account class and helper functions

@@ -45,2 +49,6 @@ */

/**
* SSZ containers
*/
exports.ssz = require("./ssz");
/**
* Helpful TypeScript types

@@ -47,0 +55,0 @@ */

@@ -73,3 +73,3 @@ "use strict";

if (typeof str !== 'string') {
throw new Error(`[getBinarySize] method requires input type 'string', recieved ${typeof str}`);
throw new Error(`[getBinarySize] method requires input type 'string', received ${typeof str}`);
}

@@ -76,0 +76,0 @@ return Buffer.byteLength(str, 'utf8');

@@ -5,3 +5,4 @@ /// <reference types="node" />

/**
* Flexible input data type for EIP-4895 withdrawal data
* Flexible input data type for EIP-4895 withdrawal data with amount in Gwei to
* match CL representation and for eventual ssz withdrawalsRoot
*/

@@ -15,3 +16,4 @@ export declare type WithdrawalData = {

/**
* JSON RPC interface for EIP-4895 withdrawal data
* JSON RPC interface for EIP-4895 withdrawal data with amount in Gwei to
* match CL representation and for eventual ssz withdrawalsRoot
*/

@@ -32,2 +34,5 @@ export interface JsonRpcWithdrawal {

readonly address: Address;
/**
* withdrawal amount in Gwei to match the CL repesentation and eventually ssz withdrawalsRoot
*/
readonly amount: bigint;

@@ -37,4 +42,9 @@ /**

* Use the static factory methods to assist in creating a Withdrawal object from varying data types.
* Its amount is in Gwei to match CL representation and for eventual ssz withdrawalsRoot
*/
constructor(index: bigint, validatorIndex: bigint, address: Address, amount: bigint);
constructor(index: bigint, validatorIndex: bigint, address: Address,
/**
* withdrawal amount in Gwei to match the CL repesentation and eventually ssz withdrawalsRoot
*/
amount: bigint);
static fromWithdrawalData(withdrawalData: WithdrawalData): Withdrawal;

@@ -49,2 +59,8 @@ static fromValuesArray(withdrawalArray: WithdrawalBuffer): Withdrawal;

raw(): WithdrawalBuffer;
toValue(): {
index: bigint;
validatorIndex: bigint;
address: Buffer;
amount: bigint;
};
toJSON(): {

@@ -51,0 +67,0 @@ index: string;

@@ -14,4 +14,9 @@ "use strict";

* Use the static factory methods to assist in creating a Withdrawal object from varying data types.
* Its amount is in Gwei to match CL representation and for eventual ssz withdrawalsRoot
*/
constructor(index, validatorIndex, address, amount) {
constructor(index, validatorIndex, address,
/**
* withdrawal amount in Gwei to match the CL repesentation and eventually ssz withdrawalsRoot
*/
amount) {
this.index = index;

@@ -65,2 +70,10 @@ this.validatorIndex = validatorIndex;

}
toValue() {
return {
index: this.index,
validatorIndex: this.validatorIndex,
address: this.address.buf,
amount: this.amount,
};
}
toJSON() {

@@ -67,0 +80,0 @@ return {

{
"name": "@ethereumjs/util",
"version": "8.0.3",
"version": "8.0.4",
"description": "A collection of utility functions for Ethereum",

@@ -86,4 +86,4 @@ "keywords": [

"dependencies": {
"@ethereumjs/rlp": "^4.0.0-beta.2",
"async": "^3.2.4",
"@chainsafe/ssz": "^0.10.0",
"@ethereumjs/rlp": "^4.0.1",
"ethereum-cryptography": "^1.1.2"

@@ -90,0 +90,0 @@ },

@@ -56,2 +56,4 @@ # @ethereumjs/util

- Internalized helper methods
- [withdrawal](src/withdrawal.ts)
- Withdrawal class (EIP-4895)

@@ -58,0 +60,0 @@ ### BigInt Support

@@ -369,3 +369,5 @@ import { RLP } from '@ethereumjs/rlp'

/**
* Converts a slim account RLP to a normal account RLP
* Converts a slim account (per snap protocol spec) to the RLP encoded version of the account
* @param body Array of 4 Buffer-like items to represent the account
* @returns RLP encoded version of the account
*/

@@ -372,0 +374,0 @@ export function accountBodyToRLP(body: AccountBodyBuffer, couldBeSlim = true) {

@@ -10,3 +10,2 @@ /**

import { eachSeries } from 'async'
import { EventEmitter } from 'events'

@@ -20,2 +19,33 @@ type AsyncListener<T, R> =

async function runInSeries(
context: any,
tasks: Array<(data: unknown, callback?: (error?: Error) => void) => void>,
data: unknown
): Promise<void> {
let error: Error | undefined
for await (const task of tasks) {
try {
if (task.length < 2) {
//sync
task.call(context, data)
} else {
await new Promise<void>((resolve, reject) => {
task.call(context, data, (error) => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
}
} catch (e: unknown) {
error = e as Error
}
}
if (error) {
throw error
}
}
export class AsyncEventEmitter<T extends EventMap> extends EventEmitter {

@@ -46,25 +76,4 @@ emit<E extends keyof T>(event: E & string, ...args: Parameters<T[E]>) {

listeners = Array.isArray(listeners) ? listeners : [listeners]
runInSeries(self, listeners.slice(), data).then(callback).catch(callback)
eachSeries(
listeners.slice(),
function (fn: any, next) {
let err
// Support synchronous functions
if (fn.length < 2) {
try {
fn.call(self, data)
} catch (e: any) {
err = e
}
return next(err)
}
// Async
fn.call(self, data, next)
},
callback
)
return self.listenerCount(event) > 0

@@ -71,0 +80,0 @@ }

@@ -18,4 +18,8 @@ import { Buffer } from 'buffer'

* The max integer that the evm can handle (2^256-1) as a bigint
* 2^256-1 equals to 340282366920938463463374607431768211455
* We use literal value instead of calculated value for compatibility issue.
*/
export const MAX_INTEGER_BIGINT = BigInt(2) ** BigInt(256) - BigInt(1)
export const MAX_INTEGER_BIGINT = BigInt(
'115792089237316195423570985008687907853269984665640564039457584007913129639935'
)

@@ -67,1 +71,3 @@ export const SECP256K1_ORDER = CURVE.n

export const RLP_EMPTY_STRING = Buffer.from([0x80])
export const MAX_WITHDRAWALS_PER_PAYLOAD = 16

@@ -7,2 +7,7 @@ /**

/**
* Units helpers
*/
export * from './units'
/**
* Account class and helper functions

@@ -33,2 +38,7 @@ */

/**
* SSZ containers
*/
export * as ssz from './ssz'
/**
* Helpful TypeScript types

@@ -35,0 +45,0 @@ */

@@ -75,3 +75,3 @@ /*

if (typeof str !== 'string') {
throw new Error(`[getBinarySize] method requires input type 'string', recieved ${typeof str}`)
throw new Error(`[getBinarySize] method requires input type 'string', received ${typeof str}`)
}

@@ -78,0 +78,0 @@

@@ -8,3 +8,4 @@ import { Address } from './address'

/**
* Flexible input data type for EIP-4895 withdrawal data
* Flexible input data type for EIP-4895 withdrawal data with amount in Gwei to
* match CL representation and for eventual ssz withdrawalsRoot
*/

@@ -19,3 +20,4 @@ export type WithdrawalData = {

/**
* JSON RPC interface for EIP-4895 withdrawal data
* JSON RPC interface for EIP-4895 withdrawal data with amount in Gwei to
* match CL representation and for eventual ssz withdrawalsRoot
*/

@@ -26,3 +28,3 @@ export interface JsonRpcWithdrawal {

address: string // DATA, 20 Bytes address to withdraw to
amount: string // QUANTITY - bigint amount in wei 32 bytes
amount: string // QUANTITY - bigint amount in Gwei 8 bytes
}

@@ -39,2 +41,3 @@

* Use the static factory methods to assist in creating a Withdrawal object from varying data types.
* Its amount is in Gwei to match CL representation and for eventual ssz withdrawalsRoot
*/

@@ -45,2 +48,5 @@ constructor(

public readonly address: Address,
/**
* withdrawal amount in Gwei to match the CL repesentation and eventually ssz withdrawalsRoot
*/
public readonly amount: bigint

@@ -105,2 +111,11 @@ ) {}

toValue() {
return {
index: this.index,
validatorIndex: this.validatorIndex,
address: this.address.buf,
amount: this.amount,
}
}
toJSON() {

@@ -107,0 +122,0 @@ return {

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

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

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