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
3 changes: 0 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@
"dependencies": {
"@noble/curves": "^1.6.0",
"@noble/hashes": "^1.5.0",
"@polkadot/api": "^15.8.1",
"@subsquid/ss58": "^2.0.2",
"polkadot-api": "^1.9.13"
},
"devDependencies": {
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.9",
"@codecov/rollup-plugin": "^1.9.0",
"@polkadot/api": "^15.8.1",
"@polkadot/types": "^15.8.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^12.1.2",
Expand Down
8 changes: 1 addition & 7 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@
"dependencies": {
"@paraspell/sdk": "^10.5.2",
"@polkadot-agent-kit/common": "workspace:*",
"@polkadot/util-crypto": "^13.5.1",
"@subsquid/ss58": "^2.0.2",
"polkadot-api": "^1.9.13",
"rxjs": "^7.8.2",
"@substrate/asset-transfer-api": "^0.7.2",
"@polkadot/api": "^16.2.2",
"@polkadot/keyring": "^13.5.1"
"rxjs": "^7.8.2"
},
"devDependencies": {
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.9",
"@codecov/rollup-plugin": "^1.9.0",
"@polkadot/api": "^15.8.1",
"@polkadot/types": "^15.8.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^12.1.2",
Expand Down
27 changes: 4 additions & 23 deletions packages/core/src/types/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { KeyringPair } from "@polkadot/keyring/types"
import type { TxResult as TxResultXcm } from "@substrate/asset-transfer-api"
import type { PolkadotSigner, TxEvent } from "polkadot-api"
import type { Observable } from "rxjs"

Expand Down Expand Up @@ -28,34 +26,17 @@ export interface SubmitAndWatchOptionsPolkadot {
signer: PolkadotSigner
}

export interface SubmitAndWatchOptionsKeypair {
transaction: TxResultXcm<"submittable">
signer: KeyringPair
}

export type SubmitAndWatchOptions = SubmitAndWatchOptionsPolkadot | SubmitAndWatchOptionsKeypair
export type SubmitAndWatchOptions = SubmitAndWatchOptionsPolkadot

export function isTxWithPolkadotSigner(
options: SubmitAndWatchOptions
): options is SubmitAndWatchOptionsPolkadot {
return (
!!options.transaction &&
typeof (options.transaction as Tx).signSubmitAndWatch === "function" &&
typeof options.transaction.signSubmitAndWatch === "function" &&
!!options.signer &&
options.signer.publicKey instanceof Uint8Array &&
typeof (options.signer as PolkadotSigner).signTx === "function" &&
typeof (options.signer as PolkadotSigner).signBytes === "function"
)
}

export function isTxXcmWithKeypair(
options: SubmitAndWatchOptions
): options is SubmitAndWatchOptionsKeypair {
return (
!!options.transaction &&
typeof (options.transaction as TxResultXcm<"submittable">).tx?.signAndSend === "function" &&
!!options.signer &&
typeof (options.signer as KeyringPair).address === "string" &&
typeof (options.signer as KeyringPair).sign === "function"
typeof options.signer.signTx === "function" &&
typeof options.signer.signBytes === "function"
)
}
84 changes: 0 additions & 84 deletions packages/core/src/utils/connection.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./connection"
export * from "./format"
export * from "./isValidAddress"
export * from "./signSubmitAndWatch"
38 changes: 1 addition & 37 deletions packages/core/src/utils/signSubmitAndWatch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { KeyringPair } from "@polkadot/keyring/types"
import type { TxResult as TxResultXcm } from "@substrate/asset-transfer-api"
import type { PolkadotSigner, TxEvent } from "polkadot-api"

import type { Tx, TxResult } from "../types"
import type { SubmitAndWatchOptions } from "../types/transaction"
import { hasTypeProperty, isTxWithPolkadotSigner, isTxXcmWithKeypair } from "../types/transaction"
import { hasTypeProperty, isTxWithPolkadotSigner } from "../types/transaction"

async function submitAndWatchTx(options: SubmitAndWatchOptions): Promise<TxResult> {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -51,30 +49,6 @@ async function submitAndWatchTx(options: SubmitAndWatchOptions): Promise<TxResul
})
}
}
// Handle Tx with KeyringPair using signAndSend
if (isTxXcmWithKeypair(options)) {
try {
options.transaction.tx
.signAndSend(options.signer)
.then(result => {
resolve({
success: true,
transactionHash: result.toString()
})
})
.catch((error: Error) => {
resolve({
success: false,
error: `Transaction failed: ${error.message}`
})
})
} catch (error) {
resolve({
success: false,
error: `Transaction failed: ${error instanceof Error ? error.message : String(error)}`
})
}
}
} catch (error) {
reject(error instanceof Error ? error : new Error(String(error)))
}
Expand All @@ -90,13 +64,3 @@ export async function submitTxWithPolkadotSigner(
): Promise<TxResult> {
return submitAndWatchTx({ transaction, signer })
}

