Flex-NFT-Marketplace / Flex-Marketplace-Contract

12 stars 40 forks source link

dev: Refactor deployment script for cleaner code #78

Closed 0xandee closed 2 months ago

0xandee commented 2 months ago

Refactor deployment.ts in marketplace/script/ folder. The current deployment script contains repetitive code. This issue aims to refactor the script to improve readability, reduce redundancy, and follow best practices for code organization.

Additional Notes: Please run a full test of the deployment process after refactoring to ensure that no functionality is broken.

od-hunter commented 2 months ago

Hi @0xandee , can I be assigned this please? I’m a blockchain developer and I’m ready to work. To solve this issue(to refactor the script), I’d take the following steps:

  1. I’ll first of all have to analyze the Script to I Identify repetitive code patterns and logic that can be abstracted into reusable functions.
  2. I’ll then abstract Repetitive Logic. I’ll create functions for common tasks like contract deployment, error handling, and logging to reduce redundancy.
  3. Next I’ll organize into Modules by splitting the script into separate files if it handles multiple tasks, such as deployContracts.ts for deployment logic, config.ts for configuration, and utils.ts for utility functions.
  4. I’ll use descriptive names, consistent formatting, and comments to enhance code clarity and improve readability.
  5. I’ll then refactor error handling into reusable functions and ensure consistent logging.
  6. I’ll make sure to run full deployment tests to verify that the refactor hasn't introduced any issues and ensure no functionality is broken.

This would be my first time contributing to this repo, I’d love to be given the opportunity please.

Mystic-Nayy commented 2 months ago

Hi @0xandee can I work on this please?

I am a web3/frontend developer I can handle this issue perfectly

I will do the following if i am assigned

  1. Identify and extract repetitive code blocks in deployment.ts into reusable functions.
  2. Organize the script by grouping related functionality, ensuring proper separation of concerns.
  3. Refactor for clarity and conciseness, and run a full deployment test to confirm that everything works as expected.
onlydustapp[bot] commented 2 months ago

Hi @od-hunter! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 2 months ago

Hi @Gift-Naomi! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

ShantelPeters commented 2 months ago

Hi @0xandee can I work on this ?

onlydustapp[bot] commented 2 months ago

Hi @ShantelPeters! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 2 months ago

Hi @Gift-Naomi! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 2 months ago

Hi @od-hunter! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

martinvibes commented 2 months ago

Hi @0xandee , can I be assigned this please? I’m a frontend/blockchain developer and I’m ready to work on this issue and get it done asap. This would be my first time contributing to this repo, I’d love to be given the opportunity please.

onlydustapp[bot] commented 2 months ago

Hi @martinvibes! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 2 months ago

Hi @Gift-Naomi! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 2 months ago

Hi @od-hunter! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

Ayoazeez26 commented 2 months ago

Hi @0xandee can I work on this?

onlydustapp[bot] commented 2 months ago

Hi @Ayoazeez26! Maintainers during the ODHack # 7.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

MatiasAchucarro commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a passionate and results-driven web developer, currently deepening my knowledge in web3 technologies, Cairo, and open-source development through Dojo Coding. My skill set includes expertise in JavaScript, React, HTML, CSS, C# with .NET Entity Framework, and more. I also have experience with tools like Git, GitHub, SQL Server, and Postman. My focus has been on building solid web applications, from task lists to full-fledged CRUD systems, with front-end, back-end, and database integration.

This will be my first contribution to the open-source ecosystem, and I am excited to learn and collaborate on innovative projects, particularly those involving Cairo.

How I plan on tackling this issue

To refactor the deployment.ts script in marketplace/script/carpeta, start by identifying and consolidating repetitive code into reusable functions or modules. Simplify logic by creating helper functions for common tasks and ensure that configuration details are centralized. Refactor the script to improve readability and maintainability while adhering to best practices. After making these changes, conduct a thorough test of the entire deployment process to ensure that no functionality is broken

