feat: Add plugin framework for community extensions#101
feat: Add plugin framework for community extensions#101sainath5001 wants to merge 5 commits intorsksmart:mainfrom
Conversation
sainath5001
commented
Jan 12, 2026
- Implement plugin system with registry, loader, and executor
- Create built-in plugins (transfer, balance) as examples
- Add plugin development documentation
- Update API route to use plugins dynamically
- Update frontend to execute plugins generically
- Add contribution guidelines and examples
- Implement plugin system with registry, loader, and executor - Create built-in plugins (transfer, balance) as examples - Add plugin development documentation - Update API route to use plugins dynamically - Update frontend to execute plugins generically - Add contribution guidelines and examples
src/plugins/builtin/balance.ts
Outdated
| }); | ||
|
|
||
| balance = { | ||
| displayValue: Number(queryBalance.value) / 10e18, |
There was a problem hiding this comment.
The value 10e18 equals 10 × 10^18 = 10^19, not 10^18. It should be 1e18. This causes balances to display 10 times smaller than the actual value.
src/plugins/builtin/transfer.ts
Outdated
| abi: erc20Abi, | ||
| address: tokenAddress as `0x${string}`, | ||
| functionName: "transfer", | ||
| args: [address as `0x${string}`, BigInt(Math.floor(amount))], |
There was a problem hiding this comment.
This truncates the amount to an integer, losing all decimals. Additionally, it doesn't consider the token's decimals (some tokens have 18, others have 6, etc.).
src/plugins/builtin/transfer.ts
Outdated
| let transactionHash: string; | ||
|
|
||
| if (tokenAddress === "trbtc") { | ||
| transactionHash = await sendTransaction(context.config as any, { |
There was a problem hiding this comment.
Multiple instances of context.config as any remove TypeScript's type safety:
src/plugins/types.ts
Outdated
| address?: string; | ||
| isConnected: boolean; | ||
| config: unknown; // Wagmi config | ||
| [key: string]: unknown; // Allow additional context |
There was a problem hiding this comment.
Plugin context is too permissive, this allows injecting any data without validation.
src/plugins/types.ts
Outdated
| address?: string; | ||
| isConnected: boolean; | ||
| config: unknown; // Wagmi config | ||
| [key: string]: unknown; // Allow additional context |
There was a problem hiding this comment.
I think all the // comments are not needed , please take them out (in your entire contribution)
- Add address validation in transfer plugin - Fix TypeScript types (use Config from wagmi) - Unify plugin registration system - Fix balance calculation (use formatEther) - Fix amount handling (use parseUnits with decimals) - Add thread-safety for serverless environments - Fix example plugin types - Remove all comments - Fix constants.ts typo - Make PluginContext strict
|
Hi, thank you for the detailed feedback! I've addressed all the issues:
All changes have been committed and pushed. Ready for re-review! |
src/app/page.tsx
Outdated
| role: "bot", | ||
| content: ( | ||
| try { | ||
| // Execute plugin function dynamically |
There was a problem hiding this comment.
Please take out all the comments, not needed.
- Remove duplicate plugin registration in index.ts - Add JSON.parse error handling in route.ts - Fetch token decimals dynamically from contract - Add React import (ReactNode) in types.ts - Sanitize URL parameters with encodeURIComponent - Add address validation in balance.ts - Verify ERC20 contract before transfer - Replace all console statements with logger - Remove all comments from page.tsx
sainath5001
left a comment
There was a problem hiding this comment.
I’ve resolved the mentioned issues and updated the PR accordingly.
- Fetch token decimals from contract (consistent with transfer.ts) - Use formatUnits instead of formatEther for ERC20 balances - Fixes incorrect display for tokens with non-18 decimals (e.g. USDT 6 decimals)
sainath5001
left a comment
There was a problem hiding this comment.
Done. balance.ts now uses dynamic decimals (formatUnits + decimals from contract), consistent with transfer.ts. Thanks!
|
Build issues resolved. |