From 441a0274ff6d4df014d23459c35db4fbb2d123b6 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sun, 4 Feb 2024 15:08:24 +1100 Subject: [PATCH] feat: Added more inputs and outputs --- README.md | 24 +++++++++++ main.py | 15 ++++++- plugins.md | 43 ++++++++++++++++++++ plugins/example/main.py | 60 +++++++++++++++++++++++++++- render.py | 17 +++++++- templates/components/address.html | 40 +++++++++++++++++++ templates/components/dns-input.html | 5 +++ templates/components/dns-output.html | 13 ++++++ templates/components/tx.html | 4 ++ 9 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 plugins.md create mode 100644 templates/components/address.html create mode 100644 templates/components/dns-input.html create mode 100644 templates/components/dns-output.html create mode 100644 templates/components/tx.html diff --git a/README.md b/README.md index 2d2399f..d7bd7d5 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,30 @@ If you have HSD running on a different IP/container sudo docker run -p 5000:5000 -e hsd_api=yourapikeyhere -e hsd_ip=hsdcontainer git.woodburn.au/nathanwoodburn/firewallet:latest ``` +## Features +- Basic wallet functionality + - Send HNS + - Receive HNS + - Have multiple wallets + - View transactions + - View balance + - View wallet domains +- Domain management + - Transfer domains + - DNS Editor + - Renew domains +- Auctions + - Send open + - Send bid + - Send reveal + - Send redeem +- Download a list of all domains +- Resend all pending transactions +- Rescan +- Zap pending transactions +- View xPub +- Custom plugin support + ## Themes Set a theme in the .env file **Available themes** diff --git a/main.py b/main.py index 84b6fc3..36fbdbe 100644 --- a/main.py +++ b/main.py @@ -1083,7 +1083,20 @@ def plugin_function(plugin,function): inputs = module.listFunctions()[function]["params"] request_data = {} for input in inputs: - request_data[input] = request.form.get(input) + request_data[input] = request.form.get(input) + + if inputs[input]['type'] == "address": + # Handle hip2 + address_check = account_module.check_address(request_data[input],True,True) + if not address_check: + return redirect("/plugin/" + plugin + "?error=Invalid address") + request_data[input] = address_check + elif inputs[input]['type'] == "dns": + # Handle URL encoding of DNS + request_data[input] = urllib.parse.unquote(request_data[input]) + + + response = module.runFunction(function,request_data,request.cookies.get("account")) if not response: diff --git a/plugins.md b/plugins.md new file mode 100644 index 0000000..6c05ffe --- /dev/null +++ b/plugins.md @@ -0,0 +1,43 @@ +# Plugins + +## Inputs + +### Plain Text +Type: `text` + +### Long Text +Type: `longText` + +### Number +Type: `number` + + +### Checkbox +Type: `checkbox` + +### Address +Type: `address` +This will handle hip2 resolution for you so the function will always receive a valid address + +### DNS +Type: `dns` +This isn't done yet but use it over text as it includes parsing + + + +## Outputs +### Plain Text +Type: `text` + + +### List +Type: `list` +This is a list if text items (or HTML items) + +### Transaction hash +Type: `tx` +This will display the hash and links to explorers + +### DNS records +Type: `dns` +This will display DNS in a table format diff --git a/plugins/example/main.py b/plugins/example/main.py index 0d22500..d9bda51 100644 --- a/plugins/example/main.py +++ b/plugins/example/main.py @@ -8,7 +8,7 @@ functions = { "description": "Check if domains in file are owned by the wallet", "params": { "domains": { - "name":"File of domains to check", + "name":"List of domains to check", "type":"longText" } }, @@ -36,6 +36,54 @@ functions = { "type": "list" } } + }, + "transfer":{ + "name": "Bulk Transfer Domains", + "description": "Transfer domains to another wallet", + "params": { + "address": { + "name":"Address to transfer to", + "type":"address" + }, + "domains": { + "name":"List of domains to transfer", + "type":"longText" + } + }, + "returns": { + "hash": { + "name": "Hash of the transaction", + "type": "tx" + }, + "address":{ + "name": "Address of the new owner", + "type": "text" + } + } + }, + "dns":{ + "name": "Set DNS for Domains", + "description": "Set DNS for domains", + "params": { + "domains": { + "name":"List of domains to set DNS for", + "type":"longText" + }, + "dns": { + "name":"DNS", + "type":"dns" + } + }, + "returns": { + "hash": { + "name": "Hash of the transaction", + "type": "tx" + }, + "dns":{ + "name": "DNS", + "type": "dns" + } + } } } @@ -47,6 +95,10 @@ def runFunction(function, params, authentication): return check(params['domains'], authentication) elif function == "search": return search(params['search'], authentication) + elif function == "transfer": + return transfer(params['address'], params['domains'], authentication) + elif function == "dns": + return dns(params['domains'],params['dns'],authentication) else: return "Function not found" @@ -74,3 +126,9 @@ def search(search, authentication): return {"domains": domains} + +def transfer(address, domains, authentication): + return {"hash":"f921ffe1bb01884bf515a8079073ee9381cb93a56b486694eda2cce0719f27c0","address":address} + +def dns(domains,dns,authentication): + return {"hash":"f921ffe1bb01884bf515a8079073ee9381cb93a56b486694eda2cce0719f27c0","dns":dns} \ No newline at end of file diff --git a/render.py b/render.py index b667632..98d5a91 100644 --- a/render.py +++ b/render.py @@ -1,6 +1,7 @@ import datetime import json import urllib.parse +from flask import render_template def domains(domains): html = '' @@ -218,6 +219,15 @@ def plugin_functions(functions, pluginName): html += f'' elif paramType == "checkbox": html += f'
' + elif paramType == "address": + # render components/address.html + address = render_template('components/address.html', paramName=paramName, param=param) + html += address + elif paramType == "dns": + html += render_template('components/dns-input.html', paramName=paramName, param=param) + + + html += f'' @@ -236,8 +246,6 @@ def plugin_output(outputs, returns): html = '' for returnOutput in returns: - print(returns) - html += f'
' html += f'
' html += f'

{returns[returnOutput]["name"]}

' @@ -251,6 +259,11 @@ def plugin_output(outputs, returns): html += f'' elif returns[returnOutput]["type"] == "text": html += f'

{output}

' + elif returns[returnOutput]["type"] == "tx": + html += render_template('components/tx.html', tx=output) + elif returns[returnOutput]["type"] == "dns": + output = json.loads(output) + html += render_template('components/dns-output.html', dns=dns(output)) html += f'
' diff --git a/templates/components/address.html b/templates/components/address.html new file mode 100644 index 0000000..598e363 --- /dev/null +++ b/templates/components/address.html @@ -0,0 +1,40 @@ +
+ + + + +
\ No newline at end of file diff --git a/templates/components/dns-input.html b/templates/components/dns-input.html new file mode 100644 index 0000000..690ea4e --- /dev/null +++ b/templates/components/dns-input.html @@ -0,0 +1,5 @@ +

TODO DNS LATER

+

For a temporary work around edit any domains DNS and before pressing save

+

Copy the text in the url after ?dns=

+ + \ No newline at end of file diff --git a/templates/components/dns-output.html b/templates/components/dns-output.html new file mode 100644 index 0000000..3c21c02 --- /dev/null +++ b/templates/components/dns-output.html @@ -0,0 +1,13 @@ +
+ + + + + + + + + {{dns | safe}} + +
+
\ No newline at end of file diff --git a/templates/components/tx.html b/templates/components/tx.html new file mode 100644 index 0000000..c1e0c1e --- /dev/null +++ b/templates/components/tx.html @@ -0,0 +1,4 @@ +TX: {{tx}} +Check your transaction on a block explorer +Niami +3xpl \ No newline at end of file