115 lines
3.3 KiB
Python
115 lines
3.3 KiB
Python
|
import json
|
||
|
import account
|
||
|
import requests
|
||
|
|
||
|
# Plugin Data
|
||
|
info = {
|
||
|
"name": "FireSales",
|
||
|
"description": "Manage FireSales listings",
|
||
|
"version": "1.0",
|
||
|
"author": "Nathan.Woodburn/"
|
||
|
}
|
||
|
|
||
|
# Functions
|
||
|
functions = {
|
||
|
"list": {
|
||
|
"name": "List",
|
||
|
"description": "List a new domain",
|
||
|
"type":"default",
|
||
|
"params": {
|
||
|
"domain": {
|
||
|
"type": "text",
|
||
|
"name": "Domain to list"
|
||
|
},
|
||
|
"price": {
|
||
|
"type": "number",
|
||
|
"name": "Price of the domain"
|
||
|
},
|
||
|
"contact": {
|
||
|
"type": "text",
|
||
|
"name": "Contact info"
|
||
|
},
|
||
|
"description": {
|
||
|
"type": "longText",
|
||
|
"name": "Listing description"
|
||
|
}
|
||
|
},
|
||
|
"returns": {
|
||
|
"status": {
|
||
|
"type": "text",
|
||
|
"name": "Status of the listing"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"delete": {
|
||
|
"name": "Delete",
|
||
|
"description": "Delete a listing",
|
||
|
"type":"default",
|
||
|
"params": {
|
||
|
"domain": {
|
||
|
"type": "text",
|
||
|
"name": "Domain to list"
|
||
|
}
|
||
|
},
|
||
|
"returns": {
|
||
|
"status": {
|
||
|
"type": "text",
|
||
|
"name": "Status"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
def list(params, authentication):
|
||
|
domain = params["domain"]
|
||
|
price = params["price"]
|
||
|
contact = params["contact"]
|
||
|
description = params["description"]
|
||
|
|
||
|
# Generate message
|
||
|
message = requests.get("https://sales.firewallet.au/api/v1/listing-message?domain=" + domain + "&price=" + str(price) + "&contact=" + contact + "&description=" + description)
|
||
|
message = message.json()
|
||
|
|
||
|
if message['success'] != True:
|
||
|
return {"status": "Error: " + message['error']}
|
||
|
|
||
|
# Sign message
|
||
|
signature = account.signMessage(authentication,domain,message['message'])
|
||
|
|
||
|
if signature['error'] != None:
|
||
|
return {"status": "Error: " + signature['error']}
|
||
|
|
||
|
# Send message
|
||
|
response = requests.post("https://sales.firewallet.au/api/v1/list",json=
|
||
|
{
|
||
|
"domain": domain,
|
||
|
"price": price,
|
||
|
"contact": contact,
|
||
|
"description": description,
|
||
|
"signature": signature['result']
|
||
|
})
|
||
|
|
||
|
response = response.json()
|
||
|
if response['success'] != True:
|
||
|
return {"status": "Error: " + response['error']}
|
||
|
|
||
|
|
||
|
return {"status": "Success<br><a href='https://sales.firewallet.au' target='_blank'>View listing</a>"}
|
||
|
|
||
|
def delete(params, authentication):
|
||
|
domain = params["domain"]
|
||
|
signature = account.signMessage(authentication,domain,f'FS: {domain}')
|
||
|
if signature['error'] != None:
|
||
|
return {"status": "Error: " + signature['error']}
|
||
|
|
||
|
response = requests.post("https://sales.firewallet.au/api/v1/delete",json=
|
||
|
{
|
||
|
"domain": domain,
|
||
|
"signature": signature['result']
|
||
|
})
|
||
|
response = response.json()
|
||
|
if response['success'] != True:
|
||
|
return {"status": "Error: " + response['error']}
|
||
|
|
||
|
|
||
|
return {"status": "Success"}
|