Zeegaths commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockhain developer. I have bult marketplaces before and I understand how deployment scrips work

How I plan on tackling this issue

GO through the deployment script to better understand it, remove unecessary code or comments , test the script to ensure no functionality is broken.

mariocodecr commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have extensive knowledge in TypeScript and a strong understanding of the SOLID principles. Additionally, I've participated in two basecamps of StarkNet where I learned Cairo, and I've successfully completed the Starklings app, which is focused on Cairo. This background equips me with the skills to effectively contribute to complex projects, ensuring clean, maintainable code and a deep understanding of emerging blockchain technologies.

How I plan on tackling this issue

To refactor the deployment.ts script, I would first analyze the existing code to identify repetitive patterns and areas for improvement. Then, I would modularize the script by extracting reusable functions and using configuration files or environment variables for hardcoded values. I would make incremental changes, testing the deployment in a test environment after each refactor to ensure that no functionality is broken. Finally, I would update the documentation and request a code review to ensure the quality and consistency of the changes.

GideonBature commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a software engineer and technical writer, I have experience working with TypeScript, I have worked on some open source projects which involves working on functions and refactoring them to improve readability and reduce redundancy. Hence, I will be able to work on this project.

How I plan on tackling this issue

I will go through all the functions in the deployment.ts files understand what they are each doing, work on those that requires improved readability as well as remove any sort of repetition. If two or more functions are doing the same thing, I will combine the functionality into just a single function. etc.

Ayoazeez26 commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a web developer with over 6 years experience building applications both personal and professional projects. I started contributing to open source via onlydust in march this year and I have contributed to a couple of issues, you can see them in my profile.

How I plan on tackling this issue

Refactor the deployment.ts file to remove repetitive code to reduce redundancy and follow best practices. I would ensure to test the deployment process after refactoring to make sure that it works as intended. This issue would take an ETA of 1 day to complete if assigned

od-hunter commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, please I'd love to be given the opportunity to contribute to this rep, I am a blockchain developer html, css, react, JavaScript, typescript, solidity and Cairo.

How I plan on tackling this issue

Hi @0xandee , can I be assigned this please? To solve this issue(to refactor the script), I’d take the following steps:

  1. I’ll first of all have to analyze the Script to I Identify repetitive code patterns and logic that can be abstracted into reusable functions.
  2. I’ll then abstract Repetitive Logic. I’ll create functions for common tasks like contract deployment, error handling, and logging to reduce redundancy.
  3. Next I’ll organize into Modules by splitting the script into separate files if it handles multiple tasks, such as deployContracts.ts for deployment logic, config.ts for configuration, and utils.ts for utility functions.
  4. I’ll use descriptive names, consistent formatting, and comments to enhance code clarity and improve readability.
  5. I’ll then refactor error handling into reusable functions and ensure consistent logging.
  6. I’ll make sure to run full deployment tests to verify that the refactor hasn't introduced any issues and ensure no functionality is broken.

This would be my first time contributing to this repo, I’d love to be given the opportunity please.

ScottyDavies commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer With background on JavaScript

How I plan on tackling this issue

Understand the Existing Deployment Process: First, I would thoroughly understand the existing deployment process, including the purpose of the script, the different components being deployed, and the overall flow of the deployment. Analyze the Existing Code: Next, I would carefully review the current deployment.ts script and identify the areas that are repetitive or could be improved in terms of readability and maintainability. I would look for opportunities to extract common functionality, simplify complex logic, and improve the organization of the code. Identify Opportunities for Refactoring: Based on the analysis, I would identify the specific areas that could be refactored, such as: Repeated deployment logic for different contracts Shared configuration or setup steps Reusable utility functions or helper methods Improved error handling and logging Plan the Refactoring Approach: With the identified areas for improvement, I would plan the refactoring approach. This might include: Creating reusable functions or classes to encapsulate common deployment logic Introducing configuration or settings management to make the script more adaptable Improving the overall structure and organization of the script (e.g., separating concerns, using modules) Enhancing error handling and providing better feedback to the user during the deployment process Implement the Refactoring: After planning the approach, I would start implementing the refactoring. This would involve modifying the existing code, introducing new functions or modules, and ensuring that the overall structure and flow of the script are improved. Test the Refactored Deployment Process: Before finalizing the changes, I would run a full test of the deployment process to ensure that no functionality is broken. This would include: Deploying the complete set of contracts and verifying their correct deployment Validating that the refactored script maintains the same overall behavior as the original Checking for any edge cases or unexpected scenarios that might have been introduced during the refactoring Document the Changes: Finally, I would document the changes made during the refactoring process, including the rationale behind the decisions and any new conventions or best practices introduced. This documentation would help other developers understand the improvements and maintain the script going forward.

