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: Add more actions to Abstract Plugin #2531

Merged
merged 7 commits into from
Jan 20, 2025

Conversation

jonathangus
Copy link
Contributor

@jonathangus jonathangus commented Jan 19, 2025

abstract.plugin.mp4

Relates to

Follow up on #2207

Risks

Low

Background

What does this PR do?

  • Add deploy token action
  • Add get balance action
  • refactored transfer action
  • cleaned up the code

What kind of change is this?

Improvements

Documentation changes needed?

Testing

Where should a reviewer start?

Detailed testing steps

Discord username

@0xheavydev

Summary by CodeRabbit

Release Notes

  • New Features

    • Added token balance checking functionality
    • Added ERC20 token deployment capability
    • Enhanced token transfer action with improved address resolution
  • Improvements

    • Updated dependency for Abstract Global Wallet client
    • Added development script for continuous monitoring
    • Improved error handling for private key and address validation
  • Changes

    • Removed deprecated ERC20 token override constant
    • Restructured utility functions for better address and token management

Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/plugin-abstract/src/actions/deployTokenAction.ts

Oops! Something went wrong! :(

ESLint: 9.18.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

📝 Walkthrough

Walkthrough

The pull request introduces significant enhancements to the Abstract plugin, focusing on expanding token-related functionalities. It adds two new actions for token deployment and balance retrieval, updates dependency versions, and refactors utility functions for improved address resolution and token management. The changes aim to provide more comprehensive blockchain interaction capabilities within the plugin ecosystem.

Changes

File Change Summary
package.json Updated @abstract-foundation/agw-client to version 1.0.1, added dev script
src/actions/deployTokenAction.ts New action for ERC20 token deployment with robust validation
src/actions/getBalanceAction.ts New action to retrieve token balances for specified addresses
src/actions/transferAction.ts Enhanced transfer action with improved address resolution and validation
src/constants/basicToken.ts Added ABI and bytecode for ERC20 token contract
src/index.ts Added new actions to abstractPlugin
src/utils/viemHelpers.ts New utility functions for address resolution and token management

Possibly related PRs

Suggested Labels

Needs Testing, Plugin_new

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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: 8

🧹 Nitpick comments (4)
packages/plugin-abstract/src/utils/viemHelpers.ts (1)

31-39: Add retry logic and timeout configurations to HTTP clients.

The HTTP clients lack important production-ready configurations.

 export const ethereumClient = createPublicClient({
 	chain: mainnet,
-	transport: http(),
+	transport: http({
+		timeout: 30000,
+		retryCount: 3,
+		retryDelay: 1000,
+	}),
 });
packages/plugin-abstract/src/actions/deployTokenAction.ts (2)

144-148: Avoid casting to 'any' to maintain type safety

Casting abstractClient to any bypasses TypeScript's type checking, potentially leading to runtime errors. Consider updating the type definitions to properly represent the return type of createAbstractClient.


241-241: Use placeholder values in examples

Line 241 includes a contract address and transaction hash that appear real. Replace them with placeholders to avoid confusion.

Apply this diff:

-    text: "Successfully deployed MyToken (MTK) with 1000000 initial supply.\nContract address: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b\nTransaction hash: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b",
+    text: "Successfully deployed MyToken (MTK) with 1000000 initial supply.\nContract address: <CONTRACT_ADDRESS>\nTransaction hash: <TRANSACTION_HASH>",
packages/plugin-abstract/src/actions/transferAction.ts (1)

203-207: Avoid casting to 'any' to maintain type safety

Casting abstractClient to any bypasses TypeScript's type checking, potentially leading to runtime errors. Consider updating the type definitions to properly represent the return type of createAbstractClient.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cfd1f48 and 2d1595c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • packages/plugin-abstract/package.json (1 hunks)
  • packages/plugin-abstract/src/actions/deployTokenAction.ts (1 hunks)
  • packages/plugin-abstract/src/actions/getBalanceAction.ts (1 hunks)
  • packages/plugin-abstract/src/actions/index.ts (1 hunks)
  • packages/plugin-abstract/src/actions/transferAction.ts (2 hunks)
  • packages/plugin-abstract/src/constants/basicToken.ts (1 hunks)
  • packages/plugin-abstract/src/constants/index.ts (0 hunks)
  • packages/plugin-abstract/src/environment.ts (1 hunks)
  • packages/plugin-abstract/src/hooks/useGetAccount.ts (1 hunks)
  • packages/plugin-abstract/src/hooks/useGetWalletClient.ts (1 hunks)
  • packages/plugin-abstract/src/index.ts (1 hunks)
  • packages/plugin-abstract/src/utils/index.ts (1 hunks)
  • packages/plugin-abstract/src/utils/validateContext.ts (0 hunks)
  • packages/plugin-abstract/src/utils/viemHelpers.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/plugin-abstract/src/constants/index.ts
  • packages/plugin-abstract/src/utils/validateContext.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/plugin-abstract/src/utils/index.ts
  • packages/plugin-abstract/src/environment.ts
  • packages/plugin-abstract/src/hooks/useGetWalletClient.ts
🧰 Additional context used
🪛 Gitleaks (8.21.2)
packages/plugin-abstract/src/actions/getBalanceAction.ts

54-54: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

packages/plugin-abstract/src/actions/transferAction.ts

61-61: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (7)
packages/plugin-abstract/src/utils/viemHelpers.ts (1)

14-22: Verify usage of imported types and functions.

Several imported entities appear unused in this file.

✅ Verification successful

All imports are actively used in the codebase.

The imported types and functions are used extensively throughout the project for:

  • Wallet implementations
  • Client configurations
  • Account management
  • Blockchain interactions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of potentially unused imports
rg -l "Account|Client(?!.*Public)|createClient|createWalletClient|Transport|toAccount" --type ts

Length of output: 394


Script:

#!/bin/bash
# Search for Account usage
rg "Account[^a-zA-Z]" --type ts

# Search for Client usage
rg "Client[^a-zA-Z]" --type ts

# Search for specific function usage
rg "(createClient|createWalletClient|toAccount)" --type ts

# Search for Transport type usage
rg "Transport[^a-zA-Z]" --type ts

# Use ast-grep to find type annotations
ast-grep --pattern 'type $_ = $_ extends Account'
ast-grep --pattern 'type $_ = Transport'

Length of output: 68025

packages/plugin-abstract/src/actions/index.ts (1)

2-3: LGTM! New action exports align with PR objectives.

packages/plugin-abstract/src/index.ts (1)

3-3: LGTM! Plugin configuration properly includes new actions.

Also applies to: 8-8

packages/plugin-abstract/src/hooks/useGetAccount.ts (1)

6-10: Great addition of error handling!

The removal of the non-null assertion operator and addition of explicit error handling improves code robustness.

packages/plugin-abstract/src/constants/basicToken.ts (1)

1-331: Well-structured ERC20 ABI with comprehensive error handling!

The ABI includes all standard ERC20 functions, events, and proper error types for common scenarios.

packages/plugin-abstract/package.json (2)

28-29: LGTM! Development workflow enhancement.

Added watch mode for development while maintaining consistent build flags.


22-22: Verify the major version upgrade of @abstract-foundation/agw-client.

The dependency has been upgraded from ^0.1.7 to 1.0.1, which is a major version change that might include breaking changes.

Let's verify the version and check for any known issues:

✅ Verification successful

The upgrade to @abstract-foundation/[email protected] looks safe.

The package is used correctly in transferAction.ts and deployTokenAction.ts, following the documented patterns. The version is current and actively maintained.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest version and release info
npm view @abstract-foundation/agw-client versions --json | jq -r '.[-1]'
npm view @abstract-foundation/agw-client time --json | jq '."1.0.1"'

# Check for deprecation warnings
npm view @abstract-foundation/agw-client deprecated

Length of output: 232


Script:

#!/bin/bash
# Check for CHANGELOG.md in the repository
fd -t f -e md -i changelog

# Look for migration guides or upgrade notes in docs
fd -t f -i -e md upgrade guide migration

# Search for breaking changes in commit messages
git log --grep="BREAKING CHANGE" --grep="breaking change" --grep="major version" -i --since="2024-01-01"

Length of output: 341


Script:

#!/bin/bash
# Check package readme
npm view @abstract-foundation/agw-client readme

# Find usage of the package in the codebase
rg -l "@abstract-foundation/agw-client" --type ts --type js

# Look for imports or requires of this package
ast-grep --pattern 'import $_ from "@abstract-foundation/agw-client"'
ast-grep --pattern 'require("@abstract-foundation/agw-client")'

Length of output: 6393

@cygaar
Copy link
Collaborator

cygaar commented Jan 19, 2025

Love this

@jonathangus jonathangus changed the title Feat: Add more actions to Abstract Plugin feat: Add more actions to Abstract Plugin Jan 19, 2025
@wtfsayo wtfsayo self-requested a review January 20, 2025 09:27
@wtfsayo wtfsayo enabled auto-merge (squash) January 20, 2025 12:10
@wtfsayo wtfsayo merged commit 02a4b61 into elizaOS:develop Jan 20, 2025
5 of 7 checks passed
mgunnin added a commit to mgunnin/kairos that referenced this pull request Jan 20, 2025
* upstream/develop:
  test configuration and tests for client-lens (elizaOS#2534)
  chore(attempt): optimize pnpm cache configuration (elizaOS#2556)
  feat: add a way to create/store/restore agents in the filesystem (elizaOS#2389)
  chore: optimize pnpm cache configuration (elizaOS#2555)
  chore: remove cleanup step from integration tests workflow (elizaOS#2553)
  feat: Add more actions to Abstract Plugin (elizaOS#2531)
  feat: add anthropic image provider for vision (elizaOS#2524)
  feat: improve integrationtests workflow caching (elizaOS#2551)
  feat: Updated READ.me file with pre-requisites to enable telegram bot (elizaOS#2547)
  feat(plugin-devin): implement client-agnostic Devin plugin (elizaOS#2549)
  use generateObject
  handle undefined env variable
  feat:add plugin-lightning (elizaOS#2429)
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.

3 participants