/**
* Function to submit a transaction with a KeyringPair
*/
export async function submitXcmTxWithKeypair(
transaction: TxResultXcm<"submittable">,
signer: KeyringPair
): Promise<TxResult> {
return submitAndWatchTx({ transaction, signer })
}
5 changes: 1 addition & 4 deletions packages/llm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@
"@polkadot-labs/hdkd": "^0.0.13",
"@polkadot-labs/hdkd-helpers": "^0.0.13",
"@subsquid/ss58": "^2.0.2",
"@polkadot/api": "^15.8.1",
"polkadot-api": "^1.9.13",
"zod": "^3.24.3",
"@polkadot/keyring": "^13.5.1"
"zod": "^3.24.3"
},
"devDependencies": {
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.9",
"@codecov/rollup-plugin": "^1.9.0",
"@polkadot/api": "^15.8.1",
"@polkadot/types": "^15.8.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/llm/src/agent/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export class PolkadotAgentApi implements IPolkadotAgentApi {
}

getNativeBalanceTool(address: string): BalanceTool {
return checkBalanceTool(this.api.getAllApis(), address) as BalanceTool
return checkBalanceTool(this.api.getAllApis(), address) as unknown as BalanceTool
}

transferNativeTool(signer: PolkadotSigner): TransferTool {
return transferNativeTool(this.api.getAllApis(), signer) as TransferTool
return transferNativeTool(this.api.getAllApis(), signer) as unknown as TransferTool
}

xcmTransferNativeTool(signer: PolkadotSigner, sender: string): XcmTransferNativeAssetTool {
return xcmTransferNativeTool(signer, sender) as XcmTransferNativeAssetTool
return xcmTransferNativeTool(signer, sender) as unknown as XcmTransferNativeAssetTool
}
}
2 changes: 1 addition & 1 deletion packages/llm/src/langchain/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const checkBalanceTool = (apis: Map<KnownChainId, Api<KnownChainId>>, add
balance: formattedBalance,
symbol: balanceInfo.symbol,
chain
}
} as unknown as BalanceToolResult
},
result => `Balance on ${result.chain}: ${result.balance} ${result.symbol}`
)
Expand Down
7 changes: 1 addition & 6 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@
"@polkadot-agent-kit/llm": "workspace:*",
"@polkadot-labs/hdkd": "^0.0.13",
"@polkadot-labs/hdkd-helpers": "^0.0.13",
"@polkadot/api": "^15.8.1",
"@subsquid/ss58": "^2.0.2",
"polkadot-api": "^1.9.13",
"zod": "^3.24.3",
"@polkadot/keyring": "^13.5.1",
"@polkadot/util": "^13.5.1"
"zod": "^3.24.3"
},
"devDependencies": {
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.9",
"@codecov/rollup-plugin": "^1.9.0",
"@polkadot/api": "^15.8.1",
"@polkadot/types": "^15.8.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-typescript": "^12.1.2",
Expand Down
10 changes: 0 additions & 10 deletions packages/sdk/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { Keyring } from "@polkadot/keyring"
import type { KeyringPair } from "@polkadot/keyring/types"
import { hexToU8a } from "@polkadot/util"
import type { AgentConfig, Api, KnownChainId } from "@polkadot-agent-kit/common"
import { getAllSupportedChains, getChainById } from "@polkadot-agent-kit/common"
import type { IPolkadotApi } from "@polkadot-agent-kit/core"
Expand Down Expand Up @@ -170,11 +167,4 @@ export class PolkadotAgentKit implements IPolkadotApi, IPolkadotAgentApi {
return signer
}
}

private getKeyringPair(): KeyringPair {
const keyring = new Keyring({ type: "sr25519" })

const keypair = keyring.addFromSeed(hexToU8a(this.wallet))
return keypair
}
}
Loading