Skip to content

Commit

Permalink
feat(opbot): print explorer refund tx link (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 authored Sep 2, 2024
1 parent 7e0b8f1 commit 4a17c15
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/slack-go/slack"
"github.com/slack-io/slacker"
"github.com/synapsecns/sanguine/contrib/opbot/signoz"
"github.com/synapsecns/sanguine/core/retry"
"github.com/synapsecns/sanguine/ethergo/chaindata"
"github.com/synapsecns/sanguine/ethergo/client"
rfqClient "github.com/synapsecns/sanguine/services/rfq/api/client"
Expand Down Expand Up @@ -280,8 +281,9 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {

var rawRequest *relapi.GetQuoteRequestResponse
var err error
var relClient relapi.RelayerClient

Check warning on line 284 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L282-L284

Added lines #L282 - L284 were not covered by tests
for _, relayer := range b.cfg.RelayerURLS {
relClient := relapi.NewRelayerClient(b.handler, relayer)
relClient = relapi.NewRelayerClient(b.handler, relayer)
rawRequest, err = getQuoteRequest(ctx.Context(), relClient, tx)
if err == nil {
break

Check warning on line 289 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L286-L289

Added lines #L286 - L289 were not covered by tests
Expand Down Expand Up @@ -332,8 +334,29 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition {
return
}

Check warning on line 335 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L332-L335

Added lines #L332 - L335 were not covered by tests

// TODO: follow the lead of https://github.com/synapsecns/sanguine/pull/2845
_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted with nonce %d", nonce))
var txHash *relapi.TxHashByNonceResponse
err = retry.WithBackoff(
ctx.Context(),
func(ctx context.Context) error {
txHash, err = relClient.GetTxHashByNonce(ctx, &relapi.GetTxByNonceRequest{
ChainID: rawRequest.OriginChainID,
Nonce: nonce,
})
if err != nil {
return fmt.Errorf("error fetching quote request: %w", err)
}
return nil

Check warning on line 348 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L337-L348

Added lines #L337 - L348 were not covered by tests
},
retry.WithMaxAttempts(3),
retry.WithMaxAttemptTime(15*time.Second),
)
if err != nil {
_, err := ctx.Response().Reply(fmt.Sprintf("error fetching explorer link to refund, but nonce is %d", nonce))
log.Printf("error fetching quote request: %v\n", err)

Check warning on line 355 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L353-L355

Added lines #L353 - L355 were not covered by tests
return
}

_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toExplorerSlackLink(txHash.Hash)))
if err != nil {
log.Println(err)
}

Check warning on line 362 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L359-L362

Added lines #L359 - L362 were not covered by tests
Expand Down

0 comments on commit 4a17c15

Please sign in to comment.