Skip to content

Commit

Permalink
- Fixed some rebasing errors, added missing package.json deps
Browse files Browse the repository at this point in the history
- refactored fluxbeam into folder
- refactored tools
- removed unused imports
  • Loading branch information
adpthegreat committed Jan 15, 2025
1 parent e58fa22 commit 2210119
Show file tree
Hide file tree
Showing 35 changed files with 890 additions and 779 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,23 @@
"@langchain/openai": "^0.3.16",
"@lightprotocol/compressed-token": "^0.17.1",
"@lightprotocol/stateless.js": "^0.17.1",
"@mayanfinance/swap-sdk": "^9.8.0",
"@metaplex-foundation/mpl-core": "^1.1.1",
"@metaplex-foundation/mpl-token-metadata": "^3.3.0",
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
"@metaplex-foundation/umi": "^0.9.2",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-options": "^1.0.0",
"@metaplex-foundation/umi-uploader-irys": "^1.0.0",
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
"@onsol/tldparser": "^0.6.7",
"@orca-so/common-sdk": "0.6.4",
"@orca-so/whirlpools-sdk": "^0.13.12",
"@project-serum/anchor": "^0.26.0",
"@pythnetwork/hermes-client": "^1.3.0",
"@raydium-io/raydium-sdk-v2": "0.1.95-alpha",
"@solana/spl-token": "^0.4.9",
"@solana/spl-token-metadata": "^0.1.6",
"@solana/web3.js": "^1.98.0",
"@sqds/multisig": "^2.1.3",
"@tensor-oss/tensorswap-sdk": "^4.5.0",
Expand Down
1,408 changes: 746 additions & 662 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/actions/fluxbeam/bridgeToken.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import {
Chain,
fluxbeamBridgeTokens,
} from "../../tools/fluxbeam_bridge_tokens";
} from "../../tools/fluxbeam/fluxbeam_bridge_tokens";

