Skip to content

Commit

Permalink
feat: injective plugin (elizaOS#1764)
Browse files Browse the repository at this point in the history
* "plugin: init injective integration and skeleton"

* "wip : skeleton partially done"

* "wip: finished fetch"

* "chore : fix format"

* "chore : renamed files"

* "wip: completed grpc endpoints for onchain queries"

* "chore : removed unwanted files"

* "wip : adding templates + integrating onchain functions"

* "wip : added inital version of templates"

* "wip : testing the plugin"

* "wip : skeleton for actions, providers"

* "chore: renamed and fixed relative imports"

* "wip : added message broadcasting rpcs"

* "feat : finished initial version of message parsing and querying"

* "chore : refactor package.json"

* "chore: added chain message broadcasters to the InjectiveGrpcBase"

* "wip : restructure actions and providers"

* "chore : fix conflicts on lockfile"

* "chore: added readme.md to use injective-sdk-client-ts"

* "chore : renamed the package to ensure consistency and updated the docs"

* "chore : refactored function args to make it easy to define function schema"

* "fix : missing imports for wasm"

* "wip : refactor injective types and templates"

* "chore : refactored the types into different files for maintainability"

* "chore : fmt"

* "wip : refactor the responses for standard message parsing"

* "chore : refactored all modules to ouput same a common message type"

* "wip : minimal tests"

* "fix: the grpc init + bug in making request"

* "wip : done with skeleton templates"

* "chore : reorgranize files"

* "wip : adding exchange templates"

* "chore : added fmt and finished comprehensive template for exchange module"

* "wip: refactored templates for auction and bank"

* "wip : almost done refactoring all the templates to add both the request, response"

* "chore : renamed to gov for consistency and added the explorer module"

* "fix : removed minor import into exchange"

* "wip : added the base action"

* "feat: finished integrating actions, wip fix for templates and examples"

* "chore : refactored all the request and response templates"

* "chore : fmt templates"

* "chore : added modules examples except exchange, fixed a few relative imports"

* "chore: finished integrating exchange examples"

* "feat: finished all integrations for injective-plugin"

* "fix : revert fmt"

* "chore : bump injective-ts sdk version"

* "fix : dependency issues"

* "fix : complex dependency issue from esm imports"

* "chore : refactored the rpc to take either inj address or eth address"

* "wip: fixed rpc initialization"

* "fix: Refactored action template"

* "chore : resolve lock file conflicts"

* "chore : added config params in .env.examples"

* "wip : improve response prompts from agent"

* "chore : refactored similes, for better interpretation"

* "wip: integrated mito's constant product market maker - amm"

* "feat: added Initial Dex offering and action, for agents to autonomously raise funds"

* "chore : revert defaultCharacter to LLAMA"

---------

Co-authored-by: rikki <[email protected]>
Co-authored-by: Odilitime <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2025
1 parent 8ab8be5 commit f70c1cd
Show file tree
Hide file tree
Showing 128 changed files with 33,252 additions and 343 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ SOLANA_ADMIN_PRIVATE_KEY= # This wallet is used to verify NFTs
SOLANA_ADMIN_PUBLIC_KEY= # This wallet is used to verify NFTs
SOLANA_VERIFY_TOKEN= # Authentication token for calling the verification API

# Injective
INJECTIVE_PRIVATE_KEY= #
INJECTIVE_PUBLIC_KEY= #
INJECTIVE_NETWORK= #
# Fallback Wallet Configuration (deprecated)
WALLET_PRIVATE_KEY=
WALLET_PUBLIC_KEY=
Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-injective": "workspace:*",
"@elizaos/plugin-solana-agentkit": "workspace:*",
"@elizaos/plugin-squid-router": "workspace:*",
"@elizaos/plugin-autonome": "workspace:*",
Expand Down
13 changes: 9 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ import { evmPlugin } from "@elizaos/plugin-evm";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { gitcoinPassportPlugin } from "@elizaos/plugin-gitcoin-passport";
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { lensPlugin } from "@elizaos/plugin-lensNetwork";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
import createNFTCollectionsPlugin from "@elizaos/plugin-nft-collections";
Expand All @@ -96,9 +93,13 @@ import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { verifiableLogPlugin } from "@elizaos/plugin-tee-verifiable-log";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { injectivePlugin } from "@elizaos/plugin-injective";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";

Expand Down Expand Up @@ -806,6 +807,10 @@ export async function createAgent(
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? evmPlugin
: null,
((getSecret(character, "EVM_PUBLIC_KEY") || getSecret(character, "INJECTIVE_PUBLIC_KEY")) &&
getSecret(character, "INJECTIVE_PRIVATE_KEY"))
? injectivePlugin
: null,
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
createCosmosPlugin(),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@0glabs/0g-ts-sdk": "0.2.1",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
"@injectivelabs/sdk-ts": "^1.14.33",
"@vitest/eslint-plugin": "1.0.1",
"amqplib": "0.10.5",
"csv-parse": "5.6.0",
Expand Down
176 changes: 176 additions & 0 deletions packages/plugin-injective/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# @elizaos/plugin-injective

A comprehensive plugin for interacting with the Injective chain through ElizaOS.

## Project Structure

```
src/
├── auction.ts # Auction module actions
├── auth.ts # Auth module actions
├── bank.ts # Bank module actions
├── distribution.ts # Distribution module actions
├── exchange.ts # Exchange module actions
├── explorer.ts # Explorer module actions
├── gov.ts # Governance module actions
├── ibc.ts # IBC module actions
├── insurance.ts # Insurance module actions
├── mint.ts # Mint module actions
├── mito.ts # Mito module actions
├── peggy.ts # Peggy module actions
├── permissions.ts # Permissions module actions
├── staking.ts # Staking module actions
├── token-factory.ts # Token Factory module actions
├── wasm.ts # WASM module actions
├── base.ts # Base action creation logic
└── index.ts # Main export file
```

## Module Organization

Each module file follows a consistent organization pattern:

### 1. File Structure
```typescript
// src/[module].ts

import { createGenericAction } from './base';
import * as ModuleTemplates from '@injective/template/[module]';
import * as ModuleExamples from '@injective/examples/[module]';

// Export individual actions
export const Action1 = createGenericAction({...});
export const Action2 = createGenericAction({...});

// Export all actions as a group
export const ModuleActions = [
Action1,
Action2,
// ...other actions
];
```

### 2. Main Export File
```typescript
// src/index.ts

export * from './auction';
export * from './auth';
// ...other module exports

export const InjectiveActions = [
...ExchangeActions,
...AuctionActions,
// ...other module actions
];
```

## Module Descriptions

### auction.ts
Handles auction-related functionality including module parameters, auction rounds, and bidding.

### auth.ts
Manages authentication, account details, and authorization grants.

### bank.ts
Handles account balances, token transfers, and supply queries.

### distribution.ts
Manages reward distribution and withdrawals.

### exchange.ts
Core exchange functionality including spot/derivative markets, orders, and positions.

### explorer.ts
Blockchain explorer functionality including transaction and block queries.

### gov.ts
Handles protocol governance including proposals and voting.

### ibc.ts
Inter-Blockchain Communication functionality.

### insurance.ts
Manages insurance funds and redemptions.

### mint.ts
Controls token minting and inflation parameters.

### mito.ts
Handles Mito-specific functionality.

### peggy.ts
Manages Ethereum bridge operations.

### permissions.ts
Controls role-based access and permissions.

### staking.ts
Manages validator operations and delegations.

### token-factory.ts
Handles token creation and management.

### wasm.ts
Smart contract functionality including deployment and execution.

## Development

### Adding New Actions

1. Add action to appropriate module file:
```typescript
export const NewAction = createGenericAction({
name: 'ACTION_NAME',
description: 'Action description',
template: Templates.template,
examples: Examples.example,
functionName: 'functionName',
validateContent: () => true
});

export const ModuleActions = [
...existingActions,
NewAction
];
```

### Adding New Modules

1. Create new module file:
```typescript
// src/new-module.ts
export const NewModuleActions = [...];
```

2. Add to main exports:
```typescript
// src/index.ts
export * from './new-module';
```

## Installation

```bash
npm install @elizaos/plugin-injective
```

## Usage

```typescript
import { InjectiveActions } from '@elizaos/plugin-injective';
```

## Contributing
Feel free to contribute to more similes, examples and refined templates - for a more robust action contorl.

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## License

ISC
3 changes: 3 additions & 0 deletions packages/plugin-injective/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
build/
23 changes: 23 additions & 0 deletions packages/plugin-injective/injective-sdk-client-ts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
// TypeScript-specific rules
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],

// General ESLint rules
"no-console": "warn",
"eqeqeq": "error",
"no-duplicate-imports": "error",
"prefer-const": "warn"
}
}
Loading

0 comments on commit f70c1cd

Please sign in to comment.