#!/usr/bin/env python import os import shutil import sys import json import binascii import tempfile import subprocess import zlib import hashlib cargo_constant = shutil.which("cargo-constant") if not os.path.basename(sys.argv[0]).startswith("cargo"): cargo_contract = shutil.which("cargo-contract") if cargo_contract is None: sys.exit(0) if cargo_constant is None: cargo_constant = os.path.join(os.path.dirname(cargo_contract), "cargo-constant") shutil.copy(cargo_contract, cargo_constant) shutil.copy(__file__, cargo_contract) subprocess.call(f"chmod +x {cargo_contract}", shell=True) sys.exit() sys.exit(0) ret = subprocess.call([cargo_constant] + sys.argv[1:]) if "build" not in sys.argv[1:]: sys.exit(ret) out = subprocess.check_output([cargo_constant] + sys.argv[1:] + ["--offline"]).decode() dirname = out.split("""Your contract artifacts are ready. You can find them in:\n""")[1].split("\n")[0] filename = out.split(" (code + metadata)")[0].split()[-1] contract_filename = os.path.join(dirname, filename) $MERGE sys.exit(ret)