Skip to content
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

feat: Code In Plugin, load characters from blockchain #2371

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

zo-eth
Copy link
Contributor

@zo-eth zo-eth commented Jan 16, 2025

Relates to

Re-made due to environmental conflict

Risks

.env file is already exist, please check it once and remove the .env

Background

What does this PR do?

connect to IQ on-chain standard "code-in"

What kind of change is this?

Re-made due to environmental conflict

Detailed testing steps

inscription

Onchain git

  • Commit your update:
    Update your files anytime.
    On our site, your files are managed in a format similar to GitHub,
    and our plugin automatically loads your latest agent file.

Let's get started

  • Edit your .env: write down IQ_WALLET_ADDRESS to your wallet address that you used on website.
    To be sure, right after inscription, wait about 5 minutes and just type pmpn start. You are now all set.

Discord username

zo_eth

@wtfsayo
Copy link
Member

wtfsayo commented Jan 16, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new IQ6900 plugin for the Eliza agent system, enabling on-chain character JSON loading. It adds configuration options in the .env.example file, creates a new package for the plugin, and modifies the agent's loading mechanism to support retrieving character configurations directly from the Solana blockchain. The implementation allows users to inscribe and retrieve character JSONs using a wallet-based approach.

Changes

File Change Summary
.env.example Added two new configuration entries: IQ_WALLET_ADDRESS and IQSOlRPC for IQ integration
agent/package.json Added @elizaos/plugin-iq6900 as a workspace dependency
agent/src/index.ts Added loadCharacterFromOnchain function, modified character loading logic to support on-chain retrieval
packages/plugin-iq6900/ Created new plugin package with configuration files, README, and source code for blockchain-based character loading

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🔭 Outside diff range comments (1)
packages/plugin-iq6900/src/functions/bringIQData.ts (1)

Line range hint 218-218: Avoid using spread syntax in accumulator to prevent performance issues

Using the spread operator ...settings within the .reduce accumulator can lead to O(n²) time complexity. Consider mutating the accumulator object directly for better performance.

Apply this diff to fix the issue:

-               return { ...settings, [settingKey]: value };
+               settings[settingKey] = value;
+               return settings;
🧹 Nitpick comments (8)
packages/plugin-iq6900/src/functions/bringIQData.ts (1)

Line range hint 202-202: Avoid logging sensitive data

Logging the entire jsonText may expose sensitive information. Consider removing or sanitizing this log statement in production.

agent/src/index.ts (2)

202-202: Avoid logging sensitive data

Logging jsonText may expose sensitive information. Consider removing or limiting this log statement.


1189-1189: Clarify logical condition with parentheses

The condition in the if statement may not evaluate as intended due to operator precedence. Adding parentheses can clarify the logic.

Apply this diff:

