def is_local_testnet(self): account_ = cleos.GetAccount(self.name, json=True, is_verbose=-1) # print(cleos._wallet_url_arg) # print(account_) if not account_.error and \ self.key_public == \ account_.json["permissions"][0]["required_auth"]["keys"] \ [0]["key"]: self.account_info = str(account_) self.EOSF(""" Local testnet is ON: the `eosio` account is master. """) return True else: return False
def __init__( self, is_verbose=1): self.name = "eosio" self.json["name"] = self.name config = teos.GetConfig(is_verbose=0) self.json["privateKey"] = config.json["EOSIO_KEY_PRIVATE"] self.json["publicKey"] = config.json["EOSIO_KEY_PUBLIC"] self.key_private = self.json["privateKey"] self.key_public = self.json["publicKey"] self._out = "transaction id: eosio" account = cleos.GetAccount(self.name, is_verbose=-1) if not account.error: self.account_info = account._out else: if "main.cpp:2712" in account.err_msg: self.account_info = "The account is not opened yet!" else: self.account_info = account.err_msg
def test_80(self): global account_alice get_account = cleos.GetAccount(account_alice) self.assertTrue(not get_account.error, "GetAcount") print(json.dumps(get_account.json, indent=4))
def __init__( self, name="", owner_key_public="", active_key_public="", is_verbose=1, verbosity=None): is_verbose = self.verify_is_verbose(verbosity, is_verbose) self.EOSF_TRACE(""" ######### Get master account. """) self.DEBUG(""" Local node is running: {} """.format(cleos.node_is_running())) AccountEosio.__init__(self, is_verbose) self.DEBUG(""" Name is `{}` Wallet URL is {} Use keosd status is {} self._out: {} self.err_msg: {} """.format( self.name, cleos.wallet_url(), setup.is_use_keosd(), self._out, self.err_msg )) if cleos.is_notrunningnotkeosd_error(self): self.ERROR(self.err_msg) return if self.is_local_testnet(): return self.account_info = "The account is not opened yet!" self.DEBUG("It is not the local testnet.") #cleos.set_wallet_url_arg(node, "") # not local testnet: if not owner_key_public: # print data for registration if not name: self.name = cleos.account_name() else: self.name = name self.owner_key = cleos.CreateKey("owner", is_verbose=0) self.active_key = cleos.CreateKey("active", is_verbose=0) self.OUT(""" Use the following data to register a new account on a public testnet: Accout Name: {} Owner Public Key: {} Owner Private Key: {} Active Public Key: {} Active Private Key: {} """.format( self.name, self.owner_key.key_public, self.owner_key.key_private, self.active_key.key_public, self.active_key.key_private )) else: # restore the master account self.name = name self.owner_key = cleos.CreateKey("owner", owner_key_public, is_verbose=0) if not active_key_public: self.active_key = owner_key else: self.active_key = cleos.CreateKey( "active", active_key_public, is_verbose=0) account_ = cleos.GetAccount(name, is_verbose=-1) if not account_.error: self.account_info = str(account_)
def __init__(self, creator, name, owner_key, active_key, stake_net, stake_cpu, permission="", buy_ram_kbytes=0, buy_ram="", transfer=False, expiration_sec=30, skip_signature=0, dont_broadcast=0, forceUnique=0, max_cpu_usage=0, max_net_usage=0, ref_block="", is_verbose=1): try: creator_name = creator.name except: creator_name = creator self.owner_key = None # private keys self.active_key = None try: owner_key_public = owner_key.key_public self.owner_key = owner_key.key_private except: owner_key_public = owner_key if not active_key: active_key = owner_key try: active_key_public = active_key.key_public self.active_key = active_key.key_private except: active_key_public = active_key args = [creator_name, name, owner_key_public, active_key_public] if setup.is_json(): args.append("--json") args.extend(["--stake-net", stake_net, "--stake-cpu", stake_cpu]) if buy_ram_kbytes: args.extend(["--buy-ram-kbytes", str(buy_ram_kbytes)]) if buy_ram: args.extend(["buy-ram", buy_ram]) if transfer: args.extend(["--transfer"]) if permission: try: permission_name = permission.name except: permission_name = permission args.extend(["--permission", permission_name]) if skip_signature: args.append("--skip-sign") if dont_broadcast: args.append("--dont-broadcast") if forceUnique: args.append("--force-unique") if max_cpu_usage: args.extend(["--max-cpu-usage-ms", max_cpu_usage]) if max_net_usage: args.extend(["--max-net-usage", max_net_usage]) if ref_block: args.extend(["--ref-block", ref_block]) self.name = name cleos._Cleos.__init__(self, args, "system", "newaccount", is_verbose) if not self.error and setup.is_json(): self.json = cleos.GetAccount(self.name, is_verbose=0, json=True).json if self.is_verbose: print(self.__str__())
def info(self): return str(cleos.GetAccount(self.name, is_verbose=1))