def _get_arwen_version(testnet_config: TestnetConfiguration): go_mod = testnet_config.node_source() / "go.mod" lines = utils.read_lines(go_mod) line = next(line for line in lines if "github.com/ElrondNetwork/arwen-wasm-vm" in line) parts = line.split() return parts[1]
def parse(pem_file): pem_file = path.expanduser(pem_file) guards.is_file(pem_file) lines = utils.read_lines(pem_file) lines = [line for line in lines if "-----" not in line] key_base64 = "".join(lines) key_hex = base64.b64decode(key_base64).decode() key_bytes = bytes.fromhex(key_hex) seed = key_bytes[:32] pubkey = key_bytes[32:] return seed, pubkey
def parse_validator_pem(pem_file, index: int = 0): pem_file = path.expanduser(pem_file) guards.is_file(pem_file) lines = utils.read_lines(pem_file) bls_keys = read_bls_keys(lines) private_keys = read_validators_private_keys(lines) private_key = private_keys[index] key_bytes = get_bytes_from_private_key(private_key) bls_key = bls_keys[index] seed = key_bytes return seed, bls_key
def parse(pem_file: Union[str, Path], index: int = 0) -> Tuple[bytes, bytes]: pem_file = path.expanduser(pem_file) guards.is_file(pem_file) lines = utils.read_lines(pem_file) keys_lines = [ list(key_lines) for is_next_key, key_lines in itertools.groupby( lines, lambda line: "-----" in line) if not is_next_key ] keys = ["".join(key_lines) for key_lines in keys_lines] key_base64 = keys[index] key_hex = base64.b64decode(key_base64).decode() key_bytes = bytes.fromhex(key_hex) seed = key_bytes[:32] pubkey = key_bytes[32:] return seed, pubkey
def get_index_by_shard_id(pem_file: Union[str, Path], shard_id: int) -> int: pem_file = path.expanduser(pem_file) guards.is_file(pem_file) lines = utils.read_lines(pem_file) keys_lines = [ list(key_lines) for is_next_key, key_lines in itertools.groupby( lines, lambda line: "-----" in line) if not is_next_key ] keys = ["".join(key_lines) for key_lines in keys_lines] idx = 0 while idx < len(keys): key_hex = base64.b64decode(keys[idx]).decode() key_bytes = bytes.fromhex(key_hex) pubkey = key_bytes[32:] shard = get_shard_of_address(pubkey) if shard_id == shard: return idx idx += 1 print("cannot find address with given shard") return 0
def _get_exports(self): file_export = self.project.find_file_globally("*.export") lines = utils.read_lines(file_export) return lines
def main(): logging.basicConfig(level=logging.DEBUG) parser = ArgumentParser() parser.add_argument("--proxy", default="https://testnet-api.elrond.com") parser.add_argument("--pem", required=True) parser.add_argument("--reward-address", required=True, help="the reward address") parser.add_argument("--nodes-file", required=True, help="file containing list of BLS keys, one per line") parser.add_argument("--value", required=True, help="the value to stake") args = parser.parse_args() proxy_url = args.proxy reward_address = Address(args.reward_address) lines = utils.read_lines(args.nodes_file) value = args.value chain = config.get_chain_id() print("Reward address:") print(reward_address.bech32()) confirm_continuation() print("Number of Nodes to stake:", len(lines)) confirm_continuation() for line in lines: print(line[:8], "...", line[-8:]) confirm_continuation() print("Elrond Proxy (or Observer) address:", proxy_url) print("Chain ID:", chain) confirm_continuation() print("Value to stake:") print(int(value)) print(int(value) / int(math.pow(10, 18)), "ERD") confirm_continuation() stake_args: Any = utils.Object() stake_args.reward_address = reward_address.bech32() stake_args.number_of_nodes = len(lines) # Minor programming artifice (the CSV formatting), # so that we are compatible with erdpy 0.7.2 (this will change in the future) stake_args.nodes_public_keys = ",".join(lines) stake_args.estimate_gas = True stake_args.gas_price = 1000000000 stake_args.value = args.value stake_args.pem = args.pem stake_args.proxy = proxy_url stake_args.chain = chain stake_args.version = config.get_tx_version() stake_args.recall_nonce = True print("Transaction will now be sent.") confirm_continuation() facade.prepare_and_send_stake_transaction(stake_args) print("Done.")
def get_exported_functions(self): file_export = self.find_file_globally('*.export') lines = utils.read_lines(file_export) return lines