Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct web3-eth2- packages types #3865

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54da486
Wrap function params in object
spacesailor24 Jan 19, 2021
254ef3b
Wrap function params in object
spacesailor24 Jan 19, 2021
78f4a57
Export needed typings in web3-eth2-core. Export class definition in w…
spacesailor24 Jan 19, 2021
d4ed3ac
Replace interface type with class
spacesailor24 Jan 19, 2021
77cd2e3
Remove addBlockExplorerApi from class type
spacesailor24 Jan 19, 2021
dc4fd22
linter errors. Add ETH2Core class export
spacesailor24 Jan 19, 2021
dc95602
Linter errors
spacesailor24 Jan 19, 2021
d8456a9
Merge branch '1.x' into wyatt/beaconchain-types-fix
spacesailor24 Jan 20, 2021
4d52138
Merge branch '1.x' into wyatt/beaconchain-types-fix
spacesailor24 Jan 21, 2021
9cf8675
Update changelog
spacesailor24 Jan 21, 2021
acbe4dd
Merge conflict
spacesailor24 Jan 21, 2021
5b2bdd7
Replace index.d.ts files with types.ts
spacesailor24 Jan 21, 2021
faa53e2
Update type declaration files, update dependencies for web3-eth2-core
spacesailor24 Jan 21, 2021
6792884
remove dtslint commands
spacesailor24 Jan 21, 2021
b877123
Add dtslint npm command - I think lerna needs it to report a success
spacesailor24 Jan 21, 2021
8665966
Remove dtslint command
spacesailor24 Jan 21, 2021
b14978c
dtslint debug
spacesailor24 Jan 21, 2021
3ae1f54
dtslint debug
spacesailor24 Jan 21, 2021
2de2dfa
Remove dtslint from devDependencies and remove dtslint npm command
spacesailor24 Jan 22, 2021
81ae5bf
Remove dtslint with npm remove
spacesailor24 Jan 22, 2021
ef342cc
Update types file path
spacesailor24 Jan 22, 2021
77d754e
Debug
spacesailor24 Jan 22, 2021
a59690d
Debug
spacesailor24 Jan 22, 2021
6fd8762
Debug
spacesailor24 Jan 22, 2021
063b302
Debug
spacesailor24 Jan 22, 2021
7b77fd7
Merge conflicts
spacesailor24 Jan 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ Released with 1.0.0-beta.37 code base.
- Grammar changes to inputAddressFormatter error message
- Fixed vulnerable dependencies

## [Unreleased]

## [1.3.2]
## [1.3.3]

### Fixed

