Skip to content

Commit

Permalink
Merge pull request #40 from ar-io/fix-ant-registry-notification
Browse files Browse the repository at this point in the history
fix(registry notifications): send state notice to the ant registry in…
  • Loading branch information
atticusofsparta authored Nov 24, 2024
2 parents 258a7d2 + 856be78 commit 138f712
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/common/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ function utils.createHandler(tagName, tagValue, handler, position)

local hasNewOwner = Owner ~= prevOwner
local hasDifferentControllers = #utils.keys(Controllers) ~= #utils.keys(prevControllers)
if (hasNewOwner or hasDifferentControllers) and tagValue ~= "State" then
notices.notifyState(msg, msg.From)
if (hasNewOwner or hasDifferentControllers) and tagValue ~= "State" and AntRegistryId ~= nil then
notices.notifyState(msg, AntRegistryId)
end

return handlerRes
Expand Down
2 changes: 2 additions & 0 deletions test/registry.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AO_LOADER_HANDLER_ENV,
DEFAULT_HANDLE_OPTIONS,
STUB_ADDRESS,
STUB_ANT_REGISTRY_ID,
} from '../tools/constants.mjs';

describe('Registry Updates', async () => {
Expand Down Expand Up @@ -94,5 +95,6 @@ describe('Registry Updates', async () => {
);

assert(notifyMessage, 'State-Notice message not found');
assert.strictEqual(result.Messages[2]?.Target, STUB_ANT_REGISTRY_ID);
});
});
3 changes: 2 additions & 1 deletion tools/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ const __dirname = path.dirname(__filename);

const STUB_PROCESS_ID = 'process-id-'.padEnd(43, '1');
const STUB_ADDRESS = 'arweave-address-'.padEnd(43, '1');
export const STUB_ANT_REGISTRY_ID = 'ant-registry-'.padEnd(43, '1');
/* ao READ-ONLY Env Variables */
const AO_LOADER_HANDLER_ENV = {
Process: {
Id: STUB_PROCESS_ID,
Owner: STUB_ADDRESS,
Tags: [
{ name: 'Authority', value: 'XXXXXX' },
{ name: 'ANT-Registry-Id', value: 'ant-registry-'.padEnd(43, '1') },
{ name: 'ANT-Registry-Id', value: STUB_ANT_REGISTRY_ID },
],
},
Module: {
Expand Down

0 comments on commit 138f712

Please sign in to comment.