Skip to content
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

Adds combined/unified bech32+EVM wallet utility functions #195

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cordt-sei
Copy link

@cordt-sei cordt-sei commented Aug 27, 2024

Add unified Wallet Utility Functions to @sei-js/evm

Implements wallet utility functions for address generation and validation in both native and EVM context.

Changes

  1. Added new utility functions in src/utils/walletUtils.ts:

    • generateAddressesFromPrivateKey: Generates Sei and EVM addresses from a private key
    • deriveAddressesFromPublicKey: Derives Sei and EVM addresses from a public key
    • isValidSeiAddress: Validates a Sei address
    • isValidEvmAddress: Validates an EVM address
  2. Created unit tests in src/utils/walletUtils.spec.ts

  3. Updated README.md for new utilities

  4. Bumped package version from 1.4.0 to 1.5.0

  5. Updated deps, specifically bech32 to latest

Implementation Details

  • The new functions use the bech32 library for Sei address encoding and validation
  • SHA-256 and RIPEMD-160 hashing is used for Sei address generation
  • EVM address generation uses keccak-256 hashing as per Ethereum standards
  • Error handling for invalid inputs

Testing

  • Unit tests added to cover all new functions:
    • Tests for generating addresses from private keys
    • Tests for deriving addresses from public keys
    • Tests for validating Sei and EVM addresses
    • Tests for handling invalid inputs
  • All tests are passing

Documentation

  • README.md has been updated with examples for each new function
  • Inline comments have been added to the code for a better view of the overall process

Impact

Adds easily accessible capabilities for developers working with both Sei and EVM addresses, providing a unified interface for address operations, verification and testing

Copy link

changeset-bot bot commented Aug 27, 2024

🦋 Changeset detected

Latest commit: b492dee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sei-js/evm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cordt-sei
Copy link
Author

Not sure why the workflow is failing, it builds and tests good locally.

@cordt-sei cordt-sei marked this pull request as draft August 27, 2024 06:01
	modified:   package.json
	modified:   packages/evm/package.json
	modified:   packages/evm/src/utils/walletUtils.ts
	modified:   yarn.lock
@cordt-sei cordt-sei marked this pull request as ready for review August 27, 2024 06:16
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.91%. Comparing base (5e40d59) to head (b492dee).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #195      +/-   ##
==========================================
+ Coverage   84.47%   86.91%   +2.43%     
==========================================
  Files          16       17       +1     
  Lines         161      191      +30     
  Branches       25       27       +2     
==========================================
+ Hits          136      166      +30     
  Misses         25       25              

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

@cordt-sei cordt-sei changed the title Adds bech32+EVM wallet utility functions Adds combined/unified bech32+EVM wallet utility functions Aug 28, 2024
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