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

Added instantiate2 #309

Merged
merged 9 commits into from
Feb 1, 2024
Merged

Conversation

Kayanski
Copy link
Contributor

@Kayanski Kayanski commented Jan 15, 2024

This PR aims at adding instantiate2 support directly inside the TxHandler trait

Closes ORC-62

Not using fix_msg because cosmwasm discourages it https://medium.com/cosmwasm/dev-note-3-limitations-of-instantiate2-and-how-to-deal-with-them-a3f946874230

Copy link

cloudflare-workers-and-pages bot commented Jan 15, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8201cd
Status:🚫  Build failed.

View logs

Copy link
Contributor

@Buckram123 Buckram123 left a comment

Choose a reason for hiding this comment

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

Would be nice to slightly improve user experience using instanitate2

Comment on lines +49 to +59
/// Send a Instantiate2Msg to a contract.
fn instantiate2<I: Serialize + Debug>(
&self,
code_id: u64,
init_msg: &I,
label: Option<&str>,
admin: Option<&Addr>,
coins: &[cosmwasm_std::Coin],
salt: Binary,
) -> Result<Self::Response, Self::Error>;

Copy link
Contributor

@Buckram123 Buckram123 Jan 15, 2024

Choose a reason for hiding this comment

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

Is it possible to return (yet) not executed instantiate2 struct instead? Main use for instantiate2 will be knowing the address, before instantiating. I'm expecting experience to be something like:

let contract1 = chain.instantiate2(...)?;
let contract1_addr = contract1.addr()?;
let contract2 = chain.instantiate2(...)?;
let contract2_addr = contract2.addr()?;
// ...
contract1.submit(Contract1InstantiateMsg{
    contract2_addr: contract2_addr.to_string()
})?;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand what you mean here ? You want a function that would return the instantiate2 addr if ever it was instantiated ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand what you mean here ? You want a function that would return the instantiate2 addr if ever it was instantiated ?

Yes, I want function that can return the address of pre-filled, but not executed instantiate2 message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using helpers such as https://docs.rs/cosmwasm-std/latest/cosmwasm_std/fn.instantiate2_address.html would be annoying, so I would prefer it to be as a part of API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK,implemented what we discussed

Copy link
Contributor

Choose a reason for hiding this comment

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

So this is now a method on the wasm querier correct?

packages/cw-orch-mock/src/core.rs Show resolved Hide resolved
packages/cw-orch-core/src/contract/contract_instance.rs Outdated Show resolved Hide resolved
cw-orch-daemon/src/core.rs Outdated Show resolved Hide resolved
cw-orch-daemon/src/core.rs Show resolved Hide resolved
cw-orch-daemon/src/core.rs Show resolved Hide resolved
Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Attention: 63 lines in your changes are missing coverage. Please review.

Comparison is base (1e0c97f) 65.7% compared to head (d8201cd) 65.5%.

Additional details and impacted files
Files Coverage Δ
cw-orch-daemon/src/error.rs 14.2% <ø> (ø)
cw-orch-daemon/src/sync/core.rs 57.4% <100.0%> (+4.9%) ⬆️
...ges/cw-orch-core/src/contract/contract_instance.rs 81.8% <100.0%> (+3.4%) ⬆️
...ages/cw-orch-core/src/contract/interface_traits.rs 75.9% <100.0%> (+1.9%) ⬆️
...ages/cw-orch-core/src/environment/queriers/wasm.rs 100.0% <ø> (ø)
packages/cw-orch-mock/src/core.rs 93.7% <100.0%> (+0.4%) ⬆️
cw-orch-daemon/src/core.rs 58.9% <90.6%> (+8.5%) ⬆️
packages/cw-orch-mock/src/queriers/wasm.rs 58.2% <0.0%> (-6.6%) ⬇️
cw-orch/src/osmosis_test_tube/core.rs 55.0% <0.0%> (-2.7%) ⬇️
...-orch-core/src/environment/cosmwasm_environment.rs 26.1% <0.0%> (-4.0%) ⬇️
... and 2 more

... and 1 file with indirect coverage changes

@Kayanski Kayanski marked this pull request as draft January 23, 2024 09:21
@Kayanski Kayanski marked this pull request as ready for review January 24, 2024 12:45
@Kayanski Kayanski merged commit 82bc650 into update/separate-query-tx Feb 1, 2024
17 of 18 checks passed
@Kayanski Kayanski deleted the update/add-instantiate-2 branch February 1, 2024 15:53
Kayanski added a commit that referenced this pull request Feb 5, 2024
* Added first queriers

* Added bank + Wasm traits

* Removed deprecated code

* Lint

* Format

* Generalized querier getter (#318)

* show POC of generalized querier getter

* update

* fix merge and impl for all envs

* Doon't verify mockj error anymore

* Fixed test

* update `QueryHandler` and WasmQuerier functions

* fix smart query URL

* fix compile

* format and clippy

---------

Co-authored-by: Kayanski <kowalski.kowalskin@gmail.com>

* Added instantiate2 (#309)

* Added instantiate2

* some fixes

* Added instantiate2 addr getter

* Format

* Nits

* Merged daemon queriers

* Corrected querier in tests

* Renamed queriers

* fix tests

* Fix tests

* Renamed trait types

* Changed types for osmosis test tube

* Feature fix

* Removed unused querier traits, adapted all daemon queriers with same structure

---------

Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
Kayanski added a commit that referenced this pull request Feb 5, 2024
* Added first queriers

* Added bank + Wasm traits

* Added cw-multi-test 0.20.0

* Removed secp, removed ibc-relayer-types

* Removed ibc-relayer-types completely

* updated prost typesé

* Start testing authz

* Added authz test

* Removed deprecated code

* Lint

* Format

* add authz querier

* tx handler error with anyhow test

* format

* Added authz builder method for options

* Some nits

* Revert with_authz, added sender options setter

* Check rest of authz queries

* Added mock state env id

* Added fee grant in daemon builder and interface

* Format

* fix find_wasm_path_with

* Generalized querier getter (#318)

* show POC of generalized querier getter

* update

* fix merge and impl for all envs

* Doon't verify mockj error anymore

* Fixed test

* update `QueryHandler` and WasmQuerier functions

* fix smart query URL

* fix compile

* format and clippy

---------

Co-authored-by: Kayanski <kowalski.kowalskin@gmail.com>

* Added instantiate2 (#309)

* Added instantiate2

* some fixes

* Added instantiate2 addr getter

* Format

* Nits

* Merged daemon queriers

* Corrected querier in tests

* Renamed queriers

* fix tests

* Fix tests

* Renamed trait types

* Changed types for osmosis test tube

* Fixed features

---------

Co-authored-by: Buckram <buckram123@gmail.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
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.

3 participants