Skip to content

Deep optimization: modernize build, fix code quality, add tests, improve CI/CD#33

Merged
GalaxySciTech merged 5 commits intomasterfrom
cursor/-bc-bf273b18-c720-4b11-8652-4039166c2aad-88b6
Apr 2, 2026
Merged

Deep optimization: modernize build, fix code quality, add tests, improve CI/CD#33
GalaxySciTech merged 5 commits intomasterfrom
cursor/-bc-bf273b18-c720-4b11-8652-4039166c2aad-88b6

Conversation

@GalaxySciTech
Copy link
Copy Markdown
Owner

Summary

Comprehensive project optimization as technical director, covering build system, code quality, testing, CI/CD, documentation, and security.

Changes

1. Build System Modernization

  • Gradle 5.1 → 8.5: Upgraded wrapper to modern Gradle with full Java 21 support
  • compileimplementation: Migrated deprecated dependency configuration
  • Removed jcenter(): Replaced with mavenCentral() (jcenter is read-only/EOL)
  • Replaced android-maven plugin with standard java-library + maven-publish
  • Removed broken processResources: Was referencing non-existent src/main/java/resources
  • Fixed bitcoinj version: Changed from 0.16.2 (breaking API) to 0.14.7 (matching the code's API usage)
  • Added missing dependencies: hutool-core, fastjson, commons-lang3
  • Added source/javadoc jars for proper Maven publishing
  • Version bump: 1.2.1 → 1.3.0

2. Code Quality Fixes

  • Thread safety: HashtableConcurrentHashMap in WalletManager
  • Performance: Reuse ObjectMapper instances across WalletManager, Identity, Wallet (avoid per-call allocation)
  • NPE fixes: Guard directory.listFiles() and dir.list() null returns in WalletManager
  • Lazy initialization: TronTransaction.ApiWrapper now lazy-loaded instead of eager (avoids network connection at construction)
  • Dependency injection: Added TronTransaction.setClient() for testability
  • Removed unused imports: HexUtil, StandardCharsets, StringUtils
  • Fixed typos: spec256k1secp256k1, purpusepurpose, singsign
  • Removed debug output: System.out.println in FileTransaction
  • Internationalized error messages: Chinese → English

3. Test Infrastructure (96 test cases)

  • Added JUnit 5 with parameterized test support
  • NumericUtilTest: 18 tests covering hex conversion, byte operations, BigInteger utils
  • MnemonicUtilTest: 6 tests for generation, validation, entropy conversion
  • ChainTypeTest: 12 tests for chain type validation
  • BIP44UtilTest: 8 tests for path generation
  • MetadataTest: 7 tests for clone, mainnet detection, constructors
  • NetworkTest: 4 tests for mainnet detection
  • TokenExceptionTest: 2 tests for exception propagation
  • EthereumAddressCreatorTest: 3 tests for address derivation
  • BitcoinAddressCreatorTest: 3 tests for mainnet/testnet
  • AddressCreatorManagerTest: 7 tests for factory pattern
  • EthereumTransactionTest: 4 tests for RLP, signing, hash
  • WalletManagerTest: 12+ integration tests for full wallet lifecycle

4. CI/CD Modernization

  • Replaced Travis CI (EOL) with GitHub Actions
  • Java 8/11/17 matrix builds
  • Gradle caching via gradle/actions
  • Test results uploaded as artifacts

5. Documentation Overhaul

  • Fixed version mismatch (README showed 1.2.7, build.gradle had 1.2.1)
  • Fixed TRON code sample bug (ChainType.BITCOINChainType.TRON)
  • Added Ethereum transaction signing example
  • Added Requirements, Running Tests, Building sections
  • Fixed Maven integration (removed dead bintray repo, corrected groupId)
  • Updated CI badge from Travis → GitHub Actions

6. Functionality & Error Handling

  • Extended mnemonic import: Added TRON, FILECOIN, DASH, DOGECOIN, BCH, BSV support
  • V3Keystore: Added Filecoin private key import support
  • Fail-fast errors: Unsupported chains now throw descriptive exceptions instead of returning null
  • Updated .gitignore with comprehensive patterns

Testing

All 96 tests pass:

BUILD SUCCESSFUL
96 tests completed, 0 failed
Open in Web Open in Cursor 

cursoragent and others added 5 commits April 2, 2026 13:20
Build system:
- Upgrade Gradle wrapper 5.1 → 8.5
- Migrate compile → implementation (Gradle 7+ requirement)
- Replace deprecated jcenter() with mavenCentral()
- Replace android-maven plugin with java-library + maven-publish
- Remove broken processResources (was referencing non-existent path)
- Add JUnit 5 test infrastructure
- Add missing dependencies (hutool, fastjson, commons-lang3)
- Add Java source/javadoc jars for publishing
- Version bump to 1.3.0

Code quality:
- WalletManager: Hashtable → ConcurrentHashMap for thread safety
- WalletManager: reuse ObjectMapper instances (avoid allocation per call)
- WalletManager: fix NPE in scanWallets when directory is empty
- WalletManager: fix NPE in deleteDir when dir.list() returns null
- Identity: reuse shared ObjectMapper from WalletManager
- Wallet: reuse ObjectMapper for keystore export
- Wallet: remove unused imports (HexUtil, StandardCharsets)
- TronTransaction: lazy-init ApiWrapper (avoid eager network conn)
- TronTransaction: add setClient() for dependency injection
- FileTransaction: remove debug System.out.println
- FileTransaction: fix variable name typo (sing → sign)
- HDMnemonicKeystore.Info: fix typos (spec256k1 → secp256k1, purpuse → purpose)
- Internationalize error messages (Chinese → English)

Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
Fix bitcoinj dependency version to 0.14.7 (matching the API the code was
written for; previously declared 0.16.2 which had breaking API changes
and wouldn't compile).

Test coverage:
- NumericUtilTest: hex conversion, byte operations, BigInteger utils (18 tests)
- MnemonicUtilTest: mnemonic generation, validation, entropy conversion (6 tests)
- ChainTypeTest: chain type validation, constants (12 tests)
- BIP44UtilTest: path generation, BTC mnemonic paths (8 tests)
- MetadataTest: clone, mainnet detection, constructors (7 tests)
- NetworkTest: mainnet detection, constants (4 tests)
- TokenExceptionTest: message, cause propagation (2 tests)
- EthereumAddressCreatorTest: address derivation from hex/bytes (3 tests)
- BitcoinAddressCreatorTest: mainnet/testnet address derivation (3 tests)
- AddressCreatorManagerTest: factory pattern for all chain types (7 tests)
- EthereumTransactionTest: RLP encoding, signing, hash calc (4 tests)
- WalletManagerTest: identity creation, wallet derivation, import,
  export, change password, remove wallet (12+ integration tests)

Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
- Add GitHub Actions workflow with Java 8/11/17 matrix
- Use Gradle wrapper caching via gradle/actions
- Upload test results as artifacts
- Remove deprecated .travis.yml (Travis CI is EOL)

Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
…reum example

- Update version from 1.2.7 → 1.3.0 in all integration examples
- Fix Maven integration (remove bintray, correct groupId)
- Fix TRON sample: use ChainType.TRON instead of ChainType.BITCOIN for TRX wallet lookup
- Add Ethereum transaction signing example
- Add Requirements section (Java 8+, Gradle 8.5+)
- Add Running Tests and Building sections
- Update CI badge from Travis to GitHub Actions
- Replace hardcoded '123456' passwords with 'your_password' placeholders
- Use implementation instead of compile in Gradle example

Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
- WalletManager.importWalletFromMnemonic: add support for TRON, FILECOIN,
  DASH, DOGECOIN, BCH, BSV (previously only ETH, BTC, LTC, EOS)
- WalletManager.importWalletFromMnemonic: throw on unsupported chain
  instead of silently returning null → NPE
- V3Keystore: add Filecoin support via FilecoinAddressCreator
- V3Keystore: improve error message for unsupported chain types
- Update .gitignore with more comprehensive patterns

Co-authored-by: Galaxy <GalaxySciTech@users.noreply.github.com>
@GalaxySciTech GalaxySciTech marked this pull request as ready for review April 2, 2026 13:42
@GalaxySciTech GalaxySciTech merged commit 564ec58 into master Apr 2, 2026
3 checks passed
@GalaxySciTech GalaxySciTech deleted the cursor/-bc-bf273b18-c720-4b11-8652-4039166c2aad-88b6 branch April 2, 2026 13:42
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