Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F/dummy contract auction #246

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
355 changes: 181 additions & 174 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ethereum-types = { version = "0.5.2" }
hex = { version = "0.4.3", features = [ "serde" ] }
injective-cosmwasm = { version = "0.3.0", path = "./packages/injective-cosmwasm" }
injective-math = { version = "0.3.0", path = "./packages/injective-math" }
injective-std = { version = "1.13.0", path = "./packages/injective-std" }
injective-std = { version = "1.13.2-auction", path = "./packages/injective-std" }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Issues Found:

  • Malformed Version in Cargo.toml: The injective-std dependency in Cargo.toml has an incorrect version specification:

    injective-std = { version = "1.13.2-auction
    1.13.0", path = "./packages/injective-std" }
    

    This should be corrected to:

    injective-std = { version = "1.13.2-auction", path = "./packages/injective-std" }
    
  • Missing injective-std Dependencies: The following Cargo.toml files are missing the injective-std dependency and should be updated accordingly:

    • contracts/atomic-order-example/Cargo.toml
    • contracts/dummy/Cargo.toml
    • contracts/injective-cosmwasm-mock/Cargo.toml
    • contracts/injective-cosmwasm-stargate-example/Cargo.toml
    • packages/injective-cosmwasm/Cargo.toml
    • packages/injective-math/Cargo.toml
    • packages/injective-std/Cargo.toml
    • packages/injective-std-derive/Cargo.toml
    • packages/injective-testing/Cargo.toml

Please address these issues to ensure consistency and prevent potential build or runtime errors.

🔗 Analysis chain

LGTM: Version update for injective-std looks good.

The update of injective-std to version "1.13.2-auction" aligns with the PR objectives, suggesting improvements to auction-related functionality. This minor version bump should maintain compatibility while introducing new features or fixes.

To ensure consistency across the project, please run the following script:

This script will help identify any inconsistencies in the injective-std version across the project and highlight direct imports that might need attention due to the version change.


This script will iterate through all Cargo.toml files in the project, extract the version of injective-std, and report any instances where the version does not match 1.13.2-auction. This will help ensure that the dependency update is consistent across the entire codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the version of injective-std across the project

# Check for any occurrences of injective-std with different versions
rg --type toml 'injective-std.*version\s*=\s*"(?!1\.13\.2-auction)' -g 'Cargo.toml'

# If the above command returns no results, it means all occurrences are consistent
# with the new version. Otherwise, it will show the inconsistent entries.

echo "Checking for any direct imports of injective-std to ensure they are compatible with the new version:"
rg --type rust '^use injective_std' -g '!packages/injective-std/**'

Length of output: 1373


Script:

#!/bin/bash
# Description: Verify the version of injective-std across all Cargo.toml files

# Find all Cargo.toml files
fd -g 'Cargo.toml' | while read -r file; do
  # Extract the version of injective-std in each Cargo.toml
  version=$(grep 'injective-std' "$file" | grep -oP 'version\s*=\s*"\K[^"]+')
  if [[ -z "$version" ]]; then
    echo "injective-std not found in $file"
  elif [[ "$version" != "1.13.2-auction" ]]; then
    echo "Version mismatch in $file: found $version, expected 1.13.2-auction"
  fi
done

Length of output: 2958

injective-std-derive = { version = "1.13.0", path = "./packages/injective-std-derive" }
injective-test-tube = { version = "1.13.2" }
injective-testing = { version = "1.1.0", path = "./packages/injective-testing" }
Expand Down
1 change: 1 addition & 0 deletions contracts/dummy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
injective-cosmwasm = { path = "../../packages/injective-cosmwasm" }
injective-std = { path = "../../packages/injective-std" }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
1 change: 1 addition & 0 deletions contracts/dummy/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn instantiate(
_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

COUNTER.save(deps.storage, &0u32)?;
ACTIVE.save(deps.storage, &false)?;
Ok(Response::new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ fn test_query_grantee_grants() {
env.users[1].account.address().to_string(),
);

let combined_grants = response_user0
.grants
.into_iter()
.chain(response_user2.grants.into_iter())
.collect::<Vec<_>>();
let combined_grants = response_user0.grants.into_iter().chain(response_user2.grants).collect::<Vec<_>>();
let query_result = get_stargate_query_result::<StargateQueryGranteeGrantsResponse>(wasm.query(&env.contract_address, &query_msg)).unwrap();

let all_grants_present = combined_grants.iter().all(|grant| query_result.grants.contains(grant));
Expand Down Expand Up @@ -125,15 +121,14 @@ fn test_query_grants() {
};

let contract_response: RunnerResult<QueryStargateResponse> = wasm.query(&env.contract_address, &query_msg);
println!("{:?}", contract_response);

if let Err(QueryError { msg }) = contract_response {
assert_eq!(
msg, "Generic error: Querier contract error: codespace: authz, code: 2: query wasm contract failed",
"The error message does not match the expected value"
);
} else {
assert!(false, "Expected an error, but got a success: {:?}", contract_response);
panic!("Expected an error, but got a success: {:?}", contract_response);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/injective-cosmwasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
ethereum-types = { workspace = true }
hex = { workspace = true }
injective-math = { workspace = true, path = "../../packages/injective-math" }
injective-math = { path = "../../packages/injective-math" }
schemars = { workspace = true }
serde = { workspace = true }
serde_repr = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion packages/injective-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0"
name = "injective-std"
readme = "README.md"
repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-std"
version = "1.13.0"
version = "1.13.2-auction"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -auction ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's got some hacks for the auction module


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
28 changes: 20 additions & 8 deletions packages/injective-std/src/types/injective/auction/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ pub struct Params {
pub struct Bid {
#[prost(string, tag = "1")]
pub bidder: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
// #[prost(string, tag = "2")]
// pub amount: ::prost::alloc::string::String,
// NOTE: THIS IS A FIX FOR RUST BINDINGS, PLEASE COPY IN FUTURE RELEASES
#[prost(message, optional, tag = "2")]
pub amount: ::core::option::Option<super::super::super::cosmos::base::v1beta1::Coin>,
Comment on lines +23 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Changing field type may cause backward compatibility issues

Modifying the amount field type from String to Option<Coin> in the Bid struct can lead to compatibility issues with existing data or services. Please ensure that this change is safe and compatible with all clients and services that use this struct.

}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, Eq, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
Expand All @@ -31,8 +34,11 @@ pub struct LastAuctionResult {
#[prost(string, tag = "1")]
pub winner: ::prost::alloc::string::String,
/// amount describes the amount the winner get from the auction
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
// #[prost(string, tag = "2")]
// pub amount: ::prost::alloc::string::String,
// NOTE: THIS IS A FIX FOR RUST BINDINGS, PLEASE COPY IN FUTURE RELEASES
#[prost(message, optional, tag = "2")]
pub amount: ::core::option::Option<super::super::super::cosmos::base::v1beta1::Coin>,
Comment on lines +37 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Changing field type may cause backward compatibility issues

The amount field in the LastAuctionResult struct has been changed from String to Option<Coin>, which might affect compatibility with existing data and services. Please verify that this change does not introduce any issues.

/// round defines the round number of auction
#[prost(uint64, tag = "3")]
#[serde(
Expand All @@ -49,8 +55,11 @@ pub struct EventBid {
#[prost(string, tag = "1")]
pub bidder: ::prost::alloc::string::String,
/// amount describes the amount the bidder put on the auction
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
// #[prost(string, tag = "2")]
// pub amount: ::prost::alloc::string::String,
// NOTE: THIS IS A FIX FOR RUST BINDINGS, PLEASE COPY IN FUTURE RELEASES
#[prost(message, optional, tag = "2")]
pub amount: ::core::option::Option<super::super::super::cosmos::base::v1beta1::Coin>,
Comment on lines +58 to +62
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Changing field type may cause backward compatibility issues

The amount field in the EventBid struct has been updated from String to Option<Coin>. Ensure that this change is compatible with all clients and services using this struct.

/// round defines the round number of auction
#[prost(uint64, tag = "3")]
#[serde(
Expand All @@ -67,8 +76,11 @@ pub struct EventAuctionResult {
#[prost(string, tag = "1")]
pub winner: ::prost::alloc::string::String,
/// amount describes the amount the winner get from the auction
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
// #[prost(string, tag = "2")]
// pub amount: ::prost::alloc::string::String,
// NOTE: THIS IS A FIX FOR RUST BINDINGS, PLEASE COPY IN FUTURE RELEASES
#[prost(message, optional, tag = "2")]
pub amount: ::core::option::Option<super::super::super::cosmos::base::v1beta1::Coin>,
Comment on lines +79 to +83
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Changing field type may cause backward compatibility issues

The amount field in the EventAuctionResult struct has been modified from String to Option<Coin>. Verify that this change does not introduce compatibility issues with existing data or services.

/// round defines the round number of auction
#[prost(uint64, tag = "3")]
#[serde(
Expand Down
6 changes: 3 additions & 3 deletions packages/injective-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ anyhow = { workspace = true }
base64 = { workspace = true }
cosmwasm-std = { workspace = true }
cw-multi-test = { workspace = true }
injective-cosmwasm = { version = "0.3.1", path = "../injective-cosmwasm" }
injective-math = { version = "0.3.0", path = "../injective-math" }
injective-std = { version = "1.13.0", path = "../injective-std" }
injective-cosmwasm = { path = "../injective-cosmwasm" }
injective-math = { path = "../injective-math" }
injective-std = { path = "../injective-std" }
injective-test-tube = { workspace = true }
prost = { workspace = true }
rand = { workspace = true }
Expand Down
Loading