Skip to content

Refactor#64

Open
manu-xmint wants to merge 7 commits intomainfrom
feature/refactor
Open

Refactor#64
manu-xmint wants to merge 7 commits intomainfrom
feature/refactor

Conversation

@manu-xmint
Copy link
Collaborator

@manu-xmint manu-xmint commented Jan 21, 2026

Greptile Summary

  • Introduces a blockchain abstraction layer with provider interfaces and registry system to support multiple blockchain types beyond just Solana
  • Extracts reusable node property factories for wallet locators and chain selectors, eliminating 250+ lines of code duplication across wallet operations
  • Creates centralized export modules (shared/chains/index.ts, shared/nodeProperties/index.ts) to improve code organization and module boundaries

Important Files Changed

Filename Overview
nodes/CrossmintWallets/CrossmintWallets.node.ts Refactored to use extracted property functions, reducing file size from ~487 to ~402 lines by eliminating duplicated wallet locator definitions
shared/chains/solana/SolanaProvider.ts New Solana provider implementation with incomplete 32-byte seed key support and mock context usage that needs cleanup
shared/chains/ChainRegistry.ts New singleton registry for blockchain providers with automatic initialization that could cause import-time side effects
shared/nodeProperties/locator.properties.ts New wallet locator property factory with comprehensive validation but throws errors instead of graceful fallbacks when chain types are unsupported
shared/chains/IChainProvider.ts New blockchain provider interface defining the contract for multi-chain support with extensive method requirements

Sequence Diagram

sequenceDiagram
    participant User
    participant CrossmintWallets as "CrossmintWallets.node"
    participant ChainRegistry
    participant SolanaProvider
    participant CrossmintApi as "CrossmintApi"

    User->>CrossmintWallets: "Execute wallet operation"
    CrossmintWallets->>ChainRegistry: "getProvider(chainType)"
    ChainRegistry->>ChainRegistry: "initialize() if needed"
    ChainRegistry->>SolanaProvider: "new SolanaProvider()"
    ChainRegistry->>ChainRegistry: "register(provider)"
    ChainRegistry-->>CrossmintWallets: "return IChainProvider"
    CrossmintWallets->>SolanaProvider: "validateAddress(address)"
    SolanaProvider-->>CrossmintWallets: "ValidationResult"
    CrossmintWallets->>CrossmintApi: "execute operation (createWallet/getWallet/etc)"
    CrossmintApi-->>CrossmintWallets: "operation result"
    CrossmintWallets-->>User: "return execution data"
Loading

Context used (4)

  • Rule from dashboard - Use TypeScript instead of JavaScript for new projects, as TypeScript is the company's preferred lang... (source)
  • Rule from dashboard - When a function grows to 80+ lines, extract helper functions to improve readability and maintainabil... (source)
  • Rule from dashboard - Remove unused code from PRs to keep them lean. Add functionality later when it's actually needed. (source)
  • Rule from dashboard - Use generic Error exceptions for unexpected backend situations that should never happen, rather than... (source)

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

*/
static createProvider(chainType: string): IChainProvider | undefined {
switch (chainType.toLowerCase()) {
case 'solana':
Copy link

Choose a reason for hiding this comment

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

Consider using CHAIN_TYPES.SOLANA constant from constants.ts instead of string literal for consistency with custom rule 0e60096d

Context Used: Rule from dashboard - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/chains/ChainFactory.ts
Line: 24:24

Comment:
Consider using `CHAIN_TYPES.SOLANA` constant from `constants.ts` instead of string literal for consistency with custom rule 0e60096d

**Context Used:** Rule from `dashboard` - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... ([source](https://app.greptile.com/review/custom-context?memory=0e60096d-0843-4800-801b-f8a78b766fbc))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

* @returns Array of supported chain type identifiers
*/
static getSupportedChainTypes(): string[] {
return ['solana'];
Copy link

Choose a reason for hiding this comment

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

Consider using CHAIN_TYPES.SOLANA constant from constants.ts instead of string literal

Context Used: Rule from dashboard - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/chains/ChainFactory.ts
Line: 42:42

Comment:
Consider using `CHAIN_TYPES.SOLANA` constant from `constants.ts` instead of string literal

**Context Used:** Rule from `dashboard` - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... ([source](https://app.greptile.com/review/custom-context?memory=0e60096d-0843-4800-801b-f8a78b766fbc))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Additional Comments (2)

shared/utils/blockchain.ts
Hardcoded 'solana' string should use CHAIN_TYPES.SOLANA constant from constants.ts for consistency

			chainType: CHAIN_TYPES.SOLANA,

Context Used: Rule from dashboard - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/utils/blockchain.ts
Line: 43:43

Comment:
Hardcoded `'solana'` string should use `CHAIN_TYPES.SOLANA` constant from `constants.ts` for consistency

```suggestion
			chainType: CHAIN_TYPES.SOLANA,
```

**Context Used:** Rule from `dashboard` - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... ([source](https://app.greptile.com/review/custom-context?memory=0e60096d-0843-4800-801b-f8a78b766fbc))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

shared/utils/constants.ts
CHAIN_TYPES constant is defined but never used in the codebase - consider using it in place of hardcoded string literals or removing it

Context Used: Rule from dashboard - Remove unused code from PRs to keep them lean. Add functionality later when it's actually needed. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/utils/constants.ts
Line: 12:14

Comment:
`CHAIN_TYPES` constant is defined but never used in the codebase - consider using it in place of hardcoded string literals or removing it

**Context Used:** Rule from `dashboard` - Remove unused code from PRs to keep them lean. Add functionality later when it's actually needed. ([source](https://app.greptile.com/review/custom-context?memory=83771aea-3c5f-4a37-9170-8ac881cd5efd))

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

*/
static createProvider(chainType: string): IChainProvider | undefined {
switch (chainType.toLowerCase()) {
case 'solana':
Copy link

Choose a reason for hiding this comment

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

Use CHAIN_TYPES.SOLANA constant from constants.ts instead of string literal for consistency and type safety.

Suggested change
case 'solana':
case CHAIN_TYPES.SOLANA:

Context Used: Rule from dashboard - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/chains/ChainFactory.ts
Line: 24:24

Comment:
Use `CHAIN_TYPES.SOLANA` constant from `constants.ts` instead of string literal for consistency and type safety.

```suggestion
			case CHAIN_TYPES.SOLANA:
```

**Context Used:** Rule from `dashboard` - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... ([source](https://app.greptile.com/review/custom-context?memory=0e60096d-0843-4800-801b-f8a78b766fbc))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +41 to +42
static getSupportedChainTypes(): string[] {
return ['solana'];
Copy link

Choose a reason for hiding this comment

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

Use CHAIN_TYPES.SOLANA constant instead of string literal.

Suggested change
static getSupportedChainTypes(): string[] {
return ['solana'];
return [CHAIN_TYPES.SOLANA];

Context Used: Rule from dashboard - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: shared/chains/ChainFactory.ts
Line: 41:42

Comment:
Use `CHAIN_TYPES.SOLANA` constant instead of string literal.

```suggestion
		return [CHAIN_TYPES.SOLANA];
```

**Context Used:** Rule from `dashboard` - Use enum constants (e.g., Chain.SOLANA, Chain.BASE) instead of string literals when comparing chain ... ([source](https://app.greptile.com/review/custom-context?memory=0e60096d-0843-4800-801b-f8a78b766fbc))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

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.

1 participant