Skip to content

Commit

Permalink
fix(registry notifications): send state notice to the ant registry in…
Browse files Browse the repository at this point in the history
…stead of the user on transfer
  • Loading branch information
atticusofsparta committed Nov 24, 2024
1 parent 258a7d2 commit 856be78
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 856be78

Please sign in to comment.