Skip to content

Commit

Permalink
chore(handlers): add handlers for setings (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored Jun 25, 2024
2 parents b5bbede + fd40bb1 commit 48b3b79
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ local ActionMap = {
Balance = "Balance",
Balances = "Balances",
DemandFactor = "Demand-Factor",
DemandFactorSettings = "Demand-Factor-Settings",
-- EPOCH READ APIS
Epochs = "Epochs",
Epoch = "Epoch",
EpochSettings = "Epoch-Settings",
PrescribedObservers = "Epoch-Prescribed-Observers",
PrescribedNames = "Epoch-Prescribed-Names",
Observations = "Epoch-Observations",
Expand All @@ -55,6 +57,7 @@ local ActionMap = {
-- GATEWAY REGISTRY READ APIS
Gateway = "Gateway",
Gateways = "Gateways",
GatewayRegistrySettings = "Gateway-Registry-Settings",
-- writes
CreateVault = "Create-Vault",
VaultedTransfer = "Vaulted-Transfer",
Expand Down Expand Up @@ -789,7 +792,7 @@ Handlers.add(ActionMap.SaveObservations, utils.hasMatchingTag("Action", ActionMa
end
end)

Handlers.add("Epoch-Settings", utils.hasMatchingTag("Action", "Epoch-Settings"), function(msg)
Handlers.add(ActionMap.EpochSettings, utils.hasMatchingTag("Action", ActionMap.EpochSettings), function(msg)
local epochSettings = epochs.getSettings()
ao.send({
Target = msg.From,
Expand All @@ -798,6 +801,32 @@ Handlers.add("Epoch-Settings", utils.hasMatchingTag("Action", "Epoch-Settings"),
})
end)

Handlers.add(
ActionMap.DemandFactorSettings,
utils.hasMatchingTag("Action", ActionMap.DemandFactorSettings),
function(msg)
local demandFactorSettings = demand.getSettings()
ao.send({
Target = msg.From,
Action = "Demand-Factor-Settings-Notice",
Data = json.encode(demandFactorSettings),
})
end
)

Handlers.add(
ActionMap.GatewayRegistrySettings,
utils.hasMatchingTag("Action", ActionMap.GatewayRegistrySettings),
function(msg)
local gatewayRegistrySettings = gar.getSettings()
ao.send({
Target = msg.From,
Action = "Gateway-Registry-Settings-Notice",
Data = json.encode(gatewayRegistrySettings),
})
end
)

-- TICK HANDLER
Handlers.add("tick", utils.hasMatchingTag("Action", "Tick"), function(msg)
-- assert this is a write interaction and we have a timetsamp
Expand Down

0 comments on commit 48b3b79

Please sign in to comment.