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

@ethereumjs/block

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/block - npm Package Compare versions

Comparing version 4.2.1 to 4.2.2

3

dist/block.d.ts
/// <reference types="node" />
import { Trie } from '@ethereumjs/trie';
import { Withdrawal } from '@ethereumjs/util';
import { ethers } from 'ethers';
import { BlockHeader } from './header';

@@ -72,3 +71,3 @@ import type { BlockBuffer, BlockData, BlockOptions, JsonBlock, JsonRpcBlock } from './types';

*/
static fromEthersProvider: (provider: ethers.providers.JsonRpcProvider | string, blockTag: string | bigint, opts: BlockOptions) => Promise<Block>;
static fromEthersProvider: (provider: any, blockTag: string | bigint, opts: BlockOptions) => Promise<Block>;
/**

@@ -75,0 +74,0 @@ * This constructor takes the values, validates them, assigns them and freezes the object.

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

const keccak_1 = require("ethereum-cryptography/keccak");
const ethers_1 = require("ethers");
const from_rpc_1 = require("./from-rpc");

@@ -148,2 +147,7 @@ const header_1 = require("./header");

}
if (opts?.common !== undefined &&
opts?.common?.isActivatedEIP(4895) &&
(values[3] === undefined || !Array.isArray(values[3]))) {
throw new Error('Invalid serialized block input: EIP-4895 is active, and no withdrawals were provided as array');
}
const [headerData, txsData, uhsData, withdrawalsBuffer] = values;

@@ -459,8 +463,14 @@ const header = header_1.BlockHeader.fromValuesArray(headerData, opts);

let blockData;
const prov = typeof provider === 'string' ? new ethers_1.ethers.providers.JsonRpcProvider(provider) : provider;
const providerUrl = (0, util_1.getProvider)(provider);
if (typeof blockTag === 'string' && blockTag.length === 66) {
blockData = await prov.send('eth_getBlockByHash', [blockTag, true]);
blockData = await (0, util_1.fetchFromProvider)(providerUrl, {
method: 'eth_getBlockByHash',
params: [blockTag, true],
});
}
else if (typeof blockTag === 'bigint') {
blockData = await prov.send('eth_getBlockByNumber', [(0, util_1.bigIntToHex)(blockTag), true]);
blockData = await (0, util_1.fetchFromProvider)(providerUrl, {
method: 'eth_getBlockByNumber',
params: [(0, util_1.bigIntToHex)(blockTag), true],
});
}

@@ -471,3 +481,6 @@ else if ((0, util_1.isHexPrefixed)(blockTag) ||

blockTag === 'pending') {
blockData = await prov.send('eth_getBlockByNumber', [blockTag, true]);
blockData = await (0, util_1.fetchFromProvider)(providerUrl, {
method: 'eth_getBlockByNumber',
params: [blockTag, true],
});
}

@@ -477,9 +490,12 @@ else {

}
if (blockData === null) {
throw new Error('No block data returned from provider');
}
const uncleHeaders = [];
if (blockData.uncles.length > 0) {
for (let x = 0; x < blockData.uncles.length; x++) {
const headerData = await prov.send('eth_getUncleByBlockHashAndIndex', [
blockData.hash,
(0, util_1.intToHex)(x),
]);
const headerData = await (0, util_1.fetchFromProvider)(providerUrl, {
method: 'eth_getUncleByBlockHashAndIndex',
params: [blockData.hash, (0, util_1.intToHex)(x)],
});
uncleHeaders.push(headerData);

@@ -486,0 +502,0 @@ }

@@ -41,5 +41,5 @@ "use strict";

const uncleHeaders = uncles.map((uh) => (0, header_from_rpc_1.blockHeaderFromRpc)(uh, options));
return index_1.Block.fromBlockData({ header, transactions, uncleHeaders }, options);
return index_1.Block.fromBlockData({ header, transactions, uncleHeaders, withdrawals: blockParams.withdrawals }, options);
}
exports.blockFromRpc = blockFromRpc;
//# sourceMappingURL=from-rpc.js.map

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

function blockHeaderFromRpc(blockParams, options) {
const { parentHash, sha3Uncles, miner, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, } = blockParams;
const { parentHash, sha3Uncles, miner, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot, } = blockParams;
const blockHeader = header_1.BlockHeader.fromHeaderData({

@@ -32,2 +32,3 @@ parentHash,

baseFeePerGas,
withdrawalsRoot,
}, options);

@@ -34,0 +35,0 @@ return blockHeader;

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

withdrawals?: Array<JsonRpcWithdrawal>;
withdrawalsRoot?: string;
excessDataGas?: string;
}
//# sourceMappingURL=types.d.ts.map
{
"name": "@ethereumjs/block",
"version": "4.2.1",
"version": "4.2.2",
"description": "Provides Block serialization and help functions",

@@ -41,13 +41,13 @@ "keywords": [

"dependencies": {
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/common": "^3.1.2",
"@ethereumjs/rlp": "^4.0.1",
"@ethereumjs/trie": "^5.0.4",
"@ethereumjs/tx": "^4.1.1",
"@ethereumjs/util": "^8.0.5",
"ethereum-cryptography": "^1.1.2",
"ethers": "^5.7.1"
"@ethereumjs/trie": "^5.0.5",
"@ethereumjs/tx": "^4.1.2",
"@ethereumjs/util": "^8.0.6",
"ethereum-cryptography": "^2.0.0"
},
"devDependencies": {
"@types/lru-cache": "^5.1.0",
"c-kzg": "^1.0.8"
"c-kzg": "^1.0.8",
"testdouble": "^3.17.2"
},

@@ -54,0 +54,0 @@ "engines": {

@@ -12,2 +12,4 @@ import { ConsensusType } from '@ethereumjs/common'

bufferToHex,
fetchFromProvider,
getProvider,
intToHex,

@@ -18,3 +20,2 @@ isHexPrefixed,

import { keccak256 } from 'ethereum-cryptography/keccak'
import { ethers } from 'ethers'

@@ -158,2 +159,12 @@ import { blockFromRpc } from './from-rpc'

}
if (
opts?.common !== undefined &&
opts?.common?.isActivatedEIP(4895) &&
(values[3] === undefined || !Array.isArray(values[3]))
) {
throw new Error(
'Invalid serialized block input: EIP-4895 is active, and no withdrawals were provided as array'
)
}
const [headerData, txsData, uhsData, withdrawalsBuffer] = values

@@ -226,3 +237,3 @@

public static fromEthersProvider = async (
provider: ethers.providers.JsonRpcProvider | string,
provider: any,
blockTag: string | bigint,

@@ -232,8 +243,14 @@ opts: BlockOptions

let blockData
const prov =
typeof provider === 'string' ? new ethers.providers.JsonRpcProvider(provider) : provider
const providerUrl = getProvider(provider)
if (typeof blockTag === 'string' && blockTag.length === 66) {
blockData = await prov.send('eth_getBlockByHash', [blockTag, true])
blockData = await fetchFromProvider(providerUrl, {
method: 'eth_getBlockByHash',
params: [blockTag, true],
})
} else if (typeof blockTag === 'bigint') {
blockData = await prov.send('eth_getBlockByNumber', [bigIntToHex(blockTag), true])
blockData = await fetchFromProvider(providerUrl, {
method: 'eth_getBlockByNumber',
params: [bigIntToHex(blockTag), true],
})
} else if (

@@ -245,3 +262,6 @@ isHexPrefixed(blockTag) ||

) {
blockData = await prov.send('eth_getBlockByNumber', [blockTag, true])
blockData = await fetchFromProvider(providerUrl, {
method: 'eth_getBlockByNumber',
params: [blockTag, true],
})
} else {

@@ -253,9 +273,13 @@ throw new Error(

if (blockData === null) {
throw new Error('No block data returned from provider')
}
const uncleHeaders = []
if (blockData.uncles.length > 0) {
for (let x = 0; x < blockData.uncles.length; x++) {
const headerData = await prov.send('eth_getUncleByBlockHashAndIndex', [
blockData.hash,
intToHex(x),
])
const headerData = await fetchFromProvider(providerUrl, {
method: 'eth_getUncleByBlockHashAndIndex',
params: [blockData.hash, intToHex(x)],
})
uncleHeaders.push(headerData)

@@ -262,0 +286,0 @@ }

@@ -57,3 +57,6 @@ import { TransactionFactory } from '@ethereumjs/tx'

return Block.fromBlockData({ header, transactions, uncleHeaders }, options)
return Block.fromBlockData(
{ header, transactions, uncleHeaders, withdrawals: blockParams.withdrawals },
options
)
}

@@ -30,2 +30,3 @@ import { BlockHeader } from './header'

baseFeePerGas,
withdrawalsRoot,
} = blockParams

@@ -51,2 +52,3 @@

baseFeePerGas,
withdrawalsRoot,
},

@@ -53,0 +55,0 @@ options

@@ -199,3 +199,4 @@ import type { BlockHeader } from './header'

withdrawals?: Array<JsonRpcWithdrawal> // If EIP-4895 is enabled for this block, array of withdrawals
withdrawalsRoot?: string // If EIP-4895 is enabled for this block, the root of the withdrawal trie of the block.
excessDataGas?: string // If EIP-4844 is enabled for this block, returns the excess data gas for the block
}

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