Exemple #1
0
    def _load_deployments(self) -> None:
        if CONFIG.network_type != "live" and not CONFIG.settings["dev_deployment_artifacts"]:
            return
        chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev"
        path = self._build_path.joinpath(f"deployments/{chainid}")
        path.mkdir(exist_ok=True)
        deployments = list(path.glob("*.json"))
        deployments.sort(key=lambda k: k.stat().st_mtime)
        deployment_map = self._load_deployment_map()
        for build_json in deployments:
            with build_json.open() as fp:
                build = json.load(fp)

            contract_name = build["contractName"]
            if contract_name not in self._containers:
                build_json.unlink()
                continue
            if "pcMap" in build:
                contract = ProjectContract(self, build, build_json.stem)
            else:
                contract = Contract.from_abi(  # type: ignore
                    contract_name, build_json.stem, build["abi"]
                )
                contract._project = self
            container = self._containers[contract_name]
            _add_contract(contract)
            container._contracts.append(contract)

            # update deployment map for the current chain
            instances = deployment_map.setdefault(chainid, {}).setdefault(contract_name, [])
            if build_json.stem in instances:
                instances.remove(build_json.stem)
            instances.insert(0, build_json.stem)

        self._save_deployment_map(deployment_map)
Exemple #2
0
 def _load_deployments(self) -> None:
     if not CONFIG["active_network"].get("persist", None):
         return
     network = CONFIG["active_network"]["name"]
     path = self._path.joinpath(f"build/deployments/{network}")
     path.mkdir(exist_ok=True)
     deployments = list(
         self._path.glob(
             f"build/deployments/{CONFIG['active_network']['name']}/*.json")
     )
     deployments.sort(key=lambda k: k.stat().st_mtime)
     for build_json in deployments:
         with build_json.open() as fp:
             build = json.load(fp)
         if build["contractName"] not in self._containers:
             build_json.unlink()
             continue
         if "pcMap" in build:
             contract = ProjectContract(self, build, build_json.stem)
         else:
             contract = Contract(  # type: ignore
                 build["contractName"], build_json.stem, build["abi"])
             contract._project = self
         container = self._containers[build["contractName"]]
         _add_contract(contract)
         container._contracts.append(contract)
Exemple #3
0
 def _load_deployments(self) -> None:
     if CONFIG.network_type != "live":
         return
     chainid = CONFIG.active_network["chainid"]
     path = self._path.joinpath(f"build/deployments/{chainid}")
     path.mkdir(exist_ok=True)
     deployments = list(path.glob("*.json"))
     deployments.sort(key=lambda k: k.stat().st_mtime)
     for build_json in deployments:
         with build_json.open() as fp:
             build = json.load(fp)
         if build["contractName"] not in self._containers:
             build_json.unlink()
             continue
         if "pcMap" in build:
             contract = ProjectContract(self, build, build_json.stem)
         else:
             contract = Contract(  # type: ignore
                 build["contractName"], build_json.stem, build["abi"])
             contract._project = self
         container = self._containers[build["contractName"]]
         _add_contract(contract)
         container._contracts.append(contract)