Skip to content

Commit 0ebcad4

Browse files
authored
Merge pull request #11 from elizaos-plugins/fix/respect-configured-chains-only
Fix: Respect configured chains from runtime settings
2 parents ef6a453 + cb07fc9 commit 0ebcad4

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The EVM plugin provides comprehensive functionality for interacting with EVM-com
2020
## Installation
2121

2222
```bash
23-
pnpm install @elizaos/plugin-evm
23+
bun add @elizaos/plugin-evm
2424
```
2525

2626
## Configuration
@@ -182,19 +182,19 @@ Execute the proposal with ID 1 on the 0xdeadbeef00000000000000000000000000000000
182182
2. Install dependencies:
183183

184184
```bash
185-
pnpm install
185+
bun install
186186
```
187187

188188
3. Build the plugin:
189189

190190
```bash
191-
pnpm run build
191+
bun run build
192192
```
193193

194194
4. Run tests:
195195

196196
```bash
197-
pnpm test
197+
bun test
198198
```
199199

200200
## API Reference
@@ -293,7 +293,7 @@ We welcome community feedback and contributions to help prioritize these enhance
293293
The plugin contains tests. Whether you're using **TDD** or not, please make sure to run the tests before submitting a PR:
294294

295295
```bash
296-
pnpm test
296+
bun test
297297
```
298298

299299
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elizaos/plugin-evm",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"type": "module",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/providers/wallet.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import type { SupportedChain } from '../types';
3636

3737
export class WalletProvider {
3838
private cacheKey = 'evm/wallet';
39-
chains: Record<string, Chain> = { ...viemChains };
39+
chains: Record<string, Chain> = {};
4040
account!: PrivateKeyAccount;
4141
runtime: IAgentRuntime;
4242
constructor(
@@ -45,7 +45,9 @@ export class WalletProvider {
4545
chains?: Record<string, Chain>
4646
) {
4747
this.setAccount(accountOrPrivateKey);
48-
this.addChains(chains);
48+
if (chains) {
49+
this.chains = chains;
50+
}
4951
this.runtime = runtime;
5052
}
5153

@@ -159,9 +161,8 @@ export class WalletProvider {
159161
if (!chains) {
160162
return;
161163
}
162-
for (const chain of Object.keys(chains)) {
163-
this.chains[chain] = chains[chain];
164-
}
164+
// Only add the chains that are explicitly provided
165+
this.chains = { ...this.chains, ...chains };
165166
};
166167

167168
private createHttpTransport = (chainName: SupportedChain) => {
@@ -200,17 +201,19 @@ export class WalletProvider {
200201
}
201202

202203
const genChainsFromRuntime = (runtime: IAgentRuntime): Record<string, Chain> => {
203-
// Get chains from settings or use default supported chains
204+
// Get chains from settings - ONLY use configured chains
204205
const configuredChains = (runtime?.character?.settings?.chains?.evm as SupportedChain[]) || [];
205206

206-
// Default chains to include if not specified in settings
207-
const defaultChains = ['mainnet', 'polygon', 'arbitrum', 'base', 'optimism', 'linea'];
207+
// If no chains are configured, default to mainnet and base
208+
const chainsToUse = configuredChains.length > 0 ? configuredChains : ['mainnet', 'base'];
209+
210+
if (!configuredChains.length) {
211+
elizaLogger.warn('No EVM chains configured in settings, defaulting to mainnet and base');
212+
}
208213

209-
// Combine configured chains with defaults, removing duplicates
210-
const chainNames = [...new Set([...configuredChains, ...defaultChains])];
211214
const chains: Record<string, Chain> = {};
212215

213-
for (const chainName of chainNames) {
216+
for (const chainName of chainsToUse) {
214217
try {
215218
// Try to get RPC URL from settings using different formats
216219
let rpcUrl = runtime.getSetting(`ETHEREUM_PROVIDER_${chainName.toUpperCase()}`);
@@ -227,6 +230,7 @@ const genChainsFromRuntime = (runtime: IAgentRuntime): Record<string, Chain> =>
227230

228231
const chain = WalletProvider.genChainFromName(chainName, rpcUrl);
229232
chains[chainName] = chain;
233+
elizaLogger.log(`Configured chain: ${chainName}`);
230234
} catch (error) {
231235
elizaLogger.error(`Error configuring chain ${chainName}:`, error);
232236
}

0 commit comments

Comments
 (0)