Skip to content

account/BridgeRelayer.hpp

Wires evmrelay burn events to MintFunds via shared EthWatchService. More...

Namespaces

Name
sgns

Classes

Name
class sgns::BridgeRelayer
Registers both BridgeSourceBurned (v1) and BridgeOutInitiated (v2) watches on a shared EthWatchService across multiple chains and calls MintFunds when burns are detected. OnWatchEvent dispatches on the variant type of values[5] to handle both event formats (D-06).

Detailed Description

Wires evmrelay burn events to MintFunds via shared EthWatchService.

Date: 2026-05-30

Source code

#ifndef SGNS_BRIDGE_RELAYER_HPP
#define SGNS_BRIDGE_RELAYER_HPP

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "account/ChainContractPair.hpp"
#include "account/ChainRpcEndpointProvider.hpp"
#include "account/TransactionManager.hpp"
#include "base/logger.hpp"
#include "eth/eth_watch_service.hpp"

class BridgeRelayerTestAccess;

namespace sgns
{
    class BridgeRelayer : public IBridgeInitObserver,
                          public std::enable_shared_from_this<BridgeRelayer>
    {
    public:
        static std::shared_ptr<BridgeRelayer> Create( std::weak_ptr<TransactionManager>     tx_manager,
                                                      std::shared_ptr<eth::EthWatchService> watch_service );

        void Start( std::vector<ChainContractPair> chains );

        void OnRpcEndpointsReady( std::vector<ChainContractPair> chains ) override;

        void Stop();

    private:
        friend class ::BridgeRelayerTestAccess;
        explicit BridgeRelayer( std::weak_ptr<TransactionManager>     tx_manager,
                                std::shared_ptr<eth::EthWatchService> watch_service,
                                base::Logger                          logger = nullptr );
        void OnWatchEvent( const eth::WatchEventNotification &notification, const std::string &chain_name );

        std::weak_ptr<TransactionManager> tx_manager_; 
        std::shared_ptr<eth::EthWatchService> watch_service_; 
        base::Logger                          logger_;        
        std::unordered_map<std::string, std::pair<eth::EventWatchId, eth::EventWatchId>> chain_watches_;
    };
} // namespace sgns

#endif // SGNS_BRIDGE_RELAYER_HPP

Updated on 2026-06-28 at 18:54:57 -0700