Repository: DA0-DA0/dao-contracts
Pull request #438 (2022-08-05 16:05:54)

Small fix of close_proposal_on_execution_failure feature
We did forget something in #385... I'm so sorry @ezekiiel.


Patch:
diff --git a/contracts/cw-proposal-multiple/src/contract.rs b/contracts/cw-proposal-multiple/src/contract.rs
index f8ff562b..45e26539 100644
--- a/contracts/cw-proposal-multiple/src/contract.rs
+++ b/contracts/cw-proposal-multiple/src/contract.rs
@@ -394,7 +394,7 @@ pub fn execute_close(
     let config = CONFIG.load(deps.storage)?;
 
     prop.update_status(&env.block)?;
-    if prop.status != Status::Rejected && prop.status != Status::ExecutionFailed {
+    if prop.status != Status::Rejected {
         return Err(ContractError::WrongCloseStatus {});
     }
 
diff --git a/types/contracts/cw-admin-factory/CwAdminFactoryContract.ts b/types/contracts/cw-admin-factory/CwAdminFactoryContract.ts
index d9e7f6d2..968393a7 100644
--- a/types/contracts/cw-admin-factory/CwAdminFactoryContract.ts
+++ b/types/contracts/cw-admin-factory/CwAdminFactoryContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-core/CwCoreContract.ts b/types/contracts/cw-core/CwCoreContract.ts
index d8a559a8..95be36ba 100644
--- a/types/contracts/cw-core/CwCoreContract.ts
+++ b/types/contracts/cw-core/CwCoreContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-named-groups/CwNamedGroupsContract.ts b/types/contracts/cw-named-groups/CwNamedGroupsContract.ts
index b8fa93e9..9619f1ff 100644
--- a/types/contracts/cw-named-groups/CwNamedGroupsContract.ts
+++ b/types/contracts/cw-named-groups/CwNamedGroupsContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-names-registry/CwNamesRegistryContract.ts b/types/contracts/cw-names-registry/CwNamesRegistryContract.ts
index 78474733..3dac4b6f 100644
--- a/types/contracts/cw-names-registry/CwNamesRegistryContract.ts
+++ b/types/contracts/cw-names-registry/CwNamesRegistryContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-native-staked-balance-voting/CwNativeStakedBalanceVotingContract.ts b/types/contracts/cw-native-staked-balance-voting/CwNativeStakedBalanceVotingContract.ts
index d564c4aa..e1772ce9 100644
--- a/types/contracts/cw-native-staked-balance-voting/CwNativeStakedBalanceVotingContract.ts
+++ b/types/contracts/cw-native-staked-balance-voting/CwNativeStakedBalanceVotingContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-proposal-multiple/CwProposalMultipleContract.ts b/types/contracts/cw-proposal-multiple/CwProposalMultipleContract.ts
index 253f7567..416a0b61 100644
--- a/types/contracts/cw-proposal-multiple/CwProposalMultipleContract.ts
+++ b/types/contracts/cw-proposal-multiple/CwProposalMultipleContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-proposal-single/CwProposalSingleContract.ts b/types/contracts/cw-proposal-single/CwProposalSingleContract.ts
index 5bef50a6..a3fbc7dd 100644
--- a/types/contracts/cw-proposal-single/CwProposalSingleContract.ts
+++ b/types/contracts/cw-proposal-single/CwProposalSingleContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw-token-swap/CwTokenSwapContract.ts b/types/contracts/cw-token-swap/CwTokenSwapContract.ts
index 5de4cf52..7b191431 100644
--- a/types/contracts/cw-token-swap/CwTokenSwapContract.ts
+++ b/types/contracts/cw-token-swap/CwTokenSwapContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw20-stake-external-rewards/Cw20StakeExternalRewardsContract.ts b/types/contracts/cw20-stake-external-rewards/Cw20StakeExternalRewardsContract.ts
index fae0ea2d..d4b7386b 100644
--- a/types/contracts/cw20-stake-external-rewards/Cw20StakeExternalRewardsContract.ts
+++ b/types/contracts/cw20-stake-external-rewards/Cw20StakeExternalRewardsContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw20-stake-reward-distributor/Cw20StakeRewardDistributorContract.ts b/types/contracts/cw20-stake-reward-distributor/Cw20StakeRewardDistributorContract.ts
index e0830851..a09d5b5e 100644
--- a/types/contracts/cw20-stake-reward-distributor/Cw20StakeRewardDistributorContract.ts
+++ b/types/contracts/cw20-stake-reward-distributor/Cw20StakeRewardDistributorContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw20-stake/Cw20StakeContract.ts b/types/contracts/cw20-stake/Cw20StakeContract.ts
index db691bd4..0c00f282 100644
--- a/types/contracts/cw20-stake/Cw20StakeContract.ts
+++ b/types/contracts/cw20-stake/Cw20StakeContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw20-staked-balance-voting/Cw20StakedBalanceVotingContract.ts b/types/contracts/cw20-staked-balance-voting/Cw20StakedBalanceVotingContract.ts
index f9a2ae94..bd06ce34 100644
--- a/types/contracts/cw20-staked-balance-voting/Cw20StakedBalanceVotingContract.ts
+++ b/types/contracts/cw20-staked-balance-voting/Cw20StakedBalanceVotingContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw4-voting/Cw4VotingContract.ts b/types/contracts/cw4-voting/Cw4VotingContract.ts
index 6bb5b9f2..4d669e12 100644
--- a/types/contracts/cw4-voting/Cw4VotingContract.ts
+++ b/types/contracts/cw4-voting/Cw4VotingContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/contracts/cw721-stake/Cw721StakeContract.ts b/types/contracts/cw721-stake/Cw721StakeContract.ts
index f9c43a39..10d4ece1 100644
--- a/types/contracts/cw721-stake/Cw721StakeContract.ts
+++ b/types/contracts/cw721-stake/Cw721StakeContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/package.json b/types/package.json
index 03454fcf..b0172f9e 100644
--- a/types/package.json
+++ b/types/package.json
@@ -18,7 +18,7 @@
   },
   "devDependencies": {
     "@types/node": "^15.14.9",
-    "cosmwasm-typescript-gen": "0.3.6",
+    "@cosmwasm/ts-codegen": "0.5.8",
     "husky": "^7.0.4",
     "prettier": "^2.5.0",
     "pretty-quick": "^3.1.2",
@@ -35,4 +35,4 @@
     "@cosmjs/tendermint-rpc": "^0.28.4",
     "dotenv": "^10.0.0"
   }
-}
+}
\ No newline at end of file
diff --git a/types/packages/cw-core-interface/CwCoreInterfaceContract.ts b/types/packages/cw-core-interface/CwCoreInterfaceContract.ts
index 334acf01..1e8e31bf 100644
--- a/types/packages/cw-core-interface/CwCoreInterfaceContract.ts
+++ b/types/packages/cw-core-interface/CwCoreInterfaceContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/packages/cw-core-macros/CwCoreMacrosContract.ts b/types/packages/cw-core-macros/CwCoreMacrosContract.ts
index b86e8487..4478f147 100644
--- a/types/packages/cw-core-macros/CwCoreMacrosContract.ts
+++ b/types/packages/cw-core-macros/CwCoreMacrosContract.ts
@@ -1,7 +1,7 @@
 /**
-* This file was automatically generated by cosmwasm-typescript-gen@0.3.6.
+* This file was automatically generated by @cosmwasm/ts-codegen@0.5.8.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
-* and run the cosmwasm-typescript-gen generate command to regenerate this file.
+* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
 */
 
 import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
