Skip to content

Commit 817063b

Browse files
committed
chore: fix lint and add type AccountData
1 parent 4d96950 commit 817063b

File tree

9 files changed

+29
-14
lines changed

9 files changed

+29
-14
lines changed

packages/common/src/types/account.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,16 @@ export interface BalanceInfo {
33
decimals: number
44
symbol: string
55
}
6+
7+
export interface AccountData {
8+
nonce: number;
9+
consumers: number;
10+
providers: number;
11+
sufficients: number;
12+
data: {
13+
free: bigint;
14+
reserved: bigint;
15+
frozen: bigint;
16+
flags: bigint;
17+
};
18+
}

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Polkadot Core exports
22
export * from "./api"
33
export * from "./pallets/assets"
4-
export * from "./utils"
54
export * from "./types"
5+
export * from "./utils"

packages/core/src/pallets/assets/getNativeBalance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Api, BalanceInfo, KnownChainId } from "@polkadot-agent-kit/common"
1+
import type { AccountData, Api, BalanceInfo, KnownChainId } from "@polkadot-agent-kit/common"
22
import { getAllSupportedChains, getChainById } from "@polkadot-agent-kit/common"
33

44
/**
@@ -11,7 +11,7 @@ export const getNativeBalance = async (
1111
api: Api<KnownChainId>,
1212
address: string
1313
): Promise<BalanceInfo> => {
14-
const balance = await api.query.System.Account.getValue(address)
14+
const balance = await api.query.System.Account.getValue(address) as AccountData
1515
const chain = getChainById(api.chainId, getAllSupportedChains())
1616

1717
return {
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import type { Api, KnownChainId } from "@polkadot-agent-kit/common"
22
import type { MultiAddress } from "@polkadot-api/descriptors"
33

4+
import type { Tx } from "../../types"
5+
46
/**
57
* Creates a transfer call for native assets
68
* @param api - The API instance to use for the transfer
79
* @param to - The recipient address
810
* @param amount - The amount to transfer
911
* @returns The transfer call
1012
*/
11-
export const transferNativeCall = (api: Api<KnownChainId>, to: MultiAddress, amount: bigint) => {
12-
// @ts-ignore
13-
return api.tx.Balances.transfer_keep_alive({ dest: to, value: amount }) as any
13+
export const transferNativeCall = (api: Api<KnownChainId>, to: MultiAddress, amount: bigint): Tx => {
14+
return api.tx.Balances.transfer_keep_alive({ dest: to, value: amount })
1415
}

packages/core/src/types/transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PolkadotSigner, TxEvent } from "polkadot-api"
1+
import type { PolkadotSigner, TxEvent } from "polkadot-api"
22
import type { Observable } from "rxjs"
33

44
export interface Tx {

packages/core/src/utils/signSubmitAndWatch.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { TxEvent, PolkadotSigner } from "polkadot-api"
2-
import { Tx, TxResult } from "../types"
1+
import type { PolkadotSigner,TxEvent } from "polkadot-api"
2+
3+
import type { Tx, TxResult } from "../types"
34

45
function hasTypeProperty(val: unknown): val is { type: string } {
56
return (
67
typeof val === "object" &&
78
val !== null &&
89
"type" in val &&
9-
typeof (val as any).type === "string"
10+
typeof (val as { type: unknown }).type === "string"
1011
)
1112
}
1213

packages/llm/src/agent/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { PolkadotApi } from "@polkadot-agent-kit/core"
2+
import type { PolkadotSigner } from "polkadot-api"
23

34
import { checkBalanceTool, transferNativeTool } from "../langchain"
45
import type { BalanceTool, TransferTool } from "../types"
5-
import { PolkadotSigner } from "polkadot-api"
66
/**
77
* Interface for Polkadot API implementations
88
* Defines the interface that all Polkadot chain types must follow

packages/llm/src/langchain/transfer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { tool } from "@langchain/core/tools"
22
import type { Api, KnownChainId } from "@polkadot-agent-kit/common"
33
import { getDecimalsByChainId, parseUnits } from "@polkadot-agent-kit/common"
4-
import { transferNativeCall, submitAndWatchTx } from "@polkadot-agent-kit/core"
4+
import { submitAndWatchTx,transferNativeCall } from "@polkadot-agent-kit/core"
5+
import type { PolkadotSigner } from "polkadot-api/signer"
56
import type { z } from "zod"
67

78
import type { TransferToolResult, transferToolSchema } from "../types"
89
import { ToolNames } from "../types/common"
910
import { toolConfigTransferNative } from "../types/transfer"
1011
import { executeTool, getApiForChain, validateAndFormatMultiAddress } from "../utils"
11-
import { PolkadotSigner } from "polkadot-api/signer"
1212
/**
1313
* Returns a tool that transfers native tokens to a specific address
1414
* @param api - The API instance to use for the transfer

packages/sdk/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { BalanceTool, IPolkadotAgentApi, TransferTool } from "@polkadot-age
66
import { PolkadotAgentApi } from "@polkadot-agent-kit/llm"
77
import { ed25519CreateDerive, sr25519CreateDerive } from "@polkadot-labs/hdkd"
88
import * as ss58 from "@subsquid/ss58"
9-
import { getPolkadotSigner, PolkadotSigner } from "polkadot-api/signer"
9+
import { getPolkadotSigner, type PolkadotSigner } from "polkadot-api/signer"
1010

1111
export class PolkadotAgentKit implements IPolkadotApi, IPolkadotAgentApi {
1212
private polkadotApi: PolkadotApi

0 commit comments

Comments
 (0)