Skip to content
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
1 change: 0 additions & 1 deletion packages/common/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export * from "./account"
export * from "./agent"
export * from "./smoldot"
export * from "./transaction"
export * from "./xcm"
21 changes: 0 additions & 21 deletions packages/common/src/types/xcm.ts

This file was deleted.

20 changes: 1 addition & 19 deletions packages/llm/src/langchain/defi/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,11 @@ import type { z } from "zod"
import { ToolNames } from "../../types/common"
import { withTimeoutAndRetry } from "../../types/common"
import { DEFAULT_DEX, UNKNOWN_ERROR_MESSAGE } from "../../types/constants"
import type { SwapContext, TransactionResult } from "../../types/defi"
import type { SwapTokensToolResult, swapTokensToolSchema } from "../../types/defi/swap"
import { toolConfigSwapTokens } from "../../types/defi/swap"
import { executeTool } from "../../utils"

// Types for internal use
interface SwapContext {
from: string
to: string
currencyFrom: string
currencyTo: string
amount: string
sender: string
receiver: string
dex: string
isCrossChainSwap: boolean
}

interface TransactionResult {
success: boolean
transactionHash?: string
error?: string
}

/**
* Returns a tool that swaps tokens either across different chains or within a specific DEX
* Case 1: Cross-chain swap - provide 'from' and 'to' chains for XCM routing
Expand Down
21 changes: 2 additions & 19 deletions packages/llm/src/types/bifrost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DynamicStructuredTool } from "@langchain/core/tools"
import { z } from "zod"

import type { ToolConfig } from "./common"
import type { BaseToolCallResult, ToolConfig } from "./common"
import { ToolNames } from "./common"

export const mintVdotSchema = z.object({
Expand All @@ -16,21 +16,4 @@ export const toolConfigMintVdot: ToolConfig = {

export type MintVdotTool = DynamicStructuredTool<typeof mintVdotSchema>

export interface MintVdotToolResult {
/**
* Indicates whether the minting was successful.
*/
success: boolean

/**
* The transaction hash if the minting was submitted successfully.
* This may be undefined if the minting failed.
*/
transactionHash?: string

/**
* An error message if the minting failed.
* This will be undefined if the minting was successful.
*/
error?: string
}
export type MintVdotToolResult = BaseToolCallResult
10 changes: 10 additions & 0 deletions packages/llm/src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,13 @@ export interface Action<TActionSchema extends z.ZodSchema = z.ZodSchema> {
schema: TActionSchema
invoke: (args: z.infer<TActionSchema>) => Promise<string>
}

/**
* Base interface for transaction-based tool results.
* Provides common structure for tools that perform blockchain transactions.
*/
export interface BaseToolCallResult {
success: boolean
transactionHash?: string
error?: string
}
18 changes: 18 additions & 0 deletions packages/llm/src/types/defi/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
export * from "./swap"

export interface SwapContext {
from: string
to: string
currencyFrom: string
currencyTo: string
amount: string
sender: string
receiver: string
dex: string
isCrossChainSwap: boolean
}

export interface TransactionResult {
success: boolean
transactionHash?: string
error?: string
}
21 changes: 2 additions & 19 deletions packages/llm/src/types/identity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DynamicStructuredTool } from "@langchain/core/tools"
import { z } from "zod"

import type { ToolConfig } from "./common"
import type { BaseToolCallResult, ToolConfig } from "./common"
import { ToolNames } from "./common"

export const registerIdentitySchema = z.object({
Expand All @@ -24,21 +24,4 @@ export const toolConfigRegisterIdentity: ToolConfig = {

export type RegisterIdentityTool = DynamicStructuredTool<typeof registerIdentitySchema>

export interface RegisterIdentityToolResult {
/**
* Indicates whether the transfer was successful.
*/
success: boolean

/**
* The transaction hash if the transfer was submitted successfully.
* This may be undefined if the transfer failed.
*/
transactionHash?: string

/**
* An error message if the transfer failed.
* This will be undefined if the transfer was successful.
*/
error?: string
}
export type RegisterIdentityToolResult = BaseToolCallResult
29 changes: 2 additions & 27 deletions packages/llm/src/types/staking.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DynamicStructuredTool } from "@langchain/core/tools"
import { z } from "zod"

import type { ToolConfig } from "./common"
import type { BaseToolCallResult, ToolConfig } from "./common"
import { ToolNames } from "./common"

/**
Expand Down Expand Up @@ -121,32 +121,7 @@ export type WithdrawUnbondedTool = DynamicStructuredTool<typeof withdrawUnbonded
*/
export type ClaimRewardsTool = DynamicStructuredTool<typeof claimRewardsToolSchema>

/**
* The result of a staking tool operation.
*/
export interface StakingToolResult {
/**
* Indicates whether the operation was successful.
*/
success: boolean

/**
* The transaction hash if the operation was submitted successfully.
* This may be undefined if the operation failed.
*/
transactionHash?: string

/**
* An error message if the operation failed.
* This will be undefined if the operation was successful.
*/
error?: string

/**
* Additional data returned by the operation.
*/
data?: unknown
}
export type StakingToolResult = BaseToolCallResult

/**
* Configuration object for the join pool tool.
Expand Down
24 changes: 2 additions & 22 deletions packages/llm/src/types/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DynamicStructuredTool } from "@langchain/core/tools"
import { z } from "zod"

import type { ToolConfig } from "./common"
import type { BaseToolCallResult, ToolConfig } from "./common"
import { ToolNames } from "./common"

/**
Expand Down Expand Up @@ -34,27 +34,7 @@ export const transferToolSchema = z.object({
*/
export type TransferTool = DynamicStructuredTool<typeof transferToolSchema>

/**
* The result of a transfer tool operation.
*/
export interface TransferToolResult {
/**
* Indicates whether the transfer was successful.
*/
success: boolean

/**
* The transaction hash if the transfer was submitted successfully.
* This may be undefined if the transfer failed.
*/
transactionHash?: string

/**
* An error message if the transfer failed.
* This will be undefined if the transfer was successful.
*/
error?: string
}
export type TransferToolResult = BaseToolCallResult

/**
* Configuration object for the native token transfer tool.
Expand Down
24 changes: 2 additions & 22 deletions packages/llm/src/types/xcm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DynamicStructuredTool } from "@langchain/core/tools"
import { z } from "zod"

import type { ToolConfig } from "./common"
import type { BaseToolCallResult, ToolConfig } from "./common"
import { ToolNames } from "./common"

export const xcmTransferNativeAssetSchema = z.object({
Expand Down Expand Up @@ -30,27 +30,7 @@ export const xcmTransferNativeAssetSchema = z.object({
*/
export type XcmTransferNativeAssetTool = DynamicStructuredTool<typeof xcmTransferNativeAssetSchema>

/**
* The result of a transfer tool operation.
*/
export interface XcmTransferNativeAssetToolResult {
/**
* Indicates whether the transfer was successful.
*/
success: boolean

/**
* The transaction hash if the transfer was submitted successfully.
* This may be undefined if the transfer failed.
*/
transactionHash?: string

/**
* An error message if the transfer failed.
* This will be undefined if the transfer was successful.
*/
error?: string
}
export type XcmTransferNativeAssetToolResult = BaseToolCallResult

/**
* Configuration object for the native token transfer tool via xcm
Expand Down