def patch_source_code(testnet_config: TestnetConfiguration): logger.info("Patching the source code...") folder = testnet_config.node_source() file = path.join(folder, "core/constants.go") content = utils.read_file(file) utils.write_file(file, content) file = path.join(folder, "cmd/node/main.go") content = utils.read_file(file) content = content.replace("secondsToWaitForP2PBootstrap = 20", "secondsToWaitForP2PBootstrap = 1") utils.write_file(file, content)
def load_from_file(cls, f: Any): data_json: bytes = utils.read_file(f).encode() fields = json.loads(data_json).get("tx") instance = cls() instance.__dict__.update(fields) instance.data = instance.data_decoded() return instance
def create_transaction(args: Any): args = utils.as_object(args) cli_shared.check_broadcast_args(args) cli_shared.prepare_nonce_in_args(args) if args.data_file: args.data = utils.read_file(args.data_file) tx = do_prepare_transaction(args) if hasattr(args, "relay") and args.relay: args.outfile.write(tx.serialize_as_inner()) return send_wait_result = args.wait_result and args.send and not args.simulate send_only = args.send and not (args.wait_result or args.simulate) simulate = args.simulate and not (send_only or send_wait_result) try: if send_wait_result: proxy = ElrondProxy(args.proxy) response = tx.send_wait_result(proxy, args.timeout) utils.dump_out_json(response) elif send_only: tx.send(ElrondProxy(args.proxy)) elif simulate: response = tx.simulate(ElrondProxy(args.proxy)) utils.dump_out_json(response) finally: tx.dump_to(args.outfile)
def _create_main_ll(self): logger.info("_create_main_ll") package_path = Path(__file__).parent template_path = package_path.joinpath("sol_main_ll.txt") template = utils.read_file(template_path) content = template.replace("{{NAME}}", self.unit_name) utils.write_file(self.file_main_ll, content)
def _replace_in_files(self, files, replacements): for file in files: content = utils.read_file(file) for to_replace, replacement in replacements: content = content.replace(to_replace, replacement) utils.write_file(file, content)
def _prepare_contract(args: Any) -> SmartContract: if args.bytecode: bytecode = utils.read_file(args.bytecode, binary=True).hex() else: project = load_project(args.project) bytecode = project.get_bytecode() metadata = CodeMetadata(args.metadata_upgradeable, args.metadata_payable) contract = SmartContract(bytecode=bytecode, metadata=metadata) return contract
def create_transaction(args: Any): args = utils.as_object(args) cli_shared.check_broadcast_args(args) cli_shared.prepare_nonce_in_args(args) if args.data_file: args.data = utils.read_file(args.data_file) tx = do_prepare_transaction(args) if hasattr(args, "relay") and args.relay: args.outfile.write(tx.serialize_as_inner()) return try: if args.send: tx.send(ElrondProxy(args.proxy)) elif args.simulate: response = tx.simulate(ElrondProxy(args.proxy)) utils.dump_out_json(response) finally: tx.dump_to(args.outfile)
def get_bytecode(self): bytecode = utils.read_file(self.get_file_wasm(), binary=True) bytecode_hex = bytecode.hex() return bytecode_hex
def from_file(cls, filename): data_json = utils.read_file(filename).encode() return cls.from_json(data_json)
def _read_index(self): info = utils.read_file(self.txs_info_file_path) info_slit = info.split(":") return int(info_slit[1])
def get_bytecode(self): bytecode = utils.read_file(self.get_file_wasm().with_suffix(".hex")) return bytecode