diff --git a/changelogs/2024-09-30-rEoJ5DtkpLZdMUSzxgV1zpahVTUtV8BVloPXDWKuqNA.md b/changelogs/2024-09-30-pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30.md similarity index 100% rename from changelogs/2024-09-30-rEoJ5DtkpLZdMUSzxgV1zpahVTUtV8BVloPXDWKuqNA.md rename to changelogs/2024-09-30-pOh2yupSaQCrLI_-ah8tVTiusUdVNTxxeWTQQHNdf30.md diff --git a/src/common/main.lua b/src/common/main.lua index d354859..825dfc2 100644 --- a/src/common/main.lua +++ b/src/common/main.lua @@ -247,7 +247,7 @@ function ant.init() end local tags = msg.Tags local name, transactionId, ttlSeconds = - tags["Sub-Domain"], tags["Transaction-Id"], tonumber(tags["TTL-Seconds"]) + string.lower(tags["Sub-Domain"]), tags["Transaction-Id"], tonumber(tags["TTL-Seconds"]) local setRecordStatus, setRecordResult = pcall(records.setRecord, name, transactionId, ttlSeconds) if not setRecordStatus then @@ -269,7 +269,8 @@ function ant.init() if assertHasPermission == false then return ao.send({ Target = msg.From, Action = "Invalid-Remove-Record-Notice", Data = permissionErr }) end - local removeRecordStatus, removeRecordResult = pcall(records.removeRecord, msg.Tags["Sub-Domain"]) + local name = string.lower(msg.Tags["Sub-Domain"]) + local removeRecordStatus, removeRecordResult = pcall(records.removeRecord, name) if not removeRecordStatus then ao.send({ Target = msg.From, @@ -284,7 +285,8 @@ function ant.init() end) Handlers.add(camel(ActionMap.Record), utils.hasMatchingTag("Action", ActionMap.Record), function(msg) - local nameStatus, nameRes = pcall(records.getRecord, msg.Tags["Sub-Domain"]) + local name = string.lower(msg.Tags["Sub-Domain"]) + local nameStatus, nameRes = pcall(records.getRecord, name) if not nameStatus then ao.send({ Target = msg.From, @@ -299,7 +301,7 @@ function ant.init() local recordNotice = { Target = msg.From, Action = "Record-Notice", - Name = msg.Tags["Sub-Domain"], + Name = name, Data = nameRes, } @@ -414,36 +416,40 @@ function ant.init() utils.notices.notifyState(msg, msg.From) end) - Handlers.prepend(camel(ActionMap.Evolve),Handlers.utils.continue(utils.hasMatchingTag("Action", "Eval")), function(msg) - local srcCodeTxId = msg.Tags["Source-Code-TX-ID"] - if not srcCodeTxId then - return - end + Handlers.prepend( + camel(ActionMap.Evolve), + Handlers.utils.continue(utils.hasMatchingTag("Action", "Eval")), + function(msg) + local srcCodeTxId = msg.Tags["Source-Code-TX-ID"] + if not srcCodeTxId then + return + end - if Owner ~= msg.From then - ao.send({ - Target = msg.From, - Action = "Invalid-Evolve-Notice", - Error = "Evolve-Error", - ["Message-Id"] = msg.Id, - Data = "Only the Owner [" .. Owner or "no owner set" .. "] can call Evolve", - }) - return - end + if Owner ~= msg.From then + ao.send({ + Target = msg.From, + Action = "Invalid-Evolve-Notice", + Error = "Evolve-Error", + ["Message-Id"] = msg.Id, + Data = "Only the Owner [" .. Owner or "no owner set" .. "] can call Evolve", + }) + return + end - local srcCodeTxIdStatus, srcCodeTxIdResult = pcall(utils.validateArweaveId, srcCodeTxId) - if srcCodeTxIdStatus and not srcCodeTxIdStatus then - ao.send({ - Target = msg.From, - Action = "Invalid-Evolve-Notice", - Error = "Evolve-Error", - ["Message-Id"] = msg.Id, - Data = "Source-Code-TX-ID is required", - }) - return + local srcCodeTxIdStatus, srcCodeTxIdResult = pcall(utils.validateArweaveId, srcCodeTxId) + if srcCodeTxIdStatus and not srcCodeTxIdStatus then + ao.send({ + Target = msg.From, + Action = "Invalid-Evolve-Notice", + Error = "Evolve-Error", + ["Message-Id"] = msg.Id, + Data = "Source-Code-TX-ID is required", + }) + return + end + SourceCodeTxId = srcCodeTxId end - SourceCodeTxId = srcCodeTxId - end) + ) end return ant diff --git a/src/common/records.lua b/src/common/records.lua index 72008af..435f09a 100644 --- a/src/common/records.lua +++ b/src/common/records.lua @@ -18,7 +18,7 @@ function records.setRecord(name, transactionId, ttlSeconds) error("Max records limit of 10,000 reached, please delete some records to make space") end - Records[string.lower(name)] = { + Records[name] = { transactionId = transactionId, ttlSeconds = ttlSeconds, } @@ -32,7 +32,7 @@ end function records.removeRecord(name) local nameValidity, nameValidityError = pcall(utils.validateUndername, name) assert(nameValidity ~= false, nameValidityError) - Records[string.lower(name)] = nil + Records[name] = nil return json.encode({ message = "Record deleted" }) end @@ -40,7 +40,7 @@ function records.getRecord(name) utils.validateUndername(name) assert(Records[name] ~= nil, "Record does not exist") - return json.encode(Records[string.lower(name)]) + return json.encode(Records[name]) end function records.getRecords()