Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Merge c564ebd into e2ec3f1
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLefrere committed Sep 13, 2019
2 parents e2ec3f1 + c564ebd commit c3665b4
Show file tree
Hide file tree
Showing 55 changed files with 887 additions and 263 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules/**
**/lib/**
**/example/**
packages/light.js/example-react
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
extends: [
'semistandard',
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/camelcase': ['error', { allow: ['keccak_256'] }],
'@typescript-eslint/no-unused-vars': [1, { argsIgnorePattern: '^_' }],

// TODO: Remove all of these disabled rules.
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['*.spec.{ts,tsx}', 'testHelpers.ts'],
env: {
jest: true,
},
plugins: ['jest'],
},
],
};
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
printWidth: 80,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ node_js:
- '10'
script:
- yarn lint
- yarn typecheck
- yarn test:api
- yarn test --silent --coverage --coverageReporters=text-lcov | coveralls ; test ${PIPESTATUS[0]} -eq 0
before_deploy:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ yarn outdated
git checkout -b <INSERT_YOUR_BRANCH_NAME>
```

5. Run tests, linting, and build
5. Run tests, type checking, linting, and build

```bash
yarn test; yarn lint; yarn build
yarn test; yarn typecheck; yarn lint; yarn build
```

6. Push the branch to your fork of the repo
Expand Down
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,32 @@
},
"scripts": {
"build": "lerna exec yarn build --stream",
"lint": "tslint 'packages/**/*.ts'",
"typecheck": "lerna exec yarn typecheck --stream",
"lint": "scripts/lint.sh",
"postinstall": "yarn build",
"test": "jest",
"test:api": "cd packages/api && yarn test",
"update-docs": "scripts/update-docs.sh"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"eslint": "^6.3.0",
"eslint-config-semistandard": "^15.0.0",
"eslint-config-standard": "^14.0.0",
"eslint-import-resolver-typescript": "^1.1.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-json": "^1.4.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"jest": "^24.8.0",
"lerna": "^3.4.3",
"prettier": "^1.18.2",
"rimraf": "^2.6.2",
"ts-jest": "^24.0.0",
"tslint": "^5.10.0",
"tslint-config-semistandard": "^7.0.0",
"typedoc": "^0.14.2",
"typedoc-plugin-markdown": "^1.1.13",
"typescript": "^3.1.6"
Expand Down
1 change: 1 addition & 0 deletions packages/abi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"scripts": {
"docs": "typedoc",
"prebuild": "rimraf lib",
"typecheck": "tsc --noEmit",
"build": "tsc",
"test": "jest"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/abi/src/decoder/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Decoder {
static decodeParam (
param: ParamType,
slices: Slices,
offset: number = 0
offset = 0
): DecodeResult {
if (!isInstanceOf(param, ParamType)) {
throw new Error('param should be instanceof ParamType');
Expand Down
4 changes: 1 addition & 3 deletions packages/abi/src/encoder/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class Encoder {
}
} catch (e) {
throw new Error(
`Cannot encode token #${index} [${token.type}: ${token.value}]. ${
e.message
}`
`Cannot encode token #${index} [${token.type}: ${token.value}]. ${e.message}`
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/abi/src/encoder/mediate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Mediate {
.join('');

case 'array':
/* eslint-disable no-case-declarations */
const prefix = padU32((this._value as Mediate[]).length);
const inits = (this._value as Mediate[])
.map((mediate: Mediate, index: number) =>
Expand All @@ -146,6 +147,7 @@ class Mediate {
.toString(16)
)
.join('');
/* eslint-enable no-case-declarations */

return `${prefix}${inits}${closings}`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/abi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type ArrayValue = FixedArrayValue[];

export type TokenValue =
| AddressValue
| Boolean
| boolean
| BytesValue
| StringValue
| IntValue
Expand Down
1 change: 1 addition & 0 deletions packages/abi/src/util/pad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const stringToBytes = (input: BytesValue) => {
export const padBytes = (input: BytesValue) => {
const inputBytes = stringToBytes(input);

// eslint-disable-next-line @typescript-eslint/no-use-before-define
return `${padU32(inputBytes.length)}${padFixedBytes(inputBytes)}`;
};

Expand Down
1 change: 1 addition & 0 deletions packages/abi/src/util/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const eventSignature = (
eventName: string | undefined,
params: ParamType[] = []
) => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const { strName, name } = parseName(eventName);
const types = (params || []).map(fromParamType).join(',');
const id = `${strName}(${types})`;
Expand Down
1 change: 1 addition & 0 deletions packages/abi/src/util/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('util/types', () => {

describe('isInstanceOf', () => {
it('correctly identifies build-in instanceof', () => {
// eslint-disable-next-line no-new-wrappers
expect(isInstanceOf(new String('123'), String)).toBe(true);
});

Expand Down
1 change: 1 addition & 0 deletions packages/abi/src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function isFunction (input?: any): input is Function {
}

export function isHex (input?: any): boolean {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
if (!isString(input)) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"scripts": {
"prebuild": "rimraf lib",
"typecheck": "tsc --noEmit",
"build": "tsc",
"test": "cross-env NODE_ENV=test mocha -r ts-node/register 'src/*.spec.js' 'src/**/*.spec.js'"
},
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/format/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//
// SPDX-License-Identifier: MIT

/* eslint-disable @typescript-eslint/no-use-before-define */

import BigNumber from 'bignumber.js';

import {
Expand Down Expand Up @@ -90,7 +92,7 @@ export const inTopics = (topics?: (Topic | Topic[])[]): (string | null)[] => {

export const inFilter = (options: FilterOptions) => {
const result: {
[key in keyof FilterOptions]: number | string | string[] | Topic[]
[key in keyof FilterOptions]: number | string | string[] | Topic[];
} = {};

if (options) {
Expand Down Expand Up @@ -232,7 +234,7 @@ export const inTraceFilter = (filterObject: FilterObject) => {

default:
// @ts-ignore Here, we explicitly pass down extra keys, if they exist
result[key] = options[key];
result[key] = filterObject[key];
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/format/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//
// SPDX-License-Identifier: MIT

/* eslint-disable @typescript-eslint/no-use-before-define */

import BigNumber from 'bignumber.js';
import { isString } from '@parity/abi/lib/util/types';
import { toChecksumAddress } from '@parity/abi/lib/util/address';
Expand Down Expand Up @@ -343,10 +345,12 @@ export function outSignerRequest (request: SerializedSignerRequest) {
break;

case 'origin':
/* eslint-disable no-case-declarations */
// @ts-ignore "Object is possibly 'undefined'." No it's not.
const type = Object.keys(result[key])[0];
// @ts-ignore "Object is possibly 'undefined'." No it's not.
const details = result[key][type];
/* eslint-enable no-case-declarations */

request[key] = { type, details };
break;
Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/util/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const abiUnencode = (abi: AbiObject, data: string) => {
return (
field.type === 'function' &&
!!field.inputs &&
// eslint-disable-next-line @typescript-eslint/no-use-before-define
abiSignature(field.name, field.inputs.map(input => input.type)).substr(
2,
8
Expand All @@ -93,9 +94,7 @@ export const abiUnencode = (abi: AbiObject, data: string) => {
(result, field, index) => {
if (!field.name) {
throw new Error(
`abiUnencode: input at index ${index} with type ${
field.type
} doesn't have a name.`
`abiUnencode: input at index ${index} with type ${field.type} doesn't have a name.`
);
}
result[field.name] = argsByIndex[index];
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/util/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const cleanupValue = (value: string | number | Bytes, type: string) => {
* @param hex - The hex string to convert.
*/
export const hexToBytes = (hex: string) => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const raw = toHex(hex).slice(2);
const bytes = [];

Expand Down Expand Up @@ -114,6 +115,7 @@ export const asciiToHex = (baseString: string) => {
*/
export const padRight = (input: string, length: number) => {
const hexLength = length * 2;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const value = toHex(input).substr(2, hexLength);

return (
Expand All @@ -133,6 +135,7 @@ export const padRight = (input: string, length: number) => {
*/
export const padLeft = (input: string | undefined, length: number) => {
const hexLength = length * 2;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const value = toHex(input).substr(2, hexLength);

return (
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/util/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
isObject,
isString
} from './types';
const Eth = require('../rpc/eth');
import * as Eth from '../rpc/eth';

describe('util/types', () => {
describe('isArray', () => {
Expand Down Expand Up @@ -71,6 +71,7 @@ describe('util/types', () => {

describe('isInstanceOf', () => {
it('correctly identifies build-in instanceof', () => {
// eslint-disable-next-line no-new-wrappers
expect(isInstanceOf(new String('123'), String)).toBe(true);
});

Expand Down
1 change: 1 addition & 0 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"scripts": {
"docs": "typedoc && rimraf docs/README.md",
"prebuild": "rimraf lib",
"typecheck": "tsc --noEmit",
"build": "tsc",
"test": "jest"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/badgereg.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// Copyright 2015-2019 Parity Technologies(UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -28,6 +28,7 @@ export default class BadgeReg {
public contracts: {
[key: string]: Contract;
} = {};

private _registry: Registry;

constructor (api: Api, registry: Registry) {
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as abis from './abi';
import { Api, Contract, ContractInstance } from './types';

interface QueueItem {
resolve (...args: any[]): void;
resolve(...args: any[]): void;
}

const REGISTRY_V1_HASHES = [
Expand All @@ -20,11 +20,13 @@ export default class Registry {
private _contracts: {
[key: string]: Contract;
} = {};

private _fetching = false;
private _instance: ContractInstance = null;
private _pendingContracts: {
[key: string]: Promise<Contract>;
} = {};

private _queue: QueueItem[] = [];
private _registryContract: Contract | null = null;

Expand Down
1 change: 1 addition & 0 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"scripts": {
"docs": "typedoc",
"prebuild": "rimraf lib",
"typecheck": "tsc --noEmit",
"build": "tsc",
"test": "jest"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/getParityPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export async function getParityPath () {
);
return path;
} catch (err) {
logger()('@parity/electron:main')(`Parity not found on machine.`);
logger()('@parity/electron:main')('Parity not found on machine.');
throw err;
}
}
2 changes: 1 addition & 1 deletion packages/electron/src/isParityRunning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function isParityRunning (
wsPort: '8546'
}
) {
return new Promise((resolve, reject) => {
return new Promise(resolve => {
const { wsInterface, wsPort } = {
wsInterface: '127.0.0.1',
wsPort: '8546',
Expand Down
4 changes: 2 additions & 2 deletions packages/electron/src/runParity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function runParity (
},
...options
};
const parityPath = options.parityPath || await getParityPath();
const parityPath = options.parityPath || (await getParityPath());

// Some users somehow had no +x on the parity binary after downloading
// it. We try to set it here (no guarantee it will work, we might not
Expand All @@ -68,7 +68,7 @@ export async function runParity (
/* Do nothing if error. */
}

return new Promise((resolve, reject) => {
return new Promise(resolve => {
let logLastLine = ''; // Always contains last line of the Parity logs

// Run an instance of parity with the correct flags
Expand Down

0 comments on commit c3665b4

Please sign in to comment.