@@ -17,9 +17,11 @@ export interface TransferContent extends Content {
17
17
amount : string ;
18
18
}
19
19
20
- function isTransferContent ( runtime : IAgentRuntime , content : any ) : content is TransferContent {
20
+ function isTransferContent ( _runtime : IAgentRuntime , content : unknown ) : content is TransferContent {
21
21
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"
23
25
) ;
24
26
}
25
27
@@ -53,7 +55,7 @@ export default {
53
55
"PAY_ON_INITIA"
54
56
] ,
55
57
description : "" ,
56
- validate : async ( runtime : IAgentRuntime , message : Memory ) => {
58
+ validate : async ( runtime : IAgentRuntime , _message : Memory ) => {
57
59
const privateKey = runtime . getSetting ( "INITIA_PRIVATE_KEY" ) ;
58
60
return typeof privateKey === "string" && privateKey . startsWith ( "0x" ) ;
59
61
} ,
@@ -64,14 +66,17 @@ export default {
64
66
_options : { [ key : string ] : unknown } ,
65
67
callback ?: HandlerCallback
66
68
) : 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 ;
69
73
} else {
70
- state = await runtime . updateRecentMessageState ( state ) ;
74
+ currentState = await runtime . updateRecentMessageState ( currentState ) ;
71
75
}
72
76
77
+
73
78
const transferContext = composeContext ( {
74
- state,
79
+ state : currentState ,
75
80
template : transferTemplate ,
76
81
} ) ;
77
82
@@ -108,11 +113,11 @@ export default {
108
113
const txResult = await walletProvider . sendTransaction ( signedTx ) ;
109
114
if ( callback ) {
110
115
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 } `
116
121
} ) ;
117
122
}
118
123
return true ;
0 commit comments