Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not set a contract admin #124

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions scripts/configs/archway.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://archway-api.polkachu.com"
MAINNET_RPC_URL = "https://archway-rpc.polkachu.com"
MAINNET_CHAIN_ID = "archway-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/chihuahua.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://chihuahua-api.polkachu.com"
MAINNET_RPC_URL = "https://chihuahua-rpc.polkachu.com"
MAINNET_CHAIN_ID = "chihuahua-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/injective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://sentry.lcd.injective.network:443"
MAINNET_RPC_URL = " https://sentry.tm.injective.network:443/"
MAINNET_CHAIN_ID = "injective-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/migaloo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://migaloo-api.polkachu.com"
MAINNET_RPC_URL = "https://migaloo-rpc.polkachu.com"
MAINNET_CHAIN_ID = "migaloo-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/neutron.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

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"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/oraichain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://orai-api.polkachu.com"
MAINNET_RPC_URL = "https://orai-rpc.polkachu.com"
MAINNET_CHAIN_ID = "Oraichain"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/osmosis.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://osmosis-api.polkachu.com"
MAINNET_RPC_URL = "https://osmosis-rpc.polkachu.com/"
MAINNET_CHAIN_ID = "osmosis-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/persistence.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://persistence-api.polkachu.com"
MAINNET_RPC_URL = "https://persistence-rpc.polkachu.com"
MAINNET_CHAIN_ID = "core-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/sei.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://sei-api.polkachu.com"
MAINNET_RPC_URL = "https://sei-rpc.polkachu.com"
MAINNET_CHAIN_ID = "pacific-1"
Expand Down
3 changes: 0 additions & 3 deletions scripts/configs/terra.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ MNEMONIC = "<YOUR MNEMONIC HERE>"
# Commit Hash of the commit used to build the contracts
COMMIT_HASH = "<COMMIT HASH HERE>"

# Admin address to execute migrations from
ADMIN_ADDRESS = "<ADMIN ADDRESS HERE>"

MAINNET_REST_URL = "https://lcd-terra.tfl.foundation"
MAINNET_RPC_URL = "https://terra-rpc.polkachu.com/"
MAINNET_CHAIN_ID = "phoenix-1"
Expand Down
34 changes: 14 additions & 20 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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']}",
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -326,7 +323,7 @@ def main():
args,
f"swap_adapter_{venue['name']}"
)
update_admin(
clear_admin(
client,
wallet,
swap_adapter_contract_address,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions scripts/deploy_injective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
Loading