DioChuks commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Full-Stack Development: End-to-End Projects: With over 3 years experience and expertise in both frontend (React.js, TypeScript) and backend (Node.js, Laravel), I can handle full-stack projects, building robust and scalable web applications from the ground up. API Design and Integration: My knowledge of Node.js and Laravel positions me well to design and implement APIs that power frontend applications, ensuring seamless integration and performance.

Performance Optimization: Use my understanding of JavaScript and TypeScript to write optimized code, improving the performance and responsiveness of the applications.

How I plan on tackling this issue

Refactoring a deployment script involves improving code quality by reducing redundancy, enhancing readability, and ensuring that best practices are followed. Here's how I would approach the problem: Firstly, i will analyze the current script; by thoroughly reading through the deployment.ts file to understand the existing structure and logic. Identify Redundant Code: Look for repetitive code blocks, such as repeated API calls, similar function logic, or duplicated configuration setups. Secondly, Refactor for Reusability; Extract Reusable Functions: i'll Identify repetitive code and extract it into reusable functions or utility modules. For example, if the script makes repeated API calls with slight variations, create a generic function that accepts parameters to handle the variations:

const deployToEnvironment = async (environment: string, config: Config) => { // Deployment logic specific to the environment };

// Usage await deployToEnvironment('staging', stagingConfig); await deployToEnvironment('production', productionConfig);

DRY Principle: I'll Follow the DRY (Don’t Repeat Yourself) principle by consolidating repeated logic into functions, constants, or configuration objects.

Thirdly, Improve Code Organization: Modularize the Script: i'll break down the script into smaller, more focused modules or files if it's large and complex. For example, i could have separate modules for environment configuration, deployment steps, and utilities. Use Descriptive Names: Ensure that function names, variables, and modules have clear, descriptive names that convey their purpose.

Fourthly, Enhance Readability: Comment and Document: i'll add comments to explain the purpose of complex code blocks or functions, making it easier for others (or future me) to understand. Logical Grouping: Group related code together to create a logical flow within the script. For instance, all configuration setups could be at the beginning, followed by deployment logic, and finally, cleanup or post-deployment tasks.

Lastly, I'll follow TypeScript Best Practices: Type Safety: Ensure all variables, function parameters, and return types are properly typed. Utilize TypeScript interfaces and types to define the structure of configuration objects or deployment responses. Error Handling: Improve error handling by wrapping critical sections of the code in try-catch blocks and providing meaningful error messages.

DanielEmmanuel1 commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, my name is Daniel, I'm a frontend web3 developer with good experience in building fully scalable and customizable UI which helps to better user experience.

How I plan on tackling this issue

Firstly I will review the existing deployment.ts script to understand its current functionality and flow.

I will then identify sections of code that are repetitive and redundant and then outline a plan too refactor the script file including creating utility functions or modules for the repetitive code.

I'll ensure that the code is organized in a logical and readable manner.

I'll update comments and improve on variable names for better readability then execute a comprehensive test of the deployment process to ensure that the refactored script functions correctly.

Finally I'll update any related documentation to reflect changes made during the refactoring process and note any significant alterations or improvements for future reference.

ShantelPeters commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

To address the application form question and highlight how your background as a blockchain developer is relevant, you can focus on your experience with scripting, code refactoring, and deployment processes. Here's how you might respond:


As a blockchain developer with experience in writing and optimizing deployment scripts, I am well-equipped to refactor the deployment.ts script in your marketplace project. My background in blockchain development has provided me with a deep understanding of the importance of clean, maintainable code and efficient deployment processes, especially in complex environments.

Relevant Experience:

  1. Experience with Deployment Scripts: Throughout my career, I have worked extensively with deployment scripts in various blockchain projects. This includes writing, testing, and refactoring scripts to deploy smart contracts, manage migrations, and automate blockchain-related tasks. I understand the critical role that these scripts play in ensuring smooth and reliable deployments.

  2. Code Refactoring Skills: I have a strong focus on code quality and best practices, which includes refactoring existing code to improve readability, reduce redundancy, and enhance maintainability. I am adept at identifying repetitive code patterns and abstracting them into reusable functions or modules, which aligns perfectly with the task of refactoring deployment.ts.

  3. Understanding of Best Practices: My experience in blockchain development has taught me the importance of following best practices, not just in writing smart contracts but also in the supporting infrastructure, such as deployment scripts. I am familiar with organizing code in a way that makes it easy to understand, maintain, and extend, which is crucial for long-term project success.

How I Would Leverage My Background:

  1. Analyzing the Existing Script: I would begin by thoroughly reviewing the deployment.ts script to identify areas of redundancy and code that can be optimized. This might involve breaking down the script into smaller, more manageable functions, each responsible for a specific task.

  2. Refactoring for Clarity and Efficiency: Using my knowledge of TypeScript and deployment practices, I would refactor the script to remove repetitive code, improve variable naming, and ensure that the script follows a logical flow. My goal would be to make the script not only more efficient but also easier for other developers to understand and maintain.

  3. Testing and Validation: After refactoring, I would run a full test of the deployment process to ensure that the changes do not break any functionality. My experience with blockchain deployments includes rigorous testing to catch any potential issues early, ensuring a smooth deployment process in production.

  4. Continuous Improvement: I would also document the refactoring process and any changes made, providing clear instructions for future developers who might need to work on the deployment script. This ensures that the script remains easy to maintain and extend as the project evolves.

By leveraging my background as a blockchain developer, I can ensure that the deployment.ts script is optimized for readability, maintainability, and efficiency, while still meeting the project's deployment need

How I plan on tackling this issue

To approach the task of refactoring the deployment.ts script in the marketplace project, I would follow a structured process to ensure that the refactoring improves the script's readability, reduces redundancy, and maintains functionality. Here's how I would approach the problem:

1. Understand the Current Script

2. Identify Redundant Code

3. Refactor the Script

4. Test the Refactored Script

5. Document the Changes

6. Prepare for Future Maintenance

7. Final Review and Deployment

Abeeujah commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a Web and Systems engineer, with deep understanding of clean code principles and best practices, this has enabled me build solutions that scale, high abstraction and can be reusable.

How I plan on tackling this issue

SoarinSkySagar commented 2 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a full stack developer with over a year of experience in developing dapps and writing smart contracts. I am proficient in tech-stacks Next.js, React.js, Typescript, web3.js.

How I plan on tackling this issue

I would approach the problem in the following way:

  1. Look for repetitive blocks of code and refactor them into functions when and where required
  2. Divide the file into smaller functions instead of one big function to improve readability
  3. Add comments to ensure any new contributor can get an idea of what the following lines of codes do
  4. Look for ways to improve the code by implementing better data structures, if any
  5. Run and test the code and thoroughly before final PR
onlydustapp[bot] commented 2 months ago

The maintainer 0xandee has assigned GideonBature to this issue via OnlyDust Platform. Good luck!

GideonBature commented 2 months ago

Thank you! Let me start working on it.