Skip to content

Conversation

@moliholy
Copy link
Collaborator

@moliholy moliholy commented Oct 16, 2025

Closes #678.

This PR:

  • Allows to query contract storage.
  • Refactors the command to make suri and url optional.
  • Adapts the tests.

Screenshots

Screenshot 2025-10-15 at 19 25 28
Screenshot 2025-10-15 at 19 26 01

This functionality avoids asking the user and accelerates the process
@Daanvdplas Daanvdplas requested a review from Copilot October 23, 2025 07:59
Copy link
Contributor

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 adds contract storage reading capabilities and refactors the contract call command to make chain URL and signer URI optional parameters. Key changes include:

  • New functionality to query and display contract storage values
  • Refactored CallContractCommand to make --url and --suri optional with improved user prompts
  • Extracted RPC endpoint selection logic into a reusable module
  • Enhanced contract metadata parsing to support both functions and storage items

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/pop-contracts/src/utils/metadata.rs Adds ContractCallable, ContractStorage types and functions to fetch/parse storage items from contract metadata
crates/pop-contracts/src/lib.rs Exports new storage-related types and functions
crates/pop-contracts/src/call.rs Moves contract parsing before signer creation and token metadata query
crates/pop-common/src/lib.rs Moves #[cfg(feature = "integration-tests")] attribute to correct position
crates/pop-cli/tests/contract.rs Updates test to use --dev flag and simplifies process termination
crates/pop-cli/src/common/rpc.rs New module extracting RPC endpoint selection logic with chain filtering
crates/pop-cli/src/common/mod.rs Adds rpc module to exports
crates/pop-cli/src/common/chain.rs Refactors to use extracted prompt_to_select_chain_rpc function
crates/pop-cli/src/commands/up/rollup.rs Updates configure calls with new select_message parameter
crates/pop-cli/src/commands/up/contract.rs Improves contract deployment flow with better RPC selection and optional parameters
crates/pop-cli/src/commands/mod.rs Passes CLI reference to contract call execution
crates/pop-cli/src/commands/call/contract.rs Major refactor making --url and --suri optional, adding storage reading support
crates/pop-cli/src/commands/call/chain.rs Updates prompts and configure calls with new parameter
Comments suppressed due to low confidence (1)

crates/pop-cli/src/commands/call/contract.rs:1

  • Line 159 evaluates the comparison self.url == local_url but doesn't assign the result to any variable. This appears to be a logic error - the intent seems to be to assign this boolean to start_local_node, but instead it's just a standalone expression with no effect.
// SPDX-License-Identifier: GPL-3.0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

Awesome!

Mainly a nit about providing a hint implementation for ContractCallable as it was done for CallItem for chains.

I have provided input on some of copilots messages based on what I could see.

Copy link
Member

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

Approving as all my feedback has been already incorporated 👍

Thanks, @moliholy :)

Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

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

Awesome! So happy to unblock this one and merge it

@moliholy moliholy merged commit 2ecdda1 into main Oct 31, 2025
19 checks passed
@moliholy moliholy deleted the feat/contract-call-read branch October 31, 2025 14:40
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.

Allow pop to read a contract's storage

5 participants