- Fix EIP-1193 provider subscriptions (#3864)

## [1.3.3]
## [Unreleased]

## [1.3.4]

### Changed

Expand All @@ -326,10 +326,18 @@ Released with 1.0.0-beta.37 code base.
- Rename `web3-eth2-base` to `web3-eth2-core` and `web3-eth2-beacon` to `web3-eth2-beaconchain`
- Bump `ts-node` from version `^8.10.2` to `^9.0.0`
- Ran `npm audit fix` which fixed 4 vulnerabilities
- Correct `web3-eth2-beaconchain` type declarations
- Correct `web3-eth2-beaconchain` type declarations (#3859) and (#3865)
- Move interfaces `IBaseAPISchema` and `IBaseAPIMethodSchema` to `index.d.ts` for `web3-eth2-core`
- Removes `IETH2BeaconChain` interface in favor of exporting a class type: `ETH2BeaconChain`
- Remove `index.d.ts` files in favor of `types.ts` for `web3-eth2-core` and `web3-eth2-beaconchain`
- Update dependencies for `web3-eth2-core`

### Removed

- `schema.ts` from `web3-eth2-core`
- `dtslint` npm command from `web3-eth2-core` and `web3-eth2-beaconchain` as `index.d.ts` files were removed

### Added
- Deprecation of bzz warning

### Removed
- ethjs-signer test (#3876)
- Add `ETH2Core` class export to `index.d.ts` for `web3-eth2-core`
- Deprecation of bzz warning
18,142 changes: 4,620 additions & 13,522 deletions packages/web3-eth2-beaconchain/package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/web3-eth2-beaconchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"engines": {
"node": ">=8.0.0"
},
"types": "types/index.d.ts",
"types": "types.ts",
"scripts": {
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types",
"test": "jest",
"tsc": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline"
},
Expand All @@ -21,7 +20,6 @@
"@chainsafe/lodestar-types": "^0.13.0",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.2",
"dtslint": "^3.4.1",
"jest": "^26.4.2",
"ts-jest": "^26.4.1",
"typescript": "^4.0.3"
Expand Down
12 changes: 4 additions & 8 deletions packages/web3-eth2-beaconchain/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
// @ts-ignore - types not full implemented yet
import { ETH2Core } from 'web3-eth2-core'
import { ETH2Core, BaseAPISchema, ETH2BaseOpts } from 'web3-eth2-core'
import { DefaultSchema } from './schema'

import { IETH2BeaconChain } from '../types/index'
// @ts-ignore - types not full implemented yet
import { IBaseAPISchema } from 'web3-eth2-core'
// @ts-ignore - types not full implemented yet
import { ETH2BaseOpts } from 'web3-eth2-core'
import { ETH2BeaconChain as IETH2BeaconChain } from '../types'

// @ts-ignore - ETH2BeaconChain incorrectly implements interface IETH2BeaconChain
// because methods are added during runtime
export class ETH2BeaconChain extends ETH2Core implements IETH2BeaconChain {
constructor(
provider: string,
schema: IBaseAPISchema = DefaultSchema,
schema: BaseAPISchema = DefaultSchema,
opts: ETH2BaseOpts = { protectProvider: true }) {
super(provider, schema, opts)
}
Expand Down
75 changes: 17 additions & 58 deletions packages/web3-eth2-beaconchain/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,21 @@
{
"compilerOptions": {
/* Basic Options */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
// "declarationDir": "lib" /* Output directory for generated declaration files. */
"declaration": true,
"outDir": "lib",
"strict": true,
"esModuleInterop": true,
"module": "commonjs",
"lib": ["es6"],
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"allowSyntheticDefaultImports": false,
"baseUrl": ".",
"paths": {
"web3-eth2-beaconchain": ["."]
}
}
}
47 changes: 47 additions & 0 deletions packages/web3-eth2-beaconchain/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
Slot,
Root,
Genesis,
Fork,
FinalityCheckpoints,
Validator,
ValidatorResponse,
ValidatorBalance,
Epoch,
BeaconCommitteeResponse,
SignedBeaconHeaderResponse,
Attestation,
CommitteeIndex,
IndexedAttestation,
ProposerSlashing,
SignedVoluntaryExit
} from '@chainsafe/lodestar-types'

export type StateId = 'head' | 'genesis' | 'finalized' | 'justified' | Slot | Root
export type BlockId = 'head' | 'genesis' | 'finalized' | Slot | Root

export interface ETH2BeaconChain {
getGenesis(): Promise<Genesis | null>
getHashRoot(params: {stateId: StateId}): Promise<{ root: Root }>
getForkData(params: {stateId: StateId}): Promise<Fork>
getFinalityCheckpoint(params: {stateId: StateId}): Promise<FinalityCheckpoints>
getValidators(params: {stateId: StateId}): Promise<Validator[]>
getValidatorById(params: {stateId: StateId, validatorId: string}): Promise<ValidatorResponse>
getValidatorBalances(params: {stateId: StateId}): Promise<ValidatorBalance>
getEpochCommittees(params: {stateId: StateId, epoch: Epoch}): Promise<BeaconCommitteeResponse>
getBlockHeaders(): Promise<SignedBeaconHeaderResponse[]>
getBlockHeader(params: {blockId: BlockId}): Promise<SignedBeaconHeaderResponse>
publishSignedBlock(): Promise<void>
getBlock(params: {blockId: BlockId}): Promise<SignedBeaconHeaderResponse>
getBlockRoot(params: {blockId: BlockId}): Promise<Root>
getBlockAttestations(params: {blockId: BlockId}): Promise<Attestation>
getAttestationsFromPool(params: {slot: Slot, committee_index: CommitteeIndex}): Promise<Attestation[]>
submitAttestation(): Promise<void>
getAttesterSlashings(): Promise<{ [index: string]: IndexedAttestation }>
submitAttesterSlashings(): Promise<void>
getProposerSlashings(): Promise<ProposerSlashing[]>
submitProposerSlashings(): Promise<void>
getSignedVoluntaryExits(): Promise<SignedVoluntaryExit[]>
submitVoluntaryExit(): Promise<void>
}

46 changes: 0 additions & 46 deletions packages/web3-eth2-beaconchain/types/index.d.ts

This file was deleted.

17 changes: 0 additions & 17 deletions packages/web3-eth2-beaconchain/types/tsconfig.json

This file was deleted.

Loading