def execute(self, arguments): asset_id = None from_addr = None watch_only = False do_count = False wallet = PromptData.Wallet arguments, from_addr_str = PromptUtils.get_from_addr(arguments) if from_addr_str: if not isValidPublicAddress(from_addr_str): print("Invalid address specified") return from_addr = wallet.ToScriptHash(from_addr_str) for item in arguments: if item == '--watch': watch_only = True elif item == '--count': do_count = True else: asset_id = PromptUtils.get_asset_id(wallet, item) return ShowUnspentCoins(wallet, asset_id, from_addr, watch_only, do_count)
def token_mint(wallet, args, prompt_passwd=True): token = PromptUtils.get_asset_id(wallet, args[0]) if not isinstance(token, NEP5Token): print("The given symbol does not represent a loaded NEP5 token") return False mint_to_addr = args[1] args, invoke_attrs = PromptUtils.get_tx_attr_from_args(args) if len(args) < 3: print("please specify assets to attach") return False asset_attachments = args[2:] tx, fee, results = token.Mint(wallet, mint_to_addr, asset_attachments, invoke_attrs=invoke_attrs) if tx is not None and results is not None and len(results) > 0: if results[0] is not None: print("\n-----------------------------------------------------------") print("[%s] Will mint tokens to address: %s " % (token.symbol, mint_to_addr)) print("Fee: %s " % (fee.value / Fixed8.D)) print("-------------------------------------------------------------\n") if prompt_passwd: passwd = prompt("[Password]> ", is_password=True) if not wallet.ValidatePassword(passwd): print("incorrect password") return False return InvokeWithTokenVerificationScript(wallet, tx, token, fee, invoke_attrs=invoke_attrs) print("Could not register address") return False
def execute(self, arguments): wallet = PromptData.Wallet if len(arguments) < 4: print("Please specify the required parameters") return if len(arguments) > 5: # the 5th argument is the optional attributes, print("Too many parameters supplied. Please check your command") return addr = arguments[0] if not isValidPublicAddress(addr): print("Invalid address specified") return try: from_addr = wallet.ToScriptHash(addr) except ValueError as e: print(str(e)) return asset_id = PromptUtils.get_asset_id(wallet, arguments[1]) if not asset_id: print(f"Unknown asset id: {arguments[1]}") return try: index = int(arguments[2]) except ValueError: print(f"Invalid unspent index value: {arguments[2]}") return try: divisions = int(arguments[3]) except ValueError: print(f"Invalid divisions value: {arguments[3]}") return if divisions < 2: print("Divisions cannot be lower than 2") return if len(arguments) == 5: fee = Fixed8.TryParse(arguments[4], require_positive=True) if not fee: print(f"Invalid fee value: {arguments[4]}") return else: fee = Fixed8.Zero() return SplitUnspentCoin(wallet, asset_id, from_addr, index, divisions, fee)