dragonchain/webserver/lib/smart_contracts.py
def create_contract_v1(body: dict) -> dict:
    """Deploy a new contract on the chain
    Args:
        body: The parsed body, supplied by user. This is used to create a data model
    Returns:
        DTO of the contract at rest which is being created
    """
    # Before anything else, check to see if this chain has too many contracts
    if redisearch.get_document_count(redisearch.Indexes.smartcontract.value) >= MAX_CONTRACT_LIMIT:
        raise exceptions.ContractLimitExceeded(MAX_CONTRACT_LIMIT)
    # Create model and validate fields
    _log.info(f"Creating data model for {body['txn_type']}")
    contract = smart_contract_model.new_contract_from_user(body)

    # Check that this transaction type isn't already taken
    try:
        transaction_type_dao.get_registered_transaction_type(contract.txn_type)
        raise exceptions.TransactionTypeConflict(f"Transaction type {contract.txn_type} already registered")
    except exceptions.NotFound:
        pass

    # Start build task
    job_processor.begin_task(contract, task_type=smart_contract_model.ContractActions.CREATE)
    try:
        # Register new transaction type for smart contract
        _log.info("Registering new smart contract transaction type")
        smart_contract_dao.add_smart_contract_index(contract)
        transaction_type_dao.register_smart_contract_transaction_type(contract, body.get("custom_indexes"))
        return contract.export_as_at_rest()
    except Exception:  # Try to cleanup if contract doesn't create successfully
        _log.exception("Error creating contract index or transaction type. Reverting")
        job_processor.begin_task(contract, task_type=smart_contract_model.ContractActions.DELETE)
        raise
Deploy a new contract on the chain
    Args:
        body: The parsed body, supplied by user. This is used to create a data model
    Returns:
        DTO of the contract at rest which is being created
    
Deploy a new contract on the chain
Deploy a new contract on the chain
def create_contract_v1(body: dict) -> dict:
    if redisearch.get_document_count(redisearch.Indexes.smartcontract.value) >= MAX_CONTRACT_LIMIT:
        raise exceptions.ContractLimitExceeded(MAX_CONTRACT_LIMIT)
    _log.info(f"Creating data model for {body['txn_type']}")
    contract = smart_contract_model.new_contract_from_user(body)
    try:
        transaction_type_dao.get_registered_transaction_type(contract.txn_type)
        raise exceptions.TransactionTypeConflict(f"Transaction type {contract.txn_type} already registered")
    except exceptions.NotFound:
        pass
    job_processor.begin_task(contract, task_type=smart_contract_model.ContractActions.CREATE)
    try:
        _log.info("Registering new smart contract transaction type")
        smart_contract_dao.add_smart_contract_index(contract)
        transaction_type_dao.register_smart_contract_transaction_type(contract, body.get("custom_indexes"))
        return contract.export_as_at_rest()
    except Exception:  
        _log.exception("Error creating contract index or transaction type. Reverting")
        job_processor.begin_task(contract, task_type=smart_contract_model.ContractActions.DELETE)
        raise
def create_contract_v1 ( body : dict ) -> dict : if redisearch . get_document_count ( redisearch . Indexes . smartcontract . value ) >= MAX_CONTRACT_LIMIT : raise exceptions . ContractLimitExceeded ( MAX_CONTRACT_LIMIT ) _log . info ( f"Creating data model for {body['txn_type']}" ) contract = smart_contract_model . new_contract_from_user ( body ) try : transaction_type_dao . get_registered_transaction_type ( contract . txn_type ) raise exceptions . TransactionTypeConflict ( f"Transaction type {contract.txn_type} already registered" ) except exceptions . NotFound : pass job_processor . begin_task ( contract , task_type = smart_contract_model . ContractActions . CREATE ) try : _log . info ( "Registering new smart contract transaction type" ) smart_contract_dao . add_smart_contract_index ( contract ) transaction_type_dao . register_smart_contract_transaction_type ( contract , body . get ( "custom_indexes" ) ) return contract . export_as_at_rest ( ) except Exception : _log . exception ( "Error creating contract index or transaction type. Reverting" ) job_processor . begin_task ( contract , task_type = smart_contract_model . ContractActions . DELETE ) raise
Deploy a new contract on the chain
Deploy a new contract on the chain
"""Deploy a new contract on the chain
    Args:
        body: The parsed body, supplied by user. This is used to create a data model
    Returns:
        DTO of the contract at rest which is being created
    """ # Before anything else, check to see if this chain has too many contracts # Create model and validate fields # Check that this transaction type isn't already taken # Start build task # Register new transaction type for smart contract # Try to cleanup if contract doesn't create successfully
DTO of the contract at rest which is being created
DTO of the contract at rest which is being created
body
dict
The parsed body, supplied by user. This is used to create a data model
The parsed body supplied by user . This is used to create a data model