diff --git a/firesales.py b/firesales.py index 46d4dc0..b9252d0 100644 --- a/firesales.py +++ b/firesales.py @@ -5,7 +5,7 @@ import os import subprocess path = os.path.realpath("customPlugins/firesales-plugin") -userData = os.path.realpath("user_data/firesales") +userData = os.path.realpath(f"user_data/firesales/{account.HSD_NETWORK}") # Plugin Data info = { @@ -71,6 +71,27 @@ functions = { } } }, + "createListing": { + "name": "CreateListing", + "description": "CreateListing a new domain", + "type":"default", + "params": { + "domain": { + "type": "text", + "name": "Domain to list" + }, + "price": { + "type": "number", + "name": "Price of the domain" + } + }, + "returns": { + "status": { + "type": "text", + "name": "Status of the listing" + } + } + }, "list": { "name": "List", "description": "List a new domain", @@ -210,6 +231,37 @@ def finalizeListingTransfer(params, authentication): txhash = txhash.split("\n")[0].rstrip('.') return {"status": "Success", "txid": txhash} +def createListing(params, authentication): + domain = params["domain"] + price = params["price"] + # Generate command + wallet = authentication.split(":")[0] + passphrase = authentication.split(":")[1] + api_key = os.getenv("hsd_api") + host = os.getenv("hsd_ip") + if host is None: + host = "127.0.0.1" + + process = subprocess.Popen( + ["node", f"{path}/node_modules/shakedex/bin/shakedex", "create-auction", domain, "-n", account.HSD_NETWORK, "-w", wallet, "-a", api_key, "-p", f"{userData}", "--httphost", host, "-P", passphrase], + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT + ) + # Wait for the process to finish + stdout, stderr = process.communicate() + print(f"STDOUT: {stdout}") + + if stderr is None: + stderr = stdout + + if process.returncode != 0: + return {"status": f"Error: {stderr}", "txid": None} + + txhash:str = stdout.split(" hash ")[1] + txhash = txhash.split("\n")[0].rstrip('.') + return {"status": "Success", "txid": txhash} + def list(params, authentication): domain = params["domain"] price = params["price"]