From 75a238a4259e5107d298bfa7a286b73090718570 Mon Sep 17 00:00:00 2001 From: neeboo Date: Thu, 11 Apr 2019 14:54:21 +0800 Subject: [PATCH] [chore] regroup ts files --- .../src/{ => blockchain}/net.ts | 0 .../src/{ => blockchain}/rpc.ts | 0 .../src/{ => blockchain}/rpcBuilder.ts | 2 +- packages/harmony-network/src/index.ts | 20 ++++++++++++------- .../src/{ => messenger}/messenger.ts | 8 ++++---- .../src/{ => messenger}/responseMiddleware.ts | 2 +- .../src/{ => providers}/baseProvider.ts | 4 ++-- .../src/{ => providers}/defaultFetcher.ts | 2 +- .../src/{ => providers}/http.ts | 4 ++-- packages/harmony-network/src/types.ts | 2 +- 10 files changed, 25 insertions(+), 19 deletions(-) rename packages/harmony-network/src/{ => blockchain}/net.ts (100%) rename packages/harmony-network/src/{ => blockchain}/rpc.ts (100%) rename packages/harmony-network/src/{ => blockchain}/rpcBuilder.ts (95%) rename packages/harmony-network/src/{ => messenger}/messenger.ts (94%) rename packages/harmony-network/src/{ => messenger}/responseMiddleware.ts (94%) rename packages/harmony-network/src/{ => providers}/baseProvider.ts (95%) rename packages/harmony-network/src/{ => providers}/defaultFetcher.ts (98%) rename packages/harmony-network/src/{ => providers}/http.ts (98%) diff --git a/packages/harmony-network/src/net.ts b/packages/harmony-network/src/blockchain/net.ts similarity index 100% rename from packages/harmony-network/src/net.ts rename to packages/harmony-network/src/blockchain/net.ts diff --git a/packages/harmony-network/src/rpc.ts b/packages/harmony-network/src/blockchain/rpc.ts similarity index 100% rename from packages/harmony-network/src/rpc.ts rename to packages/harmony-network/src/blockchain/rpc.ts diff --git a/packages/harmony-network/src/rpcBuilder.ts b/packages/harmony-network/src/blockchain/rpcBuilder.ts similarity index 95% rename from packages/harmony-network/src/rpcBuilder.ts rename to packages/harmony-network/src/blockchain/rpcBuilder.ts index fafbfdb..1291bc1 100644 --- a/packages/harmony-network/src/rpcBuilder.ts +++ b/packages/harmony-network/src/blockchain/rpcBuilder.ts @@ -1,4 +1,4 @@ -import { RPCRequestPayload } from './types'; +import { RPCRequestPayload } from '../types'; import { RPCMethod } from './rpc'; /** * @class JsonRpc diff --git a/packages/harmony-network/src/index.ts b/packages/harmony-network/src/index.ts index 99e8685..513b18a 100644 --- a/packages/harmony-network/src/index.ts +++ b/packages/harmony-network/src/index.ts @@ -1,9 +1,15 @@ -export * from './baseProvider'; -export * from './defaultFetcher'; -export * from './messenger'; -export * from './rpcBuilder'; +// provider related +export * from './providers/baseProvider'; +export * from './providers/defaultFetcher'; +export * from './providers/http'; +// messenger and middlewares +export * from './messenger/messenger'; +export * from './messenger/responseMiddleware'; +// rpc builder and blockchain method +export * from './blockchain/rpcBuilder'; +export * from './blockchain/net'; +export * from './blockchain/rpc'; +// utils export * from './util'; -export * from './http'; -export * from './net'; -export * from './rpc'; +// types export * from './types'; diff --git a/packages/harmony-network/src/messenger.ts b/packages/harmony-network/src/messenger/messenger.ts similarity index 94% rename from packages/harmony-network/src/messenger.ts rename to packages/harmony-network/src/messenger/messenger.ts index 9c20c25..6cd8719 100644 --- a/packages/harmony-network/src/messenger.ts +++ b/packages/harmony-network/src/messenger/messenger.ts @@ -1,8 +1,8 @@ -import { JsonRpc } from './rpcbuilder'; +import { JsonRpc } from '../blockchain/rpcbuilder'; import { ResponseMiddleware } from './responseMiddleware'; -import { HttpProvider } from './http'; -import { getResultForData } from './util'; -import { RPCMethod } from './rpc'; +import { HttpProvider } from '../providers/http'; +import { getResultForData } from '../util'; +import { RPCMethod } from '../blockchain/rpc'; const defaultConfig = { Default: { diff --git a/packages/harmony-network/src/responseMiddleware.ts b/packages/harmony-network/src/messenger/responseMiddleware.ts similarity index 94% rename from packages/harmony-network/src/responseMiddleware.ts rename to packages/harmony-network/src/messenger/responseMiddleware.ts index 208be02..714883e 100644 --- a/packages/harmony-network/src/responseMiddleware.ts +++ b/packages/harmony-network/src/messenger/responseMiddleware.ts @@ -1,4 +1,4 @@ -import { RPCResponseBody } from './types'; +import { RPCResponseBody } from '../types'; /** * @class ResponseMiddleware * @description Response middleware of RPC diff --git a/packages/harmony-network/src/baseProvider.ts b/packages/harmony-network/src/providers/baseProvider.ts similarity index 95% rename from packages/harmony-network/src/baseProvider.ts rename to packages/harmony-network/src/providers/baseProvider.ts index 7f5ba9c..ecdb859 100644 --- a/packages/harmony-network/src/baseProvider.ts +++ b/packages/harmony-network/src/providers/baseProvider.ts @@ -1,5 +1,5 @@ -import { ReqMiddleware, ResMiddleware, MiddlewareType } from './types'; -import { RPCMethod } from './rpc'; +import { ReqMiddleware, ResMiddleware, MiddlewareType } from '../types'; +import { RPCMethod } from '../blockchain/rpc'; class BaseProvider { middlewares = { diff --git a/packages/harmony-network/src/defaultFetcher.ts b/packages/harmony-network/src/providers/defaultFetcher.ts similarity index 98% rename from packages/harmony-network/src/defaultFetcher.ts rename to packages/harmony-network/src/providers/defaultFetcher.ts index 793fb38..38885cf 100644 --- a/packages/harmony-network/src/defaultFetcher.ts +++ b/packages/harmony-network/src/providers/defaultFetcher.ts @@ -1,5 +1,5 @@ import fetch from 'cross-fetch'; -import { RPCRequest, RPCResponseBody, RPCError, RPCResult } from './types'; +import { RPCRequest, RPCResponseBody, RPCError, RPCResult } from '../types'; export const fetchRPC = { requestHandler: (request: RPCRequest, headers: any) => diff --git a/packages/harmony-network/src/http.ts b/packages/harmony-network/src/providers/http.ts similarity index 98% rename from packages/harmony-network/src/http.ts rename to packages/harmony-network/src/providers/http.ts index 5a2ea37..3926adb 100644 --- a/packages/harmony-network/src/http.ts +++ b/packages/harmony-network/src/providers/http.ts @@ -5,9 +5,9 @@ import { performRPC, DEFAULT_TIMEOUT, DEFAULT_HEADERS, -} from './net'; +} from '../blockchain/net'; -import { RPCRequestPayload } from './types'; +import { RPCRequestPayload } from '../types'; const defaultOptions = { method: 'POST', diff --git a/packages/harmony-network/src/types.ts b/packages/harmony-network/src/types.ts index 15a3f35..a40dd39 100644 --- a/packages/harmony-network/src/types.ts +++ b/packages/harmony-network/src/types.ts @@ -1,4 +1,4 @@ -import { RPCMethod, RPCErrorCode } from './rpc'; +import { RPCMethod, RPCErrorCode } from './blockchain/rpc'; export type ReqMiddleware = Map; export type ResMiddleware = Map;