Skip to content

Conversation

@Canvinus
Copy link
Contributor

@Canvinus Canvinus commented Dec 2, 2025

This pull request updates the build environment and adds new query methods to the SourceScan contract, along with corresponding tests to ensure correct behavior. The changes improve compatibility with newer Rust versions and enhance contract querying capabilities.

Build environment updates:

  • Updated Docker image and Rust toolchain versions in Cargo.toml and rust-toolchain.toml to use Rust 1.86.0 and sourcescan/cargo-near:0.17.0, ensuring compatibility with newer tools and features. [1] [2]
  • Modified the container build command to include non-reproducible-wasm and --locked flags for more robust builds.

New contract query methods:

  • Added get_contracts_by_code_hash method to SourceScan, allowing retrieval of all verified contracts sharing the same code hash. This helps identify contracts deployed to multiple accounts with identical code.
  • Added get_contracts_count method to return the total number of verified contracts, providing a simple way to monitor contract volume.

Testing enhancements:

  • Added unit tests for both new methods to verify correct filtering by code hash and accurate contract counting, including edge cases for zero, one, and multiple contracts.

- add get_contracts_by_code_hash() to find verified contracts by hash
- add get_contracts_count() to return total verified contracts
- add unit tests for new functions
- update rust toolchain to 1.85.0
- update dependencies
Copilot AI review requested due to automatic review settings December 2, 2025 12:07
@Canvinus Canvinus merged commit e63fcff into v2 Dec 2, 2025
1 of 3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the build environment to Rust 1.86.0 and adds two new query methods to the SourceScan contract for retrieving verified contract information by code hash and getting contract counts. The changes also include comprehensive unit tests for the new functionality.

Key Changes:

  • Upgraded Rust toolchain and Docker build environment
  • Added get_contracts_by_code_hash method to query contracts sharing the same code hash
  • Added get_contracts_count method to return total verified contract count

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib.rs Added two new public query methods with comprehensive unit tests
rust-toolchain.toml Updated Rust version (with version mismatch issue)
Cargo.toml Updated Docker image and modified container build command
Cargo.lock Updated dependency versions to match new toolchain
.gitignore Added /backups directory to ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

# the command may be any combination of flags of `cargo-near`,
# supported by respective version of binary inside the container besides `--no-locked` flag
container_build_command = ["cargo", "near", "build"]
container_build_command = ["cargo", "near", "build", "non-reproducible-wasm", "--locked"]
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The build command includes non-reproducible-wasm as a positional argument, but based on the cargo-near CLI structure, this should be prefixed with -- as a flag. The correct format should be --non-reproducible-wasm.

Suggested change
container_build_command = ["cargo", "near", "build", "non-reproducible-wasm", "--locked"]
container_build_command = ["cargo", "near", "build", "--non-reproducible-wasm", "--locked"]

Copilot uses AI. Check for mistakes.
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.73.0"
channel = "1.85.0"
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The rust version is updated to "1.85.0" but the PR description and Cargo.toml specify Rust 1.86.0. This inconsistency could lead to build issues. The version should be "1.86.0" to match the docker image sourcescan/cargo-near:0.17.0-rust-1.86.0.

Suggested change
channel = "1.85.0"
channel = "1.86.0"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants