You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the wallet provider contains multiple hardcoded data sources (BirdEye, Codex) which makes the code:
Hard to maintain
Difficult to test
It is not flexible for users who want to use different data sources
Proposed Solution:
Create a plugin system for data providers:
// Example structure:
interface TokenDataProvider {
getTokenPrices(tokens: string[]): Promise<Prices>;
getWalletTokens(wallet: string): Promise<WalletData>;
}
class BirdEyeProvider implements TokenDataProvider {
// BirdEye specific implementation
}
class CodexProvider implements TokenDataProvider {
// Codex specific implementation
}
Benefits:
Easy to add new data providers
Users can choose their preferred data source
3. Better testing isolation
Cleaner code organization
export class WalletProvider {
constructor(
private connection: Connection,
private walletPublicKey: PublicKey,
private dataProvider: TokenDataProvider // 👈 Inject provider
) {
this.cache = new NodeCache({ stdTTL: 300 });
}
async fetchPortfolioValue(runtime): Promise<WalletPortfolio> {
// Use injected provider instead of hardcoded API calls
const data = await this.dataProvider.getWalletTokens(
this.walletPublicKey.toBase58()
);
// ... rest of the logic
}
}
The text was updated successfully, but these errors were encountered:
Hello @daizhengxue! Welcome to the ai16z community. Thank you for opening your first issue; we appreciate your contribution. You are now a ai16z contributor!
Description:
Currently, the wallet provider contains multiple hardcoded data sources (BirdEye, Codex) which makes the code:
Hard to maintain
Difficult to test
It is not flexible for users who want to use different data sources
Proposed Solution:
Create a plugin system for data providers:
Benefits:
Easy to add new data providers
Users can choose their preferred data source
3. Better testing isolation
Cleaner code organization
The text was updated successfully, but these errors were encountered: