From 7f3473ce065d6ca303425407eafb409571d9fe2d Mon Sep 17 00:00:00 2001 From: neeboo Date: Tue, 23 Apr 2019 19:20:02 +0800 Subject: [PATCH] [breaking] move blockchain class to core --- examples/testNode.js | 32 +- packages/harmony-account/tsconfig.test.json | 5 + packages/harmony-core/src/blockchain.ts | 320 ++++++++++++++++++ packages/harmony-core/src/harmony.ts | 3 +- packages/harmony-core/src/types.ts | 3 +- packages/harmony-core/tsconfig.test.json | 5 + packages/harmony-crypto/tsconfig.test.json | 5 + .../src/blockchain/blockchain.ts | 83 ----- packages/harmony-network/src/index.ts | 8 +- .../src/messenger/messenger.ts | 4 +- .../src/providers/baseProvider.ts | 2 +- .../harmony-network/src/providers/http.ts | 2 +- .../src/rpcMethod/blockchain.ts | 320 ++++++++++++++++++ .../src/{blockchain => rpcMethod}/net.ts | 0 .../src/{blockchain => rpcMethod}/rpc.ts | 0 .../{blockchain => rpcMethod}/rpcBuilder.ts | 0 packages/harmony-network/src/types.ts | 2 +- packages/harmony-network/tsconfig.test.json | 5 + .../harmony-transaction/tsconfig.test.json | 5 + scripts/typings/schema.ts | 8 +- tsconfig.test.json | 9 +- 21 files changed, 694 insertions(+), 127 deletions(-) create mode 100644 packages/harmony-account/tsconfig.test.json create mode 100644 packages/harmony-core/src/blockchain.ts create mode 100644 packages/harmony-core/tsconfig.test.json create mode 100644 packages/harmony-crypto/tsconfig.test.json delete mode 100644 packages/harmony-network/src/blockchain/blockchain.ts create mode 100644 packages/harmony-network/src/rpcMethod/blockchain.ts rename packages/harmony-network/src/{blockchain => rpcMethod}/net.ts (100%) rename packages/harmony-network/src/{blockchain => rpcMethod}/rpc.ts (100%) rename packages/harmony-network/src/{blockchain => rpcMethod}/rpcBuilder.ts (100%) create mode 100644 packages/harmony-network/tsconfig.test.json create mode 100644 packages/harmony-transaction/tsconfig.test.json diff --git a/examples/testNode.js b/examples/testNode.js index 6599fa0..b23bb6f 100644 --- a/examples/testNode.js +++ b/examples/testNode.js @@ -20,9 +20,9 @@ server.listen(port, function(err, blockchain) { // // console.log(acc.address); - acc.getBalance().then((c) => { - console.log(c); - }); + // acc.getBalance().then((c) => { + // console.log(c); + // }); const txn = harmony.transactions.newTx({ nonce: 1, to: sendTo, @@ -35,31 +35,7 @@ server.listen(port, function(err, blockchain) { acc.signTransaction(txn, true).then((signed) => { // console.log(signed.txPayload); - harmony.messenger - .send('hmy_sendTransaction', [signed.txPayload]) - .then((res) => { - console.log(res); - txn.confirm(res).then((result) => { - harmony.blockchain - .getBlockByHash({ - hash: result.receipt.blockHash, - returnObject: false, - }) - .then((obj) => { - console.log(obj); - }); - }); - // harmony.blockchain.getBlockByHash({ hash: res }).then((obj) => { - // console.log(obj); - // }); - }); - // signed.sendTransaction().then((msg) => { - // const [txn, result] = msg; - // txn.confirm(result).then((result) => { - // console.log(`--------------`); - // console.log(result); - // }); - // }); + harmony. }); // console.log(harmony.messenger.setRPCPrefix('eth_getPPP')); diff --git a/packages/harmony-account/tsconfig.test.json b/packages/harmony-account/tsconfig.test.json new file mode 100644 index 0000000..8daf0f0 --- /dev/null +++ b/packages/harmony-account/tsconfig.test.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.test.json", + "include": ["src", "test", "../../typings/**/*.d.ts"], + "references": [] +} diff --git a/packages/harmony-core/src/blockchain.ts b/packages/harmony-core/src/blockchain.ts new file mode 100644 index 0000000..6b43e95 --- /dev/null +++ b/packages/harmony-core/src/blockchain.ts @@ -0,0 +1,320 @@ +import { RPCMethod, Messenger } from '@harmony/network'; + +import { + assertObject, + AssertType, + HarmonyCore, + ChainType, +} from '@harmony/utils'; + +import { Transaction } from '@harmony/transaction'; + +class Blockchain extends HarmonyCore { + messenger: Messenger; + chainType: ChainType; + + constructor(messenger: Messenger, chainType: ChainType = ChainType.Harmony) { + super(chainType); + this.messenger = messenger; + this.chainType = chainType; + } + setMessenger(messenger: Messenger) { + this.messenger = messenger; + } + + /** + * + */ + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getBalance({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetBalance, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockHash: ['isHash', AssertType.required], + returnObject: ['isBoolean', AssertType.optional], + }) + async getBlockByHash({ + blockHash, + returnObject = true, + }: { + blockHash: string; + returnObject: boolean; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockByHash, + [blockHash, returnObject], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + returnObject: ['isBoolean', AssertType.optional], + }) + async getBlockByNumber({ + blockNumber, + tag = 'latest', + returnObject = true, + }: { + blockNumber: string; + tag: string; + returnObject: boolean; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockByNumber, + [blockNumber || tag, returnObject], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + blockHash: ['isHash', AssertType.required], + }) + async getBlockTransactionCountByHash({ blockHash }: { blockHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetBlockTransactionCountByHash, + [blockHash], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockNumber: ['isHex', AssertType.required], + tag: ['isString', AssertType.optional], + }) + async getBlockTransactionCountByNumber({ + blockNumber, + tag = 'latest', + }: { + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockTransactionCountByNumber, + [blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockHash: ['isHash', AssertType.required], + index: ['isHex', AssertType.required], + }) + async getTransactionByBlockHashAndIndex({ + blockHash, + index, + }: { + blockHash: string; + index: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByBlockHashAndIndex, + [blockHash, index], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + blockNumber: ['isHex', AssertType.required], + index: ['isHex', AssertType.required], + tag: ['isString', AssertType.optional], + }) + async getTransactionByBlockNumberAndIndex({ + blockNumber, + index, + tag = 'latest', + }: { + blockNumber: string; + index: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByBlockNumberAndIndex, + [blockNumber || tag, index], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + txnHash: ['isHash', AssertType.required], + }) + async getTransactionByHash({ txnHash }: { txnHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByHash, + [txnHash], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + txnHash: ['isString', AssertType.required], + }) + async getTransactionReceipt({ txnHash }: { txnHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionReceipt, + [txnHash], + this.chainPrefix, + ); + return result; + } + /** + * + */ + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getCode({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetCode, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + async syncing() { + const result = await this.messenger.send( + RPCMethod.Syncing, + [], + this.chainPrefix, + ); + if (result.responseType === 'raw') { + return result.result; + } + return result; + } + + async net_peerCount() { + const result = await this.messenger.send( + RPCMethod.PeerCount, + [], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + address: ['isAddress', AssertType.required], + position: ['isHex', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getStorageAt({ + address, + position, + blockNumber, + tag = 'latest', + }: { + address: string; + position: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetStorageAt, + [address, position, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getTransactionCount({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionCount, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + async sendTransaction(transaction: Transaction) { + if (!transaction.isSigned || !transaction) { + throw new Error('transaction is not signed or not exist'); + } + const result = await this.messenger.send( + RPCMethod.SendTransaction, + [transaction.txPayload], + this.chainPrefix, + ); + return result; + } + + // async sendRawTransaction(transaction: Transaction) { + // if (!transaction.isSigned || !transaction) { + // throw new Error('transaction is not signed or not exist'); + // } + // const [txn, result] = await transaction.sendTransaction(); + // if (txn.isPending) { + // return result; + // } + // } +} + +export { Blockchain }; diff --git a/packages/harmony-core/src/harmony.ts b/packages/harmony-core/src/harmony.ts index ba1d697..cc18c55 100644 --- a/packages/harmony-core/src/harmony.ts +++ b/packages/harmony-core/src/harmony.ts @@ -1,9 +1,10 @@ import * as crypto from '@harmony/crypto'; import * as utils from '@harmony/utils'; -import { HttpProvider, Messenger, Blockchain } from '@harmony/network'; +import { HttpProvider, Messenger } from '@harmony/network'; import { TransactionFactory, Transaction } from '@harmony/transaction'; import { Wallet, Account } from '@harmony/account'; +import { Blockchain } from './blockchain'; class Harmony extends utils.HarmonyCore { Modules = { diff --git a/packages/harmony-core/src/types.ts b/packages/harmony-core/src/types.ts index 6bcc2a0..bcc314d 100644 --- a/packages/harmony-core/src/types.ts +++ b/packages/harmony-core/src/types.ts @@ -1,6 +1,7 @@ -import { HttpProvider, Messenger, Blockchain } from '@harmony/network'; +import { HttpProvider, Messenger } from '@harmony/network'; import { TransactionFactory, Transaction } from '@harmony/transaction'; import { Wallet, Account } from '@harmony/account'; +import { Blockchain } from './blockchain'; export interface HarmonyModule { HttpProvider: HttpProvider; diff --git a/packages/harmony-core/tsconfig.test.json b/packages/harmony-core/tsconfig.test.json new file mode 100644 index 0000000..8daf0f0 --- /dev/null +++ b/packages/harmony-core/tsconfig.test.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.test.json", + "include": ["src", "test", "../../typings/**/*.d.ts"], + "references": [] +} diff --git a/packages/harmony-crypto/tsconfig.test.json b/packages/harmony-crypto/tsconfig.test.json new file mode 100644 index 0000000..8daf0f0 --- /dev/null +++ b/packages/harmony-crypto/tsconfig.test.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.test.json", + "include": ["src", "test", "../../typings/**/*.d.ts"], + "references": [] +} diff --git a/packages/harmony-network/src/blockchain/blockchain.ts b/packages/harmony-network/src/blockchain/blockchain.ts deleted file mode 100644 index 76b8355..0000000 --- a/packages/harmony-network/src/blockchain/blockchain.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { RPCMethod } from './rpc'; -import { Messenger } from '../messenger/messenger'; -import { - assertObject, - AssertType, - HarmonyCore, - ChainType, -} from '@harmony/utils'; - -class Blockchain extends HarmonyCore { - messenger: Messenger; - chainType: ChainType; - - constructor(messenger: Messenger, chainType: ChainType = ChainType.Harmony) { - super(chainType); - this.messenger = messenger; - this.chainType = chainType; - } - setMessenger(messenger: Messenger) { - this.messenger = messenger; - } - - /** - * - */ - @assertObject({ - address: ['isAddress', AssertType.required], - blockNumber: ['isHex', AssertType.optional], - tag: ['isString', AssertType.optional], - }) - async getBalance({ - address, - blockNumber, - tag = 'latest', - }: { - address: string; - blockNumber: string; - tag: string; - }) { - const result = await this.messenger.send( - RPCMethod.GetBalance, - [address, blockNumber || tag], - this.chainPrefix, - ); - return result; - } - - @assertObject({ - hash: ['isHash', AssertType.required], - returnObject: ['isBoolean', AssertType.optional], - }) - async getBlockByHash({ - hash, - returnObject = true, - }: { - hash: string; - returnObject: boolean; - }) { - const result = await this.messenger.send( - RPCMethod.GetBlockByHash, - [hash, returnObject], - this.chainPrefix, - ); - return result; - } - - /** - * - */ - @assertObject({ - hash: ['isString', AssertType.required], - }) - async getTransactionReceipt({ hash }: { hash: string }) { - const result = await this.messenger.send( - RPCMethod.GetTransactionReceipt, - [hash], - this.chainPrefix, - ); - return result; - } -} - -export { Blockchain }; diff --git a/packages/harmony-network/src/index.ts b/packages/harmony-network/src/index.ts index fca89ff..c640b46 100644 --- a/packages/harmony-network/src/index.ts +++ b/packages/harmony-network/src/index.ts @@ -6,10 +6,10 @@ export * from './providers/http'; 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'; -export * from './blockchain/blockchain'; +export * from './rpcMethod/rpcBuilder'; +export * from './rpcMethod/net'; +export * from './rpcMethod/rpc'; + // utils export * from './util'; // types diff --git a/packages/harmony-network/src/messenger/messenger.ts b/packages/harmony-network/src/messenger/messenger.ts index 6e0f83e..30c09d3 100644 --- a/packages/harmony-network/src/messenger/messenger.ts +++ b/packages/harmony-network/src/messenger/messenger.ts @@ -1,9 +1,9 @@ import { HarmonyCore, ChainType, isString } from '@harmony/utils'; -import { JsonRpc } from '../blockchain/rpcbuilder'; +import { JsonRpc } from '../rpcMethod/rpcbuilder'; import { ResponseMiddleware } from './responseMiddleware'; import { HttpProvider } from '../providers/http'; import { getResultForData } from '../util'; -import { RPCMethod } from '../blockchain/rpc'; +import { RPCMethod } from '../rpcMethod/rpc'; const defaultConfig = { Default: { diff --git a/packages/harmony-network/src/providers/baseProvider.ts b/packages/harmony-network/src/providers/baseProvider.ts index ba40afd..faf71e1 100644 --- a/packages/harmony-network/src/providers/baseProvider.ts +++ b/packages/harmony-network/src/providers/baseProvider.ts @@ -1,5 +1,5 @@ import { ReqMiddleware, ResMiddleware, MiddlewareType } from '../types'; -import { RPCMethod } from '../blockchain/rpc'; +import { RPCMethod } from '../rpcMethod/rpc'; class BaseProvider { middlewares = { diff --git a/packages/harmony-network/src/providers/http.ts b/packages/harmony-network/src/providers/http.ts index 5f56087..15dd7d5 100644 --- a/packages/harmony-network/src/providers/http.ts +++ b/packages/harmony-network/src/providers/http.ts @@ -5,7 +5,7 @@ import { performRPC, DEFAULT_TIMEOUT, DEFAULT_HEADERS, -} from '../blockchain/net'; +} from '../rpcMethod/net'; import { RPCRequestPayload } from '../types'; diff --git a/packages/harmony-network/src/rpcMethod/blockchain.ts b/packages/harmony-network/src/rpcMethod/blockchain.ts new file mode 100644 index 0000000..b178120 --- /dev/null +++ b/packages/harmony-network/src/rpcMethod/blockchain.ts @@ -0,0 +1,320 @@ +import { RPCMethod } from './rpc'; +import { Messenger } from '../messenger/messenger'; +import { + assertObject, + AssertType, + HarmonyCore, + ChainType, +} from '@harmony/utils'; + +// import {Transaction} from '@harmony/transaction' + +class Blockchain extends HarmonyCore { + messenger: Messenger; + chainType: ChainType; + + constructor(messenger: Messenger, chainType: ChainType = ChainType.Harmony) { + super(chainType); + this.messenger = messenger; + this.chainType = chainType; + } + setMessenger(messenger: Messenger) { + this.messenger = messenger; + } + + /** + * + */ + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getBalance({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetBalance, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockHash: ['isHash', AssertType.required], + returnObject: ['isBoolean', AssertType.optional], + }) + async getBlockByHash({ + blockHash, + returnObject = true, + }: { + blockHash: string; + returnObject: boolean; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockByHash, + [blockHash, returnObject], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + returnObject: ['isBoolean', AssertType.optional], + }) + async getBlockByNumber({ + blockNumber, + tag = 'latest', + returnObject = true, + }: { + blockNumber: string; + tag: string; + returnObject: boolean; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockByNumber, + [blockNumber || tag, returnObject], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + blockHash: ['isHash', AssertType.required], + }) + async getBlockTransactionCountByHash({ blockHash }: { blockHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetBlockTransactionCountByHash, + [blockHash], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockNumber: ['isHex', AssertType.required], + tag: ['isString', AssertType.optional], + }) + async getBlockTransactionCountByNumber({ + blockNumber, + tag = 'latest', + }: { + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetBlockTransactionCountByNumber, + [blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + blockHash: ['isHash', AssertType.required], + index: ['isHex', AssertType.required], + }) + async getTransactionByBlockHashAndIndex({ + blockHash, + index, + }: { + blockHash: string; + index: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByBlockHashAndIndex, + [blockHash, index], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + blockNumber: ['isHex', AssertType.required], + index: ['isHex', AssertType.required], + tag: ['isString', AssertType.optional], + }) + async getTransactionByBlockNumberAndIndex({ + blockNumber, + index, + tag = 'latest', + }: { + blockNumber: string; + index: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByBlockNumberAndIndex, + [blockNumber || tag, index], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + txnHash: ['isHash', AssertType.required], + }) + async getTransactionByHash({ txnHash }: { txnHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionByHash, + [txnHash], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + @assertObject({ + txnHash: ['isString', AssertType.required], + }) + async getTransactionReceipt({ txnHash }: { txnHash: string }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionReceipt, + [txnHash], + this.chainPrefix, + ); + return result; + } + /** + * + */ + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getCode({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetCode, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + /** + * + */ + async syncing() { + const result = await this.messenger.send( + RPCMethod.Syncing, + [], + this.chainPrefix, + ); + if (result.responseType === 'raw') { + return result.result; + } + return result; + } + + async net_peerCount() { + const result = await this.messenger.send( + RPCMethod.PeerCount, + [], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + address: ['isAddress', AssertType.required], + position: ['isHex', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getStorageAt({ + address, + position, + blockNumber, + tag = 'latest', + }: { + address: string; + position: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetStorageAt, + [address, position, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + @assertObject({ + address: ['isAddress', AssertType.required], + blockNumber: ['isHex', AssertType.optional], + tag: ['isString', AssertType.optional], + }) + async getTransactionCount({ + address, + blockNumber, + tag = 'latest', + }: { + address: string; + blockNumber: string; + tag: string; + }) { + const result = await this.messenger.send( + RPCMethod.GetTransactionCount, + [address, blockNumber || tag], + this.chainPrefix, + ); + return result; + } + + // async sendTransaction(transaction: Transaction) { + // if (!transaction.isSigned || !transaction) { + // throw new Error('transaction is not signed or not exist'); + // } + // const result = await this.messenger.send( + // RPCMethod.SendTransaction, + // [transaction.txPayload], + // this.chainPrefix, + // ); + // return result; + // } + + // async sendRawTransaction(transaction: Transaction) { + // if (!transaction.isSigned || !transaction) { + // throw new Error('transaction is not signed or not exist'); + // } + // const [txn, result] = await transaction.sendTransaction(); + // if (txn.isPending) { + // return result; + // } + // } +} + +export { Blockchain }; diff --git a/packages/harmony-network/src/blockchain/net.ts b/packages/harmony-network/src/rpcMethod/net.ts similarity index 100% rename from packages/harmony-network/src/blockchain/net.ts rename to packages/harmony-network/src/rpcMethod/net.ts diff --git a/packages/harmony-network/src/blockchain/rpc.ts b/packages/harmony-network/src/rpcMethod/rpc.ts similarity index 100% rename from packages/harmony-network/src/blockchain/rpc.ts rename to packages/harmony-network/src/rpcMethod/rpc.ts diff --git a/packages/harmony-network/src/blockchain/rpcBuilder.ts b/packages/harmony-network/src/rpcMethod/rpcBuilder.ts similarity index 100% rename from packages/harmony-network/src/blockchain/rpcBuilder.ts rename to packages/harmony-network/src/rpcMethod/rpcBuilder.ts diff --git a/packages/harmony-network/src/types.ts b/packages/harmony-network/src/types.ts index d88c983..24cfb22 100644 --- a/packages/harmony-network/src/types.ts +++ b/packages/harmony-network/src/types.ts @@ -1,4 +1,4 @@ -import { RPCMethod, RPCErrorCode } from './blockchain/rpc'; +import { RPCMethod, RPCErrorCode } from './rpcMethod/rpc'; export type ReqMiddleware = Map; export type ResMiddleware = Map; diff --git a/packages/harmony-network/tsconfig.test.json b/packages/harmony-network/tsconfig.test.json new file mode 100644 index 0000000..8daf0f0 --- /dev/null +++ b/packages/harmony-network/tsconfig.test.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.test.json", + "include": ["src", "test", "../../typings/**/*.d.ts"], + "references": [] +} diff --git a/packages/harmony-transaction/tsconfig.test.json b/packages/harmony-transaction/tsconfig.test.json new file mode 100644 index 0000000..8daf0f0 --- /dev/null +++ b/packages/harmony-transaction/tsconfig.test.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.test.json", + "include": ["src", "test", "../../typings/**/*.d.ts"], + "references": [] +} diff --git a/scripts/typings/schema.ts b/scripts/typings/schema.ts index 87b4e50..428dd92 100644 --- a/scripts/typings/schema.ts +++ b/scripts/typings/schema.ts @@ -39,10 +39,10 @@ async function generateSchemas() { const schema = schemas.generateSchema(prog, '*', settings); - fs.writeFileSync( - path.join(pkgPath, 'test', 'schema.json'), - JSON.stringify(schema, undefined, 2), - ); + // fs.writeFileSync( + // path.join(pkgPath, 'test', 'schema.json'), + // JSON.stringify(schema, undefined, 2), + // ); }); } diff --git a/tsconfig.test.json b/tsconfig.test.json index 5656591..649a8be 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -2,5 +2,12 @@ "extends": "./tsconfig.base.json", "files": [], "include": ["./typings/**/*.d.ts"], - "references": [{ "path": "packages/harmony-utils" }] + "references": [ + { "path": "packages/harmony-core" }, + { "path": "packages/harmony-account" }, + { "path": "packages/harmony-crypto" }, + { "path": "packages/harmony-utils" }, + { "path": "packages/harmony-network" }, + { "path": "packages/harmony-transaction" } + ] }