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

Enabled using addr_make inside AppBuilder::build #189

Merged
merged 16 commits into from
Jun 20, 2024

Conversation

DariuszDepta
Copy link
Member

@DariuszDepta DariuszDepta commented Jun 19, 2024

closes #188
reported in: CosmWasm/cw-template#158

Enabled using addr_make inside AppBuilder::build, the closure passed to build function gets the same Api implementation as App, like shown below. api argument here has type cosmwasm_std::testing::mock::MockApi, exactly like the App, so using addr_make inside build is now possible.

const USER: &str = "user";
const DENOM: &str = "denom";
const AMOUNT: u128 = 100;

let app = AppBuilder::new().build(|router, api, storage| {
    router
        .bank
        .init_balance(
            storage,
            &api.addr_make(USER),
            vec![Coin {
                denom: DENOM.to_string(),
                amount: Uint128::new(AMOUNT),
             }],
         )
        .unwrap();
});

@DariuszDepta DariuszDepta self-assigned this Jun 19, 2024
@DariuszDepta DariuszDepta added this to the 2.1.0 milestone Jun 19, 2024
Copy link
Contributor

@chipshort chipshort left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. Just two minor comments.

src/app.rs Outdated Show resolved Hide resolved
src/app_builder.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@chipshort chipshort left a comment

Choose a reason for hiding this comment

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

LGTM

@DariuszDepta DariuszDepta merged commit b57f7ee into main Jun 20, 2024
7 checks passed
@DariuszDepta DariuszDepta deleted the addr-make-in-app-builder branch June 20, 2024 08:43
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.

Using addr_make inside AppBuilder::build
2 participants