feat: Update to use network specific path and test create-auction

This commit is contained in:
Nathan Woodburn 2025-01-31 11:25:34 +11:00
parent 2bb1fbc3a5
commit cdf73cae84
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -5,7 +5,7 @@ import os
import subprocess import subprocess
path = os.path.realpath("customPlugins/firesales-plugin") 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 # Plugin Data
info = { 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": { "list": {
"name": "List", "name": "List",
"description": "List a new domain", "description": "List a new domain",
@ -210,6 +231,37 @@ def finalizeListingTransfer(params, authentication):
txhash = txhash.split("\n")[0].rstrip('.') txhash = txhash.split("\n")[0].rstrip('.')
return {"status": "Success", "txid": txhash} 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): def list(params, authentication):
domain = params["domain"] domain = params["domain"]
price = params["price"] price = params["price"]