@@ -123,19 +123,16 @@ const fetchChainDetails = (chainName: string) => {
123
123
124
124
const feeToken = chain . fees . fee_tokens ?. [ 0 ] ;
125
125
126
- if ( ! feeToken )
127
- throw new Error ( `Fee token not found for chain ${ chainName } ` ) ;
126
+ if ( ! feeToken ) throw new Error ( `Fee token not found for chain ${ chainName } ` ) ;
128
127
129
- const rpcUrl = chain . apis . rpc ?. [ 0 ] . address ;
128
+ const rpcUrl = chain . apis . rpc ?. [ 0 ] ? .address ;
130
129
131
130
if ( ! rpcUrl ) throw new Error ( `RPC URL not found for chain ${ chainName } ` ) ;
132
131
133
- const bech32Prefix = chain . bech32_prefix ;
134
-
135
132
return {
136
133
chainName,
137
134
rpcUrl,
138
- bech32Prefix,
135
+ bech32Prefix : chain . bech32_prefix ,
139
136
feeToken,
140
137
} ;
141
138
} ;
@@ -149,8 +146,8 @@ export const initWalletProvider = async (
149
146
if ( ! mnemonic ) {
150
147
throw new Error ( "COSMOS_RECOVERY_PHRASE is missing" ) ;
151
148
}
152
- const characterChains = genCosmosChainsFromRuntime ( runtime ) ;
153
149
150
+ const characterChains = genCosmosChainsFromRuntime ( runtime ) ;
154
151
const provider = new CosmosWalletProvider ( mnemonic , characterChains ) ;
155
152
156
153
await provider . initialize ( chainName ) ;
@@ -164,24 +161,25 @@ export const cosmosWalletProvider: Provider = {
164
161
message : Memory ,
165
162
state ?: State
166
163
) : Promise < string | null > {
167
- try {
168
- const transferContext = composeContext ( {
169
- state : state ,
170
- template : balanceTemplate ,
171
- templatingEngine : "handlebars" ,
172
- } ) ;
173
-
174
- // Generate transfer content
175
- const content = await generateObjectDeprecated ( {
176
- runtime,
177
- context : transferContext ,
178
- modelClass : ModelClass . LARGE ,
179
- } ) ;
180
-
181
- const balanceContentValidator = z . object ( {
182
- chainName : z . string ( ) ,
183
- } ) ;
184
164
165
+ const transferContext = composeContext ( {
166
+ state : state ,
167
+ template : balanceTemplate ,
168
+ templatingEngine : "handlebars" ,
169
+ } ) ;
170
+
171
+ // Generate transfer content
172
+ const content = await generateObjectDeprecated ( {
173
+ runtime,
174
+ context : transferContext ,
175
+ modelClass : ModelClass . SMALL ,
176
+ } ) ;
177
+
178
+ const balanceContentValidator = z . object ( {
179
+ chainName : z . string ( ) ,
180
+ } ) ;
181
+
182
+ try {
185
183
const transferContent = balanceContentValidator . parse ( content ) ;
186
184
187
185
const { chainName } = transferContent ;
@@ -194,7 +192,7 @@ export const cosmosWalletProvider: Provider = {
194
192
195
193
return `Address: ${ address } \nBalance: ${ balance . amount } ${ balance . denom } \nActive Chain: ${ activeChain } ` ;
196
194
} catch ( error ) {
197
- console . error ( "Error in Cosmos wallet provider:" , error ) ;
195
+ console . error ( "Error Initializing in Cosmos wallet provider:" , error ) ;
198
196
199
197
return null ;
200
198
}
0 commit comments