Skip to content

Commit

Permalink
Fix mainnet deployment, unlock account for 1 h.
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Apr 13, 2017
1 parent d15770f commit f14c3c3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
10 changes: 9 additions & 1 deletion contracts/BonusFinalizeAgent.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ contract BonusFinalizeAgent is FinalizeAgent {
function BonusFinalizeAgent(CrowdsaleToken _token, Crowdsale _crowdsale, uint _bonusBasePoints, address _teamMultisig) {
token = _token;
crowdsale = _crowdsale;
bonusBasePoints = _bonusBasePoints;
if(address(crowdsale) == 0) {
throw;
}

teamMultisig = _teamMultisig;
if(address(teamMultisig) == 0) {
throw;
}

bonusBasePoints = _bonusBasePoints;
}

/* Can we run finalize properly */
Expand Down
24 changes: 17 additions & 7 deletions crowdsales/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,34 @@ unit_test:
# They set ownership and allowed actions, so that contracts can interact
post_actions: |
# Enable new token minting by a crowdsale contract
token.transact({"from": deploy_address}).setMintAgent(crowdsale.address, True)
confirm_tx(token.transact({"from": deploy_address}).setMintAgent(crowdsale.address, True))
# Set actions what happen at the end of the crodsale.
# Enable token mintint at the end of the crowdsale to create bonus pool, founder pool and such
token.transact({"from": deploy_address}).setMintAgent(finalize_agent.address, True)
crowdsale.transact({"from": deploy_address}).setFinalizeAgent(finalize_agent.address)
token.transact({"from": deploy_address}).setReleaseAgent(finalize_agent.address)
confirm_tx(token.transact({"from": deploy_address}).setMintAgent(finalize_agent.address, True))
confirm_tx(crowdsale.transact({"from": deploy_address}).setFinalizeAgent(finalize_agent.address))
confirm_tx(token.transact({"from": deploy_address}).setReleaseAgent(finalize_agent.address))
# Move ownership of all owned contracts to the team multisig address
crowdsale.transact({"from": deploy_address}).transferOwnership(team_multisig.address)
token.transact({"from": deploy_address}).transferOwnership(team_multisig.address)
confirm_tx(crowdsale.transact({"from": deploy_address}).transferOwnership(team_multisig.address))
confirm_tx(token.transact({"from": deploy_address}).transferOwnership(team_multisig.address))
# Set token upgrade master
confirm_tx(token.transact({"from": deploy_address}).setUpgradeMaster(team_multisig.address))
# Make sure that everything we have deployed all contracts in good state
# and their internal state is sane
verify_actions: |
assert token.call().owner() == team_multisig.address
assert token.call().owner() == team_multisig.address, "Expected owner {}, got {}".format(token.call().owner(),team_multisig.address)
assert crowdsale.call().owner() == team_multisig.address
assert preico.call().owner() == team_multisig.address
assert token.call().owner() == team_multisig.address
assert token.call().upgradeMaster() == team_multisig.address
assert finalize_agent.call().teamMultisig() == team_multisig.address
assert finalize_agent.call().isSane()
assert crowdsale.call().getState() == CrowdsaleState.PreFunding
# To be used with the deposit instructions for contributors
sig_data = crowdsale._prepare_transaction("buy")
print("Crowdsale.buy() data payload is", sig_data["data"])
13 changes: 9 additions & 4 deletions ico/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def deploy_contract(project: Project, chain, deploy_address, contract_def: dict,
# Goes through geth account unlock process if needed
if need_unlock:
if is_account_locked(web3, deploy_address):
request_account_unlock(chain, deploy_address, None)
# Deploy can last max 1 h
request_account_unlock(chain, deploy_address, timeout=3600)

transaction = {"from": deploy_address}
kwargs = dict(**contract_def["arguments"]) # Unwrap YAML CommentedMap
Expand Down Expand Up @@ -95,7 +96,8 @@ def deploy_crowdsale(project: Project, chain, source_definitions: dict, deploy_a
address = contract_def.get("address")
if address:
print("Already deployed contract,", name, address)
contracts[name] = chain.get_contract_factory(contract_name)
Contract = getattr(chain.contract_factories, contract_name)
contracts[name] = Contract(address=address)
statistics["already_deployed"] += 1
continue

Expand Down Expand Up @@ -196,7 +198,7 @@ def perform_verify_actions(chain, runtime_data: dict, contracts: dict):


def deploy_crowdsale_from_file(project: Project, yaml_filename: str, deployment_name: str, deploy_address: str):
""""""
"""Deploy crowdsale plan."""
chain_data = load_crowdsale_definitions(yaml_filename, deployment_name)
chain_name = chain_data["chain"]
address = deploy_address
Expand All @@ -207,12 +209,15 @@ def deploy_crowdsale_from_file(project: Project, yaml_filename: str, deployment_

print("Web3 provider is", web3.currentProvider)
print("Owner address is", address)
print("Owner balance is", from_wei(web3.eth.getBalance(address), "ether"), "ETH")
start_balance = from_wei(web3.eth.getBalance(address), "ether")
print("Owner balance is", start_balance, "ETH")

runtime_data, statistics, contracts = deploy_crowdsale(project, chain, chain_data, deploy_address)
perform_post_actions(chain, runtime_data, contracts)
perform_verify_actions(chain, runtime_data, contracts)
write_deployment_report(yaml_filename, runtime_data)
end_balance = from_wei(web3.eth.getBalance(address), "ether")
print("Deployment cost is", start_balance - end_balance, "ETH")

return runtime_data, statistics, contracts

0 comments on commit f14c3c3

Please sign in to comment.