Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: imports and cleanups #344

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19,887 changes: 0 additions & 19,887 deletions docs/package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions packages/client-auto/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Client, IAgentRuntime } from "@ai16z/eliza";
import { TrustScoreManager } from "@ai16z/plugin-solana/src/providers/trustScoreProvider.ts";
import { TokenProvider } from "@ai16z/plugin-solana/src/providers/token.ts";
import { WalletProvider } from "@ai16z/plugin-solana/src/providers/wallet.ts";
import { TrustScoreDatabase } from "@ai16z/plugin-solana/src/adapters/trustScoreDatabase.ts";
import { TrustScoreManager } from "@ai16z/plugin-solana";
import { TokenProvider } from "@ai16z/plugin-solana";
import { WalletProvider } from "@ai16z/plugin-solana";
import { TrustScoreDatabase } from "@ai16z/plugin-solana";
import { Connection, PublicKey } from "@solana/web3.js";

export class AutoClient {
Expand Down
6 changes: 3 additions & 3 deletions packages/client-auto/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default defineConfig({
"https",
"http",
"agentkeepalive",
"safe-buffer",
"base-x",
"bs58",
"borsh",
"@solana/buffer-layout",
"ws",
"stream",
"buffer",
"rpc-websockets",
// Add other modules you want to externalize
],
});
7 changes: 4 additions & 3 deletions packages/plugin-solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"types": "dist/index.d.ts",
"dependencies": {
"@ai16z/eliza": "workspace:*",
"tsup": "^8.3.5",
"@coral-xyz/anchor": "^0.30.1",
"@solana/spl-token": "0.4.9",
"@solana/web3.js": "1.95.4",
"@coral-xyz/anchor": "^0.30.1",
"bignumber": "1.1.0",
"bignumber.js": "9.1.2",
"bs58": "^6.0.0",
"node-cache": "5.1.2",
"pumpdotfun-sdk": "1.3.2",
"node-cache": "5.1.2"
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts"
Expand Down
12 changes: 5 additions & 7 deletions packages/plugin-solana/src/actions/pumpfun.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AnchorProvider } from "@coral-xyz/anchor";
import { Wallet } from "@coral-xyz/anchor";
import { generateImage } from "@ai16z/eliza/src/generation.ts";
import { generateImage } from "@ai16z/eliza";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import {
CreateTokenMetadata,
Expand All @@ -10,28 +10,26 @@ import {
} from "pumpdotfun-sdk";

import { getAssociatedTokenAddressSync } from "@solana/spl-token";
import settings from "@ai16z/eliza/src/settings.ts";

import bs58 from "bs58";
import {
settings,
ActionExample,
Content,
HandlerCallback,
IAgentRuntime,
Memory,
ModelClass,
State,
generateObject,
composeContext,
type Action,
} from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateObject } from "@ai16z/eliza/src/generation.ts";

import {
walletProvider,
//WalletProvider,
} from "../providers/wallet.ts";

import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes/index.js";

