diff --git a/README.md b/README.md index 4f9c869..4c824f4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/contracts/tokenfactory_core/src/contract.rs b/contracts/tokenfactory_core/src/contract.rs index 99d883d..d19cee9 100644 --- a/contracts/tokenfactory_core/src/contract.rs +++ b/contracts/tokenfactory_core/src/contract.rs @@ -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 = 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 = 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(), diff --git a/scripts/mainnet_upload.sh b/scripts/mainnet_upload.sh new file mode 100644 index 0000000..8ee72aa --- /dev/null +++ b/scripts/mainnet_upload.sh @@ -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" \ No newline at end of file