Skip to content

Commit

Permalink
Merge pull request #24 from MarcoMandar/main
Browse files Browse the repository at this point in the history
token provider
  • Loading branch information
lalalune authored Oct 25, 2024
2 parents e7b2d9e + ab1b85c commit 2988d68
Show file tree
Hide file tree
Showing 6 changed files with 1,147 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ ANTHROPIC_API_KEY=
WALLET_SECRET_KEY=2eETRBeJFNfxAmPzTxfRynebRjTYK9WBLeAE5JhfxdzAxjJG8ZCbmHX1WadTRdcEpE7HRELVp6cbCfZFY6Qw9BgR
WALLET_PUBLIC_KEY=DM1fSD9KfdJ2jaSmR9NGpPPVcDzBwsYg1STttYc5Bvay


BIRDEYE_API_KEY=

SOL_ADDRESS=So11111111111111111111111111111111111111112
SLIPPAGE=1
RPC_URL=https://api.mainnet-beta.solana.com
RPC_URL=https://api.mainnet-beta.solana.com
HELIUS_API_KEY=
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"kuromoji": "^0.1.2",
"libsodium-wrappers": "^0.7.13",
"multer": "^1.4.5-lts.1",
"node-cache": "^5.1.2",
"node-llama-cpp": "^3.0.0-beta.44",
"node-wav": "^0.0.2",
"nodejs-whisper": "^0.1.18",
Expand Down
71 changes: 71 additions & 0 deletions src/providers/token.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { TokenProvider } from "./token";
import NodeCache from "node-cache";

// Mock the dependencies
jest.mock("cross-fetch");
jest.mock("fs");
jest.mock("node-cache");

describe("TokenProvider Tests", () => {
// let connection: Connection;
let tokenProvider: TokenProvider;

beforeEach(() => {
// Initialize the connection and token provider before each test
// connection = new Connection("https://api.mainnet-beta.solana.com");
tokenProvider = new TokenProvider(
"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh"
);
});

test("should fetch token security data", async () => {
// Mock the response for the fetchTokenSecurity call
const mockFetchResponse = {
success: true,
data: {
ownerBalance: "100",
creatorBalance: "50",
ownerPercentage: 10,
creatorPercentage: 5,
top10HolderBalance: "200",
top10HolderPercent: 20,
},
};

// Mock fetchWithRetry function
const fetchSpy = jest
.spyOn(tokenProvider as any, "fetchWithRetry")
.mockResolvedValue(mockFetchResponse);

// Run the fetchTokenSecurity method
// const securityData = await tokenProvider.fetchTokenSecurity();

// Check if the data returned is correct
// expect(securityData).toEqual({
// ownerBalance: "100",
// creatorBalance: "50",
// ownerPercentage: 10,
// creatorPercentage: 5,
// top10HolderBalance: "200",
// top10HolderPercent: 20,
// });
//console.log the securityData
// console.log({ securityData });

// const holderList = await tokenProvider.fetchHolderList();

// console.log({ holderList });

// const tradeData = await tokenProvider.fetchTokenTradeData();
// console.log({ tradeData });

// const dexScreenerData = await tokenProvider.fetchDexScreenerData();
// console.log({ dexScreenerData });

const tokenReport = await tokenProvider.getFormattedTokenReport();
console.log({ tokenReport });

// Ensure the mock was called
expect(fetchSpy).toHaveBeenCalled();
});
});
Loading

0 comments on commit 2988d68

Please sign in to comment.