This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add declarations for ethereumjs-vm in @0x/typescript-typings
- Loading branch information
Showing
6 changed files
with
556 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/typescript-typings/types/ethereumjs-account/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
declare module 'ethereumjs-account' { | ||
export class Account { | ||
public nonce!: Buffer; | ||
public balance!: Buffer; | ||
public stateRoot!: Buffer; | ||
public codeHash!: Buffer; | ||
constructor(data?: any); | ||
serialize(): Buffer; | ||
getCode(trie: Trie, cb: TrieGetCb): void; | ||
setCode(trie: Trie, code: Buffer, cb: (err: any, codeHash: Buffer) => void): void; | ||
getStorage(trie: Trie, key: Buffer | string, cb: TrieGetCb); | ||
setStorage(trie: Trie, key: Buffer | string, val: Buffer | string, cb: () => void); | ||
isEmpty(): boolean; | ||
} | ||
|
||
interface TrieGetCb { | ||
(err: any, value: Buffer | null): void; | ||
} | ||
interface TriePutCb { | ||
(err?: any): void; | ||
} | ||
|
||
interface Trie { | ||
root: Buffer; | ||
copy(): Trie; | ||
getRaw(key: Buffer, cb: TrieGetCb): void; | ||
putRaw(key: Buffer | string, value: Buffer, cb: TriePutCb): void; | ||
get(key: Buffer | string, cb: TrieGetCb): void; | ||
put(key: Buffer | string, value: Buffer | string, cb: TriePutCb): void; | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
packages/typescript-typings/types/ethereumjs-blockchain/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
declare module 'ethereumjs-blockchain' { | ||
import BN = require('bn.js'); | ||
import Common from 'ethereumjs-common'; | ||
import Block from 'ethereumjs-block'; | ||
|
||
interface BlockchainInterface { | ||
putBlock(block: Block, cb: any, isGenesis?: boolean): void; | ||
delBlock(blockHash: Buffer, cb: any): void; | ||
getBlock(blockTag: Buffer | number | BN, cb: (err: Error | null, block?: Block) => void): void; | ||
iterator(name: string, onBlock: any, cb: any): void; | ||
getDetails(_: string, cb: any): void; | ||
} | ||
|
||
interface BlockchainOptions { | ||
chain?: string | number; | ||
hardfork?: string | null; | ||
common?: Common; | ||
db?: any; | ||
validate?: boolean; | ||
validatePow?: boolean; | ||
validateBlocks?: boolean; | ||
} | ||
|
||
export class Blockchain implements BlockchainInterface { | ||
_common: Common; | ||
_genesis: any; | ||
_headBlock: any; | ||
_headHeader: any; | ||
_heads: any; | ||
_initDone: boolean; | ||
_initLock: any; | ||
_putSemaphore: any; | ||
_staleHeadBlock: any; | ||
_staleHeads: any; | ||
db: any; | ||
dbManager: DBManager; | ||
ethash: any; | ||
public readonly validate: boolean; | ||
private readonly _validatePow: boolean; | ||
private readonly _validateBlocks: boolean; | ||
|
||
constructor(opts: BlockchainOptions); | ||
meta(): any; | ||
_init(cb: any): void; | ||
_setCanonicalGenesisBlock(cb: any): void; | ||
putGenesis(genesis: any, cb: any): void; | ||
getHead(name: any, cb?: any): void; | ||
getLatestHeader(cb: any): void; | ||
getLatestBlock(cb: any); | ||
putBlocks(blocks: Array<any>, cb: any); | ||
putBlock(block: object, cb: any, isGenesis?: boolean); | ||
putHeaders(headers: Array<any>, cb: any); | ||
putHeader(header: object, cb: any); | ||
_putBlockOrHeader(item: any, cb: any, isGenesis?: boolean); | ||
getBlock(blockTag: Buffer | number | BN, cb: any); | ||
_getBlock(blockTag: Buffer | number | BN, cb: any); | ||
getBlocks(blockId: Buffer | number, maxBlocks: number, skip: number, reverse: boolean, cb: any); | ||
getDetails(_: string, cb: any); | ||
selectNeededHashes(hashes: Array<any>, cb: any); | ||
_saveHeadOps(); | ||
_saveHeads(cb: any); | ||
_deleteStaleAssignments(number: BN, headHash: Buffer, ops: any, cb: any); | ||
_rebuildCanonical(header: any, ops: any, cb: any); | ||
delBlock(blockHash: Buffer, cb: any); | ||
_delBlock(blockHash: Buffer | typeof Block, cb: any); | ||
_delChild(hash: Buffer, number: BN, headHash: Buffer, ops: any, cb: any); | ||
_iterator(name: string, func: any, cb: any); | ||
_batchDbOps(dbOps: any, cb: any): void; | ||
_hashToNumber(hash: Buffer, cb: any): void; | ||
_numberToHash(number: BN, cb: any): void; | ||
_lookupByHashNumber(hash: Buffer, number: BN, cb: any, next: any): void; | ||
_getHeader(hash: Buffer, number: any, cb?: any): void; | ||
_getCanonicalHeader(number: BN, cb: any): void; | ||
_getTd(hash: any, number: any, cb?: any): void; | ||
_lockUnlock(fn: any, cb: any): void; | ||
} | ||
|
||
class DBManager { | ||
_cache: { [k: string]: Cache<Buffer> }; | ||
_common: any; | ||
_db: any; | ||
constructor(db: any, common: any); | ||
getHeads(): Promise<any>; | ||
getHeadHeader(): Promise<any>; | ||
getHeadBlock(): Promise<any>; | ||
getBlock(blockTag: Buffer | BN | number): Promise<any>; | ||
getBody(hash: Buffer, number: BN): Promise<Buffer>; | ||
getHeader(hash: Buffer, number: BN); | ||
getTd(hash: Buffer, number: BN): Promise<BN>; | ||
hashToNumber(hash: Buffer): Promise<BN>; | ||
numberToHash(number: BN): Promise<Buffer>; | ||
get(key: string | Buffer, opts: any = {}): Promise<any>; | ||
batch(ops: Array<any>): Promise<any>; | ||
} | ||
|
||
class Cache<V> { | ||
_cache: LRU<string, V>; | ||
constructor(opts: LRU.Options<string, V>); | ||
set(key: string | Buffer, value: V): void; | ||
get(key: string | Buffer): V | undefined; | ||
del(key: string | Buffer): void; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/typescript-typings/types/ethereumjs-common/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
declare module 'ethereumjs-common' { | ||
export class Common { | ||
private _hardfork: string | null; | ||
private _supportedHardforks: Array<string>; | ||
private _chainParams: Chain; | ||
forCustomChain( | ||
baseChain: string | number, | ||
customChainParams: Partial<Chain>, | ||
hardfork?: string | null, | ||
supportedHardforks?: Array<string>, | ||
): Common; | ||
_getChainParams(chain: string | number): Chain; | ||
constructor(chain: string | number | object, hardfork?: string | null, supportedHardforks?: Array<string>); | ||
setChain(chain: string | number | object): any; | ||
setHardfork(hardfork: string | null): void; | ||
_chooseHardfork(hardfork?: string | null, onlySupported?: boolean): string; | ||
_getHardfork(hardfork: string): any; | ||
_isSupportedHardfork(hardfork: string | null): boolean; | ||
param(topic: string, name: string, hardfork?: string): any; | ||
paramByBlock(topic: string, name: string, blockNumber: number): any; | ||
hardforkIsActiveOnBlock(hardfork: string | null, blockNumber: number, opts?: hardforkOptions): boolean; | ||
activeOnBlock(blockNumber: number, opts?: hardforkOptions): boolean; | ||
hardforkGteHardfork(hardfork1: string | null, hardfork2: string, opts?: hardforkOptions): boolean; | ||
gteHardfork(hardfork: string, opts?: hardforkOptions): boolean; | ||
hardforkIsActiveOnChain(hardfork?: string | null, opts?: hardforkOptions): boolean; | ||
activeHardforks(blockNumber?: number | null, opts?: hardforkOptions): Array<any>; | ||
activeHardfork(blockNumber?: number | null, opts?: hardforkOptions): string; | ||
hardforkBlock(hardfork?: string): number; | ||
isHardforkBlock(blockNumber: number, hardfork?: string): boolean; | ||
consensus(hardfork?: string): string; | ||
finality(hardfork?: string): string; | ||
genesis(): any; | ||
hardforks(): any; | ||
bootstrapNodes(): any; | ||
hardfork(): string | null; | ||
chainId(): number; | ||
chainName(): string; | ||
networkId(): number; | ||
} | ||
|
||
interface hardforkOptions { | ||
onlySupported?: boolean; | ||
onlyActive?: boolean; | ||
} | ||
|
||
interface Chain { | ||
name: string; | ||
chainId: number; | ||
networkId: number; | ||
comment: string; | ||
url: string; | ||
genesis: GenesisBlock; | ||
hardforks: Hardfork[]; | ||
bootstrapNodes: BootstrapNode[]; | ||
} | ||
|
||
interface GenesisBlock { | ||
hash: string; | ||
timestamp: string | null; | ||
gasLimit: number; | ||
difficulty: number; | ||
nonce: string; | ||
extraData: string; | ||
stateRoot: string; | ||
} | ||
interface Hardfork { | ||
name: string; | ||
block: number | null; | ||
consensus: string; | ||
finality: any; | ||
} | ||
interface BootstrapNode { | ||
ip: string; | ||
port: number | string; | ||
network?: string; | ||
chainId?: number; | ||
id: string; | ||
location: string; | ||
comment: string; | ||
} | ||
} |
Oops, something went wrong.