|
| 1 | +""" |
| 2 | +TODO Vote 2026_MM_DD |
| 3 | +
|
| 4 | +TODO <list of items synced with Notion> |
| 5 | +
|
| 6 | +TODO (after vote) Vote #{vote number} passed & executed on {date+time}, block {blockNumber}. |
| 7 | +""" |
| 8 | + |
| 9 | +from brownie import interface |
| 10 | +from typing import Dict, List, Tuple |
| 11 | + |
| 12 | +from utils.voting import bake_vote_items, confirm_vote_script, create_vote |
| 13 | +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description |
| 14 | +from utils.config import get_deployer_account, get_is_live, get_priority_fee |
| 15 | +from utils.mainnet_fork import pass_and_exec_dao_vote |
| 16 | +from utils.dual_governance import submit_proposals |
| 17 | + |
| 18 | +from utils.agent import agent_forward |
| 19 | + |
| 20 | + |
| 21 | +# ============================== Constants =================================== |
| 22 | +# TODO list of constants |
| 23 | + |
| 24 | + |
| 25 | +# ============================= IPFS Description ================================== |
| 26 | +# TODO IPFS description text |
| 27 | +IPFS_DESCRIPTION = """ |
| 28 | +""" |
| 29 | + |
| 30 | + |
| 31 | +# ================================ Main ====================================== |
| 32 | +def get_dg_items() -> List[Tuple[str, str]]: |
| 33 | + # TODO set up interface objects |
| 34 | + |
| 35 | + return [ |
| 36 | + # TODO 1.1. item description |
| 37 | + agent_forward([ |
| 38 | + ( |
| 39 | + <ADDRESS>, |
| 40 | + <METHOD>.encode_input(<PARAMS>) |
| 41 | + ) |
| 42 | + ]), |
| 43 | + |
| 44 | + # TODO 1.2. item description |
| 45 | + agent_forward([ |
| 46 | + <UTILS_METHOD>(<PARAMS>) |
| 47 | + ]), |
| 48 | + ] |
| 49 | + |
| 50 | + |
| 51 | +def get_vote_items() -> Tuple[List[str], List[Tuple[str, str]]]: |
| 52 | + |
| 53 | + # TODO set up interface objects |
| 54 | + |
| 55 | + # TODO in case of using smart-contract based omnibus, retrieve vote items from omnibus contract |
| 56 | + # voting_items = brownie.interface.SmartContractOmnibus(omnibus_contract).getVoteItems() |
| 57 | + # vote_desc_items = [] |
| 58 | + # call_script_items = [] |
| 59 | + # for desc, call_script in voting_items: |
| 60 | + # vote_desc_items.append(desc) |
| 61 | + # call_script_items.append((call_script[0], call_script[1].hex())) |
| 62 | + # return vote_desc_items, call_script_items |
| 63 | + # |
| 64 | + # OR |
| 65 | + # |
| 66 | + # vote_desc_items = [] |
| 67 | + # call_script_items = [] |
| 68 | + # # 1. receive DG vote items from omnibus contract |
| 69 | + # contract_dg_items = interface.V3LaunchOmnibus(OMNIBUS_CONTRACT).getVoteItems() |
| 70 | + # dg_items = [] |
| 71 | + # for _, call_script in contract_dg_items: |
| 72 | + # dg_items.append((call_script[0], call_script[1].hex())) |
| 73 | + # dg_call_script = submit_proposals([ |
| 74 | + # (dg_items, DG_PROPOSAL_DESCRIPTION) |
| 75 | + # ]) |
| 76 | + # vote_desc_items.append(DG_SUBMISSION_DESCRIPTION) |
| 77 | + # call_script_items.append(dg_call_script[0]) |
| 78 | + # # 2. receive non-DG vote items from omnibus contract |
| 79 | + # voting_items = interface.V3LaunchOmnibus(OMNIBUS_CONTRACT).getVotingVoteItems() |
| 80 | + # for desc, call_script in voting_items: |
| 81 | + # vote_desc_items.append(desc) |
| 82 | + # call_script_items.append((call_script[0], call_script[1].hex())) |
| 83 | + # return vote_desc_items, call_script_items |
| 84 | + |
| 85 | + dg_items = get_dg_items() |
| 86 | + |
| 87 | + dg_call_script = submit_proposals([ |
| 88 | + # TODO DG proposal description |
| 89 | + (dg_items, "DG proposal description") |
| 90 | + ]) |
| 91 | + |
| 92 | + vote_desc_items, call_script_items = zip( |
| 93 | + ( |
| 94 | + # TODO DG proposal description |
| 95 | + "1. DG proposal submition description", |
| 96 | + dg_call_script[0] |
| 97 | + ), |
| 98 | + ( |
| 99 | + # TODO item description |
| 100 | + "2. Item description", |
| 101 | + ( |
| 102 | + <ADDRESS>, |
| 103 | + <METHOD>.encode_input(<PARAMS>) |
| 104 | + ) |
| 105 | + ), |
| 106 | + ( |
| 107 | + # TODO item description |
| 108 | + "3. Item description", |
| 109 | + <UTILS_METHOD>(<PARAMS>) |
| 110 | + ), |
| 111 | + ) |
| 112 | + |
| 113 | + return vote_desc_items, call_script_items |
| 114 | + |
| 115 | + |
| 116 | +def start_vote(tx_params: Dict[str, str], silent: bool = False): |
| 117 | + vote_desc_items, call_script_items = get_vote_items() |
| 118 | + vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items)) |
| 119 | + |
| 120 | + desc_ipfs = ( |
| 121 | + calculate_vote_ipfs_description(IPFS_DESCRIPTION) |
| 122 | + if silent else upload_vote_ipfs_description(IPFS_DESCRIPTION) |
| 123 | + ) |
| 124 | + |
| 125 | + vote_id, tx = confirm_vote_script(vote_items, silent, desc_ipfs) and list( |
| 126 | + create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs) |
| 127 | + ) |
| 128 | + |
| 129 | + return vote_id, tx |
| 130 | + |
| 131 | + |
| 132 | +def main(): |
| 133 | + tx_params: Dict[str, str] = {"from": get_deployer_account().address} |
| 134 | + if get_is_live(): |
| 135 | + tx_params["priority_fee"] = get_priority_fee() |
| 136 | + |
| 137 | + vote_id, _ = start_vote(tx_params=tx_params, silent=False) |
| 138 | + vote_id >= 0 and print(f"Vote created: {vote_id}.") |
| 139 | + |
| 140 | + |
| 141 | +def start_and_execute_vote_on_fork_manual(): |
| 142 | + if get_is_live(): |
| 143 | + raise Exception("This script is for local testing only.") |
| 144 | + |
| 145 | + tx_params = {"from": get_deployer_account()} |
| 146 | + vote_id, _ = start_vote(tx_params=tx_params, silent=True) |
| 147 | + print(f"Vote created: {vote_id}.") |
| 148 | + pass_and_exec_dao_vote(int(vote_id), step_by_step=True) |
0 commit comments