@@ -9,7 +9,7 @@ use figment::{
99 Figment ,
1010} ;
1111
12- use crate :: { AddressHrp , ContractType , CosmosBuilder , CosmosNetwork } ;
12+ use crate :: { gas_price :: GasPriceMethod , AddressHrp , ContractType , CosmosBuilder , CosmosNetwork } ;
1313
1414/// Configuration overrides for individual network
1515#[ derive( Debug ) ]
@@ -36,6 +36,8 @@ struct NetworkConfig {
3636 gas_multiplier : Option < f64 > ,
3737 #[ serde( default , skip_serializing_if = "BTreeMap::is_empty" ) ]
3838 code_ids : BTreeMap < ContractType , u64 > ,
39+ low_gas_price : Option < f64 > ,
40+ high_gas_price : Option < f64 > ,
3941}
4042
4143impl NetworkConfig {
@@ -52,9 +54,6 @@ impl NetworkConfig {
5254 if let Some ( hrp) = self . hrp {
5355 builder. set_hrp ( hrp) ;
5456 }
55- for ( contract_type, code_id) in & self . code_ids {
56- builder. set_code_id ( * contract_type, * code_id) ;
57- }
5857 }
5958 fn apply_extra_config ( & self , builder : & mut CosmosBuilder ) {
6059 for fallback in & self . grpc_fallbacks {
@@ -66,6 +65,18 @@ impl NetworkConfig {
6665 if let Some ( gas_multiplier) = self . gas_multiplier {
6766 builder. set_gas_estimate_multiplier ( gas_multiplier)
6867 }
68+ let gas_price = match ( self . low_gas_price , self . high_gas_price ) {
69+ ( None , None ) => None ,
70+ ( Some ( x) , None ) => Some ( ( x, x) ) ,
71+ ( None , Some ( x) ) => Some ( ( x, x) ) ,
72+ ( Some ( x) , Some ( y) ) => Some ( ( x, y) ) ,
73+ } ;
74+ if let Some ( ( low, high) ) = gas_price {
75+ builder. set_gas_price_method ( GasPriceMethod :: new_static ( low, high) ) ;
76+ }
77+ for ( contract_type, code_id) in & self . code_ids {
78+ builder. set_code_id ( * contract_type, * code_id) ;
79+ }
6980 }
7081}
7182
@@ -212,6 +223,8 @@ impl CosmosConfig {
212223 grpc_fallbacks,
213224 gas_multiplier,
214225 code_ids,
226+ low_gas_price,
227+ high_gas_price,
215228 } ,
216229 ) in networks
217230 {
@@ -235,6 +248,12 @@ impl CosmosConfig {
235248 if let Some ( gas_multiplier) = gas_multiplier {
236249 println ! ( "Gas multiplier: {gas_multiplier}" ) ;
237250 }
251+ if let Some ( low) = low_gas_price {
252+ println ! ( "Low gas price: {low}" ) ;
253+ }
254+ if let Some ( high) = high_gas_price {
255+ println ! ( "High gas price: {high}" ) ;
256+ }
238257 for ( contract_type, code_id) in code_ids {
239258 println ! ( "Code ID for {contract_type}: {code_id}" ) ;
240259 }
@@ -260,6 +279,8 @@ impl CosmosConfig {
260279 grpc_fallbacks : vec ! [ ] ,
261280 gas_multiplier : None ,
262281 code_ids : BTreeMap :: new ( ) ,
282+ low_gas_price : None ,
283+ high_gas_price : None ,
263284 } ,
264285 ) ;
265286 }
@@ -325,6 +346,16 @@ impl CosmosConfig {
325346 . code_ids
326347 . insert ( contract_type, code_id) ;
327348 }
349+
350+ /// Set the low gas price
351+ pub fn set_low_gas_price ( & mut self , name : String , low : f64 ) {
352+ self . inner . network . entry ( name) . or_default ( ) . low_gas_price = Some ( low) ;
353+ }
354+
355+ /// Set the high gas price
356+ pub fn set_high_gas_price ( & mut self , name : String , high : f64 ) {
357+ self . inner . network . entry ( name) . or_default ( ) . high_gas_price = Some ( high) ;
358+ }
328359}
329360
330361impl CosmosNetwork {
0 commit comments