From cd362f805b6f47733e89be6fe820c5fdc75de746 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 30 Jan 2025 22:31:17 +1100 Subject: [PATCH] feat: Add transfer finalize --- firesales.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- shakedex/main.js | 9 --------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/firesales.py b/firesales.py index 86778ca..181c338 100644 --- a/firesales.py +++ b/firesales.py @@ -49,6 +49,27 @@ functions = { } } }, + "finalizeListingTransfer": { + "name": "Finalize Listing Transfer", + "description": "Finalize listing transfer", + "type":"default", + "params": { + "domain": { + "type": "text", + "name": "Domain to list" + } + }, + "returns": { + "status": { + "type": "text", + "name": "Status" + }, + "txid": { + "type": "tx", + "name": "Transaction ID" + } + } + }, "list": { "name": "List", "description": "List a new domain", @@ -144,10 +165,8 @@ def startListingTransfer(params, authentication): stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - # Wait for the process to finish stdout, stderr = process.communicate() - print(f"STDOUT: {stdout}") print(f"STDERR: {stderr}") @@ -158,6 +177,35 @@ def startListingTransfer(params, authentication): txhash = txhash.split("\n")[0].rstrip('.') return {"status": "Success", "txid": txhash} +def finalizeListingTransfer(params, authentication): + domain = params["domain"] + # 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" + + # node node_modules/shakedex/bin/shakedex transfer-lock domain -n main -w wallet -a key -p ./data --httphost host + process = subprocess.Popen( + ["node", f"{path}/node_modules/shakedex/bin/shakedex", "finalize-lock", domain, "-n", "main", "-w", wallet, "-a", api_key, "-p", f"{path}/data", "--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}") + print(f"STDERR: {stderr}") + + 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"] diff --git a/shakedex/main.js b/shakedex/main.js index ad5e6dc..3b47374 100644 --- a/shakedex/main.js +++ b/shakedex/main.js @@ -276,11 +276,6 @@ async function transferLock(name) { async function finalizeLock(name) { const {db, context} = await setupCLI(); - await confirm( - `Your transfer of ${name} to the locking script will be finalized. ` + - 'This can be undone, but requires additional on-chain transactions. Do you wish to continue?', - ); - const nameState = await db.getOutboundNameState(name); if (nameState === null) { die(`Name ${name} not found.`); @@ -318,10 +313,6 @@ async function finalizeLock(name) { } async function transferLockCancel(name) { - await confirm( - `Your transfer of ${name} to the locking script will be cancelled. You will need to finalize this ` + - 'transfer to regain ownership of the name. Do you wish to continue?', - ); const {db, context} = await setupCLI();