Skip to content

Commit

Permalink
feat(io): add handler that forwards a Release-Name notice to the pr…
Browse files Browse the repository at this point in the history
…ovided IO process id

Only the owner can invoket his handler
  • Loading branch information
dtfiedler committed Oct 14, 2024
1 parent c36c1b4 commit 96448e9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/common/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function ant.init()
Records = "Records",
State = "State",
Evolve = "Evolve",
-- IO Network Contract Handlers
ReleaseName = "Release-Name",
}

local TokenSpecActionMap = {
Expand Down Expand Up @@ -450,6 +452,37 @@ function ant.init()
SourceCodeTxId = srcCodeTxId
end
)

-- IO Network Contract Handlers
Handlers.add(camel("Release-Name"), utils.hasMatchingTag("Action", "Release-Name"), function(msg)
local assertHasPermission, permissionErr = pcall(utils.validateOwner, msg.From)
if assertHasPermission == false then
return ao.send({
Target = msg.From,
Action = "Invalid-Release-Name-Notice",
Data = permissionErr,
Error = "Release-Name-Error",
})
end

local name = string.lower(msg.Tags["Name"])
local ioProcess = msg.Tags["IO-Process-Id"]

-- send the release message to the provided IO Process Id
ao.send({
Target = ioProcess,
Action = "Release-Name-Notice",
Initiator = msg.From,
Name = name,
})

ao.send({
Target = msg.From,
Action = "Release-Name-Notice",
Initiator = msg.From,
Name = name,
})
end)
end

return ant

0 comments on commit 96448e9

Please sign in to comment.