|
| 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 |
0 commit comments