@@ -178,47 +178,51 @@ func (cc *CosmosProvider) QueryBalanceWithAddress(ctx context.Context, address s
178
178
return coins , nil
179
179
}
180
180
181
- func (cc * CosmosProvider ) queryConsumerUnbondingPeriod ( ctx context.Context ) (time.Duration , error ) {
181
+ func (cc * CosmosProvider ) querySubspaceUnbondingPeriod ( subspace string , ctx context.Context ) (time.Duration , error ) {
182
182
queryClient := proposal .NewQueryClient (cc )
183
183
184
- params := proposal.QueryParamsRequest {Subspace : "ccvconsumer" , Key : "UnbondingPeriod" }
184
+ params := proposal.QueryParamsRequest {Subspace : subspace , Key : "UnbondingPeriod" }
185
185
186
186
resICS , err := queryClient .Params (ctx , & params )
187
187
188
188
if err != nil {
189
- return 0 , fmt .Errorf ("failed to make ccvconsumer params request: %w" , err )
189
+ return 0 , fmt .Errorf ("failed to make %s params request: %w" , subspace , err )
190
190
}
191
191
192
192
if resICS .Param .Value == "" {
193
- return 0 , fmt .Errorf ("ccvconsumer unbonding period is empty" )
193
+ return 0 , fmt .Errorf ("%s unbonding period is empty" , subspace )
194
194
}
195
195
196
196
unbondingPeriod , err := strconv .ParseUint (strings .ReplaceAll (resICS .Param .Value , `"` , "" ), 10 , 64 )
197
197
if err != nil {
198
- return 0 , fmt .Errorf ("failed to parse unbonding period from ccvconsumer param: %w" , err )
198
+ return 0 , fmt .Errorf ("failed to parse unbonding period from %s param: %w" , subspace , err )
199
199
}
200
200
201
201
return time .Duration (unbondingPeriod ), nil
202
202
}
203
203
204
204
// QueryUnbondingPeriod returns the unbonding period of the chain
205
205
func (cc * CosmosProvider ) QueryUnbondingPeriod (ctx context.Context ) (time.Duration , error ) {
206
- req := stakingtypes.QueryParamsRequest {}
207
- queryClient := stakingtypes .NewQueryClient (cc )
208
-
209
- res , err := queryClient .Params (ctx , & req )
210
- if err != nil {
211
- // Attempt ICS query
212
- consumerUnbondingPeriod , consumerErr := cc .queryConsumerUnbondingPeriod (ctx )
213
- if consumerErr != nil {
214
- return 0 ,
215
- fmt .Errorf ("failed to query unbonding period as both standard and consumer chain: %s: %w" , err .Error (), consumerErr )
216
- }
206
+ res , err := cc .QueryStakingParams (ctx )
207
+ if err == nil {
208
+ return res .UnbondingTime , nil
209
+ }
217
210
211
+ // Attempt ICS query
212
+ consumerUnbondingPeriod , consumerErr := cc .querySubspaceUnbondingPeriod ("ccvconsumer" , ctx )
213
+ if consumerErr == nil {
218
214
return consumerUnbondingPeriod , nil
219
215
}
220
216
221
- return res .Params .UnbondingTime , nil
217
+ poaUnbondingPeriod , poaErr := cc .querySubspaceUnbondingPeriod ("poa" , ctx )
218
+ if poaErr == nil {
219
+ return poaUnbondingPeriod , nil
220
+ }
221
+
222
+ return 0 , fmt .Errorf (
223
+ "failed to query unbonding period as both standard, consumer, and poa chain: %s, %s, %s" ,
224
+ err .Error (), consumerErr .Error (), poaErr .Error (),
225
+ )
222
226
}
223
227
224
228
// QueryTendermintProof performs an ABCI query with the given key and returns
0 commit comments