Skip to content

feat: create account if it doesnt exists#214

Merged
cristiam86 merged 5 commits intomainfrom
edinaldo/dxp-99-feat-create-account-if-it-doesnt-exists
Apr 24, 2025
Merged

feat: create account if it doesnt exists#214
cristiam86 merged 5 commits intomainfrom
edinaldo/dxp-99-feat-create-account-if-it-doesnt-exists

Conversation

@epsjunior
Copy link
Copy Markdown
Contributor

Brief Overview

  • Added automatic keypair creation when missing during contract operations
  • Implemented lazy initialization pattern for GenLayer client
  • Enhanced keypair management and testing
  • Improved error handling

Description

🔹 Problem Solved

  • Users had to manually create keypairs before deploying or calling contracts
  • Constructor async initialization issues in DeployAction and CallAction
  • Improper handling of private key retrieval

🔹 Changes Made

  • Automatic Keypair Creation:
    • Added prompt to create keypair when none exists
    • Seamless integration with contract operations
    • Improved user experience with clear feedback
  • Lazy Client Initialization:
    • Moved client initialization to getClient() method
    • Implemented proper async handling of private key retrieval
    • Added null safety checks
  • Keypair Management:
    • Enhanced KeypairManager with proper error handling
    • Added comprehensive test coverage
    • Improved type safety in keypair operations
  • Testing Improvements:
    • Added tests for getPrivateKey in BaseAction
    • Created new test suite for KeypairManager
    • Fixed existing tests to work with new async patterns

🔹 Important Decisions

  • Implemented user-friendly keypair creation flow
  • Used lazy initialization pattern to handle async operations
  • Implemented proper error handling for missing keypairs
  • Maintained backward compatibility with existing code
  • Enhanced type safety throughout the codebase

🔹 Previously Aligned Architecture Changes

  • No major architecture changes, focused on improving existing patterns

Dependencies

  • No new dependencies added

@epsjunior epsjunior requested a review from cristiam86 April 24, 2025 06:02
@epsjunior epsjunior self-assigned this Apr 24, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ae8b5fe) to head (6eec877).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #214   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           29        29           
  Lines         1505      1522   +17     
  Branches       373       381    +8     
=========================================
+ Hits          1505      1522   +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/commands/contracts/deploy.ts Outdated
});
}

private async getClient(): Promise<GenLayerClient<typeof simulator>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epsjunior Can we implement this getClient method in the base action and reuse it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds better, I'll do it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@epsjunior epsjunior changed the title Edinaldo/dxp 99 feat create account if it doesnt exists feat: create account if it doesnt exists Apr 24, 2025
@cristiam86 cristiam86 merged commit 12d2faa into main Apr 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants