Skip to content

Commit

Permalink
rough lerna build implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniuz committed Dec 7, 2018
1 parent d057f70 commit 7e2dbfa
Show file tree
Hide file tree
Showing 62 changed files with 2,167 additions and 1,402 deletions.
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages": ["packages/*"],
"npmClient": "yarn",
"npmClientArgs": ["--no-lockfile"],
"version": "0.0.0"
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"lint:ts": "$(npm bin)/tslint --fix -t stylish -c tslint.json -p tsconfig.json && $(npm bin)/prettier --parser typescript --write 'src/**/*.ts'",
"lint:rest": "$(npm bin)/prettier '**/*.{md,json}' --write",
"test": "$(npm bin)/jest",
"test:ci": "$(npm bin)/jest --maxWorkers=4",
"test:watch": "$(npm bin)/jest --watch",
"coverage": "$(npm bin)/jest --collectCoverage",
"precommit": "npm run test && $(npm bin)/lint-staged",
Expand Down Expand Up @@ -76,28 +75,29 @@
"ez-ens": "^1.0.4",
"get-port": "^4.0.0",
"graphlib": "^2.1.5",
"graphql": "^14.0.2",
"graphql-import": "^0.7.1",
"graphql-tools": "^4.0.3",
"immutable": "^4.0.0-rc.12",
"graphql": "^0.13.2",
"graphql-import": "^0.6.0",
"graphql-tools": "^3.0.2",
"immutable": "^3.8.2",
"lodash": "^4.17.10",
"patch-package": "^5.1.1",
"postinstall-postinstall": "^2.0.0",
"postinstall-postinstall": "^1.0.0",
"web3": "^1.0.0-beta.35"
},
"devDependencies": {
"@types/graphql": "^14.0.3",
"@types/graphql": "^0.13.1",
"@types/jest": "^23.1.0",
"@types/lodash": "^4.14.109",
"copyfiles": "^2.0.0",
"dotenv": "^6.0.0",
"dotenv-cli": "^1.4.0",
"husky": "^1.2.0",
"husky": "^0.14.3",
"jest": "^23.5.0",
"lint-staged": "^8.1.0",
"lerna": "^3.4.3",
"lint-staged": "^7.2.2",
"nodemon": "^1.17.5",
"npm-run-all": "^4.1.3",
"prettier": "1.15.3",
"prettier": "1.14.2",
"rimraf": "^2.6.2",
"ts-jest": "^23.1.4",
"ts-node": "^7.0.1",
Expand Down
11 changes: 11 additions & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@ethql/base",
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
"clean": "rimraf dist",
"build:ts": "npm run clean && patch-package && tsc && copyfiles -u 1 src/schema/**/*.graphql src/abi/** dist"
},
"dependencies": {
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/services.ts → packages/base/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export type EthqlServiceDefinition<Config, Service> = {
};
};

export interface EthqlServiceDefinitions {
}

export type EthqlServiceFactories = {
[P in keyof EthqlServiceDefinitions]: EthqlServiceDefinitions[P] extends EthqlServiceDefinition<
infer Config,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/base/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src/**/*"]
}
13 changes: 13 additions & 0 deletions packages/ens/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@ethql/ens",
"version": "0.0.0",
"main": "dist/index.js",
"license": "Apache-2.0",
"scripts": {
"clean": "rimraf dist",
"build:ts": "npm run clean && patch-package && tsc && copyfiles -u 1 src/schema/**/*.graphql src/abi/** dist"
},
"dependencies": {
"@ethql/base": "^0.0.0"
}
}
File renamed without changes.
4 changes: 3 additions & 1 deletion src/ens/index.ts → packages/ens/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ENS = require('ez-ens');
import { EthqlPluginFactory } from '../plugin';
import { EthqlPluginFactory } from '@ethql/base/dist/plugin';
import resolvers from './resolvers';

import {} from '@ethql/base/dist/core/services/web3';

const plugin: EthqlPluginFactory = config => ({
name: 'ens',
priority: 20,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import { EthqlContext } from '../../context';
import { EthqlBlock } from '../../core/model';
import { EthqlContext } from '@ethql/base/dist/context';
import { EthqlBlock } from '@ethql/base/dist/core/model';
import { Address, addressFn } from './scalars';

// This uses the _reduction_ approach for installing plugin resolvers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GraphQLScalarType, Kind } from 'graphql';
import Web3 = require('web3');
import { EthqlContext } from '../../context';
import { EthqlContext } from '@ethql/base/dist/context';

function isEnsDomain(input: string) {
return input.includes('.eth');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ENS = require('ez-ens');

declare module '../../services' {
declare module '@ethql/base/dist/services' {
interface EthqlServices {
ens: ENS;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/ens/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src/**/*"]
}
13 changes: 13 additions & 0 deletions packages/erc20/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@ethql/erc20",
"version": "0.0.0",
"main": "dist/index.js",
"license": "Apache-2.0",
"scripts": {
"clean": "rimraf dist",
"build:ts": "npm run clean && patch-package && tsc && copyfiles -u 1 src/schema/**/*.graphql src/abi/** dist"
},
"dependencies": {
"@ethql/base": "^0.0.0"
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EthqlContext } from '../../context';
import { EthqlAccount, EthqlTransaction } from '../../core/model';
import { createAbiDecoder, DecoderDefinition, extractParamValue } from '../../core/services/decoder';
import { EthqlContext } from '@ethql/base/dist/context';
import { EthqlAccount, EthqlTransaction } from '@ethql/base/dist/core/model';
import { createAbiDecoder, DecoderDefinition, extractParamValue } from '@ethql/base/dist/core/services/decoder';
import {
ERC20ApprovalEvent,
Erc20Approve,
Expand Down Expand Up @@ -28,7 +28,7 @@ type Erc20TxBindings = {
class Erc20TokenDecoder implements DecoderDefinition<Erc20TxBindings, Erc20LogBindings> {
public readonly entity = 'token';
public readonly standard = 'ERC20';
public readonly abiDecoder = createAbiDecoder(__dirname + '../../../abi/erc20.json');
public readonly abiDecoder = createAbiDecoder(__dirname + '/../abi/erc20.json');

public readonly txTransformers = {
transfer: (decoded: any, tx: EthqlTransaction, context: EthqlContext) => {
Expand Down
6 changes: 5 additions & 1 deletion src/erc20/index.ts → packages/erc20/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { EthqlPluginFactory } from '../plugin';
import { EthqlPluginFactory } from '@ethql/base/dist/plugin';
import { Erc20TokenDecoder } from './decoders';
import erc20Schema from './schema/erc20';
import tokenSchema from './schema/token';

import {} from '@ethql/base/dist/core/services/web3';
import {} from '@ethql/base/dist/core/services/eth-service';
import {} from '@ethql/base/dist/core/services/decoder';

const plugin: EthqlPluginFactory = config => ({
name: 'erc20',
priority: 10,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Contract from 'web3/eth/contract';
import { EthqlContext } from '../../context';
import { EthqlAccount } from '../../core/model';
import { EthqlContext } from '@ethql/base/dist/context';
import { EthqlAccount } from '@ethql/base/dist/core/model';

export interface Erc20Transaction {
tokenContract: Erc20TokenContract;
Expand Down Expand Up @@ -38,7 +38,7 @@ export type ERC20ApprovalEvent = {
};

export class Erc20TokenContract {
private static ABI = require(__dirname + '../../../abi/erc20.json');
private static ABI = require(__dirname + '/../abi/erc20.json');
private _contract: Contract;

constructor(public readonly account: EthqlAccount, readonly context: EthqlContext) {
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/erc20/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src/**/*"]
}
14 changes: 14 additions & 0 deletions packages/ethql/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "ethql",
"version": "0.0.0",
"license": "Apache-2.0",
"scripts": {
"clean": "rimraf dist",
"build:ts": "npm run clean && patch-package && tsc && copyfiles -u 1 src/schema/**/*.graphql src/abi/** dist"
},
"dependencies": {
"@ethql/base": "^0.0.0",
"@ethql/erc20": "^0.0.0",
"@ethql/ens": "^0.0.0"
}
}
17 changes: 17 additions & 0 deletions packages/ethql/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import config from '@ethql/base/dist/config';
import core from '@ethql/base/dist/core';
import ens from '@ethql/ens';
import erc20 from '@ethql/erc20';
import { EthqlServer } from '@ethql/base/dist/server';

console.log(`Effective configuration:\n${JSON.stringify(config, null, 2)}`);

const server = new EthqlServer({
config,
plugins: [core, erc20, ens],
});

process.on('SIGINT', async () => await server.stop());
process.on('SIGTERM', async () => await server.stop());

server.start();
7 changes: 7 additions & 0 deletions packages/ethql/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src/**/*"]
}
22 changes: 0 additions & 22 deletions src/index.ts

This file was deleted.

12 changes: 5 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
"esModuleInterop": true,
"module": "commonjs",
"sourceMap": true,
"rootDir": "src",
"outDir": "dist",
"baseUrl": ".",
"declaration": true,
"lib": ["esnext"],
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"paths": {
"web3": ["src/types/web3/index.d.ts"],
"*": ["node_modules/*", "src/types/*"]
"*": ["packages/base/src/types/*"]
}
},
"include": ["src/**/*"]
}
}
Loading

0 comments on commit 7e2dbfa

Please sign in to comment.