示例#1
0
def build_abi_output(compiler_data: CompilerData) -> list:
    abi = compiler_data.vyper_module_folded._metadata["type"].to_abi_dict()
    if compiler_data.show_gas_estimates:
        # Add gas estimates for each function to ABI
        gas_estimates = build_gas_estimates(compiler_data.function_signatures)
        for func in abi:
            try:
                func_signature = func["name"]
            except KeyError:
                # constructor and fallback functions don't have a name
                continue

            func_name, _, _ = func_signature.partition("(")
            # This check ensures we skip __init__ since it has no estimate
            if func_name in gas_estimates:
                func["gas"] = gas_estimates[func_name]
    return abi
示例#2
0
文件: output.py 项目: synccirle/vyper
def build_abi_output(compiler_data: CompilerData) -> list:
    abi = sig_utils.mk_full_signature(compiler_data.global_ctx)
    # Add gas estimates for each function to ABI
    gas_estimates = build_gas_estimates(compiler_data.lll_nodes)
    for func in abi:
        try:
            func_signature = func["name"]
        except KeyError:
            # constructor and fallback functions don't have a name
            continue

        func_name, _, _ = func_signature.partition("(")
        # This check ensures we skip __init__ since it has no estimate
        if func_name in gas_estimates:
            # TODO: mutation
            func["gas"] = gas_estimates[func_name]
    return abi