Skip to content

Commit

Permalink
Merge pull request cosmos#726 from CosmWasm/702-autopin-gov-contracts
Browse files Browse the repository at this point in the history
Autopin gov contracts
  • Loading branch information
ethanfrey authored Jan 21, 2022
2 parents 4bf0092 + e9d96cf commit b4258b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- Use replace statements to enforce consistent versioning. [\#692](https://github.com/CosmWasm/wasmd/pull/692) ([faddat](https://github.com/faddat))
- Fixed circleci by removing the golang executor from a docker build
- Go 1.17 provides a much clearer go.mod file [\#679](https://github.com/CosmWasm/wasmd/pull/679) ([faddat](https://github.com/faddat))

- Autopin wasm code uploaded by gov proposal [\#726](https://github.com/CosmWasm/wasmd/pull/726) ([ethanfrey](https://github.com/ethanfrey))


[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.22.0...v0.21.0)
Expand Down
7 changes: 5 additions & 2 deletions x/wasm/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ func handleStoreCodeProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types
if err != nil {
return sdkerrors.Wrap(err, "run as address")
}
_, err = k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission)
return err
codeID, err := k.Create(ctx, runAsAddr, p.WASMByteCode, p.InstantiatePermission)
if err != nil {
return err
}
return k.PinCode(ctx, codeID)
}

func handleInstantiateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.InstantiateContractProposal) error {
Expand Down
1 change: 1 addition & 0 deletions x/wasm/keeper/proposal_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestStoreCodeProposal(t *testing.T) {
cInfo := wasmKeeper.GetCodeInfo(ctx, 1)
require.NotNil(t, cInfo)
assert.Equal(t, myActorAddress, cInfo.Creator)
assert.True(t, wasmKeeper.IsPinnedCode(ctx, 1))

storedCode, err := wasmKeeper.GetByteCode(ctx, 1)
require.NoError(t, err)
Expand Down

0 comments on commit b4258b9

Please sign in to comment.