-
Notifications
You must be signed in to change notification settings - Fork 445
The Refactor #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lab/kirin-refactor
Are you sure you want to change the base?
The Refactor #735
Conversation
b2553e7 to
4a3123e
Compare
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: KIRIN.CHU 朱祐麟 <KIRIN.CHU@deltaww.com> Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
|
@YoungHypo suggest we create a new branch for this refactor work. |
I just realized that I myself can also create a new branch in this repo. Therefore, I created a new branch called Feel free to suggest another branch name. |
Signed-off-by: dodo920306 <dodo920306@gmail.com>
The peers dropdown in the chaincode form should be labelled as "peers" directly instead of "Please select peers" which should be the warning message. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
The directory contains organizational MSPs should be ignored by Git. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
To block duplicate package IDs, chaincodes package IDs will be set when they're created. Signed-off-by: dodo920306 <dodo920306@gmail.com>
- Add src/utils/serviceFactory.js with reusable utilities: - createCrudService(): generates standard CRUD methods for REST resources - customRequest(): wrapper for non-standard API endpoints - formDataRequest(): helper for file uploads - blobRequest(): helper for file downloads - Refactor all service files to use the new factory: - agent.js: use createCrudService, remove duplicate applyAgent/createAgent - network.js: use createCrudService - node.js: use createCrudService + custom helpers - organization.js: use createCrudService, fix getOrganization URL path - channel.js: use createCrudService - chaincode.js: use customRequest + formDataRequest - user.js: use createCrudService This reduces ~87 lines of duplicate code and provides: - Consistent API call patterns across all services - Centralized extension point for future enhancements - Better code readability and maintainability --- Generated-by: AI (Claude, Anthropic) Note: All changes in this commit were generated by AI assistant. Signed-off-by: dodo920306 <dodo920306@gmail.com>
- Add src/utils/modelFactory.js with reusable utilities: - createModel(): generates complete dva model with auto reducers - createListEffect(): handles paginated list with consistent logic - createSimpleEffect(): generates simple call-and-callback effects - commonReducers: shared save reducer - createClearReducer(): generates reset reducer from initial state - Refactor all model files to use the new factory: - agent.js: 127 -> 56 lines - network.js: 75 -> 28 lines - node.js: 140 -> 54 lines - organization.js: 97 -> 38 lines - channel.js: 73 -> 37 lines - chaincode.js: 90 -> 48 lines This reduces ~176 lines of duplicate code and provides: - Consistent pagination handling across all models - Auto-generated save/clear reducers - Flexible customization for edge cases --- Generated-by: AI (Claude, Anthropic) Signed-off-by: dodo920306 <dodo920306@gmail.com>
- Add src/hooks/ directory with custom React hooks: - useTableManagement: handles selected rows, pagination, filters - useModalForm: handles modal visibility, create/update modes - useDeleteConfirm: handles delete confirmation dialog with i18n These hooks can reduce ~50 lines of boilerplate code per page when migrating from Class Components to Function Components. --- Generated-by: AI (Claude, Anthropic) Signed-off-by: dodo920306 <dodo920306@gmail.com>
New models generated by the factory now will fail to be loaded since they're not static. Thus, they will be forced to be loaded after the DVA app is ready. Signed-off-by: dodo920306 <dodo920306@gmail.com>
With the introduction of Hooks in React 16.8, function components have become the preferred way to write React components. They are simpler, more readable, and provide more powerful patterns for managing state and side effects compared to class components. Signed-off-by: dodo920306 <dodo920306@gmail.com>
With the introduction of Hooks in React 16.8, function components have become the preferred way to write React components. They are simpler, more readable, and provide more powerful patterns for managing state and side effects compared to class components. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Network is deprecated. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Network is deprecated. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Convert StandardTable from Class Component (PureComponent) to Function Component using React Hooks for improved code maintainability. Changes: - Replace PureComponent with function component - Replace this.state with useState hooks - Replace getDerivedStateFromProps with useEffect - Replace injectIntl HOC with useIntl hook - Wrap handlers with useCallback for referential stability - Memoize paginationProps and rowSelection with useMemo - Simplify JSX using shorthand Fragment syntax (<>) The component API remains fully backward compatible - no changes required in consuming pages. --- Generated by AI (Claude) Signed-off-by: dodo920306 <dodo920306@gmail.com>
Convert multiple components from Class to Function Components and refactor the menu translation system to eliminate formatMessage warnings. Components converted to Function Components: - StandardTable: PureComponent → Function Component with hooks - BasicLayout: Component → Function Component with hooks - Header: Component → Function Component with hooks - SelectLang: PureComponent → Function Component with hooks - BaseMenu: PureComponent → Function Component with hooks Menu translation system refactoring: - models/menu.js: Remove formatMessage, store only locale keys - breadcrumb.js: Accept intl parameter instead of using formatMessage directly - PageHeaderWrapper: Pass intl to breadcrumb functions - BaseMenu: Translate menu items at render time using useIntl Other changes: - getPageTitle.js: Accept intl parameter for translation This refactoring moves translation from data preparation phase (Dva effects) to render phase (React components), which is the recommended pattern for umi's locale plugin and eliminates the "please use useIntl or injectIntl" warnings. --- Generated by AI (Claude) Signed-off-by: dodo920306 <dodo920306@gmail.com>
I encountered an issue after upgrading my Docker engine to version 29, and it seems to be caused by hyperledger/fabric#5350. Thus, I upgrade Hyperledger Fabric to 2.5.14 and go to 1.25.5 before I realized that the merge fix PR hyperledger/fabric#5355 hasn't been included in a Hyperledger Fabric release yet. Although I ended up downgrading my Docker engine to version 28, still, I commit my changes to these dependencies anyway. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Chaincode installation can take a really long while. It often causes the client gateway timeout. Chaincode installation now uses another thread to wait for the peer command to response as it did before the refactor. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
|
With the first interaction with a chaincode via Hyperledger Cello done on my PC, I hereby proudly announce that now Hyperledger Cello API Engine has the very basic ability to interact with chaincodes after a1f9e92 🥳! This definitely took a lot longer than expected, and the functionality is definitely not mature enough now ---- it is currently inaccessible via dashboard.
|
Signed-off-by: dodo920306 <dodo920306@gmail.com>
|
Update for this PR: After several meetings and discussions, I officially retract some of my comments in #735 (comment) and acknowledge that agents do indeed have their necessity. However, I also raised my concerns during the meetings — namely, that the logic for interacting with blockchain nodes on the Subsequently, @yeasy proposed moving all current blockchain interaction logic into the agent, allowing the agent to handle all operations. This also aligns with the original intention of Hyperledger Cello: to move blockchain-specific operations into agents, enabling users to support various blockchain projects simply by swapping agents.Fortunately, after this refactoring, user request handling is decoupled from business logic to the maximum extent (i.e., a view-service layered design). This makes it relatively easier to extract service logic and insert it into a standalone agent project compared to the In any case, reintegrating the decoupled agent will be the next and final stage of this refactoring. Hopefully, this process will go more smoothly this time. |
A new version of Hyperledger Fabric Docker Agent has been added to the repo. It has been finished yet. It's written in Python 3.13.7, a version a lot newer than the api-engine, and adopts the latest version of Django (6.0). Also, it uses `drf_spectacular` instead of `drf_yasg` to generate OpenAPI 3.0 schemas. In any respect, it's a fully upgraded version of the old agent. It now supports to create organization crypto materials via Hyperledger Fabric cryptogen. Signed-off-by: dodo920306 <dodo920306@gmail.com>
edeabb0 to
eb936ad
Compare

Let's face it: the current state of this project’s code is not so good.
Contributions over time have lacked consistency, leading to duplicated implementations and a fragmented structure that makes maintenance and development difficult.
The combination of Python, Django, and object-oriented design has introduced unnecessary complexity, and without long-term technical stewardship, the project has become hard to extend.
Another pressing issue is the number of long-standing bugs. For a project that has been in existence for over six years, there remain issues that ideally should have been addressed very early on. Many of these are not superficial problems that tools or automated testing could easily detect, but deeper logical flaws that only become evident when the affected code paths are used.
Additionally, it seems that the project has not fully embraced the design principles of Django REST Framework (DRF). For example, serializers are often used only for traffic handling, while much of the core business logic resides in views.py, which goes against DRF’s intended design practices.
To summary, a refactor is inevitable, and to make sure I’m not just another person who criticizes without acting, I’ll do it myself.