diff --git a/types/src/codegen.ts b/types/src/codegen.ts
index cf43dec2..9105f1fa 100644
--- a/types/src/codegen.ts
+++ b/types/src/codegen.ts
@@ -1,7 +1,7 @@
-import { exec } from "child_process";
 import dotenv from "dotenv";
 import fs from "fs";
 import path from "path";
+import { readSchemas, generate } from "@cosmwasm/ts-codegen";
 
 enum OutputType {
   contracts = "contracts",
@@ -64,29 +64,12 @@ const DEFAULT_CONFIG = {
   ]
 };
 
-async function run(cmd: string): Promise<boolean> {
-  log(cmd, LogLevels.Verbose);
-  return new Promise((resolve, reject) => {
-    exec(cmd, (error, stdout, stderr) => {
-      if (error) {
-        console.error(`error: ${error.message}`);
-        reject(error);
-      }
-      if (stderr) {
-        console.error(`stderr: ${stderr}`);
-        reject(stderr);
-      }
-      resolve(true);
-    });
-  });
-}
+async function generateTs(spec: CompilationSpec): Promise<void> {
+  const out = `${spec.outputPath}/${spec.outputType}/${spec.contractName}`;
+  const name = spec.contractName;
 
-async function generateTs(spec: CompilationSpec): Promise<boolean> {
-  const script = "node_modules/cosmwasm-typescript-gen/main/cosmwasm-typescript-gen.js";
-  return run(`${script} generate \
-    --schema ${spec.schemaDir} \
-    --out ${spec.outputPath}/${spec.outputType}/${spec.contractName} \
-    --name ${spec.contractName}`)
+  const schemas = readSchemas({ schemaDir: spec.schemaDir, argv: { packed: false } });
+  return await generate(name, schemas, out);
 }
 
 
diff --git a/types/yarn.lock b/types/yarn.lock
index dbd120db..f58bd762 100644
--- a/types/yarn.lock
+++ b/types/yarn.lock
@@ -1158,6 +1158,35 @@
   resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.28.10.tgz#8cb8cb3381210bb498aa766ac26c9ec369a7bfbb"
   integrity sha512-S0t2kFRiAo1MvIrbXlfrGdsn2D3PApyO1d+GCze14Cg4QOOGWDcTsd6VhHcxKhETO1Z9ofEhE4soJ8ZldBlnpg==
 
+"@cosmwasm/ts-codegen@0.5.8":
+  version "0.5.8"
+  resolved "https://registry.yarnpkg.com/@cosmwasm/ts-codegen/-/ts-codegen-0.5.8.tgz#8c7efc91bdbb85637342329daa86342082f3b895"
+  integrity sha512-zd1u8YAghunLhkZAmQvoQIbvrnCW62zs0IZoP3VN23IQWVedycjQJxhoSNKGKdfyir693hSsSMAt3NC/1PrAQQ==
+  dependencies:
+    "@babel/core" "7.18.5"
+    "@babel/generator" "7.18.2"
+    "@babel/parser" "7.18.5"
+    "@babel/plugin-proposal-class-properties" "7.17.12"
+    "@babel/plugin-proposal-export-default-from" "7.17.12"
+    "@babel/plugin-proposal-object-rest-spread" "7.18.0"
+    "@babel/plugin-transform-runtime" "7.18.5"
+    "@babel/preset-env" "7.18.2"
+    "@babel/preset-typescript" "^7.17.12"
+    "@babel/runtime" "^7.18.3"
+    "@babel/traverse" "7.18.5"
+    "@babel/types" "7.18.4"
+    case "1.6.3"
+    dargs "7.0.0"
+    fuzzy "0.1.3"
+    glob "8.0.3"
+    inquirerer "0.1.3"
+    json-schema-to-typescript "10.1.5"
+    long "^5.2.0"
+    minimist "1.2.6"
+    mkdirp "1.0.4"
+    shelljs "0.8.5"
+    wasm-ast-types "^0.4.3"
+
 "@cspotcode/source-map-support@^0.8.0":
   version "0.8.1"
   resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
@@ -1804,35 +1833,6 @@ cosmjs-types@^0.4.0:
     long "^4.0.0"
     protobufjs "~6.11.2"
 
-cosmwasm-typescript-gen@0.3.6:
-  version "0.3.6"
-  resolved "https://registry.yarnpkg.com/cosmwasm-typescript-gen/-/cosmwasm-typescript-gen-0.3.6.tgz#c863ce01335f53dd02c8ebc2c545be50828dfc3f"
-  integrity sha512-A+VfD9a59Y4LKhuuH2zN2Qdz5Re4P4qkf3DPMsCUaLiCzcdKSxj2QQCpRXsA4lXkJXbuXPop4WTpYGVX01xpjg==
-  dependencies:
-    "@babel/core" "7.18.5"
-    "@babel/generator" "7.18.2"
-    "@babel/parser" "7.18.5"
-    "@babel/plugin-proposal-class-properties" "7.17.12"
-    "@babel/plugin-proposal-export-default-from" "7.17.12"
-    "@babel/plugin-proposal-object-rest-spread" "7.18.0"
-    "@babel/plugin-transform-runtime" "7.18.5"
-    "@babel/preset-env" "7.18.2"
-    "@babel/preset-typescript" "^7.17.12"
-    "@babel/runtime" "^7.18.3"
-    "@babel/traverse" "7.18.5"
-    "@babel/types" "7.18.4"
-    case "1.6.3"
-    dargs "7.0.0"
-    fuzzy "0.1.3"
-    glob "8.0.3"
-    inquirerer "0.1.3"
-    json-schema-to-typescript "10.1.5"
-    long "^5.2.0"
-    minimist "1.2.6"
-    mkdirp "1.0.4"
-    shelljs "0.8.5"
-    wasm-ast-types "^0.3.5"
-
 create-require@^1.1.0:
   version "1.1.1"
   resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
@@ -3466,10 +3466,15 @@ util@^0.10.3:
   dependencies:
     inherits "2.0.3"
 
-wasm-ast-types@^0.3.5:
-  version "0.3.5"
-  resolved "https://registry.yarnpkg.com/wasm-ast-types/-/wasm-ast-types-0.3.5.tgz#b46d7b5f4f9312f45278f731f9eb496fdf2f4ca3"
-  integrity sha512-rzpP86SqVV3Rs24hG0ZSsFFrxp34J4U65z/3KWLZOxhe6ljuh3FFECbC6p0iyIkmG6hN5F6mQ+4Y2+QNP5GnAg==
+v8-compile-cache-lib@^3.0.1:
+  version "3.0.1"
+  resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"
+  integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==
+
+wasm-ast-types@^0.4.3:
+  version "0.4.3"
+  resolved "https://registry.yarnpkg.com/wasm-ast-types/-/wasm-ast-types-0.4.3.tgz#bfc6de5ba1c8cb5aed8d41503904372490fbccb0"
+  integrity sha512-AbQe1uwzwyev3VR93coP3hAAIGqZ0ccNeyBHYtUFckHtfrsLwDF5wf3AMmnZ/PmQpxvC8PE/1aiYG8twcg9aGQ==
   dependencies:
     "@babel/runtime" "^7.18.3"
     "@babel/types" "7.18.4"


Test patch:
diff --git a/contracts/cw-proposal-multiple/src/tests.rs b/contracts/cw-proposal-multiple/src/tests.rs
index 4f1fc66f..27619c85 100644
--- a/contracts/cw-proposal-multiple/src/tests.rs
+++ b/contracts/cw-proposal-multiple/src/tests.rs
@@ -3911,25 +3911,6 @@ fn test_close_failed_proposal() {
 
     assert_eq!(failed.proposal.status, Status::ExecutionFailed);
 
-    // Check we can close it after it failed
-    app.execute_contract(
-        Addr::unchecked(CREATOR_ADDR),
-        govmod_single.clone(),
-        &ExecuteMsg::Close { proposal_id: 1 },
-        &[],
-    )
-    .unwrap();
-
-    let closed_after_fail: ProposalResponse = app
-        .wrap()
-        .query_wasm_smart(
-            govmod_single.clone(),
-            &QueryMsg::Proposal { proposal_id: 1 },
-        )
-        .unwrap();
-
-    assert_eq!(closed_after_fail.proposal.status, Status::Closed);
-
     // With disabled feature
     // Disable feature first
     {
@@ -4040,3 +4021,226 @@ fn test_close_failed_proposal() {
     // not reverted
     assert_eq!(updated.proposal.status, Status::Passed);
 }
+
+#[test]
+fn test_no_double_refund_on_execute_fail_and_close() {
+    let mut app = App::default();
+    let proposal_module_id = app.store_code(proposal_contract());
+
+    let voting_strategy = VotingStrategy::SingleChoice {
+        quorum: PercentageThreshold::Majority {},
+    };
+    let max_voting_period = cw_utils::Duration::Height(6);
+    let instantiate = InstantiateMsg {
+        voting_strategy,
+        max_voting_period,
+        min_voting_period: None,
+        only_members_execute: false,
+        deposit_info: Some(DepositInfo {
+            token: DepositToken::VotingModuleToken {},
+            deposit: Uint128::new(1),
+            // Important to set to true here as we want to be sure
+            // that we don't get a second refund on close. Refunds on
+            // close only happen if this is true.
+            refund_failed_proposals: true,
+        }),
+        close_proposal_on_execution_failure: true,
+    };
+
+    let core_addr = instantiate_with_staking_active_threshold(
+        &mut app,
+        proposal_module_id,
+        to_binary(&instantiate).unwrap(),
+        Some(vec![Cw20Coin {
+            address: CREATOR_ADDR.to_string(),
+            // One token for sending to the DAO treasury, one token
+            // for staking, one token for paying the proposal deposit.
+            amount: Uint128::new(3),
+        }]),
+        None,
+    );
+    let proposal_modules: Vec<Addr> = app
+        .wrap()
+        .query_wasm_smart(
+            core_addr,
+            &cw_core::msg::QueryMsg::ProposalModules {
+                start_after: None,
+                limit: None,
+            },
+        )
+        .unwrap();
+
+    assert_eq!(proposal_modules.len(), 1);
+    let proposal_single = proposal_modules.into_iter().next().unwrap();
+
+    let proposal_config: Config = app
+        .wrap()
+        .query_wasm_smart(proposal_single.clone(), &QueryMsg::Config {})
+        .unwrap();
+    let dao = proposal_config.dao;
+    let voting_module: Addr = app
+        .wrap()
+        .query_wasm_smart(dao, &cw_core::msg::QueryMsg::VotingModule {})
+        .unwrap();
+    let staking_contract: Addr = app
+        .wrap()
+        .query_wasm_smart(
+            voting_module.clone(),
+            &cw20_staked_balance_voting::msg::QueryMsg::StakingContract {},
+        )
+        .unwrap();
+    let token_contract: Addr = app
+        .wrap()
+        .query_wasm_smart(
+            voting_module,
+            &cw_core_interface::voting::Query::TokenContract {},
+        )
+        .unwrap();
+
+    // Stake a token so we can propose.
+    let msg = cw20::Cw20ExecuteMsg::Send {
+        contract: staking_contract.to_string(),
+        amount: Uint128::new(1),
+        msg: to_binary(&cw20_stake::msg::ReceiveMsg::Stake {}).unwrap(),
+    };
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        token_contract.clone(),
+        &msg,
+        &[],
+    )
+    .unwrap();
+    app.update_block(next_block);
+
+    // Send some tokens to the proposal module so it has the ability
+    // to double refund if the code is buggy.
+    let msg = cw20::Cw20ExecuteMsg::Transfer {
+        recipient: proposal_single.to_string(),
+        amount: Uint128::new(1),
+    };
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        token_contract.clone(),
+        &msg,
+        &[],
+    )
+    .unwrap();
+
+    let msg = cw20::Cw20ExecuteMsg::Burn {
+        amount: Uint128::new(2000),
+    };
+    let binary_msg = to_binary(&msg).unwrap();
+
+    // Increase allowance to pay the proposal deposit.
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        token_contract.clone(),
+        &cw20_base::msg::ExecuteMsg::IncreaseAllowance {
+            spender: proposal_single.to_string(),
+            amount: Uint128::new(1),
+            expires: None,
+        },
+        &[],
+    )
+    .unwrap();
+
+    let choices = MultipleChoiceOptions {
+        options: vec![
+            MultipleChoiceOption {
+                description: "Burning more tokens, than dao treasury have".to_string(),
+                msgs: Some(vec![WasmMsg::Execute {
+                    contract_addr: token_contract.to_string(),
+                    msg: binary_msg,
+                    funds: vec![],
+                }
+                .into()]),
+            },
+            MultipleChoiceOption {
+                description: "hi there".to_string(),
+                msgs: None,
+            },
+        ],
+    };
+    // proposal to overburn tokens
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        proposal_single.clone(),
+        &ExecuteMsg::Propose {
+            title: "A simple burn tokens proposal".to_string(),
+            description: "Burning more tokens, than dao treasury have".to_string(),
+            choices,
+        },
+        &[],
+    )
+    .unwrap();
+
+    // Vote on proposal
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        proposal_single.clone(),
+        &ExecuteMsg::Vote {
+            proposal_id: 1,
+            vote: MultipleChoiceVote { option_id: 0 },
+        },
+        &[],
+    )
+    .unwrap();
+
+    // Execute proposal
+    app.execute_contract(
+        Addr::unchecked(CREATOR_ADDR),
+        proposal_single.clone(),
+        &ExecuteMsg::Execute { proposal_id: 1 },
+        &[],
+    )
+    .unwrap();
+
+    let failed: ProposalResponse = app
+        .wrap()
+        .query_wasm_smart(
+            proposal_single.clone(),
+            &QueryMsg::Proposal { proposal_id: 1 },
+        )
+        .unwrap();
+    assert_eq!(failed.proposal.status, Status::ExecutionFailed);
+
+    // Check that our deposit has been refunded.
+    let balance: cw20::BalanceResponse = app
+        .wrap()
+        .query_wasm_smart(
+            token_contract.to_string(),
+            &cw20::Cw20QueryMsg::Balance {
+                address: CREATOR_ADDR.to_string(),
+            },
+        )
+        .unwrap();
+
+    assert_eq!(balance.balance, Uint128::new(1));
+
+    // Close the proposal - this should fail as it was executed.
+    let err: ContractError = app
+        .execute_contract(
+            Addr::unchecked(CREATOR_ADDR),
+            proposal_single,
+            &ExecuteMsg::Close { proposal_id: 1 },
+            &[],
+        )
+        .unwrap_err()
+        .downcast()
+        .unwrap();
+
+    assert!(matches!(err, ContractError::WrongCloseStatus {}));
+
+    // Check that our deposit was not refunded a second time on close.
+    let balance: cw20::BalanceResponse = app
+        .wrap()
+        .query_wasm_smart(
+            token_contract.to_string(),
+            &cw20::Cw20QueryMsg::Balance {
+                address: CREATOR_ADDR.to_string(),
+            },
+        )
+        .unwrap();
+
+    assert_eq!(balance.balance, Uint128::new(1));
+}