@feelyourprotocol/block 8141.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +466 -0
- package/dist/cjs/block/block.d.ts +147 -0
- package/dist/cjs/block/block.d.ts.map +1 -0
- package/dist/cjs/block/block.js +415 -0
- package/dist/cjs/block/block.js.map +1 -0
- package/dist/cjs/block/constructors.d.ts +77 -0
- package/dist/cjs/block/constructors.d.ts.map +1 -0
- package/dist/cjs/block/constructors.js +298 -0
- package/dist/cjs/block/constructors.js.map +1 -0
- package/dist/cjs/block/index.d.ts +3 -0
- package/dist/cjs/block/index.d.ts.map +1 -0
- package/dist/cjs/block/index.js +19 -0
- package/dist/cjs/block/index.js.map +1 -0
- package/dist/cjs/consensus/clique.d.ts +52 -0
- package/dist/cjs/consensus/clique.d.ts.map +1 -0
- package/dist/cjs/consensus/clique.js +144 -0
- package/dist/cjs/consensus/clique.js.map +1 -0
- package/dist/cjs/consensus/ethash.d.ts +9 -0
- package/dist/cjs/consensus/ethash.d.ts.map +1 -0
- package/dist/cjs/consensus/ethash.js +13 -0
- package/dist/cjs/consensus/ethash.js.map +1 -0
- package/dist/cjs/consensus/index.d.ts +3 -0
- package/dist/cjs/consensus/index.d.ts.map +1 -0
- package/dist/cjs/consensus/index.js +29 -0
- package/dist/cjs/consensus/index.js.map +1 -0
- package/dist/cjs/from-beacon-payload.d.ts +36 -0
- package/dist/cjs/from-beacon-payload.d.ts.map +1 -0
- package/dist/cjs/from-beacon-payload.js +48 -0
- package/dist/cjs/from-beacon-payload.js.map +1 -0
- package/dist/cjs/header/constructors.d.ts +39 -0
- package/dist/cjs/header/constructors.d.ts.map +1 -0
- package/dist/cjs/header/constructors.js +127 -0
- package/dist/cjs/header/constructors.js.map +1 -0
- package/dist/cjs/header/header.d.ts +134 -0
- package/dist/cjs/header/header.d.ts.map +1 -0
- package/dist/cjs/header/header.js +699 -0
- package/dist/cjs/header/header.js.map +1 -0
- package/dist/cjs/header/index.d.ts +3 -0
- package/dist/cjs/header/index.d.ts.map +1 -0
- package/dist/cjs/header/index.js +19 -0
- package/dist/cjs/header/index.js.map +1 -0
- package/dist/cjs/helpers.d.ts +59 -0
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +172 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/params.d.ts +3 -0
- package/dist/cjs/params.d.ts.map +1 -0
- package/dist/cjs/params.js +97 -0
- package/dist/cjs/params.js.map +1 -0
- package/dist/cjs/types.d.ts +228 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/block/block.d.ts +147 -0
- package/dist/esm/block/block.d.ts.map +1 -0
- package/dist/esm/block/block.js +411 -0
- package/dist/esm/block/block.js.map +1 -0
- package/dist/esm/block/constructors.d.ts +77 -0
- package/dist/esm/block/constructors.d.ts.map +1 -0
- package/dist/esm/block/constructors.js +286 -0
- package/dist/esm/block/constructors.js.map +1 -0
- package/dist/esm/block/index.d.ts +3 -0
- package/dist/esm/block/index.d.ts.map +1 -0
- package/dist/esm/block/index.js +3 -0
- package/dist/esm/block/index.js.map +1 -0
- package/dist/esm/consensus/clique.d.ts +52 -0
- package/dist/esm/consensus/clique.d.ts.map +1 -0
- package/dist/esm/consensus/clique.js +132 -0
- package/dist/esm/consensus/clique.js.map +1 -0
- package/dist/esm/consensus/ethash.d.ts +9 -0
- package/dist/esm/consensus/ethash.d.ts.map +1 -0
- package/dist/esm/consensus/ethash.js +10 -0
- package/dist/esm/consensus/ethash.js.map +1 -0
- package/dist/esm/consensus/index.d.ts +3 -0
- package/dist/esm/consensus/index.d.ts.map +1 -0
- package/dist/esm/consensus/index.js +3 -0
- package/dist/esm/consensus/index.js.map +1 -0
- package/dist/esm/from-beacon-payload.d.ts +36 -0
- package/dist/esm/from-beacon-payload.d.ts.map +1 -0
- package/dist/esm/from-beacon-payload.js +45 -0
- package/dist/esm/from-beacon-payload.js.map +1 -0
- package/dist/esm/header/constructors.d.ts +39 -0
- package/dist/esm/header/constructors.d.ts.map +1 -0
- package/dist/esm/header/constructors.js +120 -0
- package/dist/esm/header/constructors.js.map +1 -0
- package/dist/esm/header/header.d.ts +134 -0
- package/dist/esm/header/header.d.ts.map +1 -0
- package/dist/esm/header/header.js +695 -0
- package/dist/esm/header/header.js.map +1 -0
- package/dist/esm/header/index.d.ts +3 -0
- package/dist/esm/header/index.d.ts.map +1 -0
- package/dist/esm/header/index.js +3 -0
- package/dist/esm/header/index.js.map +1 -0
- package/dist/esm/helpers.d.ts +59 -0
- package/dist/esm/helpers.d.ts.map +1 -0
- package/dist/esm/helpers.js +161 -0
- package/dist/esm/helpers.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/params.d.ts +3 -0
- package/dist/esm/params.d.ts.map +1 -0
- package/dist/esm/params.js +94 -0
- package/dist/esm/params.js.map +1 -0
- package/dist/esm/types.d.ts +228 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
- package/package.json +75 -0
- package/src/block/block.ts +526 -0
- package/src/block/constructors.ts +407 -0
- package/src/block/index.ts +2 -0
- package/src/consensus/clique.ts +171 -0
- package/src/consensus/ethash.ts +11 -0
- package/src/consensus/index.ts +12 -0
- package/src/from-beacon-payload.ts +82 -0
- package/src/header/constructors.ts +169 -0
- package/src/header/header.ts +890 -0
- package/src/header/index.ts +2 -0
- package/src/helpers.ts +223 -0
- package/src/index.ts +13 -0
- package/src/params.ts +95 -0
- package/src/types.ts +254 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { Common, ParamsDict } from '@feelyourprotocol/common';
|
|
2
|
+
import type { JSONRPCTx, JSONTx, TransactionType, TxData } from '@feelyourprotocol/tx';
|
|
3
|
+
import type { AddressLike, BigIntLike, BytesLike, JSONRPCWithdrawal, NumericString, PrefixedHexString, WithdrawalBytes, WithdrawalData } from '@feelyourprotocol/util';
|
|
4
|
+
import type { BlockHeader } from './index.ts';
|
|
5
|
+
/**
|
|
6
|
+
* An object to set to which blockchain the blocks and their headers belong. This could be specified
|
|
7
|
+
* using a {@link Common} object, or `chain` and `hardfork`. Defaults to mainnet without specifying a
|
|
8
|
+
* hardfork.
|
|
9
|
+
*/
|
|
10
|
+
export interface BlockOptions {
|
|
11
|
+
/**
|
|
12
|
+
* A {@link Common} object defining the chain and the hardfork a block/block header belongs to.
|
|
13
|
+
*
|
|
14
|
+
* Object will be internally copied so that tx behavior don't incidentally
|
|
15
|
+
* change on future HF changes.
|
|
16
|
+
*
|
|
17
|
+
* Default: {@link Common} object set to `mainnet` and the HF currently defined as the default
|
|
18
|
+
* hardfork in the {@link Common} class.
|
|
19
|
+
*
|
|
20
|
+
* Current default hardfork: `merge`
|
|
21
|
+
*/
|
|
22
|
+
common?: Common;
|
|
23
|
+
/**
|
|
24
|
+
* Set the hardfork either by timestamp (for HFs from Shanghai onwards) or by block number
|
|
25
|
+
* for older Hfs.
|
|
26
|
+
*
|
|
27
|
+
* Default: `false` (HF is set to whatever default HF is set by the {@link Common} instance)
|
|
28
|
+
*/
|
|
29
|
+
setHardfork?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Block parameters sorted by EIP can be found in the exported `paramsBlock` dictionary,
|
|
32
|
+
* which is internally passed to the associated `@feelyourprotocol/common` instance which
|
|
33
|
+
* manages parameter selection based on the hardfork and EIP settings.
|
|
34
|
+
*
|
|
35
|
+
* This option allows providing a custom set of parameters. Note that parameters
|
|
36
|
+
* get fully overwritten, so you need to extend the default parameter dict
|
|
37
|
+
* to provide the full parameter set.
|
|
38
|
+
*
|
|
39
|
+
* It is recommended to deep-clone the params object for this to avoid side effects:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const params = JSON.parse(JSON.stringify(paramsBlock))
|
|
43
|
+
* params['1']['minGasLimit'] = 3000 // 5000
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
params?: ParamsDict;
|
|
47
|
+
/**
|
|
48
|
+
* If a preceding {@link BlockHeader} (usually the parent header) is given the preceding
|
|
49
|
+
* header will be used to calculate the difficulty for this block and the calculated
|
|
50
|
+
* difficulty takes precedence over a provided static `difficulty` value.
|
|
51
|
+
*
|
|
52
|
+
* Note that this option has no effect on networks other than PoW/Ethash networks
|
|
53
|
+
* (respectively also deactivates on the Merge HF switching to PoS/Casper).
|
|
54
|
+
*/
|
|
55
|
+
calcDifficultyFromHeader?: BlockHeader;
|
|
56
|
+
/**
|
|
57
|
+
* A block object by default gets frozen along initialization. This gives you
|
|
58
|
+
* strong additional security guarantees on the consistency of the block parameters.
|
|
59
|
+
* It also enables block hash caching when the `hash()` method is called multiple times.
|
|
60
|
+
*
|
|
61
|
+
* If you need to deactivate the block freeze - e.g. because you want to subclass block and
|
|
62
|
+
* add additional properties - it is strongly encouraged that you do the freeze yourself
|
|
63
|
+
* within your code instead.
|
|
64
|
+
*
|
|
65
|
+
* Default: true
|
|
66
|
+
*/
|
|
67
|
+
freeze?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Skip consensus format validation checks on header if set. Defaults to false.
|
|
70
|
+
*/
|
|
71
|
+
skipConsensusFormatValidation?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A block header's data.
|
|
75
|
+
*/
|
|
76
|
+
export interface HeaderData {
|
|
77
|
+
parentHash?: BytesLike;
|
|
78
|
+
uncleHash?: BytesLike;
|
|
79
|
+
coinbase?: AddressLike;
|
|
80
|
+
stateRoot?: BytesLike;
|
|
81
|
+
transactionsTrie?: BytesLike;
|
|
82
|
+
receiptTrie?: BytesLike;
|
|
83
|
+
logsBloom?: BytesLike;
|
|
84
|
+
difficulty?: BigIntLike;
|
|
85
|
+
number?: BigIntLike;
|
|
86
|
+
gasLimit?: BigIntLike;
|
|
87
|
+
gasUsed?: BigIntLike;
|
|
88
|
+
timestamp?: BigIntLike;
|
|
89
|
+
extraData?: BytesLike;
|
|
90
|
+
mixHash?: BytesLike;
|
|
91
|
+
nonce?: BytesLike;
|
|
92
|
+
baseFeePerGas?: BigIntLike;
|
|
93
|
+
withdrawalsRoot?: BytesLike;
|
|
94
|
+
blobGasUsed?: BigIntLike;
|
|
95
|
+
excessBlobGas?: BigIntLike;
|
|
96
|
+
parentBeaconBlockRoot?: BytesLike;
|
|
97
|
+
requestsHash?: BytesLike;
|
|
98
|
+
/**
|
|
99
|
+
* 32 bytes hash of the block access list (EIP-7928)
|
|
100
|
+
*/
|
|
101
|
+
blockAccessListHash?: BytesLike;
|
|
102
|
+
/**
|
|
103
|
+
* Slot number (EIP-7843)
|
|
104
|
+
*/
|
|
105
|
+
slotNumber?: BigIntLike;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A block's data.
|
|
109
|
+
*/
|
|
110
|
+
export interface BlockData {
|
|
111
|
+
/**
|
|
112
|
+
* Header data for the block
|
|
113
|
+
*/
|
|
114
|
+
header?: HeaderData;
|
|
115
|
+
transactions?: Array<TxData[TransactionType]>;
|
|
116
|
+
uncleHeaders?: Array<HeaderData>;
|
|
117
|
+
withdrawals?: Array<WithdrawalData>;
|
|
118
|
+
}
|
|
119
|
+
export type WithdrawalsBytes = WithdrawalBytes[];
|
|
120
|
+
export type BlockBytes = [BlockHeaderBytes, TransactionsBytes, UncleHeadersBytes] | [BlockHeaderBytes, TransactionsBytes, UncleHeadersBytes, WithdrawalsBytes] | [BlockHeaderBytes, TransactionsBytes, UncleHeadersBytes, WithdrawalsBytes];
|
|
121
|
+
export type BlockHeaderBytes = Uint8Array[];
|
|
122
|
+
export type BlockBodyBytes = [TransactionsBytes, UncleHeadersBytes, WithdrawalsBytes?];
|
|
123
|
+
/**
|
|
124
|
+
* TransactionsBytes can be an array of serialized txs for Typed Transactions or an array of Uint8Array Arrays for legacy transactions.
|
|
125
|
+
*/
|
|
126
|
+
export type TransactionsBytes = Uint8Array[][] | Uint8Array[];
|
|
127
|
+
export type UncleHeadersBytes = Uint8Array[][];
|
|
128
|
+
/**
|
|
129
|
+
* An object with the block's data represented as strings.
|
|
130
|
+
*/
|
|
131
|
+
export interface JSONBlock {
|
|
132
|
+
/**
|
|
133
|
+
* Header data for the block
|
|
134
|
+
*/
|
|
135
|
+
header?: JSONHeader;
|
|
136
|
+
transactions?: JSONTx[];
|
|
137
|
+
uncleHeaders?: JSONHeader[];
|
|
138
|
+
withdrawals?: JSONRPCWithdrawal[];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* An object with the block header's data represented as 0x-prefixed hex strings.
|
|
142
|
+
*/
|
|
143
|
+
export interface JSONHeader {
|
|
144
|
+
parentHash?: PrefixedHexString;
|
|
145
|
+
uncleHash?: PrefixedHexString;
|
|
146
|
+
coinbase?: PrefixedHexString;
|
|
147
|
+
stateRoot?: PrefixedHexString;
|
|
148
|
+
transactionsTrie?: PrefixedHexString;
|
|
149
|
+
receiptTrie?: PrefixedHexString;
|
|
150
|
+
logsBloom?: PrefixedHexString;
|
|
151
|
+
difficulty?: PrefixedHexString;
|
|
152
|
+
number?: PrefixedHexString;
|
|
153
|
+
gasLimit?: PrefixedHexString;
|
|
154
|
+
gasUsed?: PrefixedHexString;
|
|
155
|
+
timestamp?: PrefixedHexString;
|
|
156
|
+
extraData?: PrefixedHexString;
|
|
157
|
+
mixHash?: PrefixedHexString;
|
|
158
|
+
nonce?: PrefixedHexString;
|
|
159
|
+
baseFeePerGas?: PrefixedHexString;
|
|
160
|
+
withdrawalsRoot?: PrefixedHexString;
|
|
161
|
+
blobGasUsed?: PrefixedHexString;
|
|
162
|
+
excessBlobGas?: PrefixedHexString;
|
|
163
|
+
parentBeaconBlockRoot?: PrefixedHexString;
|
|
164
|
+
requestsHash?: PrefixedHexString;
|
|
165
|
+
blockAccessListHash?: PrefixedHexString;
|
|
166
|
+
slotNumber?: PrefixedHexString;
|
|
167
|
+
}
|
|
168
|
+
export interface JSONRPCBlock {
|
|
169
|
+
number: PrefixedHexString;
|
|
170
|
+
hash: PrefixedHexString;
|
|
171
|
+
parentHash: PrefixedHexString;
|
|
172
|
+
mixHash?: PrefixedHexString;
|
|
173
|
+
nonce: PrefixedHexString;
|
|
174
|
+
sha3Uncles: PrefixedHexString;
|
|
175
|
+
logsBloom: PrefixedHexString;
|
|
176
|
+
transactionsRoot: PrefixedHexString;
|
|
177
|
+
stateRoot: PrefixedHexString;
|
|
178
|
+
receiptsRoot: PrefixedHexString;
|
|
179
|
+
miner: PrefixedHexString;
|
|
180
|
+
difficulty: PrefixedHexString | NumericString;
|
|
181
|
+
totalDifficulty?: PrefixedHexString;
|
|
182
|
+
extraData: PrefixedHexString;
|
|
183
|
+
size: PrefixedHexString;
|
|
184
|
+
gasLimit: PrefixedHexString;
|
|
185
|
+
gasUsed: PrefixedHexString;
|
|
186
|
+
timestamp: PrefixedHexString;
|
|
187
|
+
transactions: Array<JSONRPCTx | PrefixedHexString>;
|
|
188
|
+
uncles: PrefixedHexString[];
|
|
189
|
+
baseFeePerGas?: PrefixedHexString;
|
|
190
|
+
withdrawals?: Array<JSONRPCWithdrawal>;
|
|
191
|
+
withdrawalsRoot?: PrefixedHexString;
|
|
192
|
+
blobGasUsed?: PrefixedHexString;
|
|
193
|
+
excessBlobGas?: PrefixedHexString;
|
|
194
|
+
parentBeaconBlockRoot?: PrefixedHexString;
|
|
195
|
+
requestsHash?: PrefixedHexString;
|
|
196
|
+
blockAccessListHash?: PrefixedHexString;
|
|
197
|
+
slotNumber?: PrefixedHexString;
|
|
198
|
+
}
|
|
199
|
+
export type WithdrawalV1 = {
|
|
200
|
+
index: PrefixedHexString;
|
|
201
|
+
validatorIndex: PrefixedHexString;
|
|
202
|
+
address: PrefixedHexString;
|
|
203
|
+
amount: PrefixedHexString;
|
|
204
|
+
};
|
|
205
|
+
export type ExecutionPayload = {
|
|
206
|
+
parentHash: PrefixedHexString;
|
|
207
|
+
feeRecipient: PrefixedHexString;
|
|
208
|
+
stateRoot: PrefixedHexString;
|
|
209
|
+
receiptsRoot: PrefixedHexString;
|
|
210
|
+
logsBloom: PrefixedHexString;
|
|
211
|
+
prevRandao: PrefixedHexString;
|
|
212
|
+
blockNumber: PrefixedHexString;
|
|
213
|
+
gasLimit: PrefixedHexString;
|
|
214
|
+
gasUsed: PrefixedHexString;
|
|
215
|
+
timestamp: PrefixedHexString;
|
|
216
|
+
extraData: PrefixedHexString;
|
|
217
|
+
baseFeePerGas: PrefixedHexString;
|
|
218
|
+
blockHash: PrefixedHexString;
|
|
219
|
+
transactions: PrefixedHexString[];
|
|
220
|
+
withdrawals?: WithdrawalV1[];
|
|
221
|
+
blobGasUsed?: PrefixedHexString;
|
|
222
|
+
excessBlobGas?: PrefixedHexString;
|
|
223
|
+
parentBeaconBlockRoot?: PrefixedHexString;
|
|
224
|
+
requestsHash?: PrefixedHexString;
|
|
225
|
+
blockAccessListHash?: PrefixedHexString;
|
|
226
|
+
slotNumber?: PrefixedHexString;
|
|
227
|
+
};
|
|
228
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChF,OAAO,KAAK,EACV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AAE,iBAAiB,CAAA;IAC/B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,WAAW,EAAE,iBAAiB,CAAA;IAC9B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,aAAa,EAAE,iBAAiB,CAAA;IAChC,SAAS,EAAE,iBAAiB,CAAA;IAC5B,YAAY,EAAE,iBAAiB,EAAE,CAAA;IACjC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAA;IAC5B,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,aAAa,CAAC,EAAE,iBAAiB,CAAA;IACjC,qBAAqB,CAAC,EAAE,iBAAiB,CAAA;IACzC,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,mBAAmB,CAAC,EAAE,iBAAiB,CAAA;IACvC,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAC/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { Common } from '@feelyourprotocol/common';
|
|
2
|
+
import type { TypedTransaction } from '@feelyourprotocol/tx';
|
|
3
|
+
import type { Withdrawal } from '@feelyourprotocol/util';
|
|
4
|
+
import { BlockHeader } from '../index.ts';
|
|
5
|
+
import type { BlockBytes, BlockOptions, ExecutionPayload, JSONBlock } from '../types.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Class representing a block in the Ethereum network. The {@link BlockHeader} has its own
|
|
8
|
+
* class and can be used independently, for a block it is included in the form of the
|
|
9
|
+
* {@link Block.header} property.
|
|
10
|
+
*
|
|
11
|
+
* A block object can be created with one of the following constructor methods
|
|
12
|
+
* (separate from the Block class to allow for tree shaking):
|
|
13
|
+
*
|
|
14
|
+
* - {@link createBlock }
|
|
15
|
+
* - {@link createBlockFromBytesArray }
|
|
16
|
+
* - {@link createBlockFromRLP }
|
|
17
|
+
* - {@link createBlockFromRPC }
|
|
18
|
+
* - {@link createBlockFromJSONRPCProvider }
|
|
19
|
+
* - {@link createBlockFromExecutionPayload }
|
|
20
|
+
* - {@link createBlockFromBeaconPayloadJSON }
|
|
21
|
+
*/
|
|
22
|
+
export declare class Block {
|
|
23
|
+
readonly header: BlockHeader;
|
|
24
|
+
readonly transactions: TypedTransaction[];
|
|
25
|
+
readonly uncleHeaders: BlockHeader[];
|
|
26
|
+
readonly withdrawals?: Withdrawal[];
|
|
27
|
+
readonly common: Common;
|
|
28
|
+
protected keccakFunction: (msg: Uint8Array) => Uint8Array;
|
|
29
|
+
protected sha256Function: (msg: Uint8Array) => Uint8Array;
|
|
30
|
+
protected cache: {
|
|
31
|
+
txTrieRoot?: Uint8Array;
|
|
32
|
+
withdrawalsTrieRoot?: Uint8Array;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* This constructor takes the values, validates them, assigns them and freezes the object.
|
|
36
|
+
*
|
|
37
|
+
* @deprecated Use the static factory methods (see {@link Block} for an overview) to assist in creating
|
|
38
|
+
* a Block object from varying data types and options.
|
|
39
|
+
*/
|
|
40
|
+
constructor(header?: BlockHeader, transactions?: TypedTransaction[], uncleHeaders?: BlockHeader[], withdrawals?: Withdrawal[], opts?: BlockOptions);
|
|
41
|
+
/**
|
|
42
|
+
* Returns an array of the raw byte arrays for this block, in order.
|
|
43
|
+
*/
|
|
44
|
+
raw(): BlockBytes;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the hash of the block.
|
|
47
|
+
*/
|
|
48
|
+
hash(): Uint8Array;
|
|
49
|
+
/**
|
|
50
|
+
* Determines if this block is the genesis block.
|
|
51
|
+
*/
|
|
52
|
+
isGenesis(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the rlp encoding of the block.
|
|
55
|
+
*/
|
|
56
|
+
serialize(): Uint8Array;
|
|
57
|
+
/**
|
|
58
|
+
* Generates transaction trie for validation.
|
|
59
|
+
*/
|
|
60
|
+
genTxTrie(): Promise<Uint8Array>;
|
|
61
|
+
/**
|
|
62
|
+
* Validates the transaction trie by generating a trie
|
|
63
|
+
* and do a check on the root hash.
|
|
64
|
+
* @returns True if the transaction trie is valid, false otherwise
|
|
65
|
+
*/
|
|
66
|
+
transactionsTrieIsValid(): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Validates transaction signatures and minimum gas requirements.
|
|
69
|
+
* @returns {string[]} an array of error strings
|
|
70
|
+
*/
|
|
71
|
+
getTransactionsValidationErrors(): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Validates transaction signatures and minimum gas requirements.
|
|
74
|
+
* @returns True if all transactions are valid, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
transactionsAreValid(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Validates the block data, throwing if invalid.
|
|
79
|
+
* This can be checked on the Block itself without needing access to any parent block
|
|
80
|
+
* It checks:
|
|
81
|
+
* - All transactions are valid
|
|
82
|
+
* - The transactions trie is valid
|
|
83
|
+
* - The uncle hash is valid
|
|
84
|
+
* - Block size limit (EIP-7934)
|
|
85
|
+
* @param onlyHeader if only passed the header, skip validating txTrie and unclesHash (default: false)
|
|
86
|
+
* @param verifyTxs if set to `false`, will not check for transaction validation errors (default: true)
|
|
87
|
+
* @param validateBlockSize if set to `true`, will check for block size limit (EIP-7934) (default: false)
|
|
88
|
+
*/
|
|
89
|
+
validateData(onlyHeader?: boolean, verifyTxs?: boolean, validateBlockSize?: boolean): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Validates that blob gas fee for each transaction is greater than or equal to the
|
|
92
|
+
* blobGasPrice for the block and that total blob gas in block is less than maximum
|
|
93
|
+
* blob gas per block
|
|
94
|
+
* @param parentHeader header of parent block
|
|
95
|
+
*/
|
|
96
|
+
validateBlobTransactions(parentHeader: BlockHeader): void;
|
|
97
|
+
/**
|
|
98
|
+
* Validates the uncle's hash.
|
|
99
|
+
* @returns true if the uncle's hash is valid, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
uncleHashIsValid(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Validates the withdrawal root
|
|
104
|
+
* @returns true if the withdrawals trie root is valid, false otherwise
|
|
105
|
+
*/
|
|
106
|
+
withdrawalsTrieIsValid(): Promise<boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Consistency checks for uncles included in the block, if any.
|
|
109
|
+
*
|
|
110
|
+
* Throws if invalid.
|
|
111
|
+
*
|
|
112
|
+
* The rules for uncles checked are the following:
|
|
113
|
+
* Header has at most 2 uncles.
|
|
114
|
+
* Header does not count an uncle twice.
|
|
115
|
+
*/
|
|
116
|
+
validateUncles(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Validates if the block gasLimit remains in the boundaries set by the protocol.
|
|
119
|
+
* Throws if invalid
|
|
120
|
+
*
|
|
121
|
+
* @param parentBlock - the parent of this `Block`
|
|
122
|
+
*/
|
|
123
|
+
validateGasLimit(parentBlock: Block): void;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the block in JSON format.
|
|
126
|
+
*/
|
|
127
|
+
toJSON(): JSONBlock;
|
|
128
|
+
/**
|
|
129
|
+
* Maps the block properties to the execution payload structure from the beacon chain,
|
|
130
|
+
* see https://github.com/ethereum/consensus-specs/blob/dev/specs/bellatrix/beacon-chain.md#ExecutionPayload
|
|
131
|
+
*
|
|
132
|
+
* @returns dict with the execution payload parameters with camel case naming
|
|
133
|
+
*/
|
|
134
|
+
toExecutionPayload(): ExecutionPayload;
|
|
135
|
+
/**
|
|
136
|
+
* Return a compact error string representation of the object
|
|
137
|
+
*/
|
|
138
|
+
errorStr(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Internal helper function to create an annotated error message
|
|
141
|
+
*
|
|
142
|
+
* @param msg Base error message
|
|
143
|
+
* @hidden
|
|
144
|
+
*/
|
|
145
|
+
protected _errorMsg(msg: string): string;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/block/block.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAA6B,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,OAAO,EACL,WAAW,EAUZ,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAExF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,KAAK;IAChB,SAAgB,MAAM,EAAE,WAAW,CAAA;IACnC,SAAgB,YAAY,EAAE,gBAAgB,EAAE,CAAK;IACrD,SAAgB,YAAY,EAAE,WAAW,EAAE,CAAK;IAChD,SAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAS,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,UAAU,CAAA;IACzD,SAAS,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,UAAU,CAAA;IAEzD,SAAS,CAAC,KAAK,EAAE;QACf,UAAU,CAAC,EAAE,UAAU,CAAA;QACvB,mBAAmB,CAAC,EAAE,UAAU,CAAA;KACjC,CAAK;IAEN;;;;;OAKG;gBAED,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,GAAE,gBAAgB,EAAO,EACrC,YAAY,GAAE,WAAW,EAAO,EAChC,WAAW,CAAC,EAAE,UAAU,EAAE,EAC1B,IAAI,GAAE,YAAiB;IAqCzB;;OAEG;IACH,GAAG,IAAI,UAAU;IAgBjB;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