Skip to content

Commit

Permalink
query and lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dixitaniket committed Jul 28, 2023
1 parent 645870e commit 155d28b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
11 changes: 5 additions & 6 deletions cosmwasm/contracts/price-feed/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,16 +1076,14 @@ mod tests {
.map(|r| Uint64::new(*r))
.collect::<Vec<Uint64>>();


let symbol_rates: Vec<(String, Vec<Uint64>)> = symbols
.iter()
.zip(std::iter::repeat(deviations.clone()))
.map(|(s, r)| (s.to_owned(), r))
.collect();


let msg = ForceRelayHistoricalDeviation {
symbol_rates:symbol_rates.clone(),
symbol_rates: symbol_rates.clone(),
resolve_time: Uint64::from(100u64),
request_id: Uint64::from(2u64),
};
Expand All @@ -1099,14 +1097,12 @@ mod tests {
.map(|r| Uint64::new(*r))
.collect::<Vec<Uint64>>();


let forced_deviation_symbol_rates: Vec<(String, Vec<Uint64>)> = symbols
.iter()
.zip(std::iter::repeat(forced_deviations.clone()))
.map(|(s, r)| (s.to_owned(), r))
.collect();


let msg = ForceRelayHistoricalDeviation {
symbol_rates: forced_deviation_symbol_rates.clone(),
resolve_time: Uint64::from(10u64),
Expand All @@ -1118,7 +1114,10 @@ mod tests {
let reference_datas =
query_deviation_ref_bulk(deps.as_ref(), &symbols.clone()).unwrap();

for (expected, actual) in forced_deviation_symbol_rates.iter().zip(reference_datas.iter()) {
for (expected, actual) in forced_deviation_symbol_rates
.iter()
.zip(reference_datas.iter())
{
assert_eq!(expected.1, actual.rates)
}
}
Expand Down
6 changes: 3 additions & 3 deletions cosmwasm/contracts/price-feed/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cosmwasm_std::Uint64;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::state::{RefData, RefMedianData, ReferenceData};
use crate::state::{RefData, RefMedianData, ReferenceData,RefDeviationData};

#[cw_serde]
pub struct InstantiateMsg {}
Expand Down Expand Up @@ -135,14 +135,14 @@ pub enum QueryMsg {
// Vector of Symbols to query
symbols: Vec<String>,
},
#[returns(RefData)]
#[returns(RefDeviationData)]
// Returns the deviation RefData of a given symbol
GetDeviationRef {
// Symbol to query
symbol: String,
},

#[returns(Vec < RefData >)]
#[returns(Vec < RefDeviationData >)]
// Returns the deviation RefData of the given symbols
GetDeviationRefBulk {
// Vector of Symbols to query
Expand Down
2 changes: 1 addition & 1 deletion cw-relayer/relayer/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (oc RelayerClient) BroadcastContractQuery(
timeout time.Duration,
queries ...SmartQuery,
) ([]QueryResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

g, _ := errgroup.WithContext(ctx)
Expand Down
6 changes: 3 additions & 3 deletions cw-relayer/relayer/dep/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (m SecretMsg) Serialize() []byte {
return append(m.CodeHash, m.Msg...)
}

func (msg MsgExecuteContract) ValidateBasic() error {
func (msg *MsgExecuteContract) ValidateBasic() error {
if err := sdk.VerifyAddressFormat(msg.Sender); err != nil {
return err
}
Expand All @@ -30,12 +30,12 @@ func (msg MsgExecuteContract) ValidateBasic() error {
}

if !msg.SentFunds.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "sentFunds")
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "sentFunds") //nolint
}

return nil
}

func (msg MsgExecuteContract) GetSigners() []sdk.AccAddress {
func (msg *MsgExecuteContract) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Sender}
}
4 changes: 2 additions & 2 deletions cw-relayer/relayer/dep/utils/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func (msg RaAuthenticate) ValidateBasic() error {
}

if len(msg.Certificate) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Authenticating certificate cannot be empty")
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Authenticating certificate cannot be empty") //nolint
}

if len(msg.Certificate) > MaxCertificateSize {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "certificate length too large")
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "certificate length too large") //nolint
}

return nil
Expand Down

0 comments on commit 155d28b

Please sign in to comment.