Skip to content

Commit

Permalink
Latest code_ids, fixes transfer admin state blocker (minor)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Mar 17, 2023
1 parent 93bd3d8 commit b9168d8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ External
Easy Migration UI: https://juno.reece.sh

Mainnet Code IDs:
- Middleware: 2310
- Migrate: 2309
- Middleware code_id: 2323
- Migrate code_id: 2324
36 changes: 17 additions & 19 deletions contracts/tokenfactory_core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,23 @@ pub fn execute_transfer_admin(
let state = STATE.load(deps.storage)?;
is_contract_manager(state.clone(), info.sender)?;

let denom = state.denoms.iter().find(|d| d.to_string() == denom).ok_or(
ContractError::InvalidDenom {
denom,
message: "Denom not found in state".to_string(),
},
)?;

// remove denom from state
let updated_state: Vec<String> = state
.denoms
.iter()
.filter(|d| d.to_string() != *denom)
.map(|d| d.to_string())
.collect();

STATE.update(deps.storage, |mut state| -> StdResult<_> {
state.denoms = updated_state;
Ok(state)
})?;
// it is possible to transfer admin in without adding to contract state. So devs need a way to reclaim admin without adding it to denoms state
let state_denom: Option<&String> = state.denoms.iter().find(|d| d.to_string() == denom);

if state_denom.is_some() {
// remove it from state
let updated_state: Vec<String> = state
.denoms
.iter()
.filter(|d| d.to_string() != *state_denom.unwrap())
.map(|d| d.to_string())
.collect();

STATE.update(deps.storage, |mut state| -> StdResult<_> {
state.denoms = updated_state;
Ok(state)
})?;
}

let msg = TokenMsg::ChangeAdmin {
denom: denom.to_string(),
Expand Down
20 changes: 20 additions & 0 deletions scripts/mainnet_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Uploads the contracts to Mainnet & returns their code_ids
#
# Usage: sh scripts/mainnet_upload.sh
#

KEY="reece"
CHAINID="juno-1"
JUNOD_HOME="$HOME/.juno"
KEYALGO="secp256k1"
KEYRING="os"

export JUNOD_NODE="https://rpc.juno.strange.love:443"
export JUNOD_COMMAND_ARGS="--gas=auto -y --from $KEY --broadcast-mode block --output json --chain-id=$CHAINID --gas-prices=0.005ujuno --gas-adjustment=1.4 --home "$JUNOD_HOME" --keyring-backend $KEYRING"

middleware_tx=$(junod tx wasm store artifacts/tokenfactory_core.wasm $JUNOD_COMMAND_ARGS | jq -r .txhash)
middleware_code_id=$(junod q tx $middleware_tx --output=json | jq -r '.logs[0].events[] | select(.type=="store_code")' | jq -r .attributes[1].value) && echo "Middleware code_id: $middleware_code_id"

migrate_tx=$(junod tx wasm store artifacts/migrate.wasm $JUNOD_COMMAND_ARGS | jq -r .txhash) # && echo "Migrate tx: $migrate_tx"
migrate_code_id=$(junod q tx $migrate_tx --output=json | jq -r '.logs[].events[] | select(.type=="store_code")' | jq -r .attributes[1].value) && echo "Migrate code_id: $migrate_code_id"

0 comments on commit b9168d8

Please sign in to comment.