From 856be7864ea61057f9aa437dcc7ef18de202e3b0 Mon Sep 17 00:00:00 2001 From: atticusofsparta Date: Sun, 24 Nov 2024 11:05:36 -0600 Subject: [PATCH] fix(registry notifications): send state notice to the ant registry instead of the user on transfer --- src/common/utils.lua | 4 ++-- test/registry.test.mjs | 2 ++ tools/constants.mjs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/utils.lua b/src/common/utils.lua index 7e8ef1f..d03149c 100644 --- a/src/common/utils.lua +++ b/src/common/utils.lua @@ -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 diff --git a/test/registry.test.mjs b/test/registry.test.mjs index 6709b11..c5b615a 100644 --- a/test/registry.test.mjs +++ b/test/registry.test.mjs @@ -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 () => { @@ -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); }); }); diff --git a/tools/constants.mjs b/tools/constants.mjs index 82080d6..f5bc9ba 100644 --- a/tools/constants.mjs +++ b/tools/constants.mjs @@ -7,6 +7,7 @@ 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: { @@ -14,7 +15,7 @@ const AO_LOADER_HANDLER_ENV = { 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: {