bar[123].str_two[true]();
Это называется извращением.
const items = document.querySelectorAll(`#Moscow_all_districts > [id]:not([id^="path"])`);
items.forEach(el => el.style.filter = 'grayscale(1)');
document.addEventListener('click', (e) => {
const id = e.target.id;
const allItems = document.querySelectorAll(`#Moscow_all_districts > #${id}:not([id^="path"])`);
allItems.forEach(el => el.style.filter = 'grayscale(0)');
allItems.forEach(el => el.style.fill = '#2859FF');
});
А почему бы не использовать оригинал? https://www.npmjs.com/package/web3
Сделай свою обёртку для реакта.