const bridgeTokensAction: Action = {
name: "BRIDGE_TOKENS_ACTION",
Expand Down
12 changes: 6 additions & 6 deletions src/actions/fluxbeam/createV1Token.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { z } from "zod";
import { SolanaAgentKit } from "../../agent";
import { fluxbeamCreateMintV1 } from "../../tools";
import { fluxbeamCreateTokenV1 } from "../../tools";
import { Action } from "../../types";

// Create Mint V1 Action
const createMintV1Action: Action = {
name: "CREATE_MINT_V1_ACTION",
// Create Token V1 Action
const createTokenV1Action: Action = {
name: "CREATE_TOKEN_V1_ACTION",
similes: ["create token v1", "mint new token v1", "initialize token v1"],
description: "Creates a new SPL token with metadata (v1)",
examples: [
Expand Down Expand Up @@ -35,7 +35,7 @@ const createMintV1Action: Action = {
uri: z.string().optional(),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
const signature = await fluxbeamCreateMintV1(
const signature = await fluxbeamCreateTokenV1(
agent,
input.name,
input.symbol,
Expand All @@ -51,4 +51,4 @@ const createMintV1Action: Action = {
},
};

export default createMintV1Action;
export default createTokenV1Action;
6 changes: 3 additions & 3 deletions src/actions/fluxbeam/createV2Token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Keypair, PublicKey } from "@solana/web3.js";
import { z } from "zod";
import { SolanaAgentKit } from "../../agent";
import { ExtensionConfig, fluxbeamCreateMintV2 } from "../../tools";
import { ExtensionConfig, fluxbeamCreateTokenV2 } from "../../tools";
import { Action } from "../../types";

// Create Mint V2 Action (continued)
Expand Down Expand Up @@ -30,7 +30,7 @@ const createMintV2Action: Action = {
status: "success",
signature: "bYx4...",
},
explanation: "Create new token-2022 with extensions",
explanation: "Create new token-2022 token with extensions",
},
],
],
Expand All @@ -52,7 +52,7 @@ const createMintV2Action: Action = {
imageUri: z.string().optional(),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
const signature = await fluxbeamCreateMintV2(
const signature = await fluxbeamCreateTokenV2(
agent,
new PublicKey(input.owner),
input.tokenMint,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/fluxbeam/revokeMintAuthority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthorityType } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { z } from "zod";
import { SolanaAgentKit } from "../../agent";
import { fluxbeamRevokeAuthority } from "../../tools/fluxbeam_token_minting_controls";
import { fluxbeamRevokeAuthority } from "../../tools/fluxbeam/fluxbeam_token_minting_controls";
import { Action } from "../../types";

// Revoke Authority Action
Expand Down
2 changes: 1 addition & 1 deletion src/actions/fluxbeam/setMintAuthority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthorityType } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { z } from "zod";
import { SolanaAgentKit } from "../../agent";
import { fluxbeamSetAuthority } from "../../tools/fluxbeam_token_minting_controls";
import { fluxbeamSetAuthority } from "../../tools/fluxbeam/fluxbeam_token_minting_controls";
import { Action } from "../../types";

// Set Authority Action
Expand Down
2 changes: 1 addition & 1 deletion src/actions/fluxbeam/unwrapSol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const unwrapSolAction: Action = {
],
],
schema: z.object({}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
handler: async (agent: SolanaAgentKit) => {
const signature = await fluxbeamUnwrapSOL(agent);
return {
status: "success",
Expand Down
30 changes: 13 additions & 17 deletions src/agent/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import bs58 from "bs58";
import Decimal from "decimal.js";
Expand All @@ -7,9 +7,7 @@ import {
CreateSingleOptions,
StoreInitOptions,
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
import { DEFAULT_OPTIONS } from "../constants";
import { DEFAULT_OPTIONS, TOKENS } from "../constants";
import { Config, FluxbeamServerResponse, TokenCheck } from "../types";
import {
deploy_collection,
deploy_token,
Expand Down Expand Up @@ -109,8 +107,8 @@ import {
fluxbeamGetClaimWithheldTokensToMint,
fluxbeamGetClaimWitheldTokensFromMint,
fluxbeamGetClaimWitheldTokens,
fluxbeamCreateMintV2,
fluxbeamCreateMintV1,
fluxbeamCreateTokenV2,
fluxbeamCreateTokenV1,
fluxbeamTransferSol,
fluxbeamTransferSplToken,
fluxbeamUnwrapSOL,
Expand All @@ -133,18 +131,16 @@ import {
HeliusWebhookIdResponse,
HeliusWebhookResponse,
} from "../types";
import {
AuthorityType,
ExtensionType,
TOKEN_2022_PROGRAM_ID,
} from "@solana/spl-token";
import { AuthorityType } from "@solana/spl-token";
import {
fluxbeamMintToAccount,
fluxbeamRevokeAuthority,
fluxbeamSetAuthority,
} from "../tools/fluxbeam_token_minting_controls";
import { KeypairSigner } from "@metaplex-foundation/umi";
import { Chain, fluxbeamBridgeTokens } from "../tools/fluxbeam_bridge_tokens";
} from "../tools/fluxbeam/fluxbeam_token_minting_controls";
import {
Chain,
fluxbeamBridgeTokens,
} from "../tools/fluxbeam/fluxbeam_bridge_tokens";

/**
* Main class for interacting with Solana blockchain
Expand Down Expand Up @@ -998,7 +994,7 @@ export class SolanaAgentKit {
return fluxbeamTransferSol(agent, dstOwner, amount);
}

async fluxbeamCreateMintV1(
async fluxbeamCreateTokenV1(
agent: SolanaAgentKit,
name: string,
symbol: string,
Expand All @@ -1007,7 +1003,7 @@ export class SolanaAgentKit {
imagePath?: string,
initialSupply?: number,
): Promise<string> {
return fluxbeamCreateMintV1(
return fluxbeamCreateTokenV1(
agent,
name,
symbol,
Expand All @@ -1018,7 +1014,7 @@ export class SolanaAgentKit {
);
}

async fluxbeamCreateMintV2(
async fluxbeamCreateTokenV2(
agent: SolanaAgentKit,
owner: PublicKey,
tokenMintKeypair: Keypair,
Expand All @@ -1036,7 +1032,7 @@ export class SolanaAgentKit {
imagePath?: string,
imageUri?: string,
): Promise<string> {
return fluxbeamCreateMintV2(
return fluxbeamCreateTokenV2(
agent,
owner,
tokenMintKeypair,
Expand Down
2 changes: 1 addition & 1 deletion src/langchain/fluxbeam/bridge_token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { Chain } from "../../tools/fluxbeam_bridge_tokens";
import { Chain } from "../../tools/fluxbeam/fluxbeam_bridge_tokens";

export class SolanaFluxbeamBridgeTokensTool extends Tool {
name = "solana_bridge_tokens";
Expand Down
3 changes: 1 addition & 2 deletions src/langchain/fluxbeam/burn_token.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
Expand Down Expand Up @@ -44,4 +43,4 @@ export class SolanaFluxbeamBurnTokenTool extends Tool {
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";

export class SolanaFluxbeamCreateMintV1Tool extends Tool {
name = "solana_create_mint_v1";
description = `This tool creates a mint on the Solana blockchain.
export class SolanaFluxbeamCreateTokenV1Tool extends Tool {
name = "solana_create_token_v1";
description = `This tool creates a legacy SPL token on the Solana blockchain.
Inputs (input is a JSON string):
name: string, token name (required)
Expand All @@ -22,7 +22,7 @@ export class SolanaFluxbeamCreateMintV1Tool extends Tool {
try {
const parsedInput = JSON.parse(input);

const signature = await this.solanaKit.fluxbeamCreateMintV1(
const signature = await this.solanaKit.fluxbeamCreateTokenV1(
this.solanaKit,
parsedInput.name,
parsedInput.symbol,
Expand All @@ -34,7 +34,7 @@ export class SolanaFluxbeamCreateMintV1Tool extends Tool {

return JSON.stringify({
status: "success",
message: "Mint created successfully",
message: "Token created successfully",
transaction: signature,
});
} catch (error: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";

export class SolanaFluxbeamCreateMintV2Tool extends Tool {
name = "solana_create_mint_v2";
description = `This tool creates a mint on the Solana blockchain (version 2).
export class SolanaFluxbeamCreateTokenV2Tool extends Tool {
name = "solana_create_token_v2";
description = `This tool creates a token2022 token on the Solana blockchain.
Inputs (input is a JSON string):
owner: string, e.g., "OwnerPublicKey" (required)
Expand Down Expand Up @@ -32,7 +32,7 @@ export class SolanaFluxbeamCreateMintV2Tool extends Tool {
try {
const parsedInput = JSON.parse(input);

const signature = await this.solanaKit.fluxbeamCreateMintV2(
const signature = await this.solanaKit.fluxbeamCreateTokenV2(
this.solanaKit,
new PublicKey(parsedInput.owner),
parsedInput.tokenMintKeypair,
Expand All @@ -52,7 +52,7 @@ export class SolanaFluxbeamCreateMintV2Tool extends Tool {

return JSON.stringify({
status: "success",
message: "Mint created successfully",
message: "Token created successfully",
transaction: signature,
});
} catch (error: any) {
Expand Down
13 changes: 13 additions & 0 deletions src/langchain/fluxbeam/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from "./bridge_token";
export * from "./burn_token";
export * from "./create_token_v1";
export * from "./create_token_v2";
export * from "./create_pool";
export * from "./fee_management";
export * from "./swap";
export * from "./token_minting_controls";
export * from "./transfer";
export * from "./update_v1_token_metadata";
export * from "./update_v2_token_metadata";
export * from "./withheld_amounts_tracking";
export * from "./wrap_and_unwrap_sol";
1 change: 0 additions & 1 deletion src/langchain/fluxbeam/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
Expand Down
4 changes: 2 additions & 2 deletions src/langchain/fluxbeam/update_v1_token_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";

export class SolanaFluxbeamUpdateMetadataTool extends Tool {
export class SolanaFluxbeamUpdateV1MetadataTool extends Tool {
name = "solana_update_metadata";
description = `This tool updates metadata for a token account.
description = `This tool updates metadata for a v1 (legacy) token account.
Inputs (input is a JSON string):
mint: string, e.g., "TokenMintPublicKey" (required)
Expand Down
25 changes: 21 additions & 4 deletions src/langchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export * from "./sns";
export * from "./lightprotocol";
export * from "./squads";
export * from "./helius";
export * from "./fluxbeam"
export * from "./fluxbeam";
import { SolanaAgentKit } from "../agent";
import {
SolanaBalanceTool,
Expand Down Expand Up @@ -98,6 +98,23 @@ import {
SolanaDeleteHeliusWebhookTool,
SolanaParseTransactionHeliusTool,
SolanaGetAllAssetsByOwner,
SolanaFluxbeamBridgeTokensTool,
SolanaFluxbeamBurnTokenTool,
SolanaFluxbeamCreatePoolTool,
SolanaFluxbeamSubmitFeeClaimTool,
SolanaFluxbeamSubmitFeePaymentTool,
SolanaFluxbeamUpdateV1MetadataTool,
SolanaFluxbeamUpdateV2MetadataTool,
SolanaFluxbeamMintToAccountTool,
SolanaFluxbeamSetAuthorityTool,
SolanaFluxbeamRevokeAuthorityTool,
SolanaFluxbeamCreateTokenV1Tool,
SolanaFluxbeamCreateTokenV2Tool,
SolanaFluxbeamGetClaimWithheldTokensFromMintTool,
SolanaFluxbeamGetClaimWithheldTokensToMintTool,
SolanaFluxbeamGetClaimWithheldTokensTool,
SolanaFluxbeamWrapSOLTool,
SolanaFluxbeamUnwrapSOLTool,
} from "./index";

export function createSolanaTools(solanaKit: SolanaAgentKit) {
Expand Down Expand Up @@ -183,13 +200,13 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) {
new SolanaFluxbeamCreatePoolTool(solanaKit),
new SolanaFluxbeamSubmitFeeClaimTool(solanaKit),
new SolanaFluxbeamSubmitFeePaymentTool(solanaKit),
new SolanaFluxbeamUpdateMetadataTool(solanaKit),
new SolanaFluxbeamUpdateV1MetadataTool(solanaKit),
new SolanaFluxbeamUpdateV2MetadataTool(solanaKit),
new SolanaFluxbeamMintToAccountTool(solanaKit),
new SolanaFluxbeamSetAuthorityTool(solanaKit),
new SolanaFluxbeamRevokeAuthorityTool(solanaKit),
new SolanaFluxbeamCreateMintV1Tool(solanaKit),
new SolanaFluxbeamCreateMintV2Tool(solanaKit),
new SolanaFluxbeamCreateTokenV1Tool(solanaKit),
new SolanaFluxbeamCreateTokenV2Tool(solanaKit),
new SolanaFluxbeamGetClaimWithheldTokensFromMintTool(solanaKit),
new SolanaFluxbeamGetClaimWithheldTokensToMintTool(solanaKit),
new SolanaFluxbeamGetClaimWithheldTokensTool(solanaKit),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/* eslint-disable no-console */
import {
fetchQuote,
swapFromSolana,
Quote,
SolanaTransactionSigner,
} from "@mayanfinance/swap-sdk";
import { SolanaAgentKit } from "../agent";
import { fetchQuote, swapFromSolana } from "@mayanfinance/swap-sdk";
import { SolanaAgentKit } from "../../agent";
import { Transaction, VersionedTransaction } from "@solana/web3.js";

export enum Chain {
Expand Down
Loading

0 comments on commit 2210119

Please sign in to comment.