Skip to content

Commit 207f87c

Browse files
ELIZAAI-9 Added code review fixes. Eslint config refactor
1 parent b3f5435 commit 207f87c

File tree

6 files changed

+322
-414
lines changed

6 files changed

+322
-414
lines changed

packages/adapter-sqlite/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@ai16z/eliza": "workspace:*",
99
"@types/better-sqlite3": "7.6.12",
10-
"better-sqlite3": "^11.7.0",
10+
"better-sqlite3": "11.6.0",
1111
"sqlite-vec": "0.1.6"
1212
},
1313
"devDependencies": {
+1-37
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
11
import eslintGlobalConfig from "../../eslint.config.mjs";
22

3-
export default [
4-
...eslintGlobalConfig,
5-
{
6-
rules: {
7-
indent: ["error", 2],
8-
'padding-line-between-statements': [
9-
'error',
10-
// Blank line between "use strict" (or other directives) and imports
11-
{ blankLine: 'always', prev: 'directive', next: 'import' },
12-
13-
// No blank lines between import statements
14-
{ blankLine: 'never', prev: 'import', next: 'import' },
15-
16-
// One blank line after the last import statement
17-
{
18-
blankLine: 'always',
19-
prev: 'import',
20-
next: ['const', 'let', 'var', 'function', 'expression', 'if', 'block', 'class', 'export', 'block-like']
21-
},
22-
23-
{ blankLine: 'always', prev: '*', next: 'return' },
24-
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
25-
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
26-
{ blankLine: 'always', prev: '*', next: 'block-like' }
27-
],
28-
"no-unused-vars": [
29-
"error",
30-
{
31-
argsIgnorePattern: "^_",
32-
varsIgnorePattern: "^_",
33-
ignoreRestSiblings: true,
34-
},
35-
],
36-
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
37-
},
38-
},
39-
];
3+
export default [...eslintGlobalConfig];
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,161 @@
11
import {
2-
CosmosWalletProvider,
3-
genCosmosChainsFromRuntime,
4-
initWalletProvider,
2+
CosmosWalletProvider,
3+
genCosmosChainsFromRuntime,
4+
initWalletProvider,
55
} from "../providers/wallet.ts";
66
import {
7-
composeContext,
8-
generateObjectDeprecated,
9-
HandlerCallback,
10-
IAgentRuntime,
11-
Memory,
12-
ModelClass,
13-
State,
7+
composeContext,
8+
generateObjectDeprecated,
9+
HandlerCallback,
10+
IAgentRuntime,
11+
Memory,
12+
ModelClass,
13+
State,
1414
} from "@ai16z/eliza";
1515
import { balanceTemplate } from "../templates";
1616
import { z } from "zod";
1717

1818
export class BalanceAction {
19-
constructor(private cosmosWalletProvider: CosmosWalletProvider) {
20-
this.cosmosWalletProvider = cosmosWalletProvider;
21-
}
19+
constructor(private cosmosWalletProvider: CosmosWalletProvider) {
20+
this.cosmosWalletProvider = cosmosWalletProvider;
21+
}
2222

23-
async getBalance() {
24-
try {
25-
const activeChain = this.cosmosWalletProvider.getActiveChain();
26-
const address = this.cosmosWalletProvider.getAddress();
27-
const balance = await this.cosmosWalletProvider.getWalletBalance();
23+
async getBalance() {
24+
try {
25+
const activeChain = this.cosmosWalletProvider.getActiveChain();
26+
const address = this.cosmosWalletProvider.getAddress();
27+
const balance = await this.cosmosWalletProvider.getWalletBalance();
2828

29-
return `Address: ${address}\nBalance: ${JSON.stringify(balance, null, 2)}, chain name: ${activeChain}`;
30-
} catch (error) {
31-
console.error("Error in Cosmos wallet provider:", error);
29+
return `Address: ${address}\nBalance: ${JSON.stringify(balance, null, 2)}, chain name: ${activeChain}`;
30+
} catch (error) {
31+
console.error("Error in Cosmos wallet provider:", error);
3232

33-
return null;
33+
return null;
34+
}
3435
}
35-
}
3636
}
3737

3838
export const balanceAction = {
39-
name: "COSMOS_WALLET_BALANCE",
40-
description: "Action for fetching wallet balance on given chain",
41-
handler: async (
42-
_runtime: IAgentRuntime,
43-
_message: Memory,
44-
state: State,
45-
_options: { [key: string]: unknown },
46-
_callback: HandlerCallback
47-
) => {
48-
console.log("COSMOS_WALLET_BALANCE action handler called");
39+
name: "COSMOS_WALLET_BALANCE",
40+
description: "Action for fetching wallet balance on given chain",
41+
handler: async (
42+
_runtime: IAgentRuntime,
43+
_message: Memory,
44+
state: State,
45+
_options: { [key: string]: unknown },
46+
_callback: HandlerCallback
47+
) => {
48+
console.log("COSMOS_WALLET_BALANCE action handler called");
4949

50-
// Compose transfer context
51-
const transferContext = composeContext({
52-
state: state,
53-
template: balanceTemplate,
54-
templatingEngine: "handlebars",
55-
});
50+
// Compose transfer context
51+
const transferContext = composeContext({
52+
state: state,
53+
template: balanceTemplate,
54+
templatingEngine: "handlebars",
55+
});
5656

57-
// Generate transfer content
58-
const content = await generateObjectDeprecated({
59-
runtime: _runtime,
60-
context: transferContext,
61-
modelClass: ModelClass.SMALL,
62-
});
57+
// Generate transfer content
58+
const content = await generateObjectDeprecated({
59+
runtime: _runtime,
60+
context: transferContext,
61+
modelClass: ModelClass.SMALL,
62+
});
6363

64-
const balanceContentValidator = z.object({
65-
chainName: z.string(),
66-
});
64+
const balanceContentValidator = z.object({
65+
chainName: z.string(),
66+
});
6767

68-
const transferContent = balanceContentValidator.parse(content);
68+
const transferContent = balanceContentValidator.parse(content);
6969

70-
const { chainName } = transferContent;
70+
const { chainName } = transferContent;
7171

72-
try {
73-
const walletProvider = await initWalletProvider(
74-
_runtime,
75-
chainName
76-
);
77-
const action = new BalanceAction(walletProvider);
78-
const responseText = await action.getBalance();
72+
try {
73+
const walletProvider = await initWalletProvider(
74+
_runtime,
75+
chainName
76+
);
77+
const action = new BalanceAction(walletProvider);
78+
const responseText = await action.getBalance();
7979

80-
await _callback({
81-
text: responseText,
82-
});
83-
} catch (error) {
84-
await _callback({
85-
text: error.message,
86-
});
87-
console.error("Error in Cosmos wallet provider:", error);
88-
}
80+
await _callback({
81+
text: responseText,
82+
});
83+
} catch (error) {
84+
await _callback({
85+
text: error.message,
86+
});
87+
console.error("Error in Cosmos wallet provider:", error);
88+
}
8989

90-
return;
91-
},
92-
validate: async (runtime: IAgentRuntime) => {
93-
const recoveryPhrase = runtime.getSetting("COSMOS_RECOVERY_PHRASE");
94-
const chains = genCosmosChainsFromRuntime(runtime);
90+
return;
91+
},
92+
validate: async (runtime: IAgentRuntime) => {
93+
const recoveryPhrase = runtime.getSetting("COSMOS_RECOVERY_PHRASE");
94+
const chains = genCosmosChainsFromRuntime(runtime);
9595

96-
return recoveryPhrase !== undefined && Object.keys(chains).length > 0;
97-
},
98-
examples: [
99-
[
100-
{
101-
user: "{{user1}}",
102-
content: {
103-
text: "Show me balance of my cosmos wallet for chain mantrachaintestnet2",
104-
},
105-
},
106-
{
107-
user: "{{user2}}",
108-
content: {
109-
text: "",
110-
action: "COSMOS_WALLET_BALANCE",
111-
},
112-
},
113-
],
114-
[
115-
{
116-
user: "{{user1}}",
117-
content: {
118-
text: "Show me balance of my cosmos wallet for chain mantrachaintestnet2 use COSMOS_WALLET_BALANCE action",
119-
},
120-
},
121-
{
122-
user: "{{user2}}",
123-
content: {
124-
text: "",
125-
action: "COSMOS_WALLET_BALANCE",
126-
},
127-
},
128-
],
129-
[
130-
{
131-
user: "{{user1}}",
132-
content: {
133-
text: "Show me balance of my wallet for chain mantrachaintestnet2 on cosmos",
134-
},
135-
},
136-
{
137-
user: "{{user2}}",
138-
content: {
139-
text: "",
140-
action: "COSMOS_WALLET_BALANCE",
141-
},
142-
},
143-
],
144-
[
145-
{
146-
user: "{{user1}}",
147-
content: {
148-
text: "What is my balance on the chain mantrachaintestnet2 on cosmos",
149-
},
150-
},
151-
{
152-
user: "{{user2}}",
153-
content: {
154-
text: "",
155-
action: "COSMOS_WALLET_BALANCE",
156-
},
157-
},
96+
return recoveryPhrase !== undefined && Object.keys(chains).length > 0;
97+
},
98+
examples: [
99+
[
100+
{
101+
user: "{{user1}}",
102+
content: {
103+
text: "Show me balance of my cosmos wallet for chain mantrachaintestnet2",
104+
},
105+
},
106+
{
107+
user: "{{user2}}",
108+
content: {
109+
text: "",
110+
action: "COSMOS_WALLET_BALANCE",
111+
},
112+
},
113+
],
114+
[
115+
{
116+
user: "{{user1}}",
117+
content: {
118+
text: "Show me balance of my cosmos wallet for chain mantrachaintestnet2 use COSMOS_WALLET_BALANCE action",
119+
},
120+
},
121+
{
122+
user: "{{user2}}",
123+
content: {
124+
text: "",
125+
action: "COSMOS_WALLET_BALANCE",
126+
},
127+
},
128+
],
129+
[
130+
{
131+
user: "{{user1}}",
132+
content: {
133+
text: "Show me balance of my wallet for chain mantrachaintestnet2 on cosmos",
134+
},
135+
},
136+
{
137+
user: "{{user2}}",
138+
content: {
139+
text: "",
140+
action: "COSMOS_WALLET_BALANCE",
141+
},
142+
},
143+
],
144+
[
145+
{
146+
user: "{{user1}}",
147+
content: {
148+
text: "What is my balance on the chain mantrachaintestnet2 on cosmos",
149+
},
150+
},
151+
{
152+
user: "{{user2}}",
153+
content: {
154+
text: "",
155+
action: "COSMOS_WALLET_BALANCE",
156+
},
157+
},
158+
],
158159
],
159-
],
160-
similes: ["COSMOS_BALANCE", "COSMOS_WALLET_TOKENS"],
160+
similes: ["COSMOS_BALANCE", "COSMOS_WALLET_TOKENS"],
161161
};

packages/plugin-cosmos/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import type { Plugin } from "@ai16z/eliza";
33
import { balanceAction } from "./actions/walletProviderTestAction.ts";
44

55
export const cosmosPlugin: Plugin = {
6-
name: "cosmos",
7-
description: "Cosmos blockchain integration plugin",
8-
providers: [cosmosWalletProvider],
9-
evaluators: [],
10-
services: [],
11-
actions: [balanceAction],
6+
name: "cosmos",
7+
description: "Cosmos blockchain integration plugin",
8+
providers: [cosmosWalletProvider],
9+
evaluators: [],
10+
services: [],
11+
actions: [balanceAction],
1212
};
1313

1414
export default cosmosPlugin;

0 commit comments

Comments
 (0)