Skip to content

Commit

Permalink
Merge branch '1.x' into no-mutate
Browse files Browse the repository at this point in the history
  • Loading branch information
haltman-at authored Jan 4, 2021
2 parents 54f56b9 + 4469516 commit fd717ba
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 102 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ Released with 1.0.0-beta.37 code base.
- Fix parsedUrl problem of websocket provider (#3666)
- Fix return value for `clearSubscriptions` (#3689)

## [Unreleased]

## [1.3.1]

### Added
Expand All @@ -310,4 +308,12 @@ Released with 1.0.0-beta.37 code base.
- Fixed decoding bytes and string parameters for logs emitted with solc 0.4.x (#3724, #3738)
- Grammar changes to inputAddressFormatter error message
- Fixed vulnerable dependencies

## [Unreleased]

## [1.3.2]

### Changed

- Remove `notImplemented` flag from ETH2 Beacon Chain package methods schema
- Fixed mutation of inputs to encoding and decoding functions (#3748)
9 changes: 3 additions & 6 deletions packages/web3-eth2-base/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Axios, {AxiosInstance} from 'axios'

Axios.defaults.adapter = require('axios/lib/adapters/http');

import { ETH2BaseOpts, ETH2Function } from '../types/index'
import { IBaseAPISchema } from './schema'

Expand Down Expand Up @@ -63,17 +65,12 @@ export class ETH2Base {

private buildAPIWrappersFromSchema(schema: IBaseAPISchema) {
for (const method of schema.methods) {
if (method.notImplemented) {
this[method.name] = async () => { throw new Error('Method not implemented by beacon chain client') }
continue;
}

this[method.name] = async (routeParameters: any, queryParameters: any = {}): Promise<any> => {
try {
if (method.inputFormatter) queryParameters = method.inputFormatter(queryParameters)

const computedRoute = this.routeBuilder(method.route, routeParameters)
let {data} = await this._httpClient[method.restMethod](computedRoute, { queryParameters })
let {data} = await this._httpClient[method.restMethod](computedRoute, { params: queryParameters })
if (data.data) data = data.data

if (method.outputFormatter) data = method.outputFormatter(data)
Expand Down
5 changes: 5 additions & 0 deletions packages/web3-eth2-beacon/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
.PHONY: lodestar-docker lighthouse-docker

lodestar-docker:
docker run --network host chainsafe/lodestar beacon --testnet medalla --api.rest.enabled true

lighthouse-docker:
docker run -p 9000:9000 -p 127.0.0.1:5052:5052 -v ${HOME}/.lighthouse:/root/.lighthouse sigp/lighthouse lighthouse --network mainnet beacon --http --http-address 0.0.0.0
17 changes: 0 additions & 17 deletions packages/web3-eth2-beacon/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get genesis block:'
},
{
notImplemented: true,
name: 'getHashRoot',
route: 'states/${stateId}/root',
restMethod: 'get',
Expand All @@ -24,7 +23,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get state hash tree root:'
},
{
notImplemented: true,
name: 'getForkData',
route: 'states/${stateId}/fork',
restMethod: 'get',
Expand All @@ -34,7 +32,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get fork object for state:'
},
{
notImplemented: true,
name: 'getFinalityCheckpoint',
route: 'states/${stateId}/finality_checkpoints',
restMethod: 'get',
Expand All @@ -44,7 +41,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get state finality checkpoints:'
},
{
notImplemented: true,
name: 'getValidators',
route: 'states/${stateId}/validators',
restMethod: 'get',
Expand All @@ -54,7 +50,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get state validators:'
},
{
notImplemented: true,
name: 'getValidatorById',
route: 'states/${stateId}/validators/${validatorId}',
restMethod: 'get',
Expand All @@ -64,7 +59,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to validator from state by id:'
},
{
notImplemented: true,
name: 'getValidatorBalances',
route: 'states/${stateId}/validator_balances',
restMethod: 'get',
Expand All @@ -74,7 +68,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to validator balances from state:'
},
{
notImplemented: true,
name: 'getEpochCommittees',
route: 'states/${stateId}/committees/${epoch}',
restMethod: 'get',
Expand Down Expand Up @@ -102,7 +95,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get block header:'
},
{
notImplemented: true,
name: 'publishSignedBlock',
route: 'blocks',
restMethod: 'post',
Expand Down Expand Up @@ -130,7 +122,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get block root:'
},
{
notImplemented: true,
name: 'getBlockAttestations',
route: 'blocks/${blockId}/attestations',
restMethod: 'get',
Expand All @@ -140,7 +131,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to block attestations:'
},
{
notImplemented: true,
name: 'getAttestationsFromPool',
route: 'pool/attestations',
restMethod: 'get',
Expand All @@ -150,7 +140,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to attestations from operations pool:'
},
{
notImplemented: true,
name: 'submitAttestation',
route: 'pool/attestations',
restMethod: 'post',
Expand All @@ -160,7 +149,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to submit attestations to operations pool:'
},
{
notImplemented: true,
name: 'getAttesterSlashings',
route: 'pool/attester_slashings',
restMethod: 'get',
Expand All @@ -170,7 +158,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get attester slashings from operations pool:'
},
{
notImplemented: true,
name: 'submitAttesterSlashings',
route: 'pool/attester_slashings',
restMethod: 'post',
Expand All @@ -180,7 +167,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to submit attester slashings to operations pool:'
},
{
notImplemented: true,
name: 'getProposerSlashings',
route: 'pool/proposer_slashings',
restMethod: 'get',
Expand All @@ -190,7 +176,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get proposer slashings from operations pool:'
},
{
notImplemented: true,
name: 'submitProposerSlashings',
route: 'pool/proposer_slashings',
restMethod: 'post',
Expand All @@ -200,7 +185,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to submit proposer slashings to operations pool:'
},
{
notImplemented: true,
name: 'getSignedVoluntaryExits',
route: 'pool/voluntary_exits',
restMethod: 'get',
Expand All @@ -210,7 +194,6 @@ export const DefaultSchema: IBaseAPISchema = {
errorPrefix: 'Failed to get signed voluntary exits from operations pool'
},
{
notImplemented: true,
name: 'submitVoluntaryExit',
route: 'pool/voluntary_exits',
restMethod: 'post',
Expand Down
Loading

0 comments on commit fd717ba

Please sign in to comment.