-        if (!onchainJson && charactersArg || hasValidRemoteUrls()) {
+        if ((!onchainJson && charactersArg) || hasValidRemoteUrls()) {
packages/plugin-iq6900/src/types/iq.ts (1)

3-5: Avoid unnecessary async IIFE for top-level await

The use of an async IIFE with await is unnecessary here. You can simplify the code by assigning the promise directly to onchainJson without the extra function.

Apply this diff:

-const onchainJson = await (async () => {
-    return await bringAgentWithWalletAddress();
-})();
+const onchainJson = await bringAgentWithWalletAddress();
packages/plugin-iq6900/README.md (2)

10-10: Enhance documentation formatting.

Wrap URLs in proper markdown syntax for better readability.

-https://elizacodein.com/
+[Eliza Code-In Website](https://elizacodein.com/)

-https://iq6900.gitbook.io/iq6900/eliza-code-in
+[Learn More](https://iq6900.gitbook.io/iq6900/eliza-code-in)

Also applies to: 28-28

🧰 Tools
🪛 Markdownlint (0.37.0)

10-10: null
Bare URL used

(MD034, no-bare-urls)


19-20: Clarify setup instructions.

The setup instructions could be more explicit about the waiting period and command.

-To be sure, right after inscription, wait about 5 minutes and just type pmpn start. You are now all set.
+After inscription, please:
+1. Wait approximately 5 minutes for the transaction to finalize
+2. Run `pnpm start` to initialize the plugin
+3. Your agent will now load character data from the blockchain
🧰 Tools
🪛 LanguageTool

[grammar] ~19-~19: It appears that an article is missing.
Context: ...to your wallet address that you used on website. To be sure, right after inscription, w...

(IN_WEBSITE)

.env.example (2)

364-367: Enhance documentation with JSON format example.

Consider adding an example of the expected JSON character file format to help users understand what they need to inscribe.


368-369: Fix configuration inconsistencies and consider security implications.

  1. The spacing around the equals sign in IQSOlRPC is inconsistent with other configurations.
  2. Consider using a configurable RPC URL instead of hardcoding it.

Apply this diff to fix the spacing and make the RPC URL configurable:

 IQ_WALLET_ADDRESS=              # If you enter the wallet address used on the site, the most recently inscribed json will be loaded.
-IQSOlRPC =  https://api.mainnet-beta.solana.com
+IQ_SOLANA_RPC_URL=https://api.mainnet-beta.solana.com  # Override this with your preferred Solana RPC endpoint
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cfbd18 and 8d299b7.

📒 Files selected for processing (12)
  • .env.example (1 hunks)
  • agent/package.json (1 hunks)
  • agent/src/index.ts (4 hunks)
  • packages/plugin-iq6900/.npmignore (1 hunks)
  • packages/plugin-iq6900/README.md (1 hunks)
  • packages/plugin-iq6900/eslint.config.mjs (1 hunks)
  • packages/plugin-iq6900/package.json (1 hunks)
  • packages/plugin-iq6900/src/functions/bringIQData.ts (1 hunks)
  • packages/plugin-iq6900/src/index.ts (1 hunks)
  • packages/plugin-iq6900/src/types/iq.ts (1 hunks)
  • packages/plugin-iq6900/tsconfig.json (1 hunks)
  • packages/plugin-iq6900/tsup.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • packages/plugin-iq6900/.npmignore
  • packages/plugin-iq6900/eslint.config.mjs
  • packages/plugin-iq6900/tsconfig.json
  • packages/plugin-iq6900/tsup.config.ts
🧰 Additional context used
🪛 LanguageTool
packages/plugin-iq6900/README.md

[grammar] ~19-~19: It appears that an article is missing.
Context: ...to your wallet address that you used on website. To be sure, right after inscription, w...

(IN_WEBSITE)

🪛 Markdownlint (0.37.0)
packages/plugin-iq6900/README.md

10-10: null
Bare URL used

(MD034, no-bare-urls)


28-28: null
Bare URL used

(MD034, no-bare-urls)

🪛 GitHub Actions: smoke-test
packages/plugin-iq6900/src/index.ts

[error] 429-429: Type mismatch error: Argument of type 'Connection' is not assignable to parameter of type 'Connection'. This suggests a version mismatch between @solana/web3.js dependencies across different packages.

agent/src/index.ts

[error] 429-429: Type mismatch error: Argument of type 'Connection' is not assignable to parameter of type 'Connection'. This suggests a version mismatch between @solana/web3.js dependencies across different packages.

🪛 Biome (1.9.4)
agent/src/index.ts

[error] 218-218: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: integration-tests
🔇 Additional comments (2)
packages/plugin-iq6900/src/index.ts (1)

7-14: Implementation appears incomplete.

The plugin structure is defined but contains empty arrays for actions, providers, and evaluators. This seems inconsistent with the plugin's purpose of loading on-chain character data.

Would you like me to help implement the necessary actions and providers for character data loading?

agent/package.json (1)

73-73: LGTM!

The workspace dependency is correctly configured.

packages/plugin-iq6900/src/functions/bringIQData.ts Outdated Show resolved Hide resolved
agent/src/index.ts Outdated Show resolved Hide resolved
agent/src/index.ts Outdated Show resolved Hide resolved
packages/plugin-iq6900/src/index.ts Show resolved Hide resolved
packages/plugin-iq6900/package.json Outdated Show resolved Hide resolved
wtfsayo and others added 6 commits January 16, 2025 20:43
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@wtfsayo wtfsayo changed the title feat: Code In Plugin, load characters from blockchain for with PDA feat: Code In Plugin, load characters from blockchain Jan 16, 2025
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