Skip to content

Commit f70c1cd

Browse files
enigmarikkirikkiodilitime
authored
feat: injective plugin (#1764)
* "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 <rikki@mahishasuramardini.mynetworksettings.com> Co-authored-by: Odilitime <janesmith@airmail.cc>
1 parent 8ab8be5 commit f70c1cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+33252
-343
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ SOLANA_ADMIN_PRIVATE_KEY= # This wallet is used to verify NFTs
309309
SOLANA_ADMIN_PUBLIC_KEY= # This wallet is used to verify NFTs
310310
SOLANA_VERIFY_TOKEN= # Authentication token for calling the verification API
311311

312+
# Injective
313+
INJECTIVE_PRIVATE_KEY= #
314+
INJECTIVE_PUBLIC_KEY= #
315+
INJECTIVE_NETWORK= #
312316
# Fallback Wallet Configuration (deprecated)
313317
WALLET_PRIVATE_KEY=
314318
WALLET_PUBLIC_KEY=

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@elizaos/plugin-nft-generation": "workspace:*",
6262
"@elizaos/plugin-node": "workspace:*",
6363
"@elizaos/plugin-solana": "workspace:*",
64+
"@elizaos/plugin-injective": "workspace:*",
6465
"@elizaos/plugin-solana-agentkit": "workspace:*",
6566
"@elizaos/plugin-squid-router": "workspace:*",
6667
"@elizaos/plugin-autonome": "workspace:*",

agent/src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ import { evmPlugin } from "@elizaos/plugin-evm";
7070
import { flowPlugin } from "@elizaos/plugin-flow";
7171
import { fuelPlugin } from "@elizaos/plugin-fuel";
7272
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
73-
import { giphyPlugin } from "@elizaos/plugin-giphy";
7473
import { gitcoinPassportPlugin } from "@elizaos/plugin-gitcoin-passport";
75-
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
7674
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
7775
import { lensPlugin } from "@elizaos/plugin-lensNetwork";
78-
import { letzAIPlugin } from "@elizaos/plugin-letzai";
7976
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
8077
import { nearPlugin } from "@elizaos/plugin-near";
8178
import createNFTCollectionsPlugin from "@elizaos/plugin-nft-collections";
@@ -96,9 +93,13 @@ import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
9693
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
9794
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
9895
import { verifiableLogPlugin } from "@elizaos/plugin-tee-verifiable-log";
99-
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
10096
import { tonPlugin } from "@elizaos/plugin-ton";
10197
import { webSearchPlugin } from "@elizaos/plugin-web-search";
98+
import { injectivePlugin } from "@elizaos/plugin-injective";
99+
import { giphyPlugin } from "@elizaos/plugin-giphy";
100+
import { letzAIPlugin } from "@elizaos/plugin-letzai";
101+
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
102+
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
102103
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
103104
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";
104105

@@ -806,6 +807,10 @@ export async function createAgent(
806807
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
807808
? evmPlugin
808809
: null,
810+
((getSecret(character, "EVM_PUBLIC_KEY") || getSecret(character, "INJECTIVE_PUBLIC_KEY")) &&
811+
getSecret(character, "INJECTIVE_PRIVATE_KEY"))
812+
? injectivePlugin
813+
: null,
809814
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
810815
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
811816
createCosmosPlugin(),

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@0glabs/0g-ts-sdk": "0.2.1",
6262
"@coinbase/coinbase-sdk": "0.10.0",
6363
"@deepgram/sdk": "^3.9.0",
64+
"@injectivelabs/sdk-ts": "^1.14.33",
6465
"@vitest/eslint-plugin": "1.0.1",
6566
"amqplib": "0.10.5",
6667
"csv-parse": "5.6.0",

packages/plugin-injective/Readme.md

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# @elizaos/plugin-injective
2+
3+
A comprehensive plugin for interacting with the Injective chain through ElizaOS.
4+
5+
## Project Structure
6+
7+
```
8+
src/
9+
├── auction.ts # Auction module actions
10+
├── auth.ts # Auth module actions
11+
├── bank.ts # Bank module actions
12+
├── distribution.ts # Distribution module actions
13+
├── exchange.ts # Exchange module actions
14+
├── explorer.ts # Explorer module actions
15+
├── gov.ts # Governance module actions
16+
├── ibc.ts # IBC module actions
17+
├── insurance.ts # Insurance module actions
18+
├── mint.ts # Mint module actions
19+
├── mito.ts # Mito module actions
20+
├── peggy.ts # Peggy module actions
21+
├── permissions.ts # Permissions module actions
22+
├── staking.ts # Staking module actions
23+
├── token-factory.ts # Token Factory module actions
24+
├── wasm.ts # WASM module actions
25+
├── base.ts # Base action creation logic
26+
└── index.ts # Main export file
27+
```
28+
29+
## Module Organization
30+
31+
Each module file follows a consistent organization pattern:
32+
33+
### 1. File Structure
34+
```typescript
35+
// src/[module].ts
36+
37+
import { createGenericAction } from './base';
38+
import * as ModuleTemplates from '@injective/template/[module]';
39+
import * as ModuleExamples from '@injective/examples/[module]';
40+
41+
// Export individual actions
42+
export const Action1 = createGenericAction({...});
43+
export const Action2 = createGenericAction({...});
44+
45+
// Export all actions as a group
46+
export const ModuleActions = [
47+
Action1,
48+
Action2,
49+
// ...other actions
50+
];
51+
```
52+
53+
### 2. Main Export File
54+
```typescript
55+
// src/index.ts
56+
57+
export * from './auction';
58+
export * from './auth';
59+
// ...other module exports
60+
61+
export const InjectiveActions = [
62+
...ExchangeActions,
63+
...AuctionActions,
64+
// ...other module actions
65+
];
66+
```
67+
68+
## Module Descriptions
69+
70+
### auction.ts
71+
Handles auction-related functionality including module parameters, auction rounds, and bidding.
72+
73+
### auth.ts
74+
Manages authentication, account details, and authorization grants.
75+
76+
### bank.ts
77+
Handles account balances, token transfers, and supply queries.
78+
79+
### distribution.ts
80+
Manages reward distribution and withdrawals.
81+
82+
### exchange.ts
83+
Core exchange functionality including spot/derivative markets, orders, and positions.
84+
85+
### explorer.ts
86+
Blockchain explorer functionality including transaction and block queries.
87+
88+
### gov.ts
89+
Handles protocol governance including proposals and voting.
90+
91+
### ibc.ts
92+
Inter-Blockchain Communication functionality.
93+
94+
### insurance.ts
95+
Manages insurance funds and redemptions.
96+
97+
### mint.ts
98+
Controls token minting and inflation parameters.
99+
100+
### mito.ts
101+
Handles Mito-specific functionality.
102+
103+
### peggy.ts
104+
Manages Ethereum bridge operations.
105+
106+
### permissions.ts
107+
Controls role-based access and permissions.
108+
109+
### staking.ts
110+
Manages validator operations and delegations.
111+
112+
### token-factory.ts
113+
Handles token creation and management.
114+
115+
### wasm.ts
116+
Smart contract functionality including deployment and execution.
117+
118+
## Development
119+
120+
### Adding New Actions
121+
122+
1. Add action to appropriate module file:
123+
```typescript
124+
export const NewAction = createGenericAction({
125+
name: 'ACTION_NAME',
126+
description: 'Action description',
127+
template: Templates.template,
128+
examples: Examples.example,
129+
functionName: 'functionName',
130+
validateContent: () => true
131+
});
132+
133+
export const ModuleActions = [
134+
...existingActions,
135+
NewAction
136+
];
137+
```
138+
139+
### Adding New Modules
140+
141+
1. Create new module file:
142+
```typescript
143+
// src/new-module.ts
144+
export const NewModuleActions = [...];
145+
```
146+
147+
2. Add to main exports:
148+
```typescript
149+
// src/index.ts
150+
export * from './new-module';
151+
```
152+
153+
## Installation
154+
155+
```bash
156+
npm install @elizaos/plugin-injective
157+
```
158+
159+
## Usage
160+
161+
```typescript
162+
import { InjectiveActions } from '@elizaos/plugin-injective';
163+
```
164+
165+
## Contributing
166+
Feel free to contribute to more similes, examples and refined templates - for a more robust action contorl.
167+
168+
1. Fork the repository
169+
2. Create your feature branch
170+
3. Commit your changes
171+
4. Push to the branch
172+
5. Create a Pull Request
173+
174+
## License
175+
176+
ISC
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
build/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [
5+
"@typescript-eslint"
6+
],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended"
10+
],
11+
"rules": {
12+
// TypeScript-specific rules
13+
"@typescript-eslint/no-explicit-any": "warn",
14+
"@typescript-eslint/explicit-function-return-type": "off",
15+
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
16+
17+
// General ESLint rules
18+
"no-console": "warn",
19+
"eqeqeq": "error",
20+
"no-duplicate-imports": "error",
21+
"prefer-const": "warn"
22+
}
23+
}

0 commit comments

Comments
 (0)