Skip to content

Commit 58a10fa

Browse files
chore(zkgm): staking extension fixes
1 parent 50e06a0 commit 58a10fa

File tree

11 files changed

+192
-79
lines changed

11 files changed

+192
-79
lines changed

cosmwasm/cosmwasm.nix

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,16 @@ _: {
110110
apps = {
111111
ucs03 = ucs03-configs.cw20 // {
112112
rate_limit_disabled = true;
113+
# 2 minutes
114+
unbonding_period = 2 * 60;
113115
};
114116
};
115117
# lightclients = pkgs.lib.lists.remove "cometbls" (builtins.attrNames all-lightclients);
116118
lightclients = [
117119
# "ethereum"
118-
# "trusted-mpt"
120+
"trusted-mpt"
119121
# "bob"
120-
"ethermint"
122+
# "ethermint"
121123
];
122124
}
123125
{
@@ -158,7 +160,10 @@ _: {
158160
gas_multiplier = 1.4;
159161
};
160162
apps = {
161-
ucs03 = ucs03-configs.cw20;
163+
ucs03 = ucs03-configs.cw20 // {
164+
# 27 days unbonding period
165+
unbonding_period = 27 * 24 * 60 * 60;
166+
};
162167
};
163168
bech32_prefix = "union";
164169
lightclients = [
@@ -448,21 +453,25 @@ _: {
448453
ucs03-configs = {
449454
cw20 = {
450455
path = "${ucs03-zkgm.release}";
456+
cw_account_path = "${cw-account.release}";
451457
token_minter_path = "${cw20-token-minter.release}";
452458
token_minter_config = {
453459
cw20 = {
454460
cw20_base = "${cw20-base.release}";
455461
};
456462
};
457463
rate_limit_disabled = false;
464+
unbonding_period = 0;
458465
};
459466
osmosis_tokenfactory = {
460467
rate_limit_disabled = false;
461468
path = "${ucs03-zkgm.release}";
469+
cw_account_path = "${cw-account.release}";
462470
token_minter_path = "${osmosis-tokenfactory-token-minter.release}";
463471
token_minter_config = {
464472
osmosis_tokenfactory = { };
465473
};
474+
unbonding_period = 0;
466475
};
467476
};
468477

@@ -708,6 +717,17 @@ _: {
708717
709718
echo "token minter code id: $(cat token-minter-code-id.txt)"
710719
720+
PRIVATE_KEY=${private_key} \
721+
RUST_LOG=info \
722+
cosmwasm-deployer \
723+
store-code \
724+
--rpc-url ${rpc_url} \
725+
--bytecode ${apps.ucs03.cw_account_path} \
726+
--output cw-account-code-id.txt \
727+
${mk-gas-args gas_config}
728+
729+
echo "cw-account code id: $(cat cw-account-code-id.txt)"
730+
711731
DEPLOYER=$(
712732
PRIVATE_KEY=${private_key} \
713733
cosmwasm-deployer \
@@ -727,7 +747,7 @@ _: {
727747
--address "$(echo "$ADDRESSES" | jq '.app."${app}"' -r)" \
728748
--message "{\"token_minter_migration\":{\"new_code_id\":$(cat token-minter-code-id.txt),\"msg\":\"$(echo '{}' | base64)\"}, \"rate_limit_disabled\":${
729749
if apps.ucs03.rate_limit_disabled then "true" else "false"
730-
}}" \
750+
}, \"cw_account_code_id\": $(cat cw-account-code-id.txt)}" \
731751
--force \
732752
--new-bytecode ${(mk-app full-app.name).release} \
733753
${mk-gas-args gas_config}
@@ -813,6 +833,8 @@ _: {
813833

814834
ucs03-zkgm = crane.buildWasmContract "cosmwasm/ibc-union/app/ucs03-zkgm" { };
815835

836+
cw-account = crane.buildWasmContract "cosmwasm/cw-account" { };
837+
816838
cw20-base = crane.buildWasmContract "cosmwasm/cw20-base" { };
817839

818840
ibc-union = crane.buildWasmContract "cosmwasm/ibc-union/core" { };
@@ -1012,6 +1034,7 @@ _: {
10121034
osmosis-tokenfactory-token-minter
10131035
ibc-union
10141036
multicall
1037+
cw-account
10151038
;
10161039
cosmwasm-scripts =
10171040
{

cosmwasm/cw-account/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"]
1313

1414
[dependencies]
1515
cosmwasm-schema = { workspace = true }
16-
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_3"] }
16+
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_3", "staking"] }
1717
cw-storage-plus = { workspace = true }
1818
embed-commit = { workspace = true }
1919
frissitheto = { workspace = true }

cosmwasm/deployer/src/main.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ struct AppPaths {
338338
pub struct Ucs03Config {
339339
path: PathBuf,
340340
token_minter_path: PathBuf,
341+
cw_account_path: PathBuf,
341342
token_minter_config: TokenMinterConfig,
342343
rate_limit_disabled: bool,
344+
unbonding_period: u64,
343345
}
344346

345347
#[derive(Debug, Serialize, Deserialize)]
@@ -684,6 +686,47 @@ async fn do_main() -> Result<()> {
684686
}
685687
};
686688

689+
let (tx_hash, response) = ctx
690+
.tx(
691+
MsgStoreCode {
692+
sender: ctx.wallet().address().map_data(Into::into),
693+
wasm_byte_code: std::fs::read(ucs03_config.cw_account_path)?.into(),
694+
instantiate_permission: None,
695+
},
696+
"",
697+
gas_config.simulate,
698+
)
699+
.await
700+
.context("store minter code")?;
701+
702+
let cw_account_code_id = response.code_id;
703+
704+
info!(%tx_hash, cw_account_code_id, "cw_account stored");
705+
706+
// on permissioned cosmwasm, we must specify that this code can be instantiated by the ucs03 contract
707+
if permissioned {
708+
let (tx_hash, _) = ctx
709+
.tx(
710+
MsgUpdateInstantiateConfig {
711+
sender: ctx.wallet().address().map_data(Into::into),
712+
code_id: cw_account_code_id,
713+
new_instantiate_permission: Some(
714+
AccessConfig::AnyOfAddresses {
715+
addresses: vec![ucs03_address
716+
.clone()
717+
.map_data(Into::into)],
718+
},
719+
),
720+
},
721+
"",
722+
gas_config.simulate,
723+
)
724+
.await
725+
.context("update instantiate perms of cw-account")?;
726+
727+
info!(%tx_hash, "cw-account instantiate permissions updated");
728+
}
729+
687730
ctx.deploy_and_initiate(
688731
std::fs::read(ucs03_config.path)?,
689732
bytecode_base_code_id,
@@ -699,6 +742,9 @@ async fn do_main() -> Result<()> {
699742
ctx.wallet().address().to_string(),
700743
)],
701744
rate_limit_disabled: ucs03_config.rate_limit_disabled,
745+
dummy_code_id: bytecode_base_code_id.get(),
746+
cw_account_code_id: cw_account_code_id.get(),
747+
unbonding_period: ucs03_config.unbonding_period,
702748
},
703749
minter_init_params,
704750
},

0 commit comments

Comments
 (0)