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 for with PDA #2107

Closed
wants to merge 13 commits into from

Conversation

zo-eth
Copy link
Contributor

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

Code In Plugin For Eliza

Description

Through IQ6900's new inscription standard "Code-In", powerful inscription functionality is provided to Eliza.
Engrave Eliza on the blockchain forever.
All your Character JSON files are input onto the blockchain without compression.
Everyone can read your agent from blocks forever.

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.

You have engraved an eternal record.
Imagine, someone could develop your agent 200 years from now.

Many things will be updated.

Learn more: https://linktr.ee/IQ6900Docs

@odilitime odilitime added the Plugin_new Mark PRs that are a new plugin label Jan 10, 2025
@odilitime odilitime changed the title Added Code In Plugin For Eliza feat: Code In Plugin, load characters from blockchain for iq wallet holders Jan 10, 2025
@odilitime odilitime changed the base branch from main to develop January 10, 2025 18:50
@zo-eth zo-eth changed the title feat: Code In Plugin, load characters from blockchain for iq wallet holders feat: Code In Plugin, load characters from blockchain for with PDA Jan 11, 2025
@wtfsayo
Copy link
Member

wtfsayo commented Jan 14, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new @elizaos/plugin-iq6900 package that enables on-chain character loading for the Eliza agent system. The changes span multiple files across the project, adding functionality to retrieve and load character data from the Solana blockchain. The plugin provides a mechanism for users to inscribe and manage their character files on-chain, with support for version tracking and automatic loading.

Changes

File Change Summary
agent/package.json Added @elizaos/plugin-iq6900 as a workspace dependency
agent/src/index.ts Added loadCharacterFromOnchain() function, modified initializeClients and createAgent to support on-chain character loading
packages/plugin-iq6900/... Created new plugin package with configuration files, README, and source code for blockchain integration
packages/plugin-iq6900/src/index.ts Introduced elizaCodeinPlugin for on-chain character management
packages/plugin-iq6900/src/functions/bringIQData.ts Implemented Solana blockchain interaction functions for fetching transaction data

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: 7

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

Line range hint 254-255: Avoid using spread syntax in reducers to improve performance.

Using the spread operator (...) inside a reducer causes a new object to be created on each iteration, leading to O(n²) time complexity. Modify the accumulator object directly to enhance performance.

Apply this diff:

-    return { ...settings, [settingKey]: value };
+    settings[settingKey] = value;
+    return settings;

Line range hint 309-310: Avoid using spread syntax in reducers to improve performance.

Similar to the previous comment, avoid using the spread operator inside the reducer.

Apply this diff:

-    return { ...settings, [settingKey]: value };
+    settings[settingKey] = value;
+    return settings;

Line range hint 236-289: Remove duplicate 'loadCharacterFromOnchain' function declaration.

The function loadCharacterFromOnchain is declared twice in this file (lines 236-289 and lines 291-344), causing a redeclaration error. Remove one of the declarations to fix this issue.

Delete the duplicate function:

-// Duplicate 'loadCharacterFromOnchain' function starts here
-// Lines 291 to 344
-// Remove these lines to eliminate the duplicate declaration.
🧹 Nitpick comments (6)
packages/plugin-iq6900/src/functions/bringIQData.ts (1)

25-25: Replace 'console.error' with 'elizaLogger.error' for consistent logging.

For consistent logging throughout the application, use elizaLogger.error instead of console.error.

Apply this diff:

-    console.error("Error fetching PDA:", error);
+    elizaLogger.error("Error fetching PDA:", error);

-            console.error("chunk data undefined");
+            elizaLogger.error("Chunk data undefined");

-                    console.error("before data undefined");
+                    elizaLogger.error("Before data undefined");

Also applies to: 116-116, 126-126

agent/src/index.ts (1)

1194-1199: Clarify the logic for loading characters when on-chain data is available.

The current logic may overwrite characters loaded from on-chain data if both onchainJson and charactersArg are present. Ensure that the character loading behavior reflects the intended priority.

Consider updating the conditional statements to reflect the correct loading sequence.

packages/plugin-iq6900/tsup.config.ts (2)

8-8: Remove misleading comment about CommonJS

The format is set to ESM but the comment suggests CommonJS targeting.

-    format: ["esm"], // Ensure you're targeting CommonJS
+    format: ["esm"],

19-20: Remove TODO placeholder comment

The comment "Add other modules you want to externalize" should be removed as it's a development placeholder.

-        // Add other modules you want to externalize
packages/plugin-iq6900/README.md (2)

10-10: Format URLs as markdown links

Bare URLs should be formatted as proper markdown links for better readability.

-Go to the site and engrave your character file on-chain. https://elizacodein.com/
+Go to the site and engrave your character file on-chain. [Code-In Website](https://elizacodein.com/)

-Learn more: https://linktr.ee/IQ6900Docs
+Learn more: [IQ6900 Documentation](https://linktr.ee/IQ6900Docs)

Also applies to: 28-28

🧰 Tools
🪛 Markdownlint (0.37.0)

10-10: null
Bare URL used

(MD034, no-bare-urls)


19-20: Improve setup instructions clarity

The setup instructions lack specific details about the command and environment variable.

-To be sure, right after inscription, wait about 5 minutes and just type pmpn start. You are now all set.
+To be sure, right after inscription:
+1. Wait about 5 minutes
+2. Run `pnpm start` command
+3. You are now all set.
🧰 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)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58e9f7c and 4c93ef2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • agent/package.json (1 hunks)
  • agent/src/index.ts (9 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/eslint.config.mjs
  • packages/plugin-iq6900/tsconfig.json
  • packages/plugin-iq6900/.npmignore
  • packages/plugin-iq6900/package.json
🧰 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)

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

[error] 290-344: Illegal use of an export declaration not at the top level

move this declaration to the top level

(parse)


[error] 291-291: Shouldn't redeclare 'loadCharacterFromOnchain'. Consider to delete it or rename it.

'loadCharacterFromOnchain' is defined here:

(lint/suspicious/noRedeclare)


[error] 255-255: 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)


[error] 310-310: 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)

🔇 Additional comments (1)
agent/package.json (1)

75-75: LGTM!

The plugin dependency is correctly added using workspace syntax.

packages/plugin-iq6900/src/functions/bringIQData.ts Outdated Show resolved Hide resolved
packages/plugin-iq6900/src/functions/bringIQData.ts Outdated Show resolved Hide resolved
agent/src/index.ts Show resolved Hide resolved
agent/src/index.ts Outdated Show resolved Hide resolved
packages/plugin-iq6900/src/types/iq.ts Outdated Show resolved Hide resolved
packages/plugin-iq6900/src/index.ts Outdated Show resolved Hide resolved
packages/plugin-iq6900/src/index.ts Show resolved Hide resolved
@wtfsayo
Copy link
Member

wtfsayo commented Jan 14, 2025

@zo-eth can you resolve these minor issues; lgtm otherwise

@zo-eth zo-eth closed this by deleting the head repository Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plugin_new Mark PRs that are a new plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants