milo shop updates
This commit is contained in:
@@ -140,7 +140,7 @@ end
|
||||
function page.grid:getDisplayValues(row)
|
||||
row = Util.shallowCopy(row)
|
||||
local x = row.recipient
|
||||
row.from = x:match('(%w+)@') or x
|
||||
row.from = x and x:match('(%w+)@') or row.from
|
||||
return row
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ local wizardPage = UI.WizardPage {
|
||||
},
|
||||
[2] = UI.TextEntry {
|
||||
formLabel = 'Password', formKey = 'password',
|
||||
shadowText = 'password',
|
||||
shadowText = 'password or private key',
|
||||
limit = 256,
|
||||
required = true,
|
||||
help = 'Krist wallet password',
|
||||
@@ -38,7 +38,12 @@ local wizardPage = UI.WizardPage {
|
||||
help = 'Password is in private key format',
|
||||
limit = 64,
|
||||
},
|
||||
[5] = UI.Chooser {
|
||||
[5] = UI.Checkbox {
|
||||
formLabel = 'Single shop', formKey = 'refundInvalid',
|
||||
help = 'Only this shop using this domain',
|
||||
limit = 64,
|
||||
},
|
||||
[6] = UI.Chooser {
|
||||
width = 9,
|
||||
formLabel = 'Font Size', formKey = 'textScale',
|
||||
nochoice = 'Small',
|
||||
|
||||
@@ -18,7 +18,7 @@ local function startShop(node)
|
||||
if shopTab then
|
||||
multishell.terminate(shopTab)
|
||||
end
|
||||
shopTab = shell.openTab('/packages/swshop/swshop.lua', node.domain, node.password, node.isPrivateKey and 'true')
|
||||
shopTab = shell.openTab('/packages/swshop/swshop.lua', node.name)
|
||||
end
|
||||
|
||||
-- node has been reconfigured
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local Util = require('opus.util')
|
||||
local Config = require('opus.config')
|
||||
local Util = require('opus.util')
|
||||
|
||||
local fs = _G.fs
|
||||
local os = _G.os
|
||||
@@ -19,6 +20,7 @@ local rs = _G.rs
|
||||
local textutils = _G.textutils
|
||||
|
||||
local chat = device['plethora:chat']
|
||||
local storage = Config.load('storage')
|
||||
|
||||
rs.setOutput('top', false)
|
||||
|
||||
@@ -26,14 +28,9 @@ r.init(jua)
|
||||
w.init(jua)
|
||||
k.init(jua, json, w, r)
|
||||
|
||||
local function Syntax()
|
||||
error('Syntax: swshop [domain] [password | privateKey] [isPrivateKey]')
|
||||
end
|
||||
|
||||
local args = { ... }
|
||||
local domain = args[1] or Syntax()
|
||||
local password = args[2] or Syntax()
|
||||
local privatekey = args[3] and args[2] or k.toKristWalletFormat(password)
|
||||
local node = ({ ... })[1] or error('Node name is required')
|
||||
local config = storage[node]
|
||||
local privatekey = config.isPrivateKey and config.password or k.toKristWalletFormat(config.password)
|
||||
local address = k.makev2address(privatekey)
|
||||
|
||||
jua.on("terminate", function()
|
||||
@@ -72,7 +69,7 @@ local function handleTransaction(transaction)
|
||||
if to ~= address or not transaction.metadata then return end
|
||||
|
||||
local metadata = k.parseMeta(transaction.metadata)
|
||||
if not metadata.domain or metadata.domain ~= domain then return end
|
||||
if not metadata.domain or metadata.domain ~= config.domain then return end
|
||||
|
||||
local recipient = metadata.meta and (metadata.meta["return"] or from) or from
|
||||
print("Handling transaction from ", recipient)
|
||||
@@ -98,8 +95,10 @@ local function handleTransaction(transaction)
|
||||
if not t.itemId or not t.price then
|
||||
print('invalid item')
|
||||
logTransaction(t, { reason = 'invalid item' })
|
||||
--return refundTransaction(value, "error=Item specified is not valid")
|
||||
return -- there could be multiple stores...
|
||||
if config.refundInvalid then
|
||||
return refundTransaction(value, "error=Item specified is not valid")
|
||||
end
|
||||
return -- multiple store setup
|
||||
end
|
||||
|
||||
if value < t.price then
|
||||
@@ -141,7 +140,7 @@ local function handleTransaction(transaction)
|
||||
end
|
||||
|
||||
local function connect()
|
||||
print('opening store for: ' .. domain)
|
||||
print('opening store for: ' .. config.domain)
|
||||
print('using address: ' .. address)
|
||||
|
||||
local success, ws = await(k.connect, privatekey)
|
||||
|
||||
Reference in New Issue
Block a user