Skip to content

Commit ded7d38

Browse files
AIFlowMLwtfsayo
andauthored
Fixed all the typing issues (elizaOS#2974)
Co-authored-by: Sayo <hi@sayo.wtf>
1 parent 64975b2 commit ded7d38

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

packages/plugin-initia/src/actions/transfer.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ export interface TransferContent extends Content {
1717
amount: string;
1818
}
1919

20-
function isTransferContent(runtime: IAgentRuntime, content: any): content is TransferContent {
20+
function isTransferContent(_runtime: IAgentRuntime, content: unknown): content is TransferContent {
2121
return (
22-
typeof content.sender === "string" && typeof content.recipient === "string" && typeof content.amount === "number"
22+
typeof (content as TransferContent).sender === "string" &&
23+
typeof (content as TransferContent).recipient === "string" &&
24+
typeof (content as TransferContent).amount === "string"
2325
);
2426
}
2527

@@ -53,7 +55,7 @@ export default {
5355
"PAY_ON_INITIA"
5456
],
5557
description: "",
56-
validate: async (runtime: IAgentRuntime, message: Memory) => {
58+
validate: async (runtime: IAgentRuntime, _message: Memory) => {
5759
const privateKey = runtime.getSetting("INITIA_PRIVATE_KEY");
5860
return typeof privateKey === "string" && privateKey.startsWith("0x");
5961
},
@@ -64,14 +66,17 @@ export default {
6466
_options: { [key: string]: unknown },
6567
callback?: HandlerCallback
6668
): Promise<boolean> => {
67-
if (!state) {
68-
state = (await runtime.composeState(message)) as State;
69+
// Initialize or update state
70+
let currentState = state;
71+
if (!currentState) {
72+
currentState = (await runtime.composeState(message)) as State;
6973
} else {
70-
state = await runtime.updateRecentMessageState(state);
74+
currentState = await runtime.updateRecentMessageState(currentState);
7175
}
7276

77+
7378
const transferContext = composeContext({
74-
state,
79+
state: currentState,
7580
template: transferTemplate,
7681
});
7782

@@ -108,11 +113,11 @@ export default {
108113
const txResult = await walletProvider.sendTransaction(signedTx);
109114
if (callback) {
110115
callback({
111-
text: `Successfully transferred INITIA.\n` +
112-
`Transaction Hash: ${txResult.txhash}\n` +
113-
`Sender: ${content.sender}\n` +
114-
`Recipient: ${content.recipient}\n` +
115-
`Amount: ${content.amount}`
116+
text: `Successfully transferred INITIA.
117+
Transaction Hash: ${txResult.txhash}
118+
Sender: ${content.sender}
119+
Recipient: ${content.recipient}
120+
Amount: ${content.amount}`
116121
});
117122
}
118123
return true;

packages/plugin-initia/src/providers/wallet.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { IAgentRuntime, Provider, Memory, State } from "@elizaos/core";
1+
import type { IAgentRuntime, Provider, Memory, State } from "@elizaos/core";
22

3+
// Add type imports for Initia.js
4+
import type { Wallet, RESTClient, Tx } from '@initia/initia.js';
35

46
interface WalletProviderOptions {
57
chainId: string;
@@ -12,8 +14,8 @@ const DEFAULT_INITIA_TESTNET_CONFIGS: WalletProviderOptions = {
1214
}
1315

1416
export class WalletProvider {
15-
private wallet: any = null;
16-
private restClient: any = null;
17+
private wallet: Wallet | null = null;
18+
private restClient: RESTClient | null = null;
1719
private runtime: IAgentRuntime;
1820

1921
async initialize(runtime: IAgentRuntime, options: WalletProviderOptions = DEFAULT_INITIA_TESTNET_CONFIGS) {
@@ -59,13 +61,13 @@ export class WalletProvider {
5961
return this.wallet.rest.bank.balance(this.getAddress());
6062
}
6163

62-
async sendTransaction(signedTx: any) {
64+
async sendTransaction(signedTx: Tx | string) {
6365
return await this.restClient.tx.broadcast(signedTx);
6466
}
6567
}
6668

6769
export const initiaWalletProvider: Provider = {
68-
async get(runtime: IAgentRuntime, message: Memory, state?: State): Promise<string | null> {
70+
async get(runtime: IAgentRuntime, _message: Memory, _state?: State): Promise<string | null> {
6971
if (!runtime.getSetting("INITIA_PRIVATE_KEY")) {
7072
return null;
7173
}

0 commit comments

Comments
 (0)