diff --git a/contrib/opbot/botmd/commands.go b/contrib/opbot/botmd/commands.go index 0ca9c13a68..623431565a 100644 --- a/contrib/opbot/botmd/commands.go +++ b/contrib/opbot/botmd/commands.go @@ -310,7 +310,7 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition { return } - fastBridgeContractOrigin, fastBridgeContractDest, err := b.makeFastBridge(ctx.Context(), rawRequest) + fastBridgeContractOrigin, err := b.makeFastBridge(ctx.Context(), rawRequest.OriginChainID) if err != nil { _, err := ctx.Response().Reply(err.Error()) if err != nil { @@ -335,6 +335,15 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition { return } + fastBridgeContractDest, err := b.makeFastBridge(ctx.Context(), rawRequest.DestChainID) + if err != nil { + _, err := ctx.Response().Reply(err.Error()) + if err != nil { + log.Println(err) + } + return + } + isRelayed, err := fastBridgeContractDest.BridgeRelays(nil, [32]byte(common.Hex2Bytes(rawRequest.TxID))) if err != nil { _, err := ctx.Response().Reply("error fetching bridge relays") @@ -392,41 +401,34 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition { } } -// returns origin and dest fast bridge contracts -func (b *Bot) makeFastBridge(ctx context.Context, req *relapi.GetQuoteRequestResponse) (*fastbridge.FastBridge, *fastbridge.FastBridge, error) { +func (b *Bot) makeFastBridge(ctx context.Context, chainID uint32) (*fastbridge.FastBridge, error) { client, err := rfqClient.NewUnauthenticatedClient(b.handler, b.cfg.RFQApiURL) if err != nil { - return nil, nil, fmt.Errorf("error creating rfq client: %w", err) + return nil, fmt.Errorf("error creating rfq client: %w", err) } contracts, err := client.GetRFQContracts(ctx) if err != nil { - return nil, nil, fmt.Errorf("error fetching rfq contracts: %w", err) + return nil, fmt.Errorf("error fetching rfq contracts: %w", err) } - var fastBridges [2]*fastbridge.FastBridge - chainIDs := []uint32{req.OriginChainID, req.DestChainID} - - for i, chainID := range chainIDs { - chainClient, err := b.rpcClient.GetChainClient(ctx, int(chainID)) - if err != nil { - return nil, nil, fmt.Errorf("error getting chain client for chain ID %d: %w", chainID, err) - } - - contractAddress, ok := contracts.Contracts[chainID] - if !ok { - return nil, nil, fmt.Errorf("contract address not found for chain ID %d", chainID) - } + chainClient, err := b.rpcClient.GetChainClient(ctx, int(chainID)) + if err != nil { + return nil, fmt.Errorf("error getting chain client for chain ID %d: %w", chainID, err) + } - fastBridgeHandle, err := fastbridge.NewFastBridge(common.HexToAddress(contractAddress), chainClient) - if err != nil { - return nil, nil, fmt.Errorf("error creating fast bridge for chain ID %d: %w", chainID, err) - } + contractAddress, ok := contracts.Contracts[chainID] + if !ok { + return nil, fmt.Errorf("contract address not found for chain ID %d", chainID) + } - fastBridges[i] = fastBridgeHandle + fastBridgeHandle, err := fastbridge.NewFastBridge(common.HexToAddress(contractAddress), chainClient) + if err != nil { + return nil, fmt.Errorf("error creating fast bridge for chain ID %d: %w", chainID, err) } - return fastBridges[0], fastBridges[1], nil + return fastBridgeHandle, nil + } func getTxAge(ctx context.Context, client client.EVM, res *relapi.GetQuoteRequestResponse) string {