diff --git a/lerna.json b/lerna.json index de5edcff808..d6707ca0cd6 100644 --- a/lerna.json +++ b/lerna.json @@ -2,10 +2,5 @@ "packages": [ "packages/*" ], - "version": "0.0.0", - "command": { - "bootstrap": { - "ignore": "ethereumjs-block" - } - } + "version": "0.0.0" } diff --git a/package.json b/package.json index ad46865d9cc..be56baec9f1 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,9 @@ } }, "scripts": { - "bootstrap": "lerna bootstrap --ignore-scripts && lerna exec npm i --scope=ethereumjs-block", + "bootstrap": "lerna bootstrap --ignore-scripts", "postinstall": "npm run bootstrap", + "build:all": "lerna run build", "lint": "lerna run lint" } } diff --git a/packages/account/docs/README.md b/packages/account/docs/README.md index 518bffc242d..1e9ad19eb75 100644 --- a/packages/account/docs/README.md +++ b/packages/account/docs/README.md @@ -6,4 +6,4 @@ ### Modules -- ["index"](modules/_index_.md) +* ["index"](modules/_index_.md) diff --git a/packages/account/docs/classes/_index_.account.md b/packages/account/docs/classes/_index_.account.md index 4893d23c114..f48b3d9eee2 100644 --- a/packages/account/docs/classes/_index_.account.md +++ b/packages/account/docs/classes/_index_.account.md @@ -4,42 +4,42 @@ ## Hierarchy -- **Account** +* **Account** ## Index ### Constructors -- [constructor](_index_.account.md#constructor) +* [constructor](_index_.account.md#constructor) ### Properties -- [balance](_index_.account.md#balance) -- [codeHash](_index_.account.md#codehash) -- [nonce](_index_.account.md#nonce) -- [stateRoot](_index_.account.md#stateroot) +* [balance](_index_.account.md#balance) +* [codeHash](_index_.account.md#codehash) +* [nonce](_index_.account.md#nonce) +* [stateRoot](_index_.account.md#stateroot) ### Methods -- [getCode](_index_.account.md#getcode) -- [getStorage](_index_.account.md#getstorage) -- [isContract](_index_.account.md#iscontract) -- [isEmpty](_index_.account.md#isempty) -- [serialize](_index_.account.md#serialize) -- [setCode](_index_.account.md#setcode) -- [setStorage](_index_.account.md#setstorage) +* [getCode](_index_.account.md#getcode) +* [getStorage](_index_.account.md#getstorage) +* [isContract](_index_.account.md#iscontract) +* [isEmpty](_index_.account.md#isempty) +* [serialize](_index_.account.md#serialize) +* [setCode](_index_.account.md#setcode) +* [setStorage](_index_.account.md#setstorage) ## Constructors -### constructor +### constructor -\+ **new Account**(`data?`: any): _[Account](\_index_.account.md)\_ +\+ **new Account**(`data?`: any): *[Account](_index_.account.md)* -_Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L41)_ +*Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L41)* Creates a new account object -``` +~~~ var data = [ '0x02', //nonce '0x0384', //balance @@ -55,142 +55,142 @@ var data = { } const account = new Account(data) -``` +~~~ **Parameters:** -| Name | Type | Description | -| ------- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data?` | any | An account can be initialized with either a `buffer` containing the RLP serialized account. Or an `Array` of buffers relating to each of the account Properties, listed in order below. For `Object` and `Array` each of the elements can either be a `Buffer`, hex `String`, `Number`, or an object with a `toBuffer` method such as `Bignum`. | +Name | Type | Description | +------ | ------ | ------ | +`data?` | any | An account can be initialized with either a `buffer` containing the RLP serialized account. Or an `Array` of buffers relating to each of the account Properties, listed in order below. For `Object` and `Array` each of the elements can either be a `Buffer`, hex `String`, `Number`, or an object with a `toBuffer` method such as `Bignum`. | -**Returns:** _[Account](\_index_.account.md)\_ +**Returns:** *[Account](_index_.account.md)* ## Properties -### balance +### balance -• **balance**: _Buffer_ +• **balance**: *Buffer* -_Defined in [index.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L31)_ +*Defined in [index.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L31)* The account's balance in wei. ---- +___ -### codeHash +### codeHash -• **codeHash**: _Buffer_ +• **codeHash**: *Buffer* -_Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L41)_ +*Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L41)* The hash of the code of the contract. ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Defined in [index.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L26)_ +*Defined in [index.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L26)* The account's nonce. ---- +___ -### stateRoot +### stateRoot -• **stateRoot**: _Buffer_ +• **stateRoot**: *Buffer* -_Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L36)_ +*Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L36)* The stateRoot for the storage of the contract. ## Methods -### getCode +### getCode -▸ **getCode**(`trie`: Trie, `cb`: TrieGetCb): _void_ +▸ **getCode**(`trie`: Trie, `cb`: TrieGetCb): *void* -_Defined in [index.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L116)_ +*Defined in [index.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L116)* Fetches the code from the trie. **Parameters:** -| Name | Type | Description | -| ------ | --------- | ----------------------------------------------------------------------------------- | -| `trie` | Trie | The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts | -| `cb` | TrieGetCb | The callback | +Name | Type | Description | +------ | ------ | ------ | +`trie` | Trie | The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts | +`cb` | TrieGetCb | The callback | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getStorage +### getStorage -▸ **getStorage**(`trie`: Trie, `key`: Buffer | string, `cb`: TrieGetCb): _void_ +▸ **getStorage**(`trie`: Trie, `key`: Buffer | string, `cb`: TrieGetCb): *void* -_Defined in [index.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L179)_ +*Defined in [index.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L179)* Fetches `key` from the account's storage. **Parameters:** -| Name | Type | Description | -| ------ | -------------------- | ----------- | -| `trie` | Trie | - | -| `key` | Buffer | string | - | -| `cb` | TrieGetCb | | +Name | Type | Description | +------ | ------ | ------ | +`trie` | Trie | - | +`key` | Buffer | string | - | +`cb` | TrieGetCb | | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### isContract +### isContract -▸ **isContract**(): _boolean_ +▸ **isContract**(): *boolean* -_Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L107)_ +*Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L107)* Returns a `Boolean` deteremining if the account is a contract. -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### isEmpty +### isEmpty -▸ **isEmpty**(): _boolean_ +▸ **isEmpty**(): *boolean* -_Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L232)_ +*Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L232)* Returns a `Boolean` determining if the account is empty. -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [index.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L99)_ +*Defined in [index.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L99)* Returns the RLP serialization of the account as a `Buffer`. -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### setCode +### setCode -▸ **setCode**(`trie`: Trie, `code`: Buffer, `cb`: function): _void_ +▸ **setCode**(`trie`: Trie, `code`: Buffer, `cb`: function): *void* -_Defined in [index.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L160)_ +*Defined in [index.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L160)* Stores the code in the trie. -``` +~~~ // Requires manual merkle-patricia-tree install const SecureTrie = require('merkle-patricia-tree/secure') const Account = require('./index.js').default @@ -215,44 +215,44 @@ account.setCode(trie, code, function(err, codeHash) { console.log(`Code ${code.toString('hex')} read from trie`) }) }) -``` +~~~ **Parameters:** -▪ **trie**: _Trie_ +▪ **trie**: *Trie* The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts. -▪ **code**: _Buffer_ +▪ **code**: *Buffer* -▪ **cb**: _function_ +▪ **cb**: *function* The callback. -▸ (`err`: any, `codeHash`: Buffer): _void_ +▸ (`err`: any, `codeHash`: Buffer): *void* **Parameters:** -| Name | Type | -| ---------- | ------ | -| `err` | any | -| `codeHash` | Buffer | +Name | Type | +------ | ------ | +`err` | any | +`codeHash` | Buffer | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### setStorage +### setStorage -▸ **setStorage**(`trie`: Trie, `key`: Buffer | string, `val`: Buffer | string, `cb`: TriePutCb): _void_ +▸ **setStorage**(`trie`: Trie, `key`: Buffer | string, `val`: Buffer | string, `cb`: TriePutCb): *void* -_Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L218)_ +*Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/account/src/index.ts#L218)* Stores a `val` at the `key` in the contract's storage. Example for `getStorage` and `setStorage`: -``` +~~~ // Requires manual merkle-patricia-tree install const SecureTrie = require('merkle-patricia-tree/secure') const Account = require('./index.js').default @@ -273,15 +273,15 @@ account.setStorage(trie, key, value, function(err) { console.log(`Value ${value.toString('hex')} set and retrieved from trie.`) }) }) -``` +~~~ **Parameters:** -| Name | Type | Description | -| ------ | -------------------- | ----------- | -| `trie` | Trie | - | -| `key` | Buffer | string | - | -| `val` | Buffer | string | - | -| `cb` | TriePutCb | | +Name | Type | Description | +------ | ------ | ------ | +`trie` | Trie | - | +`key` | Buffer | string | - | +`val` | Buffer | string | - | +`cb` | TriePutCb | | -**Returns:** _void_ +**Returns:** *void* diff --git a/packages/account/docs/modules/_index_.md b/packages/account/docs/modules/_index_.md index f6913f52fc3..64db082b3d6 100644 --- a/packages/account/docs/modules/_index_.md +++ b/packages/account/docs/modules/_index_.md @@ -6,4 +6,4 @@ ### Classes -- [Account](../classes/_index_.account.md) +* [Account](../classes/_index_.account.md) diff --git a/packages/block/CHANGELOG.md b/packages/block/CHANGELOG.md index c68bd6bb4f8..1c8a6491a63 100644 --- a/packages/block/CHANGELOG.md +++ b/packages/block/CHANGELOG.md @@ -6,6 +6,116 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) (modification: no type change headlines) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.0.0] - 2020-04-01 + +Verion 3.0.0 brings modernizations to the code and some **breaking changes** you should be aware of. + +### TypeScript/Library Import + +First TypeScript based release of the library. The import structure has slightly changed along: + +**TypeScript** + +```typescript +import { BlockHeader } from 'ethereumjs-block' +import { Block } from 'ethereumjs-block' +``` + +**JavaScript/Node.js** + +```javascript +const BlockHeader = require('ethereumjs-block').BlockHeader +const Block = require('ethereumjs-block').Block +``` + +The library now also comes with a **type declaration file** distributed +along with the package published. + +### Promise-based API + +The API of this library is now completely promise-based, the old callback-style +interface has been dropped. + +This affects the following methods of the API now being defined as `async` and +returning a `Promise`: + +**Header Class** + +- `BlockHeader.validate(blockchain: Blockchain, height?: BN): Promise` + +**Block Class** + +- `Block.genTxTrie(): Promise` +- `Block.validate(blockChain: Blockchain): Promise` +- `Block.validateUncles(blockchain: Blockchain): Promise` + +Usage example: + +```javascript +try { + await block.validate(blockchain) + // Block validation has passed +} catch (err) { + // handle errors appropriately +} +``` + +### Different signature for constructor + +From now on, it's not allowed to initialize `Block` with a `null` value. If for any reason you need to initialize it without defining a value, use the more semantic `undefined` like the examples below: + +```typescript +const b = new Block(undefined, options) +``` + +or just: + +```typescript +const b = new Block() +``` + +### Change Summary + +Other changes along with the `TypeScript` transition PR +[#72](https://github.com/ethereumjs/ethereumjs-block/pull/72) + +- Added Node `10`, `12` support, dropped Node `7` support +- Browser test run on CI +- Karma browser test run config modernization and simplification +- Removal of the `async` dependency +- Update `ethereumjs-common` dependency from `v1.1.0` to `v1.5.0` +- Update `ethereumjs-tx` dependency from `v1.2.2` to `v2.1.1` +- Update `ethereumjs-util` dependency from `v5.0.0` to `v6.1.0` +- Updated test source files to `TypeScript` +- Signature fix for pre-homestead blocks, see + [#67](https://github.com/ethereumjs/ethereumjs-block/issues/67) + +[3.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.2.0...%40ethereumjs%2Fblock%403.0.0 + +## [2.2.2] - 2019-12-17 + +**MuirGlacier** support by updating to the new difficulty formula as stated +in [EIP-2384](https://eips.ethereum.org/EIPS/eip-2384). + +Please note that this release does not contain all the changes merged into +master since the `v2.2.0` release and only backports the difficulty formula +adjustments to support MuirGlacier without having to go through migration to +the `v3.0.0` which contains breaking changes. + +[2.2.2]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.2.1...%40ethereumjs%2Fblock%402.2.2 + +## [2.2.1] - 2019-11-14 + +**Istanbul** support by updating to the most recent `ethereumjs-tx` version +[v2.1.1](https://github.com/ethereumjs/ethereumjs-tx/releases/tag/v2.1.1). + +Please note that this release does not contain all the changes merged into +master since the `v2.2.0` release and only backports the most recent +`ethereumjs-tx` version to allow users to support Istanbul without having +to go through migration to the `v3.0.0` which contains breaking changes. + +[2.2.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.2.0...%40ethereumjs%2Fblock%402.2.1 + ## [2.2.0] - 2019-02-06 **Petersburg** (aka `constantinopleFix`) as well as **Goerli** @@ -24,7 +134,7 @@ PR [#64](https://github.com/ethereumjs/ethereumjs-block/pull/64) - Remove `ethereumjs-testing` dependency (much smaller dev dependencies), PR [#61](https://github.com/ethereumjs/ethereumjs-block/pull/61) -[2.2.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%402.1.0...%40ethereumjs%2Fvm%402.2.0 +[2.2.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.1.0...%40ethereumjs%2Fblock%402.2.0 ## [2.1.0] - 2018-10-19 @@ -32,13 +142,13 @@ PR [#64](https://github.com/ethereumjs/ethereumjs-block/pull/64) - Updated test data, added Constantinople tests, PR [#56](https://github.com/ethereumjs/ethereumjs-block/pull/56), [#57](https://github.com/ethereumjs/ethereumjs-block/pull/57) - Added `timestamp` field to `setGenesisParams()`, PR [#52](https://github.com/ethereumjs/ethereumjs-block/pull/52) -[2.1.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%402.0.1...%40ethereumjs%2Fvm%402.1.0 +[2.1.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.0.1...%40ethereumjs%2Fblock%402.1.0 ## [2.0.1] - 2018-08-08 - Fixes `BlockHeader.prototype.validate()` bug, see PR [#49](https://github.com/ethereumjs/ethereumjs-block/pull/49) -[2.0.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%402.0.0...%40ethereumjs%2Fvm%402.0.1 +[2.0.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%402.0.0...%40ethereumjs%2Fblock%402.0.1 ## [2.0.0] - 2018-06-25 @@ -52,7 +162,7 @@ Changes in detail: - New initialization parameters `opts.chain` (default: `mainnet`) and `opts.hardfork` (default: `null`, block number-based behaviour), PR [#44](https://github.com/ethereumjs/ethereumjs-block/pull/44) - Alternatively a `Common` class object can be provided directly with the `opts.common` parameter, - see [API](https://github.com/ethereumjs/ethereumjs-block/blob/master/docs/index.md) docs + see [API](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/docs/index.md) docs - Correct block validation for all know hardforks, PR [#47](https://github.com/ethereumjs/ethereumjs-block/pull/47), if no hardfork is set validation logic is determined by block number in combination with the `chain` set @@ -60,7 +170,7 @@ Changes in detail: - Extensive test additions to cover the newly introduced capabilities and changes - Fix default value for `nonce` (empty buffer -> ``), PR [#42](https://github.com/ethereumjs/ethereumjs-block/pull/42) -[2.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%401.7.1...%40ethereumjs%2Fvm%402.0.0 +[2.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%401.7.1...%40ethereumjs%2Fblock%402.0.0 ## [1.7.1] - 2018-02-15 @@ -68,7 +178,7 @@ Changes in detail: library, PR [#40](https://github.com/ethereumjs/ethereumjs-block/pull/40) - Updated `ethereumjs/common` dependency, PR [#38](https://github.com/ethereumjs/ethereumjs-block/pull/38) -[1.7.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%401.7.0...%40ethereumjs%2Fvm%401.7.1 +[1.7.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%401.7.0...%40ethereumjs%2Fblock%401.7.1 ## [1.7.0] - 2017-10-11 @@ -77,7 +187,7 @@ Changes in detail: - Difficulty bomb delay (EIP 649) - Removed `isHomestead`, `isHomesteadReprice` from API methods -[1.7.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fvm%401.6.0...%40ethereumjs%2Fvm%401.7.0 +[1.7.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Fblock%401.6.0...%40ethereumjs%2Fblock%401.7.0 ## [1.6.0] - 2017-07-12 diff --git a/packages/block/docs/README.md b/packages/block/docs/README.md index 212910bbd6f..0597218b6a3 100644 --- a/packages/block/docs/README.md +++ b/packages/block/docs/README.md @@ -6,9 +6,9 @@ ### Modules -- ["block"](modules/_block_.md) -- ["from-rpc"](modules/_from_rpc_.md) -- ["header"](modules/_header_.md) -- ["header-from-rpc"](modules/_header_from_rpc_.md) -- ["index"](modules/_index_.md) -- ["types"](modules/_types_.md) +* ["block"](modules/_block_.md) +* ["from-rpc"](modules/_from_rpc_.md) +* ["header"](modules/_header_.md) +* ["header-from-rpc"](modules/_header_from_rpc_.md) +* ["index"](modules/_index_.md) +* ["types"](modules/_types_.md) diff --git a/packages/block/docs/classes/_block_.block.md b/packages/block/docs/classes/_block_.block.md index 2a74ccc541f..f54fabffe2e 100644 --- a/packages/block/docs/classes/_block_.block.md +++ b/packages/block/docs/classes/_block_.block.md @@ -6,192 +6,192 @@ An object that represents the block ## Hierarchy -- **Block** +* **Block** ## Index ### Constructors -- [constructor](_block_.block.md#constructor) +* [constructor](_block_.block.md#constructor) ### Properties -- [header](_block_.block.md#header) -- [transactions](_block_.block.md#transactions) -- [txTrie](_block_.block.md#txtrie) -- [uncleHeaders](_block_.block.md#uncleheaders) +* [header](_block_.block.md#header) +* [transactions](_block_.block.md#transactions) +* [txTrie](_block_.block.md#txtrie) +* [uncleHeaders](_block_.block.md#uncleheaders) ### Accessors -- [raw](_block_.block.md#raw) +* [raw](_block_.block.md#raw) ### Methods -- [genTxTrie](_block_.block.md#gentxtrie) -- [hash](_block_.block.md#hash) -- [isGenesis](_block_.block.md#isgenesis) -- [serialize](_block_.block.md#serialize) -- [setGenesisParams](_block_.block.md#setgenesisparams) -- [toJSON](_block_.block.md#tojson) -- [validate](_block_.block.md#validate) -- [validateTransactions](_block_.block.md#validatetransactions) -- [validateTransactionsTrie](_block_.block.md#validatetransactionstrie) -- [validateUncles](_block_.block.md#validateuncles) -- [validateUnclesHash](_block_.block.md#validateuncleshash) +* [genTxTrie](_block_.block.md#gentxtrie) +* [hash](_block_.block.md#hash) +* [isGenesis](_block_.block.md#isgenesis) +* [serialize](_block_.block.md#serialize) +* [setGenesisParams](_block_.block.md#setgenesisparams) +* [toJSON](_block_.block.md#tojson) +* [validate](_block_.block.md#validate) +* [validateTransactions](_block_.block.md#validatetransactions) +* [validateTransactionsTrie](_block_.block.md#validatetransactionstrie) +* [validateUncles](_block_.block.md#validateuncles) +* [validateUnclesHash](_block_.block.md#validateuncleshash) ## Constructors -### constructor +### constructor -\+ **new Block**(`data`: Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[Block](\_block_.block.md)\_ +\+ **new Block**(`data`: Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md), `chainOptions`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[Block](_block_.block.md)* -_Defined in [block.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L20)_ +*Defined in [block.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L20)* Creates a new block object **Parameters:** -| Name | Type | Default | Description | -| ------ | --------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------- | -| `data` | Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md) | {} | The block's data. | -| `opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md) | {} | The block's data. | +`chainOptions` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | -**Returns:** _[Block](\_block_.block.md)\_ +**Returns:** *[Block](_block_.block.md)* ## Properties -### header +### header -• **header**: _[BlockHeader](\_header_.blockheader.md)\_ +• **header**: *[BlockHeader](_header_.blockheader.md)* -_Defined in [block.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L15)_ +*Defined in [block.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L15)* ---- +___ -### transactions +### transactions -• **transactions**: _Transaction[]_ = [] +• **transactions**: *Transaction[]* = [] -_Defined in [block.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L16)_ +*Defined in [block.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L16)* ---- +___ -### txTrie +### txTrie -• **txTrie**: _any_ = new Trie() +• **txTrie**: *any* = new Trie() -_Defined in [block.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L18)_ +*Defined in [block.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L18)* ---- +___ -### uncleHeaders +### uncleHeaders -• **uncleHeaders**: _[BlockHeader](\_header_.blockheader.md)[]\_ = [] +• **uncleHeaders**: *[BlockHeader](_header_.blockheader.md)[]* = [] -_Defined in [block.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L17)_ +*Defined in [block.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L17)* ## Accessors -### raw +### raw -• **get raw**(): _[Buffer[], Buffer[], Buffer[]]_ +• **get raw**(): *[Buffer[], Buffer[], Buffer[]]* -_Defined in [block.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L82)_ +*Defined in [block.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L87)* -**Returns:** _[Buffer[], Buffer[], Buffer[]]_ +**Returns:** *[Buffer[], Buffer[], Buffer[]]* ## Methods -### genTxTrie +### genTxTrie -▸ **genTxTrie**(): _Promise‹void›_ +▸ **genTxTrie**(): *Promise‹void›* -_Defined in [block.ts:131](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L131)_ +*Defined in [block.ts:136](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L136)* Generate transaction trie. The tx trie must be generated before the transaction trie can be validated with `validateTransactionTrie` -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### hash +### hash -▸ **hash**(): _Buffer_ +▸ **hash**(): *Buffer* -_Defined in [block.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L89)_ +*Defined in [block.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L94)* Produces a hash the RLP of the block -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### isGenesis +### isGenesis -▸ **isGenesis**(): _boolean_ +▸ **isGenesis**(): *boolean* -_Defined in [block.ts:96](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L96)_ +*Defined in [block.ts:101](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L101)* Determines if this block is the genesis block -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [block.ts:114](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L114)_ +*Defined in [block.ts:119](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L119)* Produces a serialization of the block. -**Returns:** _Buffer_ +**Returns:** *Buffer* -▸ **serialize**(`rlpEncode`: true): _Buffer_ +▸ **serialize**(`rlpEncode`: true): *Buffer* -_Defined in [block.ts:115](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L115)_ +*Defined in [block.ts:120](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L120)* **Parameters:** -| Name | Type | -| ----------- | ---- | -| `rlpEncode` | true | +Name | Type | +------ | ------ | +`rlpEncode` | true | -**Returns:** _Buffer_ +**Returns:** *Buffer* -▸ **serialize**(`rlpEncode`: false): _[Buffer[], Buffer[], Buffer[]]_ +▸ **serialize**(`rlpEncode`: false): *[Buffer[], Buffer[], Buffer[]]* -_Defined in [block.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L116)_ +*Defined in [block.ts:121](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L121)* **Parameters:** -| Name | Type | -| ----------- | ----- | -| `rlpEncode` | false | +Name | Type | +------ | ------ | +`rlpEncode` | false | -**Returns:** _[Buffer[], Buffer[], Buffer[]]_ +**Returns:** *[Buffer[], Buffer[], Buffer[]]* ---- +___ -### setGenesisParams +### setGenesisParams -▸ **setGenesisParams**(): _void_ +▸ **setGenesisParams**(): *void* -_Defined in [block.ts:103](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L103)_ +*Defined in [block.ts:108](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L108)* Turns the block into the canonical genesis block -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labeled`: boolean): _any_ +▸ **toJSON**(`labeled`: boolean): *any* -_Defined in [block.ts:238](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L238)_ +*Defined in [block.ts:243](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L243)* Returns the block in JSON format @@ -199,104 +199,104 @@ Returns the block in JSON format **Parameters:** -| Name | Type | Default | -| --------- | ------- | ------- | -| `labeled` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labeled` | boolean | false | -**Returns:** _any_ +**Returns:** *any* ---- +___ -### validate +### validate -▸ **validate**(`blockChain`: [Blockchain](../interfaces/_index_.blockchain.md)): _Promise‹void›_ +▸ **validate**(`blockChain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›* -_Defined in [block.ts:180](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L180)_ +*Defined in [block.ts:185](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L185)* Validates the entire block, throwing if invalid. **Parameters:** -| Name | Type | Description | -| ------------ | ------------------------------------------------- | -------------------------------------------------- | -| `blockChain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block wants to be part of | +Name | Type | Description | +------ | ------ | ------ | +`blockChain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block wants to be part of | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateTransactions +### validateTransactions -▸ **validateTransactions**(): _boolean_ +▸ **validateTransactions**(): *boolean* -_Defined in [block.ts:155](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L155)_ +*Defined in [block.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L160)* Validates the transactions -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validateTransactions**(`stringError`: false): _boolean_ +▸ **validateTransactions**(`stringError`: false): *boolean* -_Defined in [block.ts:156](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L156)_ +*Defined in [block.ts:161](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L161)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validateTransactions**(`stringError`: true): _string_ +▸ **validateTransactions**(`stringError`: true): *string* -_Defined in [block.ts:157](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L157)_ +*Defined in [block.ts:162](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L162)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### validateTransactionsTrie +### validateTransactionsTrie -▸ **validateTransactionsTrie**(): _boolean_ +▸ **validateTransactionsTrie**(): *boolean* -_Defined in [block.ts:141](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L141)_ +*Defined in [block.ts:146](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L146)* Validates the transaction trie -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### validateUncles +### validateUncles -▸ **validateUncles**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): _Promise‹void›_ +▸ **validateUncles**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›* -_Defined in [block.ts:215](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L215)_ +*Defined in [block.ts:220](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L220)* Validates the uncles that are in the block, if any. This method throws if they are invalid. **Parameters:** -| Name | Type | -| ------------ | ------------------------------------------------- | -| `blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | +Name | Type | +------ | ------ | +`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateUnclesHash +### validateUnclesHash -▸ **validateUnclesHash**(): _boolean_ +▸ **validateUnclesHash**(): *boolean* -_Defined in [block.ts:204](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L204)_ +*Defined in [block.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L209)* Validates the uncle's hash -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/block/docs/classes/_header_.blockheader.md b/packages/block/docs/classes/_header_.blockheader.md index 8a3ac2f465c..990a52e2bf6 100644 --- a/packages/block/docs/classes/_header_.blockheader.md +++ b/packages/block/docs/classes/_header_.blockheader.md @@ -6,265 +6,265 @@ An object that represents the block header ## Hierarchy -- **BlockHeader** +* **BlockHeader** ## Index ### Constructors -- [constructor](_header_.blockheader.md#constructor) +* [constructor](_header_.blockheader.md#constructor) ### Properties -- [bloom](_header_.blockheader.md#bloom) -- [coinbase](_header_.blockheader.md#coinbase) -- [difficulty](_header_.blockheader.md#difficulty) -- [extraData](_header_.blockheader.md#extradata) -- [gasLimit](_header_.blockheader.md#gaslimit) -- [gasUsed](_header_.blockheader.md#gasused) -- [mixHash](_header_.blockheader.md#mixhash) -- [nonce](_header_.blockheader.md#nonce) -- [number](_header_.blockheader.md#number) -- [parentHash](_header_.blockheader.md#parenthash) -- [raw](_header_.blockheader.md#raw) -- [receiptTrie](_header_.blockheader.md#receipttrie) -- [stateRoot](_header_.blockheader.md#stateroot) -- [timestamp](_header_.blockheader.md#timestamp) -- [transactionsTrie](_header_.blockheader.md#transactionstrie) -- [uncleHash](_header_.blockheader.md#unclehash) +* [bloom](_header_.blockheader.md#bloom) +* [coinbase](_header_.blockheader.md#coinbase) +* [difficulty](_header_.blockheader.md#difficulty) +* [extraData](_header_.blockheader.md#extradata) +* [gasLimit](_header_.blockheader.md#gaslimit) +* [gasUsed](_header_.blockheader.md#gasused) +* [mixHash](_header_.blockheader.md#mixhash) +* [nonce](_header_.blockheader.md#nonce) +* [number](_header_.blockheader.md#number) +* [parentHash](_header_.blockheader.md#parenthash) +* [raw](_header_.blockheader.md#raw) +* [receiptTrie](_header_.blockheader.md#receipttrie) +* [stateRoot](_header_.blockheader.md#stateroot) +* [timestamp](_header_.blockheader.md#timestamp) +* [transactionsTrie](_header_.blockheader.md#transactionstrie) +* [uncleHash](_header_.blockheader.md#unclehash) ### Methods -- [canonicalDifficulty](_header_.blockheader.md#canonicaldifficulty) -- [hash](_header_.blockheader.md#hash) -- [isGenesis](_header_.blockheader.md#isgenesis) -- [serialize](_header_.blockheader.md#serialize) -- [setGenesisParams](_header_.blockheader.md#setgenesisparams) -- [toJSON](_header_.blockheader.md#tojson) -- [validate](_header_.blockheader.md#validate) -- [validateDifficulty](_header_.blockheader.md#validatedifficulty) -- [validateGasLimit](_header_.blockheader.md#validategaslimit) +* [canonicalDifficulty](_header_.blockheader.md#canonicaldifficulty) +* [hash](_header_.blockheader.md#hash) +* [isGenesis](_header_.blockheader.md#isgenesis) +* [serialize](_header_.blockheader.md#serialize) +* [setGenesisParams](_header_.blockheader.md#setgenesisparams) +* [toJSON](_header_.blockheader.md#tojson) +* [validate](_header_.blockheader.md#validate) +* [validateDifficulty](_header_.blockheader.md#validatedifficulty) +* [validateGasLimit](_header_.blockheader.md#validategaslimit) ## Constructors -### constructor +### constructor -\+ **new BlockHeader**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[BlockHeader](\_header_.blockheader.md)\_ +\+ **new BlockHeader**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[BlockHeader](_header_.blockheader.md)* -_Defined in [header.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L29)_ +*Defined in [header.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L29)* Creates a new block header. **Parameters:** -| Name | Type | Default | Description | -| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) | {} | The data of the block header. | -| `opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) | {} | The data of the block header. | +`opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | -**Returns:** _[BlockHeader](\_header_.blockheader.md)\_ +**Returns:** *[BlockHeader](_header_.blockheader.md)* ## Properties -### bloom +### bloom -• **bloom**: _Buffer_ +• **bloom**: *Buffer* -_Defined in [header.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L19)_ +*Defined in [header.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L19)* ---- +___ -### coinbase +### coinbase -• **coinbase**: _Buffer_ +• **coinbase**: *Buffer* -_Defined in [header.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L15)_ +*Defined in [header.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L15)* ---- +___ -### difficulty +### difficulty -• **difficulty**: _Buffer_ +• **difficulty**: *Buffer* -_Defined in [header.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L20)_ +*Defined in [header.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L20)* ---- +___ -### extraData +### extraData -• **extraData**: _Buffer_ +• **extraData**: *Buffer* -_Defined in [header.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L25)_ +*Defined in [header.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L25)* ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Defined in [header.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L22)_ +*Defined in [header.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L22)* ---- +___ -### gasUsed +### gasUsed -• **gasUsed**: _Buffer_ +• **gasUsed**: *Buffer* -_Defined in [header.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L23)_ +*Defined in [header.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L23)* ---- +___ -### mixHash +### mixHash -• **mixHash**: _Buffer_ +• **mixHash**: *Buffer* -_Defined in [header.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L26)_ +*Defined in [header.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L26)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Defined in [header.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L27)_ +*Defined in [header.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L27)* ---- +___ -### number +### number -• **number**: _Buffer_ +• **number**: *Buffer* -_Defined in [header.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L21)_ +*Defined in [header.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L21)* ---- +___ -### parentHash +### parentHash -• **parentHash**: _Buffer_ +• **parentHash**: *Buffer* -_Defined in [header.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L13)_ +*Defined in [header.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L13)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Defined in [header.ts:12](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L12)_ +*Defined in [header.ts:12](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L12)* ---- +___ -### receiptTrie +### receiptTrie -• **receiptTrie**: _Buffer_ +• **receiptTrie**: *Buffer* -_Defined in [header.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L18)_ +*Defined in [header.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L18)* ---- +___ -### stateRoot +### stateRoot -• **stateRoot**: _Buffer_ +• **stateRoot**: *Buffer* -_Defined in [header.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L16)_ +*Defined in [header.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L16)* ---- +___ -### timestamp +### timestamp -• **timestamp**: _Buffer_ +• **timestamp**: *Buffer* -_Defined in [header.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L24)_ +*Defined in [header.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L24)* ---- +___ -### transactionsTrie +### transactionsTrie -• **transactionsTrie**: _Buffer_ +• **transactionsTrie**: *Buffer* -_Defined in [header.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L17)_ +*Defined in [header.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L17)* ---- +___ -### uncleHash +### uncleHash -• **uncleHash**: _Buffer_ +• **uncleHash**: *Buffer* -_Defined in [header.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L14)_ +*Defined in [header.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L14)* ## Methods -### canonicalDifficulty +### canonicalDifficulty -▸ **canonicalDifficulty**(`parentBlock`: [Block](_block_.block.md)): _BN_ +▸ **canonicalDifficulty**(`parentBlock`: [Block](_block_.block.md)): *BN* -_Defined in [header.ts:134](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L134)_ +*Defined in [header.ts:134](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L134)* Returns the canonical difficulty for this block. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | --------------------------------- | -| `parentBlock` | [Block](_block_.block.md) | the parent `Block` of this header | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | the parent `Block` of this header | -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(): _Buffer_ +▸ **hash**(): *Buffer* -_Defined in [header.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L303)_ +*Defined in [header.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L303)* Returns the hash of the block header. -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### isGenesis +### isGenesis -▸ **isGenesis**(): _boolean_ +▸ **isGenesis**(): *boolean* -_Defined in [header.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L310)_ +*Defined in [header.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L310)* Checks if the block header is a genesis header. -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [header.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L330)_ +*Defined in [header.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L330)* Returns the rlp encoding of the block header -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### setGenesisParams +### setGenesisParams -▸ **setGenesisParams**(): _void_ +▸ **setGenesisParams**(): *void* -_Defined in [header.ts:317](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L317)_ +*Defined in [header.ts:317](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L317)* Turns the header into the canonical genesis block header. -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`_labels`: boolean): _object | string[]_ +▸ **toJSON**(`_labels`: boolean): *object | string[]* -_Defined in [header.ts:340](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L340)_ +*Defined in [header.ts:340](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L340)* Returns the block header in JSON format @@ -272,63 +272,63 @@ Returns the block header in JSON format **Parameters:** -| Name | Type | Default | -| --------- | ------- | ------- | -| `_labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`_labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md), `height?`: BN): _Promise‹void›_ +▸ **validate**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md), `height?`: BN): *Promise‹void›* -_Defined in [header.ts:255](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L255)_ +*Defined in [header.ts:255](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L255)* Validates the entire block header, throwing if invalid. **Parameters:** -| Name | Type | Description | -| ------------ | ------------------------------------------------- | -------------------------------------------------------------------------------- | -| `blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block is validating against | -| `height?` | BN | If this is an uncle header, this is the height of the block that is including it | +Name | Type | Description | +------ | ------ | ------ | +`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block is validating against | +`height?` | BN | If this is an uncle header, this is the height of the block that is including it | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateDifficulty +### validateDifficulty -▸ **validateDifficulty**(`parentBlock`: [Block](_block_.block.md)): _boolean_ +▸ **validateDifficulty**(`parentBlock`: [Block](_block_.block.md)): *boolean* -_Defined in [header.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L221)_ +*Defined in [header.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L221)* Checks that the block's `difficulty` matches the canonical difficulty. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | ------------------- | -| `parentBlock` | [Block](_block_.block.md) | this block's parent | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | this block's parent | -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### validateGasLimit +### validateGasLimit -▸ **validateGasLimit**(`parentBlock`: [Block](_block_.block.md)): _boolean_ +▸ **validateGasLimit**(`parentBlock`: [Block](_block_.block.md)): *boolean* -_Defined in [header.ts:231](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L231)_ +*Defined in [header.ts:231](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L231)* Validates the gasLimit. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | ------------------- | -| `parentBlock` | [Block](_block_.block.md) | this block's parent | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | this block's parent | -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/block/docs/classes/_index_.block.md b/packages/block/docs/classes/_index_.block.md index d8c493e9494..04c4313c76b 100644 --- a/packages/block/docs/classes/_index_.block.md +++ b/packages/block/docs/classes/_index_.block.md @@ -6,192 +6,192 @@ An object that represents the block ## Hierarchy -- **Block** +* **Block** ## Index ### Constructors -- [constructor](_index_.block.md#constructor) +* [constructor](_index_.block.md#constructor) ### Properties -- [header](_index_.block.md#header) -- [transactions](_index_.block.md#transactions) -- [txTrie](_index_.block.md#txtrie) -- [uncleHeaders](_index_.block.md#uncleheaders) +* [header](_index_.block.md#header) +* [transactions](_index_.block.md#transactions) +* [txTrie](_index_.block.md#txtrie) +* [uncleHeaders](_index_.block.md#uncleheaders) ### Accessors -- [raw](_index_.block.md#raw) +* [raw](_index_.block.md#raw) ### Methods -- [genTxTrie](_index_.block.md#gentxtrie) -- [hash](_index_.block.md#hash) -- [isGenesis](_index_.block.md#isgenesis) -- [serialize](_index_.block.md#serialize) -- [setGenesisParams](_index_.block.md#setgenesisparams) -- [toJSON](_index_.block.md#tojson) -- [validate](_index_.block.md#validate) -- [validateTransactions](_index_.block.md#validatetransactions) -- [validateTransactionsTrie](_index_.block.md#validatetransactionstrie) -- [validateUncles](_index_.block.md#validateuncles) -- [validateUnclesHash](_index_.block.md#validateuncleshash) +* [genTxTrie](_index_.block.md#gentxtrie) +* [hash](_index_.block.md#hash) +* [isGenesis](_index_.block.md#isgenesis) +* [serialize](_index_.block.md#serialize) +* [setGenesisParams](_index_.block.md#setgenesisparams) +* [toJSON](_index_.block.md#tojson) +* [validate](_index_.block.md#validate) +* [validateTransactions](_index_.block.md#validatetransactions) +* [validateTransactionsTrie](_index_.block.md#validatetransactionstrie) +* [validateUncles](_index_.block.md#validateuncles) +* [validateUnclesHash](_index_.block.md#validateuncleshash) ## Constructors -### constructor +### constructor -\+ **new Block**(`data`: Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[Block](\_index_.block.md)\_ +\+ **new Block**(`data`: Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md), `chainOptions`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[Block](_index_.block.md)* -_Defined in [block.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L20)_ +*Defined in [block.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L20)* Creates a new block object **Parameters:** -| Name | Type | Default | Description | -| ------ | --------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------- | -| `data` | Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md) | {} | The block's data. | -| `opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [Buffer[], Buffer[], Buffer[]] | [BlockData](../interfaces/_index_.blockdata.md) | {} | The block's data. | +`chainOptions` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | -**Returns:** _[Block](\_index_.block.md)\_ +**Returns:** *[Block](_index_.block.md)* ## Properties -### header +### header -• **header**: _[BlockHeader](\_header_.blockheader.md)\_ +• **header**: *[BlockHeader](_header_.blockheader.md)* -_Defined in [block.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L15)_ +*Defined in [block.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L15)* ---- +___ -### transactions +### transactions -• **transactions**: _Transaction[]_ = [] +• **transactions**: *Transaction[]* = [] -_Defined in [block.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L16)_ +*Defined in [block.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L16)* ---- +___ -### txTrie +### txTrie -• **txTrie**: _any_ = new Trie() +• **txTrie**: *any* = new Trie() -_Defined in [block.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L18)_ +*Defined in [block.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L18)* ---- +___ -### uncleHeaders +### uncleHeaders -• **uncleHeaders**: _[BlockHeader](\_header_.blockheader.md)[]\_ = [] +• **uncleHeaders**: *[BlockHeader](_header_.blockheader.md)[]* = [] -_Defined in [block.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L17)_ +*Defined in [block.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L17)* ## Accessors -### raw +### raw -• **get raw**(): _[Buffer[], Buffer[], Buffer[]]_ +• **get raw**(): *[Buffer[], Buffer[], Buffer[]]* -_Defined in [block.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L82)_ +*Defined in [block.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L87)* -**Returns:** _[Buffer[], Buffer[], Buffer[]]_ +**Returns:** *[Buffer[], Buffer[], Buffer[]]* ## Methods -### genTxTrie +### genTxTrie -▸ **genTxTrie**(): _Promise‹void›_ +▸ **genTxTrie**(): *Promise‹void›* -_Defined in [block.ts:131](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L131)_ +*Defined in [block.ts:136](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L136)* Generate transaction trie. The tx trie must be generated before the transaction trie can be validated with `validateTransactionTrie` -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### hash +### hash -▸ **hash**(): _Buffer_ +▸ **hash**(): *Buffer* -_Defined in [block.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L89)_ +*Defined in [block.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L94)* Produces a hash the RLP of the block -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### isGenesis +### isGenesis -▸ **isGenesis**(): _boolean_ +▸ **isGenesis**(): *boolean* -_Defined in [block.ts:96](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L96)_ +*Defined in [block.ts:101](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L101)* Determines if this block is the genesis block -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [block.ts:114](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L114)_ +*Defined in [block.ts:119](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L119)* Produces a serialization of the block. -**Returns:** _Buffer_ +**Returns:** *Buffer* -▸ **serialize**(`rlpEncode`: true): _Buffer_ +▸ **serialize**(`rlpEncode`: true): *Buffer* -_Defined in [block.ts:115](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L115)_ +*Defined in [block.ts:120](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L120)* **Parameters:** -| Name | Type | -| ----------- | ---- | -| `rlpEncode` | true | +Name | Type | +------ | ------ | +`rlpEncode` | true | -**Returns:** _Buffer_ +**Returns:** *Buffer* -▸ **serialize**(`rlpEncode`: false): _[Buffer[], Buffer[], Buffer[]]_ +▸ **serialize**(`rlpEncode`: false): *[Buffer[], Buffer[], Buffer[]]* -_Defined in [block.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L116)_ +*Defined in [block.ts:121](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L121)* **Parameters:** -| Name | Type | -| ----------- | ----- | -| `rlpEncode` | false | +Name | Type | +------ | ------ | +`rlpEncode` | false | -**Returns:** _[Buffer[], Buffer[], Buffer[]]_ +**Returns:** *[Buffer[], Buffer[], Buffer[]]* ---- +___ -### setGenesisParams +### setGenesisParams -▸ **setGenesisParams**(): _void_ +▸ **setGenesisParams**(): *void* -_Defined in [block.ts:103](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L103)_ +*Defined in [block.ts:108](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L108)* Turns the block into the canonical genesis block -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labeled`: boolean): _any_ +▸ **toJSON**(`labeled`: boolean): *any* -_Defined in [block.ts:238](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L238)_ +*Defined in [block.ts:243](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L243)* Returns the block in JSON format @@ -199,104 +199,104 @@ Returns the block in JSON format **Parameters:** -| Name | Type | Default | -| --------- | ------- | ------- | -| `labeled` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labeled` | boolean | false | -**Returns:** _any_ +**Returns:** *any* ---- +___ -### validate +### validate -▸ **validate**(`blockChain`: [Blockchain](../interfaces/_index_.blockchain.md)): _Promise‹void›_ +▸ **validate**(`blockChain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›* -_Defined in [block.ts:180](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L180)_ +*Defined in [block.ts:185](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L185)* Validates the entire block, throwing if invalid. **Parameters:** -| Name | Type | Description | -| ------------ | ------------------------------------------------- | -------------------------------------------------- | -| `blockChain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block wants to be part of | +Name | Type | Description | +------ | ------ | ------ | +`blockChain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block wants to be part of | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateTransactions +### validateTransactions -▸ **validateTransactions**(): _boolean_ +▸ **validateTransactions**(): *boolean* -_Defined in [block.ts:155](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L155)_ +*Defined in [block.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L160)* Validates the transactions -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validateTransactions**(`stringError`: false): _boolean_ +▸ **validateTransactions**(`stringError`: false): *boolean* -_Defined in [block.ts:156](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L156)_ +*Defined in [block.ts:161](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L161)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validateTransactions**(`stringError`: true): _string_ +▸ **validateTransactions**(`stringError`: true): *string* -_Defined in [block.ts:157](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L157)_ +*Defined in [block.ts:162](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L162)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### validateTransactionsTrie +### validateTransactionsTrie -▸ **validateTransactionsTrie**(): _boolean_ +▸ **validateTransactionsTrie**(): *boolean* -_Defined in [block.ts:141](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L141)_ +*Defined in [block.ts:146](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L146)* Validates the transaction trie -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### validateUncles +### validateUncles -▸ **validateUncles**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): _Promise‹void›_ +▸ **validateUncles**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md)): *Promise‹void›* -_Defined in [block.ts:215](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L215)_ +*Defined in [block.ts:220](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L220)* Validates the uncles that are in the block, if any. This method throws if they are invalid. **Parameters:** -| Name | Type | -| ------------ | ------------------------------------------------- | -| `blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | +Name | Type | +------ | ------ | +`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateUnclesHash +### validateUnclesHash -▸ **validateUnclesHash**(): _boolean_ +▸ **validateUnclesHash**(): *boolean* -_Defined in [block.ts:204](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L204)_ +*Defined in [block.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/block.ts#L209)* Validates the uncle's hash -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/block/docs/classes/_index_.blockheader.md b/packages/block/docs/classes/_index_.blockheader.md index 054a9577dd9..62b1c66c110 100644 --- a/packages/block/docs/classes/_index_.blockheader.md +++ b/packages/block/docs/classes/_index_.blockheader.md @@ -6,265 +6,265 @@ An object that represents the block header ## Hierarchy -- **BlockHeader** +* **BlockHeader** ## Index ### Constructors -- [constructor](_index_.blockheader.md#constructor) +* [constructor](_index_.blockheader.md#constructor) ### Properties -- [bloom](_index_.blockheader.md#bloom) -- [coinbase](_index_.blockheader.md#coinbase) -- [difficulty](_index_.blockheader.md#difficulty) -- [extraData](_index_.blockheader.md#extradata) -- [gasLimit](_index_.blockheader.md#gaslimit) -- [gasUsed](_index_.blockheader.md#gasused) -- [mixHash](_index_.blockheader.md#mixhash) -- [nonce](_index_.blockheader.md#nonce) -- [number](_index_.blockheader.md#number) -- [parentHash](_index_.blockheader.md#parenthash) -- [raw](_index_.blockheader.md#raw) -- [receiptTrie](_index_.blockheader.md#receipttrie) -- [stateRoot](_index_.blockheader.md#stateroot) -- [timestamp](_index_.blockheader.md#timestamp) -- [transactionsTrie](_index_.blockheader.md#transactionstrie) -- [uncleHash](_index_.blockheader.md#unclehash) +* [bloom](_index_.blockheader.md#bloom) +* [coinbase](_index_.blockheader.md#coinbase) +* [difficulty](_index_.blockheader.md#difficulty) +* [extraData](_index_.blockheader.md#extradata) +* [gasLimit](_index_.blockheader.md#gaslimit) +* [gasUsed](_index_.blockheader.md#gasused) +* [mixHash](_index_.blockheader.md#mixhash) +* [nonce](_index_.blockheader.md#nonce) +* [number](_index_.blockheader.md#number) +* [parentHash](_index_.blockheader.md#parenthash) +* [raw](_index_.blockheader.md#raw) +* [receiptTrie](_index_.blockheader.md#receipttrie) +* [stateRoot](_index_.blockheader.md#stateroot) +* [timestamp](_index_.blockheader.md#timestamp) +* [transactionsTrie](_index_.blockheader.md#transactionstrie) +* [uncleHash](_index_.blockheader.md#unclehash) ### Methods -- [canonicalDifficulty](_index_.blockheader.md#canonicaldifficulty) -- [hash](_index_.blockheader.md#hash) -- [isGenesis](_index_.blockheader.md#isgenesis) -- [serialize](_index_.blockheader.md#serialize) -- [setGenesisParams](_index_.blockheader.md#setgenesisparams) -- [toJSON](_index_.blockheader.md#tojson) -- [validate](_index_.blockheader.md#validate) -- [validateDifficulty](_index_.blockheader.md#validatedifficulty) -- [validateGasLimit](_index_.blockheader.md#validategaslimit) +* [canonicalDifficulty](_index_.blockheader.md#canonicaldifficulty) +* [hash](_index_.blockheader.md#hash) +* [isGenesis](_index_.blockheader.md#isgenesis) +* [serialize](_index_.blockheader.md#serialize) +* [setGenesisParams](_index_.blockheader.md#setgenesisparams) +* [toJSON](_index_.blockheader.md#tojson) +* [validate](_index_.blockheader.md#validate) +* [validateDifficulty](_index_.blockheader.md#validatedifficulty) +* [validateGasLimit](_index_.blockheader.md#validategaslimit) ## Constructors -### constructor +### constructor -\+ **new BlockHeader**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[BlockHeader](\_index_.blockheader.md)\_ +\+ **new BlockHeader**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md), `opts`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[BlockHeader](_index_.blockheader.md)* -_Defined in [header.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L29)_ +*Defined in [header.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L29)* Creates a new block header. **Parameters:** -| Name | Type | Default | Description | -| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) | {} | The data of the block header. | -| `opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) | {} | The data of the block header. | +`opts` | [ChainOptions](../interfaces/_index_.chainoptions.md) | {} | The network options for this block, and its header, uncle headers and txs. | -**Returns:** _[BlockHeader](\_index_.blockheader.md)\_ +**Returns:** *[BlockHeader](_index_.blockheader.md)* ## Properties -### bloom +### bloom -• **bloom**: _Buffer_ +• **bloom**: *Buffer* -_Defined in [header.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L19)_ +*Defined in [header.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L19)* ---- +___ -### coinbase +### coinbase -• **coinbase**: _Buffer_ +• **coinbase**: *Buffer* -_Defined in [header.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L15)_ +*Defined in [header.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L15)* ---- +___ -### difficulty +### difficulty -• **difficulty**: _Buffer_ +• **difficulty**: *Buffer* -_Defined in [header.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L20)_ +*Defined in [header.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L20)* ---- +___ -### extraData +### extraData -• **extraData**: _Buffer_ +• **extraData**: *Buffer* -_Defined in [header.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L25)_ +*Defined in [header.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L25)* ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Defined in [header.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L22)_ +*Defined in [header.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L22)* ---- +___ -### gasUsed +### gasUsed -• **gasUsed**: _Buffer_ +• **gasUsed**: *Buffer* -_Defined in [header.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L23)_ +*Defined in [header.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L23)* ---- +___ -### mixHash +### mixHash -• **mixHash**: _Buffer_ +• **mixHash**: *Buffer* -_Defined in [header.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L26)_ +*Defined in [header.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L26)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Defined in [header.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L27)_ +*Defined in [header.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L27)* ---- +___ -### number +### number -• **number**: _Buffer_ +• **number**: *Buffer* -_Defined in [header.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L21)_ +*Defined in [header.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L21)* ---- +___ -### parentHash +### parentHash -• **parentHash**: _Buffer_ +• **parentHash**: *Buffer* -_Defined in [header.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L13)_ +*Defined in [header.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L13)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Defined in [header.ts:12](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L12)_ +*Defined in [header.ts:12](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L12)* ---- +___ -### receiptTrie +### receiptTrie -• **receiptTrie**: _Buffer_ +• **receiptTrie**: *Buffer* -_Defined in [header.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L18)_ +*Defined in [header.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L18)* ---- +___ -### stateRoot +### stateRoot -• **stateRoot**: _Buffer_ +• **stateRoot**: *Buffer* -_Defined in [header.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L16)_ +*Defined in [header.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L16)* ---- +___ -### timestamp +### timestamp -• **timestamp**: _Buffer_ +• **timestamp**: *Buffer* -_Defined in [header.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L24)_ +*Defined in [header.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L24)* ---- +___ -### transactionsTrie +### transactionsTrie -• **transactionsTrie**: _Buffer_ +• **transactionsTrie**: *Buffer* -_Defined in [header.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L17)_ +*Defined in [header.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L17)* ---- +___ -### uncleHash +### uncleHash -• **uncleHash**: _Buffer_ +• **uncleHash**: *Buffer* -_Defined in [header.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L14)_ +*Defined in [header.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L14)* ## Methods -### canonicalDifficulty +### canonicalDifficulty -▸ **canonicalDifficulty**(`parentBlock`: [Block](_block_.block.md)): _BN_ +▸ **canonicalDifficulty**(`parentBlock`: [Block](_block_.block.md)): *BN* -_Defined in [header.ts:134](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L134)_ +*Defined in [header.ts:134](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L134)* Returns the canonical difficulty for this block. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | --------------------------------- | -| `parentBlock` | [Block](_block_.block.md) | the parent `Block` of this header | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | the parent `Block` of this header | -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(): _Buffer_ +▸ **hash**(): *Buffer* -_Defined in [header.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L303)_ +*Defined in [header.ts:303](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L303)* Returns the hash of the block header. -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### isGenesis +### isGenesis -▸ **isGenesis**(): _boolean_ +▸ **isGenesis**(): *boolean* -_Defined in [header.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L310)_ +*Defined in [header.ts:310](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L310)* Checks if the block header is a genesis header. -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [header.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L330)_ +*Defined in [header.ts:330](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L330)* Returns the rlp encoding of the block header -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### setGenesisParams +### setGenesisParams -▸ **setGenesisParams**(): _void_ +▸ **setGenesisParams**(): *void* -_Defined in [header.ts:317](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L317)_ +*Defined in [header.ts:317](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L317)* Turns the header into the canonical genesis block header. -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`_labels`: boolean): _object | string[]_ +▸ **toJSON**(`_labels`: boolean): *object | string[]* -_Defined in [header.ts:340](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L340)_ +*Defined in [header.ts:340](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L340)* Returns the block header in JSON format @@ -272,63 +272,63 @@ Returns the block header in JSON format **Parameters:** -| Name | Type | Default | -| --------- | ------- | ------- | -| `_labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`_labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md), `height?`: BN): _Promise‹void›_ +▸ **validate**(`blockchain`: [Blockchain](../interfaces/_index_.blockchain.md), `height?`: BN): *Promise‹void›* -_Defined in [header.ts:255](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L255)_ +*Defined in [header.ts:255](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L255)* Validates the entire block header, throwing if invalid. **Parameters:** -| Name | Type | Description | -| ------------ | ------------------------------------------------- | -------------------------------------------------------------------------------- | -| `blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block is validating against | -| `height?` | BN | If this is an uncle header, this is the height of the block that is including it | +Name | Type | Description | +------ | ------ | ------ | +`blockchain` | [Blockchain](../interfaces/_index_.blockchain.md) | the blockchain that this block is validating against | +`height?` | BN | If this is an uncle header, this is the height of the block that is including it | -**Returns:** _Promise‹void›_ +**Returns:** *Promise‹void›* ---- +___ -### validateDifficulty +### validateDifficulty -▸ **validateDifficulty**(`parentBlock`: [Block](_block_.block.md)): _boolean_ +▸ **validateDifficulty**(`parentBlock`: [Block](_block_.block.md)): *boolean* -_Defined in [header.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L221)_ +*Defined in [header.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L221)* Checks that the block's `difficulty` matches the canonical difficulty. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | ------------------- | -| `parentBlock` | [Block](_block_.block.md) | this block's parent | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | this block's parent | -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### validateGasLimit +### validateGasLimit -▸ **validateGasLimit**(`parentBlock`: [Block](_block_.block.md)): _boolean_ +▸ **validateGasLimit**(`parentBlock`: [Block](_block_.block.md)): *boolean* -_Defined in [header.ts:231](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L231)_ +*Defined in [header.ts:231](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header.ts#L231)* Validates the gasLimit. **Parameters:** -| Name | Type | Description | -| ------------- | ------------------------- | ------------------- | -| `parentBlock` | [Block](_block_.block.md) | this block's parent | +Name | Type | Description | +------ | ------ | ------ | +`parentBlock` | [Block](_block_.block.md) | this block's parent | -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/block/docs/interfaces/_index_.blockchain.md b/packages/block/docs/interfaces/_index_.blockchain.md index d9335ae045e..131e438c61e 100644 --- a/packages/block/docs/interfaces/_index_.blockchain.md +++ b/packages/block/docs/interfaces/_index_.blockchain.md @@ -4,35 +4,35 @@ ## Hierarchy -- **Blockchain** +* **Blockchain** ## Index ### Methods -- [getBlock](_index_.blockchain.md#getblock) +* [getBlock](_index_.blockchain.md#getblock) ## Methods -### getBlock +### getBlock -▸ **getBlock**(`hash`: Buffer, `callback`: function): _void_ +▸ **getBlock**(`hash`: Buffer, `callback`: function): *void* -_Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L75)_ +*Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L75)* **Parameters:** -▪ **hash**: _Buffer_ +▪ **hash**: *Buffer* -▪ **callback**: _function_ +▪ **callback**: *function* -▸ (`err`: Error | null, `block?`: [Block](../classes/_index_.block.md)): _void_ +▸ (`err`: Error | null, `block?`: [Block](../classes/_index_.block.md)): *void* **Parameters:** -| Name | Type | -| -------- | ------------------------------------ | -| `err` | Error | null | -| `block?` | [Block](../classes/_index_.block.md) | +Name | Type | +------ | ------ | +`err` | Error | null | +`block?` | [Block](../classes/_index_.block.md) | -**Returns:** _void_ +**Returns:** *void* diff --git a/packages/block/docs/interfaces/_index_.blockdata.md b/packages/block/docs/interfaces/_index_.blockdata.md index cace6878cc6..2a45869787f 100644 --- a/packages/block/docs/interfaces/_index_.blockdata.md +++ b/packages/block/docs/interfaces/_index_.blockdata.md @@ -6,36 +6,36 @@ A block's data. ## Hierarchy -- **BlockData** +* **BlockData** ## Index ### Properties -- [header](_index_.blockdata.md#optional-header) -- [transactions](_index_.blockdata.md#optional-transactions) -- [uncleHeaders](_index_.blockdata.md#optional-uncleheaders) +* [header](_index_.blockdata.md#optional-header) +* [transactions](_index_.blockdata.md#optional-transactions) +* [uncleHeaders](_index_.blockdata.md#optional-uncleheaders) ## Properties ### `Optional` header -• **header**? : _Buffer | [PrefixedHexString](../modules/\_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)\_ +• **header**? : *Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)* -_Defined in [types.ts:69](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L69)_ +*Defined in [types.ts:69](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L69)* ---- +___ ### `Optional` transactions -• **transactions**? : _Array‹Buffer | [PrefixedHexString](../modules/\_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | TxData›\_ +• **transactions**? : *Array‹Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | TxData›* -_Defined in [types.ts:70](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L70)_ +*Defined in [types.ts:70](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L70)* ---- +___ ### `Optional` uncleHeaders -• **uncleHeaders**? : _Array‹Buffer | [PrefixedHexString](../modules/\_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)›\_ +• **uncleHeaders**? : *Array‹Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)›* -_Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L71)_ +*Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L71)* diff --git a/packages/block/docs/interfaces/_index_.blockheaderdata.md b/packages/block/docs/interfaces/_index_.blockheaderdata.md index 33ed82e55c8..bf90af01328 100644 --- a/packages/block/docs/interfaces/_index_.blockheaderdata.md +++ b/packages/block/docs/interfaces/_index_.blockheaderdata.md @@ -6,144 +6,144 @@ A block header's data. ## Hierarchy -- **BlockHeaderData** +* **BlockHeaderData** ## Index ### Properties -- [bloom](_index_.blockheaderdata.md#optional-bloom) -- [coinbase](_index_.blockheaderdata.md#optional-coinbase) -- [difficulty](_index_.blockheaderdata.md#optional-difficulty) -- [extraData](_index_.blockheaderdata.md#optional-extradata) -- [gasLimit](_index_.blockheaderdata.md#optional-gaslimit) -- [gasUsed](_index_.blockheaderdata.md#optional-gasused) -- [mixHash](_index_.blockheaderdata.md#optional-mixhash) -- [nonce](_index_.blockheaderdata.md#optional-nonce) -- [number](_index_.blockheaderdata.md#optional-number) -- [parentHash](_index_.blockheaderdata.md#optional-parenthash) -- [receiptTrie](_index_.blockheaderdata.md#optional-receipttrie) -- [stateRoot](_index_.blockheaderdata.md#optional-stateroot) -- [timestamp](_index_.blockheaderdata.md#optional-timestamp) -- [transactionsTrie](_index_.blockheaderdata.md#optional-transactionstrie) -- [uncleHash](_index_.blockheaderdata.md#optional-unclehash) +* [bloom](_index_.blockheaderdata.md#optional-bloom) +* [coinbase](_index_.blockheaderdata.md#optional-coinbase) +* [difficulty](_index_.blockheaderdata.md#optional-difficulty) +* [extraData](_index_.blockheaderdata.md#optional-extradata) +* [gasLimit](_index_.blockheaderdata.md#optional-gaslimit) +* [gasUsed](_index_.blockheaderdata.md#optional-gasused) +* [mixHash](_index_.blockheaderdata.md#optional-mixhash) +* [nonce](_index_.blockheaderdata.md#optional-nonce) +* [number](_index_.blockheaderdata.md#optional-number) +* [parentHash](_index_.blockheaderdata.md#optional-parenthash) +* [receiptTrie](_index_.blockheaderdata.md#optional-receipttrie) +* [stateRoot](_index_.blockheaderdata.md#optional-stateroot) +* [timestamp](_index_.blockheaderdata.md#optional-timestamp) +* [transactionsTrie](_index_.blockheaderdata.md#optional-transactionstrie) +* [uncleHash](_index_.blockheaderdata.md#optional-unclehash) ## Properties ### `Optional` bloom -• **bloom**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **bloom**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:54](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L54)_ +*Defined in [types.ts:54](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L54)* ---- +___ ### `Optional` coinbase -• **coinbase**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **coinbase**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L50)_ +*Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L50)* ---- +___ ### `Optional` difficulty -• **difficulty**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **difficulty**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L55)_ +*Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L55)* ---- +___ ### `Optional` extraData -• **extraData**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **extraData**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L60)_ +*Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L60)* ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L57)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L57)* ---- +___ ### `Optional` gasUsed -• **gasUsed**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasUsed**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L58)_ +*Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L58)* ---- +___ ### `Optional` mixHash -• **mixHash**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **mixHash**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L61)_ +*Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L61)* ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L62)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L62)* ---- +___ ### `Optional` number -• **number**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **number**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L56)_ +*Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L56)* ---- +___ ### `Optional` parentHash -• **parentHash**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **parentHash**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L48)_ +*Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L48)* ---- +___ ### `Optional` receiptTrie -• **receiptTrie**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **receiptTrie**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L53)_ +*Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L53)* ---- +___ ### `Optional` stateRoot -• **stateRoot**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **stateRoot**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L51)_ +*Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L51)* ---- +___ ### `Optional` timestamp -• **timestamp**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **timestamp**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:59](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L59)_ +*Defined in [types.ts:59](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L59)* ---- +___ ### `Optional` transactionsTrie -• **transactionsTrie**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **transactionsTrie**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L52)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L52)* ---- +___ ### `Optional` uncleHash -• **uncleHash**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **uncleHash**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L49)_ +*Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L49)* diff --git a/packages/block/docs/interfaces/_index_.chainoptions.md b/packages/block/docs/interfaces/_index_.chainoptions.md index 70dc0bab846..e7e4d63e6d6 100644 --- a/packages/block/docs/interfaces/_index_.chainoptions.md +++ b/packages/block/docs/interfaces/_index_.chainoptions.md @@ -8,42 +8,42 @@ hardfork. ## Hierarchy -- **ChainOptions** +* **ChainOptions** ## Index ### Properties -- [chain](_index_.chainoptions.md#optional-chain) -- [common](_index_.chainoptions.md#optional-common) -- [hardfork](_index_.chainoptions.md#optional-hardfork) +* [chain](_index_.chainoptions.md#optional-chain) +* [common](_index_.chainoptions.md#optional-common) +* [hardfork](_index_.chainoptions.md#optional-hardfork) ## Properties ### `Optional` chain -• **chain**? : _number | string_ +• **chain**? : *number | string* -_Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L19)_ +*Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L19)* The chain of the block/block header, default: 'mainnet' ---- +___ ### `Optional` common -• **common**? : _Common_ +• **common**? : *Common* -_Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L14)_ +*Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L14)* A Common object defining the chain and the hardfork a block/block header belongs to. ---- +___ ### `Optional` hardfork -• **hardfork**? : _undefined | string_ +• **hardfork**? : *undefined | string* -_Defined in [types.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L24)_ +*Defined in [types.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L24)* The hardfork of the block/block header, default: 'petersburg' diff --git a/packages/block/docs/interfaces/_index_.transformabletobuffer.md b/packages/block/docs/interfaces/_index_.transformabletobuffer.md index ce6965defd2..15f0e769833 100644 --- a/packages/block/docs/interfaces/_index_.transformabletobuffer.md +++ b/packages/block/docs/interfaces/_index_.transformabletobuffer.md @@ -6,20 +6,20 @@ Any object that can be transformed into a `Buffer` ## Hierarchy -- **TransformableToBuffer** +* **TransformableToBuffer** ## Index ### Methods -- [toBuffer](_index_.transformabletobuffer.md#tobuffer) +* [toBuffer](_index_.transformabletobuffer.md#tobuffer) ## Methods -### toBuffer +### toBuffer -▸ **toBuffer**(): _Buffer_ +▸ **toBuffer**(): *Buffer* -_Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L31)_ +*Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L31)* -**Returns:** _Buffer_ +**Returns:** *Buffer* diff --git a/packages/block/docs/interfaces/_types_.blockchain.md b/packages/block/docs/interfaces/_types_.blockchain.md index 0dcd896ab4b..3256cc2d75d 100644 --- a/packages/block/docs/interfaces/_types_.blockchain.md +++ b/packages/block/docs/interfaces/_types_.blockchain.md @@ -4,35 +4,35 @@ ## Hierarchy -- **Blockchain** +* **Blockchain** ## Index ### Methods -- [getBlock](_types_.blockchain.md#getblock) +* [getBlock](_types_.blockchain.md#getblock) ## Methods -### getBlock +### getBlock -▸ **getBlock**(`hash`: Buffer, `callback`: function): _void_ +▸ **getBlock**(`hash`: Buffer, `callback`: function): *void* -_Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L75)_ +*Defined in [types.ts:75](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L75)* **Parameters:** -▪ **hash**: _Buffer_ +▪ **hash**: *Buffer* -▪ **callback**: _function_ +▪ **callback**: *function* -▸ (`err`: Error | null, `block?`: [Block](../classes/_block_.block.md)): _void_ +▸ (`err`: Error | null, `block?`: [Block](../classes/_block_.block.md)): *void* **Parameters:** -| Name | Type | -| -------- | ------------------------------------ | -| `err` | Error | null | -| `block?` | [Block](../classes/_block_.block.md) | +Name | Type | +------ | ------ | +`err` | Error | null | +`block?` | [Block](../classes/_block_.block.md) | -**Returns:** _void_ +**Returns:** *void* diff --git a/packages/block/docs/interfaces/_types_.blockdata.md b/packages/block/docs/interfaces/_types_.blockdata.md index f9fc8e65290..0e8ecffd2eb 100644 --- a/packages/block/docs/interfaces/_types_.blockdata.md +++ b/packages/block/docs/interfaces/_types_.blockdata.md @@ -6,36 +6,36 @@ A block's data. ## Hierarchy -- **BlockData** +* **BlockData** ## Index ### Properties -- [header](_types_.blockdata.md#optional-header) -- [transactions](_types_.blockdata.md#optional-transactions) -- [uncleHeaders](_types_.blockdata.md#optional-uncleheaders) +* [header](_types_.blockdata.md#optional-header) +* [transactions](_types_.blockdata.md#optional-transactions) +* [uncleHeaders](_types_.blockdata.md#optional-uncleheaders) ## Properties ### `Optional` header -• **header**? : _Buffer | [PrefixedHexString](../modules/\_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)\_ +• **header**? : *Buffer | [PrefixedHexString](../modules/_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)* -_Defined in [types.ts:69](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L69)_ +*Defined in [types.ts:69](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L69)* ---- +___ ### `Optional` transactions -• **transactions**? : _Array‹Buffer | [PrefixedHexString](../modules/\_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | TxData›\_ +• **transactions**? : *Array‹Buffer | [PrefixedHexString](../modules/_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | TxData›* -_Defined in [types.ts:70](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L70)_ +*Defined in [types.ts:70](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L70)* ---- +___ ### `Optional` uncleHeaders -• **uncleHeaders**? : _Array‹Buffer | [PrefixedHexString](../modules/\_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)›\_ +• **uncleHeaders**? : *Array‹Buffer | [PrefixedHexString](../modules/_types_.md#prefixedhexstring) | [BufferLike](../modules/_types_.md#bufferlike)[] | [BlockHeaderData](_index_.blockheaderdata.md)›* -_Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L71)_ +*Defined in [types.ts:71](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L71)* diff --git a/packages/block/docs/interfaces/_types_.blockheaderdata.md b/packages/block/docs/interfaces/_types_.blockheaderdata.md index 9a9c73f2214..a3c0f5fd990 100644 --- a/packages/block/docs/interfaces/_types_.blockheaderdata.md +++ b/packages/block/docs/interfaces/_types_.blockheaderdata.md @@ -6,144 +6,144 @@ A block header's data. ## Hierarchy -- **BlockHeaderData** +* **BlockHeaderData** ## Index ### Properties -- [bloom](_types_.blockheaderdata.md#optional-bloom) -- [coinbase](_types_.blockheaderdata.md#optional-coinbase) -- [difficulty](_types_.blockheaderdata.md#optional-difficulty) -- [extraData](_types_.blockheaderdata.md#optional-extradata) -- [gasLimit](_types_.blockheaderdata.md#optional-gaslimit) -- [gasUsed](_types_.blockheaderdata.md#optional-gasused) -- [mixHash](_types_.blockheaderdata.md#optional-mixhash) -- [nonce](_types_.blockheaderdata.md#optional-nonce) -- [number](_types_.blockheaderdata.md#optional-number) -- [parentHash](_types_.blockheaderdata.md#optional-parenthash) -- [receiptTrie](_types_.blockheaderdata.md#optional-receipttrie) -- [stateRoot](_types_.blockheaderdata.md#optional-stateroot) -- [timestamp](_types_.blockheaderdata.md#optional-timestamp) -- [transactionsTrie](_types_.blockheaderdata.md#optional-transactionstrie) -- [uncleHash](_types_.blockheaderdata.md#optional-unclehash) +* [bloom](_types_.blockheaderdata.md#optional-bloom) +* [coinbase](_types_.blockheaderdata.md#optional-coinbase) +* [difficulty](_types_.blockheaderdata.md#optional-difficulty) +* [extraData](_types_.blockheaderdata.md#optional-extradata) +* [gasLimit](_types_.blockheaderdata.md#optional-gaslimit) +* [gasUsed](_types_.blockheaderdata.md#optional-gasused) +* [mixHash](_types_.blockheaderdata.md#optional-mixhash) +* [nonce](_types_.blockheaderdata.md#optional-nonce) +* [number](_types_.blockheaderdata.md#optional-number) +* [parentHash](_types_.blockheaderdata.md#optional-parenthash) +* [receiptTrie](_types_.blockheaderdata.md#optional-receipttrie) +* [stateRoot](_types_.blockheaderdata.md#optional-stateroot) +* [timestamp](_types_.blockheaderdata.md#optional-timestamp) +* [transactionsTrie](_types_.blockheaderdata.md#optional-transactionstrie) +* [uncleHash](_types_.blockheaderdata.md#optional-unclehash) ## Properties ### `Optional` bloom -• **bloom**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **bloom**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:54](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L54)_ +*Defined in [types.ts:54](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L54)* ---- +___ ### `Optional` coinbase -• **coinbase**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **coinbase**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L50)_ +*Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L50)* ---- +___ ### `Optional` difficulty -• **difficulty**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **difficulty**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L55)_ +*Defined in [types.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L55)* ---- +___ ### `Optional` extraData -• **extraData**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **extraData**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L60)_ +*Defined in [types.ts:60](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L60)* ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L57)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L57)* ---- +___ ### `Optional` gasUsed -• **gasUsed**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasUsed**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L58)_ +*Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L58)* ---- +___ ### `Optional` mixHash -• **mixHash**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **mixHash**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L61)_ +*Defined in [types.ts:61](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L61)* ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L62)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L62)* ---- +___ ### `Optional` number -• **number**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **number**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L56)_ +*Defined in [types.ts:56](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L56)* ---- +___ ### `Optional` parentHash -• **parentHash**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **parentHash**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L48)_ +*Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L48)* ---- +___ ### `Optional` receiptTrie -• **receiptTrie**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **receiptTrie**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L53)_ +*Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L53)* ---- +___ ### `Optional` stateRoot -• **stateRoot**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **stateRoot**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L51)_ +*Defined in [types.ts:51](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L51)* ---- +___ ### `Optional` timestamp -• **timestamp**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **timestamp**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:59](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L59)_ +*Defined in [types.ts:59](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L59)* ---- +___ ### `Optional` transactionsTrie -• **transactionsTrie**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **transactionsTrie**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L52)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L52)* ---- +___ ### `Optional` uncleHash -• **uncleHash**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **uncleHash**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L49)_ +*Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L49)* diff --git a/packages/block/docs/interfaces/_types_.chainoptions.md b/packages/block/docs/interfaces/_types_.chainoptions.md index 002a2783b35..79da9a79090 100644 --- a/packages/block/docs/interfaces/_types_.chainoptions.md +++ b/packages/block/docs/interfaces/_types_.chainoptions.md @@ -8,42 +8,42 @@ hardfork. ## Hierarchy -- **ChainOptions** +* **ChainOptions** ## Index ### Properties -- [chain](_types_.chainoptions.md#optional-chain) -- [common](_types_.chainoptions.md#optional-common) -- [hardfork](_types_.chainoptions.md#optional-hardfork) +* [chain](_types_.chainoptions.md#optional-chain) +* [common](_types_.chainoptions.md#optional-common) +* [hardfork](_types_.chainoptions.md#optional-hardfork) ## Properties ### `Optional` chain -• **chain**? : _number | string_ +• **chain**? : *number | string* -_Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L19)_ +*Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L19)* The chain of the block/block header, default: 'mainnet' ---- +___ ### `Optional` common -• **common**? : _Common_ +• **common**? : *Common* -_Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L14)_ +*Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L14)* A Common object defining the chain and the hardfork a block/block header belongs to. ---- +___ ### `Optional` hardfork -• **hardfork**? : _undefined | string_ +• **hardfork**? : *undefined | string* -_Defined in [types.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L24)_ +*Defined in [types.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L24)* The hardfork of the block/block header, default: 'petersburg' diff --git a/packages/block/docs/interfaces/_types_.transformabletobuffer.md b/packages/block/docs/interfaces/_types_.transformabletobuffer.md index d71adf3d4e7..e5e4ab912c0 100644 --- a/packages/block/docs/interfaces/_types_.transformabletobuffer.md +++ b/packages/block/docs/interfaces/_types_.transformabletobuffer.md @@ -6,20 +6,20 @@ Any object that can be transformed into a `Buffer` ## Hierarchy -- **TransformableToBuffer** +* **TransformableToBuffer** ## Index ### Methods -- [toBuffer](_types_.transformabletobuffer.md#tobuffer) +* [toBuffer](_types_.transformabletobuffer.md#tobuffer) ## Methods -### toBuffer +### toBuffer -▸ **toBuffer**(): _Buffer_ +▸ **toBuffer**(): *Buffer* -_Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L31)_ +*Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L31)* -**Returns:** _Buffer_ +**Returns:** *Buffer* diff --git a/packages/block/docs/modules/_block_.md b/packages/block/docs/modules/_block_.md index 88272d00f68..2d7c1be49d5 100644 --- a/packages/block/docs/modules/_block_.md +++ b/packages/block/docs/modules/_block_.md @@ -6,4 +6,4 @@ ### Classes -- [Block](../classes/_block_.block.md) +* [Block](../classes/_block_.block.md) diff --git a/packages/block/docs/modules/_from_rpc_.md b/packages/block/docs/modules/_from_rpc_.md index f61caae9014..2a73aece9a8 100644 --- a/packages/block/docs/modules/_from_rpc_.md +++ b/packages/block/docs/modules/_from_rpc_.md @@ -6,24 +6,24 @@ ### Functions -- [blockFromRpc](_from_rpc_.md#blockfromrpc) +* [blockFromRpc](_from_rpc_.md#blockfromrpc) ## Functions -### blockFromRpc +### blockFromRpc -▸ **blockFromRpc**(`blockParams`: any, `uncles?`: any[], `chainOptions?`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[Block](../classes/\_block_.block.md)‹›\_ +▸ **blockFromRpc**(`blockParams`: any, `uncles?`: any[], `chainOptions?`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[Block](../classes/_block_.block.md)‹›* -_Defined in [from-rpc.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/from-rpc.ts#L14)_ +*Defined in [from-rpc.ts:15](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/from-rpc.ts#L15)* Creates a new block object from Ethereum JSON RPC. **Parameters:** -| Name | Type | Description | -| --------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------ | -| `blockParams` | any | Ethereum JSON RPC of block (eth_getBlockByNumber) | -| `uncles?` | any[] | Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex) | -| `chainOptions?` | [ChainOptions](../interfaces/_index_.chainoptions.md) | An object describing the blockchain | +Name | Type | Description | +------ | ------ | ------ | +`blockParams` | any | Ethereum JSON RPC of block (eth_getBlockByNumber) | +`uncles?` | any[] | Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex) | +`chainOptions?` | [ChainOptions](../interfaces/_index_.chainoptions.md) | An object describing the blockchain | -**Returns:** _[Block](../classes/\_block_.block.md)‹›\_ +**Returns:** *[Block](../classes/_block_.block.md)‹›* diff --git a/packages/block/docs/modules/_header_.md b/packages/block/docs/modules/_header_.md index 909cffa764a..0689d9c0fb2 100644 --- a/packages/block/docs/modules/_header_.md +++ b/packages/block/docs/modules/_header_.md @@ -6,4 +6,4 @@ ### Classes -- [BlockHeader](../classes/_header_.blockheader.md) +* [BlockHeader](../classes/_header_.blockheader.md) diff --git a/packages/block/docs/modules/_header_from_rpc_.md b/packages/block/docs/modules/_header_from_rpc_.md index ecc32a09c48..9fc2bbf137f 100644 --- a/packages/block/docs/modules/_header_from_rpc_.md +++ b/packages/block/docs/modules/_header_from_rpc_.md @@ -6,23 +6,23 @@ ### Functions -- [blockHeaderFromRpc](_header_from_rpc_.md#blockheaderfromrpc) +* [blockHeaderFromRpc](_header_from_rpc_.md#blockheaderfromrpc) ## Functions -### blockHeaderFromRpc +### blockHeaderFromRpc -▸ **blockHeaderFromRpc**(`blockParams`: any, `chainOptions?`: [ChainOptions](../interfaces/_index_.chainoptions.md)): _[BlockHeader](../classes/\_header_.blockheader.md)‹›\_ +▸ **blockHeaderFromRpc**(`blockParams`: any, `chainOptions?`: [ChainOptions](../interfaces/_index_.chainoptions.md)): *[BlockHeader](../classes/_header_.blockheader.md)‹›* -_Defined in [header-from-rpc.ts:11](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header-from-rpc.ts#L11)_ +*Defined in [header-from-rpc.ts:11](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/header-from-rpc.ts#L11)* Creates a new block header object from Ethereum JSON RPC. **Parameters:** -| Name | Type | Description | -| --------------- | ----------------------------------------------------- | ------------------------------------------------- | -| `blockParams` | any | Ethereum JSON RPC of block (eth_getBlockByNumber) | -| `chainOptions?` | [ChainOptions](../interfaces/_index_.chainoptions.md) | An object describing the blockchain | +Name | Type | Description | +------ | ------ | ------ | +`blockParams` | any | Ethereum JSON RPC of block (eth_getBlockByNumber) | +`chainOptions?` | [ChainOptions](../interfaces/_index_.chainoptions.md) | An object describing the blockchain | -**Returns:** _[BlockHeader](../classes/\_header_.blockheader.md)‹›\_ +**Returns:** *[BlockHeader](../classes/_header_.blockheader.md)‹›* diff --git a/packages/block/docs/modules/_index_.md b/packages/block/docs/modules/_index_.md index 66e60e83cd7..725b46e3458 100644 --- a/packages/block/docs/modules/_index_.md +++ b/packages/block/docs/modules/_index_.md @@ -6,38 +6,38 @@ ### Classes -- [Block](../classes/_index_.block.md) -- [BlockHeader](../classes/_index_.blockheader.md) +* [Block](../classes/_index_.block.md) +* [BlockHeader](../classes/_index_.blockheader.md) ### Interfaces -- [BlockData](../interfaces/_index_.blockdata.md) -- [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) -- [Blockchain](../interfaces/_index_.blockchain.md) -- [ChainOptions](../interfaces/_index_.chainoptions.md) -- [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) +* [BlockData](../interfaces/_index_.blockdata.md) +* [BlockHeaderData](../interfaces/_index_.blockheaderdata.md) +* [Blockchain](../interfaces/_index_.blockchain.md) +* [ChainOptions](../interfaces/_index_.chainoptions.md) +* [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) ### Type aliases -- [BufferLike](_index_.md#bufferlike) -- [PrefixedHexString](_index_.md#prefixedhexstring) +* [BufferLike](_index_.md#bufferlike) +* [PrefixedHexString](_index_.md#prefixedhexstring) ## Type aliases -### BufferLike +### BufferLike -Ƭ **BufferLike**: _Buffer | [TransformableToBuffer](../interfaces/\_index_.transformabletobuffer.md) | [PrefixedHexString](_index_.md#prefixedhexstring) | number\_ +Ƭ **BufferLike**: *Buffer | [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) | [PrefixedHexString](_index_.md#prefixedhexstring) | number* -_Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L42)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L42)* A Buffer, hex string prefixed with `0x`, Number, or an object with a toBuffer method such as BN. ---- +___ -### PrefixedHexString +### PrefixedHexString -Ƭ **PrefixedHexString**: _string_ +Ƭ **PrefixedHexString**: *string* -_Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L37)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L37)* A hex string prefixed with `0x`. diff --git a/packages/block/docs/modules/_types_.md b/packages/block/docs/modules/_types_.md index c2b5708cdbc..c4e8fffc512 100644 --- a/packages/block/docs/modules/_types_.md +++ b/packages/block/docs/modules/_types_.md @@ -6,33 +6,33 @@ ### Interfaces -- [BlockData](../interfaces/_types_.blockdata.md) -- [BlockHeaderData](../interfaces/_types_.blockheaderdata.md) -- [Blockchain](../interfaces/_types_.blockchain.md) -- [ChainOptions](../interfaces/_types_.chainoptions.md) -- [TransformableToBuffer](../interfaces/_types_.transformabletobuffer.md) +* [BlockData](../interfaces/_types_.blockdata.md) +* [BlockHeaderData](../interfaces/_types_.blockheaderdata.md) +* [Blockchain](../interfaces/_types_.blockchain.md) +* [ChainOptions](../interfaces/_types_.chainoptions.md) +* [TransformableToBuffer](../interfaces/_types_.transformabletobuffer.md) ### Type aliases -- [BufferLike](_types_.md#bufferlike) -- [PrefixedHexString](_types_.md#prefixedhexstring) +* [BufferLike](_types_.md#bufferlike) +* [PrefixedHexString](_types_.md#prefixedhexstring) ## Type aliases -### BufferLike +### BufferLike -Ƭ **BufferLike**: _Buffer | [TransformableToBuffer](../interfaces/\_index_.transformabletobuffer.md) | [PrefixedHexString](_types_.md#prefixedhexstring) | number\_ +Ƭ **BufferLike**: *Buffer | [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) | [PrefixedHexString](_types_.md#prefixedhexstring) | number* -_Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L42)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L42)* A Buffer, hex string prefixed with `0x`, Number, or an object with a toBuffer method such as BN. ---- +___ -### PrefixedHexString +### PrefixedHexString -Ƭ **PrefixedHexString**: _string_ +Ƭ **PrefixedHexString**: *string* -_Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L37)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/block/src/types.ts#L37)* A hex string prefixed with `0x`. diff --git a/packages/block/package.json b/packages/block/package.json index 1308ac7432e..43a10a01484 100644 --- a/packages/block/package.json +++ b/packages/block/package.json @@ -1,6 +1,6 @@ { "name": "ethereumjs-block", - "version": "2.2.0", + "version": "3.0.0", "description": "Provides Block serialization and help functions", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -54,7 +54,6 @@ "@types/node": "^11.13.4", "@types/tape": "^4.2.33", "browserify": "^16.2.3", - "ethereumjs-blockchain": "^4.0.3", "istanbul": "^0.4.1", "karma": "^4.1.0", "karma-browserify": "^6.0.0", @@ -70,8 +69,5 @@ "typedoc-plugin-markdown": "^2.2.17", "typescript": "^3.4.3", "typestrict": "^1.0.2" - }, - "publishConfig": { - "directory": "src" } } diff --git a/packages/block/src/block.ts b/packages/block/src/block.ts index 0944866b217..93d86bf3946 100644 --- a/packages/block/src/block.ts +++ b/packages/block/src/block.ts @@ -1,7 +1,7 @@ import Common from 'ethereumjs-common' import * as ethUtil from 'ethereumjs-util' import { BN, rlp } from 'ethereumjs-util' -import { Transaction } from 'ethereumjs-tx' +import { Transaction, TransactionOptions } from 'ethereumjs-tx' import { BlockHeader } from './header' import { Blockchain, BlockData, ChainOptions } from './types' @@ -23,25 +23,30 @@ export class Block { * Creates a new block object * * @param data - The block's data. - * @param opts - The network options for this block, and its header, uncle headers and txs. + * @param chainOptions - The network options for this block, and its header, uncle headers and txs. */ constructor( data: Buffer | [Buffer[], Buffer[], Buffer[]] | BlockData = {}, - opts: ChainOptions = {}, + chainOptions: ChainOptions = {}, ) { - if (opts.common) { - if (opts.chain !== undefined || opts.hardfork !== undefined) { + // Checking at runtime, to prevent errors down the path for JavaScript consumers. + if (data === null) { + data = {} + } + + if (chainOptions.common) { + if (chainOptions.chain !== undefined || chainOptions.hardfork !== undefined) { throw new Error( - 'Instantiation with both opts.common and opts.chain / opts.hardfork parameter not allowed!', + 'Instantiation with both chainOptions.common and chainOptions.chain / chainOptions.hardfork parameter not allowed!', ) } - this._common = opts.common + this._common = chainOptions.common } else { - const chain = opts.chain ? opts.chain : 'mainnet' + const chain = chainOptions.chain ? chainOptions.chain : 'mainnet' // TODO: Compute the hardfork based on this block's number. It can be implemented right now // because the block number is not immutable, so the Common can get out of sync. - const hardfork = opts.hardfork ? opts.hardfork : null + const hardfork = chainOptions.hardfork ? chainOptions.hardfork : null this._common = new Common(chain, hardfork) } @@ -67,14 +72,14 @@ export class Block { // parse uncle headers for (let i = 0; i < rawUncleHeaders.length; i++) { - this.uncleHeaders.push(new BlockHeader(rawUncleHeaders[i], opts)) + this.uncleHeaders.push(new BlockHeader(rawUncleHeaders[i], chainOptions)) } // parse transactions for (let i = 0; i < rawTransactions.length; i++) { // TODO: Pass the common object instead of the options. It can't be implemented right now // because the hardfork may be `null`. Read the above TODO for more info. - const tx = new Transaction(rawTransactions[i], opts) + const tx = new Transaction(rawTransactions[i], chainOptions as TransactionOptions) this.transactions.push(tx) } } diff --git a/packages/block/src/from-rpc.ts b/packages/block/src/from-rpc.ts index 0b434b175b3..21079190fd5 100644 --- a/packages/block/src/from-rpc.ts +++ b/packages/block/src/from-rpc.ts @@ -1,6 +1,7 @@ -import { FakeTransaction } from 'ethereumjs-tx' +import { FakeTransaction, TransactionOptions } from 'ethereumjs-tx' import * as ethUtil from 'ethereumjs-util' -import { Block, ChainOptions } from './index' +import { Block } from './index' +import { ChainOptions } from './types' import blockHeaderFromRpc from './header-from-rpc' @@ -35,7 +36,8 @@ export default function blockFromRpc( // override from address const fromAddress = ethUtil.toBuffer(txParams.from) delete txParams.from - const tx = new FakeTransaction(txParams, chainOptions) + + const tx = new FakeTransaction(txParams, chainOptions as TransactionOptions) tx.from = fromAddress tx.getSenderAddress = function() { return fromAddress @@ -49,7 +51,6 @@ export default function blockFromRpc( block.transactions.push(tx) } } - return block } @@ -60,7 +61,12 @@ function normalizeTxParams(_txParams: any) { txParams.data = txParams.data === undefined ? txParams.input : txParams.data // strict byte length checking txParams.to = txParams.to ? ethUtil.setLengthLeft(ethUtil.toBuffer(txParams.to), 20) : null + // v as raw signature value {0,1} - txParams.v = txParams.v < 27 ? txParams.v + 27 : txParams.v + // v is the recovery bit and can be either {0,1} or {27,28}. + // https://ethereum.stackexchange.com/questions/40679/why-the-value-of-v-is-always-either-27-11011-or-28-11100 + const v: number = txParams.v + txParams.v = v < 27 ? v + 27 : v + return txParams } diff --git a/packages/block/src/header.ts b/packages/block/src/header.ts index fd75123d0d2..9e727116c83 100644 --- a/packages/block/src/header.ts +++ b/packages/block/src/header.ts @@ -283,7 +283,7 @@ export class BlockHeader { throw new Error('invalid gas limit') } - if (utils.bufferToInt(parentBlock.header.number) + 1 !== utils.bufferToInt(this.number)) { + if (utils.bufferToInt(this.number) - utils.bufferToInt(parentBlock.header.number) !== 1) { throw new Error('invalid height') } diff --git a/packages/block/test/block.spec.ts b/packages/block/test/block.spec.ts index e13dcdf5922..fe27d386514 100644 --- a/packages/block/test/block.spec.ts +++ b/packages/block/test/block.spec.ts @@ -1,9 +1,8 @@ import Common from 'ethereumjs-common' import tape = require('tape') -import { rlp, toBuffer } from 'ethereumjs-util' +import { rlp } from 'ethereumjs-util' import { Block } from '../src/block' -import { setupBlockchain } from './util' tape('[Block]: block functions', function(t) { t.test('should test block initialization', function(st) { @@ -28,6 +27,21 @@ tape('[Block]: block functions', function(t) { st.end() }) + t.test('should initialize with undefined parameters without throwing', function(st) { + st.doesNotThrow(function() { + new Block() + st.end() + }) + }) + + t.test('should initialize with null parameters without throwing', function(st) { + st.doesNotThrow(function() { + const opts = { chain: 'mainnet' } + new Block(undefined, opts) + st.end() + }) + }) + const testData = require('./testdata/testdata.json') async function testTransactionValidation(st: tape.Test, block: Block) { @@ -130,109 +144,4 @@ tape('[Block]: block functions', function(t) { st.equal(typeof block.toJSON(true), 'object') st.end() }) - - t.test('should validate a valid block', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new Block( - { - header: { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - }, - { chain: 'ropsten' }, - ) - nextBlock.header.difficulty = toBuffer(nextBlock.header.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain) - st.ok(true) - st.end() - } catch (error) { - st.fail(error) - st.end() - } - }) - - t.test('should throw on invalid uncle hash', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new Block( - { - header: { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - uncleHash: Buffer.from('testFail'), - }, - }, - { chain: 'ropsten' }, - ) - nextBlock.header.difficulty = toBuffer(nextBlock.header.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - const testBadTx = require('./testdata/DataTestNotEnoughGAS.json') - t.test('should throw on invalid transaction', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new Block( - { - header: { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - transactions: [testBadTx.rlp], - }, - { chain: 'ropsten' }, - ) - nextBlock.header.difficulty = toBuffer(nextBlock.header.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should throw on invalid uncle data', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new Block( - { - header: { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - transactions: [], - uncleHeaders: ['0xabc', '0xdef'], - }, - { chain: 'ropsten' }, - ) - nextBlock.header.difficulty = toBuffer(nextBlock.header.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validateUncles(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) }) diff --git a/packages/block/test/from-rpc.spec.ts b/packages/block/test/from-rpc.spec.ts index d8d25d1bf7e..c9ee2a9a4fe 100644 --- a/packages/block/test/from-rpc.spec.ts +++ b/packages/block/test/from-rpc.spec.ts @@ -7,20 +7,20 @@ import * as uncleBlockData from './testdata/testdata-from-rpc-with-uncles_uncle- tape('[fromRPC]: block #2924874', function(t) { t.test('should create a block with transactions with valid signatures', function(st) { - let block = blockFromRpc(blockData) - let allValid = block.transactions.every(tx => tx.verifySignature()) + const block = blockFromRpc(blockData) + const allValid = block.transactions.every(tx => tx.verifySignature()) st.equal(allValid, true, 'all transaction signatures are valid') st.end() }) t.test('should create a block header with the correct hash', function(st) { - let block = blockHeaderFromRpc(blockData) + const block = blockHeaderFromRpc(blockData) st.ok(block.hash().compare(Buffer.from(blockData.hash))) st.end() }) t.test('should create a block with uncles', function(st) { - let block = blockFromRpc(blockDataWithUncles, [uncleBlockData]) + const block = blockFromRpc(blockDataWithUncles, [uncleBlockData]) st.ok(block.validateUnclesHash()) st.end() }) diff --git a/packages/block/test/header.spec.ts b/packages/block/test/header.spec.ts index a2f6335cedd..ab96da391e0 100644 --- a/packages/block/test/header.spec.ts +++ b/packages/block/test/header.spec.ts @@ -1,11 +1,9 @@ import tape = require('tape') import Common from 'ethereumjs-common' -import Blockchain from 'ethereumjs-blockchain' import * as utils from 'ethereumjs-util' import { rlp } from 'ethereumjs-util' import { BlockHeader } from '../src/header' import { Block } from '../src/block' -import { setupBlockchain } from './util' tape('[Block]: Header functions', function(t) { t.test('should create with default constructor', function(st) { @@ -103,200 +101,4 @@ tape('[Block]: Header functions', function(t) { ) st.end() }) - - t.test('should validate a genesis block header', st => { - const blockchain = new Blockchain({ chain: 'ropsten' }) - const genesisHeader = new BlockHeader(undefined, { chain: 'ropsten' }) - genesisHeader.setGenesisParams() - st.ok(genesisHeader.validate(blockchain)) - st.end() - }) - - t.test('should validate a valid block header', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain) - st.ok(true) - st.end() - } catch (error) { - st.fail(error) - st.end() - } - }) - - t.test('should not validate a block header with invalid difficulty', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - // difficulty purposefully not set to throw invalid difficulty - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a block header with invalid gas limit', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - // gas limit purposefully not set to throw invalid difficulty - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a block header with invalid height', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: utils.toBuffer(100), - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a block header with invalid timestamp', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - // timestamp purposefully not set to throw invalid timestamp - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a block header with invalid parent', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - // parentHash set to a random invalid parent hash - nextBlock.parentHash = utils.toBuffer( - '0xc596cb892b649b4917da8c6b78611346d55daf7bcf4375da86a2d98810888e84', - ) - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a header with invalid amount of extra data', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - nextBlock.extraData = Buffer.from('a'.repeat(1000)) - try { - await nextBlock.validate(blockchain) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) - - t.test('should not validate a header with invalid height', async st => { - const [blockchain, lastBlock] = await setupBlockchain() - const nextBlock = new BlockHeader( - { - number: 2, - parentHash: lastBlock.header.hash(), - gasLimit: lastBlock.header.gasLimit, - timestamp: Date.now(), - extraData: Buffer.from('abc'), - }, - { chain: 'ropsten' }, - ) - nextBlock.difficulty = utils.toBuffer(nextBlock.canonicalDifficulty(lastBlock)) - try { - await nextBlock.validate(blockchain, new utils.BN(15)) - st.fail('should not validate') - st.end() - } catch (error) { - st.ok(true) - st.end() - } - }) }) diff --git a/packages/block/test/util.ts b/packages/block/test/util.ts deleted file mode 100644 index e5b2382aaa1..00000000000 --- a/packages/block/test/util.ts +++ /dev/null @@ -1,41 +0,0 @@ -import Blockchain from 'ethereumjs-blockchain' -import { toBuffer } from 'ethereumjs-util' -import { Block } from '../src/block' -import { BlockHeader } from '../src/header' - -export const setupBlockchain = async (): Promise<[Blockchain, Block]> => { - return new Promise((resolve, reject) => { - const blockchain = new Blockchain({ - validateBlocks: true, - validatePow: false, - chain: 'ropsten', - }) - const genesisBlock = new Block(undefined, { chain: 'ropsten' }) - genesisBlock.setGenesisParams() - - blockchain.putGenesis(genesisBlock, (err?: Error) => { - if (err) { - return reject(err) - } - const nextBlock = new Block( - { - header: new BlockHeader({ - number: 1, - parentHash: genesisBlock.header.hash(), - gasLimit: genesisBlock.header.gasLimit, - timestamp: Date.now(), - }), - }, - { chain: 'ropsten' }, - ) - nextBlock.header.difficulty = toBuffer(nextBlock.header.canonicalDifficulty(genesisBlock)) - - blockchain.putBlock(nextBlock, async (err?: Error) => { - if (err) { - return reject(err) - } - resolve([blockchain, nextBlock]) - }) - }) - }) -} diff --git a/packages/blockchain/docs/README.md b/packages/blockchain/docs/README.md index 5ae95ccb14b..0d42639c2e3 100644 --- a/packages/blockchain/docs/README.md +++ b/packages/blockchain/docs/README.md @@ -6,4 +6,4 @@ ### Modules -- ["index"](modules/_index_.md) +* ["index"](modules/_index_.md) diff --git a/packages/blockchain/docs/classes/_index_.blockchain.md b/packages/blockchain/docs/classes/_index_.blockchain.md index 1e247110a8d..dfdea0fa20e 100644 --- a/packages/blockchain/docs/classes/_index_.blockchain.md +++ b/packages/blockchain/docs/classes/_index_.blockchain.md @@ -6,268 +6,268 @@ This class stores and interacts with blocks. ## Hierarchy -- **Blockchain** +* **Blockchain** ## Implements -- [BlockchainInterface](../interfaces/_index_.blockchaininterface.md) +* [BlockchainInterface](../interfaces/_index_.blockchaininterface.md) ## Index ### Constructors -- [constructor](_index_.blockchain.md#constructor) +* [constructor](_index_.blockchain.md#constructor) ### Properties -- [db](_index_.blockchain.md#db) -- [dbManager](_index_.blockchain.md#dbmanager) -- [ethash](_index_.blockchain.md#ethash) -- [validate](_index_.blockchain.md#validate) +* [db](_index_.blockchain.md#db) +* [dbManager](_index_.blockchain.md#dbmanager) +* [ethash](_index_.blockchain.md#ethash) +* [validate](_index_.blockchain.md#validate) ### Accessors -- [meta](_index_.blockchain.md#meta) +* [meta](_index_.blockchain.md#meta) ### Methods -- [delBlock](_index_.blockchain.md#delblock) -- [getBlock](_index_.blockchain.md#getblock) -- [getBlocks](_index_.blockchain.md#getblocks) -- [getDetails](_index_.blockchain.md#getdetails) -- [getHead](_index_.blockchain.md#gethead) -- [getLatestBlock](_index_.blockchain.md#getlatestblock) -- [getLatestHeader](_index_.blockchain.md#getlatestheader) -- [iterator](_index_.blockchain.md#iterator) -- [putBlock](_index_.blockchain.md#putblock) -- [putBlocks](_index_.blockchain.md#putblocks) -- [putGenesis](_index_.blockchain.md#putgenesis) -- [putHeader](_index_.blockchain.md#putheader) -- [putHeaders](_index_.blockchain.md#putheaders) -- [selectNeededHashes](_index_.blockchain.md#selectneededhashes) +* [delBlock](_index_.blockchain.md#delblock) +* [getBlock](_index_.blockchain.md#getblock) +* [getBlocks](_index_.blockchain.md#getblocks) +* [getDetails](_index_.blockchain.md#getdetails) +* [getHead](_index_.blockchain.md#gethead) +* [getLatestBlock](_index_.blockchain.md#getlatestblock) +* [getLatestHeader](_index_.blockchain.md#getlatestheader) +* [iterator](_index_.blockchain.md#iterator) +* [putBlock](_index_.blockchain.md#putblock) +* [putBlocks](_index_.blockchain.md#putblocks) +* [putGenesis](_index_.blockchain.md#putgenesis) +* [putHeader](_index_.blockchain.md#putheader) +* [putHeaders](_index_.blockchain.md#putheaders) +* [selectNeededHashes](_index_.blockchain.md#selectneededhashes) ## Constructors -### constructor +### constructor -\+ **new Blockchain**(`opts`: [BlockchainOptions](../interfaces/_index_.blockchainoptions.md)): _[Blockchain](\_index_.blockchain.md)\_ +\+ **new Blockchain**(`opts`: [BlockchainOptions](../interfaces/_index_.blockchainoptions.md)): *[Blockchain](_index_.blockchain.md)* -_Defined in [index.ts:184](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L184)_ +*Defined in [index.ts:182](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L182)* Creates new Blockchain object **Parameters:** -| Name | Type | Default | Description | -| ------ | --------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `opts` | [BlockchainOptions](../interfaces/_index_.blockchainoptions.md) | {} | An object with the options that this constructor takes. See [BlockchainOptions](../interfaces/_index_.blockchainoptions.md). | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`opts` | [BlockchainOptions](../interfaces/_index_.blockchainoptions.md) | {} | An object with the options that this constructor takes. See [BlockchainOptions](../interfaces/_index_.blockchainoptions.md). | -**Returns:** _[Blockchain](\_index_.blockchain.md)\_ +**Returns:** *[Blockchain](_index_.blockchain.md)* ## Properties -### db +### db -• **db**: _any_ +• **db**: *any* -_Defined in [index.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L172)_ +*Defined in [index.ts:170](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L170)* ---- +___ -### dbManager +### dbManager -• **dbManager**: _DBManager_ +• **dbManager**: *DBManager* -_Defined in [index.ts:173](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L173)_ +*Defined in [index.ts:171](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L171)* ---- +___ -### ethash +### ethash -• **ethash**: _any_ +• **ethash**: *any* -_Defined in [index.ts:174](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L174)_ +*Defined in [index.ts:172](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L172)* ---- +___ -### validate +### validate -• **validate**: _boolean_ = true +• **validate**: *boolean* = true -_Defined in [index.ts:181](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L181)_ +*Defined in [index.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L179)* This field is always `true`. It's here only for backwards compatibility. -**`deprecated`** +**`deprecated`** ## Accessors -### meta +### meta -• **get meta**(): _object_ +• **get meta**(): *object* -_Defined in [index.ts:242](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L242)_ +*Defined in [index.ts:240](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L240)* Returns an object with metadata about the Blockchain. It's defined for backwards compatibility. -**Returns:** _object_ +**Returns:** *object* -- **genesis**: _any_ = this.\_genesis +* **genesis**: *any* = this._genesis -- **heads**: _any_ = this.\_heads +* **heads**: *any* = this._heads -- **rawHead**: _any_ = this.\_headHeader +* **rawHead**: *any* = this._headHeader ## Methods -### delBlock +### delBlock -▸ **delBlock**(`blockHash`: Buffer, `cb`: any): _void_ +▸ **delBlock**(`blockHash`: Buffer, `cb`: any): *void* -_Implementation of [BlockchainInterface](../interfaces/\_index_.blockchaininterface.md)\_ +*Implementation of [BlockchainInterface](../interfaces/_index_.blockchaininterface.md)* -_Defined in [index.ts:890](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L890)_ +*Defined in [index.ts:889](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L889)* Deletes a block from the blockchain. All child blocks in the chain are deleted and any encountered heads are set to the parent block. **Parameters:** -| Name | Type | Description | -| ----------- | ------ | ----------------------------------- | -| `blockHash` | Buffer | The hash of the block to be deleted | -| `cb` | any | A callback. | +Name | Type | Description | +------ | ------ | ------ | +`blockHash` | Buffer | The hash of the block to be deleted | +`cb` | any | A callback. | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getBlock +### getBlock -▸ **getBlock**(`blockTag`: Buffer | number | BN, `cb`: any): _void_ +▸ **getBlock**(`blockTag`: Buffer | number | BN, `cb`: any): *void* -_Defined in [index.ts:627](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L627)_ +*Defined in [index.ts:626](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L626)* Gets a block by its hash. **Parameters:** -| Name | Type | Description | -| ---------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | -| `blockTag` | Buffer | number | BN | The block's hash or number | -| `cb` | any | The callback. It is given two parameters `err` and the found `block` (an instance of https://github.com/ethereumjs/ethereumjs-block) if any. | +Name | Type | Description | +------ | ------ | ------ | +`blockTag` | Buffer | number | BN | The block's hash or number | +`cb` | any | The callback. It is given two parameters `err` and the found `block` (an instance of https://github.com/ethereumjs/ethereumjs-block) if any. | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getBlocks +### getBlocks -▸ **getBlocks**(`blockId`: Buffer | number, `maxBlocks`: number, `skip`: number, `reverse`: boolean, `cb`: any): _void_ +▸ **getBlocks**(`blockId`: Buffer | number, `maxBlocks`: number, `skip`: number, `reverse`: boolean, `cb`: any): *void* -_Defined in [index.ts:650](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L650)_ +*Defined in [index.ts:649](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L649)* Looks up many blocks relative to blockId **Parameters:** -| Name | Type | Description | -| ----------- | -------------------- | ----------------------------------------------------------------------------- | -| `blockId` | Buffer | number | The block's hash or number | -| `maxBlocks` | number | Max number of blocks to return | -| `skip` | number | Number of blocks to skip apart | -| `reverse` | boolean | Fetch blocks in reverse | -| `cb` | any | The callback. It is given two parameters `err` and the found `blocks` if any. | +Name | Type | Description | +------ | ------ | ------ | +`blockId` | Buffer | number | The block's hash or number | +`maxBlocks` | number | Max number of blocks to return | +`skip` | number | Number of blocks to skip apart | +`reverse` | boolean | Fetch blocks in reverse | +`cb` | any | The callback. It is given two parameters `err` and the found `blocks` if any. | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getDetails +### getDetails -▸ **getDetails**(`_`: string, `cb`: any): _void_ +▸ **getDetails**(`_`: string, `cb`: any): *void* -_Implementation of [BlockchainInterface](../interfaces/\_index_.blockchaininterface.md)\_ +*Implementation of [BlockchainInterface](../interfaces/_index_.blockchaininterface.md)* -_Defined in [index.ts:691](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L691)_ +*Defined in [index.ts:690](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L690)* This method used to return block details by its hash. It's only here for backwards compatibility. -**`deprecated`** +**`deprecated`** **Parameters:** -| Name | Type | -| ---- | ------ | -| `_` | string | -| `cb` | any | +Name | Type | +------ | ------ | +`_` | string | +`cb` | any | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getHead +### getHead -▸ **getHead**(`name`: any, `cb?`: any): _void_ +▸ **getHead**(`name`: any, `cb?`: any): *void* -_Defined in [index.ts:338](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L338)_ +*Defined in [index.ts:336](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L336)* Returns the specified iterator head. **Parameters:** -| Name | Type | Description | -| ------ | ---- | ----------------------------------------------------------------------- | -| `name` | any | Optional name of the state root head (default: 'vm') | -| `cb?` | any | The callback. It is given two parameters `err` and the returned `block` | +Name | Type | Description | +------ | ------ | ------ | +`name` | any | Optional name of the state root head (default: 'vm') | +`cb?` | any | The callback. It is given two parameters `err` and the returned `block` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getLatestBlock +### getLatestBlock -▸ **getLatestBlock**(`cb`: any): _void_ +▸ **getLatestBlock**(`cb`: any): *void* -_Defined in [index.ts:378](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L378)_ +*Defined in [index.ts:376](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L376)* Returns the latest full block in the canonical chain. **Parameters:** -| Name | Type | Description | -| ---- | ---- | ----------------------------------------------------------------------- | -| `cb` | any | The callback. It is given two parameters `err` and the returned `block` | +Name | Type | Description | +------ | ------ | ------ | +`cb` | any | The callback. It is given two parameters `err` and the returned `block` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getLatestHeader +### getLatestHeader -▸ **getLatestHeader**(`cb`: any): _void_ +▸ **getLatestHeader**(`cb`: any): *void* -_Defined in [index.ts:361](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L361)_ +*Defined in [index.ts:359](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L359)* Returns the latest header in the canonical chain. **Parameters:** -| Name | Type | Description | -| ---- | ---- | ------------------------------------------------------------------------ | -| `cb` | any | The callback. It is given two parameters `err` and the returned `header` | +Name | Type | Description | +------ | ------ | ------ | +`cb` | any | The callback. It is given two parameters `err` and the returned `header` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### iterator +### iterator -▸ **iterator**(`name`: string, `onBlock`: any, `cb`: any): _void_ +▸ **iterator**(`name`: string, `onBlock`: any, `cb`: any): *void* -_Implementation of [BlockchainInterface](../interfaces/\_index_.blockchaininterface.md)\_ +*Implementation of [BlockchainInterface](../interfaces/_index_.blockchaininterface.md)* -_Defined in [index.ts:1024](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L1024)_ +*Defined in [index.ts:1026](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L1026)* Iterates through blocks starting at the specified iterator head and calls the onBlock function on each block. The current location of an iterator head can be retrieved using the `getHead()` @@ -275,125 +275,125 @@ method. **Parameters:** -| Name | Type | Description | -| --------- | ------ | ------------------------------------------------------------ | -| `name` | string | Name of the state root head | -| `onBlock` | any | Function called on each block with params (block, reorg, cb) | -| `cb` | any | A callback function | +Name | Type | Description | +------ | ------ | ------ | +`name` | string | Name of the state root head | +`onBlock` | any | Function called on each block with params (block, reorg, cb) | +`cb` | any | A callback function | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putBlock +### putBlock -▸ **putBlock**(`block`: object, `cb`: any, `isGenesis?`: undefined | false | true): _void_ +▸ **putBlock**(`block`: object, `cb`: any, `isGenesis?`: undefined | false | true): *void* -_Defined in [index.ts:407](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L407)_ +*Defined in [index.ts:405](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L405)* Adds a block to the blockchain. **Parameters:** -| Name | Type | Description | -| ------------ | ---------------------------------- | -------------------------------------------------------------------- | -| `block` | object | The block to be added to the blockchain | -| `cb` | any | The callback. It is given two parameters `err` and the saved `block` | -| `isGenesis?` | undefined | false | true | - | +Name | Type | Description | +------ | ------ | ------ | +`block` | object | The block to be added to the blockchain | +`cb` | any | The callback. It is given two parameters `err` and the saved `block` | +`isGenesis?` | undefined | false | true | - | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putBlocks +### putBlocks -▸ **putBlocks**(`blocks`: Array‹any›, `cb`: any): _void_ +▸ **putBlocks**(`blocks`: Array‹any›, `cb`: any): *void* -_Defined in [index.ts:391](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L391)_ +*Defined in [index.ts:389](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L389)* Adds many blocks to the blockchain. **Parameters:** -| Name | Type | Description | -| -------- | ---------- | --------------------------------------------------------------------------------- | -| `blocks` | Array‹any› | The blocks to be added to the blockchain | -| `cb` | any | The callback. It is given two parameters `err` and the last of the saved `blocks` | +Name | Type | Description | +------ | ------ | ------ | +`blocks` | Array‹any› | The blocks to be added to the blockchain | +`cb` | any | The callback. It is given two parameters `err` and the last of the saved `blocks` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putGenesis +### putGenesis -▸ **putGenesis**(`genesis`: any, `cb`: any): _void_ +▸ **putGenesis**(`genesis`: any, `cb`: any): *void* -_Defined in [index.ts:328](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L328)_ +*Defined in [index.ts:326](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L326)* Puts the genesis block in the database **Parameters:** -| Name | Type | Description | -| --------- | ---- | -------------------------------------------------------------------- | -| `genesis` | any | The genesis block to be added | -| `cb` | any | The callback. It is given two parameters `err` and the saved `block` | +Name | Type | Description | +------ | ------ | ------ | +`genesis` | any | The genesis block to be added | +`cb` | any | The callback. It is given two parameters `err` and the saved `block` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putHeader +### putHeader -▸ **putHeader**(`header`: object, `cb`: any): _void_ +▸ **putHeader**(`header`: object, `cb`: any): *void* -_Defined in [index.ts:439](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L439)_ +*Defined in [index.ts:437](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L437)* Adds a header to the blockchain. **Parameters:** -| Name | Type | Description | -| -------- | ------ | --------------------------------------------------------------------- | -| `header` | object | The header to be added to the blockchain | -| `cb` | any | The callback. It is given two parameters `err` and the saved `header` | +Name | Type | Description | +------ | ------ | ------ | +`header` | object | The header to be added to the blockchain | +`cb` | any | The callback. It is given two parameters `err` and the saved `header` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putHeaders +### putHeaders -▸ **putHeaders**(`headers`: Array‹any›, `cb`: any): _void_ +▸ **putHeaders**(`headers`: Array‹any›, `cb`: any): *void* -_Defined in [index.ts:423](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L423)_ +*Defined in [index.ts:421](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L421)* Adds many headers to the blockchain. **Parameters:** -| Name | Type | Description | -| --------- | ---------- | ---------------------------------------------------------------------------------- | -| `headers` | Array‹any› | The headers to be added to the blockchain | -| `cb` | any | The callback. It is given two parameters `err` and the last of the saved `headers` | +Name | Type | Description | +------ | ------ | ------ | +`headers` | Array‹any› | The headers to be added to the blockchain | +`cb` | any | The callback. It is given two parameters `err` and the last of the saved `headers` | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### selectNeededHashes +### selectNeededHashes -▸ **selectNeededHashes**(`hashes`: Array‹any›, `cb`: any): _void_ +▸ **selectNeededHashes**(`hashes`: Array‹any›, `cb`: any): *void* -_Defined in [index.ts:701](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L701)_ +*Defined in [index.ts:700](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L700)* Given an ordered array, returns to the callback an array of hashes that are not in the blockchain yet. **Parameters:** -| Name | Type | Description | -| -------- | ---------- | ---------------------------------------------------------------- | -| `hashes` | Array‹any› | Ordered array of hashes | -| `cb` | any | The callback. It is given two parameters `err` and hashes found. | +Name | Type | Description | +------ | ------ | ------ | +`hashes` | Array‹any› | Ordered array of hashes | +`cb` | any | The callback. It is given two parameters `err` and hashes found. | -**Returns:** _void_ +**Returns:** *void* diff --git a/packages/blockchain/docs/interfaces/_index_.blockchaininterface.md b/packages/blockchain/docs/interfaces/_index_.blockchaininterface.md index 22e1026c9e3..e4d2543f556 100644 --- a/packages/blockchain/docs/interfaces/_index_.blockchaininterface.md +++ b/packages/blockchain/docs/interfaces/_index_.blockchaininterface.md @@ -4,76 +4,76 @@ ## Hierarchy -- **BlockchainInterface** +* **BlockchainInterface** ## Implemented by -- [Blockchain](../classes/_index_.blockchain.md) +* [Blockchain](../classes/_index_.blockchain.md) ## Index ### Methods -- [delBlock](_index_.blockchaininterface.md#delblock) -- [getBlock](_index_.blockchaininterface.md#getblock) -- [getDetails](_index_.blockchaininterface.md#getdetails) -- [iterator](_index_.blockchaininterface.md#iterator) -- [putBlock](_index_.blockchaininterface.md#putblock) +* [delBlock](_index_.blockchaininterface.md#delblock) +* [getBlock](_index_.blockchaininterface.md#getblock) +* [getDetails](_index_.blockchaininterface.md#getdetails) +* [iterator](_index_.blockchaininterface.md#iterator) +* [putBlock](_index_.blockchaininterface.md#putblock) ## Methods -### delBlock +### delBlock -▸ **delBlock**(`blockHash`: Buffer, `cb`: any): _void_ +▸ **delBlock**(`blockHash`: Buffer, `cb`: any): *void* -_Defined in [index.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L42)_ +*Defined in [index.ts:40](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L40)* Deletes a block from the blockchain. All child blocks in the chain are deleted and any encountered heads are set to the parent block. **Parameters:** -| Name | Type | Description | -| ----------- | ------ | ----------------------------------- | -| `blockHash` | Buffer | The hash of the block to be deleted | -| `cb` | any | A callback. | +Name | Type | Description | +------ | ------ | ------ | +`blockHash` | Buffer | The hash of the block to be deleted | +`cb` | any | A callback. | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getBlock +### getBlock -▸ **getBlock**(`blockTag`: Buffer | number | BN, `cb`: function): _void_ +▸ **getBlock**(`blockTag`: Buffer | number | BN, `cb`: function): *void* -_Defined in [index.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L47)_ +*Defined in [index.ts:45](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L45)* Returns a block by its hash or number. **Parameters:** -▪ **blockTag**: _Buffer | number | BN_ +▪ **blockTag**: *Buffer | number | BN* -▪ **cb**: _function_ +▪ **cb**: *function* -▸ (`err`: Error | null, `block?`: [Block](../modules/_index_.md#block)): _void_ +▸ (`err`: Error | null, `block?`: Block): *void* **Parameters:** -| Name | Type | -| -------- | ------------------------------------ | -| `err` | Error | null | -| `block?` | [Block](../modules/_index_.md#block) | +Name | Type | +------ | ------ | +`err` | Error | null | +`block?` | Block | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### getDetails +### getDetails -▸ **getDetails**(`_`: string, `cb`: any): _void_ +▸ **getDetails**(`_`: string, `cb`: any): *void* -_Defined in [index.ts:66](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L66)_ +*Defined in [index.ts:64](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L64)* This method is only here for backwards compatibility. It can be removed once [this PR](https://github.com/ethereumjs/ethereumjs-block/pull/72/files) gets merged, released, @@ -83,50 +83,50 @@ The method should just call `cb` with `null` as first argument. **Parameters:** -| Name | Type | -| ---- | ------ | -| `_` | string | -| `cb` | any | +Name | Type | +------ | ------ | +`_` | string | +`cb` | any | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### iterator +### iterator -▸ **iterator**(`name`: string, `onBlock`: any, `cb`: any): _void_ +▸ **iterator**(`name`: string, `onBlock`: any, `cb`: any): *void* -_Defined in [index.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L57)_ +*Defined in [index.ts:55](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L55)* Iterates through blocks starting at the specified iterator head and calls the onBlock function on each block. **Parameters:** -| Name | Type | Description | -| --------- | ------ | ------------------------------------------------------------ | -| `name` | string | Name of the state root head | -| `onBlock` | any | Function called on each block with params (block, reorg, cb) | -| `cb` | any | A callback function | +Name | Type | Description | +------ | ------ | ------ | +`name` | string | Name of the state root head | +`onBlock` | any | Function called on each block with params (block, reorg, cb) | +`cb` | any | A callback function | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### putBlock +### putBlock -▸ **putBlock**(`block`: [Block](../modules/_index_.md#block), `cb`: any, `isGenesis?`: undefined | false | true): _void_ +▸ **putBlock**(`block`: Block, `cb`: any, `isGenesis?`: undefined | false | true): *void* -_Defined in [index.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L33)_ +*Defined in [index.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L31)* Adds a block to the blockchain. **Parameters:** -| Name | Type | Description | -| ------------ | ------------------------------------ | -------------------------------------------------------------------- | -| `block` | [Block](../modules/_index_.md#block) | The block to be added to the blockchain. | -| `cb` | any | The callback. It is given two parameters `err` and the saved `block` | -| `isGenesis?` | undefined | false | true | True if block is the genesis block. | +Name | Type | Description | +------ | ------ | ------ | +`block` | Block | The block to be added to the blockchain. | +`cb` | any | The callback. It is given two parameters `err` and the saved `block` | +`isGenesis?` | undefined | false | true | True if block is the genesis block. | -**Returns:** _void_ +**Returns:** *void* diff --git a/packages/blockchain/docs/interfaces/_index_.blockchainoptions.md b/packages/blockchain/docs/interfaces/_index_.blockchainoptions.md index dec6915a9a3..55f62caad04 100644 --- a/packages/blockchain/docs/interfaces/_index_.blockchainoptions.md +++ b/packages/blockchain/docs/interfaces/_index_.blockchainoptions.md @@ -6,94 +6,94 @@ This are the options that the Blockchain constructor can receive. ## Hierarchy -- **BlockchainOptions** +* **BlockchainOptions** ## Index ### Properties -- [chain](_index_.blockchainoptions.md#optional-chain) -- [common](_index_.blockchainoptions.md#optional-common) -- [db](_index_.blockchainoptions.md#optional-db) -- [hardfork](_index_.blockchainoptions.md#optional-hardfork) -- [validate](_index_.blockchainoptions.md#optional-validate) -- [validateBlocks](_index_.blockchainoptions.md#optional-validateblocks) -- [validatePow](_index_.blockchainoptions.md#optional-validatepow) +* [chain](_index_.blockchainoptions.md#optional-chain) +* [common](_index_.blockchainoptions.md#optional-common) +* [db](_index_.blockchainoptions.md#optional-db) +* [hardfork](_index_.blockchainoptions.md#optional-hardfork) +* [validate](_index_.blockchainoptions.md#optional-validate) +* [validateBlocks](_index_.blockchainoptions.md#optional-validateblocks) +* [validatePow](_index_.blockchainoptions.md#optional-validatepow) ## Properties ### `Optional` chain -• **chain**? : _string | number_ +• **chain**? : *string | number* -_Defined in [index.ts:76](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L76)_ +*Defined in [index.ts:74](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L74)* The chain id or name. Default: `"mainnet"`. ---- +___ ### `Optional` common -• **common**? : _Common_ +• **common**? : *Common* -_Defined in [index.ts:87](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L87)_ +*Defined in [index.ts:85](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L85)* An alternative way to specify the chain and hardfork is by passing a Common instance. ---- +___ ### `Optional` db -• **db**? : _any_ +• **db**? : *any* -_Defined in [index.ts:93](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L93)_ +*Defined in [index.ts:91](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L91)* Database to store blocks and metadata. Should be a [levelup](https://github.com/rvagg/node-levelup) instance. ---- +___ ### `Optional` hardfork -• **hardfork**? : _string | null_ +• **hardfork**? : *string | null* -_Defined in [index.ts:82](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L82)_ +*Defined in [index.ts:80](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L80)* Hardfork for the blocks. If `undefined` or `null` is passed, it gets computed based on block numbers. ---- +___ ### `Optional` validate -• **validate**? : _undefined | false | true_ +• **validate**? : *undefined | false | true* -_Defined in [index.ts:101](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L101)_ +*Defined in [index.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L99)* This the flag indicates if blocks and Proof-of-Work should be validated. This option can't be used in conjunction with `validatePow` nor `validateBlocks`. -**`deprecated`** +**`deprecated`** ---- +___ ### `Optional` validateBlocks -• **validateBlocks**? : _undefined | false | true_ +• **validateBlocks**? : *undefined | false | true* -_Defined in [index.ts:115](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L115)_ +*Defined in [index.ts:113](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L113)* This flags indicates if blocks should be validated. See Block#validate for details. If `validate` is provided, this option takes its value. If neither `validate` nor this option are provided, it defaults to `true`. ---- +___ ### `Optional` validatePow -• **validatePow**? : _undefined | false | true_ +• **validatePow**? : *undefined | false | true* -_Defined in [index.ts:108](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L108)_ +*Defined in [index.ts:106](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L106)* This flags indicates if Proof-of-work should be validated. If `validate` is provided, this option takes its value. If neither `validate` nor this option are provided, it defaults to diff --git a/packages/blockchain/docs/modules/_index_.md b/packages/blockchain/docs/modules/_index_.md index 278b7c673e8..bbd769b14ec 100644 --- a/packages/blockchain/docs/modules/_index_.md +++ b/packages/blockchain/docs/modules/_index_.md @@ -6,21 +6,9 @@ ### Classes -- [Blockchain](../classes/_index_.blockchain.md) +* [Blockchain](../classes/_index_.blockchain.md) ### Interfaces -- [BlockchainInterface](../interfaces/_index_.blockchaininterface.md) -- [BlockchainOptions](../interfaces/_index_.blockchainoptions.md) - -### Type aliases - -- [Block](_index_.md#block) - -## Type aliases - -### Block - -Ƭ **Block**: _any_ - -_Defined in [index.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/blockchain/src/index.ts#L23)_ +* [BlockchainInterface](../interfaces/_index_.blockchaininterface.md) +* [BlockchainOptions](../interfaces/_index_.blockchainoptions.md) diff --git a/packages/blockchain/package.json b/packages/blockchain/package.json index 6dd703afaba..e05b6524de5 100644 --- a/packages/blockchain/package.json +++ b/packages/blockchain/package.json @@ -38,7 +38,7 @@ "dependencies": { "async": "^2.6.1", "ethashjs": "~0.0.7", - "ethereumjs-block": "~2.2.2", + "ethereumjs-block": "~3.0.0", "ethereumjs-common": "^1.5.0", "ethereumjs-util": "~6.1.0", "flow-stoplight": "^1.0.0", diff --git a/packages/blockchain/src/dbManager.ts b/packages/blockchain/src/dbManager.ts index 1c07d159d9e..7d5db247fa1 100644 --- a/packages/blockchain/src/dbManager.ts +++ b/packages/blockchain/src/dbManager.ts @@ -14,7 +14,7 @@ import { import BN = require('bn.js') const level = require('level-mem') -const Block = require('ethereumjs-block') +import { Block, BlockHeader } from 'ethereumjs-block' /** * Abstraction over a DB to facilitate storing/fetching blockchain-related @@ -83,7 +83,7 @@ export default class DBManager { throw new Error('Unknown blockTag type') } - const header = (await this.getHeader(hash, number)).raw + const header: any = (await this.getHeader(hash, number)).raw let body try { body = await this.getBody(hash, number) @@ -91,7 +91,8 @@ export default class DBManager { body = [[], []] } - return new Block([header].concat(body), { common: this._common }) + const blockData = [header].concat(body) as [Buffer[], Buffer[], Buffer[]] + return new Block(blockData, { common: this._common }) } /** @@ -105,10 +106,11 @@ export default class DBManager { /** * Fetches header of a block given its hash and number. */ + async getHeader(hash: Buffer, number: BN) { const key = headerKey(number, hash) const encodedHeader = await this.get(key, { cache: 'header' }) - return new Block.Header(rlp.decode(encodedHeader), { + return new BlockHeader(rlp.decode(encodedHeader), { common: this._common, }) } diff --git a/packages/blockchain/src/index.ts b/packages/blockchain/src/index.ts index 1ef5e84c766..f2e44132382 100644 --- a/packages/blockchain/src/index.ts +++ b/packages/blockchain/src/index.ts @@ -14,14 +14,12 @@ import { tdKey, } from './util' -const Block = require('ethereumjs-block') +import { Block, BlockHeader } from 'ethereumjs-block' const Ethash = require('ethashjs') const Stoplight = require('flow-stoplight') const level = require('level-mem') const semaphore = require('semaphore') -export type Block = any - export interface BlockchainInterface { /** * Adds a block to the blockchain. @@ -314,7 +312,7 @@ export default class Blockchain implements BlockchainInterface { * @hidden */ _setCanonicalGenesisBlock(cb: any): void { - const genesisBlock = new Block(null, { common: this._common }) + const genesisBlock = new Block(undefined, { common: this._common }) genesisBlock.setGenesisParams() this._putBlockOrHeader(genesisBlock, cb, true) } @@ -451,7 +449,7 @@ export default class Blockchain implements BlockchainInterface { */ _putBlockOrHeader(item: any, cb: any, isGenesis?: boolean) { const self = this - const isHeader = item instanceof Block.Header + const isHeader = item instanceof BlockHeader let block = isHeader ? new Block([item.raw, [], []], { common: item._common }) : item const header = block.header const hash = block.hash() @@ -470,28 +468,29 @@ export default class Blockchain implements BlockchainInterface { async.series( [ - verify, + async.asyncify(async function() { + if (!self._validateBlocks) { + return + } + + if (!isGenesis && block.isGenesis()) { + throw new Error('already have genesis set') + } + + await block.validate(self) + return + }), verifyPOW, getCurrentTd, getBlockTd, rebuildInfo, - cb => self._batchDbOps(dbOps.concat(self._saveHeadOps()), cb), + cb => { + return self._batchDbOps(dbOps.concat(self._saveHeadOps()), cb) + }, ], cb, ) - function verify(next: any) { - if (!self._validateBlocks) { - return next() - } - - if (!isGenesis && block.isGenesis()) { - return next(new Error('already have genesis set')) - } - - block.validate(self, next) - } - function verifyPOW(next: any) { if (!self._validatePow) { return next() @@ -526,11 +525,11 @@ export default class Blockchain implements BlockchainInterface { } function getBlockTd(next: any) { - // calculate the total difficulty of the new block if (isGenesis) { return next() } + // calculate the total difficulty of the new block self._getTd(header.parentHash, number.subn(1), (err?: any, parentTd?: any) => { if (err) { return next(err) @@ -900,16 +899,19 @@ export default class Blockchain implements BlockchainInterface { /** * @hidden */ - _delBlock(blockHash: Buffer | typeof Block, cb: any) { + _delBlock(blockHash: Buffer | Block, cb: any) { const self = this const dbOps: any[] = [] let blockHeader = null let blockNumber: any = null let parentHash: any = null let inCanonical: any = null + let hash: Buffer - if (!Buffer.isBuffer(blockHash)) { - blockHash = blockHash.hash() + if (Buffer.isBuffer(blockHash)) { + hash = blockHash + } else { + hash = blockHash.hash() } async.series( @@ -924,7 +926,7 @@ export default class Blockchain implements BlockchainInterface { ) function getHeader(cb2: any) { - self._getHeader(blockHash, (err?: any, header?: any) => { + self._getHeader(hash, (err?: any, header?: any) => { if (err) return cb2(err) blockHeader = header blockNumber = new BN(blockHeader.number) @@ -936,7 +938,7 @@ export default class Blockchain implements BlockchainInterface { // check if block is in the canonical chain function checkCanonical(cb2: any) { self._numberToHash(blockNumber, (err?: any, hash?: any) => { - inCanonical = !err && hash.equals(blockHash) + inCanonical = !err && hash.equals(hash) cb2() }) } @@ -944,7 +946,7 @@ export default class Blockchain implements BlockchainInterface { // delete the block, and if block is in the canonical chain, delete all // children as well function buildDBops(cb2: any) { - self._delChild(blockHash, blockNumber, inCanonical ? parentHash : null, dbOps, cb2) + self._delChild(hash, blockNumber, inCanonical ? parentHash : null, dbOps, cb2) } // delete all number to hash mappings for deleted block number and above diff --git a/packages/blockchain/test/index.ts b/packages/blockchain/test/index.ts index c1ca5eea204..0b10f399fa1 100644 --- a/packages/blockchain/test/index.ts +++ b/packages/blockchain/test/index.ts @@ -2,12 +2,12 @@ import * as async from 'async' import Common from 'ethereumjs-common' import { toBuffer, bufferToInt } from 'ethereumjs-util' import * as test from 'tape' -import Blockchain, { Block } from '../src' +import Blockchain from '../src' +import { Block, BlockHeader } from 'ethereumjs-block' import { generateBlockchain, generateBlocks, isConsecutive, createTestDB } from './util' import BN = require('bn.js') -const Block = require('ethereumjs-block') const level = require('level-mem') const testData = require('./testdata.json') @@ -99,7 +99,7 @@ test('blockchain test', t => { const block = new Block() block.header.number = toBuffer(blockNumber) block.header.parentHash = blocks[blockNumber - 1].hash() - block.header.difficulty = block.header.canonicalDifficulty(blocks[blockNumber - 1]) + block.header.difficulty = toBuffer(block.header.canonicalDifficulty(blocks[blockNumber - 1])) block.header.gasLimit = toBuffer(8000000) block.header.timestamp = toBuffer(bufferToInt(blocks[blockNumber - 1].header.timestamp) + 1) blockchain.putBlock(block, (err?: Error) => { @@ -132,7 +132,7 @@ test('blockchain test', t => { const block = new Block() block.header.number = toBuffer(1) block.header.parentHash = blocks[0].hash() - block.header.difficulty = block.header.canonicalDifficulty(blocks[0]) + block.header.difficulty = toBuffer(block.header.canonicalDifficulty(blocks[0])) block.header.gasLimit = toBuffer(8000000) block.header.timestamp = toBuffer(bufferToInt(blocks[0].header.timestamp) + 1) blocks.push(block) @@ -142,8 +142,12 @@ test('blockchain test', t => { st.error(err, 'no error') blockchain.getBlock(1, (err?: Error, block?: Block) => { st.error(err, 'no error') - st.equal(block.hash().toString('hex'), blocks[1].hash().toString('hex')) - st.end() + if (block) { + st.equal(block.hash().toString('hex'), blocks[1].hash().toString('hex')) + st.end() + } else { + st.fail('block is not defined!') + } }) }) }) @@ -158,8 +162,12 @@ test('blockchain test', t => { st.error(err, 'no error') blockchain.getBlock(genesisBlock.hash(), (err?: Error, block?: Block) => { st.error(err, 'no error') - st.equal(block.hash().toString('hex'), genesisBlock.hash().toString('hex')) - st.end() + if (block) { + st.equal(block.hash().toString('hex'), genesisBlock.hash().toString('hex')) + st.end() + } else { + st.fail('block is not defined!') + } }) }) }) @@ -370,7 +378,7 @@ test('blockchain test', t => { }) t.test('should catch iterator func error', async st => { - const { blockchain, blocks, error } = await generateBlockchain(25) + const { blockchain, error } = await generateBlockchain(25) st.error(error, 'no error') blockchain.iterator( 'error', @@ -437,10 +445,10 @@ test('blockchain test', t => { if (err) { return st.error(err) } - const forkHeader = new Block.Header() + const forkHeader = new BlockHeader() forkHeader.number = toBuffer(15) forkHeader.parentHash = blocks[14].hash() - forkHeader.difficulty = forkHeader.canonicalDifficulty(blocks[14]) + forkHeader.difficulty = toBuffer(forkHeader.canonicalDifficulty(blocks[14])) forkHeader.gasLimit = toBuffer(8000000) forkHeader.timestamp = toBuffer(bufferToInt(blocks[14].header.timestamp) + 1) blockchain._heads['staletest'] = blockchain._headHeader @@ -464,10 +472,10 @@ test('blockchain test', t => { t.test('should delete fork header', async st => { const { blockchain, blocks, error } = await generateBlockchain(15) st.error(error, 'no error') - const forkHeader = new Block.Header() + const forkHeader = new BlockHeader() forkHeader.number = toBuffer(15) forkHeader.parentHash = blocks[14].hash() - forkHeader.difficulty = forkHeader.canonicalDifficulty(blocks[14]) + forkHeader.difficulty = toBuffer(forkHeader.canonicalDifficulty(blocks[14])) forkHeader.gasLimit = toBuffer(8000000) forkHeader.timestamp = toBuffer(bufferToInt(blocks[14].header.timestamp) + 1) blockchain._heads['staletest'] = blockchain._headHeader @@ -585,9 +593,17 @@ test('blockchain test', t => { if (err) { return st.error(err) } - st.equals(head.hash().toString('hex'), genesis.hash().toString('hex'), 'should get head') - st.equals(blockchain._heads['head0'].toString('hex'), 'abcd', 'should get state root heads') - st.end() + if (genesis) { + st.equals(head.hash().toString('hex'), genesis.hash().toString('hex'), 'should get head') + st.equals( + blockchain._heads['head0'].toString('hex'), + 'abcd', + 'should get state root heads', + ) + st.end() + } else { + st.fail() + } }) }) }) @@ -627,6 +643,9 @@ test('blockchain test', t => { if (err) { return st.error(err) } + if (!genesis) { + return st.fail('genesis not defined!') + } const blockchain = new Blockchain({ db: db }) async.series( [ @@ -669,10 +688,10 @@ test('blockchain test', t => { if (err) { return st.error(err) } - const header = new Block.Header() + const header = new BlockHeader() header.number = toBuffer(1) header.parentHash = genesisBlock.hash() - header.difficulty = header.canonicalDifficulty(genesisBlock) + header.difficulty = toBuffer(header.canonicalDifficulty(genesisBlock)) header.gasLimit = toBuffer(8000000) header.timestamp = toBuffer(bufferToInt(genesisBlock.header.timestamp) + 1) blockchain.putHeader(header, (err?: Error) => { @@ -725,7 +744,7 @@ test('blockchain test', t => { const block = new Block() block.header.number = toBuffer(1) block.header.parentHash = genesisBlock.hash() - block.header.difficulty = block.header.canonicalDifficulty(genesisBlock) + block.header.difficulty = toBuffer(block.header.canonicalDifficulty(genesisBlock)) block.header.gasLimit = toBuffer(8000000) block.header.timestamp = toBuffer(bufferToInt(genesisBlock.header.timestamp) + 1) let cachedHash: Buffer @@ -746,6 +765,9 @@ test('blockchain test', t => { if (err) { return st.error(err) } + if (!block) { + return st.fail('block not defined!') + } st.equals( cachedHash.toString('hex'), block.hash().toString('hex'), @@ -760,9 +782,10 @@ test('blockchain test', t => { }) }) + // !!! t.test('should get latest', st => { const blockchain = new Blockchain({ validateBlocks: true, validatePow: false }) - const headers = [new Block.Header(), new Block.Header()] + const headers = [new BlockHeader(), new BlockHeader()] const genesisBlock = new Block() genesisBlock.setGenesisParams() genesisBlock.header.gasLimit = toBuffer(8000000) @@ -774,19 +797,19 @@ test('blockchain test', t => { const block = new Block() block.header.number = toBuffer(1) block.header.parentHash = genesisBlock.hash() - block.header.difficulty = block.header.canonicalDifficulty(genesisBlock) + block.header.difficulty = toBuffer(block.header.canonicalDifficulty(genesisBlock)) block.header.gasLimit = toBuffer(8000000) block.header.timestamp = toBuffer(bufferToInt(genesisBlock.header.timestamp) + 1) headers[0].number = toBuffer(1) headers[0].parentHash = genesisBlock.hash() - headers[0].difficulty = headers[0].canonicalDifficulty(genesisBlock) + headers[0].difficulty = toBuffer(headers[0].canonicalDifficulty(genesisBlock)) headers[0].gasLimit = toBuffer(8000000) headers[0].timestamp = toBuffer(bufferToInt(genesisBlock.header.timestamp) + 1) headers[1].number = toBuffer(2) headers[1].parentHash = headers[0].hash() - headers[1].difficulty = headers[1].canonicalDifficulty(block) + headers[1].difficulty = toBuffer(headers[1].canonicalDifficulty(block)) headers[1].gasLimit = toBuffer(8000000) headers[1].timestamp = toBuffer(bufferToInt(block.header.timestamp) + 1) @@ -853,6 +876,9 @@ test('blockchain test', t => { if (err) { return st.error(err) } + if (!getBlock) { + return st.fail('getBlock not defined!') + } t.equals( getBlock.hash().toString('hex'), block.hash().toString('hex'), @@ -874,9 +900,9 @@ test('blockchain test', t => { const common = new Common('mainnet') const blockchain = new Blockchain({ common: common, validateBlocks: true, validatePow: false }) const blocks = [ - new Block(null, { common: common }), - new Block(null, { chain: 'mainnet' }), - new Block(null, { chain: 'ropsten' }), + new Block(undefined, { common: common }), + new Block(undefined, { chain: 'mainnet' }), + new Block(undefined, { chain: 'ropsten' }), ] blocks[0].setGenesisParams() @@ -884,13 +910,13 @@ test('blockchain test', t => { blocks[1].header.number = toBuffer(1) blocks[1].header.parentHash = blocks[0].hash() - blocks[1].header.difficulty = blocks[1].header.canonicalDifficulty(blocks[0]) + blocks[1].header.difficulty = toBuffer(blocks[1].header.canonicalDifficulty(blocks[0])) blocks[1].header.gasLimit = toBuffer(8000000) blocks[1].header.timestamp = toBuffer(bufferToInt(blocks[0].header.timestamp) + 1) blocks[2].header.number = toBuffer(2) blocks[2].header.parentHash = blocks[1].hash() - blocks[2].header.difficulty = blocks[2].header.canonicalDifficulty(blocks[0]) + blocks[2].header.difficulty = toBuffer(blocks[2].header.canonicalDifficulty(blocks[0])) blocks[2].header.gasLimit = toBuffer(8000000) blocks[2].header.timestamp = toBuffer(bufferToInt(blocks[0].header.timestamp) + 2) diff --git a/packages/blockchain/test/util.ts b/packages/blockchain/test/util.ts index 9f890477265..de769b79ecc 100644 --- a/packages/blockchain/test/util.ts +++ b/packages/blockchain/test/util.ts @@ -1,9 +1,9 @@ import { rlp, toBuffer, bufferToInt } from 'ethereumjs-util' import BN = require('bn.js') -import Blockchain, { Block } from '../src' +import Blockchain from '../src' const util = require('util') -const Block = require('ethereumjs-block') +import { Block } from 'ethereumjs-block' const level = require('level-mem') export const generateBlockchain = async ( @@ -43,7 +43,7 @@ export const generateBlocks = (numberOfBlocks: number, existingBlocks?: Block[]) const block = new Block() block.header.number = toBuffer(i) block.header.parentHash = blocks[i - 1].hash() - block.header.difficulty = block.header.canonicalDifficulty(blocks[i - 1]) + block.header.difficulty = toBuffer(block.header.canonicalDifficulty(blocks[i - 1])) block.header.gasLimit = toBuffer(8000000) block.header.timestamp = toBuffer(bufferToInt(blocks[i - 1].header.timestamp) + 1) blocks.push(block) diff --git a/packages/common/docs/README.md b/packages/common/docs/README.md index 4137188d904..a367639dc87 100644 --- a/packages/common/docs/README.md +++ b/packages/common/docs/README.md @@ -6,6 +6,6 @@ ### Modules -- ["genesisStates/index"](modules/_genesisstates_index_.md) -- ["index"](modules/_index_.md) -- ["types"](modules/_types_.md) +* ["genesisStates/index"](modules/_genesisstates_index_.md) +* ["index"](modules/_index_.md) +* ["types"](modules/_types_.md) diff --git a/packages/common/docs/classes/_index_.common.md b/packages/common/docs/classes/_index_.common.md index e8a76165c45..d2a79d140d8 100644 --- a/packages/common/docs/classes/_index_.common.md +++ b/packages/common/docs/classes/_index_.common.md @@ -6,548 +6,548 @@ Common class to access chain and hardfork parameters ## Hierarchy -- **Common** +* **Common** ## Index ### Constructors -- [constructor](_index_.common.md#constructor) +* [constructor](_index_.common.md#constructor) ### Methods -- [\_chooseHardfork](_index_.common.md#_choosehardfork) -- [\_getHardfork](_index_.common.md#_gethardfork) -- [\_isSupportedHardfork](_index_.common.md#_issupportedhardfork) -- [activeHardfork](_index_.common.md#activehardfork) -- [activeHardforks](_index_.common.md#activehardforks) -- [activeOnBlock](_index_.common.md#activeonblock) -- [bootstrapNodes](_index_.common.md#bootstrapnodes) -- [chainId](_index_.common.md#chainid) -- [chainName](_index_.common.md#chainname) -- [consensus](_index_.common.md#consensus) -- [finality](_index_.common.md#finality) -- [genesis](_index_.common.md#genesis) -- [gteHardfork](_index_.common.md#gtehardfork) -- [hardfork](_index_.common.md#hardfork) -- [hardforkBlock](_index_.common.md#hardforkblock) -- [hardforkGteHardfork](_index_.common.md#hardforkgtehardfork) -- [hardforkIsActiveOnBlock](_index_.common.md#hardforkisactiveonblock) -- [hardforkIsActiveOnChain](_index_.common.md#hardforkisactiveonchain) -- [hardforks](_index_.common.md#hardforks) -- [isHardforkBlock](_index_.common.md#ishardforkblock) -- [networkId](_index_.common.md#networkid) -- [param](_index_.common.md#param) -- [paramByBlock](_index_.common.md#parambyblock) -- [setChain](_index_.common.md#setchain) -- [setHardfork](_index_.common.md#sethardfork) -- [forCustomChain](_index_.common.md#static-forcustomchain) +* [_chooseHardfork](_index_.common.md#_choosehardfork) +* [_getHardfork](_index_.common.md#_gethardfork) +* [_isSupportedHardfork](_index_.common.md#_issupportedhardfork) +* [activeHardfork](_index_.common.md#activehardfork) +* [activeHardforks](_index_.common.md#activehardforks) +* [activeOnBlock](_index_.common.md#activeonblock) +* [bootstrapNodes](_index_.common.md#bootstrapnodes) +* [chainId](_index_.common.md#chainid) +* [chainName](_index_.common.md#chainname) +* [consensus](_index_.common.md#consensus) +* [finality](_index_.common.md#finality) +* [genesis](_index_.common.md#genesis) +* [gteHardfork](_index_.common.md#gtehardfork) +* [hardfork](_index_.common.md#hardfork) +* [hardforkBlock](_index_.common.md#hardforkblock) +* [hardforkGteHardfork](_index_.common.md#hardforkgtehardfork) +* [hardforkIsActiveOnBlock](_index_.common.md#hardforkisactiveonblock) +* [hardforkIsActiveOnChain](_index_.common.md#hardforkisactiveonchain) +* [hardforks](_index_.common.md#hardforks) +* [isHardforkBlock](_index_.common.md#ishardforkblock) +* [networkId](_index_.common.md#networkid) +* [param](_index_.common.md#param) +* [paramByBlock](_index_.common.md#parambyblock) +* [setChain](_index_.common.md#setchain) +* [setHardfork](_index_.common.md#sethardfork) +* [forCustomChain](_index_.common.md#static-forcustomchain) ## Constructors -### constructor +### constructor -\+ **new Common**(`chain`: string | number | object, `hardfork?`: string | null, `supportedHardforks?`: Array‹string›): _[Common](\_index_.common.md)\_ +\+ **new Common**(`chain`: string | number | object, `hardfork?`: string | null, `supportedHardforks?`: Array‹string›): *[Common](_index_.common.md)* -_Defined in [index.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L62)_ +*Defined in [index.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L62)* -**`constructor`** +**`constructor`** **Parameters:** -| Name | Type | Description | -| --------------------- | ---------------------------------- | --------------------------------------------------------- | -| `chain` | string | number | object | String ('mainnet') or Number (1) chain | -| `hardfork?` | string | null | String identifier ('byzantium') for hardfork (optional) | -| `supportedHardforks?` | Array‹string› | Limit parameter returns to the given hardforks (optional) | +Name | Type | Description | +------ | ------ | ------ | +`chain` | string | number | object | String ('mainnet') or Number (1) chain | +`hardfork?` | string | null | String identifier ('byzantium') for hardfork (optional) | +`supportedHardforks?` | Array‹string› | Limit parameter returns to the given hardforks (optional) | -**Returns:** _[Common](\_index_.common.md)\_ +**Returns:** *[Common](_index_.common.md)* ## Methods -### \_chooseHardfork +### _chooseHardfork -▸ **\_chooseHardfork**(`hardfork?`: string | null, `onlySupported?`: undefined | false | true): _string_ +▸ **_chooseHardfork**(`hardfork?`: string | null, `onlySupported?`: undefined | false | true): *string* -_Defined in [index.ts:131](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L131)_ +*Defined in [index.ts:131](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L131)* Internal helper function to choose between hardfork set and hardfork provided as param **Parameters:** -| Name | Type | Description | -| ---------------- | ---------------------------------- | ----------------------------------------- | -| `hardfork?` | string | null | Hardfork given to function as a parameter | -| `onlySupported?` | undefined | false | true | - | +Name | Type | Description | +------ | ------ | ------ | +`hardfork?` | string | null | Hardfork given to function as a parameter | +`onlySupported?` | undefined | false | true | - | -**Returns:** _string_ +**Returns:** *string* Hardfork chosen to be used ---- +___ -### \_getHardfork +### _getHardfork -▸ **\_getHardfork**(`hardfork`: string): _any_ +▸ **_getHardfork**(`hardfork`: string): *any* -_Defined in [index.ts:150](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L150)_ +*Defined in [index.ts:150](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L150)* Internal helper function, returns the params for the given hardfork for the chain set **Parameters:** -| Name | Type | Description | -| ---------- | ------ | ------------- | -| `hardfork` | string | Hardfork name | +Name | Type | Description | +------ | ------ | ------ | +`hardfork` | string | Hardfork name | -**Returns:** _any_ +**Returns:** *any* Dictionary with hardfork params ---- +___ -### \_isSupportedHardfork +### _isSupportedHardfork -▸ **\_isSupportedHardfork**(`hardfork`: string | null): _boolean_ +▸ **_isSupportedHardfork**(`hardfork`: string | null): *boolean* -_Defined in [index.ts:163](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L163)_ +*Defined in [index.ts:163](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L163)* Internal helper function to check if a hardfork is set to be supported by the library **Parameters:** -| Name | Type | Description | -| ---------- | ------------------ | ------------- | -| `hardfork` | string | null | Hardfork name | +Name | Type | Description | +------ | ------ | ------ | +`hardfork` | string | null | Hardfork name | -**Returns:** _boolean_ +**Returns:** *boolean* True if hardfork is supported ---- +___ -### activeHardfork +### activeHardfork -▸ **activeHardfork**(`blockNumber?`: number | null, `opts?`: hardforkOptions): _string_ +▸ **activeHardfork**(`blockNumber?`: number | null, `opts?`: hardforkOptions): *string* -_Defined in [index.ts:327](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L327)_ +*Defined in [index.ts:327](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L327)* Returns the latest active hardfork name for chain or block or throws if unavailable **Parameters:** -| Name | Type | Description | -| -------------- | ------------------ | ------------------------------------------------------ | -| `blockNumber?` | number | null | up to block if provided, otherwise for the whole chain | -| `opts?` | hardforkOptions | Hardfork options (onlyActive unused) | +Name | Type | Description | +------ | ------ | ------ | +`blockNumber?` | number | null | up to block if provided, otherwise for the whole chain | +`opts?` | hardforkOptions | Hardfork options (onlyActive unused) | -**Returns:** _string_ +**Returns:** *string* Hardfork name ---- +___ -### activeHardforks +### activeHardforks -▸ **activeHardforks**(`blockNumber?`: number | null, `opts?`: hardforkOptions): _Array‹any›_ +▸ **activeHardforks**(`blockNumber?`: number | null, `opts?`: hardforkOptions): *Array‹any›* -_Defined in [index.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L307)_ +*Defined in [index.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L307)* Returns the active hardfork switches for the current chain **Parameters:** -| Name | Type | Description | -| -------------- | ------------------ | ------------------------------------------------------ | -| `blockNumber?` | number | null | up to block if provided, otherwise for the whole chain | -| `opts?` | hardforkOptions | Hardfork options (onlyActive unused) | +Name | Type | Description | +------ | ------ | ------ | +`blockNumber?` | number | null | up to block if provided, otherwise for the whole chain | +`opts?` | hardforkOptions | Hardfork options (onlyActive unused) | -**Returns:** _Array‹any›_ +**Returns:** *Array‹any›* Array with hardfork arrays ---- +___ -### activeOnBlock +### activeOnBlock -▸ **activeOnBlock**(`blockNumber`: number, `opts?`: hardforkOptions): _boolean_ +▸ **activeOnBlock**(`blockNumber`: number, `opts?`: hardforkOptions): *boolean* -_Defined in [index.ts:237](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L237)_ +*Defined in [index.ts:237](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L237)* Alias to hardforkIsActiveOnBlock when hardfork is set **Parameters:** -| Name | Type | Description | -| ------------- | --------------- | ------------------------------------ | -| `blockNumber` | number | - | -| `opts?` | hardforkOptions | Hardfork options (onlyActive unused) | +Name | Type | Description | +------ | ------ | ------ | +`blockNumber` | number | - | +`opts?` | hardforkOptions | Hardfork options (onlyActive unused) | -**Returns:** _boolean_ +**Returns:** *boolean* True if HF is active on block number ---- +___ -### bootstrapNodes +### bootstrapNodes -▸ **bootstrapNodes**(): _any_ +▸ **bootstrapNodes**(): *any* -_Defined in [index.ts:402](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L402)_ +*Defined in [index.ts:402](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L402)* Returns bootstrap nodes for the current chain -**Returns:** _any_ +**Returns:** *any* Dict with bootstrap nodes ---- +___ -### chainId +### chainId -▸ **chainId**(): _number_ +▸ **chainId**(): *number* -_Defined in [index.ts:418](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L418)_ +*Defined in [index.ts:418](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L418)* Returns the Id of current chain -**Returns:** _number_ +**Returns:** *number* chain Id ---- +___ -### chainName +### chainName -▸ **chainName**(): _string_ +▸ **chainName**(): *string* -_Defined in [index.ts:426](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L426)_ +*Defined in [index.ts:426](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L426)* Returns the name of current chain -**Returns:** _string_ +**Returns:** *string* chain name (lower case) ---- +___ -### consensus +### consensus -▸ **consensus**(`hardfork?`: undefined | string): _string_ +▸ **consensus**(`hardfork?`: undefined | string): *string* -_Defined in [index.ts:367](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L367)_ +*Defined in [index.ts:367](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L367)* Provide the consensus type for the hardfork set or provided as param **Parameters:** -| Name | Type | Description | -| ----------- | ----------------------- | --------------------------------------- | -| `hardfork?` | undefined | string | Hardfork name, optional if hardfork set | +Name | Type | Description | +------ | ------ | ------ | +`hardfork?` | undefined | string | Hardfork name, optional if hardfork set | -**Returns:** _string_ +**Returns:** *string* Consensus type (e.g. 'pow', 'poa') ---- +___ -### finality +### finality -▸ **finality**(`hardfork?`: undefined | string): _string_ +▸ **finality**(`hardfork?`: undefined | string): *string* -_Defined in [index.ts:377](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L377)_ +*Defined in [index.ts:377](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L377)* Provide the finality type for the hardfork set or provided as param **Parameters:** -| Name | Type | Description | -| ----------- | ----------------------- | --------------------------------------- | -| `hardfork?` | undefined | string | Hardfork name, optional if hardfork set | +Name | Type | Description | +------ | ------ | ------ | +`hardfork?` | undefined | string | Hardfork name, optional if hardfork set | -**Returns:** _string_ +**Returns:** *string* Finality type (e.g. 'pos', null of no finality) ---- +___ -### genesis +### genesis -▸ **genesis**(): _any_ +▸ **genesis**(): *any* -_Defined in [index.ts:386](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L386)_ +*Defined in [index.ts:386](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L386)* Returns the Genesis parameters of current chain -**Returns:** _any_ +**Returns:** *any* Genesis dictionary ---- +___ -### gteHardfork +### gteHardfork -▸ **gteHardfork**(`hardfork`: string, `opts?`: hardforkOptions): _boolean_ +▸ **gteHardfork**(`hardfork`: string, `opts?`: hardforkOptions): *boolean* -_Defined in [index.ts:281](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L281)_ +*Defined in [index.ts:281](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L281)* Alias to hardforkGteHardfork when hardfork is set **Parameters:** -| Name | Type | Description | -| ---------- | --------------- | ---------------- | -| `hardfork` | string | Hardfork name | -| `opts?` | hardforkOptions | Hardfork options | +Name | Type | Description | +------ | ------ | ------ | +`hardfork` | string | Hardfork name | +`opts?` | hardforkOptions | Hardfork options | -**Returns:** _boolean_ +**Returns:** *boolean* True if hardfork set is greater than hardfork provided ---- +___ -### hardfork +### hardfork -▸ **hardfork**(): _string | null_ +▸ **hardfork**(): *string | null* -_Defined in [index.ts:410](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L410)_ +*Defined in [index.ts:410](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L410)* Returns the hardfork set -**Returns:** _string | null_ +**Returns:** *string | null* Hardfork name ---- +___ -### hardforkBlock +### hardforkBlock -▸ **hardforkBlock**(`hardfork?`: undefined | string): _number_ +▸ **hardforkBlock**(`hardfork?`: undefined | string): *number* -_Defined in [index.ts:342](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L342)_ +*Defined in [index.ts:342](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L342)* Returns the hardfork change block for hardfork provided or set **Parameters:** -| Name | Type | Description | -| ----------- | ----------------------- | --------------------------------- | -| `hardfork?` | undefined | string | Hardfork name, optional if HF set | +Name | Type | Description | +------ | ------ | ------ | +`hardfork?` | undefined | string | Hardfork name, optional if HF set | -**Returns:** _number_ +**Returns:** *number* Block number ---- +___ -### hardforkGteHardfork +### hardforkGteHardfork -▸ **hardforkGteHardfork**(`hardfork1`: string | null, `hardfork2`: string, `opts?`: hardforkOptions): _boolean_ +▸ **hardforkGteHardfork**(`hardfork1`: string | null, `hardfork2`: string, `opts?`: hardforkOptions): *boolean* -_Defined in [index.ts:248](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L248)_ +*Defined in [index.ts:248](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L248)* Sequence based check if given or set HF1 is greater than or equal HF2 **Parameters:** -| Name | Type | Description | -| ----------- | ------------------ | ------------------------------ | -| `hardfork1` | string | null | Hardfork name or null (if set) | -| `hardfork2` | string | Hardfork name | -| `opts?` | hardforkOptions | Hardfork options | +Name | Type | Description | +------ | ------ | ------ | +`hardfork1` | string | null | Hardfork name or null (if set) | +`hardfork2` | string | Hardfork name | +`opts?` | hardforkOptions | Hardfork options | -**Returns:** _boolean_ +**Returns:** *boolean* True if HF1 gte HF2 ---- +___ -### hardforkIsActiveOnBlock +### hardforkIsActiveOnBlock -▸ **hardforkIsActiveOnBlock**(`hardfork`: string | null, `blockNumber`: number, `opts?`: hardforkOptions): _boolean_ +▸ **hardforkIsActiveOnBlock**(`hardfork`: string | null, `blockNumber`: number, `opts?`: hardforkOptions): *boolean* -_Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L218)_ +*Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L218)* Checks if set or provided hardfork is active on block number **Parameters:** -| Name | Type | Description | -| ------------- | ------------------ | ------------------------------------ | -| `hardfork` | string | null | Hardfork name or null (for HF set) | -| `blockNumber` | number | - | -| `opts?` | hardforkOptions | Hardfork options (onlyActive unused) | +Name | Type | Description | +------ | ------ | ------ | +`hardfork` | string | null | Hardfork name or null (for HF set) | +`blockNumber` | number | - | +`opts?` | hardforkOptions | Hardfork options (onlyActive unused) | -**Returns:** _boolean_ +**Returns:** *boolean* True if HF is active on block number ---- +___ -### hardforkIsActiveOnChain +### hardforkIsActiveOnChain -▸ **hardforkIsActiveOnChain**(`hardfork?`: string | null, `opts?`: hardforkOptions): _boolean_ +▸ **hardforkIsActiveOnChain**(`hardfork?`: string | null, `opts?`: hardforkOptions): *boolean* -_Defined in [index.ts:291](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L291)_ +*Defined in [index.ts:291](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L291)* Checks if given or set hardfork is active on the chain **Parameters:** -| Name | Type | Description | -| ----------- | ------------------ | ------------------------------------ | -| `hardfork?` | string | null | Hardfork name, optional if HF set | -| `opts?` | hardforkOptions | Hardfork options (onlyActive unused) | +Name | Type | Description | +------ | ------ | ------ | +`hardfork?` | string | null | Hardfork name, optional if HF set | +`opts?` | hardforkOptions | Hardfork options (onlyActive unused) | -**Returns:** _boolean_ +**Returns:** *boolean* True if hardfork is active on the chain ---- +___ -### hardforks +### hardforks -▸ **hardforks**(): _any_ +▸ **hardforks**(): *any* -_Defined in [index.ts:394](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L394)_ +*Defined in [index.ts:394](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L394)* Returns the hardforks for current chain -**Returns:** _any_ +**Returns:** *any* Array with arrays of hardforks ---- +___ -### isHardforkBlock +### isHardforkBlock -▸ **isHardforkBlock**(`blockNumber`: number, `hardfork?`: undefined | string): _boolean_ +▸ **isHardforkBlock**(`blockNumber`: number, `hardfork?`: undefined | string): *boolean* -_Defined in [index.ts:353](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L353)_ +*Defined in [index.ts:353](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L353)* True if block number provided is the hardfork (given or set) change block of the current chain **Parameters:** -| Name | Type | Description | -| ------------- | ----------------------- | --------------------------------- | -| `blockNumber` | number | Number of the block to check | -| `hardfork?` | undefined | string | Hardfork name, optional if HF set | +Name | Type | Description | +------ | ------ | ------ | +`blockNumber` | number | Number of the block to check | +`hardfork?` | undefined | string | Hardfork name, optional if HF set | -**Returns:** _boolean_ +**Returns:** *boolean* True if blockNumber is HF block ---- +___ -### networkId +### networkId -▸ **networkId**(): _number_ +▸ **networkId**(): *number* -_Defined in [index.ts:434](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L434)_ +*Defined in [index.ts:434](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L434)* Returns the Id of current network -**Returns:** _number_ +**Returns:** *number* network Id ---- +___ -### param +### param -▸ **param**(`topic`: string, `name`: string, `hardfork?`: undefined | string): _any_ +▸ **param**(`topic`: string, `name`: string, `hardfork?`: undefined | string): *any* -_Defined in [index.ts:180](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L180)_ +*Defined in [index.ts:180](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L180)* Returns the parameter corresponding to a hardfork **Parameters:** -| Name | Type | Description | -| ----------- | ----------------------- | ----------------------------------------------------------------------------- | -| `topic` | string | Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow', 'casper', 'sharding') | -| `name` | string | Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic) | -| `hardfork?` | undefined | string | Hardfork name, optional if hardfork set | +Name | Type | Description | +------ | ------ | ------ | +`topic` | string | Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow', 'casper', 'sharding') | +`name` | string | Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic) | +`hardfork?` | undefined | string | Hardfork name, optional if hardfork set | -**Returns:** _any_ +**Returns:** *any* ---- +___ -### paramByBlock +### paramByBlock -▸ **paramByBlock**(`topic`: string, `name`: string, `blockNumber`: number): _any_ +▸ **paramByBlock**(`topic`: string, `name`: string, `blockNumber`: number): *any* -_Defined in [index.ts:205](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L205)_ +*Defined in [index.ts:205](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L205)* Returns a parameter for the hardfork active on block number **Parameters:** -| Name | Type | Description | -| ------------- | ------ | --------------- | -| `topic` | string | Parameter topic | -| `name` | string | Parameter name | -| `blockNumber` | number | Block number | +Name | Type | Description | +------ | ------ | ------ | +`topic` | string | Parameter topic | +`name` | string | Parameter name | +`blockNumber` | number | Block number | -**Returns:** _any_ +**Returns:** *any* ---- +___ -### setChain +### setChain -▸ **setChain**(`chain`: string | number | object): _any_ +▸ **setChain**(`chain`: string | number | object): *any* -_Defined in [index.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L89)_ +*Defined in [index.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L89)* Sets the chain **Parameters:** -| Name | Type | Description | -| ------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------ | -| `chain` | string | number | object | String ('mainnet') or Number (1) chain representation. Or, a Dictionary of chain parameters for a private network. | +Name | Type | Description | +------ | ------ | ------ | +`chain` | string | number | object | String ('mainnet') or Number (1) chain representation. Or, a Dictionary of chain parameters for a private network. | -**Returns:** _any_ +**Returns:** *any* The dictionary with parameters set as chain ---- +___ -### setHardfork +### setHardfork -▸ **setHardfork**(`hardfork`: string | null): _void_ +▸ **setHardfork**(`hardfork`: string | null): *void* -_Defined in [index.ts:110](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L110)_ +*Defined in [index.ts:110](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L110)* Sets the hardfork to get params for **Parameters:** -| Name | Type | Description | -| ---------- | ------------------ | ------------------------------- | -| `hardfork` | string | null | String identifier ('byzantium') | +Name | Type | Description | +------ | ------ | ------ | +`hardfork` | string | null | String identifier ('byzantium') | -**Returns:** _void_ +**Returns:** *void* ---- +___ ### `Static` forCustomChain -▸ **forCustomChain**(`baseChain`: string | number, `customChainParams`: Partial‹[Chain](../interfaces/_types_.chain.md)›, `hardfork?`: string | null, `supportedHardforks?`: Array‹string›): _[Common](\_index_.common.md)\_ +▸ **forCustomChain**(`baseChain`: string | number, `customChainParams`: Partial‹[Chain](../interfaces/_types_.chain.md)›, `hardfork?`: string | null, `supportedHardforks?`: Array‹string›): *[Common](_index_.common.md)* -_Defined in [index.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L30)_ +*Defined in [index.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/index.ts#L30)* Creates a Common object for a custom chain, based on a standard one. It uses all the [Chain](../interfaces/_types_.chain.md) params from [[baseChain]] except the ones overridden in [[customChainParams]]. **Parameters:** -| Name | Type | Description | -| --------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------- | -| `baseChain` | string | number | The name (`mainnet`) or id (`1`) of a standard chain used to base the custom chain params on. | -| `customChainParams` | Partial‹[Chain](../interfaces/_types_.chain.md)› | The custom parameters of the chain. | -| `hardfork?` | string | null | String identifier ('byzantium') for hardfork (optional) | -| `supportedHardforks?` | Array‹string› | Limit parameter returns to the given hardforks (optional) | +Name | Type | Description | +------ | ------ | ------ | +`baseChain` | string | number | The name (`mainnet`) or id (`1`) of a standard chain used to base the custom chain params on. | +`customChainParams` | Partial‹[Chain](../interfaces/_types_.chain.md)› | The custom parameters of the chain. | +`hardfork?` | string | null | String identifier ('byzantium') for hardfork (optional) | +`supportedHardforks?` | Array‹string› | Limit parameter returns to the given hardforks (optional) | -**Returns:** _[Common](\_index_.common.md)\_ +**Returns:** *[Common](_index_.common.md)* diff --git a/packages/common/docs/interfaces/_types_.bootstrapnode.md b/packages/common/docs/interfaces/_types_.bootstrapnode.md index 5688dd386de..57465c02c65 100644 --- a/packages/common/docs/interfaces/_types_.bootstrapnode.md +++ b/packages/common/docs/interfaces/_types_.bootstrapnode.md @@ -4,72 +4,72 @@ ## Hierarchy -- **BootstrapNode** +* **BootstrapNode** ## Index ### Properties -- [chainId](_types_.bootstrapnode.md#optional-chainid) -- [comment](_types_.bootstrapnode.md#comment) -- [id](_types_.bootstrapnode.md#id) -- [ip](_types_.bootstrapnode.md#ip) -- [location](_types_.bootstrapnode.md#location) -- [network](_types_.bootstrapnode.md#optional-network) -- [port](_types_.bootstrapnode.md#port) +* [chainId](_types_.bootstrapnode.md#optional-chainid) +* [comment](_types_.bootstrapnode.md#comment) +* [id](_types_.bootstrapnode.md#id) +* [ip](_types_.bootstrapnode.md#ip) +* [location](_types_.bootstrapnode.md#location) +* [network](_types_.bootstrapnode.md#optional-network) +* [port](_types_.bootstrapnode.md#port) ## Properties ### `Optional` chainId -• **chainId**? : _undefined | number_ +• **chainId**? : *undefined | number* -_Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L47)_ +*Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L47)* ---- +___ -### comment +### comment -• **comment**: _string_ +• **comment**: *string* -_Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L50)_ +*Defined in [types.ts:50](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L50)* ---- +___ -### id +### id -• **id**: _string_ +• **id**: *string* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L48)_ +*Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L48)* ---- +___ -### ip +### ip -• **ip**: _string_ +• **ip**: *string* -_Defined in [types.ts:44](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L44)_ +*Defined in [types.ts:44](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L44)* ---- +___ -### location +### location -• **location**: _string_ +• **location**: *string* -_Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L49)_ +*Defined in [types.ts:49](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L49)* ---- +___ ### `Optional` network -• **network**? : _undefined | string_ +• **network**? : *undefined | string* -_Defined in [types.ts:46](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L46)_ +*Defined in [types.ts:46](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L46)* ---- +___ -### port +### port -• **port**: _number | string_ +• **port**: *number | string* -_Defined in [types.ts:45](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L45)_ +*Defined in [types.ts:45](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L45)* diff --git a/packages/common/docs/interfaces/_types_.chain.md b/packages/common/docs/interfaces/_types_.chain.md index 5538d40c553..80efdf04052 100644 --- a/packages/common/docs/interfaces/_types_.chain.md +++ b/packages/common/docs/interfaces/_types_.chain.md @@ -4,81 +4,81 @@ ## Hierarchy -- **Chain** +* **Chain** ## Index ### Properties -- [bootstrapNodes](_types_.chain.md#bootstrapnodes) -- [chainId](_types_.chain.md#chainid) -- [comment](_types_.chain.md#comment) -- [genesis](_types_.chain.md#genesis) -- [hardforks](_types_.chain.md#hardforks) -- [name](_types_.chain.md#name) -- [networkId](_types_.chain.md#networkid) -- [url](_types_.chain.md#url) +* [bootstrapNodes](_types_.chain.md#bootstrapnodes) +* [chainId](_types_.chain.md#chainid) +* [comment](_types_.chain.md#comment) +* [genesis](_types_.chain.md#genesis) +* [hardforks](_types_.chain.md#hardforks) +* [name](_types_.chain.md#name) +* [networkId](_types_.chain.md#networkid) +* [url](_types_.chain.md#url) ## Properties -### bootstrapNodes +### bootstrapNodes -• **bootstrapNodes**: _[BootstrapNode](\_types_.bootstrapnode.md)[]\_ +• **bootstrapNodes**: *[BootstrapNode](_types_.bootstrapnode.md)[]* -_Defined in [types.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L23)_ +*Defined in [types.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L23)* ---- +___ -### chainId +### chainId -• **chainId**: _number_ +• **chainId**: *number* -_Defined in [types.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L17)_ +*Defined in [types.ts:17](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L17)* ---- +___ -### comment +### comment -• **comment**: _string_ +• **comment**: *string* -_Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L19)_ +*Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L19)* ---- +___ -### genesis +### genesis -• **genesis**: _[GenesisBlock](\_types_.genesisblock.md)\_ +• **genesis**: *[GenesisBlock](_types_.genesisblock.md)* -_Defined in [types.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L21)_ +*Defined in [types.ts:21](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L21)* ---- +___ -### hardforks +### hardforks -• **hardforks**: _[Hardfork](\_types_.hardfork.md)[]\_ +• **hardforks**: *[Hardfork](_types_.hardfork.md)[]* -_Defined in [types.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L22)_ +*Defined in [types.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L22)* ---- +___ -### name +### name -• **name**: _string_ +• **name**: *string* -_Defined in [types.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L16)_ +*Defined in [types.ts:16](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L16)* ---- +___ -### networkId +### networkId -• **networkId**: _number_ +• **networkId**: *number* -_Defined in [types.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L18)_ +*Defined in [types.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L18)* ---- +___ -### url +### url -• **url**: _string_ +• **url**: *string* -_Defined in [types.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L20)_ +*Defined in [types.ts:20](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L20)* diff --git a/packages/common/docs/interfaces/_types_.chainstype.md b/packages/common/docs/interfaces/_types_.chainstype.md index 6ec10ccb47e..ffe8e7600ec 100644 --- a/packages/common/docs/interfaces/_types_.chainstype.md +++ b/packages/common/docs/interfaces/_types_.chainstype.md @@ -4,26 +4,26 @@ ## Hierarchy -- **chainsType** +* **chainsType** ## Indexable -- \[ **key**: _string_\]: any +* \[ **key**: *string*\]: any ## Index ### Properties -- [names](_types_.chainstype.md#names) +* [names](_types_.chainstype.md#names) ## Properties -### names +### names -• **names**: _object_ +• **names**: *object* -_Defined in [types.ts:9](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L9)_ +*Defined in [types.ts:9](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L9)* #### Type declaration: -- \[ **key**: _string_\]: string +* \[ **key**: *string*\]: string diff --git a/packages/common/docs/interfaces/_types_.genesisblock.md b/packages/common/docs/interfaces/_types_.genesisblock.md index 5265847b255..6e1d165a9ac 100644 --- a/packages/common/docs/interfaces/_types_.genesisblock.md +++ b/packages/common/docs/interfaces/_types_.genesisblock.md @@ -4,72 +4,72 @@ ## Hierarchy -- **GenesisBlock** +* **GenesisBlock** ## Index ### Properties -- [difficulty](_types_.genesisblock.md#difficulty) -- [extraData](_types_.genesisblock.md#extradata) -- [gasLimit](_types_.genesisblock.md#gaslimit) -- [hash](_types_.genesisblock.md#hash) -- [nonce](_types_.genesisblock.md#nonce) -- [stateRoot](_types_.genesisblock.md#stateroot) -- [timestamp](_types_.genesisblock.md#timestamp) +* [difficulty](_types_.genesisblock.md#difficulty) +* [extraData](_types_.genesisblock.md#extradata) +* [gasLimit](_types_.genesisblock.md#gaslimit) +* [hash](_types_.genesisblock.md#hash) +* [nonce](_types_.genesisblock.md#nonce) +* [stateRoot](_types_.genesisblock.md#stateroot) +* [timestamp](_types_.genesisblock.md#timestamp) ## Properties -### difficulty +### difficulty -• **difficulty**: _number_ +• **difficulty**: *number* -_Defined in [types.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L30)_ +*Defined in [types.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L30)* ---- +___ -### extraData +### extraData -• **extraData**: _string_ +• **extraData**: *string* -_Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L32)_ +*Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L32)* ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _number_ +• **gasLimit**: *number* -_Defined in [types.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L29)_ +*Defined in [types.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L29)* ---- +___ -### hash +### hash -• **hash**: _string_ +• **hash**: *string* -_Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L27)_ +*Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L27)* ---- +___ -### nonce +### nonce -• **nonce**: _string_ +• **nonce**: *string* -_Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L31)_ +*Defined in [types.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L31)* ---- +___ -### stateRoot +### stateRoot -• **stateRoot**: _string_ +• **stateRoot**: *string* -_Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L33)_ +*Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L33)* ---- +___ -### timestamp +### timestamp -• **timestamp**: _string | null_ +• **timestamp**: *string | null* -_Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L28)_ +*Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L28)* diff --git a/packages/common/docs/interfaces/_types_.genesisstatestype.md b/packages/common/docs/interfaces/_types_.genesisstatestype.md index e48a15495f4..f874da32436 100644 --- a/packages/common/docs/interfaces/_types_.genesisstatestype.md +++ b/packages/common/docs/interfaces/_types_.genesisstatestype.md @@ -4,26 +4,26 @@ ## Hierarchy -- **genesisStatesType** +* **genesisStatesType** ## Indexable -- \[ **key**: _string_\]: object +* \[ **key**: *string*\]: object ## Index ### Properties -- [names](_types_.genesisstatestype.md#names) +* [names](_types_.genesisstatestype.md#names) ## Properties -### names +### names -• **names**: _object_ +• **names**: *object* -_Defined in [types.ts:2](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L2)_ +*Defined in [types.ts:2](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L2)* #### Type declaration: -- \[ **key**: _string_\]: string +* \[ **key**: *string*\]: string diff --git a/packages/common/docs/interfaces/_types_.hardfork.md b/packages/common/docs/interfaces/_types_.hardfork.md index 4c66703e3e1..9b39fd71747 100644 --- a/packages/common/docs/interfaces/_types_.hardfork.md +++ b/packages/common/docs/interfaces/_types_.hardfork.md @@ -4,45 +4,45 @@ ## Hierarchy -- **Hardfork** +* **Hardfork** ## Index ### Properties -- [block](_types_.hardfork.md#block) -- [consensus](_types_.hardfork.md#consensus) -- [finality](_types_.hardfork.md#finality) -- [name](_types_.hardfork.md#name) +* [block](_types_.hardfork.md#block) +* [consensus](_types_.hardfork.md#consensus) +* [finality](_types_.hardfork.md#finality) +* [name](_types_.hardfork.md#name) ## Properties -### block +### block -• **block**: _number | null_ +• **block**: *number | null* -_Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L38)_ +*Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L38)* ---- +___ -### consensus +### consensus -• **consensus**: _string_ +• **consensus**: *string* -_Defined in [types.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L39)_ +*Defined in [types.ts:39](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L39)* ---- +___ -### finality +### finality -• **finality**: _any_ +• **finality**: *any* -_Defined in [types.ts:40](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L40)_ +*Defined in [types.ts:40](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L40)* ---- +___ -### name +### name -• **name**: _string_ +• **name**: *string* -_Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L37)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/types.ts#L37)* diff --git a/packages/common/docs/modules/_genesisstates_index_.md b/packages/common/docs/modules/_genesisstates_index_.md index 85d909aefd5..d9894804447 100644 --- a/packages/common/docs/modules/_genesisstates_index_.md +++ b/packages/common/docs/modules/_genesisstates_index_.md @@ -6,45 +6,45 @@ ### Functions -- [genesisStateById](_genesisstates_index_.md#genesisstatebyid) -- [genesisStateByName](_genesisstates_index_.md#genesisstatebyname) +* [genesisStateById](_genesisstates_index_.md#genesisstatebyid) +* [genesisStateByName](_genesisstates_index_.md#genesisstatebyname) ## Functions -### genesisStateById +### genesisStateById -▸ **genesisStateById**(`id`: number): _any_ +▸ **genesisStateById**(`id`: number): *any* -_Defined in [genesisStates/index.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/genesisStates/index.ts#L23)_ +*Defined in [genesisStates/index.ts:23](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/genesisStates/index.ts#L23)* Returns the genesis state by network ID **Parameters:** -| Name | Type | Description | -| ---- | ------ | -------------------------- | -| `id` | number | ID of the network (e.g. 1) | +Name | Type | Description | +------ | ------ | ------ | +`id` | number | ID of the network (e.g. 1) | -**Returns:** _any_ +**Returns:** *any* Dictionary with genesis accounts ---- +___ -### genesisStateByName +### genesisStateByName -▸ **genesisStateByName**(`name`: string): _any_ +▸ **genesisStateByName**(`name`: string): *any* -_Defined in [genesisStates/index.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/genesisStates/index.ts#L32)_ +*Defined in [genesisStates/index.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common/src/genesisStates/index.ts#L32)* Returns the genesis state by network name **Parameters:** -| Name | Type | Description | -| ------ | ------ | ------------------------------------ | -| `name` | string | Name of the network (e.g. 'mainnet') | +Name | Type | Description | +------ | ------ | ------ | +`name` | string | Name of the network (e.g. 'mainnet') | -**Returns:** _any_ +**Returns:** *any* Dictionary with genesis accounts diff --git a/packages/common/docs/modules/_index_.md b/packages/common/docs/modules/_index_.md index 673b33ea50f..fd0d79dbb10 100644 --- a/packages/common/docs/modules/_index_.md +++ b/packages/common/docs/modules/_index_.md @@ -6,4 +6,4 @@ ### Classes -- [Common](../classes/_index_.common.md) +* [Common](../classes/_index_.common.md) diff --git a/packages/common/docs/modules/_types_.md b/packages/common/docs/modules/_types_.md index 50549793abe..4222fa260c8 100644 --- a/packages/common/docs/modules/_types_.md +++ b/packages/common/docs/modules/_types_.md @@ -6,9 +6,9 @@ ### Interfaces -- [BootstrapNode](../interfaces/_types_.bootstrapnode.md) -- [Chain](../interfaces/_types_.chain.md) -- [GenesisBlock](../interfaces/_types_.genesisblock.md) -- [Hardfork](../interfaces/_types_.hardfork.md) -- [chainsType](../interfaces/_types_.chainstype.md) -- [genesisStatesType](../interfaces/_types_.genesisstatestype.md) +* [BootstrapNode](../interfaces/_types_.bootstrapnode.md) +* [Chain](../interfaces/_types_.chain.md) +* [GenesisBlock](../interfaces/_types_.genesisblock.md) +* [Hardfork](../interfaces/_types_.hardfork.md) +* [chainsType](../interfaces/_types_.chainstype.md) +* [genesisStatesType](../interfaces/_types_.genesisstatestype.md) diff --git a/packages/tx/docs/README.md b/packages/tx/docs/README.md index a8313d5b2fa..123b4280ee6 100644 --- a/packages/tx/docs/README.md +++ b/packages/tx/docs/README.md @@ -6,7 +6,7 @@ ### Modules -- ["fake"](modules/_fake_.md) -- ["index"](modules/_index_.md) -- ["transaction"](modules/_transaction_.md) -- ["types"](modules/_types_.md) +* ["fake"](modules/_fake_.md) +* ["index"](modules/_index_.md) +* ["transaction"](modules/_transaction_.md) +* ["types"](modules/_types_.md) diff --git a/packages/tx/docs/classes/_fake_.faketransaction.md b/packages/tx/docs/classes/_fake_.faketransaction.md index b7a6fe51244..197d0d30ff2 100644 --- a/packages/tx/docs/classes/_fake_.faketransaction.md +++ b/packages/tx/docs/classes/_fake_.faketransaction.md @@ -14,7 +14,7 @@ transactions belongs to. ## Hierarchy -- [Transaction](_index_.transaction.md) +* [Transaction](_index_.transaction.md) ↳ **FakeTransaction** @@ -22,330 +22,330 @@ transactions belongs to. ### Constructors -- [constructor](_fake_.faketransaction.md#constructor) +* [constructor](_fake_.faketransaction.md#constructor) ### Properties -- [data](_fake_.faketransaction.md#data) -- [from](_fake_.faketransaction.md#from) -- [gasLimit](_fake_.faketransaction.md#gaslimit) -- [gasPrice](_fake_.faketransaction.md#gasprice) -- [nonce](_fake_.faketransaction.md#nonce) -- [r](_fake_.faketransaction.md#r) -- [raw](_fake_.faketransaction.md#raw) -- [s](_fake_.faketransaction.md#s) -- [to](_fake_.faketransaction.md#to) -- [v](_fake_.faketransaction.md#v) -- [value](_fake_.faketransaction.md#value) +* [data](_fake_.faketransaction.md#data) +* [from](_fake_.faketransaction.md#from) +* [gasLimit](_fake_.faketransaction.md#gaslimit) +* [gasPrice](_fake_.faketransaction.md#gasprice) +* [nonce](_fake_.faketransaction.md#nonce) +* [r](_fake_.faketransaction.md#r) +* [raw](_fake_.faketransaction.md#raw) +* [s](_fake_.faketransaction.md#s) +* [to](_fake_.faketransaction.md#to) +* [v](_fake_.faketransaction.md#v) +* [value](_fake_.faketransaction.md#value) ### Methods -- [getBaseFee](_fake_.faketransaction.md#getbasefee) -- [getChainId](_fake_.faketransaction.md#getchainid) -- [getDataFee](_fake_.faketransaction.md#getdatafee) -- [getSenderAddress](_fake_.faketransaction.md#getsenderaddress) -- [getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey) -- [getUpfrontCost](_fake_.faketransaction.md#getupfrontcost) -- [hash](_fake_.faketransaction.md#hash) -- [serialize](_fake_.faketransaction.md#serialize) -- [sign](_fake_.faketransaction.md#sign) -- [toCreationAddress](_fake_.faketransaction.md#tocreationaddress) -- [toJSON](_fake_.faketransaction.md#tojson) -- [validate](_fake_.faketransaction.md#validate) -- [verifySignature](_fake_.faketransaction.md#verifysignature) +* [getBaseFee](_fake_.faketransaction.md#getbasefee) +* [getChainId](_fake_.faketransaction.md#getchainid) +* [getDataFee](_fake_.faketransaction.md#getdatafee) +* [getSenderAddress](_fake_.faketransaction.md#getsenderaddress) +* [getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey) +* [getUpfrontCost](_fake_.faketransaction.md#getupfrontcost) +* [hash](_fake_.faketransaction.md#hash) +* [serialize](_fake_.faketransaction.md#serialize) +* [sign](_fake_.faketransaction.md#sign) +* [toCreationAddress](_fake_.faketransaction.md#tocreationaddress) +* [toJSON](_fake_.faketransaction.md#tojson) +* [validate](_fake_.faketransaction.md#validate) +* [verifySignature](_fake_.faketransaction.md#verifysignature) ## Constructors -### constructor +### constructor -\+ **new FakeTransaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): _[FakeTransaction](\_fake_.faketransaction.md)\_ +\+ **new FakeTransaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): *[FakeTransaction](_fake_.faketransaction.md)* -_Overrides [Transaction](\_index_.transaction.md).[constructor](_index_.transaction.md#constructor)\_ +*Overrides [Transaction](_index_.transaction.md).[constructor](_index_.transaction.md#constructor)* -_Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)_ +*Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)* **Parameters:** -| Name | Type | Default | -| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md) | {} | -| `opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | +Name | Type | Default | +------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md) | {} | +`opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | -**Returns:** _[FakeTransaction](\_fake_.faketransaction.md)\_ +**Returns:** *[FakeTransaction](_fake_.faketransaction.md)* ## Properties -### data +### data -• **data**: _Buffer_ +• **data**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[data](_fake_.faketransaction.md#data)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[data](_fake_.faketransaction.md#data)* -_Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)_ +*Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)* ---- +___ -### from +### from -• **from**: _Buffer_ +• **from**: *Buffer* -_Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)_ +*Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)* Set from address to bypass transaction signing. This is not an optional property, as its getter never returns undefined. ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[gasLimit](_fake_.faketransaction.md#gaslimit)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[gasLimit](_fake_.faketransaction.md#gaslimit)* -_Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)_ +*Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)* ---- +___ -### gasPrice +### gasPrice -• **gasPrice**: _Buffer_ +• **gasPrice**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[gasPrice](_fake_.faketransaction.md#gasprice)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[gasPrice](_fake_.faketransaction.md#gasprice)* -_Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)_ +*Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[nonce](_fake_.faketransaction.md#nonce)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[nonce](_fake_.faketransaction.md#nonce)* -_Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)_ +*Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)* ---- +___ -### r +### r -• **r**: _Buffer_ +• **r**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[r](_fake_.faketransaction.md#r)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[r](_fake_.faketransaction.md#r)* -_Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)_ +*Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[raw](_fake_.faketransaction.md#raw)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[raw](_fake_.faketransaction.md#raw)* -_Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)_ +*Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)* ---- +___ -### s +### s -• **s**: _Buffer_ +• **s**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[s](_fake_.faketransaction.md#s)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[s](_fake_.faketransaction.md#s)* -_Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)_ +*Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)* ---- +___ -### to +### to -• **to**: _Buffer_ +• **to**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[to](_fake_.faketransaction.md#to)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[to](_fake_.faketransaction.md#to)* -_Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)_ +*Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)* ---- +___ -### v +### v -• **v**: _Buffer_ +• **v**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[v](_fake_.faketransaction.md#v)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[v](_fake_.faketransaction.md#v)* -_Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)_ +*Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)* ---- +___ -### value +### value -• **value**: _Buffer_ +• **value**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[value](_fake_.faketransaction.md#value)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[value](_fake_.faketransaction.md#value)* -_Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)_ +*Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)* ## Methods -### getBaseFee +### getBaseFee -▸ **getBaseFee**(): _BN_ +▸ **getBaseFee**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getBaseFee](_fake_.faketransaction.md#getbasefee)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getBaseFee](_fake_.faketransaction.md#getbasefee)* -_Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)_ +*Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)* the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getChainId +### getChainId -▸ **getChainId**(): _number_ +▸ **getChainId**(): *number* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getChainId](_fake_.faketransaction.md#getchainid)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getChainId](_fake_.faketransaction.md#getchainid)* -_Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)_ +*Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)* returns chain ID -**Returns:** _number_ +**Returns:** *number* ---- +___ -### getDataFee +### getDataFee -▸ **getDataFee**(): _BN_ +▸ **getDataFee**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getDataFee](_fake_.faketransaction.md#getdatafee)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getDataFee](_fake_.faketransaction.md#getdatafee)* -_Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)_ +*Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)* The amount of gas paid for the data in this tx -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getSenderAddress +### getSenderAddress -▸ **getSenderAddress**(): _Buffer_ +▸ **getSenderAddress**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getSenderAddress](_fake_.faketransaction.md#getsenderaddress)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getSenderAddress](_fake_.faketransaction.md#getsenderaddress)* -_Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)_ +*Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)* returns the sender's address -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getSenderPublicKey +### getSenderPublicKey -▸ **getSenderPublicKey**(): _Buffer_ +▸ **getSenderPublicKey**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey)* -_Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)_ +*Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)* returns the public key of the sender -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getUpfrontCost +### getUpfrontCost -▸ **getUpfrontCost**(): _BN_ +▸ **getUpfrontCost**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getUpfrontCost](_fake_.faketransaction.md#getupfrontcost)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getUpfrontCost](_fake_.faketransaction.md#getupfrontcost)* -_Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)_ +*Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)* the up front amount that an account must have for this transaction to be valid -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(`includeSignature`: boolean): _Buffer_ +▸ **hash**(`includeSignature`: boolean): *Buffer* -_Overrides [Transaction](\_index_.transaction.md).[hash](_index_.transaction.md#hash)\_ +*Overrides [Transaction](_index_.transaction.md).[hash](_index_.transaction.md#hash)* -_Defined in [fake.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L53)_ +*Defined in [fake.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L53)* Computes a sha3-256 hash of the serialized tx, using the sender address to generate a fake signature. **Parameters:** -| Name | Type | Default | Description | -| ------------------ | ------- | ------- | --------------------------------------- | -| `includeSignature` | boolean | true | Whether or not to include the signature | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`includeSignature` | boolean | true | Whether or not to include the signature | -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[serialize](_fake_.faketransaction.md#serialize)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[serialize](_fake_.faketransaction.md#serialize)* -_Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)_ +*Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)* Returns the rlp encoding of the transaction -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### sign +### sign -▸ **sign**(`privateKey`: Buffer): _void_ +▸ **sign**(`privateKey`: Buffer): *void* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[sign](_fake_.faketransaction.md#sign)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[sign](_fake_.faketransaction.md#sign)* -_Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)_ +*Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)* sign a transaction with a given private key **Parameters:** -| Name | Type | Description | -| ------------ | ------ | -------------------------- | -| `privateKey` | Buffer | Must be 32 bytes in length | +Name | Type | Description | +------ | ------ | ------ | +`privateKey` | Buffer | Must be 32 bytes in length | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toCreationAddress +### toCreationAddress -▸ **toCreationAddress**(): _boolean_ +▸ **toCreationAddress**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[toCreationAddress](_fake_.faketransaction.md#tocreationaddress)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[toCreationAddress](_fake_.faketransaction.md#tocreationaddress)* -_Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)_ +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* If the tx's `to` is to the creation address -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labels`: boolean): _object | string[]_ +▸ **toJSON**(`labels`: boolean): *object | string[]* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[toJSON](_fake_.faketransaction.md#tojson)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[toJSON](_fake_.faketransaction.md#tojson)* -_Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)_ +*Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)* Returns the transaction in JSON format @@ -353,64 +353,64 @@ Returns the transaction in JSON format **Parameters:** -| Name | Type | Default | -| -------- | ------- | ------- | -| `labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(): _boolean_ +▸ **validate**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)_ +*Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)* Validates the signature and checks to see if it has enough gas. -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: false): _boolean_ +▸ **validate**(`stringError`: false): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)_ +*Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: true): _string_ +▸ **validate**(`stringError`: true): *string* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)_ +*Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### verifySignature +### verifySignature -▸ **verifySignature**(): _boolean_ +▸ **verifySignature**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[verifySignature](_fake_.faketransaction.md#verifysignature)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[verifySignature](_fake_.faketransaction.md#verifysignature)* -_Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)_ +*Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)* Determines if the signature is valid -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/tx/docs/classes/_index_.faketransaction.md b/packages/tx/docs/classes/_index_.faketransaction.md index b52cf78a986..f7c9569f10a 100644 --- a/packages/tx/docs/classes/_index_.faketransaction.md +++ b/packages/tx/docs/classes/_index_.faketransaction.md @@ -14,7 +14,7 @@ transactions belongs to. ## Hierarchy -- [Transaction](_index_.transaction.md) +* [Transaction](_index_.transaction.md) ↳ **FakeTransaction** @@ -22,330 +22,330 @@ transactions belongs to. ### Constructors -- [constructor](_index_.faketransaction.md#constructor) +* [constructor](_index_.faketransaction.md#constructor) ### Properties -- [data](_index_.faketransaction.md#data) -- [from](_index_.faketransaction.md#from) -- [gasLimit](_index_.faketransaction.md#gaslimit) -- [gasPrice](_index_.faketransaction.md#gasprice) -- [nonce](_index_.faketransaction.md#nonce) -- [r](_index_.faketransaction.md#r) -- [raw](_index_.faketransaction.md#raw) -- [s](_index_.faketransaction.md#s) -- [to](_index_.faketransaction.md#to) -- [v](_index_.faketransaction.md#v) -- [value](_index_.faketransaction.md#value) +* [data](_index_.faketransaction.md#data) +* [from](_index_.faketransaction.md#from) +* [gasLimit](_index_.faketransaction.md#gaslimit) +* [gasPrice](_index_.faketransaction.md#gasprice) +* [nonce](_index_.faketransaction.md#nonce) +* [r](_index_.faketransaction.md#r) +* [raw](_index_.faketransaction.md#raw) +* [s](_index_.faketransaction.md#s) +* [to](_index_.faketransaction.md#to) +* [v](_index_.faketransaction.md#v) +* [value](_index_.faketransaction.md#value) ### Methods -- [getBaseFee](_index_.faketransaction.md#getbasefee) -- [getChainId](_index_.faketransaction.md#getchainid) -- [getDataFee](_index_.faketransaction.md#getdatafee) -- [getSenderAddress](_index_.faketransaction.md#getsenderaddress) -- [getSenderPublicKey](_index_.faketransaction.md#getsenderpublickey) -- [getUpfrontCost](_index_.faketransaction.md#getupfrontcost) -- [hash](_index_.faketransaction.md#hash) -- [serialize](_index_.faketransaction.md#serialize) -- [sign](_index_.faketransaction.md#sign) -- [toCreationAddress](_index_.faketransaction.md#tocreationaddress) -- [toJSON](_index_.faketransaction.md#tojson) -- [validate](_index_.faketransaction.md#validate) -- [verifySignature](_index_.faketransaction.md#verifysignature) +* [getBaseFee](_index_.faketransaction.md#getbasefee) +* [getChainId](_index_.faketransaction.md#getchainid) +* [getDataFee](_index_.faketransaction.md#getdatafee) +* [getSenderAddress](_index_.faketransaction.md#getsenderaddress) +* [getSenderPublicKey](_index_.faketransaction.md#getsenderpublickey) +* [getUpfrontCost](_index_.faketransaction.md#getupfrontcost) +* [hash](_index_.faketransaction.md#hash) +* [serialize](_index_.faketransaction.md#serialize) +* [sign](_index_.faketransaction.md#sign) +* [toCreationAddress](_index_.faketransaction.md#tocreationaddress) +* [toJSON](_index_.faketransaction.md#tojson) +* [validate](_index_.faketransaction.md#validate) +* [verifySignature](_index_.faketransaction.md#verifysignature) ## Constructors -### constructor +### constructor -\+ **new FakeTransaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): _[FakeTransaction](\_index_.faketransaction.md)\_ +\+ **new FakeTransaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): *[FakeTransaction](_index_.faketransaction.md)* -_Overrides [Transaction](\_index_.transaction.md).[constructor](_index_.transaction.md#constructor)\_ +*Overrides [Transaction](_index_.transaction.md).[constructor](_index_.transaction.md#constructor)* -_Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)_ +*Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)* **Parameters:** -| Name | Type | Default | -| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md) | {} | -| `opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | +Name | Type | Default | +------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [FakeTxData](../interfaces/_index_.faketxdata.md) | {} | +`opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | -**Returns:** _[FakeTransaction](\_index_.faketransaction.md)\_ +**Returns:** *[FakeTransaction](_index_.faketransaction.md)* ## Properties -### data +### data -• **data**: _Buffer_ +• **data**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[data](_fake_.faketransaction.md#data)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[data](_fake_.faketransaction.md#data)* -_Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)_ +*Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)* ---- +___ -### from +### from -• **from**: _Buffer_ +• **from**: *Buffer* -_Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)_ +*Defined in [fake.ts:22](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L22)* Set from address to bypass transaction signing. This is not an optional property, as its getter never returns undefined. ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[gasLimit](_fake_.faketransaction.md#gaslimit)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[gasLimit](_fake_.faketransaction.md#gaslimit)* -_Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)_ +*Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)* ---- +___ -### gasPrice +### gasPrice -• **gasPrice**: _Buffer_ +• **gasPrice**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[gasPrice](_fake_.faketransaction.md#gasprice)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[gasPrice](_fake_.faketransaction.md#gasprice)* -_Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)_ +*Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[nonce](_fake_.faketransaction.md#nonce)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[nonce](_fake_.faketransaction.md#nonce)* -_Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)_ +*Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)* ---- +___ -### r +### r -• **r**: _Buffer_ +• **r**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[r](_fake_.faketransaction.md#r)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[r](_fake_.faketransaction.md#r)* -_Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)_ +*Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[raw](_fake_.faketransaction.md#raw)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[raw](_fake_.faketransaction.md#raw)* -_Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)_ +*Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)* ---- +___ -### s +### s -• **s**: _Buffer_ +• **s**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[s](_fake_.faketransaction.md#s)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[s](_fake_.faketransaction.md#s)* -_Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)_ +*Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)* ---- +___ -### to +### to -• **to**: _Buffer_ +• **to**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[to](_fake_.faketransaction.md#to)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[to](_fake_.faketransaction.md#to)* -_Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)_ +*Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)* ---- +___ -### v +### v -• **v**: _Buffer_ +• **v**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[v](_fake_.faketransaction.md#v)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[v](_fake_.faketransaction.md#v)* -_Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)_ +*Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)* ---- +___ -### value +### value -• **value**: _Buffer_ +• **value**: *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[value](_fake_.faketransaction.md#value)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[value](_fake_.faketransaction.md#value)* -_Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)_ +*Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)* ## Methods -### getBaseFee +### getBaseFee -▸ **getBaseFee**(): _BN_ +▸ **getBaseFee**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getBaseFee](_fake_.faketransaction.md#getbasefee)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getBaseFee](_fake_.faketransaction.md#getbasefee)* -_Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)_ +*Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)* the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getChainId +### getChainId -▸ **getChainId**(): _number_ +▸ **getChainId**(): *number* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getChainId](_fake_.faketransaction.md#getchainid)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getChainId](_fake_.faketransaction.md#getchainid)* -_Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)_ +*Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)* returns chain ID -**Returns:** _number_ +**Returns:** *number* ---- +___ -### getDataFee +### getDataFee -▸ **getDataFee**(): _BN_ +▸ **getDataFee**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getDataFee](_fake_.faketransaction.md#getdatafee)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getDataFee](_fake_.faketransaction.md#getdatafee)* -_Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)_ +*Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)* The amount of gas paid for the data in this tx -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getSenderAddress +### getSenderAddress -▸ **getSenderAddress**(): _Buffer_ +▸ **getSenderAddress**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getSenderAddress](_fake_.faketransaction.md#getsenderaddress)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getSenderAddress](_fake_.faketransaction.md#getsenderaddress)* -_Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)_ +*Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)* returns the sender's address -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getSenderPublicKey +### getSenderPublicKey -▸ **getSenderPublicKey**(): _Buffer_ +▸ **getSenderPublicKey**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getSenderPublicKey](_fake_.faketransaction.md#getsenderpublickey)* -_Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)_ +*Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)* returns the public key of the sender -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getUpfrontCost +### getUpfrontCost -▸ **getUpfrontCost**(): _BN_ +▸ **getUpfrontCost**(): *BN* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[getUpfrontCost](_fake_.faketransaction.md#getupfrontcost)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[getUpfrontCost](_fake_.faketransaction.md#getupfrontcost)* -_Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)_ +*Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)* the up front amount that an account must have for this transaction to be valid -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(`includeSignature`: boolean): _Buffer_ +▸ **hash**(`includeSignature`: boolean): *Buffer* -_Overrides [Transaction](\_index_.transaction.md).[hash](_index_.transaction.md#hash)\_ +*Overrides [Transaction](_index_.transaction.md).[hash](_index_.transaction.md#hash)* -_Defined in [fake.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L53)_ +*Defined in [fake.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/fake.ts#L53)* Computes a sha3-256 hash of the serialized tx, using the sender address to generate a fake signature. **Parameters:** -| Name | Type | Default | Description | -| ------------------ | ------- | ------- | --------------------------------------- | -| `includeSignature` | boolean | true | Whether or not to include the signature | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`includeSignature` | boolean | true | Whether or not to include the signature | -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[serialize](_fake_.faketransaction.md#serialize)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[serialize](_fake_.faketransaction.md#serialize)* -_Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)_ +*Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)* Returns the rlp encoding of the transaction -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### sign +### sign -▸ **sign**(`privateKey`: Buffer): _void_ +▸ **sign**(`privateKey`: Buffer): *void* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[sign](_fake_.faketransaction.md#sign)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[sign](_fake_.faketransaction.md#sign)* -_Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)_ +*Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)* sign a transaction with a given private key **Parameters:** -| Name | Type | Description | -| ------------ | ------ | -------------------------- | -| `privateKey` | Buffer | Must be 32 bytes in length | +Name | Type | Description | +------ | ------ | ------ | +`privateKey` | Buffer | Must be 32 bytes in length | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toCreationAddress +### toCreationAddress -▸ **toCreationAddress**(): _boolean_ +▸ **toCreationAddress**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[toCreationAddress](_fake_.faketransaction.md#tocreationaddress)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[toCreationAddress](_fake_.faketransaction.md#tocreationaddress)* -_Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)_ +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* If the tx's `to` is to the creation address -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labels`: boolean): _object | string[]_ +▸ **toJSON**(`labels`: boolean): *object | string[]* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[toJSON](_fake_.faketransaction.md#tojson)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[toJSON](_fake_.faketransaction.md#tojson)* -_Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)_ +*Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)* Returns the transaction in JSON format @@ -353,64 +353,64 @@ Returns the transaction in JSON format **Parameters:** -| Name | Type | Default | -| -------- | ------- | ------- | -| `labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(): _boolean_ +▸ **validate**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)_ +*Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)* Validates the signature and checks to see if it has enough gas. -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: false): _boolean_ +▸ **validate**(`stringError`: false): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)_ +*Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: true): _string_ +▸ **validate**(`stringError`: true): *string* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[validate](_fake_.faketransaction.md#validate)* -_Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)_ +*Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### verifySignature +### verifySignature -▸ **verifySignature**(): _boolean_ +▸ **verifySignature**(): *boolean* -_Inherited from [FakeTransaction](\_fake_.faketransaction.md).[verifySignature](_fake_.faketransaction.md#verifysignature)\_ +*Inherited from [FakeTransaction](_fake_.faketransaction.md).[verifySignature](_fake_.faketransaction.md#verifysignature)* -_Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)_ +*Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)* Determines if the signature is valid -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/tx/docs/classes/_index_.transaction.md b/packages/tx/docs/classes/_index_.transaction.md index c77200854ed..4edca532c6d 100644 --- a/packages/tx/docs/classes/_index_.transaction.md +++ b/packages/tx/docs/classes/_index_.transaction.md @@ -6,7 +6,7 @@ An Ethereum transaction. ## Hierarchy -- **Transaction** +* **Transaction** ↳ [FakeTransaction](_fake_.faketransaction.md) @@ -16,44 +16,44 @@ An Ethereum transaction. ### Constructors -- [constructor](_index_.transaction.md#constructor) +* [constructor](_index_.transaction.md#constructor) ### Properties -- [data](_index_.transaction.md#data) -- [gasLimit](_index_.transaction.md#gaslimit) -- [gasPrice](_index_.transaction.md#gasprice) -- [nonce](_index_.transaction.md#nonce) -- [r](_index_.transaction.md#r) -- [raw](_index_.transaction.md#raw) -- [s](_index_.transaction.md#s) -- [to](_index_.transaction.md#to) -- [v](_index_.transaction.md#v) -- [value](_index_.transaction.md#value) +* [data](_index_.transaction.md#data) +* [gasLimit](_index_.transaction.md#gaslimit) +* [gasPrice](_index_.transaction.md#gasprice) +* [nonce](_index_.transaction.md#nonce) +* [r](_index_.transaction.md#r) +* [raw](_index_.transaction.md#raw) +* [s](_index_.transaction.md#s) +* [to](_index_.transaction.md#to) +* [v](_index_.transaction.md#v) +* [value](_index_.transaction.md#value) ### Methods -- [getBaseFee](_index_.transaction.md#getbasefee) -- [getChainId](_index_.transaction.md#getchainid) -- [getDataFee](_index_.transaction.md#getdatafee) -- [getSenderAddress](_index_.transaction.md#getsenderaddress) -- [getSenderPublicKey](_index_.transaction.md#getsenderpublickey) -- [getUpfrontCost](_index_.transaction.md#getupfrontcost) -- [hash](_index_.transaction.md#hash) -- [serialize](_index_.transaction.md#serialize) -- [sign](_index_.transaction.md#sign) -- [toCreationAddress](_index_.transaction.md#tocreationaddress) -- [toJSON](_index_.transaction.md#tojson) -- [validate](_index_.transaction.md#validate) -- [verifySignature](_index_.transaction.md#verifysignature) +* [getBaseFee](_index_.transaction.md#getbasefee) +* [getChainId](_index_.transaction.md#getchainid) +* [getDataFee](_index_.transaction.md#getdatafee) +* [getSenderAddress](_index_.transaction.md#getsenderaddress) +* [getSenderPublicKey](_index_.transaction.md#getsenderpublickey) +* [getUpfrontCost](_index_.transaction.md#getupfrontcost) +* [hash](_index_.transaction.md#hash) +* [serialize](_index_.transaction.md#serialize) +* [sign](_index_.transaction.md#sign) +* [toCreationAddress](_index_.transaction.md#tocreationaddress) +* [toJSON](_index_.transaction.md#tojson) +* [validate](_index_.transaction.md#validate) +* [verifySignature](_index_.transaction.md#verifysignature) ## Constructors -### constructor +### constructor -\+ **new Transaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): _[Transaction](\_index_.transaction.md)\_ +\+ **new Transaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): *[Transaction](_index_.transaction.md)* -_Defined in [transaction.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L37)_ +*Defined in [transaction.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L37)* Creates a new transaction from an object with its fields' values. @@ -61,8 +61,7 @@ Creates a new transaction from an object with its fields' values. second parameter to set a chain and hardfork before EIP155 activation (i.e. before Spurious Dragon.) -**`example`** - +**`example`** ```js const txData = { nonce: '0x00', @@ -73,239 +72,239 @@ const txData = { data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', v: '0x1c', r: '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab', - s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13', -} -const tx = new Transaction(txData) + s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13' +}; +const tx = new Transaction(txData); ``` **Parameters:** -| Name | Type | Default | Description | -| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md) | {} | A transaction can be initialized with its rlp representation, an array containing the value of its fields in order, or an object containing them by name. | -| `opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | The transaction's options, used to indicate the chain and hardfork the transactions belongs to. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md) | {} | A transaction can be initialized with its rlp representation, an array containing the value of its fields in order, or an object containing them by name. | +`opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | The transaction's options, used to indicate the chain and hardfork the transactions belongs to. | -**Returns:** _[Transaction](\_index_.transaction.md)\_ +**Returns:** *[Transaction](_index_.transaction.md)* ## Properties -### data +### data -• **data**: _Buffer_ +• **data**: *Buffer* -_Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)_ +*Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)* ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)_ +*Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)* ---- +___ -### gasPrice +### gasPrice -• **gasPrice**: _Buffer_ +• **gasPrice**: *Buffer* -_Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)_ +*Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)_ +*Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)* ---- +___ -### r +### r -• **r**: _Buffer_ +• **r**: *Buffer* -_Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)_ +*Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)_ +*Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)* ---- +___ -### s +### s -• **s**: _Buffer_ +• **s**: *Buffer* -_Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)_ +*Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)* ---- +___ -### to +### to -• **to**: _Buffer_ +• **to**: *Buffer* -_Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)_ +*Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)* ---- +___ -### v +### v -• **v**: _Buffer_ +• **v**: *Buffer* -_Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)_ +*Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)* ---- +___ -### value +### value -• **value**: _Buffer_ +• **value**: *Buffer* -_Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)_ +*Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)* ## Methods -### getBaseFee +### getBaseFee -▸ **getBaseFee**(): _BN_ +▸ **getBaseFee**(): *BN* -_Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)_ +*Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)* the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getChainId +### getChainId -▸ **getChainId**(): _number_ +▸ **getChainId**(): *number* -_Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)_ +*Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)* returns chain ID -**Returns:** _number_ +**Returns:** *number* ---- +___ -### getDataFee +### getDataFee -▸ **getDataFee**(): _BN_ +▸ **getDataFee**(): *BN* -_Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)_ +*Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)* The amount of gas paid for the data in this tx -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getSenderAddress +### getSenderAddress -▸ **getSenderAddress**(): _Buffer_ +▸ **getSenderAddress**(): *Buffer* -_Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)_ +*Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)* returns the sender's address -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getSenderPublicKey +### getSenderPublicKey -▸ **getSenderPublicKey**(): _Buffer_ +▸ **getSenderPublicKey**(): *Buffer* -_Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)_ +*Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)* returns the public key of the sender -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getUpfrontCost +### getUpfrontCost -▸ **getUpfrontCost**(): _BN_ +▸ **getUpfrontCost**(): *BN* -_Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)_ +*Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)* the up front amount that an account must have for this transaction to be valid -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(`includeSignature`: boolean): _Buffer_ +▸ **hash**(`includeSignature`: boolean): *Buffer* -_Defined in [transaction.ts:177](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L177)_ +*Defined in [transaction.ts:177](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L177)* Computes a sha3-256 hash of the serialized tx **Parameters:** -| Name | Type | Default | Description | -| ------------------ | ------- | ------- | --------------------------------------- | -| `includeSignature` | boolean | true | Whether or not to include the signature | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`includeSignature` | boolean | true | Whether or not to include the signature | -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)_ +*Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)* Returns the rlp encoding of the transaction -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### sign +### sign -▸ **sign**(`privateKey`: Buffer): _void_ +▸ **sign**(`privateKey`: Buffer): *void* -_Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)_ +*Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)* sign a transaction with a given private key **Parameters:** -| Name | Type | Description | -| ------------ | ------ | -------------------------- | -| `privateKey` | Buffer | Must be 32 bytes in length | +Name | Type | Description | +------ | ------ | ------ | +`privateKey` | Buffer | Must be 32 bytes in length | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toCreationAddress +### toCreationAddress -▸ **toCreationAddress**(): _boolean_ +▸ **toCreationAddress**(): *boolean* -_Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)_ +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* If the tx's `to` is to the creation address -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labels`: boolean): _object | string[]_ +▸ **toJSON**(`labels`: boolean): *object | string[]* -_Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)_ +*Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)* Returns the transaction in JSON format @@ -313,56 +312,56 @@ Returns the transaction in JSON format **Parameters:** -| Name | Type | Default | -| -------- | ------- | ------- | -| `labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(): _boolean_ +▸ **validate**(): *boolean* -_Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)_ +*Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)* Validates the signature and checks to see if it has enough gas. -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: false): _boolean_ +▸ **validate**(`stringError`: false): *boolean* -_Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)_ +*Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: true): _string_ +▸ **validate**(`stringError`: true): *string* -_Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)_ +*Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### verifySignature +### verifySignature -▸ **verifySignature**(): _boolean_ +▸ **verifySignature**(): *boolean* -_Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)_ +*Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)* Determines if the signature is valid -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/tx/docs/classes/_transaction_.transaction.md b/packages/tx/docs/classes/_transaction_.transaction.md index 274b6903576..a799a9bd7de 100644 --- a/packages/tx/docs/classes/_transaction_.transaction.md +++ b/packages/tx/docs/classes/_transaction_.transaction.md @@ -6,50 +6,50 @@ An Ethereum transaction. ## Hierarchy -- **Transaction** +* **Transaction** ## Index ### Constructors -- [constructor](_transaction_.transaction.md#constructor) +* [constructor](_transaction_.transaction.md#constructor) ### Properties -- [data](_transaction_.transaction.md#data) -- [gasLimit](_transaction_.transaction.md#gaslimit) -- [gasPrice](_transaction_.transaction.md#gasprice) -- [nonce](_transaction_.transaction.md#nonce) -- [r](_transaction_.transaction.md#r) -- [raw](_transaction_.transaction.md#raw) -- [s](_transaction_.transaction.md#s) -- [to](_transaction_.transaction.md#to) -- [v](_transaction_.transaction.md#v) -- [value](_transaction_.transaction.md#value) +* [data](_transaction_.transaction.md#data) +* [gasLimit](_transaction_.transaction.md#gaslimit) +* [gasPrice](_transaction_.transaction.md#gasprice) +* [nonce](_transaction_.transaction.md#nonce) +* [r](_transaction_.transaction.md#r) +* [raw](_transaction_.transaction.md#raw) +* [s](_transaction_.transaction.md#s) +* [to](_transaction_.transaction.md#to) +* [v](_transaction_.transaction.md#v) +* [value](_transaction_.transaction.md#value) ### Methods -- [getBaseFee](_transaction_.transaction.md#getbasefee) -- [getChainId](_transaction_.transaction.md#getchainid) -- [getDataFee](_transaction_.transaction.md#getdatafee) -- [getSenderAddress](_transaction_.transaction.md#getsenderaddress) -- [getSenderPublicKey](_transaction_.transaction.md#getsenderpublickey) -- [getUpfrontCost](_transaction_.transaction.md#getupfrontcost) -- [hash](_transaction_.transaction.md#hash) -- [serialize](_transaction_.transaction.md#serialize) -- [sign](_transaction_.transaction.md#sign) -- [toCreationAddress](_transaction_.transaction.md#tocreationaddress) -- [toJSON](_transaction_.transaction.md#tojson) -- [validate](_transaction_.transaction.md#validate) -- [verifySignature](_transaction_.transaction.md#verifysignature) +* [getBaseFee](_transaction_.transaction.md#getbasefee) +* [getChainId](_transaction_.transaction.md#getchainid) +* [getDataFee](_transaction_.transaction.md#getdatafee) +* [getSenderAddress](_transaction_.transaction.md#getsenderaddress) +* [getSenderPublicKey](_transaction_.transaction.md#getsenderpublickey) +* [getUpfrontCost](_transaction_.transaction.md#getupfrontcost) +* [hash](_transaction_.transaction.md#hash) +* [serialize](_transaction_.transaction.md#serialize) +* [sign](_transaction_.transaction.md#sign) +* [toCreationAddress](_transaction_.transaction.md#tocreationaddress) +* [toJSON](_transaction_.transaction.md#tojson) +* [validate](_transaction_.transaction.md#validate) +* [verifySignature](_transaction_.transaction.md#verifysignature) ## Constructors -### constructor +### constructor -\+ **new Transaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): _[Transaction](\_transaction_.transaction.md)\_ +\+ **new Transaction**(`data`: Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md), `opts`: [TransactionOptions](../interfaces/_index_.transactionoptions.md)): *[Transaction](_transaction_.transaction.md)* -_Defined in [transaction.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L37)_ +*Defined in [transaction.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L37)* Creates a new transaction from an object with its fields' values. @@ -57,8 +57,7 @@ Creates a new transaction from an object with its fields' values. second parameter to set a chain and hardfork before EIP155 activation (i.e. before Spurious Dragon.) -**`example`** - +**`example`** ```js const txData = { nonce: '0x00', @@ -69,239 +68,239 @@ const txData = { data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', v: '0x1c', r: '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab', - s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13', -} -const tx = new Transaction(txData) + s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13' +}; +const tx = new Transaction(txData); ``` **Parameters:** -| Name | Type | Default | Description | -| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md) | {} | A transaction can be initialized with its rlp representation, an array containing the value of its fields in order, or an object containing them by name. | -| `opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | The transaction's options, used to indicate the chain and hardfork the transactions belongs to. | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`data` | Buffer | [PrefixedHexString](../modules/_index_.md#prefixedhexstring) | [BufferLike](../modules/_index_.md#bufferlike)[] | [TxData](../interfaces/_index_.txdata.md) | {} | A transaction can be initialized with its rlp representation, an array containing the value of its fields in order, or an object containing them by name. | +`opts` | [TransactionOptions](../interfaces/_index_.transactionoptions.md) | {} | The transaction's options, used to indicate the chain and hardfork the transactions belongs to. | -**Returns:** _[Transaction](\_transaction_.transaction.md)\_ +**Returns:** *[Transaction](_transaction_.transaction.md)* ## Properties -### data +### data -• **data**: _Buffer_ +• **data**: *Buffer* -_Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)_ +*Defined in [transaction.ts:30](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L30)* ---- +___ -### gasLimit +### gasLimit -• **gasLimit**: _Buffer_ +• **gasLimit**: *Buffer* -_Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)_ +*Defined in [transaction.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L26)* ---- +___ -### gasPrice +### gasPrice -• **gasPrice**: _Buffer_ +• **gasPrice**: *Buffer* -_Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)_ +*Defined in [transaction.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L27)* ---- +___ -### nonce +### nonce -• **nonce**: _Buffer_ +• **nonce**: *Buffer* -_Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)_ +*Defined in [transaction.ts:25](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L25)* ---- +___ -### r +### r -• **r**: _Buffer_ +• **r**: *Buffer* -_Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)_ +*Defined in [transaction.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L32)* ---- +___ -### raw +### raw -• **raw**: _Buffer[]_ +• **raw**: *Buffer[]* -_Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)_ +*Defined in [transaction.ts:24](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L24)* ---- +___ -### s +### s -• **s**: _Buffer_ +• **s**: *Buffer* -_Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)_ +*Defined in [transaction.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L33)* ---- +___ -### to +### to -• **to**: _Buffer_ +• **to**: *Buffer* -_Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)_ +*Defined in [transaction.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L28)* ---- +___ -### v +### v -• **v**: _Buffer_ +• **v**: *Buffer* -_Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)_ +*Defined in [transaction.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L31)* ---- +___ -### value +### value -• **value**: _Buffer_ +• **value**: *Buffer* -_Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)_ +*Defined in [transaction.ts:29](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L29)* ## Methods -### getBaseFee +### getBaseFee -▸ **getBaseFee**(): _BN_ +▸ **getBaseFee**(): *BN* -_Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)_ +*Defined in [transaction.ts:296](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L296)* the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getChainId +### getChainId -▸ **getChainId**(): _number_ +▸ **getChainId**(): *number* -_Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)_ +*Defined in [transaction.ts:202](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L202)* returns chain ID -**Returns:** _number_ +**Returns:** *number* ---- +___ -### getDataFee +### getDataFee -▸ **getDataFee**(): _BN_ +▸ **getDataFee**(): *BN* -_Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)_ +*Defined in [transaction.ts:282](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L282)* The amount of gas paid for the data in this tx -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### getSenderAddress +### getSenderAddress -▸ **getSenderAddress**(): _Buffer_ +▸ **getSenderAddress**(): *Buffer* -_Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)_ +*Defined in [transaction.ts:209](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L209)* returns the sender's address -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getSenderPublicKey +### getSenderPublicKey -▸ **getSenderPublicKey**(): _Buffer_ +▸ **getSenderPublicKey**(): *Buffer* -_Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)_ +*Defined in [transaction.ts:221](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L221)* returns the public key of the sender -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### getUpfrontCost +### getUpfrontCost -▸ **getUpfrontCost**(): _BN_ +▸ **getUpfrontCost**(): *BN* -_Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)_ +*Defined in [transaction.ts:307](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L307)* the up front amount that an account must have for this transaction to be valid -**Returns:** _BN_ +**Returns:** *BN* ---- +___ -### hash +### hash -▸ **hash**(`includeSignature`: boolean): _Buffer_ +▸ **hash**(`includeSignature`: boolean): *Buffer* -_Defined in [transaction.ts:177](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L177)_ +*Defined in [transaction.ts:177](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L177)* Computes a sha3-256 hash of the serialized tx **Parameters:** -| Name | Type | Default | Description | -| ------------------ | ------- | ------- | --------------------------------------- | -| `includeSignature` | boolean | true | Whether or not to include the signature | +Name | Type | Default | Description | +------ | ------ | ------ | ------ | +`includeSignature` | boolean | true | Whether or not to include the signature | -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### serialize +### serialize -▸ **serialize**(): _Buffer_ +▸ **serialize**(): *Buffer* -_Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)_ +*Defined in [transaction.ts:337](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L337)* Returns the rlp encoding of the transaction -**Returns:** _Buffer_ +**Returns:** *Buffer* ---- +___ -### sign +### sign -▸ **sign**(`privateKey`: Buffer): _void_ +▸ **sign**(`privateKey`: Buffer): *void* -_Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)_ +*Defined in [transaction.ts:262](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L262)* sign a transaction with a given private key **Parameters:** -| Name | Type | Description | -| ------------ | ------ | -------------------------- | -| `privateKey` | Buffer | Must be 32 bytes in length | +Name | Type | Description | +------ | ------ | ------ | +`privateKey` | Buffer | Must be 32 bytes in length | -**Returns:** _void_ +**Returns:** *void* ---- +___ -### toCreationAddress +### toCreationAddress -▸ **toCreationAddress**(): _boolean_ +▸ **toCreationAddress**(): *boolean* -_Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)_ +*Defined in [transaction.ts:169](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L169)* If the tx's `to` is to the creation address -**Returns:** _boolean_ +**Returns:** *boolean* ---- +___ -### toJSON +### toJSON -▸ **toJSON**(`labels`: boolean): _object | string[]_ +▸ **toJSON**(`labels`: boolean): *object | string[]* -_Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)_ +*Defined in [transaction.ts:346](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L346)* Returns the transaction in JSON format @@ -309,56 +308,56 @@ Returns the transaction in JSON format **Parameters:** -| Name | Type | Default | -| -------- | ------- | ------- | -| `labels` | boolean | false | +Name | Type | Default | +------ | ------ | ------ | +`labels` | boolean | false | -**Returns:** _object | string[]_ +**Returns:** *object | string[]* ---- +___ -### validate +### validate -▸ **validate**(): _boolean_ +▸ **validate**(): *boolean* -_Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)_ +*Defined in [transaction.ts:314](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L314)* Validates the signature and checks to see if it has enough gas. -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: false): _boolean_ +▸ **validate**(`stringError`: false): *boolean* -_Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)_ +*Defined in [transaction.ts:315](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L315)* **Parameters:** -| Name | Type | -| ------------- | ----- | -| `stringError` | false | +Name | Type | +------ | ------ | +`stringError` | false | -**Returns:** _boolean_ +**Returns:** *boolean* -▸ **validate**(`stringError`: true): _string_ +▸ **validate**(`stringError`: true): *string* -_Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)_ +*Defined in [transaction.ts:316](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L316)* **Parameters:** -| Name | Type | -| ------------- | ---- | -| `stringError` | true | +Name | Type | +------ | ------ | +`stringError` | true | -**Returns:** _string_ +**Returns:** *string* ---- +___ -### verifySignature +### verifySignature -▸ **verifySignature**(): _boolean_ +▸ **verifySignature**(): *boolean* -_Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)_ +*Defined in [transaction.ts:233](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/transaction.ts#L233)* Determines if the signature is valid -**Returns:** _boolean_ +**Returns:** *boolean* diff --git a/packages/tx/docs/interfaces/_index_.faketxdata.md b/packages/tx/docs/interfaces/_index_.faketxdata.md index 1abb65c1fe2..c3765f0e871 100644 --- a/packages/tx/docs/interfaces/_index_.faketxdata.md +++ b/packages/tx/docs/interfaces/_index_.faketxdata.md @@ -6,7 +6,7 @@ The data of a fake (self-signing) transaction. ## Hierarchy -- [TxData](_index_.txdata.md) +* [TxData](_index_.txdata.md) ↳ **FakeTxData** @@ -14,131 +14,131 @@ The data of a fake (self-signing) transaction. ### Properties -- [data](_index_.faketxdata.md#optional-data) -- [from](_index_.faketxdata.md#optional-from) -- [gasLimit](_index_.faketxdata.md#optional-gaslimit) -- [gasPrice](_index_.faketxdata.md#optional-gasprice) -- [nonce](_index_.faketxdata.md#optional-nonce) -- [r](_index_.faketxdata.md#optional-r) -- [s](_index_.faketxdata.md#optional-s) -- [to](_index_.faketxdata.md#optional-to) -- [v](_index_.faketxdata.md#optional-v) -- [value](_index_.faketxdata.md#optional-value) +* [data](_index_.faketxdata.md#optional-data) +* [from](_index_.faketxdata.md#optional-from) +* [gasLimit](_index_.faketxdata.md#optional-gaslimit) +* [gasPrice](_index_.faketxdata.md#optional-gasprice) +* [nonce](_index_.faketxdata.md#optional-nonce) +* [r](_index_.faketxdata.md#optional-r) +* [s](_index_.faketxdata.md#optional-s) +* [to](_index_.faketxdata.md#optional-to) +* [v](_index_.faketxdata.md#optional-v) +* [value](_index_.faketxdata.md#optional-value) ## Properties ### `Optional` data -• **data**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **data**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[data](_index_.txdata.md#optional-data)\_ +*Inherited from [TxData](_index_.txdata.md).[data](_index_.txdata.md#optional-data)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L48)_ +*Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L47)* This will contain the data of the message or the init of a contract ---- +___ ### `Optional` from -• **from**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **from**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:78](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L78)_ +*Defined in [types.ts:77](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L77)* The sender of the Tx. ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[gasLimit](_index_.txdata.md#optional-gaslimit)\_ +*Inherited from [TxData](_index_.txdata.md).[gasLimit](_index_.txdata.md#optional-gaslimit)* -_Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L28)_ +*Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L27)* The transaction's gas limit. ---- +___ ### `Optional` gasPrice -• **gasPrice**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasPrice**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[gasPrice](_index_.txdata.md#optional-gasprice)\_ +*Inherited from [TxData](_index_.txdata.md).[gasPrice](_index_.txdata.md#optional-gasprice)* -_Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L33)_ +*Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L32)* The transaction's gas price. ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[nonce](_index_.txdata.md#optional-nonce)\_ +*Inherited from [TxData](_index_.txdata.md).[nonce](_index_.txdata.md#optional-nonce)* -_Defined in [types.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L43)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L42)* The transaction's nonce. ---- +___ ### `Optional` r -• **r**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **r**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[r](_index_.txdata.md#optional-r)\_ +*Inherited from [TxData](_index_.txdata.md).[r](_index_.txdata.md#optional-r)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L58)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L57)* EC signature parameter. ---- +___ ### `Optional` s -• **s**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **s**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[s](_index_.txdata.md#optional-s)\_ +*Inherited from [TxData](_index_.txdata.md).[s](_index_.txdata.md#optional-s)* -_Defined in [types.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L63)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L62)* EC signature parameter. ---- +___ ### `Optional` to -• **to**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **to**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[to](_index_.txdata.md#optional-to)\_ +*Inherited from [TxData](_index_.txdata.md).[to](_index_.txdata.md#optional-to)* -_Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L38)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L37)* The transaction's the address is sent to. ---- +___ ### `Optional` v -• **v**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **v**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[v](_index_.txdata.md#optional-v)\_ +*Inherited from [TxData](_index_.txdata.md).[v](_index_.txdata.md#optional-v)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L53)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L52)* EC recovery ID. ---- +___ ### `Optional` value -• **value**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **value**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[value](_index_.txdata.md#optional-value)\_ +*Inherited from [TxData](_index_.txdata.md).[value](_index_.txdata.md#optional-value)* -_Defined in [types.ts:68](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L68)_ +*Defined in [types.ts:67](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L67)* The amount of Ether sent. diff --git a/packages/tx/docs/interfaces/_index_.transactionoptions.md b/packages/tx/docs/interfaces/_index_.transactionoptions.md index ca319114193..04d1f619cbd 100644 --- a/packages/tx/docs/interfaces/_index_.transactionoptions.md +++ b/packages/tx/docs/interfaces/_index_.transactionoptions.md @@ -2,47 +2,48 @@ # Interface: TransactionOptions -The transaction's options. This could be specified using a Common object, or `chain` and `hardfork`. Defaults to -mainnet. +An object to set to which blockchain the blocks and their headers belong. This could be specified +using a Common object, or `chain` and `hardfork`. Defaults to mainnet without specifying a +hardfork. ## Hierarchy -- **TransactionOptions** +* **TransactionOptions** ## Index ### Properties -- [chain](_index_.transactionoptions.md#optional-chain) -- [common](_index_.transactionoptions.md#optional-common) -- [hardfork](_index_.transactionoptions.md#optional-hardfork) +* [chain](_index_.transactionoptions.md#optional-chain) +* [common](_index_.transactionoptions.md#optional-common) +* [hardfork](_index_.transactionoptions.md#optional-hardfork) ## Properties ### `Optional` chain -• **chain**? : _number | string_ +• **chain**? : *number | string* -_Defined in [types.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L94)_ +*Defined in [types.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L94)* The chain of the transaction, default: 'mainnet' ---- +___ ### `Optional` common -• **common**? : _Common_ +• **common**? : *Common* -_Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)_ +*Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)* A Common object defining the chain and the hardfork a transaction belongs to. ---- +___ ### `Optional` hardfork -• **hardfork**? : _undefined | string_ +• **hardfork**? : *undefined | string* -_Defined in [types.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L99)_ +*Defined in [types.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L99)* The hardfork of the transaction, default: 'petersburg' diff --git a/packages/tx/docs/interfaces/_index_.transformabletobuffer.md b/packages/tx/docs/interfaces/_index_.transformabletobuffer.md index 063adde961b..f9ceeab28d4 100644 --- a/packages/tx/docs/interfaces/_index_.transformabletobuffer.md +++ b/packages/tx/docs/interfaces/_index_.transformabletobuffer.md @@ -6,20 +6,20 @@ Any object that can be transformed into a `Buffer` ## Hierarchy -- **TransformableToBuffer** +* **TransformableToBuffer** ## Index ### Methods -- [toBuffer](_index_.transformabletobuffer.md#tobuffer) +* [toBuffer](_index_.transformabletobuffer.md#tobuffer) ## Methods -### toBuffer +### toBuffer -▸ **toBuffer**(): _Buffer_ +▸ **toBuffer**(): *Buffer* -_Defined in [types.ts:8](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L8)_ +*Defined in [types.ts:7](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L7)* -**Returns:** _Buffer_ +**Returns:** *Buffer* diff --git a/packages/tx/docs/interfaces/_index_.txdata.md b/packages/tx/docs/interfaces/_index_.txdata.md index 20bf27a9e86..5da39efa6b2 100644 --- a/packages/tx/docs/interfaces/_index_.txdata.md +++ b/packages/tx/docs/interfaces/_index_.txdata.md @@ -6,7 +6,7 @@ A transaction's data. ## Hierarchy -- **TxData** +* **TxData** ↳ [FakeTxData](_index_.faketxdata.md) @@ -16,102 +16,102 @@ A transaction's data. ### Properties -- [data](_index_.txdata.md#optional-data) -- [gasLimit](_index_.txdata.md#optional-gaslimit) -- [gasPrice](_index_.txdata.md#optional-gasprice) -- [nonce](_index_.txdata.md#optional-nonce) -- [r](_index_.txdata.md#optional-r) -- [s](_index_.txdata.md#optional-s) -- [to](_index_.txdata.md#optional-to) -- [v](_index_.txdata.md#optional-v) -- [value](_index_.txdata.md#optional-value) +* [data](_index_.txdata.md#optional-data) +* [gasLimit](_index_.txdata.md#optional-gaslimit) +* [gasPrice](_index_.txdata.md#optional-gasprice) +* [nonce](_index_.txdata.md#optional-nonce) +* [r](_index_.txdata.md#optional-r) +* [s](_index_.txdata.md#optional-s) +* [to](_index_.txdata.md#optional-to) +* [v](_index_.txdata.md#optional-v) +* [value](_index_.txdata.md#optional-value) ## Properties ### `Optional` data -• **data**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **data**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L48)_ +*Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L47)* This will contain the data of the message or the init of a contract ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L28)_ +*Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L27)* The transaction's gas limit. ---- +___ ### `Optional` gasPrice -• **gasPrice**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **gasPrice**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L33)_ +*Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L32)* The transaction's gas price. ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L43)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L42)* The transaction's nonce. ---- +___ ### `Optional` r -• **r**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **r**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L58)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L57)* EC signature parameter. ---- +___ ### `Optional` s -• **s**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **s**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L63)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L62)* EC signature parameter. ---- +___ ### `Optional` to -• **to**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **to**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L38)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L37)* The transaction's the address is sent to. ---- +___ ### `Optional` v -• **v**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **v**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L53)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L52)* EC recovery ID. ---- +___ ### `Optional` value -• **value**? : _[BufferLike](../modules/\_index_.md#bufferlike)\_ +• **value**? : *[BufferLike](../modules/_index_.md#bufferlike)* -_Defined in [types.ts:68](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L68)_ +*Defined in [types.ts:67](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L67)* The amount of Ether sent. diff --git a/packages/tx/docs/interfaces/_types_.faketxdata.md b/packages/tx/docs/interfaces/_types_.faketxdata.md index 7effb32d755..c3e823ca5c0 100644 --- a/packages/tx/docs/interfaces/_types_.faketxdata.md +++ b/packages/tx/docs/interfaces/_types_.faketxdata.md @@ -6,7 +6,7 @@ The data of a fake (self-signing) transaction. ## Hierarchy -- [TxData](_index_.txdata.md) +* [TxData](_index_.txdata.md) ↳ **FakeTxData** @@ -14,131 +14,131 @@ The data of a fake (self-signing) transaction. ### Properties -- [data](_types_.faketxdata.md#optional-data) -- [from](_types_.faketxdata.md#optional-from) -- [gasLimit](_types_.faketxdata.md#optional-gaslimit) -- [gasPrice](_types_.faketxdata.md#optional-gasprice) -- [nonce](_types_.faketxdata.md#optional-nonce) -- [r](_types_.faketxdata.md#optional-r) -- [s](_types_.faketxdata.md#optional-s) -- [to](_types_.faketxdata.md#optional-to) -- [v](_types_.faketxdata.md#optional-v) -- [value](_types_.faketxdata.md#optional-value) +* [data](_types_.faketxdata.md#optional-data) +* [from](_types_.faketxdata.md#optional-from) +* [gasLimit](_types_.faketxdata.md#optional-gaslimit) +* [gasPrice](_types_.faketxdata.md#optional-gasprice) +* [nonce](_types_.faketxdata.md#optional-nonce) +* [r](_types_.faketxdata.md#optional-r) +* [s](_types_.faketxdata.md#optional-s) +* [to](_types_.faketxdata.md#optional-to) +* [v](_types_.faketxdata.md#optional-v) +* [value](_types_.faketxdata.md#optional-value) ## Properties ### `Optional` data -• **data**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **data**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[data](_index_.txdata.md#optional-data)\_ +*Inherited from [TxData](_index_.txdata.md).[data](_index_.txdata.md#optional-data)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L48)_ +*Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L47)* This will contain the data of the message or the init of a contract ---- +___ ### `Optional` from -• **from**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **from**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:78](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L78)_ +*Defined in [types.ts:77](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L77)* The sender of the Tx. ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[gasLimit](_index_.txdata.md#optional-gaslimit)\_ +*Inherited from [TxData](_index_.txdata.md).[gasLimit](_index_.txdata.md#optional-gaslimit)* -_Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L28)_ +*Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L27)* The transaction's gas limit. ---- +___ ### `Optional` gasPrice -• **gasPrice**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasPrice**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[gasPrice](_index_.txdata.md#optional-gasprice)\_ +*Inherited from [TxData](_index_.txdata.md).[gasPrice](_index_.txdata.md#optional-gasprice)* -_Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L33)_ +*Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L32)* The transaction's gas price. ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[nonce](_index_.txdata.md#optional-nonce)\_ +*Inherited from [TxData](_index_.txdata.md).[nonce](_index_.txdata.md#optional-nonce)* -_Defined in [types.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L43)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L42)* The transaction's nonce. ---- +___ ### `Optional` r -• **r**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **r**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[r](_index_.txdata.md#optional-r)\_ +*Inherited from [TxData](_index_.txdata.md).[r](_index_.txdata.md#optional-r)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L58)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L57)* EC signature parameter. ---- +___ ### `Optional` s -• **s**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **s**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[s](_index_.txdata.md#optional-s)\_ +*Inherited from [TxData](_index_.txdata.md).[s](_index_.txdata.md#optional-s)* -_Defined in [types.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L63)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L62)* EC signature parameter. ---- +___ ### `Optional` to -• **to**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **to**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[to](_index_.txdata.md#optional-to)\_ +*Inherited from [TxData](_index_.txdata.md).[to](_index_.txdata.md#optional-to)* -_Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L38)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L37)* The transaction's the address is sent to. ---- +___ ### `Optional` v -• **v**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **v**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[v](_index_.txdata.md#optional-v)\_ +*Inherited from [TxData](_index_.txdata.md).[v](_index_.txdata.md#optional-v)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L53)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L52)* EC recovery ID. ---- +___ ### `Optional` value -• **value**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **value**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Inherited from [TxData](\_index_.txdata.md).[value](_index_.txdata.md#optional-value)\_ +*Inherited from [TxData](_index_.txdata.md).[value](_index_.txdata.md#optional-value)* -_Defined in [types.ts:68](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L68)_ +*Defined in [types.ts:67](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L67)* The amount of Ether sent. diff --git a/packages/tx/docs/interfaces/_types_.transactionoptions.md b/packages/tx/docs/interfaces/_types_.transactionoptions.md index c2630f0b17d..0f5d4ddd302 100644 --- a/packages/tx/docs/interfaces/_types_.transactionoptions.md +++ b/packages/tx/docs/interfaces/_types_.transactionoptions.md @@ -2,47 +2,48 @@ # Interface: TransactionOptions -The transaction's options. This could be specified using a Common object, or `chain` and `hardfork`. Defaults to -mainnet. +An object to set to which blockchain the blocks and their headers belong. This could be specified +using a Common object, or `chain` and `hardfork`. Defaults to mainnet without specifying a +hardfork. ## Hierarchy -- **TransactionOptions** +* **TransactionOptions** ## Index ### Properties -- [chain](_types_.transactionoptions.md#optional-chain) -- [common](_types_.transactionoptions.md#optional-common) -- [hardfork](_types_.transactionoptions.md#optional-hardfork) +* [chain](_types_.transactionoptions.md#optional-chain) +* [common](_types_.transactionoptions.md#optional-common) +* [hardfork](_types_.transactionoptions.md#optional-hardfork) ## Properties ### `Optional` chain -• **chain**? : _number | string_ +• **chain**? : *number | string* -_Defined in [types.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L94)_ +*Defined in [types.ts:94](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L94)* The chain of the transaction, default: 'mainnet' ---- +___ ### `Optional` common -• **common**? : _Common_ +• **common**? : *Common* -_Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)_ +*Defined in [types.ts:89](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L89)* A Common object defining the chain and the hardfork a transaction belongs to. ---- +___ ### `Optional` hardfork -• **hardfork**? : _undefined | string_ +• **hardfork**? : *undefined | string* -_Defined in [types.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L99)_ +*Defined in [types.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L99)* The hardfork of the transaction, default: 'petersburg' diff --git a/packages/tx/docs/interfaces/_types_.transformabletobuffer.md b/packages/tx/docs/interfaces/_types_.transformabletobuffer.md index 2a0f2238f63..06c54444766 100644 --- a/packages/tx/docs/interfaces/_types_.transformabletobuffer.md +++ b/packages/tx/docs/interfaces/_types_.transformabletobuffer.md @@ -6,20 +6,20 @@ Any object that can be transformed into a `Buffer` ## Hierarchy -- **TransformableToBuffer** +* **TransformableToBuffer** ## Index ### Methods -- [toBuffer](_types_.transformabletobuffer.md#tobuffer) +* [toBuffer](_types_.transformabletobuffer.md#tobuffer) ## Methods -### toBuffer +### toBuffer -▸ **toBuffer**(): _Buffer_ +▸ **toBuffer**(): *Buffer* -_Defined in [types.ts:8](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L8)_ +*Defined in [types.ts:7](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L7)* -**Returns:** _Buffer_ +**Returns:** *Buffer* diff --git a/packages/tx/docs/interfaces/_types_.txdata.md b/packages/tx/docs/interfaces/_types_.txdata.md index a89839cc874..314c2d7511c 100644 --- a/packages/tx/docs/interfaces/_types_.txdata.md +++ b/packages/tx/docs/interfaces/_types_.txdata.md @@ -6,108 +6,108 @@ A transaction's data. ## Hierarchy -- **TxData** +* **TxData** ## Index ### Properties -- [data](_types_.txdata.md#optional-data) -- [gasLimit](_types_.txdata.md#optional-gaslimit) -- [gasPrice](_types_.txdata.md#optional-gasprice) -- [nonce](_types_.txdata.md#optional-nonce) -- [r](_types_.txdata.md#optional-r) -- [s](_types_.txdata.md#optional-s) -- [to](_types_.txdata.md#optional-to) -- [v](_types_.txdata.md#optional-v) -- [value](_types_.txdata.md#optional-value) +* [data](_types_.txdata.md#optional-data) +* [gasLimit](_types_.txdata.md#optional-gaslimit) +* [gasPrice](_types_.txdata.md#optional-gasprice) +* [nonce](_types_.txdata.md#optional-nonce) +* [r](_types_.txdata.md#optional-r) +* [s](_types_.txdata.md#optional-s) +* [to](_types_.txdata.md#optional-to) +* [v](_types_.txdata.md#optional-v) +* [value](_types_.txdata.md#optional-value) ## Properties ### `Optional` data -• **data**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **data**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:48](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L48)_ +*Defined in [types.ts:47](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L47)* This will contain the data of the message or the init of a contract ---- +___ ### `Optional` gasLimit -• **gasLimit**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasLimit**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:28](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L28)_ +*Defined in [types.ts:27](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L27)* The transaction's gas limit. ---- +___ ### `Optional` gasPrice -• **gasPrice**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **gasPrice**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:33](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L33)_ +*Defined in [types.ts:32](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L32)* The transaction's gas price. ---- +___ ### `Optional` nonce -• **nonce**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **nonce**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:43](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L43)_ +*Defined in [types.ts:42](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L42)* The transaction's nonce. ---- +___ ### `Optional` r -• **r**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **r**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:58](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L58)_ +*Defined in [types.ts:57](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L57)* EC signature parameter. ---- +___ ### `Optional` s -• **s**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **s**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:63](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L63)_ +*Defined in [types.ts:62](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L62)* EC signature parameter. ---- +___ ### `Optional` to -• **to**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **to**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:38](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L38)_ +*Defined in [types.ts:37](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L37)* The transaction's the address is sent to. ---- +___ ### `Optional` v -• **v**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **v**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:53](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L53)_ +*Defined in [types.ts:52](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L52)* EC recovery ID. ---- +___ ### `Optional` value -• **value**? : _[BufferLike](../modules/\_types_.md#bufferlike)\_ +• **value**? : *[BufferLike](../modules/_types_.md#bufferlike)* -_Defined in [types.ts:68](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L68)_ +*Defined in [types.ts:67](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L67)* The amount of Ether sent. diff --git a/packages/tx/docs/modules/_fake_.md b/packages/tx/docs/modules/_fake_.md index 6e5d8ac71b3..05951881ab2 100644 --- a/packages/tx/docs/modules/_fake_.md +++ b/packages/tx/docs/modules/_fake_.md @@ -6,4 +6,4 @@ ### Classes -- [FakeTransaction](../classes/_fake_.faketransaction.md) +* [FakeTransaction](../classes/_fake_.faketransaction.md) diff --git a/packages/tx/docs/modules/_index_.md b/packages/tx/docs/modules/_index_.md index ca95b7fcad7..705952982ab 100644 --- a/packages/tx/docs/modules/_index_.md +++ b/packages/tx/docs/modules/_index_.md @@ -6,37 +6,37 @@ ### Classes -- [FakeTransaction](../classes/_index_.faketransaction.md) -- [Transaction](../classes/_index_.transaction.md) +* [FakeTransaction](../classes/_index_.faketransaction.md) +* [Transaction](../classes/_index_.transaction.md) ### Interfaces -- [FakeTxData](../interfaces/_index_.faketxdata.md) -- [TransactionOptions](../interfaces/_index_.transactionoptions.md) -- [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) -- [TxData](../interfaces/_index_.txdata.md) +* [FakeTxData](../interfaces/_index_.faketxdata.md) +* [TransactionOptions](../interfaces/_index_.transactionoptions.md) +* [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) +* [TxData](../interfaces/_index_.txdata.md) ### Type aliases -- [BufferLike](_index_.md#bufferlike) -- [PrefixedHexString](_index_.md#prefixedhexstring) +* [BufferLike](_index_.md#bufferlike) +* [PrefixedHexString](_index_.md#prefixedhexstring) ## Type aliases -### BufferLike +### BufferLike -Ƭ **BufferLike**: _Buffer | [TransformableToBuffer](../interfaces/\_index_.transformabletobuffer.md) | [PrefixedHexString](_index_.md#prefixedhexstring) | number\_ +Ƭ **BufferLike**: *Buffer | [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) | [PrefixedHexString](_index_.md#prefixedhexstring) | number* -_Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L19)_ +*Defined in [types.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L18)* A Buffer, hex string prefixed with `0x`, Number, or an object with a toBuffer method such as BN. ---- +___ -### PrefixedHexString +### PrefixedHexString -Ƭ **PrefixedHexString**: _string_ +Ƭ **PrefixedHexString**: *string* -_Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L14)_ +*Defined in [types.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L13)* A hex string prefixed with `0x`. diff --git a/packages/tx/docs/modules/_transaction_.md b/packages/tx/docs/modules/_transaction_.md index c3660a595bf..7ed4938cb44 100644 --- a/packages/tx/docs/modules/_transaction_.md +++ b/packages/tx/docs/modules/_transaction_.md @@ -6,4 +6,4 @@ ### Classes -- [Transaction](../classes/_transaction_.transaction.md) +* [Transaction](../classes/_transaction_.transaction.md) diff --git a/packages/tx/docs/modules/_types_.md b/packages/tx/docs/modules/_types_.md index d6046bcd710..f78fd735302 100644 --- a/packages/tx/docs/modules/_types_.md +++ b/packages/tx/docs/modules/_types_.md @@ -6,32 +6,32 @@ ### Interfaces -- [FakeTxData](../interfaces/_types_.faketxdata.md) -- [TransactionOptions](../interfaces/_types_.transactionoptions.md) -- [TransformableToBuffer](../interfaces/_types_.transformabletobuffer.md) -- [TxData](../interfaces/_types_.txdata.md) +* [FakeTxData](../interfaces/_types_.faketxdata.md) +* [TransactionOptions](../interfaces/_types_.transactionoptions.md) +* [TransformableToBuffer](../interfaces/_types_.transformabletobuffer.md) +* [TxData](../interfaces/_types_.txdata.md) ### Type aliases -- [BufferLike](_types_.md#bufferlike) -- [PrefixedHexString](_types_.md#prefixedhexstring) +* [BufferLike](_types_.md#bufferlike) +* [PrefixedHexString](_types_.md#prefixedhexstring) ## Type aliases -### BufferLike +### BufferLike -Ƭ **BufferLike**: _Buffer | [TransformableToBuffer](../interfaces/\_index_.transformabletobuffer.md) | [PrefixedHexString](_types_.md#prefixedhexstring) | number\_ +Ƭ **BufferLike**: *Buffer | [TransformableToBuffer](../interfaces/_index_.transformabletobuffer.md) | [PrefixedHexString](_types_.md#prefixedhexstring) | number* -_Defined in [types.ts:19](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L19)_ +*Defined in [types.ts:18](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L18)* A Buffer, hex string prefixed with `0x`, Number, or an object with a toBuffer method such as BN. ---- +___ -### PrefixedHexString +### PrefixedHexString -Ƭ **PrefixedHexString**: _string_ +Ƭ **PrefixedHexString**: *string* -_Defined in [types.ts:14](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L14)_ +*Defined in [types.ts:13](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/tx/src/types.ts#L13)* A hex string prefixed with `0x`. diff --git a/packages/tx/src/types.ts b/packages/tx/src/types.ts index 8b3a68988fb..03d0c4efba9 100644 --- a/packages/tx/src/types.ts +++ b/packages/tx/src/types.ts @@ -1,4 +1,3 @@ -import { Buffer } from 'buffer' import Common from 'ethereumjs-common' /** @@ -79,8 +78,9 @@ export interface FakeTxData extends TxData { } /** - * The transaction's options. This could be specified using a Common object, or `chain` and `hardfork`. Defaults to - * mainnet. + * An object to set to which blockchain the blocks and their headers belong. This could be specified + * using a Common object, or `chain` and `hardfork`. Defaults to mainnet without specifying a + * hardfork. */ export interface TransactionOptions { /** diff --git a/packages/vm/examples/run-blockchain/index.ts b/packages/vm/examples/run-blockchain/index.ts index c5c17061a1e..de08d9712c2 100644 --- a/packages/vm/examples/run-blockchain/index.ts +++ b/packages/vm/examples/run-blockchain/index.ts @@ -1,11 +1,10 @@ import VM from '../../' import Account from 'ethereumjs-account' +import { Block, BlockHeader } from 'ethereumjs-block' import Blockchain from 'ethereumjs-blockchain' import { toBuffer, setLength } from 'ethereumjs-util' -const Block = require('ethereumjs-block') -const BlockHeader = require('ethereumjs-block/header.js') const testData = require('./test-data') const level = require('level') const { promisify } = require('util') diff --git a/packages/vm/lib/evm/evm.ts b/packages/vm/lib/evm/evm.ts index 9343b76cf91..3db478d7fe3 100644 --- a/packages/vm/lib/evm/evm.ts +++ b/packages/vm/lib/evm/evm.ts @@ -16,7 +16,7 @@ import Message from './message' import EEI from './eei' import { default as Interpreter, InterpreterOpts, RunState } from './interpreter' -const Block = require('ethereumjs-block') +import { Block } from 'ethereumjs-block' /** * Result of executing a message via the [[EVM]]. diff --git a/packages/vm/lib/runBlock.ts b/packages/vm/lib/runBlock.ts index f635562785a..43b744249f0 100644 --- a/packages/vm/lib/runBlock.ts +++ b/packages/vm/lib/runBlock.ts @@ -171,7 +171,7 @@ async function applyBlock(this: VM, block: any, opts: RunBlockOpts) { if (new BN(block.header.gasLimit).gte(new BN('8000000000000000', 16))) { throw new Error('Invalid block with gas limit greater than (2^63 - 1)') } else { - await promisify(block.validate).bind(block)(this.blockchain) + await block.validate(this.blockchain) } } // Apply transactions diff --git a/packages/vm/lib/runCall.ts b/packages/vm/lib/runCall.ts index 69b1a235786..43d747de710 100644 --- a/packages/vm/lib/runCall.ts +++ b/packages/vm/lib/runCall.ts @@ -4,7 +4,7 @@ import VM from './index' import TxContext from './evm/txContext' import Message from './evm/message' import { default as EVM, EVMResult } from './evm/evm' -const Block = require('ethereumjs-block') +import { Block } from 'ethereumjs-block' /** * Options for running a call (or create) operation diff --git a/packages/vm/lib/runCode.ts b/packages/vm/lib/runCode.ts index 2694e3e519e..03bc7480191 100644 --- a/packages/vm/lib/runCode.ts +++ b/packages/vm/lib/runCode.ts @@ -16,7 +16,7 @@ import VM from './index' import TxContext from './evm/txContext' import Message from './evm/message' import { default as EVM, ExecResult } from './evm/evm' -const Block = require('ethereumjs-block') +import { Block } from 'ethereumjs-block' /** * Options for the [[runCode]] method. diff --git a/packages/vm/lib/runTx.ts b/packages/vm/lib/runTx.ts index 9e64a034c2a..10ffe459d86 100644 --- a/packages/vm/lib/runTx.ts +++ b/packages/vm/lib/runTx.ts @@ -7,7 +7,7 @@ import Bloom from './bloom' import { default as EVM, EVMResult } from './evm/evm' import Message from './evm/message' import TxContext from './evm/txContext' -const Block = require('ethereumjs-block') +import { Block } from 'ethereumjs-block' /** * Options for the `runTx` method. diff --git a/packages/vm/package.json b/packages/vm/package.json index f684ad620c7..0efd0149832 100644 --- a/packages/vm/package.json +++ b/packages/vm/package.json @@ -19,7 +19,7 @@ "test:state:slow": "npm run test:state -- --runSkipped=slow", "test:buildIntegrity": "npm run test:state -- --test='stackOverflow'", "test:blockchain": "node -r ts-node/register --stack-size=1500 ./tests/tester --blockchain", - "test:API": "npm run build && ts-node ./node_modules/tape/bin/tape './tests/api/**/*.js'", + "test:API": "node -r ts-node/register --stack-size=1500 ./node_modules/tape/bin/tape './tests/api/**/*.js'", "test:API:browser": "npm run build && karma start karma.conf.js", "test": "echo \"[INFO] Generic test cmd not used. See package.json for more specific test run cmds.\"", "tslint": "ethereumjs-config-tslint", @@ -44,7 +44,7 @@ "async-eventemitter": "^0.2.4", "core-js-pure": "^3.0.1", "ethereumjs-account": "^3.0.0", - "ethereumjs-block": "^2.2.2", + "ethereumjs-block": "^3.0.0", "ethereumjs-blockchain": "^4.0.3", "ethereumjs-common": "^1.5.0", "ethereumjs-tx": "^2.1.2", diff --git a/packages/vm/tests/BlockchainTestsRunner.js b/packages/vm/tests/BlockchainTestsRunner.js index 7df1514d634..32253653201 100644 --- a/packages/vm/tests/BlockchainTestsRunner.js +++ b/packages/vm/tests/BlockchainTestsRunner.js @@ -2,9 +2,8 @@ const util = require('util') const testUtil = require('./util.js') const ethUtil = require('ethereumjs-util') const Trie = require('merkle-patricia-tree/secure') -const Block = require('ethereumjs-block') +const {Block, BlockHeader} = require('ethereumjs-block') const Blockchain = require('ethereumjs-blockchain').default -const BlockHeader = require('ethereumjs-block/header.js') const level = require('level') const levelMem = require('level-mem') @@ -37,7 +36,7 @@ module.exports = async function runBlockchainTest(options, testData, t) { blockchain: blockchain, hardfork: options.forkConfigVM, }) - const genesisBlock = new Block({ hardfork: options.forkConfigVM }) + const genesisBlock = new Block(undefined, { hardfork: options.forkConfigVM }) testData.homestead = true if (testData.homestead) { diff --git a/packages/vm/tests/api/events.js b/packages/vm/tests/api/events.js index cda81b5f363..3616d5eb363 100644 --- a/packages/vm/tests/api/events.js +++ b/packages/vm/tests/api/events.js @@ -1,7 +1,7 @@ const tape = require('tape') const util = require('ethereumjs-util') const { Transaction } = require('ethereumjs-tx') -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block const VM = require('../../dist/index').default tape('VM events', t => { diff --git a/packages/vm/tests/api/index.js b/packages/vm/tests/api/index.js index ba808732dc8..b7954392903 100644 --- a/packages/vm/tests/api/index.js +++ b/packages/vm/tests/api/index.js @@ -1,7 +1,7 @@ const tape = require('tape') const promisify = require('util.promisify') const util = require('ethereumjs-util') -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block const Common = require('ethereumjs-common').default const Trie = require('merkle-patricia-tree/secure') const VM = require('../../dist/index').default diff --git a/packages/vm/tests/api/runBlock.js b/packages/vm/tests/api/runBlock.js index ab1da5f74a0..7028eb55274 100644 --- a/packages/vm/tests/api/runBlock.js +++ b/packages/vm/tests/api/runBlock.js @@ -1,6 +1,6 @@ const tape = require('tape') const promisify = require('util.promisify') -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block const Common = require('ethereumjs-common').default const util = require('ethereumjs-util') const runBlock = require('../../dist/runBlock').default @@ -90,7 +90,7 @@ tape('should fail when block validation fails', async (t) => { const suite = setup() const block = new Block(util.rlp.decode(suite.data.blocks[0].rlp)) - block.validate = (_, cb) => cb(new Error('test')) + block.validate = async () => { throw new Error('test') } await suite.p .runBlock({ block }) diff --git a/packages/vm/tests/api/runBlockchain.js b/packages/vm/tests/api/runBlockchain.js index 606b618f993..5eb07946b7f 100644 --- a/packages/vm/tests/api/runBlockchain.js +++ b/packages/vm/tests/api/runBlockchain.js @@ -2,13 +2,15 @@ const tape = require('tape') const level = require('level-mem') const promisify = require('util.promisify') const Blockchain = require('ethereumjs-blockchain').default -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block const Common = require('ethereumjs-common').default const util = require('ethereumjs-util') const runBlockchain = require('../../dist/runBlockchain').default const { StateManager } = require('../../dist/state') const { createGenesis } = require('./utils') +Error.stackTraceLimit = 100 + tape('runBlockchain', (t) => { const blockchainDB = level() const blockchain = new Blockchain({ @@ -27,16 +29,22 @@ tape('runBlockchain', (t) => { const getHeadP = promisify(blockchain.getHead.bind(blockchain)) t.test('should run without a blockchain parameter', async (st) => { - await runBlockchain.bind(vm)() - st.end() + st.doesNotThrow(async function(){ + await runBlockchain.bind(vm)() + st.end() + }) }) t.test('should run without blocks', async (st) => { - await runBlockchain.bind(vm)(blockchain) - st.end() + st.doesNotThrow(async function(){ + await runBlockchain.bind(vm)(blockchain) + st.end() + }) }) t.test('should run with genesis block', async (st) => { + try { + const genesis = createGenesis({ chain: 'goerli' }) await putGenesisP(genesis) @@ -44,6 +52,9 @@ tape('runBlockchain', (t) => { await runBlockchain.bind(vm)(blockchain) st.end() + } catch(e) { + st.end(e) + } }) t.test('should run with valid and invalid blocks', async (st) => { @@ -94,7 +105,7 @@ function createBlock(parent = null, n = 0, opts = {}) { return createGenesis(opts) } - const b = new Block(null, opts) + const b = new Block(undefined, opts) b.header.number = util.toBuffer(n) b.header.parentHash = parent.hash() b.header.difficulty = '0xfffffff' diff --git a/packages/vm/tests/api/utils.js b/packages/vm/tests/api/utils.js index 94991309187..8aede871b51 100644 --- a/packages/vm/tests/api/utils.js +++ b/packages/vm/tests/api/utils.js @@ -1,4 +1,4 @@ -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block const Account = require('ethereumjs-account').default const level = require('level-mem') const Blockchain = require('ethereumjs-blockchain').default @@ -6,7 +6,7 @@ const VM = require('../../dist/index').default function createGenesis (opts = {}) { opts.chain = opts.chain ? opts.chain : 'mainnet' - const genesis = new Block(null, opts) + const genesis = new Block(undefined, opts) genesis.setGenesisParams() return genesis diff --git a/packages/vm/tests/tester.js b/packages/vm/tests/tester.js index d9fe0fe3187..57889e42054 100755 --- a/packages/vm/tests/tester.js +++ b/packages/vm/tests/tester.js @@ -63,6 +63,8 @@ function runTests() { const runner = require(`./${name}Runner.js`) // Tests for HFs before Istanbul have been moved under `LegacyTests/Constantinople`: // https://github.com/ethereum/tests/releases/tag/v7.0.0-beta.1 + + // TODO: Replace with Common.lteHardfork('Istanbul') if (testGetterArgs.forkConfig !== 'Istanbul') { name = 'LegacyTests/Constantinople/'.concat(name) } diff --git a/packages/vm/tests/util.js b/packages/vm/tests/util.js index 3ba5a67934f..08933381be4 100644 --- a/packages/vm/tests/util.js +++ b/packages/vm/tests/util.js @@ -5,7 +5,7 @@ const BN = utils.BN const rlp = utils.rlp const Account = require('ethereumjs-account').default const Transaction = require('ethereumjs-tx').Transaction -const Block = require('ethereumjs-block') +const Block = require('ethereumjs-block').Block exports.dumpState = function(state, cb) { function readAccounts(state) {