Skip to content

Commit

Permalink
naive
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 committed Jul 17, 2024
1 parent 116605f commit dd39ca3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"
"time"

"github.com/dustin/go-humanize"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -207,6 +208,8 @@ func (b *Bot) rfqLookupCommand() *slacker.CommandDefinition {
var slackBlocks []slack.Block

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

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L209

Added line #L209 was not covered by tests
for _, status := range statuses {

Check failure on line 210 in contrib/opbot/botmd/commands.go

View workflow job for this annotation

GitHub Actions / Lint (contrib/opbot)

unnecessary leading newline (whitespace)

// TODO: add CreatedAt field to GetQuoteRequestStatusResponse so we don't need to make network calls?
client, err := b.rpcClient.GetChainClient(ctx.Context(), int(status.OriginChainID))
if err != nil {
log.Printf("error getting chain client: %v\n", err)
Expand All @@ -216,14 +219,12 @@ func (b *Bot) rfqLookupCommand() *slacker.CommandDefinition {
if err != nil {
log.Printf("error getting transaction receipt: %v\n", err)
}

txBlockNum := receipt.BlockNumber.Uint64()
nowBlockNum, err := client.BlockByNumber(ctx.Context(), nil)
txBlock, err := client.BlockByHash(ctx.Context(), receipt.BlockHash)
if err != nil {
log.Printf("error getting block by number: %v\n", err)
log.Printf("error getting block by hash: %v\n", err)
}

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

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L218-L225

Added lines #L218 - L225 were not covered by tests

deltaBlockNumber := (nowBlockNum.NumberU64() - txBlockNum) * 12.0
txTime := time.Unix(int64(txBlock.Time()), 0)

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

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L227-L228

Added lines #L227 - L228 were not covered by tests
objects := []*slack.TextBlockObject{
{
Expand All @@ -244,7 +245,7 @@ func (b *Bot) rfqLookupCommand() *slacker.CommandDefinition {
},
{
Type: slack.MarkdownType,
Text: fmt.Sprintf("*Estimated Tx Age*: %d", deltaBlockNumber),
Text: fmt.Sprintf("*Estimated Tx Age*: %s", humanize.Time(txTime)),
},

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

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L246-L249

Added lines #L246 - L249 were not covered by tests
}

Expand Down

0 comments on commit dd39ca3

Please sign in to comment.