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

Rename eth2 packages #3833

Merged
merged 2 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,4 @@ Released with 1.0.0-beta.37 code base.

- Remove `notImplemented` flag from ETH2 Beacon Chain package methods schema
- Fixed mutation of inputs to encoding and decoding functions (#3748)
- Rename `web3-eth2-base` to `web3-eth2-core` and `web3-eth2-beacon` to `web3-eth2-beaconchain`
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "web3-eth2-beacon",
"name": "web3-eth2-beaconchain",
"version": "1.3.0",
"description": "Web3 ETH2 Beacon chain API wrappers.",
"repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-beacon",
"repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-beaconchain",
"license": "LGPL-3.0",
"engines": {
"node": ">=8.0.0"
Expand All @@ -15,7 +15,7 @@
},
"main": "lib/index.js",
"dependencies": {
"web3-eth2-base": "^1.3.0"
"web3-eth2-core": "^1.3.0"
},
"devDependencies": {
"@chainsafe/lodestar-types": "^0.11.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore - types not full implemented yet
import { ETH2Base } from 'web3-eth2-base'
import { ETH2Core } from 'web3-eth2-core'
import { DefaultSchema } from './schema'

import { IETH2Beacon } from '../types/index'
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'

// @ts-ignore - ETH2Beacon incorrectly implements interface IETH2Beacon
export class ETH2Beacon extends ETH2Base implements IETH2Beacon {
// @ts-ignore - ETH2BeaconChain incorrectly implements interface IETH2BeaconChain
export class ETH2BeaconChain extends ETH2Core implements IETH2BeaconChain {
constructor(
provider: string,
schema: IBaseAPISchema = DefaultSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IBaseAPISchema } from '../../web3-eth2-base/src/schema'
import { IBaseAPISchema } from '../../web3-eth2-core/src/schema'

export const DefaultSchema: IBaseAPISchema = {
packageName: 'eth2-beacon',
packageName: 'eth2-beaconchain',
routePrefix: '/eth/v1/beacon/',
methods: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ETH2Beacon } from '../src/index'
import { ETH2BeaconChain } from '../src/index'

const provider = 'http://127.0.0.1:9596'
const providerSuffix = '/eth/v1/beacon/'

it('constructs a ETH2BeaconChain instance with expected properties', () => {
const eth2BeaconChain = new ETH2Beacon(provider)
const eth2BeaconChain = new ETH2BeaconChain(provider)

// @ts-ignore - types not full implemented yet
expect(eth2BeaconChain.name).toBe('eth2-beacon')
expect(eth2BeaconChain.name).toBe('eth2-beaconchain')
// @ts-ignore - types not full implemented yet
expect(eth2BeaconChain.provider).toBe(`${provider}${providerSuffix}`)
// @ts-ignore - types not full implemented yet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETH2Beacon } from '../src/index'
import { ETH2BeaconChain } from '../src/index'

// Jest doesn't have a native method to test if value is boolean
expect.extend({
Expand All @@ -18,7 +18,7 @@ let eth2BeaconChain: any // should be ETH2BeaconChain but types aren't implement
beforeAll(() => {
// const provider = 'http://127.0.0.1:9596' // default port for Lodestar
const provider = 'http://127.0.0.1:5052' // default port for Lighthouse
eth2BeaconChain = new ETH2Beacon(provider)
eth2BeaconChain = new ETH2BeaconChain(provider)
})

it('getGenesis', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Genesis } from '@chainsafe/lodestar-types'

export interface IETH2Beacon {
export interface IETH2BeaconChain {
getGenesis(): Promise<Genesis>
getBlockHeader(): Promise<any>
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"allowSyntheticDefaultImports": false,
"baseUrl": ".",
"paths": {
"web3-eth2-beacon": ["."]
"web3-eth2-beaconchain": ["."]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "web3-eth2-base",
"name": "web3-eth2-core",
"version": "1.3.0",
"description": "Web3 ETH2 base tools for sub-packages. This is an internal package.",
"repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-base",
"description": "Web3 ETH2 core tools for sub-packages. This is an internal package.",
"repository": "https://github.com/ethereum/web3.js/tree/1.x/packages/web3-eth2-core",
"license": "LGPL-3.0",
"engines": {
"node": ">=8.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Axios.defaults.adapter = require('axios/lib/adapters/http');
import { ETH2BaseOpts, ETH2Function } from '../types/index'
import { IBaseAPISchema } from './schema'

export class ETH2Base {
export class ETH2Core {
private _httpClient: AxiosInstance

[ key: string ]: ETH2Function | any;
Expand Down Expand Up @@ -37,7 +37,7 @@ export class ETH2Base {
throw new Error(`Invalid HTTP(S) provider: ${provider}`)
}

this._httpClient = ETH2Base.createHttpClient(provider)
this._httpClient = ETH2Core.createHttpClient(provider)
this.provider = provider
} catch (error) {
throw new Error(`Failed to set provider: ${error.message}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETH2Base } from '../src/index'
import { ETH2Core } from '../src/index'

const provider = 'http://127.0.0.1:9596'
const testAPISchema = {
Expand All @@ -18,7 +18,7 @@ const testAPISchema = {
}

it('constructs a ETH2Core instance with expected properties', () => {
const eth2Core = new ETH2Base(provider, testAPISchema, { protectProvider: true })
const eth2Core = new ETH2Core(provider, testAPISchema, { protectProvider: true })

expect(eth2Core.name).toBe(testAPISchema.packageName)
expect(eth2Core.provider).toBe(`${provider}${testAPISchema.routePrefix}`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETH2Base } from '../src/index'
import { ETH2Core } from '../src/index'

const provider = 'http://127.0.0.1:9596'
const testAPISchema = {
Expand Down Expand Up @@ -38,7 +38,7 @@ const testAPISchema = {
let eth2Core

beforeAll(() => {
eth2Core = new ETH2Base(provider, testAPISchema, { protectProvider: true })
eth2Core = new ETH2Core(provider, testAPISchema, { protectProvider: true })
})

it('Should build expectedComputedRoute with 1 parameter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"allowSyntheticDefaultImports": false,
"baseUrl": ".",
"paths": {
"web3-eth2-base": ["."]
"web3-eth2-core": ["."]
}
}
}