Skip to content

Commit 448c758

Browse files
authored
Merge pull request elizaOS#3069 from AIFlowML/fix-plugin-dexscreener
fix: plugin-dexscreener lint
2 parents 171ebb0 + 485ca3f commit 448c758

File tree

5 files changed

+77
-13
lines changed

5 files changed

+77
-13
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
3+
"organizeImports": {
4+
"enabled": false
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true,
10+
"correctness": {
11+
"noUnusedVariables": "error"
12+
},
13+
"suspicious": {
14+
"noExplicitAny": "error"
15+
},
16+
"style": {
17+
"useConst": "error",
18+
"useImportType": "off"
19+
}
20+
}
21+
},
22+
"formatter": {
23+
"enabled": true,
24+
"indentStyle": "space",
25+
"indentWidth": 4,
26+
"lineWidth": 100
27+
},
28+
"javascript": {
29+
"formatter": {
30+
"quoteStyle": "single",
31+
"trailingCommas": "es5"
32+
}
33+
},
34+
"files": {
35+
"ignore": [
36+
"dist/**/*",
37+
"extra/**/*",
38+
"node_modules/**/*"
39+
]
40+
}
41+
}

packages/plugin-dexscreener/package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@
1010
},
1111
"scripts": {
1212
"build": "tsup --format esm --dts",
13-
"dev": "tsup --format esm --dts --watch"
13+
"dev": "tsup --format esm --dts --watch",
14+
"clean": "rm -rf dist",
15+
"lint": "biome lint .",
16+
"lint:fix": "biome check --apply .",
17+
"format": "biome format .",
18+
"format:fix": "biome format --write ."
1419
},
1520
"peerDependencies": {
1621
"whatwg-url": "7.1.0"
22+
},
23+
"devDependencies": {
24+
"@biomejs/biome": "1.9.4"
1725
}
1826
}

packages/plugin-dexscreener/src/actions/tokenAction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class TokenPriceAction implements Action {
2121
suppressInitialMessage = true;
2222
template = priceTemplate;
2323

24-
async validate(runtime: IAgentRuntime, message: Memory): Promise<boolean> {
24+
async validate(_runtime: IAgentRuntime, message: Memory): Promise<boolean> {
2525
const content = typeof message.content === 'string'
2626
? message.content
2727
: message.content?.text;

packages/plugin-dexscreener/src/actions/trendsAction.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class LatestTokensAction implements Action {
5151
suppressInitialMessage = true;
5252
template = latestTokensTemplate;
5353

54-
async validate(runtime: IAgentRuntime, message: Memory): Promise<boolean> {
54+
async validate(_runtime: IAgentRuntime, message: Memory): Promise<boolean> {
5555
const content =
5656
typeof message.content === "string"
5757
? message.content
@@ -68,7 +68,7 @@ export class LatestTokensAction implements Action {
6868
async handler(
6969
runtime: IAgentRuntime,
7070
message: Memory,
71-
state?: State,
71+
_state?: State,
7272
_options: { [key: string]: unknown } = {},
7373
callback?: HandlerCallback
7474
): Promise<boolean> {
@@ -166,7 +166,7 @@ export class LatestBoostedTokensAction implements Action {
166166
suppressInitialMessage = true;
167167
template = latestBoostedTemplate;
168168

169-
async validate(runtime: IAgentRuntime, message: Memory): Promise<boolean> {
169+
async validate(_runtime: IAgentRuntime, message: Memory): Promise<boolean> {
170170
const content =
171171
typeof message.content === "string"
172172
? message.content
@@ -186,7 +186,7 @@ export class LatestBoostedTokensAction implements Action {
186186
async handler(
187187
runtime: IAgentRuntime,
188188
message: Memory,
189-
state?: State,
189+
_state?: State,
190190
_options: { [key: string]: unknown } = {},
191191
callback?: HandlerCallback
192192
): Promise<boolean> {
@@ -284,7 +284,7 @@ export class TopBoostedTokensAction implements Action {
284284
suppressInitialMessage = true;
285285
template = topBoostedTemplate;
286286

287-
async validate(runtime: IAgentRuntime, message: Memory): Promise<boolean> {
287+
async validate(_runtime: IAgentRuntime, message: Memory): Promise<boolean> {
288288
const content =
289289
typeof message.content === "string"
290290
? message.content
@@ -304,7 +304,7 @@ export class TopBoostedTokensAction implements Action {
304304
async handler(
305305
runtime: IAgentRuntime,
306306
message: Memory,
307-
state?: State,
307+
_state?: State,
308308
_options: { [key: string]: unknown } = {},
309309
callback?: HandlerCallback
310310
): Promise<boolean> {

packages/plugin-dexscreener/src/providers/tokenProvider.ts

+20-5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,25 @@ interface TokenPriceData {
2020
}
2121
*/
2222

23+
interface DexScreenerPair {
24+
baseToken: {
25+
name: string;
26+
symbol: string;
27+
address: string;
28+
decimals: number;
29+
};
30+
priceUsd: string;
31+
liquidity?: {
32+
usd: string;
33+
};
34+
volume?: {
35+
h24: number;
36+
};
37+
}
38+
2339
export class TokenPriceProvider implements Provider {
2440
async get(
25-
runtime: IAgentRuntime,
41+
_lengthruntime: IAgentRuntime,
2642
message: Memory,
2743
_state?: State
2844
): Promise<string> {
@@ -93,21 +109,20 @@ export class TokenPriceProvider implements Provider {
93109
return null;
94110
}
95111

96-
private getBestPair(pairs: any[]): any {
112+
private getBestPair(pairs: DexScreenerPair[]): DexScreenerPair {
97113
return pairs.reduce((best, current) => {
98114
const bestLiquidity = Number.parseFloat(best.liquidity?.usd || "0");
99115
const currentLiquidity = Number.parseFloat(current.liquidity?.usd || "0");
100116
return currentLiquidity > bestLiquidity ? current : best;
101117
}, pairs[0]);
102118
}
103119

104-
private formatPriceData(pair: any): string {
120+
private formatPriceData(pair: DexScreenerPair): string {
105121
const price = Number.parseFloat(pair.priceUsd).toFixed(6);
106-
//const change24h = pair.priceChange?.h24?.toFixed(2) || "0.00";
107122
const liquidity = Number.parseFloat(
108123
pair.liquidity?.usd || "0"
109124
).toLocaleString();
110-
const volume = Number.parseFloat(pair.volume?.h24 || "0").toLocaleString();
125+
const volume = (pair.volume?.h24 || 0).toLocaleString();
111126

112127
return `
113128
The price of ${pair.baseToken.symbol} is $${price} USD, with liquidity of $${liquidity} and 24h volume of $${volume}.`;

0 commit comments

Comments
 (0)