From 246d7fbac6ea495d38b35265871f2cda4757c573 Mon Sep 17 00:00:00 2001 From: Yi DENG Date: Wed, 20 Mar 2019 17:30:25 +0800 Subject: [PATCH] make import functions of fabricClient uniformly Signed-off-by: Yi DENG --- src/app.jsx | 2 +- src/components/UserLayout.jsx | 2 +- src/components/content/ChaincodeInstallContent.jsx | 2 +- src/components/content/ChaincodeInvokeContent.jsx | 2 +- src/components/content/ChannelManangeContent.jsx | 2 +- src/components/content/DataContent.jsx | 2 +- src/util/fabric.js | 5 +---- src/util/queryBlock.js | 2 +- test/util/fabric.test.js | 2 +- 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/app.jsx b/src/app.jsx index 1a3fc0e..c33ea98 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -8,7 +8,7 @@ import LoadingLayout from './components/LoadingLayout'; import { getConfigDBSingleton } from './util/createDB'; // import generateYaml from './util/generateYaml'; -// import getFabricClientSingleton from './util/fabric'; +// import { getFabricClientSingleton } from './util/fabric'; const logger = require('electron-log'); diff --git a/src/components/UserLayout.jsx b/src/components/UserLayout.jsx index 5ebbd2f..6c94ac1 100644 --- a/src/components/UserLayout.jsx +++ b/src/components/UserLayout.jsx @@ -3,7 +3,7 @@ // TODO: 登录页(秘钥导入页面) import React from 'react'; import { Button, Input, Layout, Icon, message } from 'antd'; -import getFabricClientSingleton from '../util/fabric'; +import { getFabricClientSingleton } from '../util/fabric'; import { getConfigDBSingleton } from '../util/createDB'; diff --git a/src/components/content/ChaincodeInstallContent.jsx b/src/components/content/ChaincodeInstallContent.jsx index 958cd1d..bf89893 100644 --- a/src/components/content/ChaincodeInstallContent.jsx +++ b/src/components/content/ChaincodeInstallContent.jsx @@ -3,7 +3,7 @@ import React from 'react'; import { Button, Form, Input, Modal, Menu, Dropdown, Icon, Select, Tag, message } from 'antd'; -import getFabricClientSingleton from '../../util/fabric'; +import { getFabricClientSingleton } from '../../util/fabric'; const logger = require('electron-log'); diff --git a/src/components/content/ChaincodeInvokeContent.jsx b/src/components/content/ChaincodeInvokeContent.jsx index fde202b..d5c8b11 100644 --- a/src/components/content/ChaincodeInvokeContent.jsx +++ b/src/components/content/ChaincodeInvokeContent.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Button, Input, Select, Radio, message, Modal, Icon, Tag, Tooltip } from 'antd'; -import getFabricClientSingleton from '../../util/fabric'; +import { getFabricClientSingleton } from '../../util/fabric'; const logger = require('electron-log'); const path = require('path'); diff --git a/src/components/content/ChannelManangeContent.jsx b/src/components/content/ChannelManangeContent.jsx index b72efe6..be772fe 100644 --- a/src/components/content/ChannelManangeContent.jsx +++ b/src/components/content/ChannelManangeContent.jsx @@ -4,7 +4,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Button, message, Input, Icon, Tooltip } from 'antd'; -import getFabricClientSingleton from '../../util/fabric'; +import { getFabricClientSingleton } from '../../util/fabric'; import { copyDir, copyFile, deleteDir } from '../../util/tools'; const path = require('path'); diff --git a/src/components/content/DataContent.jsx b/src/components/content/DataContent.jsx index 181ebb7..c83b65d 100644 --- a/src/components/content/DataContent.jsx +++ b/src/components/content/DataContent.jsx @@ -3,7 +3,7 @@ import React from 'react'; import { Col, Row, Table, Modal, Select, message } from 'antd'; import { getQueryBlockSingleton, deleteQueryBlockSingleton } from '../../util/queryBlock'; -import getFabricClientSingleton from '../../util/fabric'; +import { getFabricClientSingleton } from '../../util/fabric'; const logger = require('electron-log'); diff --git a/src/util/fabric.js b/src/util/fabric.js index 0020b46..43f4f71 100644 --- a/src/util/fabric.js +++ b/src/util/fabric.js @@ -835,11 +835,8 @@ export function getFabricClientSingletonHelper(dbConfig) { return Promise.resolve(__fabricClient); } -// TODO: 考虑是否去除export default,全部使用export。 -// 由此保证import无需再区分 import something from 'lib' 与 import {something} from 'lib' - // FabricClient单例模式。后续考虑优化为多套身份,多个client -export default function getFabricClientSingleton() { +export function getFabricClientSingleton() { return getFabricClientSingletonHelper(db); } diff --git a/src/util/queryBlock.js b/src/util/queryBlock.js index 1c43de0..2be8570 100644 --- a/src/util/queryBlock.js +++ b/src/util/queryBlock.js @@ -1,7 +1,7 @@ // Copyright 2018 The hyperledger-fabric-desktop Authors. All rights reserved. import { getBlockDBSingleton } from './createDB'; -import getFabricClientSingleton from './fabric'; +import { getFabricClientSingleton } from './fabric'; const db = getBlockDBSingleton(); diff --git a/test/util/fabric.test.js b/test/util/fabric.test.js index 645d92f..adde493 100644 --- a/test/util/fabric.test.js +++ b/test/util/fabric.test.js @@ -1,5 +1,5 @@ // Copyright 2019 The hyperledger-fabric-desktop Authors. All rights reserved. -import { getFabricClientSingletonHelper, deleteFabricClientSingleton} from '../../src/util/fabric'; +import { getFabricClientSingletonHelper, deleteFabricClientSingleton } from '../../src/util/fabric'; const { execSync } = require('child_process'); const logger = require('electron-log');