Skip to content

Commit ce0e715

Browse files
committed
correct places were stricter checking is now in place
1 parent a73d460 commit ce0e715

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

.github/workflows/ci.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,11 @@ jobs:
2525
- name: Run Prettier
2626
run: pnpm run prettier --check .
2727

28+
- name: Create test env file
29+
run: cp core/.env.test.example core/.env.test || cp core/.env.test core/.env.test
30+
31+
- name: Run tests
32+
run: cd core && pnpm test
33+
2834
- name: Build packages
2935
run: pnpm run build

core/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"ts-node": "10.9.2",
6868
"tslib": "2.8.0",
6969
"typescript": "5.6.3",
70-
"wrangler": "3.84.0"
70+
"wrangler": "3.84.0",
71+
"@types/pdfjs-dist": "^2.10.378"
7172
},
7273
"pnpm": {
7374
"overrides": {

core/src/cli/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "fs";
22
import yaml from "js-yaml";
33
import path from "path";
44
import { fileURLToPath } from "url";
5-
import { Action } from "../core/types";
5+
import { Action } from "../core/types.ts";
66

77
const ROOT_DIR = path.resolve(fileURLToPath(import.meta.url), "../../../src");
88

core/src/core/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Readable } from "stream";
2-
import { ImageGenModel } from "./imageGenModels";
2+
import { ImageGenModel } from "./imageGenModels.ts";
33

44
/**
55
* Represents a UUID, which is a universally unique identifier conforming to the UUID standard.

core/src/providers/token.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Connection } from "@solana/web3.js";
22
// import fetch from "cross-fetch";
33
import { IAgentRuntime, Memory, Provider, State } from "../core/types.ts";
44
import settings from "../core/settings.ts";
5-
import BigNumber from "bignumber.js";
5+
import { toBN, BN } from '../utils/bignumber.js';
66
import {
77
ProcessedTokenData,
88
TokenSecurityData,
@@ -609,40 +609,38 @@ export class TokenProvider {
609609
): Promise<Array<{ holderAddress: string; balanceUsd: string }>> {
610610
const holdersData = await this.fetchHolderList();
611611

612-
const tokenPriceUsd = new BigNumber(tradeData.price);
612+
const tokenPriceUsd = toBN(tradeData.price);
613613

614614
const highValueHolders = holdersData
615615
.filter((holder) => {
616-
const balanceUsd = new BigNumber(holder.balance).multipliedBy(
616+
const balanceUsd = toBN(holder.balance).multipliedBy(
617617
tokenPriceUsd
618618
);
619619
return balanceUsd.isGreaterThan(5);
620620
})
621621
.map((holder) => ({
622622
holderAddress: holder.address,
623-
balanceUsd: new BigNumber(holder.balance)
624-
.multipliedBy(tokenPriceUsd)
625-
.toFixed(2),
623+
balanceUsd: toBN(holder.balance).multipliedBy(tokenPriceUsd).toFixed(2),
626624
}));
627625

628626
return highValueHolders;
629627
}
630628

631629
async checkRecentTrades(tradeData: TokenTradeData): Promise<boolean> {
632-
return new BigNumber(tradeData.volume_24h_usd).isGreaterThan(0);
630+
return toBN(tradeData.volume_24h_usd).isGreaterThan(0);
633631
}
634632

635633
async countHighSupplyHolders(
636634
securityData: TokenSecurityData
637635
): Promise<number> {
638636
try {
639-
const ownerBalance = new BigNumber(securityData.ownerBalance);
637+
const ownerBalance = toBN(securityData.ownerBalance);
640638
const totalSupply = ownerBalance.plus(securityData.creatorBalance);
641639

642640
const highSupplyHolders = await this.fetchHolderList();
643641
const highSupplyHoldersCount = highSupplyHolders.filter(
644642
(holder) => {
645-
const balance = new BigNumber(holder.balance);
643+
const balance = toBN(holder.balance);
646644
return balance.dividedBy(totalSupply).isGreaterThan(0.02);
647645
}
648646
).length;
@@ -738,8 +736,8 @@ export class TokenProvider {
738736
output += `- Unique Wallets (24h): ${data.tradeData.unique_wallet_24h}\n`;
739737
output += `- Price Change (24h): ${data.tradeData.price_change_24h_percent}%\n`;
740738
output += `- Price Change (12h): ${data.tradeData.price_change_12h_percent}%\n`;
741-
output += `- Volume (24h USD): $${new BigNumber(data.tradeData.volume_24h_usd).toFixed(2)}\n`;
742-
output += `- Current Price: $${new BigNumber(data.tradeData.price).toFixed(2)}\n\n`;
739+
output += `- Volume (24h USD): $${toBN(data.tradeData.volume_24h_usd).toFixed(2)}\n`;
740+
output += `- Current Price: $${toBN(data.tradeData.price).toFixed(2)}\n\n`;
743741

744742
// Holder Distribution Trend
745743
output += `**Holder Distribution Trend:** ${data.holderDistributionTrend}\n\n`;
@@ -771,10 +769,10 @@ export class TokenProvider {
771769
output += `\n**Pair ${index + 1}:**\n`;
772770
output += `- DEX: ${pair.dexId}\n`;
773771
output += `- URL: ${pair.url}\n`;
774-
output += `- Price USD: $${new BigNumber(pair.priceUsd).toFixed(6)}\n`;
775-
output += `- Volume (24h USD): $${new BigNumber(pair.volume.h24).toFixed(2)}\n`;
772+
output += `- Price USD: $${toBN(pair.priceUsd).toFixed(6)}\n`;
773+
output += `- Volume (24h USD): $${toBN(pair.volume.h24).toFixed(2)}\n`;
776774
output += `- Boosts Active: ${pair.boosts && pair.boosts.active}\n`;
777-
output += `- Liquidity USD: $${new BigNumber(pair.liquidity.usd).toFixed(2)}\n`;
775+
output += `- Liquidity USD: $${toBN(pair.liquidity.usd).toFixed(2)}\n`;
778776
});
779777
}
780778
output += `\n`;

core/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
33
"target": "ESNext",
4-
"module": "NodeNext",
4+
"module": "ESNext",
55
"lib": ["ESNext", "dom"],
6-
"moduleResolution": "NodeNext",
6+
"moduleResolution": "Bundler",
77
"outDir": "./dist",
88
"rootDir": "./src",
99
"strict": false,

0 commit comments

Comments
 (0)