export interface CreateAndBuyContent extends Content {
tokenMetadata: {
name: string;
Expand Down
18 changes: 12 additions & 6 deletions packages/plugin-solana/src/actions/swap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes/index.js";
import bs58 from "bs58";
import {
Connection,
Keypair,
Expand All @@ -8,9 +8,9 @@ import {
import BigNumber from "bignumber.js";
import { v4 as uuidv4 } from "uuid";
import { TrustScoreDatabase } from "../adapters/trustScoreDatabase.ts";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateObject } from "@ai16z/eliza/src/generation.ts";
import settings from "@ai16z/eliza/src/settings.ts";
import { composeContext } from "@ai16z/eliza";
import { generateObject } from "@ai16z/eliza";
import { settings } from "@ai16z/eliza";
import {
ActionExample,
HandlerCallback,
Expand Down Expand Up @@ -391,7 +391,10 @@ export const executeSwap: Action = {
}

if (type === "buy") {
const tokenProvider = new TokenProvider(response.outputTokenCA);
const tokenProvider = new TokenProvider(
response.outputTokenCA,
await walletProvider.get(runtime, message, state)
);
const module = await import("better-sqlite3");
const Database = module.default;
const trustScoreDb = new TrustScoreDatabase(
Expand Down Expand Up @@ -421,7 +424,10 @@ export const executeSwap: Action = {
tradeData
);
} else if (type === "sell") {
const tokenProvider = new TokenProvider(response.inputTokenCA);
const tokenProvider = new TokenProvider(
response.inputTokenCA,
await walletProvider.get(runtime, message, state)
);
const module = await import("better-sqlite3");
const Database = module.default;
const trustScoreDb = new TrustScoreDatabase(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/actions/swapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TokenAmount,
VersionedTransaction,
} from "@solana/web3.js";
import settings from "@ai16z/eliza/src/settings.ts";
import { settings } from "@ai16z/eliza";

const solAddress = settings.SOL_ADDRESS;
const SLIPPAGE = settings.SLIPPAGE;
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-solana/src/actions/takeOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
ModelClass,
} from "@ai16z/eliza";
import * as fs from "fs";
import settings from "@ai16z/eliza/src/settings.ts";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateText } from "@ai16z/eliza/src/generation.ts";
import { settings } from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateText } from "@ai16z/eliza";

interface Order {
userId: string;
Expand Down
11 changes: 4 additions & 7 deletions packages/plugin-solana/src/actions/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { AnchorProvider } from "@coral-xyz/anchor";
import { Wallet } from "@coral-xyz/anchor";

import {
getAssociatedTokenAddressSync,
createTransferInstruction,
} from "@solana/spl-token";
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes/index.js";
import settings from "@ai16z/eliza/src/settings.ts";
import bs58 from "bs58";
import { settings } from "@ai16z/eliza";

import {
Connection,
Expand All @@ -26,8 +23,8 @@ import {
State,
type Action,
} from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateObject } from "@ai16z/eliza/src/generation.ts";
import { composeContext } from "@ai16z/eliza";
import { generateObject } from "@ai16z/eliza";

export interface TransferContent extends Content {
tokenAddress: string;
Expand Down
12 changes: 4 additions & 8 deletions packages/plugin-solana/src/evaluators/trust.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { composeContext } from "@ai16z/eliza/src/context.ts";
import {
generateObjectArray,
generateTrueOrFalse,
} from "@ai16z/eliza/src/generation.ts";
import { MemoryManager } from "@ai16z/eliza/src/memory.ts";
import { booleanFooter } from "@ai16z/eliza/src/parsing.ts";
import { composeContext } from "@ai16z/eliza";
import { generateObjectArray, generateTrueOrFalse } from "@ai16z/eliza";
import { MemoryManager } from "@ai16z/eliza";
import { booleanFooter } from "@ai16z/eliza";
import {
ActionExample,
Content,
Expand All @@ -13,7 +10,6 @@ import {
ModelClass,
Evaluator,
} from "@ai16z/eliza";
import { stringToUuid } from "@ai16z/eliza/src/uuid.ts";
import { TrustScoreManager } from "../providers/trustScoreProvider.ts";
import { TokenProvider } from "../providers/token.ts";
import { WalletProvider } from "../providers/wallet.ts";
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-solana/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export * from "./providers/token.ts";
export * from "./providers/wallet.ts";
export * from "./providers/trustScoreProvider.ts";
export * from "./evaluators/trust.ts";
export * from "./adapters/trustScoreDatabase.ts";

import { Plugin } from "@ai16z/eliza";
//import { executeSwap } from "./actions/swap.ts";
//import take_order from "./actions/takeOrder";
Expand Down
6 changes: 5 additions & 1 deletion packages/plugin-solana/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ export default defineConfig({
"https",
"http",
"agentkeepalive",
"safe-buffer",
"base-x",
"bs58",
"buffer",
"borsh",
"@solana/buffer-layout",
"stream",
"buffer",
// Add other modules you want to externalize
],
});
Loading