2019-05-27 05:15:10 +00:00
|
|
|
import argparse
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
2020-01-22 17:09:40 +00:00
|
|
|
from vyper import compiler
|
2019-05-27 05:15:10 +00:00
|
|
|
|
|
|
|
DIR = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
|
|
|
|
def generate_compiled_json(file_path: str):
|
|
|
|
deposit_contract_code = open(file_path).read()
|
|
|
|
abi = compiler.mk_full_signature(deposit_contract_code)
|
|
|
|
bytecode = compiler.compile_code(deposit_contract_code)['bytecode']
|
|
|
|
contract_json = {
|
|
|
|
'abi': abi,
|
|
|
|
'bytecode': bytecode,
|
|
|
|
}
|
|
|
|
# write json
|
|
|
|
basename = os.path.basename(file_path)
|
|
|
|
dirname = os.path.dirname(file_path)
|
|
|
|
contract_name = basename.split('.')[0]
|
|
|
|
with open(dirname + "/{}.json".format(contract_name), 'w') as f_write:
|
|
|
|
json.dump(contract_json, f_write)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("path", type=str, help="the path of the contract")
|
|
|
|
args = parser.parse_args()
|
|
|
|
path = args.path
|
|
|
|
generate_compiled_json(path)
|