From 4b38f7d7227f66246f766c26ea37839c86f866d2 Mon Sep 17 00:00:00 2001 From: Wesley Coakley Date: Thu, 1 Aug 2024 05:15:18 -0400 Subject: [PATCH] never set a contract admin (except for sei) --- scripts/configs/archway.toml | 3 --- scripts/configs/chihuahua.toml | 3 --- scripts/configs/injective.toml | 3 --- scripts/configs/migaloo.toml | 3 --- scripts/configs/neutron.toml | 3 --- scripts/configs/oraichain.toml | 3 --- scripts/configs/osmosis.toml | 3 --- scripts/configs/persistence.toml | 3 --- scripts/configs/sei.toml | 3 --- scripts/configs/terra.toml | 3 --- scripts/deploy.py | 34 +++++++++++++------------------- scripts/deploy_injective.py | 5 ----- 12 files changed, 14 insertions(+), 55 deletions(-) diff --git a/scripts/configs/archway.toml b/scripts/configs/archway.toml index 84c92875..355f8e67 100644 --- a/scripts/configs/archway.toml +++ b/scripts/configs/archway.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://archway-api.polkachu.com" MAINNET_RPC_URL = "https://archway-rpc.polkachu.com" MAINNET_CHAIN_ID = "archway-1" diff --git a/scripts/configs/chihuahua.toml b/scripts/configs/chihuahua.toml index 50bbfed8..417e4ccf 100644 --- a/scripts/configs/chihuahua.toml +++ b/scripts/configs/chihuahua.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://chihuahua-api.polkachu.com" MAINNET_RPC_URL = "https://chihuahua-rpc.polkachu.com" MAINNET_CHAIN_ID = "chihuahua-1" diff --git a/scripts/configs/injective.toml b/scripts/configs/injective.toml index fba8ee38..7cc811ca 100644 --- a/scripts/configs/injective.toml +++ b/scripts/configs/injective.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://sentry.lcd.injective.network:443" MAINNET_RPC_URL = " https://sentry.tm.injective.network:443/" MAINNET_CHAIN_ID = "injective-1" diff --git a/scripts/configs/migaloo.toml b/scripts/configs/migaloo.toml index d6b68f81..f78978b9 100644 --- a/scripts/configs/migaloo.toml +++ b/scripts/configs/migaloo.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://migaloo-api.polkachu.com" MAINNET_RPC_URL = "https://migaloo-rpc.polkachu.com" MAINNET_CHAIN_ID = "migaloo-1" diff --git a/scripts/configs/neutron.toml b/scripts/configs/neutron.toml index b61fb9b4..1c58cc5b 100644 --- a/scripts/configs/neutron.toml +++ b/scripts/configs/neutron.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://rest-kralum.neutron-1.neutron.org" MAINNET_RPC_URL = "https://rpc-kralum.neutron-1.neutron.org" MAINNET_CHAIN_ID = "neutron-1" diff --git a/scripts/configs/oraichain.toml b/scripts/configs/oraichain.toml index af9bfb61..0e9068e0 100644 --- a/scripts/configs/oraichain.toml +++ b/scripts/configs/oraichain.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://orai-api.polkachu.com" MAINNET_RPC_URL = "https://orai-rpc.polkachu.com" MAINNET_CHAIN_ID = "Oraichain" diff --git a/scripts/configs/osmosis.toml b/scripts/configs/osmosis.toml index def00313..fe8da284 100644 --- a/scripts/configs/osmosis.toml +++ b/scripts/configs/osmosis.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://osmosis-api.polkachu.com" MAINNET_RPC_URL = "https://osmosis-rpc.polkachu.com/" MAINNET_CHAIN_ID = "osmosis-1" diff --git a/scripts/configs/persistence.toml b/scripts/configs/persistence.toml index 7fcb6ee2..1f09f6a6 100644 --- a/scripts/configs/persistence.toml +++ b/scripts/configs/persistence.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://persistence-api.polkachu.com" MAINNET_RPC_URL = "https://persistence-rpc.polkachu.com" MAINNET_CHAIN_ID = "core-1" diff --git a/scripts/configs/sei.toml b/scripts/configs/sei.toml index dd397d0f..e3d564b5 100644 --- a/scripts/configs/sei.toml +++ b/scripts/configs/sei.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://sei-api.polkachu.com" MAINNET_RPC_URL = "https://sei-rpc.polkachu.com" MAINNET_CHAIN_ID = "pacific-1" diff --git a/scripts/configs/terra.toml b/scripts/configs/terra.toml index 75c815ae..57e7d7cb 100644 --- a/scripts/configs/terra.toml +++ b/scripts/configs/terra.toml @@ -4,9 +4,6 @@ MNEMONIC = "" # Commit Hash of the commit used to build the contracts COMMIT_HASH = "" -# Admin address to execute migrations from -ADMIN_ADDRESS = "" - MAINNET_REST_URL = "https://lcd-terra.tfl.foundation" MAINNET_RPC_URL = "https://terra-rpc.polkachu.com/" MAINNET_CHAIN_ID = "phoenix-1" diff --git a/scripts/deploy.py b/scripts/deploy.py index 2a88c00b..7c77b302 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -18,7 +18,7 @@ MsgInstantiateContract, MsgInstantiateContract2, MsgMigrateContract, - MsgUpdateAdmin, + MsgClearAdmin, ) from cosmpy.common.utils import json_encode from cosmpy.protos.cosmos.authz.v1beta1.tx_pb2 import MsgExec @@ -92,9 +92,6 @@ # Pregenerated Contract Addresses ENTRY_POINT_PRE_GENERATED_ADDRESS = config["ENTRY_POINT_PRE_GENERATED_ADDRESS"] -# Admin address for future migrations -ADMIN_ADDRESS = config["ADMIN_ADDRESS"] - MNEMONIC = config["MNEMONIC"] del config["MNEMONIC"] @@ -145,7 +142,7 @@ def main(): ibc_transfer_adapter_contract_address = instantiate_contract( client, wallet, - ADMIN_ADDRESS, + None, ibc_transfer_adapter_contract_code_id, {"entry_point_contract_address": ENTRY_POINT_PRE_GENERATED_ADDRESS}, "Skip Swap IBC Transfer Adapter", @@ -205,7 +202,7 @@ def main(): swap_adapter_contract_address = instantiate_contract( client, wallet, - ADMIN_ADDRESS, + None, swap_adapter_contract_code_id, swap_adapter_instantiate_args, f"Skip Swap Swap Adapter {venue['name']}", @@ -270,7 +267,7 @@ def main(): entry_point_contract_address = instantiate_contract( client, wallet, - ADMIN_ADDRESS, + None, entry_point_contract_code_id, entry_point_instantiate_args, "Skip Swap Entry Point", @@ -297,15 +294,15 @@ def main(): "ibc_transfer_adapter" ) - # Update Admin for IBC transfer adapter contract back to real admin - update_admin( + # Clear Admin for IBC transfer adapter contract + clear_admin( client, wallet, ibc_transfer_adapter_contract_address, "ibc_transfer_adapter" ) - # Store, migrate, and update admin for swap adapter contracts + # Store, migrate, and clear admin for swap adapter contracts for i, venue in enumerate(SWAP_VENUES): swap_adapter_contract_code_id = store_contract( client, @@ -326,7 +323,7 @@ def main(): args, f"swap_adapter_{venue['name']}" ) - update_admin( + clear_admin( client, wallet, swap_adapter_contract_address, @@ -517,27 +514,26 @@ def migrate_contract(client, wallet, contract_address, code_id, args, name) -> s toml.dump(DEPLOYED_CONTRACTS_INFO, f) return contract_address -def update_admin(client, wallet, contract_address, name): +def clear_admin(client, wallet, contract_address, name): if CHAIN == "osmosis": gas_limit = 600000 else: gas_limit = 300000 - msg = MsgUpdateAdmin( + msg = MsgClearAdmin( sender=str(wallet.address()), - new_admin=ADMIN_ADDRESS, contract=contract_address, ) - update_admin_tx = create_tx( + clear_admin_tx = create_tx( msg=msg, client=client, wallet=wallet, gas_limit=gas_limit, fee=f"{int(GAS_PRICE*gas_limit)}{DENOM}" ) - tx_hash = sha256(update_admin_tx.tx.SerializeToString()).hexdigest() + tx_hash = sha256(clear_admin_tx.tx.SerializeToString()).hexdigest() print("Tx hash: ", tx_hash) - broadcast_tx(update_admin_tx) - DEPLOYED_CONTRACTS_INFO["tx-hashes"][f"update_admin_{name}_tx_hash"] = tx_hash + broadcast_tx(clear_admin_tx) + DEPLOYED_CONTRACTS_INFO["tx-hashes"][f"clear_admin_{name}_tx_hash"] = tx_hash with open(f"{DEPLOYED_CONTRACTS_FOLDER_PATH}/{CHAIN}/{NETWORK}.toml", "w") as f: toml.dump(DEPLOYED_CONTRACTS_INFO, f) return None @@ -562,7 +558,6 @@ def instantiate2_contract( if permissioned_uploader_address is not None: msg = MsgInstantiateContract2( sender=permissioned_uploader_address, - admin=ADMIN_ADDRESS, code_id=code_id, msg=json_encode(args).encode("UTF8"), label=label, @@ -573,7 +568,6 @@ def instantiate2_contract( else: msg = MsgInstantiateContract2( sender=str(wallet.address()), - admin=ADMIN_ADDRESS, code_id=code_id, msg=json_encode(args).encode("UTF8"), label=label, diff --git a/scripts/deploy_injective.py b/scripts/deploy_injective.py index 604d1958..22bea693 100644 --- a/scripts/deploy_injective.py +++ b/scripts/deploy_injective.py @@ -61,9 +61,6 @@ # Pregenerated Contract Addresses ENTRY_POINT_PRE_GENERATED_ADDRESS = config["ENTRY_POINT_PRE_GENERATED_ADDRESS"] -# Admin address for future migrations -ADMIN_ADDRESS = config["ADMIN_ADDRESS"] - # MNEMONIC MNEMONIC = config["MNEMONIC"] @@ -164,7 +161,6 @@ async def instantiate_contract( ): msg = wasm_tx_pb.MsgInstantiateContract( sender=address.to_acc_bech32(), - admin=ADMIN_ADDRESS, code_id=code_id, label=label, msg=json.dumps(args).encode('utf-8'), @@ -193,7 +189,6 @@ async def instantiate2_contract( ): msg = wasm_tx_pb.MsgInstantiateContract2( sender=address.to_acc_bech32(), - admin=ADMIN_ADDRESS, code_id=code_id, label=label, msg=json.dumps(args).encode('utf-8'),