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