feat: Added more inputs and outputs
All checks were successful
Build Docker / Build Image (push) Successful in 32s

This commit is contained in:
Nathan Woodburn 2024-02-04 15:08:24 +11:00
parent 5bb4e1bc4c
commit 441a0274ff
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
9 changed files with 217 additions and 4 deletions

View File

@ -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**

13
main.py
View File

@ -1085,6 +1085,19 @@ def plugin_function(plugin,function):
for input in inputs:
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:
return redirect("/plugin/" + plugin + "?error=An error occurred")

43
plugins.md Normal file
View File

@ -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

View File

@ -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}

View File

@ -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'<input class="form-control" type="number" name="{param}" />'
elif paramType == "checkbox":
html += f'<div class="form-check"><input id="{param}" class="form-check-input" type="checkbox" name="{param}" /><label class="form-check-label" for="{param}">{paramName}</label></div>'
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'</div>'
@ -236,8 +246,6 @@ def plugin_output(outputs, returns):
html = ''
for returnOutput in returns:
print(returns)
html += f'<div class="card" style="margin-top: 50px; margin-bottom: 50px;">'
html += f'<div class="card-body">'
html += f'<h4 class="card-title">{returns[returnOutput]["name"]}</h4>'
@ -251,6 +259,11 @@ def plugin_output(outputs, returns):
html += f'</ul>'
elif returns[returnOutput]["type"] == "text":
html += f'<p>{output}</p>'
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'</div>'

View File

@ -0,0 +1,40 @@
<div style="margin-top: 25px;">
<label class="form-label">{{paramName}}</label>
<input id="{{param}}" class="form-control" type="text" placeholder="Address or @domain" name="{{param}}" value="{{address}}" />
<span id="addressValid"></span>
<script>
function checkAddress(inputValue) {
// Make API request to "/checkaddress"
var apiUrl = '/checkaddress?address=' + encodeURIComponent(inputValue);
fetch(apiUrl)
.then(response => response.json())
.then(data => {
// Update the content of the span with the response data
var addressCheckSpan = document.getElementById('addressValid');
addressCheckSpan.textContent = data.result; // You can replace 'addressInfo' with the actual property you receive from the API
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
// Function to handle input field blur event
function handleBlur() {
var inputField = document.getElementById('{{param}}');
var inputValue = inputField.value;
// Check if the input value is not empty
if (inputValue.trim() !== '') {
checkAddress(inputValue);
} else {
var addressCheckSpan = document.getElementById('addressValid');
addressCheckSpan.textContent = 'Invalid address';
}
}
// Add a blur event listener to the input field
var inputField = document.getElementById('{{param}}');
inputField.addEventListener('blur', handleBlur);
</script>
</div>

View File

@ -0,0 +1,5 @@
<h4>TODO DNS LATER</h4>
<p>For a temporary work around edit any domains DNS and before pressing save</p>
<p>Copy the text in the url after ?dns=</p>
<label for="{{param}}">{{paramName}}</label>
<input class="form-control" type="text" name="{{param}}" />

View File

@ -0,0 +1,13 @@
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{{dns | safe}}
</tbody>
</table>
</div>

View File

@ -0,0 +1,4 @@
<span style="display: block;font-size: 12px;">TX: {{tx}}</span>
<span style="display: block;">Check your transaction on a block explorer</span>
<a class="card-link" href="https://niami.io/tx/{{tx}}" target="_blank">Niami</a>
<a class="card-link" href="https://3xpl.com/handshake/transaction/{{tx}}" target="_blank">3xpl</a>