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.0 to 8.0.1

dist/lock.d.ts

5

dist/account.d.ts

@@ -9,2 +9,3 @@ /// <reference types="node" />

}
export declare type AccountBodyBuffer = [Buffer, Buffer, Buffer | Uint8Array, Buffer | Uint8Array];
export declare class Account {

@@ -120,6 +121,8 @@ nonce: bigint;

export declare const isZeroAddress: (hexAddress: string) => boolean;
export declare function accountBodyFromSlim(body: AccountBodyBuffer): (Uint8Array | Buffer)[];
export declare function accountBodyToSlim(body: AccountBodyBuffer): (Uint8Array | Buffer)[];
/**
* Converts a slim account RLP to a normal account RLP
*/
export declare function convertSlimAccount(body: any): Buffer;
export declare function accountBodyToRLP(body: AccountBodyBuffer, couldBeSlim?: boolean): Buffer;
//# sourceMappingURL=account.d.ts.map

39

dist/account.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertSlimAccount = exports.isZeroAddress = exports.zeroAddress = exports.importPublic = exports.privateToAddress = exports.privateToPublic = exports.publicToAddress = exports.pubToAddress = exports.isValidPublic = exports.isValidPrivate = exports.generateAddress2 = exports.generateAddress = exports.isValidChecksumAddress = exports.toChecksumAddress = exports.isValidAddress = exports.Account = void 0;
exports.accountBodyToRLP = exports.accountBodyToSlim = exports.accountBodyFromSlim = exports.isZeroAddress = exports.zeroAddress = exports.importPublic = exports.privateToAddress = exports.privateToPublic = exports.publicToAddress = exports.pubToAddress = exports.isValidPublic = exports.isValidPrivate = exports.generateAddress2 = exports.generateAddress = exports.isValidChecksumAddress = exports.toChecksumAddress = exports.isValidAddress = exports.Account = void 0;
const rlp_1 = require("@ethereumjs/rlp");

@@ -289,18 +289,31 @@ const keccak_1 = require("ethereum-cryptography/keccak");

exports.isZeroAddress = isZeroAddress;
function accountBodyFromSlim(body) {
const [nonce, balance, storageRoot, codeHash] = body;
return [
nonce,
balance,
(0, bytes_1.arrToBufArr)(storageRoot).length === 0 ? constants_1.KECCAK256_RLP : storageRoot,
(0, bytes_1.arrToBufArr)(codeHash).length === 0 ? constants_1.KECCAK256_NULL : codeHash,
];
}
exports.accountBodyFromSlim = accountBodyFromSlim;
const emptyUint8Arr = new Uint8Array(0);
function accountBodyToSlim(body) {
const [nonce, balance, storageRoot, codeHash] = body;
return [
nonce,
balance,
(0, bytes_1.arrToBufArr)(storageRoot).equals(constants_1.KECCAK256_RLP) ? emptyUint8Arr : storageRoot,
(0, bytes_1.arrToBufArr)(codeHash).equals(constants_1.KECCAK256_NULL) ? emptyUint8Arr : codeHash,
];
}
exports.accountBodyToSlim = accountBodyToSlim;
/**
* Converts a slim account RLP to a normal account RLP
*/
function convertSlimAccount(body) {
const cpy = [body[0], body[1], body[2], body[3]];
if ((0, bytes_1.arrToBufArr)(body[2]).length === 0) {
// StorageRoot
cpy[2] = constants_1.KECCAK256_RLP;
}
if ((0, bytes_1.arrToBufArr)(body[3]).length === 0) {
// CodeHash
cpy[3] = constants_1.KECCAK256_NULL;
}
return (0, bytes_1.arrToBufArr)(rlp_1.RLP.encode(cpy));
function accountBodyToRLP(body, couldBeSlim = true) {
const accountBody = couldBeSlim ? accountBodyFromSlim(body) : body;
return (0, bytes_1.arrToBufArr)(rlp_1.RLP.encode(accountBody));
}
exports.convertSlimAccount = convertSlimAccount;
exports.accountBodyToRLP = accountBodyToRLP;
//# sourceMappingURL=account.js.map

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

export { arrayContainsArray, fromAscii, fromUtf8, getBinarySize, getKeys, isHexPrefixed, isHexString, padToEven, stripHexPrefix, toAscii, } from './internal';
export * from './lock';
//# sourceMappingURL=index.d.ts.map

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

Object.defineProperty(exports, "toAscii", { enumerable: true, get: function () { return internal_1.toAscii; } });
__exportStar(require("./lock"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@ethereumjs/util",
"version": "8.0.0",
"version": "8.0.1",
"description": "A collection of utility functions for Ethereum",

@@ -5,0 +5,0 @@ "keywords": [

@@ -30,2 +30,4 @@ import { RLP } from '@ethereumjs/rlp'

export type AccountBodyBuffer = [Buffer, Buffer, Buffer | Uint8Array, Buffer | Uint8Array]
export class Account {

@@ -346,16 +348,29 @@ nonce: bigint

export function accountBodyFromSlim(body: AccountBodyBuffer) {
const [nonce, balance, storageRoot, codeHash] = body
return [
nonce,
balance,
arrToBufArr(storageRoot).length === 0 ? KECCAK256_RLP : storageRoot,
arrToBufArr(codeHash).length === 0 ? KECCAK256_NULL : codeHash,
]
}
const emptyUint8Arr = new Uint8Array(0)
export function accountBodyToSlim(body: AccountBodyBuffer) {
const [nonce, balance, storageRoot, codeHash] = body
return [
nonce,
balance,
arrToBufArr(storageRoot).equals(KECCAK256_RLP) ? emptyUint8Arr : storageRoot,
arrToBufArr(codeHash).equals(KECCAK256_NULL) ? emptyUint8Arr : codeHash,
]
}
/**
* Converts a slim account RLP to a normal account RLP
*/
export function convertSlimAccount(body: any) {
const cpy = [body[0], body[1], body[2], body[3]]
if (arrToBufArr(body[2]).length === 0) {
// StorageRoot
cpy[2] = KECCAK256_RLP
}
if (arrToBufArr(body[3]).length === 0) {
// CodeHash
cpy[3] = KECCAK256_NULL
}
return arrToBufArr(RLP.encode(cpy))
export function accountBodyToRLP(body: AccountBodyBuffer, couldBeSlim = true) {
const accountBody = couldBeSlim ? accountBodyFromSlim(body) : body
return arrToBufArr(RLP.encode(accountBody))
}

@@ -46,1 +46,2 @@ /**

} from './internal'
export * from './lock'

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