@@ -4,6 +4,7 @@ import { resolve } from 'path';
44import { diffSnapshots } from '../protocol-diff' ;
55import { diff , isChange , hasChanges } from '../diff' ;
66import { formatValue , type FormatterContext } from '../formatters' ;
7+ import { renderLogsSection } from '../sections/logs' ;
78
89const before = JSON . parse (
910 readFileSync ( resolve ( __dirname , '../../../reports/default_before.json' ) , 'utf-8' )
@@ -1811,3 +1812,299 @@ describe('diffSnapshots', () => {
18111812 ` ) ;
18121813 } ) ;
18131814} ) ;
1815+
1816+ // Topic hashes for IAgentConfigurator events (keccak256 of signature)
1817+ const AGENT_REGISTERED = '0x0d063c6022bff16d09991a9f91882ffa112f5fb2529136f65eb4c77bbd047e43' ;
1818+ const AGENT_ADDRESS_SET = '0x49ae5a2f9400fc9a6874ec8e69cf4dcb82883d824c93388271dca846098e8bfe' ;
1819+ const AGENT_ADMIN_SET = '0xd61d2421c5bb057269066046ce93b137bb1df44332310530dec71fca964485b4' ;
1820+ const AGENT_ENABLED_SET = '0x2d687e7e18d7d5e9fccf01f905bb15b7a6521a83eea31080b430fe99a82c3d82' ;
1821+ const AGENT_PERMISSIONED_STATUS_SET =
1822+ '0xfb39cc5d87e3067ba835813b35ed2181005ece073d76c7cbbdb4779b7a6446ed' ;
1823+ const MARKETS_FROM_AGENT_ENABLED =
1824+ '0x50cdda6e37491918e4a5f7941910c68aa643a311610f9dd213f6d2955a246c0a' ;
1825+ const EXPIRATION_PERIOD_SET = '0x6a8e901a014ecaeac1bf64b55f5cf50d9988250d9f33a56f9b694971592ade43' ;
1826+ const MINIMUM_DELAY_SET = '0x272ec2b5975364e003ffa08930bbafc77472bc7fc2c2b078bf9a09997de6632f' ;
1827+ const AGENT_CONTEXT_SET = '0x62628638a1817b830bc3c14382a2f4df99a461cee4408e978bb6aaaab6a1b036' ;
1828+ const ALLOWED_MARKET_ADDED = '0x2fc0d54cb5ab2406eb24b175bf09b6fff1268acd21ac14c7e3422146a60bb37e' ;
1829+ const ALLOWED_MARKET_REMOVED = '0x65bb60f6360137104c7b1d036ac5e53273c9da5662306bae223c1f8942a01bcd' ;
1830+ const RESTRICTED_MARKET_ADDED = '0xa32f8d38bd6f79b28a99f671eafa0d6c7d9ed79a92c6fbf9433124f335b39b84' ;
1831+ const RESTRICTED_MARKET_REMOVED =
1832+ '0x9fdc8893bd7bb12c1431f72399b7caf70867c7c68b1da755533287dd68c4f1dc' ;
1833+ const PERMISSIONED_SENDER_ADDED =
1834+ '0x0040935b7c4188ff3d4b804d38d3008c9cd5fb141b3b3453904a76cfae835d54' ;
1835+ const PERMISSIONED_SENDER_REMOVED =
1836+ '0xefd1a368b568dd579ddf460ad65587bdc6ed7797375b82f559c40901f1f3ad36' ;
1837+ const MAX_BATCH_SIZE_SET = '0x41122ae347d086d4eca255208d465d964ae84c71bc0dd28e1d2be5861d966e0b' ;
1838+ const UPDATE_INJECTED = '0x3b5f9b036a0fa1bd3e6bda204322458c0667dcc37bbcc038d0903e57e8a058be' ;
1839+
1840+ // Padded values reused across tests
1841+ const AGENT_ID_0 = '0x0000000000000000000000000000000000000000000000000000000000000000' ;
1842+ const AGENT_ID_1 = '0x0000000000000000000000000000000000000000000000000000000000000001' ;
1843+ const RISK_ORACLE = '0x0000000000000000000000002e4d168044b4532b4182dc00434498082e13e0bf' ;
1844+ const AGENT_ADDRESS = '0x000000000000000000000000a2430ab7ac492d70c2bd4ea83feaf6f8af3e165c' ;
1845+ const ADMIN_ADDRESS = '0x0000000000000000000000001df462e2712496373a347f8ad10802a5e95f053d' ;
1846+ const MARKET_ADDRESS = '0x0000000000000000000000004200000000000000000000000000000000000006' ;
1847+ const SENDER_ADDRESS = '0x000000000000000000000000050e8fc96dd6c1ba971e3633c0b340680043661e' ;
1848+ const BOOL_TRUE = '0x0000000000000000000000000000000000000000000000000000000000000001' ;
1849+ const BOOL_FALSE = '0x0000000000000000000000000000000000000000000000000000000000000000' ;
1850+ const VALUE_1000 = '0x00000000000000000000000000000000000000000000000000000000000003e8' ;
1851+ const VALUE_255 = '0x00000000000000000000000000000000000000000000000000000000000000ff' ;
1852+ const UPDATE_TYPE_HASH = '0xa2a23724fc9bbd60f7d28de9b7010ef0fc522d17af97a644153b859501877e51' ;
1853+ const CONTEXT_HASH = '0x20fb6752da6295cc7038ee3d686e0cc48f953d7463d6801aa3902ce2e84811f0' ;
1854+
1855+ const AGENT_HUB = '0x17781Ba226b359e5C1E1ee5ac9E28Ec5b84fd039' ;
1856+ // Ink chain id
1857+ const INK_CHAIN_ID = 57073 ;
1858+
1859+ describe ( 'renderLogsSection - IAgentConfigurator events' , ( ) => {
1860+ it ( 'decodes AgentRegistered' , async ( ) => {
1861+ const result = await renderLogsSection (
1862+ [
1863+ {
1864+ emitter : AGENT_HUB ,
1865+ topics : [ AGENT_REGISTERED , AGENT_ID_0 , RISK_ORACLE , UPDATE_TYPE_HASH ] ,
1866+ data : '0x' ,
1867+ } ,
1868+ ] ,
1869+ INK_CHAIN_ID
1870+ ) ;
1871+ expect ( result ) . toContain ( 'AgentRegistered(' ) ;
1872+ expect ( result ) . not . toContain ( 'topics:' ) ;
1873+ } ) ;
1874+
1875+ it ( 'decodes AgentAddressSet' , async ( ) => {
1876+ const result = await renderLogsSection (
1877+ [ { emitter : AGENT_HUB , topics : [ AGENT_ADDRESS_SET , AGENT_ID_0 , AGENT_ADDRESS ] , data : '0x' } ] ,
1878+ INK_CHAIN_ID
1879+ ) ;
1880+ expect ( result ) . toContain ( 'AgentAddressSet(' ) ;
1881+ expect ( result ) . not . toContain ( 'topics:' ) ;
1882+ } ) ;
1883+
1884+ it ( 'decodes AgentAdminSet' , async ( ) => {
1885+ const result = await renderLogsSection (
1886+ [ { emitter : AGENT_HUB , topics : [ AGENT_ADMIN_SET , AGENT_ID_0 , ADMIN_ADDRESS ] , data : '0x' } ] ,
1887+ INK_CHAIN_ID
1888+ ) ;
1889+ expect ( result ) . toContain ( 'AgentAdminSet(' ) ;
1890+ expect ( result ) . not . toContain ( 'topics:' ) ;
1891+ } ) ;
1892+
1893+ it ( 'decodes AgentEnabledSet' , async ( ) => {
1894+ const result = await renderLogsSection (
1895+ [ { emitter : AGENT_HUB , topics : [ AGENT_ENABLED_SET , AGENT_ID_0 , BOOL_TRUE ] , data : '0x' } ] ,
1896+ INK_CHAIN_ID
1897+ ) ;
1898+ expect ( result ) . toContain ( 'AgentEnabledSet(' ) ;
1899+ expect ( result ) . not . toContain ( 'topics:' ) ;
1900+ } ) ;
1901+
1902+ it ( 'decodes AgentPermissionedStatusSet' , async ( ) => {
1903+ const result = await renderLogsSection (
1904+ [
1905+ {
1906+ emitter : AGENT_HUB ,
1907+ topics : [ AGENT_PERMISSIONED_STATUS_SET , AGENT_ID_0 , BOOL_FALSE ] ,
1908+ data : '0x' ,
1909+ } ,
1910+ ] ,
1911+ INK_CHAIN_ID
1912+ ) ;
1913+ expect ( result ) . toContain ( 'AgentPermissionedStatusSet(' ) ;
1914+ expect ( result ) . not . toContain ( 'topics:' ) ;
1915+ } ) ;
1916+
1917+ it ( 'decodes MarketsFromAgentEnabled' , async ( ) => {
1918+ const result = await renderLogsSection (
1919+ [
1920+ {
1921+ emitter : AGENT_HUB ,
1922+ topics : [ MARKETS_FROM_AGENT_ENABLED , AGENT_ID_0 , BOOL_TRUE ] ,
1923+ data : '0x' ,
1924+ } ,
1925+ ] ,
1926+ INK_CHAIN_ID
1927+ ) ;
1928+ expect ( result ) . toContain ( 'MarketsFromAgentEnabled(' ) ;
1929+ expect ( result ) . not . toContain ( 'topics:' ) ;
1930+ } ) ;
1931+
1932+ it ( 'decodes ExpirationPeriodSet' , async ( ) => {
1933+ const result = await renderLogsSection (
1934+ [
1935+ {
1936+ emitter : AGENT_HUB ,
1937+ topics : [ EXPIRATION_PERIOD_SET , AGENT_ID_0 , VALUE_1000 ] ,
1938+ data : '0x' ,
1939+ } ,
1940+ ] ,
1941+ INK_CHAIN_ID
1942+ ) ;
1943+ expect ( result ) . toContain ( 'ExpirationPeriodSet(' ) ;
1944+ expect ( result ) . not . toContain ( 'topics:' ) ;
1945+ } ) ;
1946+
1947+ it ( 'decodes MinimumDelaySet' , async ( ) => {
1948+ const result = await renderLogsSection (
1949+ [ { emitter : AGENT_HUB , topics : [ MINIMUM_DELAY_SET , AGENT_ID_0 , VALUE_1000 ] , data : '0x' } ] ,
1950+ INK_CHAIN_ID
1951+ ) ;
1952+ expect ( result ) . toContain ( 'MinimumDelaySet(' ) ;
1953+ expect ( result ) . not . toContain ( 'topics:' ) ;
1954+ } ) ;
1955+
1956+ it ( 'decodes AgentContextSet' , async ( ) => {
1957+ const result = await renderLogsSection (
1958+ [ { emitter : AGENT_HUB , topics : [ AGENT_CONTEXT_SET , AGENT_ID_0 , CONTEXT_HASH ] , data : '0x' } ] ,
1959+ INK_CHAIN_ID
1960+ ) ;
1961+ expect ( result ) . toContain ( 'AgentContextSet(' ) ;
1962+ expect ( result ) . not . toContain ( 'topics:' ) ;
1963+ } ) ;
1964+
1965+ it ( 'decodes AllowedMarketAdded' , async ( ) => {
1966+ const result = await renderLogsSection (
1967+ [
1968+ {
1969+ emitter : AGENT_HUB ,
1970+ topics : [ ALLOWED_MARKET_ADDED , AGENT_ID_0 , MARKET_ADDRESS ] ,
1971+ data : '0x' ,
1972+ } ,
1973+ ] ,
1974+ INK_CHAIN_ID
1975+ ) ;
1976+ expect ( result ) . toContain ( 'AllowedMarketAdded(' ) ;
1977+ expect ( result ) . not . toContain ( 'topics:' ) ;
1978+ } ) ;
1979+
1980+ it ( 'decodes AllowedMarketRemoved' , async ( ) => {
1981+ const result = await renderLogsSection (
1982+ [
1983+ {
1984+ emitter : AGENT_HUB ,
1985+ topics : [ ALLOWED_MARKET_REMOVED , AGENT_ID_0 , MARKET_ADDRESS ] ,
1986+ data : '0x' ,
1987+ } ,
1988+ ] ,
1989+ INK_CHAIN_ID
1990+ ) ;
1991+ expect ( result ) . toContain ( 'AllowedMarketRemoved(' ) ;
1992+ expect ( result ) . not . toContain ( 'topics:' ) ;
1993+ } ) ;
1994+
1995+ it ( 'decodes RestrictedMarketAdded' , async ( ) => {
1996+ const result = await renderLogsSection (
1997+ [
1998+ {
1999+ emitter : AGENT_HUB ,
2000+ topics : [ RESTRICTED_MARKET_ADDED , AGENT_ID_0 , MARKET_ADDRESS ] ,
2001+ data : '0x' ,
2002+ } ,
2003+ ] ,
2004+ INK_CHAIN_ID
2005+ ) ;
2006+ expect ( result ) . toContain ( 'RestrictedMarketAdded(' ) ;
2007+ expect ( result ) . not . toContain ( 'topics:' ) ;
2008+ } ) ;
2009+
2010+ it ( 'decodes RestrictedMarketRemoved' , async ( ) => {
2011+ const result = await renderLogsSection (
2012+ [
2013+ {
2014+ emitter : AGENT_HUB ,
2015+ topics : [ RESTRICTED_MARKET_REMOVED , AGENT_ID_0 , MARKET_ADDRESS ] ,
2016+ data : '0x' ,
2017+ } ,
2018+ ] ,
2019+ INK_CHAIN_ID
2020+ ) ;
2021+ expect ( result ) . toContain ( 'RestrictedMarketRemoved(' ) ;
2022+ expect ( result ) . not . toContain ( 'topics:' ) ;
2023+ } ) ;
2024+
2025+ it ( 'decodes PermissionedSenderAdded' , async ( ) => {
2026+ const result = await renderLogsSection (
2027+ [
2028+ {
2029+ emitter : AGENT_HUB ,
2030+ topics : [ PERMISSIONED_SENDER_ADDED , AGENT_ID_0 , SENDER_ADDRESS ] ,
2031+ data : '0x' ,
2032+ } ,
2033+ ] ,
2034+ INK_CHAIN_ID
2035+ ) ;
2036+ expect ( result ) . toContain ( 'PermissionedSenderAdded(' ) ;
2037+ expect ( result ) . not . toContain ( 'topics:' ) ;
2038+ } ) ;
2039+
2040+ it ( 'decodes PermissionedSenderRemoved' , async ( ) => {
2041+ const result = await renderLogsSection (
2042+ [
2043+ {
2044+ emitter : AGENT_HUB ,
2045+ topics : [ PERMISSIONED_SENDER_REMOVED , AGENT_ID_0 , SENDER_ADDRESS ] ,
2046+ data : '0x' ,
2047+ } ,
2048+ ] ,
2049+ INK_CHAIN_ID
2050+ ) ;
2051+ expect ( result ) . toContain ( 'PermissionedSenderRemoved(' ) ;
2052+ expect ( result ) . not . toContain ( 'topics:' ) ;
2053+ } ) ;
2054+
2055+ it ( 'decodes MaxBatchSizeSet' , async ( ) => {
2056+ const result = await renderLogsSection (
2057+ [ { emitter : AGENT_HUB , topics : [ MAX_BATCH_SIZE_SET , VALUE_255 ] , data : '0x' } ] ,
2058+ INK_CHAIN_ID
2059+ ) ;
2060+ expect ( result ) . toContain ( 'MaxBatchSizeSet(' ) ;
2061+ expect ( result ) . not . toContain ( 'topics:' ) ;
2062+ } ) ;
2063+
2064+ it ( 'decodes UpdateInjected' , async ( ) => {
2065+ const result = await renderLogsSection (
2066+ [
2067+ {
2068+ emitter : AGENT_HUB ,
2069+ topics : [ UPDATE_INJECTED , AGENT_ID_1 , MARKET_ADDRESS , UPDATE_TYPE_HASH ] ,
2070+ data :
2071+ '0x' +
2072+ '0000000000000000000000000000000000000000000000000000000000000001' + // updateId
2073+ '0000000000000000000000000000000000000000000000000000000000000040' + // offset for newValue bytes
2074+ '0000000000000000000000000000000000000000000000000000000000000004' + // length of newValue
2075+ '0000000000000000000000000000000000000000000000000000000000000000' , // newValue padded
2076+ } ,
2077+ ] ,
2078+ INK_CHAIN_ID
2079+ ) ;
2080+ expect ( result ) . toContain ( 'UpdateInjected(' ) ;
2081+ expect ( result ) . not . toContain ( 'topics:' ) ;
2082+ } ) ;
2083+
2084+ it ( 'decodes all agent hub events in a single batch' , async ( ) => {
2085+ const logs = [
2086+ { emitter : AGENT_HUB , topics : [ AGENT_REGISTERED , AGENT_ID_0 , RISK_ORACLE , UPDATE_TYPE_HASH ] , data : '0x' } ,
2087+ { emitter : AGENT_HUB , topics : [ AGENT_ADDRESS_SET , AGENT_ID_0 , AGENT_ADDRESS ] , data : '0x' } ,
2088+ { emitter : AGENT_HUB , topics : [ AGENT_ADMIN_SET , AGENT_ID_0 , ADMIN_ADDRESS ] , data : '0x' } ,
2089+ { emitter : AGENT_HUB , topics : [ AGENT_ENABLED_SET , AGENT_ID_0 , BOOL_TRUE ] , data : '0x' } ,
2090+ { emitter : AGENT_HUB , topics : [ AGENT_PERMISSIONED_STATUS_SET , AGENT_ID_0 , BOOL_FALSE ] , data : '0x' } ,
2091+ { emitter : AGENT_HUB , topics : [ MARKETS_FROM_AGENT_ENABLED , AGENT_ID_0 , BOOL_TRUE ] , data : '0x' } ,
2092+ { emitter : AGENT_HUB , topics : [ EXPIRATION_PERIOD_SET , AGENT_ID_0 , VALUE_1000 ] , data : '0x' } ,
2093+ { emitter : AGENT_HUB , topics : [ MINIMUM_DELAY_SET , AGENT_ID_0 , VALUE_1000 ] , data : '0x' } ,
2094+ { emitter : AGENT_HUB , topics : [ AGENT_CONTEXT_SET , AGENT_ID_0 , CONTEXT_HASH ] , data : '0x' } ,
2095+ { emitter : AGENT_HUB , topics : [ ALLOWED_MARKET_ADDED , AGENT_ID_0 , MARKET_ADDRESS ] , data : '0x' } ,
2096+ ] ;
2097+ const result = await renderLogsSection ( logs , INK_CHAIN_ID ) ;
2098+ expect ( result ) . toContain ( 'AgentRegistered(' ) ;
2099+ expect ( result ) . toContain ( 'AgentAddressSet(' ) ;
2100+ expect ( result ) . toContain ( 'AgentAdminSet(' ) ;
2101+ expect ( result ) . toContain ( 'AgentEnabledSet(' ) ;
2102+ expect ( result ) . toContain ( 'AgentPermissionedStatusSet(' ) ;
2103+ expect ( result ) . toContain ( 'MarketsFromAgentEnabled(' ) ;
2104+ expect ( result ) . toContain ( 'ExpirationPeriodSet(' ) ;
2105+ expect ( result ) . toContain ( 'MinimumDelaySet(' ) ;
2106+ expect ( result ) . toContain ( 'AgentContextSet(' ) ;
2107+ expect ( result ) . toContain ( 'AllowedMarketAdded(' ) ;
2108+ expect ( result ) . not . toContain ( 'topics:' ) ;
2109+ } ) ;
2110+ } ) ;
0 commit comments