-
Notifications
You must be signed in to change notification settings - Fork 11
docs: Update README with comprehensive documentation #11
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
base: main
Are you sure you want to change the base?
Conversation
1.x Updated to Latest Spartan changes
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Plugin Initialization Prematurely Completes
The solanaPlugin.init function prematurely resolves its internal Promise before completing its asynchronous setup (waiting for the TRADER_CHAIN service and registering the chain). This causes the init function to complete prematurely, leading to potential race conditions or incomplete plugin initialization.
src/index.ts#L17-L39
Lines 17 to 39 in 43423f1
| new Promise<void>(async (resolve) => { | |
| resolve(); | |
| const asking = 'solana'; | |
| const serviceType = 'TRADER_CHAIN'; | |
| let traderChainService = runtime.getService(serviceType) as any; | |
| while (!traderChainService) { | |
| console.log(asking, 'waiting for', serviceType, 'service...'); | |
| traderChainService = runtime.getService(serviceType) as any; | |
| if (!traderChainService) { | |
| await new Promise((waitResolve) => setTimeout(waitResolve, 1000)); | |
| } else { | |
| console.log(asking, 'Acquired', serviceType, 'service...'); | |
| } | |
| } | |
| const me = { | |
| name: 'Solana services', | |
| }; | |
| traderChainService.registerChain(me); | |
| console.log('solana init done'); | |
| }); |
Bug: Async Initialization Causes Undefined PublicKey
A race condition exists in the SolanaService constructor where this.publicKey is initialized asynchronously. This allows methods like updateWalletData() to be called before this.publicKey is set. When this.publicKey is undefined, updateWalletData() returns an empty object {}, which violates its Promise<WalletPortfolio> return type. The WalletPortfolio interface requires totalUsd: string and items: Array<Item>, leading to runtime errors when consumers attempt to access these missing properties.
src/service.ts#L181-L188
Lines 181 to 188 in 43423f1
| if (!this.publicKey) { | |
| // can't be warn if we fire every start up | |
| // maybe we just get the pubkey here proper | |
| // or fall back to SOLANA_PUBLIC_KEY | |
| logger.log('solana::updateWalletData - no Public Key yet'); | |
| return {}; | |
| } | |
src/service.ts#L42-L62
Lines 42 to 62 in 43423f1
| */ | |
| constructor(protected runtime: IAgentRuntime) { | |
| super(); | |
| this.exchangeRegistry = {}; | |
| const connection = new Connection( | |
| runtime.getSetting('SOLANA_RPC_URL') || PROVIDER_CONFIG.DEFAULT_RPC | |
| ); | |
| this.connection = connection; | |
| // Initialize publicKey using getWalletKey | |
| getWalletKey(runtime, false) | |
| .then(({ publicKey }) => { | |
| if (!publicKey) { | |
| throw new Error('Failed to initialize public key'); | |
| } | |
| this.publicKey = publicKey; | |
| }) | |
| .catch((error) => { | |
| logger.error('Error initializing public key:', error); | |
| }); | |
| this.subscriptions = new Map(); | |
| } |
Bug: Direct Environment Access Bypasses Configuration
The SOL_ADDRESS is directly accessed via process.env.SOL_ADDRESS in swapToken and executeSwap functions. This bypasses the runtime configuration system (runtime.getSetting) and could lead to failures if the environment variable is not set or differs from the intended runtime setting.
src/actions/swap.ts#L65-L66
plugin-solana/src/actions/swap.ts
Lines 65 to 66 in 43423f1
| const decimals = | |
| inputTokenCA === process.env.SOL_ADDRESS |
src/actions/swap.ts#L283-L287
plugin-solana/src/actions/swap.ts
Lines 283 to 287 in 43423f1
| if (response.inputTokenSymbol?.toUpperCase() === 'SOL') { | |
| response.inputTokenCA = process.env.SOL_ADDRESS; | |
| } | |
| if (response.outputTokenSymbol?.toUpperCase() === 'SOL') { | |
| response.outputTokenCA = process.env.SOL_ADDRESS; |
Was this report helpful? Give feedback by reacting with 👍 or 👎
This PR updates the README.md with comprehensive documentation including:
Generated by the plugins-automation script.