Concordium / concordium-rust-smart-contracts

Libraries and tools for writing and testing smart contracts on Concordium
https://docs.rs/concordium-std/latest/concordium_std/
Mozilla Public License 2.0
57 stars 36 forks source link

Query contract module #400

Closed td202 closed 6 months ago

td202 commented 6 months ago

Purpose

Closes #399 Depends on https://github.com/Concordium/concordium-rust-sdk/pull/183

Adds support for smart contracts to query the module reference and contract name of smart contract instances.

Changes

Checklist

DOBEN commented 6 months ago

The contract name that we return from the query is appended by the init_ phrase (e.g. "init_contract"). Would it be better if we just return the contract part of the name for simplicity?

td202 commented 6 months ago

The contract name that we return from the query is appended by the init_ phrase (e.g. "init_contract"). Would it be better if we just return the contract part of the name for simplicity?

I went this way (partly) because [Owned]ContractName includes the init_ prefix, so it seemed sensible to use that. I didn't want to introduce a new type for the prefix-less contract name, as I feel that would be likely to create confusion, and I didn't really want to mess around too much with the representation of these existing types. While the prefix is clearly redundant, I don't think removing it achieves simplicity, and absent a stronger argument, I propose to keep it.

DOBEN commented 6 months ago

It would be great if the factory logs an event when a new contract is added to the factory. This is particularly useful in (e.g. the uniswapV2 protocol) since indexers pick up the new DEXMarket and provide analytics from that point on for the new trading pair.