dragonchain/webserver/lib/smart_contracts.py
def update_contract_v1(contract_id: str, update: dict) -> dict:
    """Update an existing contract on the chain
    Args:
        contract_id: The contract_id of the contract
        update: The parsed body, supplied by user. This is used to create an update data model
    Returns:
        DTO of the contract at rest which has been updated
    """
    # Get existing model, and check state
    contract = smart_contract_dao.get_contract_by_id(contract_id)
    contract_update = smart_contract_model.new_update_contract(update, existing_contract=contract)
    if smart_contract_model.ContractState.is_updatable_state(contract.status["state"]):
        raise exceptions.BadStateError(f'State {contract.status["state"]} not valid to begin updates')

    # Create and validate update model
    contract_update.start_state = contract.status["state"]

    # Set state to updating
    contract.set_state(smart_contract_model.ContractState.UPDATING)
    contract.save()

    try:
        job_processor.begin_task(contract_update, task_type=smart_contract_model.ContractActions.UPDATE)
    except RuntimeError:
        contract.set_state(state=smart_contract_model.ContractState.ACTIVE, msg="Contract update failed: could not start update.")
        contract.save()
        raise
    return contract.export_as_at_rest()
Update an existing contract on the chain
    Args:
        contract_id: The contract_id of the contract
        update: The parsed body, supplied by user. This is used to create an update data model
    Returns:
        DTO of the contract at rest which has been updated
    
Update an existing contract on the chain
Update an existing contract on the chain
def update_contract_v1(contract_id: str, update: dict) -> dict:
    contract = smart_contract_dao.get_contract_by_id(contract_id)
    contract_update = smart_contract_model.new_update_contract(update, existing_contract=contract)
    if smart_contract_model.ContractState.is_updatable_state(contract.status["state"]):
        raise exceptions.BadStateError(f'State {contract.status["state"]} not valid to begin updates')
    contract_update.start_state = contract.status["state"]
    contract.set_state(smart_contract_model.ContractState.UPDATING)
    contract.save()
    try:
        job_processor.begin_task(contract_update, task_type=smart_contract_model.ContractActions.UPDATE)
    except RuntimeError:
        contract.set_state(state=smart_contract_model.ContractState.ACTIVE, msg="Contract update failed: could not start update.")
        contract.save()
        raise
    return contract.export_as_at_rest()
def update_contract_v1 ( contract_id : str , update : dict ) -> dict : contract = smart_contract_dao . get_contract_by_id ( contract_id ) contract_update = smart_contract_model . new_update_contract ( update , existing_contract = contract ) if smart_contract_model . ContractState . is_updatable_state ( contract . status [ "state" ] ) : raise exceptions . BadStateError ( f'State {contract.status["state"]} not valid to begin updates' ) contract_update . start_state = contract . status [ "state" ] contract . set_state ( smart_contract_model . ContractState . UPDATING ) contract . save ( ) try : job_processor . begin_task ( contract_update , task_type = smart_contract_model . ContractActions . UPDATE ) except RuntimeError : contract . set_state ( state = smart_contract_model . ContractState . ACTIVE , msg = "Contract update failed: could not start update." ) contract . save ( ) raise return contract . export_as_at_rest ( )
Update an existing contract on the chain
Update an existing contract on the chain
"""Update an existing contract on the chain
    Args:
        contract_id: The contract_id of the contract
        update: The parsed body, supplied by user. This is used to create an update data model
    Returns:
        DTO of the contract at rest which has been updated
    """ # Get existing model, and check state # Create and validate update model # Set state to updating
DTO of the contract at rest which has been updated
DTO of the contract at rest which has been updated
contract_id
str
The contract_id of the contract
The contract_id of the contract
update
dict
The parsed body, supplied by user. This is used to create an update data model
The parsed body supplied by user . This is used to create an update data model